@wordpress/components 28.1.0 → 28.2.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 (58) hide show
  1. package/CHANGELOG.md +131 -120
  2. package/build/custom-select-control-v2/custom-select.js +1 -3
  3. package/build/custom-select-control-v2/custom-select.js.map +1 -1
  4. package/build/custom-select-control-v2/legacy-component/index.js +16 -10
  5. package/build/custom-select-control-v2/legacy-component/index.js.map +1 -1
  6. package/build/custom-select-control-v2/styles.js +34 -19
  7. package/build/custom-select-control-v2/styles.js.map +1 -1
  8. package/build/custom-select-control-v2/types.js.map +1 -1
  9. package/build/drop-zone/index.js +16 -79
  10. package/build/drop-zone/index.js.map +1 -1
  11. package/build/lock-unlock.js +1 -1
  12. package/build/lock-unlock.js.map +1 -1
  13. package/build/palette-edit/index.js +30 -38
  14. package/build/palette-edit/index.js.map +1 -1
  15. package/build/palette-edit/types.js.map +1 -1
  16. package/build-module/custom-select-control-v2/custom-select.js +1 -3
  17. package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
  18. package/build-module/custom-select-control-v2/legacy-component/index.js +16 -11
  19. package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -1
  20. package/build-module/custom-select-control-v2/styles.js +33 -18
  21. package/build-module/custom-select-control-v2/styles.js.map +1 -1
  22. package/build-module/custom-select-control-v2/types.js.map +1 -1
  23. package/build-module/drop-zone/index.js +17 -80
  24. package/build-module/drop-zone/index.js.map +1 -1
  25. package/build-module/lock-unlock.js +1 -1
  26. package/build-module/lock-unlock.js.map +1 -1
  27. package/build-module/palette-edit/index.js +31 -39
  28. package/build-module/palette-edit/index.js.map +1 -1
  29. package/build-module/palette-edit/types.js.map +1 -1
  30. package/build-style/style-rtl.css +28 -6
  31. package/build-style/style.css +28 -6
  32. package/build-types/custom-select-control/stories/index.story.d.ts +15 -0
  33. package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
  34. package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -1
  35. package/build-types/custom-select-control-v2/styles.d.ts +4 -0
  36. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  37. package/build-types/custom-select-control-v2/types.d.ts +1 -0
  38. package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
  39. package/build-types/drop-zone/index.d.ts +3 -0
  40. package/build-types/drop-zone/index.d.ts.map +1 -1
  41. package/build-types/palette-edit/index.d.ts.map +1 -1
  42. package/build-types/palette-edit/types.d.ts +1 -3
  43. package/build-types/palette-edit/types.d.ts.map +1 -1
  44. package/package.json +19 -19
  45. package/src/custom-select-control/stories/index.story.tsx +32 -3
  46. package/src/custom-select-control/test/index.js +205 -22
  47. package/src/custom-select-control-v2/custom-select.tsx +1 -1
  48. package/src/custom-select-control-v2/legacy-component/index.tsx +18 -10
  49. package/src/custom-select-control-v2/legacy-component/test/index.tsx +220 -38
  50. package/src/custom-select-control-v2/styles.ts +22 -10
  51. package/src/custom-select-control-v2/types.ts +1 -0
  52. package/src/drop-zone/index.tsx +17 -76
  53. package/src/drop-zone/style.scss +51 -16
  54. package/src/lock-unlock.js +1 -1
  55. package/src/palette-edit/index.tsx +33 -45
  56. package/src/palette-edit/test/index.tsx +2 -4
  57. package/src/palette-edit/types.ts +1 -3
  58. package/tsconfig.tsbuildinfo +1 -1
@@ -530,8 +530,7 @@ p + .components-button.is-tertiary {
530
530
  vertical-align: top;
531
531
  width: var(--checkbox-input-size);
532
532
  height: var(--checkbox-input-size);
533
- -webkit-appearance: none;
534
- appearance: none;
533
+ appearance: none;
535
534
  transition: 0.1s border-color ease-in-out;
536
535
  }
