@wordpress/components 25.3.0 → 25.5.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.
Files changed (190) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/border-control/border-control-dropdown/component.js +8 -10
  3. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  4. package/build/button/index.native.js +9 -6
  5. package/build/button/index.native.js.map +1 -1
  6. package/build/color-palette/index.js +2 -2
  7. package/build/color-palette/index.js.map +1 -1
  8. package/build/focal-point-picker/index.native.js +6 -4
  9. package/build/focal-point-picker/index.native.js.map +1 -1
  10. package/build/form-token-field/styles.js +4 -2
  11. package/build/form-token-field/styles.js.map +1 -1
  12. package/build/item-group/item/hook.js +1 -1
  13. package/build/item-group/item/hook.js.map +1 -1
  14. package/build/item-group/styles.js +13 -10
  15. package/build/item-group/styles.js.map +1 -1
  16. package/build/menu-items-choice/index.js +1 -0
  17. package/build/menu-items-choice/index.js.map +1 -1
  18. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  19. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  20. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +50 -44
  21. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  22. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -20
  23. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  24. package/build/mobile/bottom-sheet/index.native.js +3 -1
  25. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  26. package/build/mobile/image/index.native.js +4 -3
  27. package/build/mobile/image/index.native.js.map +1 -1
  28. package/build/mobile/link-picker/link-picker-results.native.js +2 -1
  29. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  30. package/build/mobile/segmented-control/index.native.js +7 -7
  31. package/build/mobile/segmented-control/index.native.js.map +1 -1
  32. package/build/modal/index.js +14 -1
  33. package/build/modal/index.js.map +1 -1
  34. package/build/navigator/navigator-provider/component.js +18 -10
  35. package/build/navigator/navigator-provider/component.js.map +1 -1
  36. package/build/private-apis.js +4 -1
  37. package/build/private-apis.js.map +1 -1
  38. package/build/progress-bar/index.js +54 -0
  39. package/build/progress-bar/index.js.map +1 -0
  40. package/build/progress-bar/styles.js +69 -0
  41. package/build/progress-bar/styles.js.map +1 -0
  42. package/build/progress-bar/types.js +6 -0
  43. package/build/progress-bar/types.js.map +1 -0
  44. package/build/query-controls/index.js +1 -0
  45. package/build/query-controls/index.js.map +1 -1
  46. package/build/query-controls/index.native.js +1 -0
  47. package/build/query-controls/index.native.js.map +1 -1
  48. package/build/tab-panel/index.js +91 -58
  49. package/build/tab-panel/index.js.map +1 -1
  50. package/build/text-control/index.js +2 -2
  51. package/build/text-control/index.js.map +1 -1
  52. package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
  53. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  54. package/build-module/border-control/border-control-dropdown/component.js +8 -10
  55. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  56. package/build-module/button/index.native.js +8 -6
  57. package/build-module/button/index.native.js.map +1 -1
  58. package/build-module/color-palette/index.js +2 -2
  59. package/build-module/color-palette/index.js.map +1 -1
  60. package/build-module/focal-point-picker/index.native.js +6 -5
  61. package/build-module/focal-point-picker/index.native.js.map +1 -1
  62. package/build-module/form-token-field/styles.js +3 -2
  63. package/build-module/form-token-field/styles.js.map +1 -1
  64. package/build-module/item-group/item/hook.js +1 -1
  65. package/build-module/item-group/item/hook.js.map +1 -1
  66. package/build-module/item-group/styles.js +13 -11
  67. package/build-module/item-group/styles.js.map +1 -1
  68. package/build-module/menu-items-choice/index.js +1 -0
  69. package/build-module/menu-items-choice/index.js.map +1 -1
  70. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  71. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  72. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +43 -41
  73. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  74. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +14 -20
  75. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  76. package/build-module/mobile/bottom-sheet/index.native.js +3 -1
  77. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  78. package/build-module/mobile/image/index.native.js +4 -3
  79. package/build-module/mobile/image/index.native.js.map +1 -1
  80. package/build-module/mobile/link-picker/link-picker-results.native.js +2 -1
  81. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  82. package/build-module/mobile/segmented-control/index.native.js +7 -7
  83. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  84. package/build-module/modal/index.js +14 -1
  85. package/build-module/modal/index.js.map +1 -1
  86. package/build-module/navigator/navigator-provider/component.js +18 -10
  87. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  88. package/build-module/private-apis.js +3 -1
  89. package/build-module/private-apis.js.map +1 -1
  90. package/build-module/progress-bar/index.js +41 -0
  91. package/build-module/progress-bar/index.js.map +1 -0
  92. package/build-module/progress-bar/styles.js +61 -0
  93. package/build-module/progress-bar/styles.js.map +1 -0
  94. package/build-module/progress-bar/types.js +2 -0
  95. package/build-module/progress-bar/types.js.map +1 -0
  96. package/build-module/query-controls/index.js +1 -0
  97. package/build-module/query-controls/index.js.map +1 -1
  98. package/build-module/query-controls/index.native.js +1 -0
  99. package/build-module/query-controls/index.native.js.map +1 -1
  100. package/build-module/tab-panel/index.js +88 -59
  101. package/build-module/tab-panel/index.js.map +1 -1
  102. package/build-module/text-control/index.js +2 -2
  103. package/build-module/text-control/index.js.map +1 -1
  104. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
  105. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  106. package/build-style/style-rtl.css +3 -0
  107. package/build-style/style.css +3 -0
  108. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  109. package/build-types/form-token-field/styles.d.ts.map +1 -1
  110. package/build-types/item-group/item/hook.d.ts.map +1 -1
  111. package/build-types/item-group/stories/index.d.ts.map +1 -1
  112. package/build-types/item-group/styles.d.ts +1 -1
  113. package/build-types/item-group/styles.d.ts.map +1 -1
  114. package/build-types/menu-items-choice/index.d.ts.map +1 -1
  115. package/build-types/menu-items-choice/types.d.ts +5 -0
  116. package/build-types/menu-items-choice/types.d.ts.map +1 -1
  117. package/build-types/modal/index.d.ts.map +1 -1
  118. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  119. package/build-types/navigator/types.d.ts +3 -1
  120. package/build-types/navigator/types.d.ts.map +1 -1
  121. package/build-types/private-apis.d.ts.map +1 -1
  122. package/build-types/progress-bar/index.d.ts +5 -0
  123. package/build-types/progress-bar/index.d.ts.map +1 -0
  124. package/build-types/progress-bar/stories/index.d.ts +12 -0
  125. package/build-types/progress-bar/stories/index.d.ts.map +1 -0
  126. package/build-types/progress-bar/styles.d.ts +18 -0
  127. package/build-types/progress-bar/styles.d.ts.map +1 -0
  128. package/build-types/progress-bar/test/index.d.ts +2 -0
  129. package/build-types/progress-bar/test/index.d.ts.map +1 -0
  130. package/build-types/progress-bar/types.d.ts +11 -0
  131. package/build-types/progress-bar/types.d.ts.map +1 -0
  132. package/build-types/query-controls/index.d.ts.map +1 -1
  133. package/build-types/tab-panel/index.d.ts.map +1 -1
  134. package/build-types/tab-panel/stories/index.d.ts +1 -0
  135. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  136. package/build-types/tab-panel/types.d.ts +1 -9
  137. package/build-types/tab-panel/types.d.ts.map +1 -1
  138. package/build-types/text-control/test/text-control.d.ts +2 -0
  139. package/build-types/text-control/test/text-control.d.ts.map +1 -0
  140. package/package.json +22 -22
  141. package/src/border-control/border-control-dropdown/component.tsx +7 -11
  142. package/src/border-control/test/index.js +6 -6
  143. package/src/button/index.native.js +9 -3
  144. package/src/button/style.native.scss +9 -0
  145. package/src/color-palette/index.tsx +2 -2
  146. package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
  147. package/src/color-palette/test/index.tsx +1 -5
  148. package/src/draggable/test/index.native.js +4 -0
  149. package/src/focal-point-picker/index.native.js +6 -5
  150. package/src/form-token-field/styles.ts +2 -0
  151. package/src/item-group/item/hook.ts +2 -1
  152. package/src/item-group/stories/index.tsx +8 -3
  153. package/src/item-group/styles.ts +39 -28
  154. package/src/menu-item/README.md +7 -0
  155. package/src/menu-items-choice/index.tsx +1 -0
  156. package/src/menu-items-choice/types.ts +5 -0
  157. package/src/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +1 -1
  158. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +72 -53
  159. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -21
  160. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +165 -119
  161. package/src/mobile/bottom-sheet/index.native.js +2 -0
  162. package/src/mobile/image/index.native.js +8 -6
  163. package/src/mobile/image/style.native.scss +5 -1
  164. package/src/mobile/link-picker/link-picker-results.native.js +1 -1
  165. package/src/mobile/link-settings/test/edit.native.js +37 -23
  166. package/src/mobile/segmented-control/index.native.js +11 -11
  167. package/src/modal/index.tsx +16 -0
  168. package/src/modal/test/index.tsx +33 -0
  169. package/src/navigator/navigator-provider/component.tsx +30 -23
  170. package/src/navigator/types.ts +4 -1
  171. package/src/placeholder/style.scss +5 -0
  172. package/src/private-apis.ts +2 -0
  173. package/src/progress-bar/README.md +30 -0
  174. package/src/progress-bar/index.tsx +45 -0
  175. package/src/progress-bar/stories/index.tsx +33 -0
  176. package/src/progress-bar/styles.ts +67 -0
  177. package/src/progress-bar/test/index.tsx +79 -0
  178. package/src/progress-bar/types.ts +11 -0
  179. package/src/query-controls/index.native.js +1 -0
  180. package/src/query-controls/index.tsx +1 -0
  181. package/src/tab-panel/index.tsx +121 -84
  182. package/src/tab-panel/stories/index.tsx +6 -0
  183. package/src/tab-panel/test/index.tsx +128 -109
  184. package/src/tab-panel/types.ts +1 -10
  185. package/src/text-control/index.tsx +2 -2
  186. package/src/text-control/test/text-control.tsx +61 -0
  187. package/src/toolbar/toolbar-group/style.native.scss +2 -3
  188. package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
  189. package/src/tooltip/README.md +1 -1
  190. package/tsconfig.tsbuildinfo +1 -1
