Changeset 2833195
- Timestamp:
- 12/13/2022 06:27:00 PM (3 years ago)
- Location:
- content-visibility-date-and-time
- Files:
-
- 6 deleted
- 14 edited
- 1 copied
-
tags/0.1.3 (copied) (copied from content-visibility-date-and-time/trunk)
-
tags/0.1.3/build/index.asset.php (modified) (1 diff)
-
tags/0.1.3/build/index.css (modified) (1 diff)
-
tags/0.1.3/build/index.css.map (deleted)
-
tags/0.1.3/build/index.js (modified) (1 diff)
-
tags/0.1.3/build/index.js.map (deleted)
-
tags/0.1.3/build/style-index.css (modified) (1 diff)
-
tags/0.1.3/build/style-index.css.map (deleted)
-
tags/0.1.3/content-visibility-date-and-time.php (modified) (1 diff)
-
tags/0.1.3/includes/content-visibility-date-and-time.php (modified) (1 diff)
-
tags/0.1.3/readme.txt (modified) (2 diffs)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.css (modified) (1 diff)
-
trunk/build/index.css.map (deleted)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/build/index.js.map (deleted)
-
trunk/build/style-index.css (modified) (1 diff)
-
trunk/build/style-index.css.map (deleted)
-
trunk/content-visibility-date-and-time.php (modified) (1 diff)
-
trunk/includes/content-visibility-date-and-time.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
content-visibility-date-and-time/tags/0.1.3/build/index.asset.php
r2568526 r2833195 1 <?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins' , 'wp-polyfill'), 'version' => '5eaadffda77e9529b231cfc32d084c54');1 <?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins'), 'version' => '4da5dd48c0f56734789c'); -
content-visibility-date-and-time/tags/0.1.3/build/index.css
r2480205 r2833195 1 /* 2 As this button is a 'link' we tweak it to not have an underline as it looks super weird with an icon 3 */ 4 .content-visibility-schedule-controls .content-visibility-set-date-time.is-link { 5 text-decoration: none; 6 margin-left: -10px; } 7 8 /* 9 Button icon needs some room 10 */ 11 .content-visibility-schedule-controls .content-visibility-set-date-time span { 12 margin-right: 10px; } 13 14 .content-visibility-schedule-controls .components-dropdown { 15 margin: 1rem 0 0; } 16 17 /* 18 Tweak the 'clear' date and time button 19 */ 20 .content-visibility-schedule-controls .content-visibility-clear-date-time svg { 21 fill: transparent; } 22 23 /* 24 The DateTime Picker Popover needs some love 25 */ 26 .wp-admin .content-visibility-picker-popover .components-datetime__time { 27 padding: 1rem; 28 background: whitesmoke; } 29 30 .wp-admin .content-visibility-picker-popover .components-datetime__buttons { 31 display: none; } 32 33 .wp-admin .content-visibility-picker-popover .components-datetime__date { 34 padding-left: 17px; } 35 36 .wp-admin .content-visibility-picker-popover .CalendarMonth.CalendarMonth_1 { 37 padding: 0 !important; } 38 39 40 /*# sourceMappingURL=index.css.map*/ 1 .content-visibility-schedule-controls .content-visibility-set-date-time.is-link{margin-left:-10px;text-decoration:none}.content-visibility-schedule-controls .content-visibility-set-date-time span{margin-right:10px}.content-visibility-schedule-controls .components-dropdown{margin:1rem 0 0}.content-visibility-schedule-controls .content-visibility-clear-date-time svg{fill:transparent}.wp-admin .content-visibility-picker-popover .components-datetime__time{background:#f5f5f5;padding:1rem}.wp-admin .content-visibility-picker-popover .components-datetime__buttons{display:none}.wp-admin .content-visibility-picker-popover .components-datetime__date{padding-left:17px}.wp-admin .content-visibility-picker-popover .CalendarMonth.CalendarMonth_1{padding:0!important} -
content-visibility-date-and-time/tags/0.1.3/build/index.js
r2568526 r2833195 1 (window["webpackJsonp"] = window["webpackJsonp"] || []).push([["style-index"],{ 2 3 /***/ "./src/style.scss": 4 /*!************************!*\ 5 !*** ./src/style.scss ***! 6 \************************/ 7 /*! no static exports found */ 8 /***/ (function(module, exports, __webpack_require__) { 9 10 // extracted by mini-css-extract-plugin 11 12 /***/ }) 13 14 }]); 15 16 /******/ (function(modules) { // webpackBootstrap 17 /******/ // install a JSONP callback for chunk loading 18 /******/ function webpackJsonpCallback(data) { 19 /******/ var chunkIds = data[0]; 20 /******/ var moreModules = data[1]; 21 /******/ var executeModules = data[2]; 22 /******/ 23 /******/ // add "moreModules" to the modules object, 24 /******/ // then flag all "chunkIds" as loaded and fire callback 25 /******/ var moduleId, chunkId, i = 0, resolves = []; 26 /******/ for(;i < chunkIds.length; i++) { 27 /******/ chunkId = chunkIds[i]; 28 /******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) { 29 /******/ resolves.push(installedChunks[chunkId][0]); 30 /******/ } 31 /******/ installedChunks[chunkId] = 0; 32 /******/ } 33 /******/ for(moduleId in moreModules) { 34 /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { 35 /******/ modules[moduleId] = moreModules[moduleId]; 36 /******/ } 37 /******/ } 38 /******/ if(parentJsonpFunction) parentJsonpFunction(data); 39 /******/ 40 /******/ while(resolves.length) { 41 /******/ resolves.shift()(); 42 /******/ } 43 /******/ 44 /******/ // add entry modules from loaded chunk to deferred list 45 /******/ deferredModules.push.apply(deferredModules, executeModules || []); 46 /******/ 47 /******/ // run deferred modules when all chunks ready 48 /******/ return checkDeferredModules(); 49 /******/ }; 50 /******/ function checkDeferredModules() { 51 /******/ var result; 52 /******/ for(var i = 0; i < deferredModules.length; i++) { 53 /******/ var deferredModule = deferredModules[i]; 54 /******/ var fulfilled = true; 55 /******/ for(var j = 1; j < deferredModule.length; j++) { 56 /******/ var depId = deferredModule[j]; 57 /******/ if(installedChunks[depId] !== 0) fulfilled = false; 58 /******/ } 59 /******/ if(fulfilled) { 60 /******/ deferredModules.splice(i--, 1); 61 /******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); 62 /******/ } 63 /******/ } 64 /******/ 65 /******/ return result; 66 /******/ } 67 /******/ 68 /******/ // The module cache 69 /******/ var installedModules = {}; 70 /******/ 71 /******/ // object to store loaded and loading chunks 72 /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 73 /******/ // Promise = chunk loading, 0 = chunk loaded 74 /******/ var installedChunks = { 75 /******/ "index": 0 76 /******/ }; 77 /******/ 78 /******/ var deferredModules = []; 79 /******/ 80 /******/ // The require function 81 /******/ function __webpack_require__(moduleId) { 82 /******/ 83 /******/ // Check if module is in cache 84 /******/ if(installedModules[moduleId]) { 85 /******/ return installedModules[moduleId].exports; 86 /******/ } 87 /******/ // Create a new module (and put it into the cache) 88 /******/ var module = installedModules[moduleId] = { 89 /******/ i: moduleId, 90 /******/ l: false, 91 /******/ exports: {} 92 /******/ }; 93 /******/ 94 /******/ // Execute the module function 95 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 96 /******/ 97 /******/ // Flag the module as loaded 98 /******/ module.l = true; 99 /******/ 100 /******/ // Return the exports of the module 101 /******/ return module.exports; 102 /******/ } 103 /******/ 104 /******/ 105 /******/ // expose the modules object (__webpack_modules__) 106 /******/ __webpack_require__.m = modules; 107 /******/ 108 /******/ // expose the module cache 109 /******/ __webpack_require__.c = installedModules; 110 /******/ 111 /******/ // define getter function for harmony exports 112 /******/ __webpack_require__.d = function(exports, name, getter) { 113 /******/ if(!__webpack_require__.o(exports, name)) { 114 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 115 /******/ } 116 /******/ }; 117 /******/ 118 /******/ // define __esModule on exports 119 /******/ __webpack_require__.r = function(exports) { 120 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 121 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 122 /******/ } 123 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 124 /******/ }; 125 /******/ 126 /******/ // create a fake namespace object 127 /******/ // mode & 1: value is a module id, require it 128 /******/ // mode & 2: merge all properties of value into the ns 129 /******/ // mode & 4: return value when already ns object 130 /******/ // mode & 8|1: behave like require 131 /******/ __webpack_require__.t = function(value, mode) { 132 /******/ if(mode & 1) value = __webpack_require__(value); 133 /******/ if(mode & 8) return value; 134 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 135 /******/ var ns = Object.create(null); 136 /******/ __webpack_require__.r(ns); 137 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 138 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 139 /******/ return ns; 140 /******/ }; 141 /******/ 142 /******/ // getDefaultExport function for compatibility with non-harmony modules 143 /******/ __webpack_require__.n = function(module) { 144 /******/ var getter = module && module.__esModule ? 145 /******/ function getDefault() { return module['default']; } : 146 /******/ function getModuleExports() { return module; }; 147 /******/ __webpack_require__.d(getter, 'a', getter); 148 /******/ return getter; 149 /******/ }; 150 /******/ 151 /******/ // Object.prototype.hasOwnProperty.call 152 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 153 /******/ 154 /******/ // __webpack_public_path__ 155 /******/ __webpack_require__.p = ""; 156 /******/ 157 /******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; 158 /******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); 159 /******/ jsonpArray.push = webpackJsonpCallback; 160 /******/ jsonpArray = jsonpArray.slice(); 161 /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); 162 /******/ var parentJsonpFunction = oldJsonpFunction; 163 /******/ 164 /******/ 165 /******/ // add entry module to deferred list 166 /******/ deferredModules.push(["./src/index.js","style-index"]); 167 /******/ // run deferred modules when ready 168 /******/ return checkDeferredModules(); 169 /******/ }) 170 /************************************************************************/ 171 /******/ ({ 172 173 /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": 174 /*!*****************************************************************!*\ 175 !*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***! 176 \*****************************************************************/ 177 /*! no static exports found */ 178 /***/ (function(module, exports) { 179 180 function _arrayLikeToArray(arr, len) { 181 if (len == null || len > arr.length) len = arr.length; 182 183 for (var i = 0, arr2 = new Array(len); i < len; i++) { 184 arr2[i] = arr[i]; 185 } 186 187 return arr2; 188 } 189 190 module.exports = _arrayLikeToArray; 191 192 /***/ }), 193 194 /***/ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js": 195 /*!***************************************************************!*\ 196 !*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***! 197 \***************************************************************/ 198 /*! no static exports found */ 199 /***/ (function(module, exports) { 200 201 function _arrayWithHoles(arr) { 202 if (Array.isArray(arr)) return arr; 203 } 204 205 module.exports = _arrayWithHoles; 206 207 /***/ }), 208 209 /***/ "./node_modules/@babel/runtime/helpers/defineProperty.js": 210 /*!***************************************************************!*\ 211 !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! 212 \***************************************************************/ 213 /*! no static exports found */ 214 /***/ (function(module, exports) { 215 216 function _defineProperty(obj, key, value) { 217 if (key in obj) { 218 Object.defineProperty(obj, key, { 219 value: value, 220 enumerable: true, 221 configurable: true, 222 writable: true 223 }); 224 } else { 225 obj[key] = value; 226 } 227 228 return obj; 229 } 230 231 module.exports = _defineProperty; 232 233 /***/ }), 234 235 /***/ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js": 236 /*!*********************************************************************!*\ 237 !*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***! 238 \*********************************************************************/ 239 /*! no static exports found */ 240 /***/ (function(module, exports) { 241 242 function _iterableToArrayLimit(arr, i) { 243 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 244 var _arr = []; 245 var _n = true; 246 var _d = false; 247 var _e = undefined; 248 249 try { 250 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 251 _arr.push(_s.value); 252 253 if (i && _arr.length === i) break; 254 } 255 } catch (err) { 256 _d = true; 257 _e = err; 258 } finally { 259 try { 260 if (!_n && _i["return"] != null) _i["return"](); 261 } finally { 262 if (_d) throw _e; 263 } 264 } 265 266 return _arr; 267 } 268 269 module.exports = _iterableToArrayLimit; 270 271 /***/ }), 272 273 /***/ "./node_modules/@babel/runtime/helpers/nonIterableRest.js": 274 /*!****************************************************************!*\ 275 !*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***! 276 \****************************************************************/ 277 /*! no static exports found */ 278 /***/ (function(module, exports) { 279 280 function _nonIterableRest() { 281 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 282 } 283 284 module.exports = _nonIterableRest; 285 286 /***/ }), 287 288 /***/ "./node_modules/@babel/runtime/helpers/slicedToArray.js": 289 /*!**************************************************************!*\ 290 !*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***! 291 \**************************************************************/ 292 /*! no static exports found */ 293 /***/ (function(module, exports, __webpack_require__) { 294 295 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles */ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js"); 296 297 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit */ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"); 298 299 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"); 300 301 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest */ "./node_modules/@babel/runtime/helpers/nonIterableRest.js"); 302 303 function _slicedToArray(arr, i) { 304 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 305 } 306 307 module.exports = _slicedToArray; 308 309 /***/ }), 310 311 /***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js": 312 /*!***************************************************************************!*\ 313 !*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***! 314 \***************************************************************************/ 315 /*! no static exports found */ 316 /***/ (function(module, exports, __webpack_require__) { 317 318 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js"); 319 320 function _unsupportedIterableToArray(o, minLen) { 321 if (!o) return; 322 if (typeof o === "string") return arrayLikeToArray(o, minLen); 323 var n = Object.prototype.toString.call(o).slice(8, -1); 324 if (n === "Object" && o.constructor) n = o.constructor.name; 325 if (n === "Map" || n === "Set") return Array.from(o); 326 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 327 } 328 329 module.exports = _unsupportedIterableToArray; 330 331 /***/ }), 332 333 /***/ "./src/controls/content-visibility-date-time-controls.js": 334 /*!***************************************************************!*\ 335 !*** ./src/controls/content-visibility-date-time-controls.js ***! 336 \***************************************************************/ 337 /*! exports provided: ContentVisibilityDateTimeControls */ 338 /***/ (function(module, __webpack_exports__, __webpack_require__) { 339 340 "use strict"; 341 __webpack_require__.r(__webpack_exports__); 342 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ContentVisibilityDateTimeControls", function() { return ContentVisibilityDateTimeControls; }); 343 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"); 344 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__); 345 /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"); 346 /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__); 347 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 348 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); 349 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 350 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__); 351 /* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date"); 352 /* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__); 353 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 354 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__); 355 356 357 358 359 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 360 361 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 362 363 364 365 366 367 var ContentVisibilityDateTimeControls = function ContentVisibilityDateTimeControls(_ref) { 368 var rules = _ref.rules, 369 setAttributes = _ref.setAttributes, 370 attributes = _ref.attributes; 371 372 var _useState = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["useState"])(false), 373 _useState2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2), 374 openDatePopupForStart = _useState2[0], 375 setOpenDatePopupForStart = _useState2[1]; 376 377 var _useState3 = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["useState"])(false), 378 _useState4 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2), 379 openDatePopupForEnd = _useState4[0], 380 setOpenDatePopupForEnd = _useState4[1]; 381 /** 382 * Clear the date and time - resets to not having a value. 383 * 384 * @param {*} startOrEnd Are we resetting the start or end date. 385 * @param {*} rules The current ruleset for this block. 386 */ 387 388 389 var clearDateAndTime = function clearDateAndTime(startOrEnd, rules) { 390 setAttributes({ 391 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 392 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, startOrEnd, {})) 393 }) 394 }); 395 }; 396 /** 397 * DateTimePicker for the Start date/time. 398 */ 399 400 401 var ScheduleStartDateTime = function ScheduleStartDateTime() { 402 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["DateTimePicker"], { 403 currentDate: rules.dateTime.start, 404 onChange: function onChange(date) { 405 setAttributes({ 406 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 407 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, { 408 'start': date 409 }) 410 }) 411 }); 412 setOpenDatePopupForStart(false); 413 }, 414 is12Hour: false 415 }); 416 }; 417 /** 418 * DateTimePicker for the End date/time. 419 */ 420 421 422 var ScheduleEndDateTime = function ScheduleEndDateTime() { 423 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["DateTimePicker"], { 424 currentDate: rules.dateTime.end, 425 onChange: function onChange(date) { 426 setAttributes({ 427 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 428 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, { 429 'end': date 430 }) 431 }) 432 }); 433 setOpenDatePopupForEnd(false); 434 }, 435 is12Hour: false 436 }); 437 }; 438 439 var ClearCurrentDateTimeIcon = function ClearCurrentDateTimeIcon() { 440 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Icon"], { 441 icon: function icon() { 442 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("svg", { 443 xmlns: "http://www.w3.org/2000/svg", 444 width: "20", 445 height: "20", 446 viewBox: "0 0 24 24", 447 fill: "none", 448 stroke: "currentColor", 449 "stroke-width": "1", 450 "stroke-linecap": "round", 451 "stroke-linejoin": "round", 452 class: "feather feather-x-circle" 453 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("circle", { 454 cx: "12", 455 cy: "12", 456 r: "10" 457 }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("line", { 458 x1: "15", 459 y1: "9", 460 x2: "9", 461 y2: "15" 462 }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("line", { 463 x1: "9", 464 y1: "9", 465 x2: "15", 466 y2: "15" 467 })); 468 } 469 }); 470 }; 471 /** 472 * Output the Scheduling controls 473 */ 474 475 476 var ContentVisibilityScheduleControls = function ContentVisibilityScheduleControls() { 477 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 478 className: "content-visibility-schedule-controls" 479 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 480 className: "components-dropdown" 481 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 482 isLink: true, 483 className: "content-visibility-set-date-time", 484 icon: "calendar-alt", 485 onClick: function onClick() { 486 return setOpenDatePopupForStart(!openDatePopupForStart); 487 } 488 }, rules.dateTime.start && typeof rules.dateTime.start === 'string' ? Object(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__["dateI18n"])('D M j Y, G:i', rules.dateTime.start) : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])("Set Start Date/Time")), openDatePopupForStart && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Popover"], { 489 position: "middle left", 490 className: "content-visibility-picker-popover content-visibility-picker-popover-start", 491 onClose: setOpenDatePopupForStart.bind(null, false) 492 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ScheduleStartDateTime, null)), rules.dateTime.start && typeof rules.dateTime.start === 'string' && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 493 isLink: true, 494 label: "Clear date and time", 495 className: "content-visibility-clear-date-time", 496 onClick: function onClick() { 497 clearDateAndTime('start', rules); 498 } 499 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ClearCurrentDateTimeIcon, null))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 500 className: "components-dropdown" 501 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 502 isLink: true, 503 className: "content-visibility-set-date-time", 504 icon: "calendar-alt", 505 onClick: function onClick() { 506 return setOpenDatePopupForEnd(!openDatePopupForEnd); 507 } 508 }, rules.dateTime.end && typeof rules.dateTime.end === 'string' ? Object(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__["dateI18n"])('D M j Y, G:i', rules.dateTime.end) : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])("Set End Date/Time")), openDatePopupForEnd && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Popover"], { 509 position: "middle left", 510 className: "content-visibility-picker-popover content-visibility-picker-popover-end", 511 onClose: setOpenDatePopupForEnd.bind(null, false) 512 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ScheduleEndDateTime, null)), rules.dateTime.end && typeof rules.dateTime.end === 'string' && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 513 isLink: true, 514 label: "Clear date and time", 515 className: "content-visibility-clear-date-time", 516 onClick: function onClick() { 517 clearDateAndTime('end', rules); 518 } 519 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ClearCurrentDateTimeIcon, null))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("p", { 520 className: "date-time-help-intro content-visibility-help-text" 521 }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])('Set start and/or end dates for when this block will be ' + attributes.contentVisibility + '. Not selecting either date will mean this block is ' + attributes.contentVisibility + ' at all times.'))); 522 }; 523 524 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ContentVisibilityScheduleControls, null); 525 }; 526 527 /***/ }), 528 529 /***/ "./src/controls/content-visibility-date-time-panel-body.js": 530 /*!*****************************************************************!*\ 531 !*** ./src/controls/content-visibility-date-time-panel-body.js ***! 532 \*****************************************************************/ 533 /*! exports provided: default */ 534 /***/ (function(module, __webpack_exports__, __webpack_require__) { 535 536 "use strict"; 537 __webpack_require__.r(__webpack_exports__); 538 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 539 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 540 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 541 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__); 542 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 543 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); 544 /* harmony import */ var _content_visibility_date_time_controls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./content-visibility-date-time-controls */ "./src/controls/content-visibility-date-time-controls.js"); 545 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 546 547 548 549 550 551 552 function ContentVisibilityDateTimePanelBodyControl(_ref) { 553 var setAttributes = _ref.setAttributes, 554 attributes = _ref.attributes; 555 var rules = attributes.contentVisibilityRules; 556 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_4__["default"])(attributes, 'dateTime') ? ' has-active-rules' : ''; 557 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelBody"], { 558 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Date and Time', 'content-visibility-date-time'), 559 initialOpen: false, 560 className: "content-visibility-control-panel block-visibility-date-time-controls" + hasRulesClass 561 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_controls__WEBPACK_IMPORTED_MODULE_3__["ContentVisibilityDateTimeControls"], { 562 rules: rules, 563 setAttributes: setAttributes, 564 attributes: attributes 565 }))); 566 } 567 568 /* harmony default export */ __webpack_exports__["default"] = (ContentVisibilityDateTimePanelBodyControl); 569 570 /***/ }), 571 572 /***/ "./src/controls/content-visibility-date-time.js": 573 /*!******************************************************!*\ 574 !*** ./src/controls/content-visibility-date-time.js ***! 575 \******************************************************/ 576 /*! exports provided: ContentVisibilityDateTimeControl */ 577 /***/ (function(module, __webpack_exports__, __webpack_require__) { 578 579 "use strict"; 580 __webpack_require__.r(__webpack_exports__); 581 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ContentVisibilityDateTimeControl", function() { return ContentVisibilityDateTimeControl; }); 582 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 583 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 584 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 585 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__); 586 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 587 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); 588 /* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins"); 589 /* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__); 590 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 591 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__); 592 /* harmony import */ var _content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./content-visibility-date-time-panel-body */ "./src/controls/content-visibility-date-time-panel-body.js"); 593 594 595 596 597 598 599 function ContentVisibilityDateTimeControl(data) { 600 var rulesEnabled = data.attributes.contentVisibilityRules.contentVisibilityRulesEnabled; 601 var contentVisibility = data.attributes.hasOwnProperty('contentVisibility'); 602 603 if (!rulesEnabled || !contentVisibility) { 604 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["Disabled"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__["default"], { 605 setAttributes: data.setAttributes, 606 attributes: data.attributes 607 })); 608 } 609 610 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__["default"], { 611 setAttributes: data.setAttributes, 612 attributes: data.attributes 613 }); 614 } 615 /** 616 * Render the <ContentVisibilityDateTimeControl> component by adding 617 * it to the block-visibility-extra-controls Fill. 618 * 619 * @return {Object} A Fill component wrapping the ContentVisibilityDateTimeControl component. 620 */ 621 622 function ContentVisibilityDateTimeFill() { 623 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["Fill"], { 624 name: "content-visibility-extra-controls" 625 }, function (fillProps) { 626 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(ContentVisibilityDateTimeControl, { 627 setAttributes: fillProps.setAttributes, 628 attributes: fillProps.attributes 629 }); 630 }); 631 } // Add our component to the Slot provided by BlockVisibilityControls 632 633 634 Object(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__["registerPlugin"])('content-visibility-03-date-time-fill', { 635 render: ContentVisibilityDateTimeFill 636 }); // Register our visibility rule with the main plugin 637 638 Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__["addFilter"])('contentVisibility.defaultContentVisibilityRules', 'content-visibility-date-time/block-visibility-rules', registerDateTimeContentVisibilityRule); 639 640 function registerDateTimeContentVisibilityRule(defaultRules) { 641 defaultRules.dateTime = { 642 start: {}, 643 end: {} 644 }; 645 return defaultRules; 646 } 647 648 /***/ }), 649 650 /***/ "./src/editor.scss": 651 /*!*************************!*\ 652 !*** ./src/editor.scss ***! 653 \*************************/ 654 /*! no static exports found */ 655 /***/ (function(module, exports, __webpack_require__) { 656 657 // extracted by mini-css-extract-plugin 658 659 /***/ }), 660 661 /***/ "./src/helpers/has-rules.js": 662 /*!**********************************!*\ 663 !*** ./src/helpers/has-rules.js ***! 664 \**********************************/ 665 /*! exports provided: default */ 666 /***/ (function(module, __webpack_exports__, __webpack_require__) { 667 668 "use strict"; 669 __webpack_require__.r(__webpack_exports__); 670 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 671 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 672 673 /** 674 * Determine if the passed block props contain rules of the passed type. 675 * 676 * @param {object} props The currently selected block's props. 677 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 678 * 679 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 680 */ 681 682 function hasRules(props, type) { 683 if (!props.contentVisibilityRules) { 684 return false; 685 } 686 687 if (!props.contentVisibilityRules[type]) { 688 return false; 689 } // Default to false. Passed through a filter later. 690 691 692 var hasRules = false; 693 694 switch (type) { 695 case 'dateTime': 696 if (props.contentVisibilityRules[type] && props.contentVisibilityRules[type]['start'] && Object.keys(props.contentVisibilityRules[type]['start']).length !== 0) { 697 hasRules = true; 698 } 699 700 if (props.contentVisibilityRules[type] && props.contentVisibilityRules[type]['end'] && Object.keys(props.contentVisibilityRules[type]['end']).length !== 0) { 701 hasRules = true; 702 } 703 704 break; 705 706 default: 707 break; 708 } 709 710 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 711 } // end hasRules() 712 713 714 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 715 716 /***/ }), 717 718 /***/ "./src/index.js": 719 /*!**********************!*\ 720 !*** ./src/index.js ***! 721 \**********************/ 722 /*! no exports provided */ 723 /***/ (function(module, __webpack_exports__, __webpack_require__) { 724 725 "use strict"; 726 __webpack_require__.r(__webpack_exports__); 727 /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); 728 /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_editor_scss__WEBPACK_IMPORTED_MODULE_0__); 729 /* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); 730 /* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_scss__WEBPACK_IMPORTED_MODULE_1__); 731 /* harmony import */ var _controls_content_visibility_date_time__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/content-visibility-date-time */ "./src/controls/content-visibility-date-time.js"); 732 733 734 735 736 /***/ }), 737 738 /***/ "@wordpress/components": 739 /*!*********************************************!*\ 740 !*** external {"this":["wp","components"]} ***! 741 \*********************************************/ 742 /*! no static exports found */ 743 /***/ (function(module, exports) { 744 745 (function() { module.exports = this["wp"]["components"]; }()); 746 747 /***/ }), 748 749 /***/ "@wordpress/date": 750 /*!***************************************!*\ 751 !*** external {"this":["wp","date"]} ***! 752 \***************************************/ 753 /*! no static exports found */ 754 /***/ (function(module, exports) { 755 756 (function() { module.exports = this["wp"]["date"]; }()); 757 758 /***/ }), 759 760 /***/ "@wordpress/element": 761 /*!******************************************!*\ 762 !*** external {"this":["wp","element"]} ***! 763 \******************************************/ 764 /*! no static exports found */ 765 /***/ (function(module, exports) { 766 767 (function() { module.exports = this["wp"]["element"]; }()); 768 769 /***/ }), 770 771 /***/ "@wordpress/hooks": 772 /*!****************************************!*\ 773 !*** external {"this":["wp","hooks"]} ***! 774 \****************************************/ 775 /*! no static exports found */ 776 /***/ (function(module, exports) { 777 778 (function() { module.exports = this["wp"]["hooks"]; }()); 779 780 /***/ }), 781 782 /***/ "@wordpress/i18n": 783 /*!***************************************!*\ 784 !*** external {"this":["wp","i18n"]} ***! 785 \***************************************/ 786 /*! no static exports found */ 787 /***/ (function(module, exports) { 788 789 (function() { module.exports = this["wp"]["i18n"]; }()); 790 791 /***/ }), 792 793 /***/ "@wordpress/plugins": 794 /*!******************************************!*\ 795 !*** external {"this":["wp","plugins"]} ***! 796 \******************************************/ 797 /*! no static exports found */ 798 /***/ (function(module, exports) { 799 800 (function() { module.exports = this["wp"]["plugins"]; }()); 801 802 /***/ }) 803 804 /******/ }); 805 //# sourceMappingURL=index.js.map 1 (()=>{"use strict";var t,e={996:()=>{const t=window.wp.element,e=window.wp.components,i=window.wp.i18n,n=window.wp.plugins,l=window.wp.hooks,s=window.wp.date,r=n=>{let{rules:l,setAttributes:r,attributes:a}=n;const[o,c]=(0,t.useState)(!1),[u,d]=(0,t.useState)(!1),b=(t,e)=>{r({contentVisibilityRules:{...e,dateTime:{...e.dateTime,[t]:null}}})},m=()=>(0,t.createElement)(e.DateTimePicker,{currentDate:l.dateTime.start,onChange:t=>{r({contentVisibilityRules:{...l,dateTime:{...l.dateTime,start:t}}}),c(!1)},is12Hour:!1}),y=()=>(0,t.createElement)(e.DateTimePicker,{currentDate:l.dateTime.end,onChange:t=>{r({contentVisibilityRules:{...l,dateTime:{...l.dateTime,end:t}}}),d(!1)},is12Hour:!1}),p=()=>(0,t.createElement)(e.Icon,{icon:()=>(0,t.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x-circle"},(0,t.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.createElement)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,t.createElement)("line",{x1:"9",y1:"9",x2:"15",y2:"15"}))});return(0,t.createElement)((()=>(0,t.createElement)("div",{className:"content-visibility-schedule-controls"},(0,t.createElement)("div",{className:"components-dropdown"},(0,t.createElement)(e.Button,{isLink:!0,className:"content-visibility-set-date-time",icon:"calendar-alt",onClick:()=>c(!o)},l.dateTime.start&&"string"==typeof l.dateTime.start?(0,s.dateI18n)("D M j Y, G:i",l.dateTime.start):(0,i.__)("Set Start Date/Time")),o&&(0,t.createElement)(e.Popover,{position:"middle left",className:"content-visibility-picker-popover content-visibility-picker-popover-start",onClose:c.bind(null,!1)},(0,t.createElement)(m,null)),l.dateTime.start&&"string"==typeof l.dateTime.start&&(0,t.createElement)(e.Button,{isLink:!0,label:"Clear date and time",className:"content-visibility-clear-date-time",onClick:()=>{b("start",l)}},(0,t.createElement)(p,null))),(0,t.createElement)("div",{className:"components-dropdown"},(0,t.createElement)(e.Button,{isLink:!0,className:"content-visibility-set-date-time",icon:"calendar-alt",onClick:()=>d(!u)},l.dateTime.end&&"string"==typeof l.dateTime.end?(0,s.dateI18n)("D M j Y, G:i",l.dateTime.end):(0,i.__)("Set End Date/Time")),u&&(0,t.createElement)(e.Popover,{position:"middle left",className:"content-visibility-picker-popover content-visibility-picker-popover-end",onClose:d.bind(null,!1)},(0,t.createElement)(y,null)),l.dateTime.end&&"string"==typeof l.dateTime.end&&(0,t.createElement)(e.Button,{isLink:!0,label:"Clear date and time",className:"content-visibility-clear-date-time",onClick:()=>{b("end",l)}},(0,t.createElement)(p,null))),(0,t.createElement)("p",{className:"date-time-help-intro content-visibility-help-text"},(0,i.__)("Set start and/or end dates for when this block will be "+a.contentVisibility+". Not selecting either date will mean this block is "+a.contentVisibility+" at all times.")))),null)},a=function(n){let{setAttributes:s,attributes:a}=n,o=a.contentVisibilityRules,c=function(t,e){if(!t.contentVisibilityRules)return!1;if(!t.contentVisibilityRules[e])return!1;let i=!1;return"dateTime"===e&&(t.contentVisibilityRules[e]&&t.contentVisibilityRules[e].start&&0!==Object.keys(t.contentVisibilityRules[e].start).length&&(i=!0),t.contentVisibilityRules[e]&&t.contentVisibilityRules[e].end&&0!==Object.keys(t.contentVisibilityRules[e].end).length&&(i=!0)),(0,l.applyFilters)("content-visibility-has-rules",i,t,e)}(a,"dateTime")?" has-active-rules":"";return(0,t.createElement)(e.PanelBody,{title:(0,i.__)("Date and Time","content-visibility-date-time"),initialOpen:!1,className:"content-visibility-control-panel block-visibility-date-time-controls"+c},(0,t.createElement)(e.PanelRow,null,(0,t.createElement)(r,{rules:o,setAttributes:s,attributes:a})))};function o(i){let n=i.attributes.contentVisibilityRules.contentVisibilityRulesEnabled,l=i.attributes.hasOwnProperty("contentVisibility");return n&&l?(0,t.createElement)(a,{setAttributes:i.setAttributes,attributes:i.attributes}):(0,t.createElement)(e.Disabled,null,(0,t.createElement)(a,{setAttributes:i.setAttributes,attributes:i.attributes}))}(0,n.registerPlugin)("content-visibility-03-date-time-fill",{render:function(){return(0,t.createElement)(e.Fill,{name:"content-visibility-extra-controls"},(e=>(0,t.createElement)(o,{setAttributes:e.setAttributes,attributes:e.attributes})))}}),(0,l.addFilter)("contentVisibility.defaultContentVisibilityRules","content-visibility-date-time/block-visibility-rules",(function(t){return t.dateTime={start:null,end:null},t})),(0,l.addFilter)("blocks.registerBlockType","content-visibility/dateTimeAttributesDeprecation",(function(t){if(!t.attributes.contentVisibilityRules.default.dateTime)return t;const e={attributes:{...t.attributes,contentVisibilityRules:{...t.attributes.contentVisibilityRules,default:{...t.attributes.contentVisibilityRules.default,dateTime:{end:{},start:{}}}}},supports:t.supports,save:t.save,migrate:t=>({...t,contentVisibilityRules:{...t.contentVisibilityRules,dateTime:{end:null,start:null}}}),isEligible:t=>t&&t.contentVisibilityRules&&t.contentVisibilityRules.dateTime&&t.contentVisibilityRules.dateTime.start&&Object.getPrototypeOf(t.contentVisibilityRules.dateTime.start)===Object.prototype&&0===Object.keys(t.contentVisibilityRules.dateTime.start).length};return t.deprecated=t.deprecated&&Array.isArray(t.deprecated)?[...t.deprecated,e]:[e],t}),99)}},i={};function n(t){var l=i[t];if(void 0!==l)return l.exports;var s=i[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.m=e,t=[],n.O=(e,i,l,s)=>{if(!i){var r=1/0;for(u=0;u<t.length;u++){for(var[i,l,s]=t[u],a=!0,o=0;o<i.length;o++)(!1&s||r>=s)&&Object.keys(n.O).every((t=>n.O[t](i[o])))?i.splice(o--,1):(a=!1,s<r&&(r=s));if(a){t.splice(u--,1);var c=l();void 0!==c&&(e=c)}}return e}s=s||0;for(var u=t.length;u>0&&t[u-1][2]>s;u--)t[u]=t[u-1];t[u]=[i,l,s]},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={826:0,431:0};n.O.j=e=>0===t[e];var e=(e,i)=>{var l,s,[r,a,o]=i,c=0;if(r.some((e=>0!==t[e]))){for(l in a)n.o(a,l)&&(n.m[l]=a[l]);if(o)var u=o(n)}for(e&&e(i);c<r.length;c++)s=r[c],n.o(t,s)&&t[s]&&t[s][0](),t[s]=0;return n.O(u)},i=globalThis.webpackChunkcontent_visibility_user_role=globalThis.webpackChunkcontent_visibility_user_role||[];i.forEach(e.bind(null,0)),i.push=e.bind(null,i.push.bind(i))})();var l=n.O(void 0,[431],(()=>n(996)));l=n.O(l)})(); -
content-visibility-date-and-time/tags/0.1.3/build/style-index.css
r2480205 r2833195 1 1 2 3 /*# sourceMappingURL=style-index.css.map*/ -
content-visibility-date-and-time/tags/0.1.3/content-visibility-date-and-time.php
r2568526 r2833195 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Schedule showing or hiding specific content blocks. 14 * Version: 0.1. 214 * Version: 0.1.3 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-date-and-time/tags/0.1.3/includes/content-visibility-date-and-time.php
r2480205 r2833195 23 23 */ 24 24 function enqueue_editor_assets() { // phpcs:ignore 25 26 $prereqs = array( 27 'wp-blocks', 28 'wp-i18n', 29 'wp-element', 30 'wp-plugins', 31 'wp-dom-ready', 32 ); 33 34 // The 5.8 widgets screen requires a special editor?! Feelsbadman. 35 $CVEditor = new \RichardTape\ContentVisibility\Editor(); 36 if ( $CVEditor->on_widgets_screen() ) { 37 $prereqs[] = 'wp-edit-widgets'; 38 } else { 39 $prereqs[] = 'wp-editor'; 40 } 25 41 26 42 wp_register_script( 27 43 'content-visibility-date-and-time', 28 44 plugins_url( '/build/index.js', dirname( __FILE__ ) ), 29 array( 30 'wp-blocks', 31 'wp-i18n', 32 'wp-element', 33 'wp-editor', 34 'wp-plugins', 35 'wp-edit-post', 36 ), 45 $prereqs, 37 46 filemtime( plugin_dir_path( __DIR__ ) . 'build/index.js' ), 38 47 true -
content-visibility-date-and-time/tags/0.1.3/readme.txt
r2568526 r2833195 4 4 Tags: contentvisibility, block, content, visibility, date, time 5 5 Requires at least: 5.0 6 Tested up to: 5.8.07 Stable tag: 0.1. 26 Tested up to: 6.1.1 7 Stable tag: 0.1.3 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 35 35 == Changelog == 36 36 37 = 0.1.3 = 38 * WP 6.1.1 compatibility. 39 * Fixed warning in widgets screen to do with loading the wrong editor. 40 * Fixed date popup not showing correctly due to changes in the underlying DateTime component. props kelvinxu. 41 37 42 = 0.1.2 = 38 43 * Added indicator to show when Date/Time rules are present for a block to make it easier to see when a block has rules. -
content-visibility-date-and-time/trunk/build/index.asset.php
r2568526 r2833195 1 <?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins' , 'wp-polyfill'), 'version' => '5eaadffda77e9529b231cfc32d084c54');1 <?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins'), 'version' => '4da5dd48c0f56734789c'); -
content-visibility-date-and-time/trunk/build/index.css
r2480205 r2833195 1 /* 2 As this button is a 'link' we tweak it to not have an underline as it looks super weird with an icon 3 */ 4 .content-visibility-schedule-controls .content-visibility-set-date-time.is-link { 5 text-decoration: none; 6 margin-left: -10px; } 7 8 /* 9 Button icon needs some room 10 */ 11 .content-visibility-schedule-controls .content-visibility-set-date-time span { 12 margin-right: 10px; } 13 14 .content-visibility-schedule-controls .components-dropdown { 15 margin: 1rem 0 0; } 16 17 /* 18 Tweak the 'clear' date and time button 19 */ 20 .content-visibility-schedule-controls .content-visibility-clear-date-time svg { 21 fill: transparent; } 22 23 /* 24 The DateTime Picker Popover needs some love 25 */ 26 .wp-admin .content-visibility-picker-popover .components-datetime__time { 27 padding: 1rem; 28 background: whitesmoke; } 29 30 .wp-admin .content-visibility-picker-popover .components-datetime__buttons { 31 display: none; } 32 33 .wp-admin .content-visibility-picker-popover .components-datetime__date { 34 padding-left: 17px; } 35 36 .wp-admin .content-visibility-picker-popover .CalendarMonth.CalendarMonth_1 { 37 padding: 0 !important; } 38 39 40 /*# sourceMappingURL=index.css.map*/ 1 .content-visibility-schedule-controls .content-visibility-set-date-time.is-link{margin-left:-10px;text-decoration:none}.content-visibility-schedule-controls .content-visibility-set-date-time span{margin-right:10px}.content-visibility-schedule-controls .components-dropdown{margin:1rem 0 0}.content-visibility-schedule-controls .content-visibility-clear-date-time svg{fill:transparent}.wp-admin .content-visibility-picker-popover .components-datetime__time{background:#f5f5f5;padding:1rem}.wp-admin .content-visibility-picker-popover .components-datetime__buttons{display:none}.wp-admin .content-visibility-picker-popover .components-datetime__date{padding-left:17px}.wp-admin .content-visibility-picker-popover .CalendarMonth.CalendarMonth_1{padding:0!important} -
content-visibility-date-and-time/trunk/build/index.js
r2568526 r2833195 1 (window["webpackJsonp"] = window["webpackJsonp"] || []).push([["style-index"],{ 2 3 /***/ "./src/style.scss": 4 /*!************************!*\ 5 !*** ./src/style.scss ***! 6 \************************/ 7 /*! no static exports found */ 8 /***/ (function(module, exports, __webpack_require__) { 9 10 // extracted by mini-css-extract-plugin 11 12 /***/ }) 13 14 }]); 15 16 /******/ (function(modules) { // webpackBootstrap 17 /******/ // install a JSONP callback for chunk loading 18 /******/ function webpackJsonpCallback(data) { 19 /******/ var chunkIds = data[0]; 20 /******/ var moreModules = data[1]; 21 /******/ var executeModules = data[2]; 22 /******/ 23 /******/ // add "moreModules" to the modules object, 24 /******/ // then flag all "chunkIds" as loaded and fire callback 25 /******/ var moduleId, chunkId, i = 0, resolves = []; 26 /******/ for(;i < chunkIds.length; i++) { 27 /******/ chunkId = chunkIds[i]; 28 /******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) { 29 /******/ resolves.push(installedChunks[chunkId][0]); 30 /******/ } 31 /******/ installedChunks[chunkId] = 0; 32 /******/ } 33 /******/ for(moduleId in moreModules) { 34 /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { 35 /******/ modules[moduleId] = moreModules[moduleId]; 36 /******/ } 37 /******/ } 38 /******/ if(parentJsonpFunction) parentJsonpFunction(data); 39 /******/ 40 /******/ while(resolves.length) { 41 /******/ resolves.shift()(); 42 /******/ } 43 /******/ 44 /******/ // add entry modules from loaded chunk to deferred list 45 /******/ deferredModules.push.apply(deferredModules, executeModules || []); 46 /******/ 47 /******/ // run deferred modules when all chunks ready 48 /******/ return checkDeferredModules(); 49 /******/ }; 50 /******/ function checkDeferredModules() { 51 /******/ var result; 52 /******/ for(var i = 0; i < deferredModules.length; i++) { 53 /******/ var deferredModule = deferredModules[i]; 54 /******/ var fulfilled = true; 55 /******/ for(var j = 1; j < deferredModule.length; j++) { 56 /******/ var depId = deferredModule[j]; 57 /******/ if(installedChunks[depId] !== 0) fulfilled = false; 58 /******/ } 59 /******/ if(fulfilled) { 60 /******/ deferredModules.splice(i--, 1); 61 /******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); 62 /******/ } 63 /******/ } 64 /******/ 65 /******/ return result; 66 /******/ } 67 /******/ 68 /******/ // The module cache 69 /******/ var installedModules = {}; 70 /******/ 71 /******/ // object to store loaded and loading chunks 72 /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 73 /******/ // Promise = chunk loading, 0 = chunk loaded 74 /******/ var installedChunks = { 75 /******/ "index": 0 76 /******/ }; 77 /******/ 78 /******/ var deferredModules = []; 79 /******/ 80 /******/ // The require function 81 /******/ function __webpack_require__(moduleId) { 82 /******/ 83 /******/ // Check if module is in cache 84 /******/ if(installedModules[moduleId]) { 85 /******/ return installedModules[moduleId].exports; 86 /******/ } 87 /******/ // Create a new module (and put it into the cache) 88 /******/ var module = installedModules[moduleId] = { 89 /******/ i: moduleId, 90 /******/ l: false, 91 /******/ exports: {} 92 /******/ }; 93 /******/ 94 /******/ // Execute the module function 95 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 96 /******/ 97 /******/ // Flag the module as loaded 98 /******/ module.l = true; 99 /******/ 100 /******/ // Return the exports of the module 101 /******/ return module.exports; 102 /******/ } 103 /******/ 104 /******/ 105 /******/ // expose the modules object (__webpack_modules__) 106 /******/ __webpack_require__.m = modules; 107 /******/ 108 /******/ // expose the module cache 109 /******/ __webpack_require__.c = installedModules; 110 /******/ 111 /******/ // define getter function for harmony exports 112 /******/ __webpack_require__.d = function(exports, name, getter) { 113 /******/ if(!__webpack_require__.o(exports, name)) { 114 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 115 /******/ } 116 /******/ }; 117 /******/ 118 /******/ // define __esModule on exports 119 /******/ __webpack_require__.r = function(exports) { 120 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 121 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 122 /******/ } 123 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 124 /******/ }; 125 /******/ 126 /******/ // create a fake namespace object 127 /******/ // mode & 1: value is a module id, require it 128 /******/ // mode & 2: merge all properties of value into the ns 129 /******/ // mode & 4: return value when already ns object 130 /******/ // mode & 8|1: behave like require 131 /******/ __webpack_require__.t = function(value, mode) { 132 /******/ if(mode & 1) value = __webpack_require__(value); 133 /******/ if(mode & 8) return value; 134 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 135 /******/ var ns = Object.create(null); 136 /******/ __webpack_require__.r(ns); 137 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 138 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 139 /******/ return ns; 140 /******/ }; 141 /******/ 142 /******/ // getDefaultExport function for compatibility with non-harmony modules 143 /******/ __webpack_require__.n = function(module) { 144 /******/ var getter = module && module.__esModule ? 145 /******/ function getDefault() { return module['default']; } : 146 /******/ function getModuleExports() { return module; }; 147 /******/ __webpack_require__.d(getter, 'a', getter); 148 /******/ return getter; 149 /******/ }; 150 /******/ 151 /******/ // Object.prototype.hasOwnProperty.call 152 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 153 /******/ 154 /******/ // __webpack_public_path__ 155 /******/ __webpack_require__.p = ""; 156 /******/ 157 /******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; 158 /******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); 159 /******/ jsonpArray.push = webpackJsonpCallback; 160 /******/ jsonpArray = jsonpArray.slice(); 161 /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); 162 /******/ var parentJsonpFunction = oldJsonpFunction; 163 /******/ 164 /******/ 165 /******/ // add entry module to deferred list 166 /******/ deferredModules.push(["./src/index.js","style-index"]); 167 /******/ // run deferred modules when ready 168 /******/ return checkDeferredModules(); 169 /******/ }) 170 /************************************************************************/ 171 /******/ ({ 172 173 /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": 174 /*!*****************************************************************!*\ 175 !*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***! 176 \*****************************************************************/ 177 /*! no static exports found */ 178 /***/ (function(module, exports) { 179 180 function _arrayLikeToArray(arr, len) { 181 if (len == null || len > arr.length) len = arr.length; 182 183 for (var i = 0, arr2 = new Array(len); i < len; i++) { 184 arr2[i] = arr[i]; 185 } 186 187 return arr2; 188 } 189 190 module.exports = _arrayLikeToArray; 191 192 /***/ }), 193 194 /***/ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js": 195 /*!***************************************************************!*\ 196 !*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***! 197 \***************************************************************/ 198 /*! no static exports found */ 199 /***/ (function(module, exports) { 200 201 function _arrayWithHoles(arr) { 202 if (Array.isArray(arr)) return arr; 203 } 204 205 module.exports = _arrayWithHoles; 206 207 /***/ }), 208 209 /***/ "./node_modules/@babel/runtime/helpers/defineProperty.js": 210 /*!***************************************************************!*\ 211 !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! 212 \***************************************************************/ 213 /*! no static exports found */ 214 /***/ (function(module, exports) { 215 216 function _defineProperty(obj, key, value) { 217 if (key in obj) { 218 Object.defineProperty(obj, key, { 219 value: value, 220 enumerable: true, 221 configurable: true, 222 writable: true 223 }); 224 } else { 225 obj[key] = value; 226 } 227 228 return obj; 229 } 230 231 module.exports = _defineProperty; 232 233 /***/ }), 234 235 /***/ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js": 236 /*!*********************************************************************!*\ 237 !*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***! 238 \*********************************************************************/ 239 /*! no static exports found */ 240 /***/ (function(module, exports) { 241 242 function _iterableToArrayLimit(arr, i) { 243 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 244 var _arr = []; 245 var _n = true; 246 var _d = false; 247 var _e = undefined; 248 249 try { 250 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 251 _arr.push(_s.value); 252 253 if (i && _arr.length === i) break; 254 } 255 } catch (err) { 256 _d = true; 257 _e = err; 258 } finally { 259 try { 260 if (!_n && _i["return"] != null) _i["return"](); 261 } finally { 262 if (_d) throw _e; 263 } 264 } 265 266 return _arr; 267 } 268 269 module.exports = _iterableToArrayLimit; 270 271 /***/ }), 272 273 /***/ "./node_modules/@babel/runtime/helpers/nonIterableRest.js": 274 /*!****************************************************************!*\ 275 !*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***! 276 \****************************************************************/ 277 /*! no static exports found */ 278 /***/ (function(module, exports) { 279 280 function _nonIterableRest() { 281 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 282 } 283 284 module.exports = _nonIterableRest; 285 286 /***/ }), 287 288 /***/ "./node_modules/@babel/runtime/helpers/slicedToArray.js": 289 /*!**************************************************************!*\ 290 !*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***! 291 \**************************************************************/ 292 /*! no static exports found */ 293 /***/ (function(module, exports, __webpack_require__) { 294 295 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles */ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js"); 296 297 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit */ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"); 298 299 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"); 300 301 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest */ "./node_modules/@babel/runtime/helpers/nonIterableRest.js"); 302 303 function _slicedToArray(arr, i) { 304 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 305 } 306 307 module.exports = _slicedToArray; 308 309 /***/ }), 310 311 /***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js": 312 /*!***************************************************************************!*\ 313 !*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***! 314 \***************************************************************************/ 315 /*! no static exports found */ 316 /***/ (function(module, exports, __webpack_require__) { 317 318 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js"); 319 320 function _unsupportedIterableToArray(o, minLen) { 321 if (!o) return; 322 if (typeof o === "string") return arrayLikeToArray(o, minLen); 323 var n = Object.prototype.toString.call(o).slice(8, -1); 324 if (n === "Object" && o.constructor) n = o.constructor.name; 325 if (n === "Map" || n === "Set") return Array.from(o); 326 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 327 } 328 329 module.exports = _unsupportedIterableToArray; 330 331 /***/ }), 332 333 /***/ "./src/controls/content-visibility-date-time-controls.js": 334 /*!***************************************************************!*\ 335 !*** ./src/controls/content-visibility-date-time-controls.js ***! 336 \***************************************************************/ 337 /*! exports provided: ContentVisibilityDateTimeControls */ 338 /***/ (function(module, __webpack_exports__, __webpack_require__) { 339 340 "use strict"; 341 __webpack_require__.r(__webpack_exports__); 342 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ContentVisibilityDateTimeControls", function() { return ContentVisibilityDateTimeControls; }); 343 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"); 344 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__); 345 /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"); 346 /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__); 347 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 348 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); 349 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 350 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__); 351 /* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date"); 352 /* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__); 353 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 354 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__); 355 356 357 358 359 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 360 361 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 362 363 364 365 366 367 var ContentVisibilityDateTimeControls = function ContentVisibilityDateTimeControls(_ref) { 368 var rules = _ref.rules, 369 setAttributes = _ref.setAttributes, 370 attributes = _ref.attributes; 371 372 var _useState = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["useState"])(false), 373 _useState2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2), 374 openDatePopupForStart = _useState2[0], 375 setOpenDatePopupForStart = _useState2[1]; 376 377 var _useState3 = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["useState"])(false), 378 _useState4 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2), 379 openDatePopupForEnd = _useState4[0], 380 setOpenDatePopupForEnd = _useState4[1]; 381 /** 382 * Clear the date and time - resets to not having a value. 383 * 384 * @param {*} startOrEnd Are we resetting the start or end date. 385 * @param {*} rules The current ruleset for this block. 386 */ 387 388 389 var clearDateAndTime = function clearDateAndTime(startOrEnd, rules) { 390 setAttributes({ 391 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 392 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, startOrEnd, {})) 393 }) 394 }); 395 }; 396 /** 397 * DateTimePicker for the Start date/time. 398 */ 399 400 401 var ScheduleStartDateTime = function ScheduleStartDateTime() { 402 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["DateTimePicker"], { 403 currentDate: rules.dateTime.start, 404 onChange: function onChange(date) { 405 setAttributes({ 406 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 407 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, { 408 'start': date 409 }) 410 }) 411 }); 412 setOpenDatePopupForStart(false); 413 }, 414 is12Hour: false 415 }); 416 }; 417 /** 418 * DateTimePicker for the End date/time. 419 */ 420 421 422 var ScheduleEndDateTime = function ScheduleEndDateTime() { 423 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["DateTimePicker"], { 424 currentDate: rules.dateTime.end, 425 onChange: function onChange(date) { 426 setAttributes({ 427 contentVisibilityRules: _objectSpread(_objectSpread({}, rules), {}, { 428 dateTime: _objectSpread(_objectSpread({}, rules.dateTime), {}, { 429 'end': date 430 }) 431 }) 432 }); 433 setOpenDatePopupForEnd(false); 434 }, 435 is12Hour: false 436 }); 437 }; 438 439 var ClearCurrentDateTimeIcon = function ClearCurrentDateTimeIcon() { 440 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Icon"], { 441 icon: function icon() { 442 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("svg", { 443 xmlns: "http://www.w3.org/2000/svg", 444 width: "20", 445 height: "20", 446 viewBox: "0 0 24 24", 447 fill: "none", 448 stroke: "currentColor", 449 "stroke-width": "1", 450 "stroke-linecap": "round", 451 "stroke-linejoin": "round", 452 class: "feather feather-x-circle" 453 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("circle", { 454 cx: "12", 455 cy: "12", 456 r: "10" 457 }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("line", { 458 x1: "15", 459 y1: "9", 460 x2: "9", 461 y2: "15" 462 }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("line", { 463 x1: "9", 464 y1: "9", 465 x2: "15", 466 y2: "15" 467 })); 468 } 469 }); 470 }; 471 /** 472 * Output the Scheduling controls 473 */ 474 475 476 var ContentVisibilityScheduleControls = function ContentVisibilityScheduleControls() { 477 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 478 className: "content-visibility-schedule-controls" 479 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 480 className: "components-dropdown" 481 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 482 isLink: true, 483 className: "content-visibility-set-date-time", 484 icon: "calendar-alt", 485 onClick: function onClick() { 486 return setOpenDatePopupForStart(!openDatePopupForStart); 487 } 488 }, rules.dateTime.start && typeof rules.dateTime.start === 'string' ? Object(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__["dateI18n"])('D M j Y, G:i', rules.dateTime.start) : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])("Set Start Date/Time")), openDatePopupForStart && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Popover"], { 489 position: "middle left", 490 className: "content-visibility-picker-popover content-visibility-picker-popover-start", 491 onClose: setOpenDatePopupForStart.bind(null, false) 492 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ScheduleStartDateTime, null)), rules.dateTime.start && typeof rules.dateTime.start === 'string' && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 493 isLink: true, 494 label: "Clear date and time", 495 className: "content-visibility-clear-date-time", 496 onClick: function onClick() { 497 clearDateAndTime('start', rules); 498 } 499 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ClearCurrentDateTimeIcon, null))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("div", { 500 className: "components-dropdown" 501 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 502 isLink: true, 503 className: "content-visibility-set-date-time", 504 icon: "calendar-alt", 505 onClick: function onClick() { 506 return setOpenDatePopupForEnd(!openDatePopupForEnd); 507 } 508 }, rules.dateTime.end && typeof rules.dateTime.end === 'string' ? Object(_wordpress_date__WEBPACK_IMPORTED_MODULE_4__["dateI18n"])('D M j Y, G:i', rules.dateTime.end) : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])("Set End Date/Time")), openDatePopupForEnd && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Popover"], { 509 position: "middle left", 510 className: "content-visibility-picker-popover content-visibility-picker-popover-end", 511 onClose: setOpenDatePopupForEnd.bind(null, false) 512 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ScheduleEndDateTime, null)), rules.dateTime.end && typeof rules.dateTime.end === 'string' && Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], { 513 isLink: true, 514 label: "Clear date and time", 515 className: "content-visibility-clear-date-time", 516 onClick: function onClick() { 517 clearDateAndTime('end', rules); 518 } 519 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ClearCurrentDateTimeIcon, null))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])("p", { 520 className: "date-time-help-intro content-visibility-help-text" 521 }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__["__"])('Set start and/or end dates for when this block will be ' + attributes.contentVisibility + '. Not selecting either date will mean this block is ' + attributes.contentVisibility + ' at all times.'))); 522 }; 523 524 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["createElement"])(ContentVisibilityScheduleControls, null); 525 }; 526 527 /***/ }), 528 529 /***/ "./src/controls/content-visibility-date-time-panel-body.js": 530 /*!*****************************************************************!*\ 531 !*** ./src/controls/content-visibility-date-time-panel-body.js ***! 532 \*****************************************************************/ 533 /*! exports provided: default */ 534 /***/ (function(module, __webpack_exports__, __webpack_require__) { 535 536 "use strict"; 537 __webpack_require__.r(__webpack_exports__); 538 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 539 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 540 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 541 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__); 542 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 543 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); 544 /* harmony import */ var _content_visibility_date_time_controls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./content-visibility-date-time-controls */ "./src/controls/content-visibility-date-time-controls.js"); 545 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 546 547 548 549 550 551 552 function ContentVisibilityDateTimePanelBodyControl(_ref) { 553 var setAttributes = _ref.setAttributes, 554 attributes = _ref.attributes; 555 var rules = attributes.contentVisibilityRules; 556 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_4__["default"])(attributes, 'dateTime') ? ' has-active-rules' : ''; 557 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelBody"], { 558 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Date and Time', 'content-visibility-date-time'), 559 initialOpen: false, 560 className: "content-visibility-control-panel block-visibility-date-time-controls" + hasRulesClass 561 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_controls__WEBPACK_IMPORTED_MODULE_3__["ContentVisibilityDateTimeControls"], { 562 rules: rules, 563 setAttributes: setAttributes, 564 attributes: attributes 565 }))); 566 } 567 568 /* harmony default export */ __webpack_exports__["default"] = (ContentVisibilityDateTimePanelBodyControl); 569 570 /***/ }), 571 572 /***/ "./src/controls/content-visibility-date-time.js": 573 /*!******************************************************!*\ 574 !*** ./src/controls/content-visibility-date-time.js ***! 575 \******************************************************/ 576 /*! exports provided: ContentVisibilityDateTimeControl */ 577 /***/ (function(module, __webpack_exports__, __webpack_require__) { 578 579 "use strict"; 580 __webpack_require__.r(__webpack_exports__); 581 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ContentVisibilityDateTimeControl", function() { return ContentVisibilityDateTimeControl; }); 582 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 583 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 584 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); 585 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__); 586 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); 587 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); 588 /* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins"); 589 /* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__); 590 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 591 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__); 592 /* harmony import */ var _content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./content-visibility-date-time-panel-body */ "./src/controls/content-visibility-date-time-panel-body.js"); 593 594 595 596 597 598 599 function ContentVisibilityDateTimeControl(data) { 600 var rulesEnabled = data.attributes.contentVisibilityRules.contentVisibilityRulesEnabled; 601 var contentVisibility = data.attributes.hasOwnProperty('contentVisibility'); 602 603 if (!rulesEnabled || !contentVisibility) { 604 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["Disabled"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__["default"], { 605 setAttributes: data.setAttributes, 606 attributes: data.attributes 607 })); 608 } 609 610 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_date_time_panel_body__WEBPACK_IMPORTED_MODULE_5__["default"], { 611 setAttributes: data.setAttributes, 612 attributes: data.attributes 613 }); 614 } 615 /** 616 * Render the <ContentVisibilityDateTimeControl> component by adding 617 * it to the block-visibility-extra-controls Fill. 618 * 619 * @return {Object} A Fill component wrapping the ContentVisibilityDateTimeControl component. 620 */ 621 622 function ContentVisibilityDateTimeFill() { 623 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["Fill"], { 624 name: "content-visibility-extra-controls" 625 }, function (fillProps) { 626 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(ContentVisibilityDateTimeControl, { 627 setAttributes: fillProps.setAttributes, 628 attributes: fillProps.attributes 629 }); 630 }); 631 } // Add our component to the Slot provided by BlockVisibilityControls 632 633 634 Object(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_3__["registerPlugin"])('content-visibility-03-date-time-fill', { 635 render: ContentVisibilityDateTimeFill 636 }); // Register our visibility rule with the main plugin 637 638 Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__["addFilter"])('contentVisibility.defaultContentVisibilityRules', 'content-visibility-date-time/block-visibility-rules', registerDateTimeContentVisibilityRule); 639 640 function registerDateTimeContentVisibilityRule(defaultRules) { 641 defaultRules.dateTime = { 642 start: {}, 643 end: {} 644 }; 645 return defaultRules; 646 } 647 648 /***/ }), 649 650 /***/ "./src/editor.scss": 651 /*!*************************!*\ 652 !*** ./src/editor.scss ***! 653 \*************************/ 654 /*! no static exports found */ 655 /***/ (function(module, exports, __webpack_require__) { 656 657 // extracted by mini-css-extract-plugin 658 659 /***/ }), 660 661 /***/ "./src/helpers/has-rules.js": 662 /*!**********************************!*\ 663 !*** ./src/helpers/has-rules.js ***! 664 \**********************************/ 665 /*! exports provided: default */ 666 /***/ (function(module, __webpack_exports__, __webpack_require__) { 667 668 "use strict"; 669 __webpack_require__.r(__webpack_exports__); 670 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 671 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 672 673 /** 674 * Determine if the passed block props contain rules of the passed type. 675 * 676 * @param {object} props The currently selected block's props. 677 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 678 * 679 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 680 */ 681 682 function hasRules(props, type) { 683 if (!props.contentVisibilityRules) { 684 return false; 685 } 686 687 if (!props.contentVisibilityRules[type]) { 688 return false; 689 } // Default to false. Passed through a filter later. 690 691 692 var hasRules = false; 693 694 switch (type) { 695 case 'dateTime': 696 if (props.contentVisibilityRules[type] && props.contentVisibilityRules[type]['start'] && Object.keys(props.contentVisibilityRules[type]['start']).length !== 0) { 697 hasRules = true; 698 } 699 700 if (props.contentVisibilityRules[type] && props.contentVisibilityRules[type]['end'] && Object.keys(props.contentVisibilityRules[type]['end']).length !== 0) { 701 hasRules = true; 702 } 703 704 break; 705 706 default: 707 break; 708 } 709 710 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 711 } // end hasRules() 712 713 714 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 715 716 /***/ }), 717 718 /***/ "./src/index.js": 719 /*!**********************!*\ 720 !*** ./src/index.js ***! 721 \**********************/ 722 /*! no exports provided */ 723 /***/ (function(module, __webpack_exports__, __webpack_require__) { 724 725 "use strict"; 726 __webpack_require__.r(__webpack_exports__); 727 /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); 728 /* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_editor_scss__WEBPACK_IMPORTED_MODULE_0__); 729 /* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); 730 /* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_scss__WEBPACK_IMPORTED_MODULE_1__); 731 /* harmony import */ var _controls_content_visibility_date_time__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/content-visibility-date-time */ "./src/controls/content-visibility-date-time.js"); 732 733 734 735 736 /***/ }), 737 738 /***/ "@wordpress/components": 739 /*!*********************************************!*\ 740 !*** external {"this":["wp","components"]} ***! 741 \*********************************************/ 742 /*! no static exports found */ 743 /***/ (function(module, exports) { 744 745 (function() { module.exports = this["wp"]["components"]; }()); 746 747 /***/ }), 748 749 /***/ "@wordpress/date": 750 /*!***************************************!*\ 751 !*** external {"this":["wp","date"]} ***! 752 \***************************************/ 753 /*! no static exports found */ 754 /***/ (function(module, exports) { 755 756 (function() { module.exports = this["wp"]["date"]; }()); 757 758 /***/ }), 759 760 /***/ "@wordpress/element": 761 /*!******************************************!*\ 762 !*** external {"this":["wp","element"]} ***! 763 \******************************************/ 764 /*! no static exports found */ 765 /***/ (function(module, exports) { 766 767 (function() { module.exports = this["wp"]["element"]; }()); 768 769 /***/ }), 770 771 /***/ "@wordpress/hooks": 772 /*!****************************************!*\ 773 !*** external {"this":["wp","hooks"]} ***! 774 \****************************************/ 775 /*! no static exports found */ 776 /***/ (function(module, exports) { 777 778 (function() { module.exports = this["wp"]["hooks"]; }()); 779 780 /***/ }), 781 782 /***/ "@wordpress/i18n": 783 /*!***************************************!*\ 784 !*** external {"this":["wp","i18n"]} ***! 785 \***************************************/ 786 /*! no static exports found */ 787 /***/ (function(module, exports) { 788 789 (function() { module.exports = this["wp"]["i18n"]; }()); 790 791 /***/ }), 792 793 /***/ "@wordpress/plugins": 794 /*!******************************************!*\ 795 !*** external {"this":["wp","plugins"]} ***! 796 \******************************************/ 797 /*! no static exports found */ 798 /***/ (function(module, exports) { 799 800 (function() { module.exports = this["wp"]["plugins"]; }()); 801 802 /***/ }) 803 804 /******/ }); 805 //# sourceMappingURL=index.js.map 1 (()=>{"use strict";var t,e={996:()=>{const t=window.wp.element,e=window.wp.components,i=window.wp.i18n,n=window.wp.plugins,l=window.wp.hooks,s=window.wp.date,r=n=>{let{rules:l,setAttributes:r,attributes:a}=n;const[o,c]=(0,t.useState)(!1),[u,d]=(0,t.useState)(!1),b=(t,e)=>{r({contentVisibilityRules:{...e,dateTime:{...e.dateTime,[t]:null}}})},m=()=>(0,t.createElement)(e.DateTimePicker,{currentDate:l.dateTime.start,onChange:t=>{r({contentVisibilityRules:{...l,dateTime:{...l.dateTime,start:t}}}),c(!1)},is12Hour:!1}),y=()=>(0,t.createElement)(e.DateTimePicker,{currentDate:l.dateTime.end,onChange:t=>{r({contentVisibilityRules:{...l,dateTime:{...l.dateTime,end:t}}}),d(!1)},is12Hour:!1}),p=()=>(0,t.createElement)(e.Icon,{icon:()=>(0,t.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x-circle"},(0,t.createElement)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.createElement)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,t.createElement)("line",{x1:"9",y1:"9",x2:"15",y2:"15"}))});return(0,t.createElement)((()=>(0,t.createElement)("div",{className:"content-visibility-schedule-controls"},(0,t.createElement)("div",{className:"components-dropdown"},(0,t.createElement)(e.Button,{isLink:!0,className:"content-visibility-set-date-time",icon:"calendar-alt",onClick:()=>c(!o)},l.dateTime.start&&"string"==typeof l.dateTime.start?(0,s.dateI18n)("D M j Y, G:i",l.dateTime.start):(0,i.__)("Set Start Date/Time")),o&&(0,t.createElement)(e.Popover,{position:"middle left",className:"content-visibility-picker-popover content-visibility-picker-popover-start",onClose:c.bind(null,!1)},(0,t.createElement)(m,null)),l.dateTime.start&&"string"==typeof l.dateTime.start&&(0,t.createElement)(e.Button,{isLink:!0,label:"Clear date and time",className:"content-visibility-clear-date-time",onClick:()=>{b("start",l)}},(0,t.createElement)(p,null))),(0,t.createElement)("div",{className:"components-dropdown"},(0,t.createElement)(e.Button,{isLink:!0,className:"content-visibility-set-date-time",icon:"calendar-alt",onClick:()=>d(!u)},l.dateTime.end&&"string"==typeof l.dateTime.end?(0,s.dateI18n)("D M j Y, G:i",l.dateTime.end):(0,i.__)("Set End Date/Time")),u&&(0,t.createElement)(e.Popover,{position:"middle left",className:"content-visibility-picker-popover content-visibility-picker-popover-end",onClose:d.bind(null,!1)},(0,t.createElement)(y,null)),l.dateTime.end&&"string"==typeof l.dateTime.end&&(0,t.createElement)(e.Button,{isLink:!0,label:"Clear date and time",className:"content-visibility-clear-date-time",onClick:()=>{b("end",l)}},(0,t.createElement)(p,null))),(0,t.createElement)("p",{className:"date-time-help-intro content-visibility-help-text"},(0,i.__)("Set start and/or end dates for when this block will be "+a.contentVisibility+". Not selecting either date will mean this block is "+a.contentVisibility+" at all times.")))),null)},a=function(n){let{setAttributes:s,attributes:a}=n,o=a.contentVisibilityRules,c=function(t,e){if(!t.contentVisibilityRules)return!1;if(!t.contentVisibilityRules[e])return!1;let i=!1;return"dateTime"===e&&(t.contentVisibilityRules[e]&&t.contentVisibilityRules[e].start&&0!==Object.keys(t.contentVisibilityRules[e].start).length&&(i=!0),t.contentVisibilityRules[e]&&t.contentVisibilityRules[e].end&&0!==Object.keys(t.contentVisibilityRules[e].end).length&&(i=!0)),(0,l.applyFilters)("content-visibility-has-rules",i,t,e)}(a,"dateTime")?" has-active-rules":"";return(0,t.createElement)(e.PanelBody,{title:(0,i.__)("Date and Time","content-visibility-date-time"),initialOpen:!1,className:"content-visibility-control-panel block-visibility-date-time-controls"+c},(0,t.createElement)(e.PanelRow,null,(0,t.createElement)(r,{rules:o,setAttributes:s,attributes:a})))};function o(i){let n=i.attributes.contentVisibilityRules.contentVisibilityRulesEnabled,l=i.attributes.hasOwnProperty("contentVisibility");return n&&l?(0,t.createElement)(a,{setAttributes:i.setAttributes,attributes:i.attributes}):(0,t.createElement)(e.Disabled,null,(0,t.createElement)(a,{setAttributes:i.setAttributes,attributes:i.attributes}))}(0,n.registerPlugin)("content-visibility-03-date-time-fill",{render:function(){return(0,t.createElement)(e.Fill,{name:"content-visibility-extra-controls"},(e=>(0,t.createElement)(o,{setAttributes:e.setAttributes,attributes:e.attributes})))}}),(0,l.addFilter)("contentVisibility.defaultContentVisibilityRules","content-visibility-date-time/block-visibility-rules",(function(t){return t.dateTime={start:null,end:null},t})),(0,l.addFilter)("blocks.registerBlockType","content-visibility/dateTimeAttributesDeprecation",(function(t){if(!t.attributes.contentVisibilityRules.default.dateTime)return t;const e={attributes:{...t.attributes,contentVisibilityRules:{...t.attributes.contentVisibilityRules,default:{...t.attributes.contentVisibilityRules.default,dateTime:{end:{},start:{}}}}},supports:t.supports,save:t.save,migrate:t=>({...t,contentVisibilityRules:{...t.contentVisibilityRules,dateTime:{end:null,start:null}}}),isEligible:t=>t&&t.contentVisibilityRules&&t.contentVisibilityRules.dateTime&&t.contentVisibilityRules.dateTime.start&&Object.getPrototypeOf(t.contentVisibilityRules.dateTime.start)===Object.prototype&&0===Object.keys(t.contentVisibilityRules.dateTime.start).length};return t.deprecated=t.deprecated&&Array.isArray(t.deprecated)?[...t.deprecated,e]:[e],t}),99)}},i={};function n(t){var l=i[t];if(void 0!==l)return l.exports;var s=i[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.m=e,t=[],n.O=(e,i,l,s)=>{if(!i){var r=1/0;for(u=0;u<t.length;u++){for(var[i,l,s]=t[u],a=!0,o=0;o<i.length;o++)(!1&s||r>=s)&&Object.keys(n.O).every((t=>n.O[t](i[o])))?i.splice(o--,1):(a=!1,s<r&&(r=s));if(a){t.splice(u--,1);var c=l();void 0!==c&&(e=c)}}return e}s=s||0;for(var u=t.length;u>0&&t[u-1][2]>s;u--)t[u]=t[u-1];t[u]=[i,l,s]},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={826:0,431:0};n.O.j=e=>0===t[e];var e=(e,i)=>{var l,s,[r,a,o]=i,c=0;if(r.some((e=>0!==t[e]))){for(l in a)n.o(a,l)&&(n.m[l]=a[l]);if(o)var u=o(n)}for(e&&e(i);c<r.length;c++)s=r[c],n.o(t,s)&&t[s]&&t[s][0](),t[s]=0;return n.O(u)},i=globalThis.webpackChunkcontent_visibility_user_role=globalThis.webpackChunkcontent_visibility_user_role||[];i.forEach(e.bind(null,0)),i.push=e.bind(null,i.push.bind(i))})();var l=n.O(void 0,[431],(()=>n(996)));l=n.O(l)})(); -
content-visibility-date-and-time/trunk/build/style-index.css
r2480205 r2833195 1 1 2 3 /*# sourceMappingURL=style-index.css.map*/ -
content-visibility-date-and-time/trunk/content-visibility-date-and-time.php
r2568526 r2833195 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Schedule showing or hiding specific content blocks. 14 * Version: 0.1. 214 * Version: 0.1.3 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-date-and-time/trunk/includes/content-visibility-date-and-time.php
r2480205 r2833195 23 23 */ 24 24 function enqueue_editor_assets() { // phpcs:ignore 25 26 $prereqs = array( 27 'wp-blocks', 28 'wp-i18n', 29 'wp-element', 30 'wp-plugins', 31 'wp-dom-ready', 32 ); 33 34 // The 5.8 widgets screen requires a special editor?! Feelsbadman. 35 $CVEditor = new \RichardTape\ContentVisibility\Editor(); 36 if ( $CVEditor->on_widgets_screen() ) { 37 $prereqs[] = 'wp-edit-widgets'; 38 } else { 39 $prereqs[] = 'wp-editor'; 40 } 25 41 26 42 wp_register_script( 27 43 'content-visibility-date-and-time', 28 44 plugins_url( '/build/index.js', dirname( __FILE__ ) ), 29 array( 30 'wp-blocks', 31 'wp-i18n', 32 'wp-element', 33 'wp-editor', 34 'wp-plugins', 35 'wp-edit-post', 36 ), 45 $prereqs, 37 46 filemtime( plugin_dir_path( __DIR__ ) . 'build/index.js' ), 38 47 true -
content-visibility-date-and-time/trunk/readme.txt
r2568526 r2833195 4 4 Tags: contentvisibility, block, content, visibility, date, time 5 5 Requires at least: 5.0 6 Tested up to: 5.8.07 Stable tag: 0.1. 26 Tested up to: 6.1.1 7 Stable tag: 0.1.3 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 35 35 == Changelog == 36 36 37 = 0.1.3 = 38 * WP 6.1.1 compatibility. 39 * Fixed warning in widgets screen to do with loading the wrong editor. 40 * Fixed date popup not showing correctly due to changes in the underlying DateTime component. props kelvinxu. 41 37 42 = 0.1.2 = 38 43 * Added indicator to show when Date/Time rules are present for a block to make it easier to see when a block has rules.
Note: See TracChangeset
for help on using the changeset viewer.