537
536
  @media (prefers-reduced-motion: reduce) {
@@ -1179,8 +1178,7 @@ body.is-dragging-components-draggable {
1179
1178
  opacity: 1;
1180
1179
  visibility: visible;
1181
1180
  }
1182
-
1183
- .components-drop-zone__content {
1181
+ .components-drop-zone .components-drop-zone__content {
1184
1182
  position: absolute;
1185
1183
  top: 0;
1186
1184
  bottom: 0;
@@ -1195,6 +1193,31 @@ body.is-dragging-components-draggable {
1195
1193
  z-index: 50;
1196
1194
  text-align: center;
1197
1195
  color: #fff;
1196
+ opacity: 0;
1197
+ pointer-events: none;
1198
+ }
1199
+ .components-drop-zone .components-drop-zone__content-inner {
1200
+ opacity: 0;
1201
+ transform: scale(0.9);
1202
+ }
1203
+ .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1204
+ opacity: 1;
1205
+ transition: opacity 0.2s ease-in-out;
1206
+ }
1207
+ @media (prefers-reduced-motion) {
1208
+ .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1209
+ transition: none;
1210
+ }
1211
+ }
1212
+ .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1213
+ opacity: 1;
1214
+ transform: scale(1);
1215
+ transition: opacity 0.1s ease-in-out 0.1s, transform 0.1s ease-in-out 0.1s;
1216
+ }
1217
+ @media (prefers-reduced-motion) {
1218
+ .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1219
+ transition: none;
1220
+ }
1198
1221
  }
1199
1222
 
1200
1223
  .components-drop-zone__content-icon,
@@ -2656,8 +2679,7 @@ body.rtl .components-panel__body-toggle.components-button .dashicons-arrow-right
2656
2679
  display: inline-flex;
2657
2680
  margin: 0 8px 0 0;
2658
2681
  padding: 0;
2659
- -webkit-appearance: none;
2660
- appearance: none;
2682
+ appearance: none;
2661
2683
  cursor: pointer;
2662
2684
  }
2663
2685
  @media (prefers-reduced-motion: reduce) {
@@ -26,6 +26,21 @@ declare const _default: {
26
26
  type: string;
27
27
  };
28
28
  };
29
+ onChange: {
30
+ control: {
31
+ type: null;
32
+ };
33
+ };
34
+ value: {
35
+ control: {
36
+ type: null;
37
+ };
38
+ };
39
+ };
40
+ parameters: {
41
+ actions: {
42
+ argTypesRegex: string;
43
+ };
29
44
  };
30
45
  };
31
46
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/custom-select-control/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,OAAO,mBAAmB,MAAM,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAErC,wBAaE;AAEF,eAAO,MAAM,OAAO,EAAE,OAAwC,CAAC;AA4B/D,eAAO,MAAM,cAAc,EAAE,OAAwC,CAAC;AAmBtE,eAAO,MAAM,SAAS,EAAE,OAAwC,CAAC"}
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/custom-select-control/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOhD;;GAEG;AACH,OAAO,mBAAmB,MAAM,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErC,wBAkBE;AAqBF,eAAO,MAAM,OAAO,EAAE,OAA6B,CAAC;AA4BpD,eAAO,MAAM,cAAc,EAAE,OAA6B,CAAC;AAmB3D,eAAO,MAAM,SAAS,EAAE,OAA6B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom-select-control-v2/legacy-component/index.tsx"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,iBAAS,mBAAmB,CAAE,KAAK,EAAE,uBAAuB,+BA2G3D;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom-select-control-v2/legacy-component/index.tsx"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,iBAAS,mBAAmB,CAAE,KAAK,EAAE,uBAAuB,+BAmH3D;AAED,eAAe,mBAAmB,CAAC"}
@@ -8,6 +8,10 @@ export declare const WithHintWrapper: import("@emotion/styled").StyledComponent<
8
8
  theme?: import("@emotion/react").Theme | undefined;