@@ -9,14 +9,18 @@ exports.default = exports.TabPanel = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
13
+
12
14
  var _classnames = _interopRequireDefault(require("classnames"));
13
15
 
14
16
  var _compose = require("@wordpress/compose");
15
17
 
16
- var _navigableContainer = require("../navigable-container");
17
-
18
18
  var _button = _interopRequireDefault(require("../button"));
19
19
 
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
20
24
  /**
21
25
  * External dependencies
22
26
  */
@@ -28,19 +32,17 @@ var _button = _interopRequireDefault(require("../button"));
28
32
  /**
29
33
  * Internal dependencies
30
34
  */
31
- const TabButton = ({
32
- tabId,
33
- children,
34
- selected,
35
- ...rest
36
- }) => (0, _element.createElement)(_button.default, {
37
- role: "tab",
38
- tabIndex: selected ? undefined : -1,
39
- "aria-selected": selected,
40
- id: tabId,
41
- __experimentalIsFocusable: true,
42
- ...rest
43
- }, children);
35
+ // Separate the actual tab name from the instance ID. This is
36
+ // necessary because Ariakit internally uses the element ID when
37
+ // a new tab is selected, but our implementation looks specifically
38
+ // for the tab name to be passed to the `onSelect` callback.
39
+ const extractTabName = id => {
40
+ if (typeof id === 'undefined' || id === null) {
41
+ return;
42
+ }
43
+
44
+ return id.match(/^tab-panel-[0-9]*-(.*)/)?.[1];
45
+ };
44
46
  /**
45
47
  * TabPanel is an ARIA-compliant tabpanel.
46
48
  *
@@ -89,24 +91,52 @@ const UnforwardedTabPanel = ({
89
91
  activeClass = 'is-active',
90
92
  onSelect
91
93
  }, ref) => {
92
- var _selectedTab$name;
93
-
94
94
  const instanceId = (0, _compose.useInstanceId)(TabPanel, 'tab-panel');
95
- const [selected, setSelected] = (0, _element.useState)();
96
- const handleTabSelection = (0, _element.useCallback)(tabKey => {
97
- setSelected(tabKey);
98
- onSelect?.(tabKey);
99
- }, [onSelect]); // Simulate a click on the newly focused tab, which causes the component
100
- // to show the `tab-panel` associated with the clicked tab.
101
-
102
- const activateTabAutomatically = (_childIndex, child) => {
103
- child.click();
104
- };
95
+ const prependInstanceId = (0, _element.useCallback)(tabName => {
96
+ if (typeof tabName === 'undefined') {
97
+ return;
98
+ }
105
99
 
100
+ return `${instanceId}-${tabName}`;
101
+ }, [instanceId]);
102
+ const tabStore = Ariakit.useTabStore({
103
+ setSelectedId: newTabValue => {
104
+ if (typeof newTabValue === 'undefined' || newTabValue === null) {
105
+ return;
106
+ }
107
+
108
+ const newTab = tabs.find(t => prependInstanceId(t.name) === newTabValue);
109
+
110
+ if (newTab?.disabled || newTab === selectedTab) {
111
+ return;
112
+ }
113
+
114
+ const simplifiedTabName = extractTabName(newTabValue);
115
+
116
+ if (typeof simplifiedTabName === 'undefined') {
117
+ return;
118
+ }
119
+
120
+ onSelect?.(simplifiedTabName);
121
+ },
122
+ orientation,
123
+ selectOnMove,
124
+ defaultSelectedId: prependInstanceId(initialTabName)
125
+ });
126
+ const selectedTabName = extractTabName(tabStore.useState('selectedId'));
127
+ const setTabStoreSelectedId = (0, _element.useCallback)(tabName => {
128
+ tabStore.setState('selectedId', prependInstanceId(tabName));
129
+ }, [prependInstanceId, tabStore]);
106
130
  const selectedTab = tabs.find(({
107
131
  name
108
- }) => name === selected);
109
- const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab?.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`; // Handle selecting the initial tab.
132
+ }) => name === selectedTabName);
133
+ const previousSelectedTabName = (0, _compose.usePrevious)(selectedTabName); // Ensure `onSelect` is called when the initial tab is selected.
134
+
135
+ (0, _element.useEffect)(() => {
136
+ if (previousSelectedTabName !== selectedTabName && selectedTabName === initialTabName && !!selectedTabName) {
137
+ onSelect?.(selectedTabName);
138
+ }
139
+ }, [selectedTabName, initialTabName, onSelect, previousSelectedTabName]); // Handle selecting the initial tab.
110
140
 
111
141
  (0, _element.useLayoutEffect)(() => {
112
142
  // If there's a selected tab, don't override it.
@@ -124,13 +154,17 @@ const UnforwardedTabPanel = ({
124
154
 
125
155
  if (initialTab && !initialTab.disabled) {
126
156
  // Select the initial tab if it's not disabled.
127
- handleTabSelection(initialTab.name);
157
+ setTabStoreSelectedId(initialTab.name);
128
158
  } else {
129
- // Fallback to the first enabled tab when the initial is disabled.
159
+ // Fallback to the first enabled tab when the initial tab is
160
+ // disabled or it can't be found.
130
161
  const firstEnabledTab = tabs.find(tab => !tab.disabled);
131
- if (firstEnabledTab) handleTabSelection(firstEnabledTab.name);
162
+
163
+ if (firstEnabledTab) {
164
+ setTabStoreSelectedId(firstEnabledTab.name);
165
+ }
132
166
  }
133
- }, [tabs, selectedTab, initialTabName, handleTabSelection]); // Handle the currently selected tab becoming disabled.
167
+ }, [tabs, selectedTab, initialTabName, instanceId, setTabStoreSelectedId]); // Handle the currently selected tab becoming disabled.
134
168
 
135
169
  (0, _element.useEffect)(() => {
136
170
  // This effect only runs when the selected tab is defined and becomes disabled.
@@ -142,36 +176,35 @@ const UnforwardedTabPanel = ({
142
176
  // (if there is one).
143
177
 
144
178
  if (firstEnabledTab) {
145
- handleTabSelection(firstEnabledTab.name);
179
+ setTabStoreSelectedId(firstEnabledTab.name);
146
180
  }
147
- }, [tabs, selectedTab?.disabled, handleTabSelection]);
181
+ }, [tabs, selectedTab?.disabled, setTabStoreSelectedId, instanceId]);
148
182
  return (0, _element.createElement)("div", {
149
183
  className: className,
150
184
  ref: ref
151
- }, (0, _element.createElement)(_navigableContainer.NavigableMenu, {
152
- role: "tablist",
153
- orientation: orientation,
154
- onNavigate: selectOnMove ? activateTabAutomatically : undefined,
185
+ }, (0, _element.createElement)(Ariakit.TabList, {
186
+ store: tabStore,
155
187
  className: "components-tab-panel__tabs"
156
- }, tabs.map(tab => (0, _element.createElement)(TabButton, {
157
- className: (0, _classnames.default)('components-tab-panel__tabs-item', tab.className, {
158
- [activeClass]: tab.name === selected
159
- }),
160
- tabId: `${instanceId}-${tab.name}`,
161
- "aria-controls": `${instanceId}-${tab.name}-view`,
162
- selected: tab.name === selected,
163
- key: tab.name,
164
- onClick: () => handleTabSelection(tab.name),
165
- disabled: tab.disabled,
166
- label: tab.icon && tab.title,
167
- icon: tab.icon,
168
- showTooltip: !!tab.icon
169
- }, !tab.icon && tab.title))), selectedTab && (0, _element.createElement)("div", {
170
- key: selectedId,
171
- "aria-labelledby": selectedId,
172
- role: "tabpanel",
173
- id: `${selectedId}-view`,
174
- className: "components-tab-panel__tab-content"
188
+ }, tabs.map(tab => {
189
+ return (0, _element.createElement)(Ariakit.Tab, {
190
+ key: tab.name,
191
+ id: prependInstanceId(tab.name),
192
+ className: (0, _classnames.default)('components-tab-panel__tabs-item', tab.className, {
193
+ [activeClass]: tab.name === selectedTabName
194
+ }),
195
+ disabled: tab.disabled,
196
+ "aria-controls": `${prependInstanceId(tab.name)}-view`,
197
+ render: (0, _element.createElement)(_button.default, {
198
+ icon: tab.icon,
199
+ label: tab.icon && tab.title,
200
+ showTooltip: !!tab.icon
201
+ })
202
+ }, !tab.icon && tab.title);
203
+ })), selectedTab && (0, _element.createElement)(Ariakit.TabPanel, {
204
+ id: `${prependInstanceId(selectedTab.name)}-view`,
205
+ store: tabStore,
206
+ tabId: prependInstanceId(selectedTab.name),
207
+ className: 'components-tab-panel__tab-content'
175
208
  }, children(selectedTab)));
176
209
  };
177
210
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["TabButton","tabId","children","selected","rest","undefined","UnforwardedTabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","ref","instanceId","TabPanel","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","initialTab","tab","disabled","firstEnabledTab","map","icon","title"],"mappings":";;;;;;;;;AASA;;AANA;;AAaA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG,CAAE;AACnBC,EAAAA,KADmB;AAEnBC,EAAAA,QAFmB;AAGnBC,EAAAA,QAHmB;AAInB,KAAGC;AAJgB,CAAF,KAMjB,4BAAC,eAAD;AACC,EAAA,IAAI,EAAC,KADN;AAEC,EAAA,QAAQ,EAAGD,QAAQ,GAAGE,SAAH,GAAe,CAAC,CAFpC;AAGC,mBAAgBF,QAHjB;AAIC,EAAA,EAAE,EAAGF,KAJN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AL,CAAYH,GAAF,IACX,4BAAC,SAAD;AACC,IAAA,SAAS,EAAG,yBACX,iCADW,EAEXA,GAAG,CAACtB,SAFO,EAGX;AACC,OAAEK,WAAF,GAAiBiB,GAAG,CAACH,IAAJ,KAAavB;AAD/B,KAHW,CADb;AAQC,IAAA,KAAK,EAAI,GAAGY,UAAY,IAAIc,GAAG,CAACH,IAAM,EARvC;AASC,qBAAiB,GAAGX,UAAY,IAAIc,GAAG,CAACH,IAAM,OAT/C;AAUC,IAAA,QAAQ,EAAGG,GAAG,CAACH,IAAJ,KAAavB,QAVzB;AAWC,IAAA,GAAG,EAAG0B,GAAG,CAACH,IAXX;AAYC,IAAA,OAAO,EAAG,MAAMR,kBAAkB,CAAEW,GAAG,CAACH,IAAN,CAZnC;AAaC,IAAA,QAAQ,EAAGG,GAAG,CAACC,QAbhB;AAcC,IAAA,KAAK,EAAGD,GAAG,CAACI,IAAJ,IAAYJ,GAAG,CAACK,KAdzB;AAeC,IAAA,IAAI,EAAGL,GAAG,CAACI,IAfZ;AAgBC,IAAA,WAAW,EAAG,CAAC,CAAEJ,GAAG,CAACI;AAhBtB,KAkBG,CAAEJ,GAAG,CAACI,IAAN,IAAcJ,GAAG,CAACK,KAlBrB,CADC,CARH,CADD,EAgCGV,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGzB,QAAQ,CAAEsB,WAAF,CAPX,CAjCF,CADD;AA8CA,CA3HD;;AA6HO,MAAMR,QAAQ,GAAG,yBAAYV,mBAAZ,CAAjB;;eACQU,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseState,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? undefined : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\t__experimentalIsFocusable\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nconst UnforwardedTabPanel = (\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\ttabs,\n\t\tselectOnMove = true,\n\t\tinitialTabName,\n\t\torientation = 'horizontal',\n\t\tactiveClass = 'is-active',\n\t\tonSelect,\n\t}: WordPressComponentProps< TabPanelProps, 'div', false >,\n\tref: ForwardedRef< any >\n) => {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\t// Handle selecting the initial tab.\n\tuseLayoutEffect( () => {\n\t\t// If there's a selected tab, don't override it.\n\t\tif ( selectedTab ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst initialTab = tabs.find( ( tab ) => tab.name === initialTabName );\n\n\t\t// Wait for the denoted initial tab to be declared before making a\n\t\t// selection. This ensures that if a tab is declared lazily it can\n\t\t// still receive initial selection.\n\t\tif ( initialTabName && ! initialTab ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( initialTab && ! initialTab.disabled ) {\n\t\t\t// Select the initial tab if it's not disabled.\n\t\t\thandleTabSelection( initialTab.name );\n\t\t} else {\n\t\t\t// Fallback to the first enabled tab when the initial is disabled.\n\t\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\t\t\tif ( firstEnabledTab ) handleTabSelection( firstEnabledTab.name );\n\t\t}\n\t}, [ tabs, selectedTab, initialTabName, handleTabSelection ] );\n\n\t// Handle the currently selected tab becoming disabled.\n\tuseEffect( () => {\n\t\t// This effect only runs when the selected tab is defined and becomes disabled.\n\t\tif ( ! selectedTab?.disabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\n\t\t// If the currently selected tab becomes disabled, select the first enabled tab.\n\t\t// (if there is one).\n\t\tif ( firstEnabledTab ) {\n\t\t\thandleTabSelection( firstEnabledTab.name );\n\t\t}\n\t}, [ tabs, selectedTab?.disabled, handleTabSelection ] );\n\n\treturn (\n\t\t<div className={ className } ref={ ref }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tdisabled={ tab.disabled }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport const TabPanel = forwardRef( UnforwardedTabPanel );\nexport default TabPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["extractTabName","id","match","UnforwardedTabPanel","className","children","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","ref","instanceId","TabPanel","prependInstanceId","tabName","tabStore","Ariakit","useTabStore","setSelectedId","newTabValue","newTab","find","t","name","disabled","selectedTab","simplifiedTabName","defaultSelectedId","selectedTabName","useState","setTabStoreSelectedId","setState","previousSelectedTabName","initialTab","tab","firstEnabledTab","map","icon","title"],"mappings":";;;;;;;;;AAUA;;AAPA;;AACA;;AAYA;;AAMA;;;;;;AAtBA;AACA;AACA;;AAKA;AACA;AACA;;AASA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAKC,EAAF,IAAqC;AAC3D,MAAK,OAAOA,EAAP,KAAc,WAAd,IAA6BA,EAAE,KAAK,IAAzC,EAAgD;AAC/C;AACA;;AACD,SAAOA,EAAE,CAACC,KAAH,CAAU,wBAAV,IAAwC,CAAxC,CAAP;AACA,CALD;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,mBAAmB,GAAG,CAC3B;AACCC,EAAAA,SADD;AAECC,EAAAA,QAFD;AAGCC,EAAAA,IAHD;AAICC,EAAAA,YAAY,GAAG,IAJhB;AAKCC,EAAAA,cALD;AAMCC,EAAAA,WAAW,GAAG,YANf;AAOCC,EAAAA,WAAW,GAAG,WAPf;AAQCC,EAAAA;AARD,CAD2B,EAW3BC,GAX2B,KAYvB;AACJ,QAAMC,UAAU,GAAG,4BAAeC,QAAf,EAAyB,WAAzB,CAAnB;AAEA,QAAMC,iBAAiB,GAAG,0BACvBC,OAAF,IAAmC;AAClC,QAAK,OAAOA,OAAP,KAAmB,WAAxB,EAAsC;AACrC;AACA;;AACD,WAAQ,GAAGH,UAAY,IAAIG,O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IAAd,CAH1B;AAIC,IAAA,SAAS,EAAG;AAJb,KAMGpB,QAAQ,CAAEsB,WAAF,CANX,CApCF,CADD;AAgDA,CAvKD;;AAyKO,MAAMb,QAAQ,GAAG,yBAAYX,mBAAZ,CAAjB;;eACQW,Q","sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport classnames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport { useInstanceId, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\n\nimport Button from '../button';\nimport type { TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\n// Separate the actual tab name from the instance ID. This is\n// necessary because Ariakit internally uses the element ID when\n// a new tab is selected, but our implementation looks specifically\n// for the tab name to be passed to the `onSelect` callback.\nconst extractTabName = ( id: string | undefined | null ) => {\n\tif ( typeof id === 'undefined' || id === null ) {\n\t\treturn;\n\t}\n\treturn id.match( /^tab-panel-[0-9]*-(.*)/ )?.[ 1 ];\n};\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nconst UnforwardedTabPanel = (\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\ttabs,\n\t\tselectOnMove = true,\n\t\tinitialTabName,\n\t\torientation = 'horizontal',\n\t\tactiveClass = 'is-active',\n\t\tonSelect,\n\t}: WordPressComponentProps< TabPanelProps, 'div', false >,\n\tref: ForwardedRef< any >\n) => {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\n\tconst prependInstanceId = useCallback(\n\t\t( tabName: string | undefined ) => {\n\t\t\tif ( typeof tabName === 'undefined' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn `${ instanceId }-${ tabName }`;\n\t\t},\n\t\t[ instanceId ]\n\t);\n\n\tconst tabStore = Ariakit.useTabStore( {\n\t\tsetSelectedId: ( newTabValue ) => {\n\t\t\tif ( typeof newTabValue === 'undefined' || newTabValue === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newTab = tabs.find(\n\t\t\t\t( t ) => prependInstanceId( t.name ) === newTabValue\n\t\t\t);\n\t\t\tif ( newTab?.disabled || newTab === selectedTab ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst simplifiedTabName = extractTabName( newTabValue );\n\t\t\tif ( typeof simplifiedTabName === 'undefined' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tonSelect?.( simplifiedTabName );\n\t\t},\n\t\torientation,\n\t\tselectOnMove,\n\t\tdefaultSelectedId: prependInstanceId( initialTabName ),\n\t} );\n\n\tconst selectedTabName = extractTabName( tabStore.useState( 'selectedId' ) );\n\n\tconst setTabStoreSelectedId = useCallback(\n\t\t( tabName: string ) => {\n\t\t\ttabStore.setState( 'selectedId', prependInstanceId( tabName ) );\n\t\t},\n\t\t[ prependInstanceId, tabStore ]\n\t);\n\n\tconst selectedTab = tabs.find( ( { name } ) => name === selectedTabName );\n\n\tconst previousSelectedTabName = usePrevious( selectedTabName );\n\n\t// Ensure `onSelect` is called when the initial tab is selected.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tpreviousSelectedTabName !== selectedTabName &&\n\t\t\tselectedTabName === initialTabName &&\n\t\t\t!! selectedTabName\n\t\t) {\n\t\t\tonSelect?.( selectedTabName );\n\t\t}\n\t}, [ selectedTabName, initialTabName, onSelect, previousSelectedTabName ] );\n\n\t// Handle selecting the initial tab.\n\tuseLayoutEffect( () => {\n\t\t// If there's a selected tab, don't override it.\n\t\tif ( selectedTab ) {\n\t\t\treturn;\n\t\t}\n\t\tconst initialTab = tabs.find( ( tab ) => tab.name === initialTabName );\n\t\t// Wait for the denoted initial tab to be declared before making a\n\t\t// selection. This ensures that if a tab is declared lazily it can\n\t\t// still receive initial selection.\n\t\tif ( initialTabName && ! initialTab ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( initialTab && ! initialTab.disabled ) {\n\t\t\t// Select the initial tab if it's not disabled.\n\t\t\tsetTabStoreSelectedId( initialTab.name );\n\t\t} else {\n\t\t\t// Fallback to the first enabled tab when the initial tab is\n\t\t\t// disabled or it can't be found.\n\t\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\t\t\tif ( firstEnabledTab ) {\n\t\t\t\tsetTabStoreSelectedId( firstEnabledTab.name );\n\t\t\t}\n\t\t}\n\t}, [\n\t\ttabs,\n\t\tselectedTab,\n\t\tinitialTabName,\n\t\tinstanceId,\n\t\tsetTabStoreSelectedId,\n\t] );\n\n\t// Handle the currently selected tab becoming disabled.\n\tuseEffect( () => {\n\t\t// This effect only runs when the selected tab is defined and becomes disabled.\n\t\tif ( ! selectedTab?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst firstEnabledTab = tabs.find( ( tab ) => ! tab.disabled );\n\t\t// If the currently selected tab becomes disabled, select the first enabled tab.\n\t\t// (if there is one).\n\t\tif ( firstEnabledTab ) {\n\t\t\tsetTabStoreSelectedId( firstEnabledTab.name );\n\t\t}\n\t}, [ tabs, selectedTab?.disabled, setTabStoreSelectedId, instanceId ] );\n\treturn (\n\t\t<div className={ className } ref={ ref }>\n\t\t\t<Ariakit.TabList\n\t\t\t\tstore={ tabStore }\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Ariakit.Tab\n\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\tid={ prependInstanceId( tab.name ) }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[ activeClass ]:\n\t\t\t\t\t\t\t\t\t\ttab.name === selectedTabName,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tdisabled={ tab.disabled }\n\t\t\t\t\t\t\taria-controls={ `${ prependInstanceId(\n\t\t\t\t\t\t\t\ttab.name\n\t\t\t\t\t\t\t) }-view` }\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t\t</Ariakit.Tab>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</Ariakit.TabList>\n\t\t\t{ selectedTab && (\n\t\t\t\t<Ariakit.TabPanel\n\t\t\t\t\tid={ `${ prependInstanceId( selectedTab.name ) }-view` }\n\t\t\t\t\tstore={ tabStore }\n\t\t\t\t\ttabId={ prependInstanceId( selectedTab.name ) }\n\t\t\t\t\tclassName={ 'components-tab-panel__tab-content' }\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</Ariakit.TabPanel>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport const TabPanel = forwardRef( UnforwardedTabPanel );\nexport default TabPanel;\n"]}
@@ -31,13 +31,13 @@ function UnforwardedTextControl(props, ref) {
31
31
  hideLabelFromVision,
32
32
  value,
33
33
  help,
34
+ id: idProp,
34
35
  className,
35
36
  onChange,
36
37
  type = 'text',
37
38
  ...additionalProps
38
39
  } = props;
39
- const instanceId = (0, _compose.useInstanceId)(TextControl);
40
- const id = `inspector-text-control-${instanceId}`;
40
+ const id = (0, _compose.useInstanceId)(TextControl, 'inspector-text-control', idProp);
41
41
 
42
42
  const onChangeValue = event => onChange(event.target.value);
43
43
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/text-control/index.tsx"],"names":["UnforwardedTextControl","props","ref","__nextHasNoMarginBottom","label","hideLabelFromVision","value","help","className","onChange","type","additionalProps","instanceId","TextControl","id","onChangeValue","event","target","undefined"],"mappings":";;;;;;;;;AASA;;AADA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,sBAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AACLC,IAAAA,uBADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,mBAHK;AAILC,IAAAA,KAJK;AAKLC,IAAAA,IALK;AAMLC,IAAAA,SANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA,IAAI,GAAG,MARF;AASL,OAAGC;AATE,MAUFV,KAVJ;AAWA,QAAMW,UAAU,GAAG,4BAAeC,WAAf,CAAnB;AACA,QAAMC,EAAE,GAAI,0BAA0BF,UAAY,EAAlD;;AACA,QAAMG,aAAa,GAAKC,KAAF,IACrBP,QAAQ,CAAEO,KAAK,CAACC,MAAN,CAAaX,KAAf,CADT;;AAGA,SACC,4BAAC,oBAAD;AACC,IAAA,uBAAuB,EAAGH,uBAD3B;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,EAAE,EAAGS,EAJN;AAKC,IAAA,IAAI,EAAGP,IALR;AAMC,IAAA,SAAS,EAAGC;AANb,KAQC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,IAAI,EAAGE,IAFR;AAGC,IAAA,EAAE,EAAGI,EAHN;AAIC,IAAA,KAAK,EAAGR,KAJT;AAKC,IAAA,QAAQ,EAAGS,aALZ;AAMC,wBAAmB,CAAC,CAAER,IAAH,GAAUO,EAAE,GAAG,QAAf,GAA0BI,SAN9C;AAOC,IAAA,GAAG,EAAGhB,GAPP;AAAA,OAQMS;AARN,IARD,CADD;AAqBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,WAAW,GAAG,yBAAYb,sBAAZ,CAApB;;eAEQa,W","sourcesContent":["/**\n * External dependencies\n */\nimport type { ChangeEvent, ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { TextControlProps } from './types';\n\nfunction UnforwardedTextControl(\n\tprops: WordPressComponentProps< TextControlProps, 'input', false >,\n\tref: ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom,\n\t\tlabel,\n\t\thideLabelFromVision,\n\t\tvalue,\n\t\thelp,\n\t\tclassName,\n\t\tonChange,\n\t\ttype = 'text',\n\t\t...additionalProps\n\t} = props;\n\tconst instanceId = useInstanceId( TextControl );\n\tconst id = `inspector-text-control-${ instanceId }`;\n\tconst onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>\n\t\tonChange( event.target.value );\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"components-text-control__input\"\n\t\t\t\ttype={ type }\n\t\t\t\tid={ id }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeValue }\n\t\t\t\taria-describedby={ !! help ? id + '__help' : undefined }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * TextControl components let users enter and edit text.\n *\n * ```jsx\n * import { TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTextControl = () => {\n * const [ className, setClassName ] = useState( '' );\n *\n * return (\n * <TextControl\n * label=\"Additional CSS Class\"\n * value={ className }\n * onChange={ ( value ) => setClassName( value ) }\n * />\n * );\n * };\n * ```\n */\nexport const TextControl = forwardRef( UnforwardedTextControl );\n\nexport default TextControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/text-control/index.tsx"],"names":["UnforwardedTextControl","props","ref","__nextHasNoMarginBottom","label","hideLabelFromVision","value","help","id","idProp","className","onChange","type","additionalProps","TextControl","onChangeValue","event","target","undefined"],"mappings":";;;;;;;;;AASA;;AADA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,sBAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AACLC,IAAAA,uBADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,mBAHK;AAILC,IAAAA,KAJK;AAKLC,IAAAA,IALK;AAMLC,IAAAA,EAAE,EAAEC,MANC;AAOLC,IAAAA,SAPK;AAQLC,IAAAA,QARK;AASLC,IAAAA,IAAI,GAAG,MATF;AAUL,OAAGC;AAVE,MAWFZ,KAXJ;AAYA,QAAMO,EAAE,GAAG,4BAAeM,WAAf,EAA4B,wBAA5B,EAAsDL,MAAtD,CAAX;;AACA,QAAMM,aAAa,GAAKC,KAAF,IACrBL,QAAQ,CAAEK,KAAK,CAACC,MAAN,CAAaX,KAAf,CADT;;AAGA,SACC,4BAAC,oBAAD;AACC,IAAA,uBAAuB,EAAGH,uBAD3B;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,EAAE,EAAGG,EAJN;AAKC,IAAA,IAAI,EAAGD,IALR;AAMC,IAAA,SAAS,EAAGG;AANb,KAQC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,IAAI,EAAGE,IAFR;AAGC,IAAA,EAAE,EAAGJ,EAHN;AAIC,IAAA,KAAK,EAAGF,KAJT;AAKC,IAAA,QAAQ,EAAGS,aALZ;AAMC,wBAAmB,CAAC,CAAER,IAAH,GAAUC,EAAE,GAAG,QAAf,GAA0BU,SAN9C;AAOC,IAAA,GAAG,EAAGhB,GAPP;AAAA,OAQMW;AARN,IARD,CADD;AAqBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,yBAAYd,sBAAZ,CAApB;;eAEQc,W","sourcesContent":["/**\n * External dependencies\n */\nimport type { ChangeEvent, ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { TextControlProps } from './types';\n\nfunction UnforwardedTextControl(\n\tprops: WordPressComponentProps< TextControlProps, 'input', false >,\n\tref: ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom,\n\t\tlabel,\n\t\thideLabelFromVision,\n\t\tvalue,\n\t\thelp,\n\t\tid: idProp,\n\t\tclassName,\n\t\tonChange,\n\t\ttype = 'text',\n\t\t...additionalProps\n\t} = props;\n\tconst id = useInstanceId( TextControl, 'inspector-text-control', idProp );\n\tconst onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>\n\t\tonChange( event.target.value );\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"components-text-control__input\"\n\t\t\t\ttype={ type }\n\t\t\t\tid={ id }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeValue }\n\t\t\t\taria-describedby={ !! help ? id + '__help' : undefined }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * TextControl components let users enter and edit text.\n *\n * ```jsx\n * import { TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTextControl = () => {\n * const [ className, setClassName ] = useState( '' );\n *\n * return (\n * <TextControl\n * label=\"Additional CSS Class\"\n * value={ className }\n * onChange={ ( value ) => setClassName( value ) }\n * />\n * );\n * };\n * ```\n */\nexport const TextControl = forwardRef( UnforwardedTextControl );\n\nexport default TextControl;\n"]}
@@ -27,14 +27,17 @@ var _style = _interopRequireDefault(require("./style.scss"));
27
27
  * Internal dependencies
