@wordpress/components 27.0.0 → 27.1.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 (208) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/build/base-control/index.native.js.map +1 -1
  3. package/build/border-box-control/border-box-control/component.js.map +1 -1
  4. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  5. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  6. package/build/button/index.js +2 -2
  7. package/build/button/index.js.map +1 -1
  8. package/build/button/index.native.js.map +1 -1
  9. package/build/confirm-dialog/component.js.map +1 -1
  10. package/build/custom-select-control-v2/default-component/index.js.map +1 -1
  11. package/build/custom-select-control-v2/index.js +2 -2
  12. package/build/custom-select-control-v2/index.js.map +1 -1
  13. package/build/custom-select-control-v2/types.js.map +1 -1
  14. package/build/draggable/index.native.js +2 -2
  15. package/build/draggable/index.native.js.map +1 -1
  16. package/build/dropdown-menu/index.native.js.map +1 -1
  17. package/build/flex/flex/hook.js +1 -1
  18. package/build/flex/flex/hook.js.map +1 -1
  19. package/build/font-size-picker/index.native.js.map +1 -1
  20. package/build/form-token-field/index.js.map +1 -1
  21. package/build/h-stack/hook.js +6 -1
  22. package/build/h-stack/hook.js.map +1 -1
  23. package/build/mobile/bottom-sheet/button.native.js.map +1 -1
  24. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  25. package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  26. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  27. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  28. package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  29. package/build/mobile/gradient/index.native.js.map +1 -1
  30. package/build/mobile/image/index.native.js +4 -13
  31. package/build/mobile/image/index.native.js.map +1 -1
  32. package/build/mobile/media-edit/index.native.js.map +1 -1
  33. package/build/palette-edit/index.js.map +1 -1
  34. package/build/query-controls/index.native.js.map +1 -1
  35. package/build/range-control/index.js.map +1 -1
  36. package/build/search-control/index.native.js.map +1 -1
  37. package/build/snackbar/index.js +3 -2
  38. package/build/snackbar/index.js.map +1 -1
  39. package/build/snackbar/list.js +2 -1
  40. package/build/snackbar/list.js.map +1 -1
  41. package/build/snackbar/types.js.map +1 -1
  42. package/build/tabs/index.js +7 -7
  43. package/build/tabs/index.js.map +1 -1
  44. package/build/tabs/types.js.map +1 -1
  45. package/build/utils/hooks/index.js +0 -7
  46. package/build/utils/hooks/index.js.map +1 -1
  47. package/build-module/base-control/index.native.js.map +1 -1
  48. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  49. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  50. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  51. package/build-module/button/index.js +2 -2
  52. package/build-module/button/index.js.map +1 -1
  53. package/build-module/button/index.native.js.map +1 -1
  54. package/build-module/confirm-dialog/component.js.map +1 -1
  55. package/build-module/custom-select-control-v2/default-component/index.js.map +1 -1
  56. package/build-module/custom-select-control-v2/index.js +1 -1
  57. package/build-module/custom-select-control-v2/index.js.map +1 -1
  58. package/build-module/custom-select-control-v2/types.js.map +1 -1
  59. package/build-module/draggable/index.native.js +2 -2
  60. package/build-module/draggable/index.native.js.map +1 -1
  61. package/build-module/dropdown-menu/index.native.js.map +1 -1
  62. package/build-module/flex/flex/hook.js +1 -1
  63. package/build-module/flex/flex/hook.js.map +1 -1
  64. package/build-module/font-size-picker/index.native.js.map +1 -1
  65. package/build-module/form-token-field/index.js.map +1 -1
  66. package/build-module/h-stack/hook.js +6 -1
  67. package/build-module/h-stack/hook.js.map +1 -1
  68. package/build-module/mobile/bottom-sheet/button.native.js.map +1 -1
  69. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  70. package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  71. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  72. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  73. package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  74. package/build-module/mobile/gradient/index.native.js.map +1 -1
  75. package/build-module/mobile/image/index.native.js +6 -15
  76. package/build-module/mobile/image/index.native.js.map +1 -1
  77. package/build-module/mobile/media-edit/index.native.js.map +1 -1
  78. package/build-module/palette-edit/index.js.map +1 -1
  79. package/build-module/query-controls/index.native.js.map +1 -1
  80. package/build-module/range-control/index.js.map +1 -1
  81. package/build-module/search-control/index.native.js.map +1 -1
  82. package/build-module/snackbar/index.js +3 -2
  83. package/build-module/snackbar/index.js.map +1 -1
  84. package/build-module/snackbar/list.js +2 -1
  85. package/build-module/snackbar/list.js.map +1 -1
  86. package/build-module/snackbar/types.js.map +1 -1
  87. package/build-module/tabs/index.js +7 -7
  88. package/build-module/tabs/index.js.map +1 -1
  89. package/build-module/tabs/types.js.map +1 -1
  90. package/build-module/utils/hooks/index.js +0 -1
  91. package/build-module/utils/hooks/index.js.map +1 -1
  92. package/build-style/style-rtl.css +8 -1
  93. package/build-style/style.css +8 -1
  94. package/build-types/custom-select-control-v2/default-component/index.d.ts +2 -1
  95. package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -1
  96. package/build-types/custom-select-control-v2/index.d.ts +1 -1
  97. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  98. package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts +2 -0
  99. package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts.map +1 -0
  100. package/build-types/custom-select-control-v2/stories/default.story.d.ts +4 -3
  101. package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -1
  102. package/build-types/custom-select-control-v2/stories/legacy.story.d.ts +2 -2
  103. package/build-types/custom-select-control-v2/stories/legacy.story.d.ts.map +1 -1
  104. package/build-types/custom-select-control-v2/types.d.ts +0 -1
  105. package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
  106. package/build-types/flex/flex/hook.d.ts +2 -3
  107. package/build-types/flex/flex/hook.d.ts.map +1 -1
  108. package/build-types/h-stack/hook.d.ts +2 -4
  109. package/build-types/h-stack/hook.d.ts.map +1 -1
  110. package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -1
  111. package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
  112. package/build-types/snackbar/index.d.ts +5 -2
  113. package/build-types/snackbar/index.d.ts.map +1 -1
  114. package/build-types/snackbar/list.d.ts.map +1 -1
  115. package/build-types/snackbar/test/index.d.ts +2 -0
  116. package/build-types/snackbar/test/index.d.ts.map +1 -0
  117. package/build-types/snackbar/test/list.d.ts +2 -0
  118. package/build-types/snackbar/test/list.d.ts.map +1 -0
  119. package/build-types/snackbar/types.d.ts +18 -2
  120. package/build-types/snackbar/types.d.ts.map +1 -1
  121. package/build-types/tabs/index.d.ts +1 -1
  122. package/build-types/tabs/types.d.ts +1 -1
  123. package/build-types/utils/hooks/index.d.ts +0 -1
  124. package/build-types/v-stack/hook.d.ts +2 -4
  125. package/build-types/v-stack/hook.d.ts.map +1 -1
  126. package/package.json +19 -19
  127. package/src/base-control/index.native.js +1 -1
  128. package/src/base-control/test/index.tsx +1 -1
  129. package/src/border-box-control/border-box-control/component.tsx +1 -1
  130. package/src/border-box-control/border-box-control-split-controls/component.tsx +4 -4
  131. package/src/border-control/border-control-dropdown/component.tsx +1 -1
  132. package/src/button/index.native.js +1 -1
  133. package/src/button/index.tsx +1 -1
  134. package/src/button/style.scss +1 -3
  135. package/src/circular-option-picker/test/index.tsx +2 -4
  136. package/src/combobox-control/test/index.tsx +1 -1
  137. package/src/confirm-dialog/component.tsx +1 -1
  138. package/src/confirm-dialog/test/index.tsx +5 -21
  139. package/src/custom-select-control-v2/default-component/index.tsx +4 -1
  140. package/src/custom-select-control-v2/index.tsx +1 -1
  141. package/src/custom-select-control-v2/legacy-component/test/index.tsx +457 -0
  142. package/src/custom-select-control-v2/stories/legacy.story.tsx +5 -6
  143. package/src/custom-select-control-v2/test/index.tsx +279 -749
  144. package/src/custom-select-control-v2/types.ts +0 -1
  145. package/src/disabled/test/index.tsx +1 -1
  146. package/src/draggable/index.native.js +2 -2
  147. package/src/draggable/test/index.native.js +6 -2
  148. package/src/dropdown-menu/index.native.js +2 -2
  149. package/src/flex/flex/hook.ts +1 -1
  150. package/src/font-size-picker/index.native.js +2 -2
  151. package/src/form-token-field/index.tsx +1 -1
  152. package/src/h-stack/hook.tsx +2 -1
  153. package/src/h-stack/test/index.tsx +10 -0
  154. package/src/item-group/test/index.js +2 -2
  155. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +10 -15
  156. package/src/mobile/bottom-sheet/button.native.js +1 -5
  157. package/src/mobile/bottom-sheet/index.native.js +2 -2
  158. package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
  159. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -2
  160. package/src/mobile/bottom-sheet-select-control/index.native.js +1 -1
  161. package/src/mobile/bottom-sheet-text-control/index.native.js +1 -1
  162. package/src/mobile/gradient/index.native.js +1 -1
  163. package/src/mobile/image/index.native.js +8 -23
  164. package/src/mobile/media-edit/index.native.js +1 -1
  165. package/src/modal/test/index.tsx +1 -1
  166. package/src/navigation/stories/utils/hide-if-empty.tsx +2 -6
  167. package/src/palette-edit/index.tsx +2 -2
  168. package/src/popover/test/index.tsx +1 -4
  169. package/src/query-controls/index.native.js +2 -2
  170. package/src/radio-group/stories/index.story.tsx +1 -0
  171. package/src/range-control/index.tsx +3 -3
  172. package/src/range-control/test/index.tsx +2 -2
  173. package/src/search-control/index.native.js +1 -1
  174. package/src/snackbar/index.tsx +5 -2
  175. package/src/snackbar/list.tsx +6 -1
  176. package/src/snackbar/stories/list.story.tsx +0 -3
  177. package/src/snackbar/test/index.tsx +267 -0
  178. package/src/snackbar/test/list.tsx +46 -0
  179. package/src/snackbar/types.ts +31 -3
  180. package/src/tabs/README.md +18 -18
  181. package/src/tabs/index.tsx +7 -7
  182. package/src/tabs/stories/index.story.tsx +1 -1
  183. package/src/tabs/test/index.tsx +30 -30
  184. package/src/tabs/types.ts +1 -1
  185. package/src/toggle-group-control/test/index.tsx +1 -1
  186. package/src/tools-panel/stories/index.story.tsx +8 -8
  187. package/src/tools-panel/test/index.tsx +10 -28
  188. package/src/tooltip/style.scss +2 -1
  189. package/src/tooltip/test/index.native.js +3 -3
  190. package/src/tree-grid/test/index.tsx +1 -1
  191. package/src/utils/hooks/index.js +0 -1
  192. package/src/v-stack/test/index.tsx +10 -0
  193. package/tsconfig.tsbuildinfo +1 -1
  194. package/build/custom-select-control-v2/legacy-adapter.js +0 -29
  195. package/build/custom-select-control-v2/legacy-adapter.js.map +0 -1
  196. package/build/utils/hooks/use-latest-ref.js +0 -33
  197. package/build/utils/hooks/use-latest-ref.js.map +0 -1
  198. package/build-module/custom-select-control-v2/legacy-adapter.js +0 -21
  199. package/build-module/custom-select-control-v2/legacy-adapter.js.map +0 -1
  200. package/build-module/utils/hooks/use-latest-ref.js +0 -27
  201. package/build-module/utils/hooks/use-latest-ref.js.map +0 -1
  202. package/build-types/custom-select-control-v2/legacy-adapter.d.ts +0 -6
  203. package/build-types/custom-select-control-v2/legacy-adapter.d.ts.map +0 -1
  204. package/build-types/utils/hooks/use-latest-ref.d.ts +0 -15
  205. package/build-types/utils/hooks/use-latest-ref.d.ts.map +0 -1
  206. package/src/custom-select-control-v2/legacy-adapter.tsx +0 -25
  207. package/src/utils/hooks/test/use-latest-ref.js +0 -119
  208. package/src/utils/hooks/use-latest-ref.ts +0 -29
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = require("react");
9
- var _legacyComponent = _interopRequireDefault(require("./legacy-component"));
10
- var _defaultComponent = _interopRequireDefault(require("./default-component"));
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- function isLegacy(props) {
16
- return typeof props.options !== 'undefined';
17
- }
18
- function CustomSelect(props) {
19
- if (isLegacy(props)) {
20
- return (0, _react.createElement)(_legacyComponent.default, {
21
- ...props
22
- });
23
- }
24
- return (0, _react.createElement)(_defaultComponent.default, {
25
- ...props
26
- });
27
- }
28
- var _default = exports.default = CustomSelect;
29
- //# sourceMappingURL=legacy-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_legacyComponent","_interopRequireDefault","require","_defaultComponent","isLegacy","props","options","CustomSelect","_react","createElement","default","_default","exports"],"sources":["@wordpress/components/src/custom-select-control-v2/legacy-adapter.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport _LegacyCustomSelect from './legacy-component';\nimport _NewCustomSelect from './default-component';\nimport type { CustomSelectProps, LegacyCustomSelectProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction isLegacy( props: any ): props is LegacyCustomSelectProps {\n\treturn typeof props.options !== 'undefined';\n}\n\nfunction CustomSelect(\n\tprops:\n\t\t| LegacyCustomSelectProps\n\t\t| WordPressComponentProps< CustomSelectProps, 'button', false >\n) {\n\tif ( isLegacy( props ) ) {\n\t\treturn <_LegacyCustomSelect { ...props } />;\n\t}\n\n\treturn <_NewCustomSelect { ...props } />;\n}\n\nexport default CustomSelect;\n"],"mappings":";;;;;;;;AAGA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAMA,SAASE,QAAQA,CAAEC,KAAU,EAAqC;EACjE,OAAO,OAAOA,KAAK,CAACC,OAAO,KAAK,WAAW;AAC5C;AAEA,SAASC,YAAYA,CACpBF,KAEgE,EAC/D;EACD,IAAKD,QAAQ,CAAEC,KAAM,CAAC,EAAG;IACxB,OAAO,IAAAG,MAAA,CAAAC,aAAA,EAACT,gBAAA,CAAAU,OAAmB;MAAA,GAAML;IAAK,CAAI,CAAC;EAC5C;EAEA,OAAO,IAAAG,MAAA,CAAAC,aAAA,EAACN,iBAAA,CAAAO,OAAgB;IAAA,GAAML;EAAK,CAAI,CAAC;AACzC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEcH,YAAY"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useLatestRef = useLatestRef;
7
- var _element = require("@wordpress/element");
8
- var _compose = require("@wordpress/compose");
9
- /**
10
- * External dependencies
11
- */
12
-
13
- /**
14
- * WordPress dependencies
15
- */
16
-
17
- /**
18
- * Creates a reference for a prop. This is useful for preserving dependency
19
- * memoization for hooks like useCallback.
20
- *
21
- * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx
22
- *
23
- * @param value The value to reference
24
- * @return The prop reference.
25
- */
26
- function useLatestRef(value) {
27
- const ref = (0, _element.useRef)(value);
28
- (0, _compose.useIsomorphicLayoutEffect)(() => {
29
- ref.current = value;
30
- });
31
- return ref;
32
- }
33
- //# sourceMappingURL=use-latest-ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_element","require","_compose","useLatestRef","value","ref","useRef","useIsomorphicLayoutEffect","current"],"sources":["@wordpress/components/src/utils/hooks/use-latest-ref.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Creates a reference for a prop. This is useful for preserving dependency\n * memoization for hooks like useCallback.\n *\n * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx\n *\n * @param value The value to reference\n * @return The prop reference.\n */\nexport function useLatestRef< T >( value: T ): RefObject< T > {\n\tconst ref = useRef( value );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tref.current = value;\n\t} );\n\n\treturn ref;\n}\n"],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAOC,KAAQ,EAAmB;EAC7D,MAAMC,GAAG,GAAG,IAAAC,eAAM,EAAEF,KAAM,CAAC;EAE3B,IAAAG,kCAAyB,EAAE,MAAM;IAChCF,GAAG,CAACG,OAAO,GAAGJ,KAAK;EACpB,CAAE,CAAC;EAEH,OAAOC,GAAG;AACX"}
@@ -1,21 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * Internal dependencies
4
- */
5
- import _LegacyCustomSelect from './legacy-component';
6
- import _NewCustomSelect from './default-component';
7
- function isLegacy(props) {
8
- return typeof props.options !== 'undefined';
9
- }
10
- function CustomSelect(props) {
11
- if (isLegacy(props)) {
12
- return createElement(_LegacyCustomSelect, {
13
- ...props
14
- });
15
- }
16
- return createElement(_NewCustomSelect, {
17
- ...props
18
- });
19
- }
20
- export default CustomSelect;
21
- //# sourceMappingURL=legacy-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_LegacyCustomSelect","_NewCustomSelect","isLegacy","props","options","CustomSelect","createElement"],"sources":["@wordpress/components/src/custom-select-control-v2/legacy-adapter.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport _LegacyCustomSelect from './legacy-component';\nimport _NewCustomSelect from './default-component';\nimport type { CustomSelectProps, LegacyCustomSelectProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nfunction isLegacy( props: any ): props is LegacyCustomSelectProps {\n\treturn typeof props.options !== 'undefined';\n}\n\nfunction CustomSelect(\n\tprops:\n\t\t| LegacyCustomSelectProps\n\t\t| WordPressComponentProps< CustomSelectProps, 'button', false >\n) {\n\tif ( isLegacy( props ) ) {\n\t\treturn <_LegacyCustomSelect { ...props } />;\n\t}\n\n\treturn <_NewCustomSelect { ...props } />;\n}\n\nexport default CustomSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,mBAAmB,MAAM,oBAAoB;AACpD,OAAOC,gBAAgB,MAAM,qBAAqB;AAIlD,SAASC,QAAQA,CAAEC,KAAU,EAAqC;EACjE,OAAO,OAAOA,KAAK,CAACC,OAAO,KAAK,WAAW;AAC5C;AAEA,SAASC,YAAYA,CACpBF,KAEgE,EAC/D;EACD,IAAKD,QAAQ,CAAEC,KAAM,CAAC,EAAG;IACxB,OAAOG,aAAA,CAACN,mBAAmB;MAAA,GAAMG;IAAK,CAAI,CAAC;EAC5C;EAEA,OAAOG,aAAA,CAACL,gBAAgB;IAAA,GAAME;EAAK,CAAI,CAAC;AACzC;AAEA,eAAeE,YAAY"}
@@ -1,27 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- /**
6
- * WordPress dependencies
7
- */
8
- import { useRef } from '@wordpress/element';
9
- import { useIsomorphicLayoutEffect } from '@wordpress/compose';
10
-
11
- /**
12
- * Creates a reference for a prop. This is useful for preserving dependency
13
- * memoization for hooks like useCallback.
14
- *
15
- * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx
16
- *
17
- * @param value The value to reference
18
- * @return The prop reference.
19
- */
20
- export function useLatestRef(value) {
21
- const ref = useRef(value);
22
- useIsomorphicLayoutEffect(() => {
23
- ref.current = value;
24
- });
25
- return ref;
26
- }
27
- //# sourceMappingURL=use-latest-ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useRef","useIsomorphicLayoutEffect","useLatestRef","value","ref","current"],"sources":["@wordpress/components/src/utils/hooks/use-latest-ref.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Creates a reference for a prop. This is useful for preserving dependency\n * memoization for hooks like useCallback.\n *\n * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx\n *\n * @param value The value to reference\n * @return The prop reference.\n */\nexport function useLatestRef< T >( value: T ): RefObject< T > {\n\tconst ref = useRef( value );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tref.current = value;\n\t} );\n\n\treturn ref;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,yBAAyB,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAOC,KAAQ,EAAmB;EAC7D,MAAMC,GAAG,GAAGJ,MAAM,CAAEG,KAAM,CAAC;EAE3BF,yBAAyB,CAAE,MAAM;IAChCG,GAAG,CAACC,OAAO,GAAGF,KAAK;EACpB,CAAE,CAAC;EAEH,OAAOC,GAAG;AACX"}
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import type { CustomSelectProps, LegacyCustomSelectProps } from './types';
3
- import type { WordPressComponentProps } from '../context';
4
- declare function CustomSelect(props: LegacyCustomSelectProps | WordPressComponentProps<CustomSelectProps, 'button', false>): JSX.Element;
5
- export default CustomSelect;
6
- //# sourceMappingURL=legacy-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy-adapter.d.ts","sourceRoot":"","sources":["../../src/custom-select-control-v2/legacy-adapter.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAM1D,iBAAS,YAAY,CACpB,KAAK,EACF,uBAAuB,GACvB,uBAAuB,CAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,CAAE,eAOhE;AAED,eAAe,YAAY,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { RefObject } from 'react';
5
- /**
6
- * Creates a reference for a prop. This is useful for preserving dependency
7
- * memoization for hooks like useCallback.
8
- *
9
- * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx
10
- *
11
- * @param value The value to reference
12
- * @return The prop reference.
13
- */
14
- export declare function useLatestRef<T>(value: T): RefObject<T>;
15
- //# sourceMappingURL=use-latest-ref.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-latest-ref.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/use-latest-ref.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAE,CAAC,EAAI,KAAK,EAAE,CAAC,GAAI,SAAS,CAAE,CAAC,CAAE,CAQ5D"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import _LegacyCustomSelect from './legacy-component';
5
- import _NewCustomSelect from './default-component';
6
- import type { CustomSelectProps, LegacyCustomSelectProps } from './types';
7
- import type { WordPressComponentProps } from '../context';
8
-
9
- function isLegacy( props: any ): props is LegacyCustomSelectProps {
10
- return typeof props.options !== 'undefined';
11
- }
12
-
13
- function CustomSelect(
14
- props:
15
- | LegacyCustomSelectProps
16
- | WordPressComponentProps< CustomSelectProps, 'button', false >
17
- ) {
18
- if ( isLegacy( props ) ) {
19
- return <_LegacyCustomSelect { ...props } />;
20
- }
21
-
22
- return <_NewCustomSelect { ...props } />;
23
- }
24
-
25
- export default CustomSelect;
@@ -1,119 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useState } from '@wordpress/element';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { useLatestRef } from '..';
15
-
16
- function debounce( callback, timeout = 0 ) {
17
- let timeoutId = 0;
18
- return ( ...args ) => {
19
- window.clearTimeout( timeoutId );
20
- timeoutId = window.setTimeout( () => callback( ...args ), timeout );
21
- };
22
- }
23
-
24
- function useDebounce( callback, timeout = 0 ) {
25
- const callbackRef = useLatestRef( callback );
26
- return debounce( ( ...args ) => callbackRef.current( ...args ), timeout );
27
- }
28
-
29
- function Example() {
30
- const [ count, setCount ] = useState( 0 );
31
- const increment = () => setCount( count + 1 );
32
- const incrementDebounced = debounce( increment, 50 );
33
- const incrementDebouncedWithLatestRef = useDebounce( increment, 50 );
34
-
35
- return (
36
- <>
37
- <div>Count: { count }</div>
38
- <button onClick={ incrementDebounced }>Increment debounced</button>
39
- <button onClick={ increment }>Increment immediately</button>
40
- <br />
41
- <button onClick={ incrementDebouncedWithLatestRef }>
42
- Increment debounced with latest ref
43
- </button>
44
- </>
45
- );
46
- }
47
-
48
- function getCount() {
49
- return screen.getByText( /Count:/ ).innerHTML;
50
- }
51
-
52
- function incrementCount() {
53
- fireEvent.click( screen.getByText( 'Increment immediately' ) );
54
- }
55
-
56
- function incrementCountDebounced() {
57
- fireEvent.click( screen.getByText( 'Increment debounced' ) );
58
- }
59
-
60
- function incrementCountDebouncedRef() {
61
- fireEvent.click(
62
- screen.getByText( 'Increment debounced with latest ref' )
63
- );
64
- }
65
-
66
- describe( 'useLatestRef', () => {
67
- describe( 'Example', () => {
68
- // Prove the example works as expected.
69
- it( 'should start at 0', () => {
70
- render( <Example /> );
71
-
72
- expect( getCount() ).toEqual( 'Count: 0' );
73
- } );
74
-
75
- it( 'should increment immediately', () => {
76
- render( <Example /> );
77
-
78
- incrementCount();
79
-
80
- expect( getCount() ).toEqual( 'Count: 1' );
81
- } );
82
-
83
- it( 'should increment after debouncing', async () => {
84
- render( <Example /> );
85
-
86
- incrementCountDebounced();
87
-
88
- expect( getCount() ).toEqual( 'Count: 0' );
89
- await waitFor( () => expect( getCount() ).toEqual( 'Count: 1' ) );
90
- } );
91
-
92
- it( 'should increment after debouncing with latest ref', async () => {
93
- render( <Example /> );
94
-
95
- incrementCountDebouncedRef();
96
-
97
- expect( getCount() ).toEqual( 'Count: 0' );
98
- await waitFor( () => expect( getCount() ).toEqual( 'Count: 1' ) );
99
- } );
100
- } );
101
-
102
- it( 'should increment to one', async () => {
103
- render( <Example /> );
104
-
105
- incrementCountDebounced();
106
- incrementCount();
107
-
108
- await waitFor( () => expect( getCount() ).toEqual( 'Count: 1' ) );
109
- } );
110
-
111
- it( 'should increment to two', async () => {
112
- render( <Example /> );
113
-
114
- incrementCountDebouncedRef();
115
- incrementCount();
116
-
117
- await waitFor( () => expect( getCount() ).toEqual( 'Count: 2' ) );
118
- } );
119
- } );
@@ -1,29 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { RefObject } from 'react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useRef } from '@wordpress/element';
10
- import { useIsomorphicLayoutEffect } from '@wordpress/compose';
11
-
12
- /**
13
- * Creates a reference for a prop. This is useful for preserving dependency
14
- * memoization for hooks like useCallback.
15
- *
16
- * @see https://codesandbox.io/s/uselatestref-mlj3i?file=/src/App.tsx
17
- *
18
- * @param value The value to reference
19
- * @return The prop reference.
20
- */
21
- export function useLatestRef< T >( value: T ): RefObject< T > {
22
- const ref = useRef( value );
23
-
24
- useIsomorphicLayoutEffect( () => {
25
- ref.current = value;
26
- } );
27
-
28
- return ref;
29
- }