| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ // The require scope |
| 4 |
/******/ var __webpack_require__ = {}; |
| 5 |
/******/ |
| 6 |
/************************************************************************/ |
| 7 |
/******/ /* webpack/runtime/compat get default export */ |
| 8 |
/******/ (() => { |
| 9 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 10 |
/******/ __webpack_require__.n = (module) => { |
| 11 |
/******/ var getter = module && module.__esModule ? |
| 12 |
/******/ () => (module['default']) : |
| 13 |
/******/ () => (module); |
| 14 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 15 |
/******/ return getter; |
| 16 |
/******/ }; |
| 17 |
/******/ })(); |
| 18 |
/******/ |
| 19 |
/******/ /* webpack/runtime/define property getters */ |
| 20 |
/******/ (() => { |
| 21 |
/******/ // define getter functions for harmony exports |
| 22 |
/******/ __webpack_require__.d = (exports, definition) => { |
| 23 |
/******/ for(var key in definition) { |
| 24 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 25 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 26 |
/******/ } |
| 27 |
/******/ } |
| 28 |
/******/ }; |
| 29 |
/******/ })(); |
| 30 |
/******/ |
| 31 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 32 |
/******/ (() => { |
| 33 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 34 |
/******/ })(); |
| 35 |
/******/ |
| 36 |
/******/ /* webpack/runtime/make namespace object */ |
| 37 |
/******/ (() => { |
| 38 |
/******/ // define __esModule on exports |
| 39 |
/******/ __webpack_require__.r = (exports) => { |
| 40 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 41 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 42 |
/******/ } |
| 43 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 44 |
/******/ }; |
| 45 |
/******/ })(); |
| 46 |
/******/ |
| 47 |
/************************************************************************/ |
| 48 |
var __webpack_exports__ = {}; |
| 49 |
// ESM COMPAT FLAG |
| 50 |
__webpack_require__.r(__webpack_exports__); |
| 51 |
|
| 52 |
// EXPORTS |
| 53 |
__webpack_require__.d(__webpack_exports__, { |
| 54 |
PreferenceToggleMenuItem: () => (/* reexport */ PreferenceToggleMenuItem), |
| 55 |
privateApis: () => (/* reexport */ privateApis), |
| 56 |
store: () => (/* reexport */ store) |
| 57 |
}); |
| 58 |
|
| 59 |
// NAMESPACE OBJECT: ./packages/preferences/build-module/store/actions.js |
| 60 |
var actions_namespaceObject = {}; |
| 61 |
__webpack_require__.r(actions_namespaceObject); |
| 62 |
__webpack_require__.d(actions_namespaceObject, { |
| 63 |
set: () => (set), |
| 64 |
setDefaults: () => (setDefaults), |
| 65 |
setPersistenceLayer: () => (setPersistenceLayer), |
| 66 |
toggle: () => (toggle) |
| 67 |
}); |
| 68 |
|
| 69 |
// NAMESPACE OBJECT: ./packages/preferences/build-module/store/selectors.js |
| 70 |
var selectors_namespaceObject = {}; |
| 71 |
__webpack_require__.r(selectors_namespaceObject); |
| 72 |
__webpack_require__.d(selectors_namespaceObject, { |
| 73 |
get: () => (get) |
| 74 |
}); |
| 75 |
|
| 76 |
;// CONCATENATED MODULE: external ["wp","data"] |
| 77 |
const external_wp_data_namespaceObject = window["wp"]["data"]; |
| 78 |
;// CONCATENATED MODULE: external ["wp","components"] |
| 79 |
const external_wp_components_namespaceObject = window["wp"]["components"]; |
| 80 |
;// CONCATENATED MODULE: external ["wp","i18n"] |
| 81 |
const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
| 82 |
;// CONCATENATED MODULE: external ["wp","primitives"] |
| 83 |
const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
| 84 |
;// CONCATENATED MODULE: external "ReactJSXRuntime" |
| 85 |
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
| 86 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js |
| 87 |
/** |
| 88 |
* WordPress dependencies |
| 89 |
*/ |
| 90 |
|
| 91 |
|
| 92 |
const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
| 93 |
xmlns: "http://www.w3.org/2000/svg", |
| 94 |
viewBox: "0 0 24 24", |
| 95 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
| 96 |
d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" |
| 97 |
}) |
| 98 |
}); |
| 99 |
/* harmony default export */ const library_check = (check); |
| 100 |
|
| 101 |
;// CONCATENATED MODULE: external ["wp","a11y"] |
| 102 |
const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
| 103 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/store/reducer.js |
| 104 |
/** |
| 105 |
* WordPress dependencies |
| 106 |
*/ |
| 107 |
|
| 108 |
|
| 109 |
/** |
| 110 |
* Reducer returning the defaults for user preferences. |
| 111 |
* |
| 112 |
* This is kept intentionally separate from the preferences |
| 113 |
* themselves so that defaults are not persisted. |
| 114 |
* |
| 115 |
* @param {Object} state Current state. |
| 116 |
* @param {Object} action Dispatched action. |
| 117 |
* |
| 118 |
* @return {Object} Updated state. |
| 119 |
*/ |
| 120 |
function defaults(state = {}, action) { |
| 121 |
if (action.type === 'SET_PREFERENCE_DEFAULTS') { |
| 122 |
const { |
| 123 |
scope, |
| 124 |
defaults: values |
| 125 |
} = action; |
| 126 |
return { |
| 127 |
...state, |
| 128 |
[scope]: { |
| 129 |
...state[scope], |
| 130 |
...values |
| 131 |
} |
| 132 |
}; |
| 133 |
} |
| 134 |
return state; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* Higher order reducer that does the following: |
| 139 |
* - Merges any data from the persistence layer into the state when the |
| 140 |
* `SET_PERSISTENCE_LAYER` action is received. |
| 141 |
* - Passes any preferences changes to the persistence layer. |
| 142 |
* |
| 143 |
* @param {Function} reducer The preferences reducer. |
| 144 |
* |
| 145 |
* @return {Function} The enhanced reducer. |
| 146 |
*/ |
| 147 |
function withPersistenceLayer(reducer) { |
| 148 |
let persistenceLayer; |
| 149 |
return (state, action) => { |
| 150 |
// Setup the persistence layer, and return the persisted data |
| 151 |
// as the state. |
| 152 |
if (action.type === 'SET_PERSISTENCE_LAYER') { |
| 153 |
const { |
| 154 |
persistenceLayer: persistence, |
| 155 |
persistedData |
| 156 |
} = action; |
| 157 |
persistenceLayer = persistence; |
| 158 |
return persistedData; |
| 159 |
} |
| 160 |
const nextState = reducer(state, action); |
| 161 |
if (action.type === 'SET_PREFERENCE_VALUE') { |
| 162 |
persistenceLayer?.set(nextState); |
| 163 |
} |
| 164 |
return nextState; |
| 165 |
}; |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* Reducer returning the user preferences. |
| 170 |
* |
| 171 |
* @param {Object} state Current state. |
| 172 |
* @param {Object} action Dispatched action. |
| 173 |
* |
| 174 |
* @return {Object} Updated state. |
| 175 |
*/ |
| 176 |
const preferences = withPersistenceLayer((state = {}, action) => { |
| 177 |
if (action.type === 'SET_PREFERENCE_VALUE') { |
| 178 |
const { |
| 179 |
scope, |
| 180 |
name, |
| 181 |
value |
| 182 |
} = action; |
| 183 |
return { |
| 184 |
...state, |
| 185 |
[scope]: { |
| 186 |
...state[scope], |
| 187 |
[name]: value |
| 188 |
} |
| 189 |
}; |
| 190 |
} |
| 191 |
return state; |
| 192 |
}); |
| 193 |
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
| 194 |
defaults, |
| 195 |
preferences |
| 196 |
})); |
| 197 |
|
| 198 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/store/actions.js |
| 199 |
/** |
| 200 |
* Returns an action object used in signalling that a preference should be |
| 201 |
* toggled. |
| 202 |
* |
| 203 |
* @param {string} scope The preference scope (e.g. core/edit-post). |
| 204 |
* @param {string} name The preference name. |
| 205 |
*/ |
| 206 |
function toggle(scope, name) { |
| 207 |
return function ({ |
| 208 |
select, |
| 209 |
dispatch |
| 210 |
}) { |
| 211 |
const currentValue = select.get(scope, name); |
| 212 |
dispatch.set(scope, name, !currentValue); |
| 213 |
}; |
| 214 |
} |
| 215 |
|
| 216 |
/** |
| 217 |
* Returns an action object used in signalling that a preference should be set |
| 218 |
* to a value |
| 219 |
* |
| 220 |
* @param {string} scope The preference scope (e.g. core/edit-post). |
| 221 |
* @param {string} name The preference name. |
| 222 |
* @param {*} value The value to set. |
| 223 |
* |
| 224 |
* @return {Object} Action object. |
| 225 |
*/ |
| 226 |
function set(scope, name, value) { |
| 227 |
return { |
| 228 |
type: 'SET_PREFERENCE_VALUE', |
| 229 |
scope, |
| 230 |
name, |
| 231 |
value |
| 232 |
}; |
| 233 |
} |
| 234 |
|
| 235 |
/** |
| 236 |
* Returns an action object used in signalling that preference defaults should |
| 237 |
* be set. |
| 238 |
* |
| 239 |
* @param {string} scope The preference scope (e.g. core/edit-post). |
| 240 |
* @param {Object<string, *>} defaults A key/value map of preference names to values. |
| 241 |
* |
| 242 |
* @return {Object} Action object. |
| 243 |
*/ |
| 244 |
function setDefaults(scope, defaults) { |
| 245 |
return { |
| 246 |
type: 'SET_PREFERENCE_DEFAULTS', |
| 247 |
scope, |
| 248 |
defaults |
| 249 |
}; |
| 250 |
} |
| 251 |
|
| 252 |
/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */ |
| 253 |
/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */ |
| 254 |
/** |
| 255 |
* @typedef WPPreferencesPersistenceLayer |
| 256 |
* |
| 257 |
* @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer. |
| 258 |
* @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer. |
| 259 |
*/ |
| 260 |
|
| 261 |
/** |
| 262 |
* Sets the persistence layer. |
| 263 |
* |
| 264 |
* When a persistence layer is set, the preferences store will: |
| 265 |
* - call `get` immediately and update the store state to the value returned. |
| 266 |
* - call `set` with all preferences whenever a preference changes value. |
| 267 |
* |
| 268 |
* `setPersistenceLayer` should ideally be dispatched at the start of an |
| 269 |
* application's lifecycle, before any other actions have been dispatched to |
| 270 |
* the preferences store. |
| 271 |
* |
| 272 |
* @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer. |
| 273 |
* |
| 274 |
* @return {Object} Action object. |
| 275 |
*/ |
| 276 |
async function setPersistenceLayer(persistenceLayer) { |
| 277 |
const persistedData = await persistenceLayer.get(); |
| 278 |
return { |
| 279 |
type: 'SET_PERSISTENCE_LAYER', |
| 280 |
persistenceLayer, |
| 281 |
persistedData |
| 282 |
}; |
| 283 |
} |
| 284 |
|
| 285 |
;// CONCATENATED MODULE: external ["wp","deprecated"] |
| 286 |
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
| 287 |
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
| 288 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/store/selectors.js |
| 289 |
/** |
| 290 |
* WordPress dependencies |
| 291 |
*/ |
| 292 |
|
| 293 |
const withDeprecatedKeys = originalGet => (state, scope, name) => { |
| 294 |
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems']; |
| 295 |
if (settingsToMoveToCore.includes(name) && ['core/edit-post', 'core/edit-site'].includes(scope)) { |
| 296 |
external_wp_deprecated_default()(`wp.data.select( 'core/preferences' ).get( '${scope}', '${name}' )`, { |
| 297 |
since: '6.5', |
| 298 |
alternative: `wp.data.select( 'core/preferences' ).get( 'core', '${name}' )` |
| 299 |
}); |
| 300 |
return originalGet(state, 'core', name); |
| 301 |
} |
| 302 |
return originalGet(state, scope, name); |
| 303 |
}; |
| 304 |
|
| 305 |
/** |
| 306 |
* Returns a boolean indicating whether a prefer is active for a particular |
| 307 |
* scope. |
| 308 |
* |
| 309 |
* @param {Object} state The store state. |
| 310 |
* @param {string} scope The scope of the feature (e.g. core/edit-post). |
| 311 |
* @param {string} name The name of the feature. |
| 312 |
* |
| 313 |
* @return {*} Is the feature enabled? |
| 314 |
*/ |
| 315 |
const get = withDeprecatedKeys((state, scope, name) => { |
| 316 |
const value = state.preferences[scope]?.[name]; |
| 317 |
return value !== undefined ? value : state.defaults[scope]?.[name]; |
| 318 |
}); |
| 319 |
|
| 320 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/store/constants.js |
| 321 |
/** |
| 322 |
* The identifier for the data store. |
| 323 |
* |
| 324 |
* @type {string} |
| 325 |
*/ |
| 326 |
const STORE_NAME = 'core/preferences'; |
| 327 |
|
| 328 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/store/index.js |
| 329 |
/** |
| 330 |
* WordPress dependencies |
| 331 |
*/ |
| 332 |
|
| 333 |
|
| 334 |
/** |
| 335 |
* Internal dependencies |
| 336 |
*/ |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
/** |
| 343 |
* Store definition for the preferences namespace. |
| 344 |
* |
| 345 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
| 346 |
* |
| 347 |
* @type {Object} |
| 348 |
*/ |
| 349 |
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
| 350 |
reducer: reducer, |
| 351 |
actions: actions_namespaceObject, |
| 352 |
selectors: selectors_namespaceObject |
| 353 |
}); |
| 354 |
(0,external_wp_data_namespaceObject.register)(store); |
| 355 |
|
| 356 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preference-toggle-menu-item/index.js |
| 357 |
/** |
| 358 |
* WordPress dependencies |
| 359 |
*/ |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
/** |
| 367 |
* Internal dependencies |
| 368 |
*/ |
| 369 |
|
| 370 |
|
| 371 |
function PreferenceToggleMenuItem({ |
| 372 |
scope, |
| 373 |
name, |
| 374 |
label, |
| 375 |
info, |
| 376 |
messageActivated, |
| 377 |
messageDeactivated, |
| 378 |
shortcut, |
| 379 |
handleToggling = true, |
| 380 |
onToggle = () => null, |
| 381 |
disabled = false |
| 382 |
}) { |
| 383 |
const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, name), [scope, name]); |
| 384 |
const { |
| 385 |
toggle |
| 386 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 387 |
const speakMessage = () => { |
| 388 |
if (isActive) { |
| 389 |
const message = messageDeactivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */ |
| 390 |
(0,external_wp_i18n_namespaceObject.__)('Preference deactivated - %s'), label); |
| 391 |
(0,external_wp_a11y_namespaceObject.speak)(message); |
| 392 |
} else { |
| 393 |
const message = messageActivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */ |
| 394 |
(0,external_wp_i18n_namespaceObject.__)('Preference activated - %s'), label); |
| 395 |
(0,external_wp_a11y_namespaceObject.speak)(message); |
| 396 |
} |
| 397 |
}; |
| 398 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { |
| 399 |
icon: isActive && library_check, |
| 400 |
isSelected: isActive, |
| 401 |
onClick: () => { |
| 402 |
onToggle(); |
| 403 |
if (handleToggling) { |
| 404 |
toggle(scope, name); |
| 405 |
} |
| 406 |
speakMessage(); |
| 407 |
}, |
| 408 |
role: "menuitemcheckbox", |
| 409 |
info: info, |
| 410 |
shortcut: shortcut, |
| 411 |
disabled: disabled, |
| 412 |
children: label |
| 413 |
}); |
| 414 |
} |
| 415 |
|
| 416 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/index.js |
| 417 |
|
| 418 |
|
| 419 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preference-base-option/index.js |
| 420 |
/** |
| 421 |
* WordPress dependencies |
| 422 |
*/ |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
function BaseOption({ |
| 427 |
help, |
| 428 |
label, |
| 429 |
isChecked, |
| 430 |
onChange, |
| 431 |
children |
| 432 |
}) { |
| 433 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { |
| 434 |
className: "preference-base-option", |
| 435 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, { |
| 436 |
__nextHasNoMarginBottom: true, |
| 437 |
help: help, |
| 438 |
label: label, |
| 439 |
checked: isChecked, |
| 440 |
onChange: onChange |
| 441 |
}), children] |
| 442 |
}); |
| 443 |
} |
| 444 |
/* harmony default export */ const preference_base_option = (BaseOption); |
| 445 |
|
| 446 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preference-toggle-control/index.js |
| 447 |
/** |
| 448 |
* WordPress dependencies |
| 449 |
*/ |
| 450 |
|
| 451 |
|
| 452 |
/** |
| 453 |
* Internal dependencies |
| 454 |
*/ |
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
function PreferenceToggleControl(props) { |
| 459 |
const { |
| 460 |
scope, |
| 461 |
featureName, |
| 462 |
onToggle = () => {}, |
| 463 |
...remainingProps |
| 464 |
} = props; |
| 465 |
const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, featureName), [scope, featureName]); |
| 466 |
const { |
| 467 |
toggle |
| 468 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 469 |
const onChange = () => { |
| 470 |
onToggle(); |
| 471 |
toggle(scope, featureName); |
| 472 |
}; |
| 473 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(preference_base_option, { |
| 474 |
onChange: onChange, |
| 475 |
isChecked: isChecked, |
| 476 |
...remainingProps |
| 477 |
}); |
| 478 |
} |
| 479 |
/* harmony default export */ const preference_toggle_control = (PreferenceToggleControl); |
| 480 |
|
| 481 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preferences-modal/index.js |
| 482 |
/** |
| 483 |
* WordPress dependencies |
| 484 |
*/ |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
function PreferencesModal({ |
| 489 |
closeModal, |
| 490 |
children |
| 491 |
}) { |
| 492 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
| 493 |
className: "preferences-modal", |
| 494 |
title: (0,external_wp_i18n_namespaceObject.__)('Preferences'), |
| 495 |
onRequestClose: closeModal, |
| 496 |
children: children |
| 497 |
}); |
| 498 |
} |
| 499 |
|
| 500 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preferences-modal-section/index.js |
| 501 |
|
| 502 |
|
| 503 |
const Section = ({ |
| 504 |
description, |
| 505 |
title, |
| 506 |
children |
| 507 |
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", { |
| 508 |
className: "preferences-modal__section", |
| 509 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("legend", { |
| 510 |
className: "preferences-modal__section-legend", |
| 511 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", { |
| 512 |
className: "preferences-modal__section-title", |
| 513 |
children: title |
| 514 |
}), description && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { |
| 515 |
className: "preferences-modal__section-description", |
| 516 |
children: description |
| 517 |
})] |
| 518 |
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { |
| 519 |
className: "preferences-modal__section-content", |
| 520 |
children: children |
| 521 |
})] |
| 522 |
}); |
| 523 |
/* harmony default export */ const preferences_modal_section = (Section); |
| 524 |
|
| 525 |
;// CONCATENATED MODULE: external ["wp","compose"] |
| 526 |
const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
| 527 |
;// CONCATENATED MODULE: external ["wp","element"] |
| 528 |
const external_wp_element_namespaceObject = window["wp"]["element"]; |
| 529 |
;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js |
| 530 |
/** |
| 531 |
* WordPress dependencies |
| 532 |
*/ |
| 533 |
|
| 534 |
|
| 535 |
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
| 536 |
|
| 537 |
/** |
| 538 |
* Return an SVG icon. |
| 539 |
* |
| 540 |
* @param {IconProps} props icon is the SVG component to render |
| 541 |
* size is a number specifiying the icon size in pixels |
| 542 |
* Other props will be passed to wrapped SVG component |
| 543 |
* @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. |
| 544 |
* |
| 545 |
* @return {JSX.Element} Icon component |
| 546 |
*/ |
| 547 |
function Icon({ |
| 548 |
icon, |
| 549 |
size = 24, |
| 550 |
...props |
| 551 |
}, ref) { |
| 552 |
return (0,external_wp_element_namespaceObject.cloneElement)(icon, { |
| 553 |
width: size, |
| 554 |
height: size, |
| 555 |
...props, |
| 556 |
ref |
| 557 |
}); |
| 558 |
} |
| 559 |
/* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon)); |
| 560 |
|
| 561 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js |
| 562 |
/** |
| 563 |
* WordPress dependencies |
| 564 |
*/ |
| 565 |
|
| 566 |
|
| 567 |
const chevronLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
| 568 |
xmlns: "http://www.w3.org/2000/svg", |
| 569 |
viewBox: "0 0 24 24", |
| 570 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
| 571 |
d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" |
| 572 |
}) |
| 573 |
}); |
| 574 |
/* harmony default export */ const chevron_left = (chevronLeft); |
| 575 |
|
| 576 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js |
| 577 |
/** |
| 578 |
* WordPress dependencies |
| 579 |
*/ |
| 580 |
|
| 581 |
|
| 582 |
const chevronRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
| 583 |
xmlns: "http://www.w3.org/2000/svg", |
| 584 |
viewBox: "0 0 24 24", |
| 585 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
| 586 |
d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" |
| 587 |
}) |
| 588 |
}); |
| 589 |
/* harmony default export */ const chevron_right = (chevronRight); |
| 590 |
|
| 591 |
;// CONCATENATED MODULE: external ["wp","privateApis"] |
| 592 |
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
| 593 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/lock-unlock.js |
| 594 |
/** |
| 595 |
* WordPress dependencies |
| 596 |
*/ |
| 597 |
|
| 598 |
const { |
| 599 |
lock, |
| 600 |
unlock |
| 601 |
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/preferences'); |
| 602 |
|
| 603 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/components/preferences-modal-tabs/index.js |
| 604 |
/** |
| 605 |
* WordPress dependencies |
| 606 |
*/ |
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
/** |
| 614 |
* Internal dependencies |
| 615 |
*/ |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
const { |
| 620 |
Tabs |
| 621 |
} = unlock(external_wp_components_namespaceObject.privateApis); |
| 622 |
const PREFERENCES_MENU = 'preferences-menu'; |
| 623 |
function PreferencesModalTabs({ |
| 624 |
sections |
| 625 |
}) { |
| 626 |
const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); |
| 627 |
|
| 628 |
// This is also used to sync the two different rendered components |
| 629 |
// between small and large viewports. |
| 630 |
const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU); |
| 631 |
/** |
| 632 |
* Create helper objects from `sections` for easier data handling. |
| 633 |
* `tabs` is used for creating the `Tabs` and `sectionsContentMap` |
| 634 |
* is used for easier access to active tab's content. |
| 635 |
*/ |
| 636 |
const { |
| 637 |
tabs, |
| 638 |
sectionsContentMap |
| 639 |
} = (0,external_wp_element_namespaceObject.useMemo)(() => { |
| 640 |
let mappedTabs = { |
| 641 |
tabs: [], |
| 642 |
sectionsContentMap: {} |
| 643 |
}; |
| 644 |
if (sections.length) { |
| 645 |
mappedTabs = sections.reduce((accumulator, { |
| 646 |
name, |
| 647 |
tabLabel: title, |
| 648 |
content |
| 649 |
}) => { |
| 650 |
accumulator.tabs.push({ |
| 651 |
name, |
| 652 |
title |
| 653 |
}); |
| 654 |
accumulator.sectionsContentMap[name] = content; |
| 655 |
return accumulator; |
| 656 |
}, { |
| 657 |
tabs: [], |
| 658 |
sectionsContentMap: {} |
| 659 |
}); |
| 660 |
} |
| 661 |
return mappedTabs; |
| 662 |
}, [sections]); |
| 663 |
let modalContent; |
| 664 |
// We render different components based on the viewport size. |
| 665 |
if (isLargeViewport) { |
| 666 |
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { |
| 667 |
className: "preferences__tabs", |
| 668 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, { |
| 669 |
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined, |
| 670 |
onSelect: setActiveMenu, |
| 671 |
orientation: "vertical", |
| 672 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabList, { |
| 673 |
className: "preferences__tabs-tablist", |
| 674 |
children: tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, { |
| 675 |
tabId: tab.name, |
| 676 |
className: "preferences__tabs-tab", |
| 677 |
children: tab.title |
| 678 |
}, tab.name)) |
| 679 |
}), tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, { |
| 680 |
tabId: tab.name, |
| 681 |
className: "preferences__tabs-tabpanel", |
| 682 |
focusable: false, |
| 683 |
children: sectionsContentMap[tab.name] || null |
| 684 |
}, tab.name))] |
| 685 |
}) |
| 686 |
}); |
| 687 |
} else { |
| 688 |
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { |
| 689 |
initialPath: "/", |
| 690 |
className: "preferences__provider", |
| 691 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { |
| 692 |
path: "/", |
| 693 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Card, { |
| 694 |
isBorderless: true, |
| 695 |
size: "small", |
| 696 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, { |
| 697 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalItemGroup, { |
| 698 |
children: tabs.map(tab => { |
| 699 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { |
| 700 |
path: tab.name, |
| 701 |
as: external_wp_components_namespaceObject.__experimentalItem, |
| 702 |
isAction: true, |
| 703 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { |
| 704 |
justify: "space-between", |
| 705 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, { |
| 706 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTruncate, { |
| 707 |
children: tab.title |
| 708 |
}) |
| 709 |
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, { |
| 710 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, { |
| 711 |
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right |
| 712 |
}) |
| 713 |
})] |
| 714 |
}) |
| 715 |
}, tab.name); |
| 716 |
}) |
| 717 |
}) |
| 718 |
}) |
| 719 |
}) |
| 720 |
}), sections.length && sections.map(section => { |
| 721 |
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { |
| 722 |
path: section.name, |
| 723 |
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Card, { |
| 724 |
isBorderless: true, |
| 725 |
size: "large", |
| 726 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.CardHeader, { |
| 727 |
isBorderless: false, |
| 728 |
justify: "left", |
| 729 |
size: "small", |
| 730 |
gap: "6", |
| 731 |
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, { |
| 732 |
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left, |
| 733 |
label: (0,external_wp_i18n_namespaceObject.__)('Back') |
| 734 |
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, { |
| 735 |
size: "16", |
| 736 |
children: section.tabLabel |
| 737 |
})] |
| 738 |
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, { |
| 739 |
children: section.content |
| 740 |
})] |
| 741 |
}) |
| 742 |
}, `${section.name}-menu`); |
| 743 |
})] |
| 744 |
}); |
| 745 |
} |
| 746 |
return modalContent; |
| 747 |
} |
| 748 |
|
| 749 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/private-apis.js |
| 750 |
/** |
| 751 |
* Internal dependencies |
| 752 |
*/ |
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
const privateApis = {}; |
| 760 |
lock(privateApis, { |
| 761 |
PreferenceBaseOption: preference_base_option, |
| 762 |
PreferenceToggleControl: preference_toggle_control, |
| 763 |
PreferencesModal: PreferencesModal, |
| 764 |
PreferencesModalSection: preferences_modal_section, |
| 765 |
PreferencesModalTabs: PreferencesModalTabs |
| 766 |
}); |
| 767 |
|
| 768 |
;// CONCATENATED MODULE: ./packages/preferences/build-module/index.js |
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
(window.wp = window.wp || {}).preferences = __webpack_exports__; |
| 774 |
/******/ })() |
| 775 |
; |