@wordpress/preferences 4.34.0 → 4.35.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/CHANGELOG.md +2 -0
- package/build/components/index.js +2 -0
- package/build/components/index.js.map +1 -1
- package/build/components/preference-base-option/index.js +3 -1
- package/build/components/preference-base-option/index.js.map +1 -1
- package/build/components/preference-base-option/types.js +2 -0
- package/build/components/preference-base-option/types.js.map +1 -1
- package/build/components/preference-toggle-control/index.js +3 -1
- package/build/components/preference-toggle-control/index.js.map +1 -1
- package/build/components/preference-toggle-menu-item/index.js +3 -1
- package/build/components/preference-toggle-menu-item/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/types.js +2 -0
- package/build/components/preferences-modal/types.js.map +1 -1
- package/build/components/preferences-modal-section/index.js +3 -1
- package/build/components/preferences-modal-section/index.js.map +1 -1
- package/build/components/preferences-modal-tabs/index.js +5 -3
- package/build/components/preferences-modal-tabs/index.js.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +3 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +3 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +4 -2
- package/build/store/selectors.js.map +1 -1
- package/build/store/types.js +2 -0
- package/build/store/types.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/preference-base-option/index.js +2 -1
- package/build-module/components/preference-base-option/index.js.map +1 -1
- package/build-module/components/preference-toggle-control/index.js +2 -1
- package/build-module/components/preference-toggle-control/index.js.map +1 -1
- package/build-module/components/preference-toggle-menu-item/index.js +2 -1
- package/build-module/components/preference-toggle-menu-item/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +2 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal-section/index.js +2 -1
- package/build-module/components/preferences-modal-section/index.js.map +1 -1
- package/build-module/components/preferences-modal-tabs/index.js +4 -3
- package/build-module/components/preferences-modal-tabs/index.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +1 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +2 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +2 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-types/components/preferences-modal-section/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/package.json +12 -12
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preference-toggle-control/index.tsx"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\nimport type { BaseOptionProps } from '../preference-base-option/types';\nimport PreferenceBaseOption from '../preference-base-option';\n\nexport type PreferenceToggleControlProps = {\n\tscope: string;\n\tfeatureName: string;\n\tonToggle: () => void;\n} & Omit< BaseOptionProps, 'onChange' | 'isChecked' >;\n\nfunction PreferenceToggleControl( props: PreferenceToggleControlProps ) {\n\tconst {\n\t\tscope,\n\t\tfeatureName,\n\t\tonToggle = () => {},\n\t\t...remainingProps\n\t} = props;\n\tconst isChecked = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, featureName ),\n\t\t[ scope, featureName ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst onChange = () => {\n\t\tonToggle();\n\t\ttoggle( scope, featureName );\n\t};\n\n\treturn (\n\t\t<PreferenceBaseOption\n\t\t\t{ ...remainingProps }\n\t\t\tonChange={ onChange }\n\t\t\tisChecked={ isChecked }\n\t\t/>\n\t);\n}\n\nexport default PreferenceToggleControl;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AAKvC,SAAS,SAAS,wBAAwB;AAE1C,OAAO,0BAA0B;AA0B/B;AAlBF,SAAS,wBAAyB,OAAsC;AACvE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,MAAM;AAAA,IAAC;AAAA,IAClB,GAAG;AAAA,EACJ,IAAI;AACJ,QAAM,YAAY;AAAA,IACjB,CAAE,WAAY,CAAC,CAAE,OAAQ,gBAAiB,EAAE,IAAK,OAAO,WAAY;AAAA,IACpE,CAAE,OAAO,WAAY;AAAA,EACtB;AACA,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,WAAW,MAAM;AACtB,aAAS;AACT,WAAQ,OAAO,WAAY;AAAA,EAC5B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL;AAAA,MACA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,oCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/preferences/src/components/preference-toggle-menu-item/index.tsx
|
|
2
2
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
3
3
|
import { MenuItem } from "@wordpress/components";
|
|
4
4
|
import { __, sprintf } from "@wordpress/i18n";
|
|
5
5
|
import { check } from "@wordpress/icons";
|
|
6
6
|
import { speak } from "@wordpress/a11y";
|
|
7
7
|
import { store as preferencesStore } from "../../store";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
function PreferenceToggleMenuItem({
|
|
9
10
|
scope,
|
|
10
11
|
name,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preference-toggle-menu-item/index.tsx"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\ntype PreferenceToggleMenuItemProps = {\n\tscope: string;\n\tname: string;\n\tlabel: string;\n\tinfo?: string;\n\tmessageActivated?: string;\n\tmessageDeactivated?: string;\n\tshortcut?: string | { display: string; ariaLabel: string };\n\thandleToggling?: boolean;\n\tonToggle?: () => void;\n\tdisabled?: boolean;\n};\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\thandleToggling = true,\n\tonToggle = () => null,\n\tdisabled = false,\n}: PreferenceToggleMenuItemProps ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive ? check : null }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\tonToggle();\n\t\t\t\tif ( handleToggling ) {\n\t\t\t\t\ttoggle( scope, name );\n\t\t\t\t}\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,aAAa;AAKtB,SAAS,SAAS,wBAAwB;AAsDxC;AAxCa,SAAR,yBAA2C;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,WAAW;AACZ,GAAmC;AAClC,QAAM,WAAW;AAAA,IAChB,CAAE,WAAY,CAAC,CAAE,OAAQ,gBAAiB,EAAE,IAAK,OAAO,IAAK;AAAA,IAC7D,CAAE,OAAO,IAAK;AAAA,EACf;AACA,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,eAAe,MAAM;AAC1B,QAAK,UAAW;AACf,YAAM,UACL,sBACA;AAAA;AAAA,QAEC,GAAI,6BAA8B;AAAA,QAClC;AAAA,MACD;AACD,YAAO,OAAQ;AAAA,IAChB,OAAO;AACN,YAAM,UACL,oBACA;AAAA;AAAA,QAEC,GAAI,2BAA4B;AAAA,QAChC;AAAA,MACD;AACD,YAAO,OAAQ;AAAA,IAChB;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO,WAAW,QAAQ;AAAA,MAC1B,YAAa;AAAA,MACb,SAAU,MAAM;AACf,iBAAS;AACT,YAAK,gBAAiB;AACrB,iBAAQ,OAAO,IAAK;AAAA,QACrB;AACA,qBAAa;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/preferences/src/components/preferences-modal/index.tsx
|
|
2
2
|
import { Modal } from "@wordpress/components";
|
|
3
3
|
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
function PreferencesModal({
|
|
5
6
|
closeModal,
|
|
6
7
|
children
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preferences-modal/index.tsx"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport type { PreferencesModalProps } from './types';\n\nexport default function PreferencesModal( {\n\tcloseModal,\n\tchildren,\n}: PreferencesModalProps ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"preferences-modal\"\n\t\t\ttitle={ __( 'Preferences' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t>\n\t\t\t{ children }\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,UAAU;AAWjB;AALa,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AACD,GAA2B;AAC1B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,aAAc;AAAA,MAC1B,gBAAiB;AAAA,MAEf;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// packages/preferences/src/components/preferences-modal-section/index.tsx
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
+
var Section = ({ description, title, children }) => /* @__PURE__ */ jsxs("fieldset", { className: "preferences-modal__section", children: [
|
|
3
4
|
/* @__PURE__ */ jsxs("legend", { className: "preferences-modal__section-legend", children: [
|
|
4
5
|
/* @__PURE__ */ jsx("h2", { className: "preferences-modal__section-title", children: title }),
|
|
5
6
|
description && /* @__PURE__ */ jsx("p", { className: "preferences-modal__section-description", children: description })
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preferences-modal-section/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export type SectionProps = {\n\tdescription?: React.ReactNode;\n\ttitle?: React.ReactNode;\n\tchildren?: React.ReactNode;\n};\n\nconst Section = ( { description, title, children }: SectionProps ) => (\n\t<fieldset className=\"preferences-modal__section\">\n\t\t<legend className=\"preferences-modal__section-legend\">\n\t\t\t<h2 className=\"preferences-modal__section-title\">{ title }</h2>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"preferences-modal__section-description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</legend>\n\t\t<div className=\"preferences-modal__section-content\">{ children }</div>\n\t</fieldset>\n);\n\nexport default Section;\n"],
|
|
5
|
-
"mappings": "AAQE,SACC,KADD;AAFF,
|
|
5
|
+
"mappings": ";AAQE,SACC,KADD;AAFF,IAAM,UAAU,CAAE,EAAE,aAAa,OAAO,SAAS,MAChD,qBAAC,cAAS,WAAU,8BACnB;AAAA,uBAAC,YAAO,WAAU,qCACjB;AAAA,wBAAC,QAAG,WAAU,oCAAqC,iBAAO;AAAA,IACxD,eACD,oBAAC,OAAE,WAAU,0CACV,uBACH;AAAA,KAEF;AAAA,EACA,oBAAC,SAAI,WAAU,sCAAuC,UAAU;AAAA,GACjE;AAGD,IAAO,oCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/preferences/src/components/preferences-modal-tabs/index.tsx
|
|
2
2
|
import { useViewportMatch } from "@wordpress/compose";
|
|
3
3
|
import {
|
|
4
4
|
Navigator,
|
|
@@ -17,8 +17,9 @@ import { useMemo, useState } from "@wordpress/element";
|
|
|
17
17
|
import { chevronLeft, chevronRight, Icon } from "@wordpress/icons";
|
|
18
18
|
import { isRTL, __ } from "@wordpress/i18n";
|
|
19
19
|
import { unlock } from "../../lock-unlock";
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var { Tabs } = unlock(componentsPrivateApis);
|
|
22
|
+
var PREFERENCES_MENU = "preferences-menu";
|
|
22
23
|
function PreferencesModalTabs({
|
|
23
24
|
sections
|
|
24
25
|
}) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preferences-modal-tabs/index.tsx"],
|
|
4
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 type PreferencesModalTabsProps = {\n\tsections: { name: string; tabLabel: string; content: React.ReactNode }[];\n};\nexport default function PreferencesModalTabs( {\n\tsections,\n}: PreferencesModalTabsProps ) {\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: { name: string; title: string }[];\n\t\t\tsectionsContentMap: Record< string, React.ReactNode >;\n\t\t} = {\n\t\t\ttabs: [],\n\t\t\tsectionsContentMap: {},\n\t\t};\n\t\tif ( sections.length ) {\n\t\t\tmappedTabs = sections.reduce< typeof mappedTabs >(\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// @ts-expect-error: Navigator.Button is currently typed in a way that prevents Item from being passed in\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\tas=\"div\"\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"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA,2BAA2B;AAAA,EAC3B,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,gBAAgB;AAClC,SAAS,aAAa,cAAc,YAAY;AAChD,SAAS,OAAO,UAAU;AAK1B,SAAS,cAAc;AAgDnB,SASG,KATH;AA9CJ,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,IAAM,mBAAmB;AAKV,SAAR,qBAAuC;AAAA,EAC7C;AACD,GAA+B;AAC9B,QAAM,kBAA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GED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './components';\nexport { store } from './store';\nexport * from './private-apis';\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,SAAS,aAAa;AACtB,cAAc;",
|
|
5
|
+
"mappings": ";AAAA,cAAc;AACd,SAAS,aAAa;AACtB,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// packages/preferences/src/lock-unlock.ts
|
|
1
2
|
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
-
|
|
3
|
+
var { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
4
|
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
5
|
"@wordpress/preferences"
|
|
5
6
|
);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/lock-unlock.ts"],
|
|
4
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,
|
|
5
|
+
"mappings": ";AAGA,SAAS,wDAAwD;AAC1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// packages/preferences/src/private-apis.ts
|
|
1
2
|
import PreferenceBaseOption from "./components/preference-base-option";
|
|
2
3
|
import PreferenceToggleControl from "./components/preference-toggle-control";
|
|
3
4
|
import PreferencesModal from "./components/preferences-modal";
|
|
4
5
|
import PreferencesModalSection from "./components/preferences-modal-section";
|
|
5
6
|
import PreferencesModalTabs from "./components/preferences-modal-tabs";
|
|
6
7
|
import { lock } from "./lock-unlock";
|
|
7
|
-
|
|
8
|
+
var privateApis = {};
|
|
8
9
|
lock(privateApis, {
|
|
9
10
|
PreferenceBaseOption,
|
|
10
11
|
PreferenceToggleControl,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.ts"],
|
|
4
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,
|
|
5
|
+
"mappings": ";AAGA,OAAO,0BAA0B;AACjC,OAAO,6BAA6B;AACpC,OAAO,sBAAsB;AAC7B,OAAO,6BAA6B;AACpC,OAAO,0BAA0B;AACjC,SAAS,YAAY;AAEd,IAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/actions.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tActionObject,\n\tStoreState,\n\tWPPreferencesPersistenceLayer,\n} from './types';\n\n/**\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: string, name: string ) {\n\t// @ts-expect-error We cannot properly type this until we have a fully-typed datastore\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\ntype SetAction = ActionObject<\n\t'SET_PREFERENCE_VALUE',\n\t{ scope: string; name: string; value: any }\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 {SetAction} Action object.\n */\nexport function set( scope: string, name: string, value: any ): SetAction {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\ntype ScopedDefaults = StoreState[ 'defaults' ][ string ];\ntype SetDefaultsAction = ActionObject<\n\t'SET_PREFERENCE_DEFAULTS',\n\t{ scope: string; defaults: ScopedDefaults }\n>;\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param scope The preference scope (e.g. core/edit-post).\n * @param defaults A key/value map of preference names to values.\n *\n * @return Action object.\n */\nexport function setDefaults(\n\tscope: string,\n\tdefaults: ScopedDefaults\n): SetDefaultsAction {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\ntype SetPersistenceLayerAction< D extends Object > = ActionObject<\n\t'SET_PERSISTENCE_LAYER',\n\t{\n\t\tpersistenceLayer: WPPreferencesPersistenceLayer< D >;\n\t\tpersistedData: D;\n\t}\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 persistenceLayer The persistence layer.\n *\n * @return Action object.\n */\nexport async function setPersistenceLayer< D extends Object >(\n\tpersistenceLayer: WPPreferencesPersistenceLayer< D >\n): Promise< SetPersistenceLayerAction< D > > {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n\nexport type AvailableActions =\n\t| SetAction\n\t| SetDefaultsAction\n\t| SetPersistenceLayerAction< any >;\n"],
|
|
5
|
-
"mappings": "AAgBO,SAAS,OAAQ,OAAe,MAAe;AAErD,SAAO,SAAW,EAAE,QAAQ,SAAS,GAAI;AACxC,UAAM,eAAe,OAAO,IAAK,OAAO,IAAK;AAC7C,aAAS,IAAK,OAAO,MAAM,CAAE,YAAa;AAAA,EAC3C;AACD;AAiBO,SAAS,IAAK,OAAe,MAAc,OAAwB;AACzE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAiBO,SAAS,YACf,OACA,UACoB;AACpB,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAyBA,eAAsB,oBACrB,kBAC4C;AAC5C,QAAM,gBAAgB,MAAM,iBAAiB,IAAI;AACjD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
5
|
+
"mappings": ";AAgBO,SAAS,OAAQ,OAAe,MAAe;AAErD,SAAO,SAAW,EAAE,QAAQ,SAAS,GAAI;AACxC,UAAM,eAAe,OAAO,IAAK,OAAO,IAAK;AAC7C,aAAS,IAAK,OAAO,MAAM,CAAE,YAAa;AAAA,EAC3C;AACD;AAiBO,SAAS,IAAK,OAAe,MAAc,OAAwB;AACzE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAiBO,SAAS,YACf,OACA,UACoB;AACpB,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAyBA,eAAsB,oBACrB,kBAC4C;AAC5C,QAAM,gBAAgB,MAAM,iBAAiB,IAAI;AACjD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
// packages/preferences/src/store/index.ts
|
|
1
2
|
import { createReduxStore, register } from "@wordpress/data";
|
|
2
3
|
import reducer from "./reducer";
|
|
3
4
|
import * as actions from "./actions";
|
|
4
5
|
import * as selectors from "./selectors";
|
|
5
6
|
import { STORE_NAME } from "./constants";
|
|
6
|
-
|
|
7
|
+
var store = createReduxStore(STORE_NAME, {
|
|
7
8
|
reducer,
|
|
8
9
|
actions,
|
|
9
10
|
selectors
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/index.ts"],
|
|
4
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';\nimport type { StoreState } from './types';\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 */\nexport const store = createReduxStore<\n\tStoreState,\n\ttypeof actions,\n\ttypeof selectors\n>( 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;AAQpB,
|
|
5
|
+
"mappings": ";AAGA,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,SAAS,kBAAkB;AAQpB,IAAM,QAAQ,iBAIlB,YAAY;AAAA,EACd;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// packages/preferences/src/store/reducer.ts
|
|
1
2
|
import { combineReducers } from "@wordpress/data";
|
|
2
3
|
function defaults(state = {}, action) {
|
|
3
4
|
if (action.type === "SET_PREFERENCE_DEFAULTS") {
|
|
@@ -27,7 +28,7 @@ function withPersistenceLayer(reducer) {
|
|
|
27
28
|
return nextState;
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
var preferences = withPersistenceLayer((state = {}, action) => {
|
|
31
32
|
if (action.type === "SET_PREFERENCE_VALUE") {
|
|
32
33
|
const { scope, name, value } = action;
|
|
33
34
|
return {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/reducer.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport type { StoreState, WPPreferencesPersistenceLayer } from './types';\nimport type { AvailableActions } from './actions';\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 state Current state.\n * @param action Dispatched action.\n *\n * @return Updated state.\n */\nexport function defaults(\n\tstate: StoreState[ 'defaults' ] = {},\n\taction: AvailableActions\n): StoreState[ 'defaults' ] {\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\ntype PreferencesReducer = (\n\tstate: StoreState[ 'preferences' ],\n\taction: AvailableActions\n) => StoreState[ 'preferences' ];\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 reducer The preferences reducer.\n *\n * @return The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer: PreferencesReducer ) {\n\tlet persistenceLayer: WPPreferencesPersistenceLayer< any >;\n\n\treturn ( state: StoreState[ 'preferences' ], action: AvailableActions ) => {\n\t\t// Set up 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;AAkBzB,SAAS,SACf,QAAkC,CAAC,GACnC,QAC2B;AAC3B,M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AAE,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// packages/preferences/src/store/selectors.ts
|
|
1
2
|
import deprecated from "@wordpress/deprecated";
|
|
2
|
-
|
|
3
|
+
var withDeprecatedKeys = (originalGet) => (state, scope, name) => {
|
|
3
4
|
const settingsToMoveToCore = [
|
|
4
5
|
"allowRightClickOverrides",
|
|
5
6
|
"distractionFree",
|
|
@@ -30,7 +31,7 @@ const withDeprecatedKeys = (originalGet) => (state, scope, name) => {
|
|
|
30
31
|
}
|
|
31
32
|
return originalGet(state, scope, name);
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
+
var get = withDeprecatedKeys(
|
|
34
35
|
(state, scope, name) => {
|
|
35
36
|
const value = state.preferences[scope]?.[name];
|
|
36
37
|
return value !== void 0 ? value : state.defaults[scope]?.[name];
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/selectors.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n/**\n * Internal dependencies\n */\nimport type { StoreState } from './types';\n\nconst withDeprecatedKeys =\n\t(\n\t\toriginalGet: ( state: StoreState, scope: string, name: string ) => any\n\t) =>\n\t( state: StoreState, scope: string, name: string ) => {\n\t\tconst settingsToMoveToCore = [\n\t\t\t'allowRightClickOverrides',\n\t\t\t'distractionFree',\n\t\t\t'editorMode',\n\t\t\t'fixedToolbar',\n\t\t\t'focusMode',\n\t\t\t'hiddenBlockTypes',\n\t\t\t'inactivePanels',\n\t\t\t'keepCaretInsideBlock',\n\t\t\t'mostUsedBlocks',\n\t\t\t'openPanels',\n\t\t\t'showBlockBreadcrumbs',\n\t\t\t'showIconLabels',\n\t\t\t'showListViewByDefault',\n\t\t\t'isPublishSidebarEnabled',\n\t\t\t'isComplementaryAreaVisible',\n\t\t\t'pinnedItems',\n\t\t];\n\n\t\tif (\n\t\t\tsettingsToMoveToCore.includes( name ) &&\n\t\t\t[ 'core/edit-post', 'core/edit-site' ].includes( scope )\n\t\t) {\n\t\t\tdeprecated(\n\t\t\t\t`wp.data.select( 'core/preferences' ).get( '${ scope }', '${ name }' )`,\n\t\t\t\t{\n\t\t\t\t\tsince: '6.5',\n\t\t\t\t\talternative: `wp.data.select( 'core/preferences' ).get( 'core', '${ name }' )`,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\treturn originalGet( state, 'core', name );\n\t\t}\n\n\t\treturn originalGet( state, scope, name );\n\t};\n\n/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {StoreState} 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(\n\t( state: StoreState, scope: string, name: string ) => {\n\t\tconst value = state.preferences[ scope ]?.[ name ];\n\t\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n\t}\n);\n"],
|
|
5
|
-
"mappings": "AAGA,OAAO,gBAAgB;AAMvB,
|
|
5
|
+
"mappings": ";AAGA,OAAO,gBAAgB;AAMvB,IAAM,qBACL,CACC,gBAED,CAAE,OAAmB,OAAe,SAAkB;AACrD,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;AAYM,IAAM,MAAM;AAAA,EAClB,CAAE,OAAmB,OAAe,SAAkB;AACrD,UAAM,QAAQ,MAAM,YAAa,KAAM,IAAK,IAAK;AACjD,WAAO,UAAU,SAAY,QAAQ,MAAM,SAAU,KAAM,IAAK,IAAK;AAAA,EACtE;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preferences-modal-section/index.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preferences-modal-section/index.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,OAAO,GAAK,kCAAkC,YAAY,gCAY/D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAEhC;;;CAAoB,UAItC;AAED,KAAK,SAAS,GAAG,YAAY,CAC5B,sBAAsB,EACtB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAI,SAAS,CAOxE;AAED,KAAK,cAAc,GAAG,UAAU,CAAE,UAAU,CAAE,CAAE,MAAM,CAAE,CAAC;AACzD,KAAK,iBAAiB,GAAG,YAAY,CACpC,yBAAyB,EACzB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,GACtB,iBAAiB,CAMnB;AAED,KAAK,yBAAyB,CAAE,CAAC,SAAS,MAAM,IAAK,YAAY,CAChE,uBAAuB,EACvB;IACC,gBAAgB,EAAE,6BAA6B,CAAE,CAAC,CAAE,CAAC;IACrD,aAAa,EAAE,CAAC,CAAC;CACjB,CACD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CAAE,CAAC,SAAS,MAAM,EAC1D,gBAAgB,EAAE,6BAA6B,CAAE,CAAC,CAAE,GAClD,OAAO,CAAE,yBAAyB,CAAE,CAAC,CAAE,CAAE,CAO3C;AAED,MAAM,MAAM,gBAAgB,GACzB,SAAS,GACT,iBAAiB,GACjB,yBAAyB,CAAE,GAAG,CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/preferences",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.35.0",
|
|
4
4
|
"description": "Utilities for managing WordPress preferences.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
],
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@wordpress/a11y": "^4.
|
|
46
|
-
"@wordpress/base-styles": "^6.
|
|
47
|
-
"@wordpress/components": "^30.
|
|
48
|
-
"@wordpress/compose": "^7.
|
|
49
|
-
"@wordpress/data": "^10.
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/element": "^6.
|
|
52
|
-
"@wordpress/i18n": "^6.
|
|
53
|
-
"@wordpress/icons": "^11.
|
|
54
|
-
"@wordpress/private-apis": "^1.
|
|
45
|
+
"@wordpress/a11y": "^4.35.0",
|
|
46
|
+
"@wordpress/base-styles": "^6.11.0",
|
|
47
|
+
"@wordpress/components": "^30.8.0",
|
|
48
|
+
"@wordpress/compose": "^7.35.0",
|
|
49
|
+
"@wordpress/data": "^10.35.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.35.0",
|
|
51
|
+
"@wordpress/element": "^6.35.0",
|
|
52
|
+
"@wordpress/i18n": "^6.8.0",
|
|
53
|
+
"@wordpress/icons": "^11.2.0",
|
|
54
|
+
"@wordpress/private-apis": "^1.35.0",
|
|
55
55
|
"clsx": "^2.1.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "77aa1f194edceafe8ac2a1b9438bf84b557e76e3"
|
|
65
65
|
}
|