28
28
  */
29
29
  const ToolbarGroupContainer = ({
30
- getStylesFromColorScheme,
31
30
  passedStyle,
32
31
  children
33
- }) => (0, _element.createElement)(_reactNative.View, {
34
- style: [getStylesFromColorScheme(_style.default.container, _style.default.containerDark), passedStyle]
35
- }, children);
36
-
37
- var _default = (0, _compose.withPreferredColorScheme)(ToolbarGroupContainer);
38
-
32
+ }) => {
33
+ const groupStyles = [(0, _compose.usePreferredColorSchemeStyle)(_style.default.container, _style.default.containerDark), {
34
+ borderLeftWidth: _reactNative.StyleSheet.hairlineWidth
35
+ }, passedStyle];
36
+ return (0, _element.createElement)(_reactNative.View, {
37
+ style: groupStyles
38
+ }, children);
39
+ };
40
+
41
+ var _default = ToolbarGroupContainer;
39
42
  exports.default = _default;
40
43
  //# sourceMappingURL=toolbar-group-container.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.native.js"],"names":["ToolbarGroupContainer","getStylesFromColorScheme","passedStyle","children","styles","container","containerDark"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,CAAE;AAC/BC,EAAAA,wBAD+B;AAE/BC,EAAAA,WAF+B;AAG/BC,EAAAA;AAH+B,CAAF,KAK7B,4BAAC,iBAAD;AACC,EAAA,KAAK,EAAG,CACPF,wBAAwB,CAAEG,eAAOC,SAAT,EAAoBD,eAAOE,aAA3B,CADjB,EAEPJ,WAFO;AADT,GAMGC,QANH,CALD;;eAee,uCAA0BH,qBAA1B,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { withPreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ToolbarGroupContainer = ( {\n\tgetStylesFromColorScheme,\n\tpassedStyle,\n\tchildren,\n} ) => (\n\t<View\n\t\tstyle={ [\n\t\t\tgetStylesFromColorScheme( styles.container, styles.containerDark ),\n\t\t\tpassedStyle,\n\t\t] }\n\t>\n\t\t{ children }\n\t</View>\n);\n\nexport default withPreferredColorScheme( ToolbarGroupContainer );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.native.js"],"names":["ToolbarGroupContainer","passedStyle","children","groupStyles","styles","container","containerDark","borderLeftWidth","StyleSheet","hairlineWidth"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,CAAE;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAAF,KAAiC;AAC9D,QAAMC,WAAW,GAAG,CACnB,2CAA8BC,eAAOC,SAArC,EAAgDD,eAAOE,aAAvD,CADmB,EAEnB;AAAEC,IAAAA,eAAe,EAAEC,wBAAWC;AAA9B,GAFmB,EAGnBR,WAHmB,CAApB;AAMA,SAAO,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGE;AAAd,KAA8BD,QAA9B,CAAP;AACA,CARD;;eAUeF,qB","sourcesContent":["/**\n * External dependencies\n */\nimport { StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ToolbarGroupContainer = ( { passedStyle, children } ) => {\n\tconst groupStyles = [\n\t\tusePreferredColorSchemeStyle( styles.container, styles.containerDark ),\n\t\t{ borderLeftWidth: StyleSheet.hairlineWidth },\n\t\tpassedStyle,\n\t];\n\n\treturn <View style={ groupStyles }>{ children }</View>;\n};\n\nexport default ToolbarGroupContainer;\n"]}