9
9
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
10
10
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
11
+ export declare const SelectedExperimentalHintWrapper: import("@emotion/styled").StyledComponent<{
12
+ theme?: import("@emotion/react").Theme | undefined;
13
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
14
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
11
15
  export declare const SelectedExperimentalHintItem: import("@emotion/styled").StyledComponent<{
12
16
  theme?: import("@emotion/react").Theme | undefined;
13
17
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/custom-select-control-v2/styles.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAQ1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAItD,eAAO,MAAM,eAAe;;;yGAI3B,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;2GAGxC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;2GAIhC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;UAMvB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;UAOZ,YAAa,sBAAsB,CAAE,MAAM,CAAE,CAAE;yBAChC,OAAO;UA2C1B,CAAC;AAEJ,eAAO,MAAM,aAAa;;;;;;;;;UAQzB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;UAUtB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;UAK7B,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/custom-select-control-v2/styles.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAS1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAUtD,eAAO,MAAM,eAAe;;;yGAI3B,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;yGAE3C,CAAC;AAEF,eAAO,MAAM,4BAA4B;;;2GAGxC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;2GAIhC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;UAMvB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;UAOZ,YAAa,sBAAsB,CAAE,MAAM,CAAE,CAAE;yBAChC,OAAO;UA4C1B,CAAC;AAEJ,eAAO,MAAM,aAAa;;;;;;;;;UAQzB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;UAUtB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;UAK7B,CAAC"}
@@ -64,6 +64,7 @@ type LegacyOption = {
64
64
  style?: React.CSSProperties;
65
65
  className?: string;
66
66
  __experimentalHint?: string;
67
+ [key: string]: any;
67
68
  };
68
69
  /**
69
70
  * The legacy object returned from the onChange event.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/custom-select-control-v2/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAEhE,KAAK,gBAAgB,CAAE,IAAI,GAAG,SAAS,GAAG,SAAS,IAAK;IACvD;;;;OAIG;IACH,I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AG,OAAO,GAAG,kBAAkB,CAAC;IAChD;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;;OAIG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -1,4 +1,7 @@
1
1
  /// <reference types="react" />
2
+ /**
3
+ * Internal dependencies
4
+ */
2
5
  import type { DropZoneProps } from './types';
3
6
  import type { WordPressComponentProps } from '../context';
4
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drop-zone/index.tsx"],"names":[],"mappings":";AAwBA,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAmE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAE,EAClC,SAAS,EACT,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,GAAG,SAAS,EACZ,EAAE,uBAAuB,CAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAE,+BA6ExD;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drop-zone/index.tsx"],"names":[],"mappings":";AAcA;;GAEG;AACH,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAE,EAClC,SAAS,EACT,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,GAAG,SAAS,EACZ,EAAE,uBAAuB,CAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAE,+BA0FxD;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette-edit/index.tsx"],"names":[],"mappings":";AAmDA,OAAO,KAAK,EAOX,gBAAgB,EAChB,cAAc,EACd,MAAM,SAAS,CAAC;AAejB;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,cAAc,EAAE,EAC1B,UAAU,EAAE,MAAM;;;EAwBlB;AAwOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAE,EAC5B,SAAS,EACT,MAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,wBAA4B,EAC5B,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,UAAe,EACf,YAAY,GACZ,EAAE,gBAAgB,+BA4OlB;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette-edit/index.tsx"],"names":[],"mappings":";AAgDA,OAAO,KAAK,EAOX,gBAAgB,EAChB,cAAc,EACd,MAAM,SAAS,CAAC;AAejB;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,cAAc,EAAE,EAC1B,UAAU,EAAE,MAAM;;;EAwBlB;AA6ND;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAE,EAC5B,SAAS,EACT,MAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,wBAA4B,EAC5B,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,UAAe,EACf,YAAY,GACZ,EAAE,gBAAgB,+BA8OlB;AAED,eAAe,WAAW,CAAC"}
@@ -100,11 +100,8 @@ export type OptionProps<T extends Color | Gradient> = {
100
100
  onChange: (newElement: T) => void;
101
101
  isGradient: T extends Gradient ? true : false;
102
102
  canOnlyChangeValues: PaletteEditProps['canOnlyChangeValues'];
103
- isEditing: boolean;
104
103
  key: Key;
105
104
  onRemove: MouseEventHandler<HTMLButtonElement>;
106
- onStartEditing: () => void;
107
- onStopEditing: () => void;
108
105
  popoverProps?: PaletteEditProps['popoverProps'];
109
106
  slugPrefix: string;
110
107
  };
@@ -113,6 +110,7 @@ export type PaletteEditListViewProps<T extends Color | Gradient> = {
113
110
  onChange: (newElements?: T[]) => void;
114
111
  isGradient: T extends Gradient ? true : false;
115
112
  canOnlyChangeValues: PaletteEditProps['canOnlyChangeValues'];
113
+ addColorRef: React.RefObject<HTMLButtonElement>;
116
114
  editingElement?: EditingElement;
117
115
  popoverProps?: PaletteEditProps['popoverProps'];
118
116
  setEditingElement: (newEditingElement?: EditingElement) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/palette-edit/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEpD;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,M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AC;AAEF,MAAM,MAAM,WAAW,CAAE,CAAC,SAAS,KAAK,GAAG,QAAQ,IAAK;IACvD,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,CAAE,UAAU,EAAE,CAAC,KAAM,IAAI,CAAC;IACpC,UAAU,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,CAAC;IAC9C,mBAAmB,EAAE,gBAAgB,CAAE,qBAAqB,CAAE,CAAC;IAC/D,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,iBAAiB,CAAE,iBAAiB,CAAE,CAAC;IACjD,YAAY,CAAC,EAAE,gBAAgB,CAAE,cAAc,CAAE,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAE,CAAC,SAAS,KAAK,GAAG,QAAQ,IAAK;IACpE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,QAAQ,EAAE,CAAE,WAAW,CAAC,EAAE,CAAC,EAAE,KAAM,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,CAAC;IAC9C,mBAAmB,EAAE,gBAAgB,CAAE,qBAAqB,CAAE,CAAC;IAC/D,WAAW,EAAE,KAAK,CAAC,SAAS,CAAE,iBAAiB,CAAE,CAAC;IAClD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,gBAAgB,CAAE,cAAc,CAAE,CAAC;IAClD,iBAAiB,EAAE,CAAE,iBAAiB,CAAC,EAAE,cAAc,KAAM,IAAI,CAAC;IAClE,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "28.1.0",
3
+ "version": "28.2.0",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,23 +43,23 @@
43
43
  "@types/gradient-parser": "0.1.3",
44
44
  "@types/highlight-words-core": "1.2.1",
45
45
  "@use-gesture/react": "^10.3.1",
46
- "@wordpress/a11y": "^4.1.0",
47
- "@wordpress/compose": "^7.1.0",
48
- "@wordpress/date": "^5.1.0",
49
- "@wordpress/deprecated": "^4.1.0",
50
- "@wordpress/dom": "^4.1.0",
51
- "@wordpress/element": "^6.1.0",
52
- "@wordpress/escape-html": "^3.1.0",
53
- "@wordpress/hooks": "^4.1.0",
54
- "@wordpress/html-entities": "^4.1.0",
55
- "@wordpress/i18n": "^5.1.0",
56
- "@wordpress/icons": "^10.1.0",
57
- "@wordpress/is-shallow-equal": "^5.1.0",
58
- "@wordpress/keycodes": "^4.1.0",
59
- "@wordpress/primitives": "^4.1.0",
60
- "@wordpress/private-apis": "^1.1.0",
61
- "@wordpress/rich-text": "^7.1.0",
62
- "@wordpress/warning": "^3.1.0",
46
+ "@wordpress/a11y": "^4.2.0",
47
+ "@wordpress/compose": "^7.2.0",
48
+ "@wordpress/date": "^5.2.0",
49
+ "@wordpress/deprecated": "^4.2.0",
50
+ "@wordpress/dom": "^4.2.0",
51
+ "@wordpress/element": "^6.2.0",
52
+ "@wordpress/escape-html": "^3.2.0",
53
+ "@wordpress/hooks": "^4.2.0",
54
+ "@wordpress/html-entities": "^4.2.0",
55
+ "@wordpress/i18n": "^5.2.0",
56
+ "@wordpress/icons": "^10.2.0",
57
+ "@wordpress/is-shallow-equal": "^5.2.0",
58
+ "@wordpress/keycodes": "^4.2.0",
59
+ "@wordpress/primitives": "^4.2.0",
60
+ "@wordpress/private-apis": "^1.2.0",
61
+ "@wordpress/rich-text": "^7.2.0",
62
+ "@wordpress/warning": "^3.2.0",
63
63
  "change-case": "^4.1.2",
64
64
  "clsx": "^2.1.1",
65
65
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "66d3bf12e67d16deddc4b4a9ec42e1d0bed3479a"
89
+ "gitHead": "aa5b14bb5bdbb8d8a02914e154c3bc1c2f18ace6"
90
90
  }
@@ -3,6 +3,11 @@
3
3
  */
4
4
  import type { StoryFn } from '@storybook/react';
5
5
 
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useState } from '@wordpress/element';
10
+
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
@@ -20,10 +25,34 @@ export default {
20
25
  type: 'radio',
21
26
  },
22
27
  },
