@wordpress/format-library 4.25.0 → 4.25.1-next.79a6196f.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2023 by the contributors
3
+ Copyright 2016-2024 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.unlock = exports.lock = void 0;
7
+ var _privateApis = require("@wordpress/private-apis");
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+
12
+ const {
13
+ lock,
14
+ unlock
15
+ } = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/format-library');
16
+ exports.unlock = unlock;
17
+ exports.lock = lock;
18
+ //# sourceMappingURL=lock-unlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/format-library/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/format-library'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,iHAAiH,EACjH,2BACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
@@ -14,6 +14,7 @@ var _blockEditor = require("@wordpress/block-editor");
14
14
  var _components = require("@wordpress/components");
15
15
  var _i18n = require("@wordpress/i18n");
16
16
  var _index = require("./index");
17
+ var _lockUnlock = require("../lock-unlock");
17
18
  /**
18
19
  * WordPress dependencies
19
20
  */
@@ -22,6 +23,16 @@ var _index = require("./index");
22
23
  * Internal dependencies
23
24
  */
24
25
 
26
+ const {
27
+ Tabs
28
+ } = (0, _lockUnlock.unlock)(_components.privateApis);
29
+ const TABS = [{
30
+ name: 'color',
31
+ title: (0, _i18n.__)('Text')
32
+ }, {
33
+ name: 'backgroundColor',
34
+ title: (0, _i18n.__)('Background')
35
+ }];
25
36
  function parseCSS(css = '') {
26
37
  return css.split(';').reduce((accumulator, rule) => {
27
38
  if (rule) {
@@ -135,21 +146,20 @@ function InlineColorUI({
135
146
  popoverAnchor.getBoundingClientRect = () => cachedRect;
136
147
  return (0, _react.createElement)(_components.Popover, {
137
148
  onClose: onClose,
138
- className: "components-inline-color-popover",
149
+ className: "format-library__inline-color-popover",
139
150
  anchor: popoverAnchor
140
- }, (0, _react.createElement)(_components.TabPanel, {
141
- tabs: [{
142
- name: 'color',
143
- title: (0, _i18n.__)('Text')
144
- }, {
145
- name: 'backgroundColor',
146
- title: (0, _i18n.__)('Background')
147
- }]
148
- }, tab => (0, _react.createElement)(ColorPicker, {
151
+ }, (0, _react.createElement)(Tabs, null, (0, _react.createElement)(Tabs.TabList, null, TABS.map(tab => (0, _react.createElement)(Tabs.Tab, {
152
+ tabId: tab.name,
153
+ key: tab.name
154
+ }, tab.title))), TABS.map(tab => (0, _react.createElement)(Tabs.TabPanel, {
155
+ tabId: tab.name,
156
+ focusable: false,
157
+ key: tab.name
158
+ }, (0, _react.createElement)(ColorPicker, {
149
159
  name: name,
150
160
  property: tab.name,
151
161
  value: value,
152
162
  onChange: onChange
153
- })));
163
+ })))));
154
164
  }
155
165
  //# sourceMappingURL=inline.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_richText","_blockEditor","_components","_i18n","_index","parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getColorObjectByAttributeValues","getActiveColors","activeColorFormat","getActiveFormat","attributes","style","class","setColors","colors","removeFormat","styles","classNames","push","join","getColorObjectByColorValue","getColorClassName","slug","length","applyFormat","type","ColorPicker","onChange","useSelect","select","_getSettings$colors","getSettings","blockEditorStore","onColorChange","useCallback","activeColors","useMemo","_react","createElement","ColorPalette","InlineColorUI","onClose","contentRef","popoverAnchor","useAnchor","editableContentElement","current","settings","cachedRect","useCachedTruthy","getBoundingClientRect","Popover","anchor","TabPanel","tabs","title","__","tab"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings,\n\t} );\n\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );\n\tpopoverAnchor.getBoundingClientRect = () => cachedRect;\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t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AC;EACC,GAECC,GAAG,IACN,IAAApB,MAAA,CAAAC,aAAA,EAACZ,WAAW;IACX1B,IAAI,EAAGA,IAAM;IACbR,QAAQ,EAAGiE,GAAG,CAACzD,IAAM;IACrBP,KAAK,EAAGA,KAAO;IACfkC,QAAQ,EAAGA;EAAU,CACrB,CAEO,CACF,CAAC;AAEZ"}
1
+ {"version":3,"names":["_element","require","_data","_richText","_blockEditor","_components","_i18n","_index","_lockUnlock","Tabs","unlock","componentsPrivateApis","TABS","name","title","__","parseCSS","css","split","reduce","accumulator","rule","property","value","color","transparentValue","backgroundColor","parseClassName","className","colorSettings","startsWith","endsWith","colorSlug","replace","colorObject","getColorObjectByAttributeValues","getActiveColors","activeColorFormat","getActiveFormat","attributes","style","class","setColors","colors","removeFormat","styles","classNames","push","join","getColorObjectByColorValue","getColorClassName","slug","length","applyFormat","type","ColorPicker","onChange","useSelect","select","_getSettings$colors","getSettings","blockEditorStore","onColorChange","useCallback","activeColors","useMemo","_react","createElement","ColorPalette","InlineColorUI","onClose","contentRef","popoverAnchor","useAnchor","editableContentElement","current","settings","cachedRect","useCachedTruthy","getBoundingClientRect","Popover","anchor","TabList","map","tab","Tab","tabId","key","TabPanel","focusable"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings,\n\t} );\n\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );\n\tpopoverAnchor.getBoundingClientRect = () => cachedRect;\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,WAAA,GAAAJ,OAAA;AAIA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AA7BA;AACA;AACA;;AAuBA;AACA;AACA;;AAIA,MAAM;EAAEQ;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhD,MAAMC,IAAI,GAAG,CACZ;EAAEC,IAAI,EAAE,OAAO;EAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO;AAAE,CAAC,EACtC;EAAEF,IAAI,EAAE,iBAAiB;EAAEC,KAAK,EAAE,IAA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hB,IAAAqD,MAAA,CAAAC,aAAA,EAACZ,WAAW;IACX1C,IAAI,EAAGA,IAAM;IACbS,QAAQ,EAAG8D,GAAG,CAACvE,IAAM;IACrBU,KAAK,EAAGA,KAAO;IACfiC,QAAQ,EAAGA;EAAU,CACrB,CACa,CACd,CACG,CACE,CAAC;AAEZ"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
+ export const {
6
+ lock,
7
+ unlock
8
+ } = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/format-library');
9
+ //# sourceMappingURL=lock-unlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/format-library/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/format-library'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,2BACD,CAAC"}
@@ -6,13 +6,24 @@ import { useCallback, useMemo } from '@wordpress/element';
6
6
  import { useSelect } from '@wordpress/data';
7
7
  import { applyFormat, removeFormat, getActiveFormat, useAnchor } from '@wordpress/rich-text';
8
8
  import { ColorPalette, getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, store as blockEditorStore, useCachedTruthy } from '@wordpress/block-editor';
9
- import { Popover, TabPanel } from '@wordpress/components';
9
+ import { Popover, privateApis as componentsPrivateApis } from '@wordpress/components';
10
10
  import { __ } from '@wordpress/i18n';
11
11
 
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
15
  import { textColor as settings, transparentValue } from './index';
16
+ import { unlock } from '../lock-unlock';
17
+ const {
18
+ Tabs
19
+ } = unlock(componentsPrivateApis);
20
+ const TABS = [{
21
+ name: 'color',
22
+ title: __('Text')
23
+ }, {
24
+ name: 'backgroundColor',
25
+ title: __('Background')
26
+ }];
16
27
  function parseCSS(css = '') {
17
28
  return css.split(';').reduce((accumulator, rule) => {
18
29
  if (rule) {
@@ -126,21 +137,20 @@ export default function InlineColorUI({
126
137
  popoverAnchor.getBoundingClientRect = () => cachedRect;
127
138
  return createElement(Popover, {
128
139
  onClose: onClose,
129
- className: "components-inline-color-popover",
140
+ className: "format-library__inline-color-popover",
130
141
  anchor: popoverAnchor
131
- }, createElement(TabPanel, {
132
- tabs: [{
133
- name: 'color',
134
- title: __('Text')
135
- }, {
136
- name: 'backgroundColor',
137
- title: __('Background')
138
- }]
139
- }, tab => createElement(ColorPicker, {
142
+ }, createElement(Tabs, null, createElement(Tabs.TabList, null, TABS.map(tab => createElement(Tabs.Tab, {
143
+ tabId: tab.name,
144
+ key: tab.name
145
+ }, tab.title))), TABS.map(tab => createElement(Tabs.TabPanel, {
146
+ tabId: tab.name,
147
+ focusable: false,
148
+ key: tab.name
149
+ }, createElement(ColorPicker, {
140
150
  name: name,
141
151
  property: tab.name,
142
152
  value: value,
143
153
  onChange: onChange
144
- })));
154
+ })))));
145
155
  }
146
156
  //# sourceMappingURL=inline.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useMemo","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","useCachedTruthy","Popover","TabPanel","__","textColor","settings","transparentValue","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","name","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","onColorChange","activeColors","createElement","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","cachedRect","getBoundingClientRect","anchor","tabs","title","tab"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport { Popover, TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings,\n\t} );\n\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );\n\tpopoverAnchor.getBoundingClientRect = () => cachedRect;\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"components-inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<TabPanel\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'color',\n\t\t\t\t\t\ttitle: __( 'Text' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'backgroundColor',\n\t\t\t\t\t\ttitle: __( 'Background' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAA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","useSelect","applyFormat","removeFormat","getActiveFormat","useAnchor","ColorPalette","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","store","blockEditorStore","useCachedTruthy","Popover","privateApis","componentsPrivateApis","__","textColor","settings","transparentValue","unlock","Tabs","TABS","name","title","parseCSS","css","split","reduce","accumulator","rule","property","value","color","backgroundColor","parseClassName","className","colorSettings","startsWith","endsWith","colorSlug","replace","colorObject","getActiveColors","activeColorFormat","attributes","style","class","setColors","colors","styles","classNames","push","join","slug","length","type","ColorPicker","onChange","select","_getSettings$colors","getSettings","onColorChange","activeColors","createElement","InlineColorUI","onClose","contentRef","popoverAnchor","editableContentElement","current","cachedRect","getBoundingClientRect","anchor","TabList","map","tab","Tab","tabId","key","TabPanel","focusable"],"sources":["@wordpress/format-library/src/text-color/inline.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tapplyFormat,\n\tremoveFormat,\n\tgetActiveFormat,\n\tuseAnchor,\n} from '@wordpress/rich-text';\nimport {\n\tColorPalette,\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tstore as blockEditorStore,\n\tuseCachedTruthy,\n} from '@wordpress/block-editor';\nimport {\n\tPopover,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { textColor as settings, transparentValue } from './index';\nimport { unlock } from '../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst TABS = [\n\t{ name: 'color', title: __( 'Text' ) },\n\t{ name: 'backgroundColor', title: __( 'Background' ) },\n];\n\nfunction parseCSS( css = '' ) {\n\treturn css.split( ';' ).reduce( ( accumulator, rule ) => {\n\t\tif ( rule ) {\n\t\t\tconst [ property, value ] = rule.split( ':' );\n\t\t\tif ( property === 'color' ) accumulator.color = value;\n\t\t\tif ( property === 'background-color' && value !== transparentValue )\n\t\t\t\taccumulator.backgroundColor = value;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function parseClassName( className = '', colorSettings ) {\n\treturn className.split( ' ' ).reduce( ( accumulator, name ) => {\n\t\t// `colorSlug` could contain dashes, so simply match the start and end.\n\t\tif ( name.startsWith( 'has-' ) && name.endsWith( '-color' ) ) {\n\t\t\tconst colorSlug = name\n\t\t\t\t.replace( /^has-/, '' )\n\t\t\t\t.replace( /-color$/, '' );\n\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\tcolorSettings,\n\t\t\t\tcolorSlug\n\t\t\t);\n\t\t\taccumulator.color = colorObject.color;\n\t\t}\n\t\treturn accumulator;\n\t}, {} );\n}\n\nexport function getActiveColors( value, name, colorSettings ) {\n\tconst activeColorFormat = getActiveFormat( value, name );\n\n\tif ( ! activeColorFormat ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t...parseCSS( activeColorFormat.attributes.style ),\n\t\t...parseClassName( activeColorFormat.attributes.class, colorSettings ),\n\t};\n}\n\nfunction setColors( value, name, colorSettings, colors ) {\n\tconst { color, backgroundColor } = {\n\t\t...getActiveColors( value, name, colorSettings ),\n\t\t...colors,\n\t};\n\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn removeFormat( value, name );\n\t}\n\n\tconst styles = [];\n\tconst classNames = [];\n\tconst attributes = {};\n\n\tif ( backgroundColor ) {\n\t\tstyles.push( [ 'background-color', backgroundColor ].join( ':' ) );\n\t} else {\n\t\t// Override default browser color for mark element.\n\t\tstyles.push( [ 'background-color', transparentValue ].join( ':' ) );\n\t}\n\n\tif ( color ) {\n\t\tconst colorObject = getColorObjectByColorValue( colorSettings, color );\n\n\t\tif ( colorObject ) {\n\t\t\tclassNames.push( getColorClassName( 'color', colorObject.slug ) );\n\t\t} else {\n\t\t\tstyles.push( [ 'color', color ].join( ':' ) );\n\t\t}\n\t}\n\n\tif ( styles.length ) attributes.style = styles.join( ';' );\n\tif ( classNames.length ) attributes.class = classNames.join( ' ' );\n\n\treturn applyFormat( value, { type: name, attributes } );\n}\n\nfunction ColorPicker( { name, property, value, onChange } ) {\n\tconst colors = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().colors ?? [];\n\t}, [] );\n\tconst onColorChange = useCallback(\n\t\t( color ) => {\n\t\t\tonChange(\n\t\t\t\tsetColors( value, name, colors, { [ property ]: color } )\n\t\t\t);\n\t\t},\n\t\t[ colors, onChange, property ]\n\t);\n\tconst activeColors = useMemo(\n\t\t() => getActiveColors( value, name, colors ),\n\t\t[ name, value, colors ]\n\t);\n\n\treturn (\n\t\t<ColorPalette\n\t\t\tvalue={ activeColors[ property ] }\n\t\t\tonChange={ onColorChange }\n\t\t/>\n\t);\n}\n\nexport default function InlineColorUI( {\n\tname,\n\tvalue,\n\tonChange,\n\tonClose,\n\tcontentRef,\n} ) {\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement: contentRef.current,\n\t\tsettings,\n\t} );\n\n\t/*\n\t As you change the text color by typing a HEX value into a field,\n\t the return value of document.getSelection jumps to the field you're editing,\n\t not the highlighted text. Given that useAnchor uses document.getSelection,\n\t it will return null, since it can't find the <mark> element within the HEX input.\n\t This caches the last truthy value of the selection anchor reference.\n\t */\n\tconst cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );\n\tpopoverAnchor.getBoundingClientRect = () => cachedRect;\n\n\treturn (\n\t\t<Popover\n\t\t\tonClose={ onClose }\n\t\t\tclassName=\"format-library__inline-color-popover\"\n\t\t\tanchor={ popoverAnchor }\n\t\t>\n\t\t\t<Tabs>\n\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t\t<Tabs.Tab tabId={ tab.name } key={ tab.name }>\n\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t) ) }\n\t\t\t\t</Tabs.TabList>\n\t\t\t\t{ TABS.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\t\tproperty={ tab.name }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,QACH,sBAAsB;AAC7B,SACCC,YAAY,EACZC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,KAAK,IAAIC,gBAAgB,EACzBC,eAAe,QACT,yBAAyB;AAChC,SACCC,OAAO,EACPC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,SAAS,IAAIC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AACjE,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EAAEC;AAAK,CAAC,GAAGD,MAAM,CAAEL,qBAAsB,CAAC;AAEhD,MAAMO,IAAI,GAAG,CACZ;EAAEC,IAAI,EAAE,OAAO;EAAEC,KAAK,EAAER,EAAE,CAAE,MAAO;AAAE,CAAC,EACtC;EAAEO,IAAI,EAAE,iBAAiB;EAAEC,KAAK,EAAER,EAAE,CAAE,YAAa;AAAE,CAAC,CACtD;AAED,SAASS,QAAQA,CAAEC,GAAG,GAAG,EAAE,EAAG;EAC7B,OAAOA,GAAG,CAAC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;EACL0B,QAAQ;EACRQ,OAAO;EACPC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAG/D,SAAS,CAAE;IAChCgE,sBAAsB,EAAEF,UAAU,CAACG,OAAO;IAC1CpD;EACD,CAAE,CAAC;;EAEH;AACD;AACA;AACA;AACA;AACA;AACA;EACC,MAAMqD,UAAU,GAAG3D,eAAe,CAAEwD,aAAa,CAACI,qBAAqB,CAAC,CAAE,CAAC;EAC3EJ,aAAa,CAACI,qBAAqB,GAAG,MAAMD,UAAU;EAEtD,OACCP,aAAA,CAACnD,OAAO;IACPqD,OAAO,EAAGA,OAAS;IACnB9B,SAAS,EAAC,sCAAsC;IAChDqC,MAAM,EAAGL;EAAe,GAExBJ,aAAA,CAAC3C,IAAI,QACJ2C,aAAA,CAAC3C,IAAI,CAACqD,OAAO,QACVpD,IAAI,CAACqD,GAAG,CAAIC,GAAG,IAChBZ,aAAA,CAAC3C,IAAI,CAACwD,GAAG;IAACC,KAAK,EAAGF,GAAG,CAACrD,IAAM;IAACwD,GAAG,EAAGH,GAAG,CAACrD;EAAM,GAC1CqD,GAAG,CAACpD,KACG,CACT,CACW,CAAC,EACbF,IAAI,CAACqD,GAAG,CAAIC,GAAG,IAChBZ,aAAA,CAAC3C,IAAI,CAAC2D,QAAQ;IACbF,KAAK,EAAGF,GAAG,CAACrD,IAAM;IAClB0D,SAAS,EAAG,KAAO;IACnBF,GAAG,EAAGH,GAAG,CAACrD;EAAM,GAEhByC,aAAA,CAACP,WAAW;IACXlC,IAAI,EAAGA,IAAM;IACbQ,QAAQ,EAAG6C,GAAG,CAACrD,IAAM;IACrBS,KAAK,EAAGA,KAAO;IACf0B,QAAQ,EAAGA;EAAU,CACrB,CACa,CACd,CACG,CACE,CAAC;AAEZ"}
@@ -135,21 +135,9 @@
135
135
  color: #cc1818;
136
136
  }
137
137
 
138
- .components-inline-color-popover .components-popover__content .components-tab-panel__tab-content {
138
+ .format-library__inline-color-popover [role=tabpanel] {
139
139
  padding: 16px;
140
140
  }
141
- .components-inline-color-popover .components-popover__content .components-color-palette {
142
- margin-top: 0.6rem;
143
- }
144
- .components-inline-color-popover .components-popover__content .components-base-control__title {
145
- display: block;
146
- margin-bottom: 16px;
147
- font-weight: 600;
148
- color: #191e23;
149
- }
150
- .components-inline-color-popover .components-popover__content .component-color-indicator {
151
- vertical-align: text-bottom;
152
- }
153
141
 
154
142
  .block-editor-format-toolbar__language-popover .components-popover__content {
155
143
  width: auto;
@@ -135,21 +135,9 @@
135
135
  color: #cc1818;
136
136
  }
137
137
 
138
- .components-inline-color-popover .components-popover__content .components-tab-panel__tab-content {
138
+ .format-library__inline-color-popover [role=tabpanel] {
139
139
  padding: 16px;
140
140
  }
141
- .components-inline-color-popover .components-popover__content .components-color-palette {
142
- margin-top: 0.6rem;
143
- }
144
- .components-inline-color-popover .components-popover__content .components-base-control__title {
145
- display: block;
146
- margin-bottom: 16px;
147
- font-weight: 600;
148
- color: #191e23;
149
- }
150
- .components-inline-color-popover .components-popover__content .component-color-indicator {
151
- vertical-align: text-bottom;
152
- }
153
141
 
154
142
  .block-editor-format-toolbar__language-popover .components-popover__content {
155
143
  width: auto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/format-library",
3
- "version": "4.25.0",
3
+ "version": "4.25.1-next.79a6196f.0",
4
4
  "description": "Format library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,17 +26,18 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/a11y": "^3.48.0",
30
- "@wordpress/block-editor": "^12.16.0",
31
- "@wordpress/components": "^25.14.0",
32
- "@wordpress/compose": "^6.25.0",
33
- "@wordpress/data": "^9.18.0",
34
- "@wordpress/element": "^5.25.0",
35
- "@wordpress/html-entities": "^3.48.0",
36
- "@wordpress/i18n": "^4.48.0",
37
- "@wordpress/icons": "^9.39.0",
38
- "@wordpress/rich-text": "^6.25.0",
39
- "@wordpress/url": "^3.49.0"
29
+ "@wordpress/a11y": "^3.48.1-next.79a6196f.0",
30
+ "@wordpress/block-editor": "^12.16.1-next.79a6196f.0",
31
+ "@wordpress/components": "^25.15.1-next.79a6196f.0",
32
+ "@wordpress/compose": "^6.25.1-next.79a6196f.0",
33
+ "@wordpress/data": "^9.18.1-next.79a6196f.0",
34
+ "@wordpress/element": "^5.25.1-next.79a6196f.0",
35
+ "@wordpress/html-entities": "^3.48.1-next.79a6196f.0",
36
+ "@wordpress/i18n": "^4.48.1-next.79a6196f.0",
37
+ "@wordpress/icons": "^9.39.1-next.79a6196f.0",
38
+ "@wordpress/private-apis": "^0.30.1-next.79a6196f.0",
39
+ "@wordpress/rich-text": "^6.25.1-next.79a6196f.0",
40
+ "@wordpress/url": "^3.49.1-next.79a6196f.0"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "react": "^18.0.0",
@@ -45,5 +46,5 @@
45
46
  "publishConfig": {
46
47
  "access": "public"
47
48
  },
48
- "gitHead": "fcf61b4beff747222c2c81d09d757ca1a0abd925"
49
+ "gitHead": "1e74b942ac0119a22ceaaf5c9594263f3ec516ab"
49
50
  }
@@ -7,6 +7,7 @@ exports[`LinksUI LinksUI renders 1`] = `
7
7
  backdropOpacity={0.2}
8
8
  backdropTransitionInTiming={50}
9
9
  backdropTransitionOutTiming={50}
10
+ hardwareAccelerated={true}
10
11
  isVisible={true}
11
12
  onAccessibilityEscape={[Function]}
12
13
  onBackButtonPress={[Function]}
@@ -18,6 +19,7 @@ exports[`LinksUI LinksUI renders 1`] = `
18
19
  preferredColorScheme="light"
19
20
  swipeDirection="down"
20
21
  testID="link-settings-modal"
22
+ useNativeDriverForBackdrop={true}
21
23
  >
22
24
  <View
23
25
  behavior={false}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
+
6
+ export const { lock, unlock } =
7
+ __dangerousOptInToUnstableAPIsOnlyForCoreModules(
8
+ 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
9
+ '@wordpress/format-library'
10
+ );
@@ -17,13 +17,24 @@ import {
17
17
  store as blockEditorStore,
18
18
  useCachedTruthy,
19
19
  } from '@wordpress/block-editor';
20
- import { Popover, TabPanel } from '@wordpress/components';
20
+ import {
21
+ Popover,
22
+ privateApis as componentsPrivateApis,
23
+ } from '@wordpress/components';
21
24
  import { __ } from '@wordpress/i18n';
22
25
 
23
26
  /**
24
27
  * Internal dependencies
25
28
  */
26
29
  import { textColor as settings, transparentValue } from './index';
30
+ import { unlock } from '../lock-unlock';
31
+
32
+ const { Tabs } = unlock( componentsPrivateApis );
33
+
34
+ const TABS = [
35
+ { name: 'color', title: __( 'Text' ) },
36
+ { name: 'backgroundColor', title: __( 'Background' ) },
37
+ ];
27
38
 
28
39
  function parseCSS( css = '' ) {
29
40
  return css.split( ';' ).reduce( ( accumulator, rule ) => {
@@ -155,30 +166,32 @@ export default function InlineColorUI( {
155
166
  return (
156
167
  <Popover
157
168
  onClose={ onClose }
158
- className="components-inline-color-popover"
169
+ className="format-library__inline-color-popover"
159
170
  anchor={ popoverAnchor }
160
171
  >
161
- <TabPanel
162
- tabs={ [
163
- {
164
- name: 'color',
165
- title: __( 'Text' ),
166
- },
167
- {
168
- name: 'backgroundColor',
169
- title: __( 'Background' ),
170
- },
171
- ] }
172
- >
173
- { ( tab ) => (
174
- <ColorPicker
175
- name={ name }
176
- property={ tab.name }
177
- value={ value }
178
- onChange={ onChange }
179
- />
180
- ) }
181
- </TabPanel>
172
+ <Tabs>
173
+ <Tabs.TabList>
174
+ { TABS.map( ( tab ) => (
175
+ <Tabs.Tab tabId={ tab.name } key={ tab.name }>
176
+ { tab.title }
177
+ </Tabs.Tab>
178
+ ) ) }
179
+ </Tabs.TabList>
180
+ { TABS.map( ( tab ) => (
181
+ <Tabs.TabPanel
182
+ tabId={ tab.name }
183
+ focusable={ false }
184
+ key={ tab.name }
185
+ >
186
+ <ColorPicker
187
+ name={ name }
188
+ property={ tab.name }
189
+ value={ value }
190
+ onChange={ onChange }
191
+ />
192
+ </Tabs.TabPanel>
193
+ ) ) }
194
+ </Tabs>
182
195
  </Popover>
183
196
  );
184
197
  }
@@ -1,23 +1,6 @@
1
- .components-inline-color-popover {
1
+ .format-library__inline-color-popover {
2
2
 
3
- .components-popover__content {
4
- .components-tab-panel__tab-content {
5
- padding: 16px;
6
- }
7
-
8
- .components-color-palette {
9
- margin-top: 0.6rem;
10
- }
11
-
12
- .components-base-control__title {
13
- display: block;
14
- margin-bottom: 16px;
15
- font-weight: 600;
16
- color: #191e23;
17
- }
18
-
19
- .component-color-indicator {
20
- vertical-align: text-bottom;
21
- }
3
+ [role="tabpanel"] {
4
+ padding: 16px;
22
5
  }
23
6
  }