@@ -27,10 +27,8 @@ import DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';
27
27
  import { isMultiplePaletteArray } from '../../color-palette/utils';
28
28
 
29
29
  const getAriaLabelColorValue = colorValue => {
30
- const isHex = colorValue.startsWith('#'); // Leave hex values as-is. Remove the `var()` wrapper from CSS vars.
31
-
32
- const displayValue = colorValue.replace(/^var\((.+)\)$/, '$1');
33
- return isHex ? displayValue.split('').join('-') : displayValue;
30
+ // Leave hex values as-is. Remove the `var()` wrapper from CSS vars.
31
+ return colorValue.replace(/^var\((.+)\)$/, '$1');
34
32
  };
35
33
 
36
34
  const getColorObject = (colorValue, colors) => {
@@ -60,15 +58,15 @@ const getToggleAriaLabel = (colorValue, colorObject, style, isStyleEnabled) => {
60
58
  if (isStyleEnabled) {
61
59
  if (colorObject) {
62
60
  const ariaLabelValue = getAriaLabelColorValue(colorObject.color);
63
- return style ? sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code, with added hyphens e.g: "#-f-0-0". %3$s: The current border style selection e.g. "solid".
64
- 'Border color and style picker. The currently selected color is called "%1$s" and has a value of "%2$s". The currently selected style is "%3$s".', colorObject.name, ariaLabelValue, style) : sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code, with added hyphens e.g: "#-f-0-0".
61
+ return style ? sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code e.g.: "#f00:". %3$s: The current border style selection e.g. "solid".
62
+ 'Border color and style picker. The currently selected color is called "%1$s" and has a value of "%2$s". The currently selected style is "%3$s".', colorObject.name, ariaLabelValue, style) : sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code e.g.: "#f00:".
65
63
  'Border color and style picker. The currently selected color is called "%1$s" and has a value of "%2$s".', colorObject.name, ariaLabelValue);
66
64
  }
