@wordpress/preferences 4.32.0 → 4.32.1-next.b8c8708f3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/index.js +36 -12
- package/build/components/index.js.map +7 -1
- package/build/components/preference-base-option/index.js +39 -30
- package/build/components/preference-base-option/index.js.map +7 -1
- package/build/components/preference-toggle-control/index.js +52 -30
- package/build/components/preference-toggle-control/index.js.map +7 -1
- package/build/components/preference-toggle-menu-item/index.js +65 -47
- package/build/components/preference-toggle-menu-item/index.js.map +7 -1
- package/build/components/preferences-modal/index.js +35 -23
- package/build/components/preferences-modal/index.js.map +7 -1
- package/build/components/preferences-modal-section/index.js +31 -28
- package/build/components/preferences-modal-section/index.js.map +7 -1
- package/build/components/preferences-modal-tabs/index.js +123 -134
- package/build/components/preferences-modal-tabs/index.js.map +7 -1
- package/build/index.js +29 -36
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/private-apis.js +49 -24
- package/build/private-apis.js.map +7 -1
- package/build/store/actions.js +36 -69
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -12
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -32
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +39 -65
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +67 -33
- package/build/store/selectors.js.map +7 -1
- package/build-module/components/index.js +5 -2
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/preference-base-option/index.js +21 -24
- package/build-module/components/preference-base-option/index.js.map +7 -1
- package/build-module/components/preference-toggle-control/index.js +24 -23
- package/build-module/components/preference-toggle-control/index.js.map +7 -1
- package/build-module/components/preference-toggle-menu-item/index.js +46 -40
- package/build-module/components/preference-toggle-menu-item/index.js.map +7 -1
- package/build-module/components/preferences-modal/index.js +17 -17
- package/build-module/components/preferences-modal/index.js.map +7 -1
- package/build-module/components/preferences-modal-section/index.js +13 -23
- package/build-module/components/preferences-modal-section/index.js.map +7 -1
- package/build-module/components/preferences-modal-tabs/index.js +116 -127
- package/build-module/components/preferences-modal-tabs/index.js.map +7 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/private-apis.js +11 -11
- package/build-module/private-apis.js.map +7 -1
- package/build-module/store/actions.js +15 -65
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -7
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -22
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +17 -59
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +35 -26
- package/build-module/store/selectors.js.map +7 -1
- package/build-style/style-rtl.css +4 -158
- package/build-style/style.css +4 -158
- package/package.json +20 -12
- package/src/components/preference-base-option/style.scss +2 -0
- package/src/components/preferences-modal/style.scss +6 -2
- package/src/components/preferences-modal-section/style.scss +3 -0
- package/src/components/preferences-modal-tabs/style.scss +4 -1
- package/src/style.scss +4 -4
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["useViewportMatch","Navigator","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","__experimentalText","Text","__experimentalTruncate","Truncate","FlexItem","Card","CardHeader","CardBody","privateApis","componentsPrivateApis","useMemo","useState","chevronLeft","chevronRight","Icon","isRTL","__","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","PREFERENCES_MENU","PreferencesModalTabs","sections","isLargeViewport","activeMenu","setActiveMenu","tabs","sectionsContentMap","mappedTabs","length","reduce","accumulator","name","tabLabel","title","content","push","modalContent","className","children","defaultTabId","undefined","onSelect","orientation","TabList","map","tab","Tab","tabId","TabPanel","focusable","initialPath","Screen","path","isBorderless","size","Button","as","isAction","justify","icon","section","gap","BackButton","label"],"sources":["@wordpress/preferences/src/components/preferences-modal-tabs/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tNavigator,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\t__experimentalTruncate as Truncate,\n\tFlexItem,\n\tCard,\n\tCardHeader,\n\tCardBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { chevronLeft, chevronRight, Icon } from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst PREFERENCES_MENU = 'preferences-menu';\n\nexport default function PreferencesModalTabs( { sections } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\t// This is also used to sync the two different rendered components\n\t// between small and large viewports.\n\tconst [ activeMenu, setActiveMenu ] = useState( PREFERENCES_MENU );\n\t/**\n\t * Create helper objects from `sections` for easier data handling.\n\t * `tabs` is used for creating the `Tabs` and `sectionsContentMap`\n\t * is used for easier access to active tab's content.\n\t */\n\tconst { tabs, sectionsContentMap } = useMemo( () => {\n\t\tlet mappedTabs = {\n\t\t\ttabs: [],\n\t\t\tsectionsContentMap: {},\n\t\t};\n\t\tif ( sections.length ) {\n\t\t\tmappedTabs = sections.reduce(\n\t\t\t\t( accumulator, { name, tabLabel: title, content } ) => {\n\t\t\t\t\taccumulator.tabs.push( { name, title } );\n\t\t\t\t\taccumulator.sectionsContentMap[ name ] = content;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ tabs: [], sectionsContentMap: {} }\n\t\t\t);\n\t\t}\n\t\treturn mappedTabs;\n\t}, [ sections ] );\n\n\tlet modalContent;\n\t// We render different components based on the viewport size.\n\tif ( isLargeViewport ) {\n\t\tmodalContent = (\n\t\t\t<div className=\"preferences__tabs\">\n\t\t\t\t<Tabs\n\t\t\t\t\tdefaultTabId={\n\t\t\t\t\t\tactiveMenu !== PREFERENCES_MENU ? activeMenu : undefined\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={ setActiveMenu }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t>\n\t\t\t\t\t<Tabs.TabList className=\"preferences__tabs-tablist\">\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\tclassName=\"preferences__tabs-tab\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\tclassName=\"preferences__tabs-tabpanel\"\n\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sectionsContentMap[ tab.name ] || null }\n\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tmodalContent = (\n\t\t\t<Navigator initialPath=\"/\" className=\"preferences__provider\">\n\t\t\t\t<Navigator.Screen path=\"/\">\n\t\t\t\t\t<Card isBorderless size=\"small\">\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t{ tabs.map( ( tab ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<Navigator.Button\n\t\t\t\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\t\t\t\tpath={ `/${ tab.name }` }\n\t\t\t\t\t\t\t\t\t\t\tas={ Item }\n\t\t\t\t\t\t\t\t\t\t\tisAction\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t</Navigator.Button>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t</Card>\n\t\t\t\t</Navigator.Screen>\n\t\t\t\t{ sections.length &&\n\t\t\t\t\tsections.map( ( section ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Navigator.Screen\n\t\t\t\t\t\t\t\tkey={ `${ section.name }-menu` }\n\t\t\t\t\t\t\t\tpath={ `/${ section.name }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Card isBorderless size=\"large\">\n\t\t\t\t\t\t\t\t\t<CardHeader\n\t\t\t\t\t\t\t\t\t\tisBorderless={ false }\n\t\t\t\t\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\tgap=\"6\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Navigator.BackButton\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Text size=\"16\">\n\t\t\t\t\t\t\t\t\t\t\t{ section.tabLabel }\n\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t</CardHeader>\n\t\t\t\t\t\t\t\t\t<CardBody>{ section.content }</CardBody>\n\t\t\t\t\t\t\t\t</Card>\n\t\t\t\t\t\t\t</Navigator.Screen>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t</Navigator>\n\t\t);\n\t}\n\n\treturn modalContent;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,SAAS,EACTC,uBAAuB,IAAIC,SAAS,EACpCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,sBAAsB,IAAIC,QAAQ,EAClCC,QAAQ,EACRC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,WAAW,EAAEC,YAAY,EAAEC,IAAI,QAAQ,kBAAkB;AAClE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,eACFG,IAAA,CAAClB,IAAI;gBAACyD,IAAI,EAAC,IAAI;gBAAAhB,QAAA,EACZsB,OAAO,CAAC5B;cAAQ,CACb,CAAC;YAAA,CACI,CAAC,eACbjB,IAAA,CAACZ,QAAQ;cAAAmC,QAAA,EAAGsB,OAAO,CAAC1B;YAAO,CAAY,CAAC;UAAA,CACnC;QAAC,GAvBD,GAAI0B,OAAO,CAAC7B,IAAI,OAwBL,CAAC;MAErB,CAAE,CAAC;IAAA,CACM,CACX;EACF;EAEA,OAAOK,YAAY;AACpB","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preferences-modal-tabs/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tNavigator,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\t__experimentalTruncate as Truncate,\n\tFlexItem,\n\tCard,\n\tCardHeader,\n\tCardBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { chevronLeft, chevronRight, Icon } from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst PREFERENCES_MENU = 'preferences-menu';\n\nexport default function PreferencesModalTabs( { sections } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\t// This is also used to sync the two different rendered components\n\t// between small and large viewports.\n\tconst [ activeMenu, setActiveMenu ] = useState( PREFERENCES_MENU );\n\t/**\n\t * Create helper objects from `sections` for easier data handling.\n\t * `tabs` is used for creating the `Tabs` and `sectionsContentMap`\n\t * is used for easier access to active tab's content.\n\t */\n\tconst { tabs, sectionsContentMap } = useMemo( () => {\n\t\tlet mappedTabs = {\n\t\t\ttabs: [],\n\t\t\tsectionsContentMap: {},\n\t\t};\n\t\tif ( sections.length ) {\n\t\t\tmappedTabs = sections.reduce(\n\t\t\t\t( accumulator, { name, tabLabel: title, content } ) => {\n\t\t\t\t\taccumulator.tabs.push( { name, title } );\n\t\t\t\t\taccumulator.sectionsContentMap[ name ] = content;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ tabs: [], sectionsContentMap: {} }\n\t\t\t);\n\t\t}\n\t\treturn mappedTabs;\n\t}, [ sections ] );\n\n\tlet modalContent;\n\t// We render different components based on the viewport size.\n\tif ( isLargeViewport ) {\n\t\tmodalContent = (\n\t\t\t<div className=\"preferences__tabs\">\n\t\t\t\t<Tabs\n\t\t\t\t\tdefaultTabId={\n\t\t\t\t\t\tactiveMenu !== PREFERENCES_MENU ? activeMenu : undefined\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={ setActiveMenu }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t>\n\t\t\t\t\t<Tabs.TabList className=\"preferences__tabs-tablist\">\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\tclassName=\"preferences__tabs-tab\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\tclassName=\"preferences__tabs-tabpanel\"\n\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sectionsContentMap[ tab.name ] || null }\n\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tmodalContent = (\n\t\t\t<Navigator initialPath=\"/\" className=\"preferences__provider\">\n\t\t\t\t<Navigator.Screen path=\"/\">\n\t\t\t\t\t<Card isBorderless size=\"small\">\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t{ tabs.map( ( tab ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<Navigator.Button\n\t\t\t\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\t\t\t\tpath={ `/${ tab.name }` }\n\t\t\t\t\t\t\t\t\t\t\tas={ Item }\n\t\t\t\t\t\t\t\t\t\t\tisAction\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t</Navigator.Button>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t</Card>\n\t\t\t\t</Navigator.Screen>\n\t\t\t\t{ sections.length &&\n\t\t\t\t\tsections.map( ( section ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Navigator.Screen\n\t\t\t\t\t\t\t\tkey={ `${ section.name }-menu` }\n\t\t\t\t\t\t\t\tpath={ `/${ section.name }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Card isBorderless size=\"large\">\n\t\t\t\t\t\t\t\t\t<CardHeader\n\t\t\t\t\t\t\t\t\t\tisBorderless={ false }\n\t\t\t\t\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\tgap=\"6\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Navigator.BackButton\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Text size=\"16\">\n\t\t\t\t\t\t\t\t\t\t\t{ section.tabLabel }\n\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t</CardHeader>\n\t\t\t\t\t\t\t\t\t<CardBody>{ section.content }</CardBody>\n\t\t\t\t\t\t\t\t</Card>\n\t\t\t\t\t\t\t</Navigator.Screen>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t</Navigator>\n\t\t);\n\t}\n\n\tretur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,MAAK;AAAA,kBACL,KAAI;AAAA,kBAEJ;AAAA;AAAA,sBAAC,UAAU;AAAA,sBAAV;AAAA,wBACA,MACC,MAAM,IACH,eACA;AAAA,wBAEJ,OAAQ,GAAI,MAAO;AAAA;AAAA,oBACpB;AAAA,oBACA,oBAAC,QAAK,MAAK,MACR,kBAAQ,UACX;AAAA;AAAA;AAAA,cACD;AAAA,cACA,oBAAC,YAAW,kBAAQ,SAAS;AAAA,eAC9B;AAAA;AAAA,UAvBM,GAAI,QAAQ,IAAK;AAAA,QAwBxB;AAAA,MAEF,CAAE;AAAA,OACJ;AAAA,EAEF;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
|
|
1
|
+
export * from "./components";
|
|
2
|
+
import { store } from "./store";
|
|
3
|
+
export * from "./private-apis";
|
|
4
|
+
export {
|
|
5
|
+
store
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["export * from './components';\nexport { store } from './store';\nexport * from './private-apis';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,SAAS,aAAa;AACtB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
|
+
"@wordpress/preferences"
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
6
7
|
lock,
|
|
7
8
|
unlock
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=lock-unlock.js.map
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/preferences'\n\t);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wDAAwD;AAC1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import PreferencesModalTabs from './components/preferences-modal-tabs';
|
|
9
|
-
import { lock } from './lock-unlock';
|
|
10
|
-
export const privateApis = {};
|
|
1
|
+
import PreferenceBaseOption from "./components/preference-base-option";
|
|
2
|
+
import PreferenceToggleControl from "./components/preference-toggle-control";
|
|
3
|
+
import PreferencesModal from "./components/preferences-modal";
|
|
4
|
+
import PreferencesModalSection from "./components/preferences-modal-section";
|
|
5
|
+
import PreferencesModalTabs from "./components/preferences-modal-tabs";
|
|
6
|
+
import { lock } from "./lock-unlock";
|
|
7
|
+
const privateApis = {};
|
|
11
8
|
lock(privateApis, {
|
|
12
9
|
PreferenceBaseOption,
|
|
13
10
|
PreferenceToggleControl,
|
|
@@ -15,4 +12,7 @@ lock(privateApis, {
|
|
|
15
12
|
PreferencesModalSection,
|
|
16
13
|
PreferencesModalTabs
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
export {
|
|
16
|
+
privateApis
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/private-apis.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport PreferenceBaseOption from './components/preference-base-option';\nimport PreferenceToggleControl from './components/preference-toggle-control';\nimport PreferencesModal from './components/preferences-modal';\nimport PreferencesModalSection from './components/preferences-modal-section';\nimport PreferencesModalTabs from './components/preferences-modal-tabs';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tPreferenceBaseOption,\n\tPreferenceToggleControl,\n\tPreferencesModal,\n\tPreferencesModalSection,\n\tPreferencesModalTabs,\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,0BAA0B;AACjC,OAAO,6BAA6B;AACpC,OAAO,sBAAsB;AAC7B,OAAO,6BAA6B;AACpC,OAAO,0BAA0B;AACjC,SAAS,YAAY;AAEd,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,86 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* toggled.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} scope The preference scope (e.g. core/edit-post).
|
|
6
|
-
* @param {string} name The preference name.
|
|
7
|
-
*/
|
|
8
|
-
export function toggle(scope, name) {
|
|
9
|
-
return function ({
|
|
10
|
-
select,
|
|
11
|
-
dispatch
|
|
12
|
-
}) {
|
|
1
|
+
function toggle(scope, name) {
|
|
2
|
+
return function({ select, dispatch }) {
|
|
13
3
|
const currentValue = select.get(scope, name);
|
|
14
4
|
dispatch.set(scope, name, !currentValue);
|
|
15
5
|
};
|
|
16
6
|
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns an action object used in signalling that a preference should be set
|
|
20
|
-
* to a value
|
|
21
|
-
*
|
|
22
|
-
* @param {string} scope The preference scope (e.g. core/edit-post).
|
|
23
|
-
* @param {string} name The preference name.
|
|
24
|
-
* @param {*} value The value to set.
|
|
25
|
-
*
|
|
26
|
-
* @return {Object} Action object.
|
|
27
|
-
*/
|
|
28
|
-
export function set(scope, name, value) {
|
|
7
|
+
function set(scope, name, value) {
|
|
29
8
|
return {
|
|
30
|
-
type:
|
|
9
|
+
type: "SET_PREFERENCE_VALUE",
|
|
31
10
|
scope,
|
|
32
11
|
name,
|
|
33
12
|
value
|
|
34
13
|
};
|
|
35
14
|
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Returns an action object used in signalling that preference defaults should
|
|
39
|
-
* be set.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} scope The preference scope (e.g. core/edit-post).
|
|
42
|
-
* @param {Object<string, *>} defaults A key/value map of preference names to values.
|
|
43
|
-
*
|
|
44
|
-
* @return {Object} Action object.
|
|
45
|
-
*/
|
|
46
|
-
export function setDefaults(scope, defaults) {
|
|
15
|
+
function setDefaults(scope, defaults) {
|
|
47
16
|
return {
|
|
48
|
-
type:
|
|
17
|
+
type: "SET_PREFERENCE_DEFAULTS",
|
|
49
18
|
scope,
|
|
50
19
|
defaults
|
|
51
20
|
};
|
|
52
21
|
}
|
|
53
|
-
|
|
54
|
-
/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
|
|
55
|
-
/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
|
|
56
|
-
/**
|
|
57
|
-
* @typedef WPPreferencesPersistenceLayer
|
|
58
|
-
*
|
|
59
|
-
* @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.
|
|
60
|
-
* @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Sets the persistence layer.
|
|
65
|
-
*
|
|
66
|
-
* When a persistence layer is set, the preferences store will:
|
|
67
|
-
* - call `get` immediately and update the store state to the value returned.
|
|
68
|
-
* - call `set` with all preferences whenever a preference changes value.
|
|
69
|
-
*
|
|
70
|
-
* `setPersistenceLayer` should ideally be dispatched at the start of an
|
|
71
|
-
* application's lifecycle, before any other actions have been dispatched to
|
|
72
|
-
* the preferences store.
|
|
73
|
-
*
|
|
74
|
-
* @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.
|
|
75
|
-
*
|
|
76
|
-
* @return {Object} Action object.
|
|
77
|
-
*/
|
|
78
|
-
export async function setPersistenceLayer(persistenceLayer) {
|
|
22
|
+
async function setPersistenceLayer(persistenceLayer) {
|
|
79
23
|
const persistedData = await persistenceLayer.get();
|
|
80
24
|
return {
|
|
81
|
-
type:
|
|
25
|
+
type: "SET_PERSISTENCE_LAYER",
|
|
82
26
|
persistenceLayer,
|
|
83
27
|
persistedData
|
|
84
28
|
};
|
|
85
29
|
}
|
|
86
|
-
|
|
30
|
+
export {
|
|
31
|
+
set,
|
|
32
|
+
setDefaults,
|
|
33
|
+
setPersistenceLayer,
|
|
34
|
+
toggle
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/actions.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns an action object used in signalling that a preference should be\n * toggled.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n */\nexport function toggle( scope, name ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a preference should be set\n * to a value\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n * @param {*} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function set( scope, name, value ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {Object<string, *>} defaults A key/value map of preference names to values.\n *\n * @return {Object} Action object.\n */\nexport function setDefaults( scope, defaults ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\n/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */\n/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */\n/**\n * @typedef WPPreferencesPersistenceLayer\n *\n * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.\n * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.\n */\n\n/**\n * Sets the persistence layer.\n *\n * When a persistence layer is set, the preferences store will:\n * - call `get` immediately and update the store state to the value returned.\n * - call `set` with all preferences whenever a preference changes value.\n *\n * `setPersistenceLayer` should ideally be dispatched at the start of an\n * application's lifecycle, before any other actions have been dispatched to\n * the preferences store.\n *\n * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.\n *\n * @return {Object} Action object.\n */\nexport async function setPersistenceLayer( persistenceLayer ) {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "AAOO,SAAS,OAAQ,OAAO,MAAO;AACrC,SAAO,SAAW,EAAE,QAAQ,SAAS,GAAI;AACxC,UAAM,eAAe,OAAO,IAAK,OAAO,IAAK;AAC7C,aAAS,IAAK,OAAO,MAAM,CAAE,YAAa;AAAA,EAC3C;AACD;AAYO,SAAS,IAAK,OAAO,MAAM,OAAQ;AACzC,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAWO,SAAS,YAAa,OAAO,UAAW;AAC9C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AA0BA,eAAsB,oBAAqB,kBAAmB;AAC7D,QAAM,gBAAgB,MAAM,iBAAiB,IAAI;AACjD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const STORE_NAME = 'core/preferences';
|
|
7
|
-
//# sourceMappingURL=constants.js.map
|
|
1
|
+
const STORE_NAME = "core/preferences";
|
|
2
|
+
export {
|
|
3
|
+
STORE_NAME
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/constants.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/preferences';\n"],
|
|
5
|
+
"mappings": "AAKO,MAAM,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import reducer from './reducer';
|
|
10
|
-
import * as actions from './actions';
|
|
11
|
-
import * as selectors from './selectors';
|
|
12
|
-
import { STORE_NAME } from './constants';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Store definition for the preferences namespace.
|
|
16
|
-
*
|
|
17
|
-
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
|
18
|
-
*
|
|
19
|
-
* @type {Object}
|
|
20
|
-
*/
|
|
21
|
-
export const store = createReduxStore(STORE_NAME, {
|
|
1
|
+
import { createReduxStore, register } from "@wordpress/data";
|
|
2
|
+
import reducer from "./reducer";
|
|
3
|
+
import * as actions from "./actions";
|
|
4
|
+
import * as selectors from "./selectors";
|
|
5
|
+
import { STORE_NAME } from "./constants";
|
|
6
|
+
const store = createReduxStore(STORE_NAME, {
|
|
22
7
|
reducer,
|
|
23
8
|
actions,
|
|
24
9
|
selectors
|
|
25
10
|
});
|
|
26
11
|
register(store);
|
|
27
|
-
|
|
12
|
+
export {
|
|
13
|
+
store
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the preferences namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,SAAS,kBAAkB;AASpB,MAAM,QAAQ,iBAAkB,YAAY;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reducer returning the defaults for user preferences.
|
|
8
|
-
*
|
|
9
|
-
* This is kept intentionally separate from the preferences
|
|
10
|
-
* themselves so that defaults are not persisted.
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} state Current state.
|
|
13
|
-
* @param {Object} action Dispatched action.
|
|
14
|
-
*
|
|
15
|
-
* @return {Object} Updated state.
|
|
16
|
-
*/
|
|
17
|
-
export function defaults(state = {}, action) {
|
|
18
|
-
if (action.type === 'SET_PREFERENCE_DEFAULTS') {
|
|
19
|
-
const {
|
|
20
|
-
scope,
|
|
21
|
-
defaults: values
|
|
22
|
-
} = action;
|
|
1
|
+
import { combineReducers } from "@wordpress/data";
|
|
2
|
+
function defaults(state = {}, action) {
|
|
3
|
+
if (action.type === "SET_PREFERENCE_DEFAULTS") {
|
|
4
|
+
const { scope, defaults: values } = action;
|
|
23
5
|
return {
|
|
24
6
|
...state,
|
|
25
7
|
[scope]: {
|
|
@@ -30,53 +12,24 @@ export function defaults(state = {}, action) {
|
|
|
30
12
|
}
|
|
31
13
|
return state;
|
|
32
14
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Higher order reducer that does the following:
|
|
36
|
-
* - Merges any data from the persistence layer into the state when the
|
|
37
|
-
* `SET_PERSISTENCE_LAYER` action is received.
|
|
38
|
-
* - Passes any preferences changes to the persistence layer.
|
|
39
|
-
*
|
|
40
|
-
* @param {Function} reducer The preferences reducer.
|
|
41
|
-
*
|
|
42
|
-
* @return {Function} The enhanced reducer.
|
|
43
|
-
*/
|
|
44
15
|
function withPersistenceLayer(reducer) {
|
|
45
16
|
let persistenceLayer;
|
|
46
17
|
return (state, action) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (action.type === 'SET_PERSISTENCE_LAYER') {
|
|
50
|
-
const {
|
|
51
|
-
persistenceLayer: persistence,
|
|
52
|
-
persistedData
|
|
53
|
-
} = action;
|
|
18
|
+
if (action.type === "SET_PERSISTENCE_LAYER") {
|
|
19
|
+
const { persistenceLayer: persistence, persistedData } = action;
|
|
54
20
|
persistenceLayer = persistence;
|
|
55
21
|
return persistedData;
|
|
56
22
|
}
|
|
57
23
|
const nextState = reducer(state, action);
|
|
58
|
-
if (action.type ===
|
|
24
|
+
if (action.type === "SET_PREFERENCE_VALUE") {
|
|
59
25
|
persistenceLayer?.set(nextState);
|
|
60
26
|
}
|
|
61
27
|
return nextState;
|
|
62
28
|
};
|
|
63
29
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} state Current state.
|
|
69
|
-
* @param {Object} action Dispatched action.
|
|
70
|
-
*
|
|
71
|
-
* @return {Object} Updated state.
|
|
72
|
-
*/
|
|
73
|
-
export const preferences = withPersistenceLayer((state = {}, action) => {
|
|
74
|
-
if (action.type === 'SET_PREFERENCE_VALUE') {
|
|
75
|
-
const {
|
|
76
|
-
scope,
|
|
77
|
-
name,
|
|
78
|
-
value
|
|
79
|
-
} = action;
|
|
30
|
+
const preferences = withPersistenceLayer((state = {}, action) => {
|
|
31
|
+
if (action.type === "SET_PREFERENCE_VALUE") {
|
|
32
|
+
const { scope, name, value } = action;
|
|
80
33
|
return {
|
|
81
34
|
...state,
|
|
82
35
|
[scope]: {
|
|
@@ -87,8 +40,13 @@ export const preferences = withPersistenceLayer((state = {}, action) => {
|
|
|
87
40
|
}
|
|
88
41
|
return state;
|
|
89
42
|
});
|
|
90
|
-
|
|
43
|
+
var reducer_default = combineReducers({
|
|
91
44
|
defaults,
|
|
92
45
|
preferences
|
|
93
46
|
});
|
|
94
|
-
|
|
47
|
+
export {
|
|
48
|
+
reducer_default as default,
|
|
49
|
+
defaults,
|
|
50
|
+
preferences
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/reducer.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function defaults( state = {}, action ) {\n\tif ( action.type === 'SET_PREFERENCE_DEFAULTS' ) {\n\t\tconst { scope, defaults: values } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t...values,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher order reducer that does the following:\n * - Merges any data from the persistence layer into the state when the\n * `SET_PERSISTENCE_LAYER` action is received.\n * - Passes any preferences changes to the persistence layer.\n *\n * @param {Function} reducer The preferences reducer.\n *\n * @return {Function} The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer ) {\n\tlet persistenceLayer;\n\n\treturn ( state, action ) => {\n\t\t// Setup the persistence layer, and return the persisted data\n\t\t// as the state.\n\t\tif ( action.type === 'SET_PERSISTENCE_LAYER' ) {\n\t\t\tconst { persistenceLayer: persistence, persistedData } = action;\n\t\t\tpersistenceLayer = persistence;\n\t\t\treturn persistedData;\n\t\t}\n\n\t\tconst nextState = reducer( state, action );\n\t\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\t\tpersistenceLayer?.set( nextState );\n\t\t}\n\n\t\treturn nextState;\n\t};\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = withPersistenceLayer( ( state = {}, action ) => {\n\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\tconst { scope, name, value } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t[ name ]: value,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n} );\n\nexport default combineReducers( {\n\tdefaults,\n\tpreferences,\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,uBAAuB;AAazB,SAAS,SAAU,QAAQ,CAAC,GAAG,QAAS;AAC9C,MAAK,OAAO,SAAS,2BAA4B;AAChD,UAAM,EAAE,OAAO,UAAU,OAAO,IAAI;AACpC,WAAO;AAAA,MACN,GAAG;AAAA,MACH,CAAE,KAAM,GAAG;AAAA,QACV,GAAG,MAAO,KAAM;AAAA,QAChB,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAYA,SAAS,qBAAsB,SAAU;AACxC,MAAI;AAEJ,SAAO,CAAE,OAAO,WAAY;AAG3B,QAAK,OAAO,SAAS,yBAA0B;AAC9C,YAAM,EAAE,kBAAkB,aAAa,cAAc,IAAI;AACzD,yBAAmB;AACnB,aAAO;AAAA,IACR;AAEA,UAAM,YAAY,QAAS,OAAO,MAAO;AACzC,QAAK,OAAO,SAAS,wBAAyB;AAC7C,wBAAkB,IAAK,SAAU;AAAA,IAClC;AAEA,WAAO;AAAA,EACR;AACD;AAUO,MAAM,cAAc,qBAAsB,CAAE,QAAQ,CAAC,GAAG,WAAY;AAC1E,MAAK,OAAO,SAAS,wBAAyB;AAC7C,UAAM,EAAE,OAAO,MAAM,MAAM,IAAI;AAC/B,WAAO;AAAA,MACN,GAAG;AAAA,MACH,CAAE,KAAM,GAAG;AAAA,QACV,GAAG,MAAO,KAAM;AAAA,QAChB,CAAE,IAAK,GAAG;AAAA,MACX;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR,CAAE;AAEF,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AAAA,EACA;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import deprecated from "@wordpress/deprecated";
|
|
2
|
+
const withDeprecatedKeys = (originalGet) => (state, scope, name) => {
|
|
3
|
+
const settingsToMoveToCore = [
|
|
4
|
+
"allowRightClickOverrides",
|
|
5
|
+
"distractionFree",
|
|
6
|
+
"editorMode",
|
|
7
|
+
"fixedToolbar",
|
|
8
|
+
"focusMode",
|
|
9
|
+
"hiddenBlockTypes",
|
|
10
|
+
"inactivePanels",
|
|
11
|
+
"keepCaretInsideBlock",
|
|
12
|
+
"mostUsedBlocks",
|
|
13
|
+
"openPanels",
|
|
14
|
+
"showBlockBreadcrumbs",
|
|
15
|
+
"showIconLabels",
|
|
16
|
+
"showListViewByDefault",
|
|
17
|
+
"isPublishSidebarEnabled",
|
|
18
|
+
"isComplementaryAreaVisible",
|
|
19
|
+
"pinnedItems"
|
|
20
|
+
];
|
|
21
|
+
if (settingsToMoveToCore.includes(name) && ["core/edit-post", "core/edit-site"].includes(scope)) {
|
|
22
|
+
deprecated(
|
|
23
|
+
`wp.data.select( 'core/preferences' ).get( '${scope}', '${name}' )`,
|
|
24
|
+
{
|
|
25
|
+
since: "6.5",
|
|
26
|
+
alternative: `wp.data.select( 'core/preferences' ).get( 'core', '${name}' )`
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
return originalGet(state, "core", name);
|
|
13
30
|
}
|
|
14
31
|
return originalGet(state, scope, name);
|
|
15
32
|
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns a boolean indicating whether a prefer is active for a particular
|
|
19
|
-
* scope.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} state The store state.
|
|
22
|
-
* @param {string} scope The scope of the feature (e.g. core/edit-post).
|
|
23
|
-
* @param {string} name The name of the feature.
|
|
24
|
-
*
|
|
25
|
-
* @return {*} Is the feature enabled?
|
|
26
|
-
*/
|
|
27
|
-
export const get = withDeprecatedKeys((state, scope, name) => {
|
|
33
|
+
const get = withDeprecatedKeys((state, scope, name) => {
|
|
28
34
|
const value = state.preferences[scope]?.[name];
|
|
29
|
-
return value !==
|
|
35
|
+
return value !== void 0 ? value : state.defaults[scope]?.[name];
|
|
30
36
|
});
|
|
31
|
-
|
|
37
|
+
export {
|
|
38
|
+
get
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/selectors.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nconst withDeprecatedKeys = ( originalGet ) => ( state, scope, name ) => {\n\tconst settingsToMoveToCore = [\n\t\t'allowRightClickOverrides',\n\t\t'distractionFree',\n\t\t'editorMode',\n\t\t'fixedToolbar',\n\t\t'focusMode',\n\t\t'hiddenBlockTypes',\n\t\t'inactivePanels',\n\t\t'keepCaretInsideBlock',\n\t\t'mostUsedBlocks',\n\t\t'openPanels',\n\t\t'showBlockBreadcrumbs',\n\t\t'showIconLabels',\n\t\t'showListViewByDefault',\n\t\t'isPublishSidebarEnabled',\n\t\t'isComplementaryAreaVisible',\n\t\t'pinnedItems',\n\t];\n\n\tif (\n\t\tsettingsToMoveToCore.includes( name ) &&\n\t\t[ 'core/edit-post', 'core/edit-site' ].includes( scope )\n\t) {\n\t\tdeprecated(\n\t\t\t`wp.data.select( 'core/preferences' ).get( '${ scope }', '${ name }' )`,\n\t\t\t{\n\t\t\t\tsince: '6.5',\n\t\t\t\talternative: `wp.data.select( 'core/preferences' ).get( 'core', '${ name }' )`,\n\t\t\t}\n\t\t);\n\n\t\treturn originalGet( state, 'core', name );\n\t}\n\n\treturn originalGet( state, scope, name );\n};\n\n/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} name The name of the feature.\n *\n * @return {*} Is the feature enabled?\n */\nexport const get = withDeprecatedKeys( ( state, scope, name ) => {\n\tconst value = state.preferences[ scope ]?.[ name ];\n\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,gBAAgB;AAEvB,MAAM,qBAAqB,CAAE,gBAAiB,CAAE,OAAO,OAAO,SAAU;AACvE,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,MACC,qBAAqB,SAAU,IAAK,KACpC,CAAE,kBAAkB,gBAAiB,EAAE,SAAU,KAAM,GACtD;AACD;AAAA,MACC,8CAA+C,KAAM,OAAQ,IAAK;AAAA,MAClE;AAAA,QACC,OAAO;AAAA,QACP,aAAa,sDAAuD,IAAK;AAAA,MAC1E;AAAA,IACD;AAEA,WAAO,YAAa,OAAO,QAAQ,IAAK;AAAA,EACzC;AAEA,SAAO,YAAa,OAAO,OAAO,IAAK;AACxC;AAYO,MAAM,MAAM,mBAAoB,CAAE,OAAO,OAAO,SAAU;AAChE,QAAM,QAAQ,MAAM,YAAa,KAAM,IAAK,IAAK;AACjD,SAAO,UAAU,SAAY,QAAQ,MAAM,SAAU,KAAM,IAAK,IAAK;AACtE,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|