28
+ onChange: { control: { type: null } },
29
+ value: { control: { type: null } },
30
+ },
31
+ parameters: {
32
+ actions: { argTypesRegex: '^on.*' },
23
33
  },
24
34
  };
25
35
 
26
- export const Default: StoryFn = CustomSelectControl.bind( {} );
36
+ const Template: StoryFn< typeof CustomSelectControl > = ( props ) => {
37
+ const [ value, setValue ] = useState( props.options[ 0 ] );
38
+
39
+ const onChange: React.ComponentProps<
40
+ typeof CustomSelectControl
41
+ >[ 'onChange' ] = ( changeObject: { selectedItem: any } ) => {
42
+ setValue( changeObject.selectedItem );
43
+ props.onChange?.( changeObject );
44
+ };
45
+
46
+ return (
47
+ <CustomSelectControl
48
+ { ...props }
49
+ onChange={ onChange }
50
+ value={ value }
51
+ />
52
+ );
53
+ };
54
+
55
+ export const Default: StoryFn = Template.bind( {} );
27
56
  Default.args = {
28
57
  label: 'Label',
29
58
  options: [
@@ -51,7 +80,7 @@ Default.args = {
51
80
  ],
52
81
  };
53
82
 
54
- export const WithLongLabels: StoryFn = CustomSelectControl.bind( {} );
83
+ export const WithLongLabels: StoryFn = Template.bind( {} );
55
84
  WithLongLabels.args = {
56
85
  ...Default.args,
57
86
  options: [
@@ -70,7 +99,7 @@ WithLongLabels.args = {
70
99
  ],
71
100
  };
72
101
 
73
- export const WithHints: StoryFn = CustomSelectControl.bind( {} );
102
+ export const WithHints: StoryFn = Template.bind( {} );
74
103
  WithHints.args = {
75
104
  ...Default.args,
76
105
  options: [
@@ -14,7 +14,11 @@ import { useState } from '@wordpress/element';
14
14
  */
15
15
  import UncontrolledCustomSelectControl from '..';
16
16
 
17
- const customClass = 'amber-skies';
17
+ const customClassName = 'amber-skies';
18
+ const customStyles = {
19
+ backgroundColor: 'rgb(127, 255, 212)',
20
+ rotate: '13deg',
21
+ };
18
22
 
19
23
  const props = {
20
24
  label: 'label!',
@@ -26,7 +30,7 @@ const props = {
26
30
  {
27
31
  key: 'flower2',
28
32
  name: 'crimson clover',
29
- className: customClass,
33
+ className: customClassName,
30
34
  },
31
35
  {
32
36
  key: 'flower3',
@@ -35,37 +39,114 @@ const props = {
35
39
  {
36
40
  key: 'color1',
37
41
  name: 'amber',
38
- className: customClass,
42
+ className: customClassName,
39
43
  },
40
44
  {
41
45
  key: 'color2',
42
46
  name: 'aquamarine',
43
- style: {
44
- backgroundColor: 'rgb(127, 255, 212)',
45
- rotate: '13deg',
46
- },
47
+ style: customStyles,
48
+ },
49
+ {
50
+ key: 'color3',
51
+ name: 'tomato (with custom props)',
52
+ className: customClassName,
53
+ style: customStyles,
54
+ // try passing a valid HTML attribute
55
+ 'aria-label': 'test label',
56
+ // try adding a custom prop
57
+ customPropFoo: 'foo',
47
58
  },
48
59
  ],
49
60
  };
50
61
 
51
- const ControlledCustomSelectControl = ( { options, ...restProps } ) => {
52
- const [ value, setValue ] = useState( options[ 0 ] );
62
+ const ControlledCustomSelectControl = ( {
63
+ options,
64
+ onChange: onChangeProp,
65
+ ...restProps
66
+ } ) => {
67
+ const [ value, setValue ] = useState( restProps.value ?? options[ 0 ] );
68
+
69
+ const onChange = ( changeObject ) => {
70
+ onChangeProp?.( changeObject );
71
+ setValue( changeObject.selectedItem );
72
+ };
73
+
53
74
  return (
54
75
  <UncontrolledCustomSelectControl
55
76
  { ...restProps }
56
77
  options={ options }
57
- onChange={ ( { selectedItem } ) => setValue( selectedItem ) }
78
+ onChange={ onChange }
58
79
  value={ options.find( ( option ) => option.key === value.key ) }
59
80
  />
60
81
  );
61
82
  };
62
83
 
84
+ it( 'Should apply external controlled updates', async () => {
85
+ const mockOnChange = jest.fn();
86
+ const { rerender } = render(
87
+ <UncontrolledCustomSelectControl
88
+ { ...props }
89
+ value={ props.options[ 0 ] }
90
+ onChange={ mockOnChange }
91
+ />
92
+ );
93
+
94
+ const currentSelectedItem = screen.getByRole( 'button', {
95
+ expanded: false,
96
+ } );
97
+
98
+ expect( currentSelectedItem ).toHaveTextContent( props.options[ 0 ].name );
99
+
100
+ rerender(
101
+ <UncontrolledCustomSelectControl
102
+ { ...props }
103
+ value={ props.options[ 1 ] }
104
+ />
105
+ );
106
+
107
+ expect( currentSelectedItem ).toHaveTextContent( props.options[ 1 ].name );
108
+
109
+ expect( mockOnChange ).not.toHaveBeenCalled();
110
+ } );
111
+
63
112
  describe.each( [
64
- [ 'uncontrolled', UncontrolledCustomSelectControl ],
65
- [ 'controlled', ControlledCustomSelectControl ],
113
+ [ 'Uncontrolled', UncontrolledCustomSelectControl ],
114
+ [ 'Controlled', ControlledCustomSelectControl ],
66
115
  ] )( 'CustomSelectControl %s', ( ...modeAndComponent ) => {
67
116
  const [ , Component ] = modeAndComponent;
68
117
 
118
+ it( 'Should select the first option when no explicit initial value is passed without firing onChange', () => {
119
+ const mockOnChange = jest.fn();
120
+ render( <Component { ...props } onChange={ mockOnChange } /> );
121
+
122
+ expect(
123
+ screen.getByRole( 'button', {
124
+ expanded: false,
125
+ } )
126
+ ).toHaveTextContent( props.options[ 0 ].name );
127
+
128
+ expect( mockOnChange ).not.toHaveBeenCalled();
129
+ } );
130
+
131
+ it( 'Should pick the initially selected option if the value prop is passed without firing onChange', async () => {
132
+ const mockOnChange = jest.fn();
133
+ render(
134
+ <Component
135
+ { ...props }
136
+ onChange={ mockOnChange }
137
+ value={ props.options[ 3 ] }
138
+ />
139
+ );
140
+
141
+ expect(
142
+ screen.getByRole( 'button', {
143
+ expanded: false,
144
+ } )
145
+ ).toHaveTextContent( props.options[ 3 ].name );
146
+
147
+ expect( mockOnChange ).not.toHaveBeenCalled();
148
+ } );
149
+
69
150
  it( 'Should replace the initial selection when a new item is selected', async () => {
70
151
  const user = userEvent.setup();
71
152
 
@@ -144,7 +225,7 @@ describe.each( [
144
225
  // assert against filtered array
145
226
  itemsWithClass.map( ( { name } ) =>
146
227
  expect( screen.getByRole( 'option', { name } ) ).toHaveClass(
147
- customClass
228
+ customClassName
148
229
  )
149
230
  );
150
231
 
@@ -156,15 +237,13 @@ describe.each( [
156
237
  // assert against filtered array
157
238
  itemsWithoutClass.map( ( { name } ) =>
158
239
  expect( screen.getByRole( 'option', { name } ) ).not.toHaveClass(
159
- customClass
240
+ customClassName
160
241
  )
161
242
  );
162
243
  } );
163
244
 
164
245
  it( 'Should apply styles only to options that have styles defined', async () => {
165
246
  const user = userEvent.setup();
166
- const customStyles =
167
- 'background-color: rgb(127, 255, 212); rotate: 13deg;';
168
247
 
169
248
  render( <Component { ...props } /> );
170
249
 
@@ -262,6 +341,105 @@ describe.each( [
262
341
  expect( screen.getByRole( 'option', { name: /hint/i } ) ).toBeVisible();
263
342
  } );
264
343
 
344
+ it( 'Should return object onChange', async () => {
345
+ const user = userEvent.setup();
346
+ const mockOnChange = jest.fn();
347
+
348
+ render( <Component { ...props } onChange={ mockOnChange } /> );
349
+
350
+ await user.click(
351
+ screen.getByRole( 'button', {
352
+ expanded: false,
353
+ } )
354
+ );
355
+
356
+ await user.click(
357
+ screen.getByRole( 'option', {
358
+ name: 'aquamarine',
359
+ } )
360
+ );
361
+
362
+ expect( mockOnChange ).toHaveBeenCalledTimes( 1 );
363
+ expect( mockOnChange ).toHaveBeenLastCalledWith(
364
+ expect.objectContaining( {
365
+ inputValue: '',
366
+ isOpen: false,
367
+ selectedItem: expect.objectContaining( {
368
+ name: 'aquamarine',
369
+ } ),
370
+ type: expect.any( String ),
371
+ } )
372
+ );
373
+ } );
374
+
375
+ it( 'Should return selectedItem object when specified onChange', async () => {
376
+ const user = userEvent.setup();
377
+ const mockOnChange = jest.fn();
378
+
379
+ render( <Component { ...props } onChange={ mockOnChange } /> );
380
+
381
+ await user.tab();
382
+ expect(
383
+ screen.getByRole( 'button', {
384
+ expanded: false,
385
+ } )
386
+ ).toHaveFocus();
387
+
388
+ await user.keyboard( 'p' );
389
+ await user.keyboard( '{enter}' );
390
+
391
+ expect( mockOnChange ).toHaveBeenCalledTimes( 1 );
392
+ expect( mockOnChange ).toHaveBeenLastCalledWith(
393
+ expect.objectContaining( {
394
+ selectedItem: expect.objectContaining( {
395
+ key: 'flower3',
396
+ name: 'poppy',
397
+ } ),
398
+ } )
399
+ );
400
+ } );
401
+
402
+ it( "Should pass arbitrary props to onChange's selectedItem, but apply only style and className to DOM elements", async () => {
403
+ const user = userEvent.setup();
404
+ const onChangeMock = jest.fn();
405
+
406
+ render( <Component { ...props } onChange={ onChangeMock } /> );
407
+
408
+ const currentSelectedItem = screen.getByRole( 'button', {
409
+ expanded: false,
410
+ } );
411
+
412
+ await user.click( currentSelectedItem );
413
+
414
+ const optionWithCustomAttributes = screen.getByRole( 'option', {
415
+ name: 'tomato (with custom props)',
416
+ } );
417
+
418
+ // Assert that the option element does not have the custom attributes
419
+ expect( optionWithCustomAttributes ).not.toHaveAttribute(
420
+ 'customPropFoo'
421
+ );
422
+ expect( optionWithCustomAttributes ).not.toHaveAttribute(
423
+ 'aria-label'
424
+ );
425
+
426
+ await user.click( optionWithCustomAttributes );
427
+
428
+ expect( onChangeMock ).toHaveBeenCalledTimes( 1 );
429
+ expect( onChangeMock ).toHaveBeenCalledWith(
430
+ expect.objectContaining( {
431
+ selectedItem: expect.objectContaining( {
432
+ key: 'color3',
433
+ name: 'tomato (with custom props)',
434
+ className: customClassName,
435
+ style: customStyles,
436
+ 'aria-label': 'test label',
437
+ customPropFoo: 'foo',
438
+ } ),
439
+ } )
440
+ );
441
+ } );
442
+
265
443
  describe( 'Keyboard behavior and accessibility', () => {
266
444
  it( 'Captures the keypress event and does not let it propagate', async () => {
267
445
  const user = userEvent.setup();
@@ -311,7 +489,9 @@ describe.each( [
311
489
  await user.keyboard( '{arrowdown}' );
312
490
  await user.keyboard( '{enter}' );
313
491
 
314
- expect( currentSelectedItem ).toHaveTextContent( 'crimson clover' );
492
+ expect( currentSelectedItem ).toHaveTextContent(
493
+ props.options[ 1 ].name
494
+ );
315
495
  } );
316
496
 
317
497
  it( 'Should be able to type characters to select matching options', async () => {
@@ -422,11 +602,14 @@ describe.each( [
422
602
  const onBlurMock = jest.fn();
423
603
 
424
604
  render(
425
- <Component
426
- { ...props }
427
- onFocus={ onFocusMock }
428
- onBlur={ onBlurMock }
429
- />
605
+ <>
606
+ <Component
607
+ { ...props }
608
+ onFocus={ onFocusMock }
609
+ onBlur={ onBlurMock }
610
+ />
611
+ <button>Focus stop</button>
612
+ </>
430
613
  );
431
614
 
432
615
  const currentSelectedItem = screen.getByRole( 'button', {
@@ -74,7 +74,7 @@ const CustomSelectButton = ( {
74
74
  // move selection rather than open the popover
75
75
  showOnKeyDown={ false }
76
76
  >
77
- <div>{ computedRenderSelectedValue( currentValue ) }</div>
77
+ { computedRenderSelectedValue( currentValue ) }
78
78
  </Styled.Select>
79
79
  );
80
80
  };