67
65
 
68
66
  if (colorValue) {
69
67
  const ariaLabelValue = getAriaLabelColorValue(colorValue);
70
- return style ? sprintf( // translators: %1$s: The color's hex code, with added hyphens e.g: "#-f-0-0". %2$s: The current border style selection e.g. "solid".
71
- 'Border color and style picker. The currently selected color has a value of "%1$s". The currently selected style is "%2$s".', ariaLabelValue, style) : sprintf( // translators: %1$s: The color's hex code, with added hyphens e.g: "#-f-0-0".
68
+ return style ? sprintf( // translators: %1$s: The color's hex code e.g.: "#f00:". %2$s: The current border style selection e.g. "solid".
69
+ 'Border color and style picker. The currently selected color has a value of "%1$s". The currently selected style is "%2$s".', ariaLabelValue, style) : sprintf( // translators: %1$s: The color's hex code e.g: "#f00".
72
70
  'Border color and style picker. The currently selected color has a value of "%1$s".', ariaLabelValue);
73
71
  }
74
72
 
@@ -76,12 +74,12 @@ const getToggleAriaLabel = (colorValue, colorObject, style, isStyleEnabled) => {
76
74
  }
77
75
 
78
76
  if (colorObject) {
79
- return sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code, with added hyphens e.g: "#-f-0-0".
77
+ return sprintf( // translators: %1$s: The name of the color e.g. "vivid red". %2$s: The color's hex code e.g: "#f00".
80
78
  'Border color picker. The currently selected color is called "%1$s" and has a value of "%2$s".', colorObject.name, getAriaLabelColorValue(colorObject.color));
81
79
  }
82
80
 
83
81
  if (colorValue) {
84
- return sprintf( // translators: %1$s: The color's hex code, with added hyphens e.g: "#-f-0-0".
82
+ return sprintf( // translators: %1$s: The color's hex code e.g: "#f00".
85
83
  'Border color picker. The currently selected color has a value of "%1$s".', getAriaLabelColorValue(colorValue));
86
84
  }
87
85
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","isHex","startsWith","displayValue","replace","split","join","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","renderContent","onClose","ConnectedBorderControlDropdown"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,wBAAP,MAAqC,gCAArC;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,c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D,EAEpD,uBAFoD,CAArD;AAKA,eAAe2B,8BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\tconst isHex = colorValue.startsWith( '#' );\n\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\tconst displayValue = colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n\n\treturn isHex ? displayValue.split( '' ).join( '-' ) : displayValue;\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\".\n\t\t\t'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code, with added hyphens e.g: \"#-f-0-0\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset to default' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","replace","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","renderContent","onClose","ConnectedBorderControlDropdown"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,wBAAP,MAAqC,gCAArC;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,cAAP,MAA2B,uBAA3B;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,QAAP,MAAqB,gBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,cAAT,QAAwD,kBAAxD;AACA,SAASC,wBAAT,QAAyC,QAAzC;AACA,SAASC,WAAT,QAA4B,+CAA5B;AACA,OAAOC,sBAAP,MAAmC,yCAAnC;AAGA,SAASC,sBAAT,QAAuC,2BAAvC;;AAIA,MAAMC,sBAAsB,GAAKC,UAAF,IAA0B;AACxD;AACA,SAAOA,UAAU,CAACC,OAAX,CAAoB,eAApB,EAAqC,IAArC,CAAP;AACA,CAHD;;AAKA,MAAMC,cAAc,GAAG,CACtBF,UADsB,EAEtBG,MAFsB,KAGlB;AACJ,MAAK,CAAEH,UAAF,IAAgB,CAAEG,MAAvB,EAAgC;AAC/B;AACA;;AAED,MAAKL,sBAAsB,CAAEK,MAAF,CAA3B,EAAwC;AACvC;AACA,QAAIC,YAAJ;AAEAD,IAAAA,MAAM,CAACE,IAAP,CAAeC,MAAF,IACZA,MAAM,CAACH,MAAP,CAAcE,IAAd,CAAsBE,KAAF,IAAa;AAChC,UAAKA,KAAK,CAACA,KAAN,KAAgBP,UAArB,EAAkC;AACjCI,QAAAA,YAAY,GAAGG,KAAf;AACA,eAAO,IAAP;AACA;;AA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,IAAA,YAAY,EAAG,EACd,GAAGR;AADW,KAHhB;AAAA,OAMMC,UANN;AAOC,IAAA,GAAG,EAAGhB;AAPP,IADD;AAWA,CA5HD;;AA8HA,MAAMyB,8BAA8B,GAAGhD,cAAc,CACpDqB,qBADoD,EAEpD,uBAFoD,CAArD;AAKA,eAAe2B,8BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\treturn colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g.: \"#f00:\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset to default' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"]}
@@ -17,6 +17,7 @@ import { usePreferredColorScheme, usePreferredColorSchemeStyle } from '@wordpres
17
17
 
18
18
  import Tooltip from '../tooltip';
19
19
  import Icon from '../icon';
20
+ import style from './style.scss';
20
21
  const isAndroid = Platform.OS === 'android';
21
22
  const marginBottom = isAndroid ? -0.5 : 0;
22
23
  const marginLeft = -3;
@@ -41,9 +42,7 @@ const styles = StyleSheet.create({
41
42
  flexDirection: 'row',
42
43
  justifyContent: 'center',
43
44
  alignItems: 'center',
44
- borderRadius: 6,
45
- borderColor: '#2e4453',
46
- backgroundColor: '#2e4453'
45
+ borderRadius: 6
47
46
  },
48
47
  subscriptInactive: {
49
48
  color: '#7b9ab1',
@@ -86,16 +85,19 @@ export function Button(props) {
86
85
  shortcut,
87
86
  tooltipPosition,
88
87
  isActiveStyle,
89
- customContainerStyles
88
+ customContainerStyles,
89
+ hitSlop
90
90
  } = props;
91
91
  const preferredColorScheme = usePreferredColorScheme();
92
92
  const isDisabled = ariaDisabled || disabled;
93
93
  const containerStyle = [styles.container, customContainerStyles && { ...customContainerStyles
94
94
  }];
95
+ const buttonActiveColorStyles = usePreferredColorSchemeStyle(style['components-button-light--active'], style['components-button-dark--active']);
95
96
  const buttonViewStyle = {
96
97
  opacity: isDisabled ? 0.3 : 1,
97
98
  ...(fixedRatio && styles.fixedRatio),
98
99
  ...(isPressed ? styles.buttonActive : styles.buttonInactive),
100
+ ...(isPressed ? buttonActiveColorStyles : {}),
99
101
  ...(isPressed && isActiveStyle?.borderRadius && {
100
102
  borderRadius: isActiveStyle.borderRadius
101
103
  }),
@@ -131,7 +133,6 @@ export function Button(props) {
131
133
  icon: icon,
132
134
  size: iconSize
133
135
  }), {
134
- colorScheme: preferredColorScheme,
135
136
  isPressed
136
137
  }) : null;
137
138
  const longPressHandler = useCallback(({
@@ -151,7 +152,8 @@ export function Button(props) {
151
152
  onPress: onClick,
152
153
  style: containerStyle,
153
154
  disabled: isDisabled,
154
- testID: testID
155
+ testID: testID,
156
+ hitSlop: hitSlop
155
157
  }, createElement(LongPressGestureHandler, {
156
158
  minDurationMs: 500,
157
159
  maxDist: 150,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/button/index.native.js"],"names":["StyleSheet","TouchableOpacity","Text","View","Platform","LongPressGestureHandler","State","Children","cloneElement","useCallback","usePreferredColorScheme","usePreferredColorSchemeStyle","Tooltip","Icon","isAndroid","OS","marginBottom","marginLeft","styles","create","container","flex","padding","justifyContent","alignItems","buttonInactive","flexDirection","fixedRatio","aspectRatio","buttonActive","borderRadius","borderColor","backgroundColor","subscriptInactive","color","fontWeight","fontSize","alignSelf","subscriptInactiveDark","subscriptActive","Button","props","children","onClick","onLongPress","disabled","hint","isPressed","ariaDisabled","subscript","testID","icon","iconSize","showTooltip","label","shortcut","tooltipPosition","isActiveStyle","customContainerStyles","preferredColorScheme","isDisabled","containerStyle","buttonViewStyle","opacity","states","push","newChildren","map","child","colorScheme","shouldShowTooltip","Array","isArray","length","newIcon","longPressHandler","nativeEvent","state","ACTIVE","element"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,gBAFD,EAGCC,IAHD,EAICC,IAJD,EAKCC,QALD,QAMO,cANP;AAOA,SAASC,uBAAT,EAAkCC,KAAlC,QAA+C,8BAA/C;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,YAAnB,EAAiCC,WAAjC,QAAoD,oBAApD;AACA,SACCC,uBADD,EAECC,4BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AAEA,MAAMC,SAAS,GAAGV,QAAQ,CAACW,EAAT,KAAgB,SAAlC;AACA,MAAMC,YAAY,GAAGF,SAAS,GAAG,CAAC,GAAJ,GAAU,CAAxC;AACA,MAAMG,UAAU,GAAG,CAAC,CAApB;AAEA,MAAMC,MAAM,GAAGlB,UAAU,CAACmB,MAAX,CAAmB;AACjCC,EAAAA,SAAS,EAAE;AACVC,IAAAA,IAAI,EAAE,CADI;AAEVC,IAAAA,OAAO,EAAE,CAFC;AAGVC,IAAAA,cAAc,EAAE,QAHN;AAIVC,IAAAA,UAAU,EAAE;AAJF,GADsB;AAOjCC,EAAAA,cAAc,EAAE;AACfJ,IAAAA,IAAI,EAAE,CADS;AAEfK,IAAAA,aAAa,EAAE,KAFA;AAGfH,IAAAA,cAAc,EAAE,QAHD;AAIfC,IAAAA,UAAU,EAAE;AAJG,GAPiB;AAajCG,EAAAA,UAAU,EAAE;AACXC,IAAAA,WAAW,EAAE;AADF,GAbqB;AAg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b;AAAd,KACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAG;AAAEpC,MAAAA,aAAa,EAAE;AAAjB;AAAd,KACGgD,OADH,EAEGR,WAFH,EAGGjB,SAAS,IACV,cAAC,IAAD;AACC,IAAA,KAAK,EACJF,SAAS,GACN7B,MAAM,CAACqB,eADD,GAENN;AAJL,KAOGgB,SAPH,CAJF,CADD,CALD,CAZD,CADD;;AAuCA,MAAK,CAAEqB,iBAAP,EAA2B;AAC1B,WAAOS,OAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,IAAI,EAAGzB,KADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC,eAHZ;AAIC,IAAA,OAAO,EAAGH,WAAW,KAAK;AAJ3B,KAMG0B,OANH,CADD;AAUA;AAED,eAAevC,MAAf","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tStyleSheet,\n\tTouchableOpacity,\n\tText,\n\tView,\n\tPlatform,\n} from 'react-native';\nimport { LongPressGestureHandler, State } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Children, cloneElement, useCallback } from '@wordpress/element';\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\n\nconst isAndroid = Platform.OS === 'android';\nconst marginBottom = isAndroid ? -0.5 : 0;\nconst marginLeft = -3;\n\nconst styles = StyleSheet.create( {\n\tcontainer: {\n\t\tflex: 1,\n\t\tpadding: 3,\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tbuttonInactive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tfixedRatio: {\n\t\taspectRatio: 1,\n\t},\n\tbuttonActive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\tborderRadius: 6,\n\t\tborderColor: '#2e4453',\n\t\tbackgroundColor: '#2e4453',\n\t},\n\tsubscriptInactive: {\n\t\tcolor: '#7b9ab1', // $toolbar-button.\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n\tsubscriptInactiveDark: {\n\t\tcolor: '#a7aaad', // $gray_20.\n\t},\n\tsubscriptActive: {\n\t\tcolor: 'white',\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n} );\n\nexport function Button( props ) {\n\tconst {\n\t\tchildren,\n\t\tonClick,\n\t\tonLongPress,\n\t\tdisabled,\n\t\thint,\n\t\tfixedRatio = true,\n\t\tisPressed,\n\t\t'aria-disabled': ariaDisabled,\n\t\t'data-subscript': subscript,\n\t\ttestID,\n\t\ticon,\n\t\ticonSize,\n\t\tshowTooltip,\n\t\tlabel,\n\t\tshortcut,\n\t\ttooltipPosition,\n\t\tisActiveStyle,\n\t\tcustomContainerStyles,\n\t} = props;\n\tconst preferredColorScheme = usePreferredColorScheme();\n\n\tconst isDisabled = ariaDisabled || disabled;\n\n\tconst containerStyle = [\n\t\tstyles.container,\n\t\tcustomContainerStyles && { ...customContainerStyles },\n\t];\n\n\tconst buttonViewStyle = {\n\t\topacity: isDisabled ? 0.3 : 1,\n\t\t...( fixedRatio && styles.fixedRatio ),\n\t\t...( isPressed ? styles.buttonActive : styles.buttonInactive ),\n\t\t...( isPressed &&\n\t\t\tisActiveStyle?.borderRadius && {\n\t\t\t\tborderRadius: isActiveStyle.borderRadius,\n\t\t\t} ),\n\t\t...( isActiveStyle?.backgroundColor && {\n\t\t\tbackgroundColor: isActiveStyle.backgroundColor,\n\t\t} ),\n\t};\n\n\tconst states = [];\n\tif ( isPressed ) {\n\t\tstates.push( 'selected' );\n\t}\n\n\tif ( isDisabled ) {\n\t\tstates.push( 'disabled' );\n\t}\n\n\tconst subscriptInactive = usePreferredColorSchemeStyle(\n\t\tstyles.subscriptInactive,\n\t\tstyles.subscriptInactiveDark\n\t);\n\n\tconst newChildren = Children.map( children, ( child ) => {\n\t\treturn child\n\t\t\t? cloneElement( child, {\n\t\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\t\tisPressed,\n\t\t\t } )\n\t\t\t: child;\n\t} );\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! isDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t( ! children ||\n\t\t\t\t\t( Array.isArray( children ) && ! children.length ) ) &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst newIcon = icon\n\t\t? cloneElement( <Icon icon={ icon } size={ iconSize } />, {\n\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\tisPressed,\n\t\t } )\n\t\t: null;\n\n\tconst longPressHandler = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tif ( nativeEvent.state === State.ACTIVE && onLongPress ) {\n\t\t\t\tonLongPress();\n\t\t\t}\n\t\t},\n\t\t[ onLongPress ]\n\t);\n\n\tconst element = (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.7 }\n\t\t\taccessible={ true }\n\t\t\taccessibilityLabel={ label }\n\t\t\taccessibilityStates={ states }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ hint }\n\t\t\tonPress={ onClick }\n\t\t\tstyle={ containerStyle }\n\t\t\tdisabled={ isDisabled }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<LongPressGestureHandler\n\t\t\t\tminDurationMs={ 500 }\n\t\t\t\tmaxDist={ 150 }\n\t\t\t\tonHandlerStateChange={ longPressHandler }\n\t\t\t>\n\t\t\t\t<View style={ buttonViewStyle }>\n\t\t\t\t\t<View style={ { flexDirection: 'row' } }>\n\t\t\t\t\t\t{ newIcon }\n\t\t\t\t\t\t{ newChildren }\n\t\t\t\t\t\t{ subscript && (\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tisPressed\n\t\t\t\t\t\t\t\t\t\t? styles.subscriptActive\n\t\t\t\t\t\t\t\t\t\t: subscriptInactive\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ subscript }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</View>\n\t\t\t\t</View>\n\t\t\t</LongPressGestureHandler>\n\t\t</TouchableOpacity>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn element;\n\t}\n\n\treturn (\n\t\t<Tooltip\n\t\t\ttext={ label }\n\t\t\tshortcut={ shortcut }\n\t\t\tposition={ tooltipPosition }\n\t\t\tvisible={ showTooltip === true }\n\t\t>\n\t\t\t{ element }\n\t\t</Tooltip>\n\t);\n}\n\nexport default Button;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/button/index.native.js"],"names":["StyleSheet","TouchableOpacity","Text","View","Platform","LongPressGestureHandler","State","Children","cloneElement","useCallback","usePreferredColorScheme","usePreferredColorSchemeStyle","Tooltip","Icon","style","isAndroid","OS","marginBottom","marginLeft","styles","create","container","flex","padding","justifyContent","alignItems","buttonInactive","flexDirection","fixedRatio","aspectRatio","buttonActive","borderRadius","subscriptInactive","color","fontWeight","fontSize","alignSelf","subscriptInactiveDark","subscriptActive","Button","props","children","onClick","onLongPress","disabled","hint","isPressed","ariaDisabled","subscript","testID","icon","iconSize","showTooltip","label","shortcut","tooltipPosition","isActiveStyle","customContainerStyles","hitSlop","preferredColorScheme","isDisabled","containerStyle","buttonActiveColorStyles","buttonViewStyle","opacity","backgroundColor","states","push","newChildren","map","child","colorScheme","shouldShowTooltip","Array","isArray","length","newIcon","longPressHandler","nativeEvent","state","ACTIVE","element"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,gBAFD,EAGCC,IAHD,EAICC,IAJD,EAKCC,QALD,QAMO,cANP;AAOA,SAASC,uBAAT,EAAkCC,KAAlC,QAA+C,8BAA/C;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,YAAnB,EAAiCC,WAAjC,QAAoD,oBAApD;AACA,SACCC,uBADD,EAECC,4BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AAEA,MAAMC,SAAS,GAAGX,QAAQ,CAACY,EAAT,KAAgB,SAAlC;AACA,MAAMC,YAAY,GAAGF,SAAS,GAAG,CAAC,GAAJ,GAAU,CAAxC;AACA,MAAMG,UAAU,GAAG,CAAC,CAApB;AAEA,MAAMC,MAAM,GAAGnB,UAAU,CAACoB,MAAX,CAAmB;AACjCC,EAAAA,SAAS,EAAE;AACVC,IAAAA,IAAI,EAAE,CADI;AAEVC,IAAAA,OAAO,EAAE,CAFC;AAGVC,IAAAA,cAAc,EAAE,QAHN;AAIVC,IAAAA,UAAU,EAAE;AAJF,GADsB;AAOjCC,EAAAA,cAAc,EAAE;AACfJ,IAAAA,IAAI,EAAE,CADS;AAEfK,IAAAA,aAAa,EAAE,KAFA;AAGfH,IAAAA,cAAc,EAAE,QAHD;AAIfC,IAAAA,UAAU,EAAE;AAJG,GAPiB;AAajCG,EAAAA,UAAU,EAAE;AACXC,IAAAA,WAAW,EAAE;AADF,GAbqB;AAgBjCC,EAAAA,YAAY,EAAE;AACbR,IAAAA,IAAI,EAAE,CADO;AAEbK,IAAAA,aAAa,EAAE,KAFF;AAGbH,IAAAA,cAAc,EAAE,QAHH;AAIbC,IAAAA,UAAU,EAAE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AAAM,IAAA,KAAK,EAAG;AAAEpC,MAAAA,aAAa,EAAE;AAAjB;AAAd,KACGiD,OADH,EAEGR,WAFH,EAGGpB,SAAS,IACV,cAAC,IAAD;AACC,IAAA,KAAK,EACJF,SAAS,GACN3B,MAAM,CAACmB,eADD,GAENN;AAJL,KAOGgB,SAPH,CAJF,CADD,CALD,CAbD,CADD;;AAwCA,MAAK,CAAEwB,iBAAP,EAA2B;AAC1B,WAAOS,OAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,IAAI,EAAG5B,KADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC,eAHZ;AAIC,IAAA,OAAO,EAAGH,WAAW,KAAK;AAJ3B,KAMG6B,OANH,CADD;AAUA;AAED,eAAe1C,MAAf","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tStyleSheet,\n\tTouchableOpacity,\n\tText,\n\tView,\n\tPlatform,\n} from 'react-native';\nimport { LongPressGestureHandler, State } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Children, cloneElement, useCallback } from '@wordpress/element';\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport style from './style.scss';\n\nconst isAndroid = Platform.OS === 'android';\nconst marginBottom = isAndroid ? -0.5 : 0;\nconst marginLeft = -3;\n\nconst styles = StyleSheet.create( {\n\tcontainer: {\n\t\tflex: 1,\n\t\tpadding: 3,\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tbuttonInactive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tfixedRatio: {\n\t\taspectRatio: 1,\n\t},\n\tbuttonActive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\tborderRadius: 6,\n\t},\n\tsubscriptInactive: {\n\t\tcolor: '#7b9ab1', // $toolbar-button.\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n\tsubscriptInactiveDark: {\n\t\tcolor: '#a7aaad', // $gray_20.\n\t},\n\tsubscriptActive: {\n\t\tcolor: 'white',\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n} );\n\nexport function Button( props ) {\n\tconst {\n\t\tchildren,\n\t\tonClick,\n\t\tonLongPress,\n\t\tdisabled,\n\t\thint,\n\t\tfixedRatio = true,\n\t\tisPressed,\n\t\t'aria-disabled': ariaDisabled,\n\t\t'data-subscript': subscript,\n\t\ttestID,\n\t\ticon,\n\t\ticonSize,\n\t\tshowTooltip,\n\t\tlabel,\n\t\tshortcut,\n\t\ttooltipPosition,\n\t\tisActiveStyle,\n\t\tcustomContainerStyles,\n\t\thitSlop,\n\t} = props;\n\tconst preferredColorScheme = usePreferredColorScheme();\n\n\tconst isDisabled = ariaDisabled || disabled;\n\n\tconst containerStyle = [\n\t\tstyles.container,\n\t\tcustomContainerStyles && { ...customContainerStyles },\n\t];\n\n\tconst buttonActiveColorStyles = usePreferredColorSchemeStyle(\n\t\tstyle[ 'components-button-light--active' ],\n\t\tstyle[ 'components-button-dark--active' ]\n\t);\n\n\tconst buttonViewStyle = {\n\t\topacity: isDisabled ? 0.3 : 1,\n\t\t...( fixedRatio && styles.fixedRatio ),\n\t\t...( isPressed ? styles.buttonActive : styles.buttonInactive ),\n\t\t...( isPressed ? buttonActiveColorStyles : {} ),\n\t\t...( isPressed &&\n\t\t\tisActiveStyle?.borderRadius && {\n\t\t\t\tborderRadius: isActiveStyle.borderRadius,\n\t\t\t} ),\n\t\t...( isActiveStyle?.backgroundColor && {\n\t\t\tbackgroundColor: isActiveStyle.backgroundColor,\n\t\t} ),\n\t};\n\n\tconst states = [];\n\tif ( isPressed ) {\n\t\tstates.push( 'selected' );\n\t}\n\n\tif ( isDisabled ) {\n\t\tstates.push( 'disabled' );\n\t}\n\n\tconst subscriptInactive = usePreferredColorSchemeStyle(\n\t\tstyles.subscriptInactive,\n\t\tstyles.subscriptInactiveDark\n\t);\n\n\tconst newChildren = Children.map( children, ( child ) => {\n\t\treturn child\n\t\t\t? cloneElement( child, {\n\t\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\t\tisPressed,\n\t\t\t } )\n\t\t\t: child;\n\t} );\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! isDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t( ! children ||\n\t\t\t\t\t( Array.isArray( children ) && ! children.length ) ) &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst newIcon = icon\n\t\t? cloneElement( <Icon icon={ icon } size={ iconSize } />, {\n\t\t\t\tisPressed,\n\t\t } )\n\t\t: null;\n\n\tconst longPressHandler = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tif ( nativeEvent.state === State.ACTIVE && onLongPress ) {\n\t\t\t\tonLongPress();\n\t\t\t}\n\t\t},\n\t\t[ onLongPress ]\n\t);\n\n\tconst element = (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.7 }\n\t\t\taccessible={ true }\n\t\t\taccessibilityLabel={ label }\n\t\t\taccessibilityStates={ states }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ hint }\n\t\t\tonPress={ onClick }\n\t\t\tstyle={ containerStyle }\n\t\t\tdisabled={ isDisabled }\n\t\t\ttestID={ testID }\n\t\t\thitSlop={ hitSlop }\n\t\t>\n\t\t\t<LongPressGestureHandler\n\t\t\t\tminDurationMs={ 500 }\n\t\t\t\tmaxDist={ 150 }\n\t\t\t\tonHandlerStateChange={ longPressHandler }\n\t\t\t>\n\t\t\t\t<View style={ buttonViewStyle }>\n\t\t\t\t\t<View style={ { flexDirection: 'row' } }>\n\t\t\t\t\t\t{ newIcon }\n\t\t\t\t\t\t{ newChildren }\n\t\t\t\t\t\t{ subscript && (\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tisPressed\n\t\t\t\t\t\t\t\t\t\t? styles.subscriptActive\n\t\t\t\t\t\t\t\t\t\t: subscriptInactive\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ subscript }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</View>\n\t\t\t\t</View>\n\t\t\t</LongPressGestureHandler>\n\t\t</TouchableOpacity>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn element;\n\t}\n\n\treturn (\n\t\t<Tooltip\n\t\t\ttext={ label }\n\t\t\tshortcut={ shortcut }\n\t\t\tposition={ tooltipPosition }\n\t\t\tvisible={ showTooltip === true }\n\t\t>\n\t\t\t{ element }\n\t\t</Tooltip>\n\t);\n}\n\nexport default Button;\n"]}
@@ -160,8 +160,8 @@ function UnforwardedColorPalette(props, forwardedRef) {
160
160
  const isHex = value?.startsWith('#'); // Leave hex values as-is. Remove the `var()` wrapper from CSS vars.
161
161
 
162
162
  const displayValue = value?.replace(/^var\((.+)\)$/, '$1');
163
- const customColorAccessibleLabel = !!displayValue ? sprintf( // translators: %1$s: The name of the color e.g: "vivid red". %2$s: The color's hex code, with added hyphens e.g: "#-f-0-0".
164
- __('Custom color picker. The currently selected color is called "%1$s" and has a value of "%2$s".'), buttonLabelName, isHex ? displayValue.split('').join('-') : displayValue) : __('Custom color picker.');
163
+ const customColorAccessibleLabel = !!displayValue ? sprintf( // translators: %1$s: The name of the color e.g: "vivid red". %2$s: The color's hex code e.g: "#f00".
164
+ __('Custom color picker. The currently selected color is called "%1$s" and has a value of "%2$s".'), buttonLabelName, displayValue) : __('Custom color picker.');
165
165
  const paletteCommonProps = {
166
166
  clearable,
167
167
  clearColor,