@wordpress/components 29.11.0 → 29.13.1-next.719a03cbe.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 (169) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/build/box-control/input-control.js +2 -2
  3. package/build/box-control/input-control.js.map +1 -1
  4. package/build/calendar/date-calendar/index.js +60 -0
  5. package/build/calendar/date-calendar/index.js.map +1 -0
  6. package/build/calendar/date-range-calendar/index.js +168 -0
  7. package/build/calendar/date-range-calendar/index.js.map +1 -0
  8. package/build/calendar/index.js +27 -0
  9. package/build/calendar/index.js.map +1 -0
  10. package/build/calendar/types.js +6 -0
  11. package/build/calendar/types.js.map +1 -0
  12. package/build/calendar/utils/constants.js +68 -0
  13. package/build/calendar/utils/constants.js.map +1 -0
  14. package/build/calendar/utils/day-cell.js +137 -0
  15. package/build/calendar/utils/day-cell.js.map +1 -0
  16. package/build/calendar/utils/misc.js +10 -0
  17. package/build/calendar/utils/misc.js.map +1 -0
  18. package/build/calendar/utils/use-controlled-value.js +58 -0
  19. package/build/calendar/utils/use-controlled-value.js.map +1 -0
  20. package/build/calendar/utils/use-localization-props.js +162 -0
  21. package/build/calendar/utils/use-localization-props.js.map +1 -0
  22. package/build/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  23. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  24. package/build/custom-select-control-v2/custom-select.js +3 -3
  25. package/build/custom-select-control-v2/custom-select.js.map +1 -1
  26. package/build/date-time/date/index.js +1 -1
  27. package/build/date-time/date/index.js.map +1 -1
  28. package/build/form-file-upload/index.js +4 -6
  29. package/build/form-file-upload/index.js.map +1 -1
  30. package/build/form-token-field/index.js +11 -1
  31. package/build/form-token-field/index.js.map +1 -1
  32. package/build/form-token-field/token.js +1 -1
  33. package/build/form-token-field/token.js.map +1 -1
  34. package/build/index.js +19 -0
  35. package/build/index.js.map +1 -1
  36. package/build/mobile/bottom-sheet/cell.native.js +2 -2
  37. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  38. package/build/mobile/image/index.native.js +1 -1
  39. package/build/mobile/image/index.native.js.map +1 -1
  40. package/build/mobile/link-picker/index.native.js +1 -1
  41. package/build/mobile/link-picker/index.native.js.map +1 -1
  42. package/build/navigation/menu/menu-title-search.js +1 -1
  43. package/build/navigation/menu/menu-title-search.js.map +1 -1
  44. package/build/palette-edit/index.js +4 -4
  45. package/build/palette-edit/index.js.map +1 -1
  46. package/build-module/box-control/input-control.js +2 -2
  47. package/build-module/box-control/input-control.js.map +1 -1
  48. package/build-module/calendar/date-calendar/index.js +51 -0
  49. package/build-module/calendar/date-calendar/index.js.map +1 -0
  50. package/build-module/calendar/date-range-calendar/index.js +157 -0
  51. package/build-module/calendar/date-range-calendar/index.js.map +1 -0
  52. package/build-module/calendar/index.js +4 -0
  53. package/build-module/calendar/index.js.map +1 -0
  54. package/build-module/calendar/types.js +2 -0
  55. package/build-module/calendar/types.js.map +1 -0
  56. package/build-module/calendar/utils/constants.js +61 -0
  57. package/build-module/calendar/utils/constants.js.map +1 -0
  58. package/build-module/calendar/utils/day-cell.js +131 -0
  59. package/build-module/calendar/utils/day-cell.js.map +1 -0
  60. package/build-module/calendar/utils/misc.js +4 -0
  61. package/build-module/calendar/utils/misc.js.map +1 -0
  62. package/build-module/calendar/utils/use-controlled-value.js +51 -0
  63. package/build-module/calendar/utils/use-controlled-value.js.map +1 -0
  64. package/build-module/calendar/utils/use-localization-props.js +154 -0
  65. package/build-module/calendar/utils/use-localization-props.js.map +1 -0
  66. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -1
  67. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  68. package/build-module/custom-select-control-v2/custom-select.js +4 -4
  69. package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
  70. package/build-module/date-time/date/index.js +1 -1
  71. package/build-module/date-time/date/index.js.map +1 -1
  72. package/build-module/form-file-upload/index.js +4 -6
  73. package/build-module/form-file-upload/index.js.map +1 -1
  74. package/build-module/form-token-field/index.js +11 -1
  75. package/build-module/form-token-field/index.js.map +1 -1
  76. package/build-module/form-token-field/token.js +1 -1
  77. package/build-module/form-token-field/token.js.map +1 -1
  78. package/build-module/index.js +1 -0
  79. package/build-module/index.js.map +1 -1
  80. package/build-module/mobile/bottom-sheet/cell.native.js +2 -2
  81. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  82. package/build-module/mobile/image/index.native.js +1 -1
  83. package/build-module/mobile/image/index.native.js.map +1 -1
  84. package/build-module/mobile/link-picker/index.native.js +1 -1
  85. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  86. package/build-module/navigation/menu/menu-title-search.js +1 -1
  87. package/build-module/navigation/menu/menu-title-search.js.map +1 -1
  88. package/build-module/palette-edit/index.js +4 -4
  89. package/build-module/palette-edit/index.js.map +1 -1
  90. package/build-style/style-rtl.css +358 -5
  91. package/build-style/style.css +358 -5
  92. package/build-types/box-control/input-control.d.ts.map +1 -1
  93. package/build-types/box-control/utils.d.ts +7 -7
  94. package/build-types/calendar/date-calendar/index.d.ts +11 -0
  95. package/build-types/calendar/date-calendar/index.d.ts.map +1 -0
  96. package/build-types/calendar/date-range-calendar/index.d.ts +14 -0
  97. package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -0
  98. package/build-types/calendar/index.d.ts +4 -0
  99. package/build-types/calendar/index.d.ts.map +1 -0
  100. package/build-types/calendar/stories/date-calendar.story.d.ts +16 -0
  101. package/build-types/calendar/stories/date-calendar.story.d.ts.map +1 -0
  102. package/build-types/calendar/stories/date-range-calendar.story.d.ts +16 -0
  103. package/build-types/calendar/stories/date-range-calendar.story.d.ts.map +1 -0
  104. package/build-types/calendar/test/__utils__/index.d.ts +10 -0
  105. package/build-types/calendar/test/__utils__/index.d.ts.map +1 -0
  106. package/build-types/calendar/test/date-calendar.d.ts +2 -0
  107. package/build-types/calendar/test/date-calendar.d.ts.map +1 -0
  108. package/build-types/calendar/test/date-range-calendar.d.ts +2 -0
  109. package/build-types/calendar/test/date-range-calendar.d.ts.map +1 -0
  110. package/build-types/calendar/types.d.ts +317 -0
  111. package/build-types/calendar/types.d.ts.map +1 -0
  112. package/build-types/calendar/utils/constants.d.ts +52 -0
  113. package/build-types/calendar/utils/constants.d.ts.map +1 -0
  114. package/build-types/calendar/utils/day-cell.d.ts +21 -0
  115. package/build-types/calendar/utils/day-cell.d.ts.map +1 -0
  116. package/build-types/calendar/utils/misc.d.ts +2 -0
  117. package/build-types/calendar/utils/misc.d.ts.map +1 -0
  118. package/build-types/calendar/utils/use-controlled-value.d.ts +27 -0
  119. package/build-types/calendar/utils/use-controlled-value.d.ts.map +1 -0
  120. package/build-types/calendar/utils/use-localization-props.d.ts +64 -0
  121. package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -0
  122. package/build-types/custom-gradient-picker/constants.d.ts +6 -3
  123. package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
  124. package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
  125. package/build-types/dimension-control/sizes.d.ts +15 -3
  126. package/build-types/dimension-control/sizes.d.ts.map +1 -1
  127. package/build-types/font-size-picker/constants.d.ts +2 -2
  128. package/build-types/font-size-picker/constants.d.ts.map +1 -1
  129. package/build-types/form-file-upload/index.d.ts.map +1 -1
  130. package/build-types/form-token-field/index.d.ts.map +1 -1
  131. package/build-types/index.d.ts +1 -0
  132. package/build-types/index.d.ts.map +1 -1
  133. package/build-types/popover/overlay-middlewares.d.ts +6 -1
  134. package/build-types/popover/overlay-middlewares.d.ts.map +1 -1
  135. package/package.json +21 -20
  136. package/src/box-control/input-control.tsx +14 -5
  137. package/src/calendar/date-calendar/README.md +250 -0
  138. package/src/calendar/date-calendar/index.tsx +55 -0
  139. package/src/calendar/date-range-calendar/README.md +287 -0
  140. package/src/calendar/date-range-calendar/index.tsx +203 -0
  141. package/src/calendar/index.tsx +3 -0
  142. package/src/calendar/stories/date-calendar.story.tsx +221 -0
  143. package/src/calendar/stories/date-range-calendar.story.tsx +230 -0
  144. package/src/calendar/style.scss +431 -0
  145. package/src/calendar/test/__utils__/index.ts +56 -0
  146. package/src/calendar/test/date-calendar.tsx +975 -0
  147. package/src/calendar/test/date-range-calendar.tsx +1701 -0
  148. package/src/calendar/types.ts +342 -0
  149. package/src/calendar/utils/constants.ts +62 -0
  150. package/src/calendar/utils/day-cell.tsx +133 -0
  151. package/src/calendar/utils/misc.ts +3 -0
  152. package/src/calendar/utils/use-controlled-value.ts +61 -0
  153. package/src/calendar/utils/use-localization-props.ts +169 -0
  154. package/src/circular-option-picker/stories/index.story.tsx +2 -2
  155. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
  156. package/src/custom-select-control-v2/custom-select.tsx +6 -3
  157. package/src/date-time/date/index.tsx +1 -1
  158. package/src/form-file-upload/index.tsx +6 -12
  159. package/src/form-token-field/index.tsx +12 -1
  160. package/src/form-token-field/token.tsx +1 -1
  161. package/src/index.ts +1 -0
  162. package/src/mobile/bottom-sheet/cell.native.js +2 -2
  163. package/src/mobile/image/index.native.js +1 -1
  164. package/src/mobile/link-picker/index.native.js +1 -1
  165. package/src/navigation/menu/menu-title-search.tsx +1 -1
  166. package/src/palette-edit/index.tsx +4 -4
  167. package/src/select-control/style.scss +0 -6
  168. package/src/style.scss +1 -0
  169. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Day = Day;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ /**
9
+ * External dependencies
10
+ */
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ /**
17
+ * The dash array and offset are calculated by:
18
+ * - measuring the path length (eg 92,28384)
19
+ * - establishing how many segments should the path be split into (eg. 24)
20
+ * - dividing the path length by the number of segments (eg. 92,28384 / 24 = 3,84516)
21
+ * - playing with the dash offset to make sure the dashes look good on rounded corners
22
+ */
23
+
24
+ /**
25
+ * Dashed rectangle. The dash array and offset are chosen to make sure dashes
26
+ * look good on rounded corners and have similar metrics to the other dash
27
+ * preview shapes.
28
+ */
29
+ const PreviewDashStartAndEnd = () => {
30
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
31
+ viewBox: "0 0 32 32",
32
+ xmlns: "http://www.w3.org/2000/svg",
33
+ fill: "none",
34
+ stroke: "currentColor",
35
+ strokeDasharray: "3.7677",
36
+ strokeDashoffset: "3.2",
37
+ strokeWidth: "1",
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
39
+ d: "M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2"
40
+ })
41
+ });
42
+ };
43
+
44
+ /**
45
+ * Dashed top, left, and bottom sides, with rounded corners. The dash array and
46
+ * offset are chosen to make sure that multiple days in a row show a seamless
47
+ * dashed border, and the dashes look good on rounded corners.
48
+ */
49
+ const PreviewDashStart = () => {
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
51
+ viewBox: "0 0 32 32",
52
+ xmlns: "http://www.w3.org/2000/svg",
53
+ fill: "none",
54
+ stroke: "currentColor",
55
+ strokeDasharray: "3.84516",
56
+ strokeDashoffset: "1.9226",
57
+ strokeWidth: "1",
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
59
+ d: "M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30"
60
+ })
61
+ });
62
+ };
63
+ /**
64
+ * Dashed top and bottom sides. The dash array and offset are chosen
65
+ * to make sure that multiple days in a row show a seamless dashed border.
66
+ */
67
+ const PreviewDashMiddle = () => {
68
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
69
+ viewBox: "0 0 32 32",
70
+ xmlns: "http://www.w3.org/2000/svg",
71
+ fill: "none",
72
+ stroke: "currentColor",
73
+ strokeDasharray: "3.9 4",
74
+ strokeDashoffset: "2",
75
+ strokeWidth: "1",
76
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
77
+ x1: "0",
78
+ y1: "0.5",
79
+ x2: "100",
80
+ y2: "0.5"
81
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
82
+ x1: "0",
83
+ y1: "31.5",
84
+ x2: "100",
85
+ y2: "31.5"
86
+ })]
87
+ });
88
+ };
89
+ /**
90
+ * Dashed top, right, and bottom sides, with rounded corners. The dash array and
91
+ * offset are chosen to make sure that multiple days in a row show a seamless
92
+ * dashed border, and the dashes look good on rounded corners.
93
+ */
94
+ const PreviewDashEnd = () => {
95
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
96
+ viewBox: "0 0 32 32",
97
+ xmlns: "http://www.w3.org/2000/svg",
98
+ fill: "none",
99
+ stroke: "currentColor",
100
+ strokeDasharray: "3.84516",
101
+ strokeDashoffset: "1.9226",
102
+ strokeWidth: "1",
103
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
104
+ d: "M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5"
105
+ })
106
+ });
107
+ };
108
+
109
+ /**
110
+ * Render a grid cell for a specific day in the calendar.
111
+ *
112
+ * Handles interaction and focus for the day.
113
+ * @see https://daypicker.dev/guides/custom-components
114
+ */
115
+ function Day(props) {
116
+ const {
117
+ day,
118
+ modifiers,
119
+ children,
120
+ ...tdProps
121
+ } = props;
122
+ let PreviewDash;
123
+ if (modifiers.preview_start && modifiers.preview_end) {
124
+ PreviewDash = PreviewDashStartAndEnd;
125
+ } else if (modifiers.preview_start) {
126
+ PreviewDash = PreviewDashStart;
127
+ } else if (modifiers.preview_end) {
128
+ PreviewDash = PreviewDashEnd;
129
+ } else if (modifiers.preview) {
130
+ PreviewDash = PreviewDashMiddle;
131
+ }
132
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("td", {
133
+ ...tdProps,
134
+ children: [PreviewDash && /*#__PURE__*/(0, _jsxRuntime.jsx)(PreviewDash, {}), children]
135
+ });
136
+ }
137
+ //# sourceMappingURL=day-cell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PreviewDashStartAndEnd","_jsxRuntime","jsx","viewBox","xmlns","fill","stroke","strokeDasharray","strokeDashoffset","strokeWidth","children","d","PreviewDashStart","PreviewDashMiddle","jsxs","x1","y1","x2","y2","PreviewDashEnd","Day","props","day","modifiers","tdProps","PreviewDash","preview_start","preview_end","preview"],"sources":["@wordpress/components/src/calendar/utils/day-cell.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CalendarDay } from 'react-day-picker';\n/**\n * Internal dependencies\n */\nimport type { Modifiers } from '../types';\n\n/**\n * The dash array and offset are calculated by:\n * - measuring the path length (eg 92,28384)\n * - establishing how many segments should the path be split into (eg. 24)\n * - dividing the path length by the number of segments (eg. 92,28384 / 24 = 3,84516)\n * - playing with the dash offset to make sure the dashes look good on rounded corners\n */\n\n/**\n * Dashed rectangle. The dash array and offset are chosen to make sure dashes\n * look good on rounded corners and have similar metrics to the other dash\n * preview shapes.\n */\nconst PreviewDashStartAndEnd = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.7677\"\n\t\t\tstrokeDashoffset=\"3.2\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2\" />\n\t\t</svg>\n\t);\n};\n\n/**\n * Dashed top, left, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashStart = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.84516\"\n\t\t\tstrokeDashoffset=\"1.9226\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30\" />\n\t\t</svg>\n\t);\n};\n/**\n * Dashed top and bottom sides. The dash array and offset are chosen\n * to make sure that multiple days in a row show a seamless dashed border.\n */\nconst PreviewDashMiddle = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.9 4\"\n\t\t\tstrokeDashoffset=\"2\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<line x1=\"0\" y1=\"0.5\" x2=\"100\" y2=\"0.5\" />\n\t\t\t<line x1=\"0\" y1=\"31.5\" x2=\"100\" y2=\"31.5\" />\n\t\t</svg>\n\t);\n};\n/**\n * Dashed top, right, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashEnd = () => {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 32 32\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeDasharray=\"3.84516\"\n\t\t\tstrokeDashoffset=\"1.9226\"\n\t\t\tstrokeWidth=\"1\"\n\t\t>\n\t\t\t<path d=\"M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5\" />\n\t\t</svg>\n\t);\n};\n\n/**\n * Render a grid cell for a specific day in the calendar.\n *\n * Handles interaction and focus for the day.\n * @see https://daypicker.dev/guides/custom-components\n */\nexport function Day(\n\tprops: {\n\t\t/** The day to render. */\n\t\tday: CalendarDay;\n\t\t/** The modifiers to apply to the day. */\n\t\tmodifiers: Modifiers;\n\t} & React.HTMLAttributes< HTMLDivElement >\n) {\n\tconst { day, modifiers, children, ...tdProps } = props;\n\n\tlet PreviewDash;\n\tif ( modifiers.preview_start && modifiers.preview_end ) {\n\t\tPreviewDash = PreviewDashStartAndEnd;\n\t} else if ( modifiers.preview_start ) {\n\t\tPreviewDash = PreviewDashStart;\n\t} else if ( modifiers.preview_end ) {\n\t\tPreviewDash = PreviewDashEnd;\n\t} else if ( modifiers.preview ) {\n\t\tPreviewDash = PreviewDashMiddle;\n\t}\n\n\treturn (\n\t\t<td { ...tdProps }>\n\t\t\t{ PreviewDash && <PreviewDash /> }\n\t\t\t{ children }\n\t\t</td>\n\t);\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMA,sBAAsB,GAAGA,CAAA,KAAM;EACpC,oBACC,IAAAC,WAAA,CAAAC,GAAA;IACCC,OAAO,EAAC,WAAW;IACnBC,KAAK,EAAC,4BAA4B;IAClCC,IAAI,EAAC,MAAM;IACXC,MAAM,EAAC,cAAc;IACrBC,eAAe,EAAC,QAAQ;IACxBC,gBAAgB,EAAC,KAAK;IACtBC,WAAW,EAAC,GAAG;IAAAC,QAAA,eAEf,IAAAT,WAAA,CAAAC,GAAA;MAAMS,CAAC,EAAC;IAA6F,CAAE;EAAC,CACpG,CAAC;AAER,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAC9B,oBACC,IAAAX,WAAA,CAAAC,GAAA;IACCC,OAAO,EAAC,WAAW;IACnBC,KAAK,EAAC,4BAA4B;IAClCC,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ED;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,GAAGA,CAClBC,KAK0C,EACzC;EACD,MAAM;IAAEC,GAAG;IAAEC,SAAS;IAAEb,QAAQ;IAAE,GAAGc;EAAQ,CAAC,GAAGH,KAAK;EAEtD,IAAII,WAAW;EACf,IAAKF,SAAS,CAACG,aAAa,IAAIH,SAAS,CAACI,WAAW,EAAG;IACvDF,WAAW,GAAGzB,sBAAsB;EACrC,CAAC,MAAM,IAAKuB,SAAS,CAACG,aAAa,EAAG;IACrCD,WAAW,GAAGb,gBAAgB;EAC/B,CAAC,MAAM,IAAKW,SAAS,CAACI,WAAW,EAAG;IACnCF,WAAW,GAAGN,cAAc;EAC7B,CAAC,MAAM,IAAKI,SAAS,CAACK,OAAO,EAAG;IAC/BH,WAAW,GAAGZ,iBAAiB;EAChC;EAEA,oBACC,IAAAZ,WAAA,CAAAa,IAAA;IAAA,GAASU,OAAO;IAAAd,QAAA,GACbe,WAAW,iBAAI,IAAAxB,WAAA,CAAAC,GAAA,EAACuB,WAAW,IAAE,CAAC,EAC9Bf,QAAQ;EAAA,CACP,CAAC;AAEP","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clampNumberOfMonths = clampNumberOfMonths;
7
+ function clampNumberOfMonths(numberOfMonths) {
8
+ return Math.min(3, Math.max(1, numberOfMonths));
9
+ }
10
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["clampNumberOfMonths","numberOfMonths","Math","min","max"],"sources":["@wordpress/components/src/calendar/utils/misc.ts"],"sourcesContent":["export function clampNumberOfMonths( numberOfMonths: number ) {\n\treturn Math.min( 3, Math.max( 1, numberOfMonths ) );\n}\n"],"mappings":";;;;;;AAAO,SAASA,mBAAmBA,CAAEC,cAAsB,EAAG;EAC7D,OAAOC,IAAI,CAACC,GAAG,CAAE,CAAC,EAAED,IAAI,CAACE,GAAG,CAAE,CAAC,EAAEH,cAAe,CAAE,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useControlledValue = useControlledValue;
7
+ var _element = require("@wordpress/element");
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+
12
+ /**
13
+ * Handles controlled and uncontrolled state for the selected calendar value.
14
+ * It is assumed that the `value` prop is controlled when it's not undefined:
15
+ * - initial date selected, uncontrolled: use a non-undefined`defaultValue`
16
+ * - initial date selected, controlled: use a non-undefined `value`
17
+ * - no date selected, controlled: set `value` to `null`
18
+ *
19
+ * The `onChange` prop will return `undefined` when no date is selected,
20
+ * regardless of controlled / uncontrolled. It is expected that the consumer
21
+ * of the component will handle setting the value to `null` to indicate no date
22
+ * selected in controlled mode.
23
+ *
24
+ * @param props - The props object.
25
+ * @param props.defaultValue - The default value.
26
+ * @param props.onChange - The onChange callback.
27
+ * @param props.value - The value.
28
+ *
29
+ * @return The value and the setValue function.
30
+ */
31
+ function useControlledValue({
32
+ defaultValue,
33
+ onChange,
34
+ value: valueProp
35
+ }) {
36
+ var _ref;
37
+ const hasValue = typeof valueProp !== 'undefined';
38
+ const initialValue = hasValue ? valueProp : defaultValue;
39
+ const [state, setState] = (0, _element.useState)(initialValue);
40
+ const value = (_ref = hasValue ? valueProp : state) !== null && _ref !== void 0 ? _ref : undefined;
41
+ let setValue;
42
+ const uncontrolledSetValue = (0, _element.useCallback)((nextValue, ...args) => {
43
+ setState(nextValue);
44
+ onChange?.(nextValue, ...args);
45
+ }, [setState, onChange]);
46
+ if (hasValue && typeof onChange === 'function') {
47
+ // Controlled mode.
48
+ setValue = onChange;
49
+ } else if (!hasValue && typeof onChange === 'function') {
50
+ // Uncontrolled mode, plus forwarding to the onChange prop.
51
+ setValue = uncontrolledSetValue;
52
+ } else {
53
+ // Uncontrolled mode, only update internal state.
54
+ setValue = setState;
55
+ }
56
+ return [value, setValue];
57
+ }
58
+ //# sourceMappingURL=use-controlled-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","useControlledValue","defaultValue","onChange","value","valueProp","_ref","hasValue","initialValue","state","setState","useState","undefined","setValue","uncontrolledSetValue","useCallback","nextValue","args"],"sources":["@wordpress/components/src/calendar/utils/use-controlled-value.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\n\ntype Props< T > = {\n\tdefaultValue?: T;\n\tvalue?: T | null | undefined;\n\tonChange?: ( newValue: T, ...args: any[] ) => void;\n};\n\n/**\n * Handles controlled and uncontrolled state for the selected calendar value.\n * It is assumed that the `value` prop is controlled when it's not undefined:\n * - initial date selected, uncontrolled: use a non-undefined`defaultValue`\n * - initial date selected, controlled: use a non-undefined `value`\n * - no date selected, controlled: set `value` to `null`\n *\n * The `onChange` prop will return `undefined` when no date is selected,\n * regardless of controlled / uncontrolled. It is expected that the consumer\n * of the component will handle setting the value to `null` to indicate no date\n * selected in controlled mode.\n *\n * @param props - The props object.\n * @param props.defaultValue - The default value.\n * @param props.onChange - The onChange callback.\n * @param props.value - The value.\n *\n * @return The value and the setValue function.\n */\nexport function useControlledValue< T >( {\n\tdefaultValue,\n\tonChange,\n\tvalue: valueProp,\n}: Props< T > ) {\n\tconst hasValue = typeof valueProp !== 'undefined';\n\tconst initialValue = hasValue ? valueProp : defaultValue;\n\tconst [ state, setState ] = useState( initialValue );\n\tconst value = ( hasValue ? valueProp : state ) ?? undefined;\n\n\tlet setValue: typeof onChange;\n\tconst uncontrolledSetValue: NonNullable< typeof onChange > = useCallback(\n\t\t( nextValue, ...args ) => {\n\t\t\tsetState( nextValue );\n\t\t\tonChange?.( nextValue, ...args );\n\t\t},\n\t\t[ setState, onChange ]\n\t);\n\tif ( hasValue && typeof onChange === 'function' ) {\n\t\t// Controlled mode.\n\t\tsetValue = onChange;\n\t} else if ( ! hasValue && typeof onChange === 'function' ) {\n\t\t// Uncontrolled mode, plus forwarding to the onChange prop.\n\t\tsetValue = uncontrolledSetValue;\n\t} else {\n\t\t// Uncontrolled mode, only update internal state.\n\t\tsetValue = setState;\n\t}\n\n\treturn [ value, setValue ] as const;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAO;EACxCC,YAAY;EACZC,QAAQ;EACRC,KAAK,EAAEC;AACI,CAAC,EAAG;EAAA,IAAAC,IAAA;EACf,MAAMC,QAAQ,GAAG,OAAOF,SAAS,KAAK,WAAW;EACjD,MAAMG,YAAY,GAAGD,QAAQ,GAAGF,SAAS,GAAGH,YAAY;EACxD,MAAM,CAAEO,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAC,iBAAQ,EAAEH,YAAa,CAAC;EACpD,MAAMJ,KAAK,IAAAE,IAAA,GAAKC,QAAQ,GAAGF,SAAS,GAAGI,KAAK,cAAAH,IAAA,cAAAA,IAAA,GAAMM,SAAS;EAE3D,IAAIC,QAAyB;EAC7B,MAAMC,oBAAoD,GAAG,IAAAC,oBAAW,EACvE,CAAEC,SAAS,EAAE,GAAGC,IAAI,KAAM;IACzBP,QAAQ,CAAEM,SAAU,CAAC;IACrBb,QAAQ,GAAIa,SAAS,EAAE,GAAGC,IAAK,CAAC;EACjC,CAAC,EACD,CAAEP,QAAQ,EAAEP,QAAQ,CACrB,CAAC;EACD,IAAKI,QAAQ,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAG;IACjD;IACAU,QAAQ,GAAGV,QAAQ;EACpB,CAAC,MAAM,IAAK,CAAEI,QAAQ,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAG;IAC1D;IACAU,QAAQ,GAAGC,oBAAoB;EAChC,CAAC,MAAM;IACN;IACAD,QAAQ,GAAGH,QAAQ;EACpB;EAEA,OAAO,CAAEN,KAAK,EAAES,QAAQ,CAAE;AAC3B","ignoreList":[]}
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useLocalizationProps = void 0;
7
+ var _i18n = require("@wordpress/i18n");
8
+ var _element = require("@wordpress/element");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+
17
+ function isLocaleRTL(localeCode) {
18
+ const localeObj = new Intl.Locale(localeCode);
19
+ if ('getTextInfo' in localeObj) {
20
+ // @ts-expect-error - getTextInfo is not typed yet
21
+ // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
22
+ return localeObj.getTextInfo().direction === 'rtl';
23
+ }
24
+ return ['ar',
25
+ // Arabic
26
+ 'he',
27
+ // Hebrew
28
+ 'fa',
29
+ // Persian (Farsi)
30
+ 'ur',
31
+ // Urdu
32
+ 'ps',
33
+ // Pashto
34
+ 'syr',
35
+ // Syriac
36
+ 'dv',
37
+ // Divehi
38
+ 'ku',
39
+ // Kurdish (Sorani)
40
+ 'yi' // Yiddish
41
+ ].includes(localeObj.language);
42
+ }
43
+
44
+ /**
45
+ * Returns localization props for the calendar components.
46
+ *
47
+ * Notes:
48
+ * - the following props should be intended as defaults, and should
49
+ * be overridden by consumer props if listed as public props.
50
+ * - It is possible for the translated strings to use a different locale
51
+ * than the formatted dates and the computed `dir`. This is because the
52
+ * translation function doesn't expose the locale used for the translated
53
+ * strings, meaning that the dates are formatted using the `locale` prop.
54
+ * For a correct localized experience, consumers should make sure that
55
+ * translation context and `locale` prop are consistent.
56
+ * @param props
57
+ * @param props.locale
58
+ * @param props.timeZone
59
+ * @param props.mode
60
+ */
61
+ const useLocalizationProps = ({
62
+ locale,
63
+ timeZone,
64
+ mode
65
+ }) => {
66
+ return (0, _element.useMemo)(() => {
67
+ // ie. April 2025
68
+ const monthNameFormatter = new Intl.DateTimeFormat(locale.code, {
69
+ year: 'numeric',
70
+ month: 'long',
71
+ timeZone
72
+ });
73
+ // ie. M, T, W, T, F, S, S
74
+ const weekdayNarrowFormatter = new Intl.DateTimeFormat(locale.code, {
75
+ weekday: 'narrow',
76
+ timeZone
77
+ });
78
+ // ie. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
79
+ const weekdayLongFormatter = new Intl.DateTimeFormat(locale.code, {
80
+ weekday: 'long',
81
+ timeZone
82
+ });
83
+ // ie. Monday, April 29, 2025
84
+ const fullDateFormatter = new Intl.DateTimeFormat(locale.code, {
85
+ weekday: 'long',
86
+ year: 'numeric',
87
+ month: 'long',
88
+ day: 'numeric',
89
+ timeZone
90
+ });
91
+
92
+ // Note: the following props should be intended as defaults, and should
93
+ // be overridden by consumer props if listed as public props.
94
+ return {
95
+ 'aria-label': mode === 'single' ? (0, _i18n.__)('Date calendar') : (0, _i18n.__)('Date range calendar'),
96
+ labels: {
97
+ /**
98
+ * The label for the month grid.
99
+ * @param date
100
+ */
101
+ labelGrid: date => monthNameFormatter.format(date),
102
+ /**
103
+ * The label for the gridcell, when the calendar is not interactive.
104
+ * @param date
105
+ * @param modifiers
106
+ */
107
+ labelGridcell: (date, modifiers) => {
108
+ const formattedDate = fullDateFormatter.format(date);
109
+ let label = formattedDate;
110
+ if (modifiers?.today) {
111
+ label = (0, _i18n.sprintf)(
112
+ // translators: %s is the full date (e.g. "Monday, April 29, 2025")
113
+ (0, _i18n.__)('Today, %s'), formattedDate);
114
+ }
115
+ return label;
116
+ },
117
+ /** The label for the "next month" button. */
118
+ labelNext: () => (0, _i18n.__)('Go to the Next Month'),
119
+ /** The label for the "previous month" button. */
120
+ labelPrevious: () => (0, _i18n.__)('Go to the Previous Month'),
121
+ /**
122
+ * The label for the day button.
123
+ * @param date
124
+ * @param modifiers
125
+ */
126
+ labelDayButton: (date, modifiers) => {
127
+ const formattedDate = fullDateFormatter.format(date);
128
+ let label = formattedDate;
129
+ if (modifiers?.today) {
130
+ label = (0, _i18n.sprintf)(
131
+ // translators: %s is the full date (e.g. "Monday, April 29, 2025")
132
+ (0, _i18n.__)('Today, %s'), formattedDate);
133
+ }
134
+ if (modifiers?.selected) {
135
+ label = (0, _i18n.sprintf)(
136
+ // translators: %s is the full date (e.g. "Monday, April 29, 2025")
137
+ (0, _i18n.__)('%s, selected'), formattedDate);
138
+ }
139
+ return label;
140
+ },
141
+ /**
142
+ * The label for the weekday.
143
+ * @param date
144
+ */
145
+ labelWeekday: date => weekdayLongFormatter.format(date)
146
+ },
147
+ locale,
148
+ dir: isLocaleRTL(locale.code) ? 'rtl' : 'ltr',
149
+ formatters: {
150
+ formatWeekdayName: date => {
151
+ return weekdayNarrowFormatter.format(date);
152
+ },
153
+ formatCaption: date => {
154
+ return monthNameFormatter.format(date);
155
+ }
156
+ },
157
+ timeZone
158
+ };
159
+ }, [locale, timeZone, mode]);
160
+ };
161
+ exports.useLocalizationProps = useLocalizationProps;
162
+ //# sourceMappingURL=use-localization-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_element","isLocaleRTL","localeCode","localeObj","Intl","Locale","getTextInfo","direction","includes","language","useLocalizationProps","locale","timeZone","mode","useMemo","monthNameFormatter","DateTimeFormat","code","year","month","weekdayNarrowFormatter","weekday","weekdayLongFormatter","fullDateFormatter","day","__","labels","labelGrid","date","format","labelGridcell","modifiers","formattedDate","label","today","sprintf","labelNext","labelPrevious","labelDayButton","selected","labelWeekday","dir","formatters","formatWeekdayName","formatCaption","exports"],"sources":["@wordpress/components/src/calendar/utils/use-localization-props.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport type { Modifiers, BaseProps } from '../types';\n\nfunction isLocaleRTL( localeCode: string ) {\n\tconst localeObj = new Intl.Locale( localeCode );\n\tif ( 'getTextInfo' in localeObj ) {\n\t\t// @ts-expect-error - getTextInfo is not typed yet\n\t\t// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo\n\t\treturn localeObj.getTextInfo().direction === 'rtl';\n\t}\n\treturn [\n\t\t'ar', // Arabic\n\t\t'he', // Hebrew\n\t\t'fa', // Persian (Farsi)\n\t\t'ur', // Urdu\n\t\t'ps', // Pashto\n\t\t'syr', // Syriac\n\t\t'dv', // Divehi\n\t\t'ku', // Kurdish (Sorani)\n\t\t'yi', // Yiddish\n\t].includes( localeObj.language );\n}\n\n/**\n * Returns localization props for the calendar components.\n *\n * Notes:\n * - the following props should be intended as defaults, and should\n * be overridden by consumer props if listed as public props.\n * - It is possible for the translated strings to use a different locale\n * than the formatted dates and the computed `dir`. This is because the\n * translation function doesn't expose the locale used for the translated\n * strings, meaning that the dates are formatted using the `locale` prop.\n * For a correct localized experience, consumers should make sure that\n * translation context and `locale` prop are consistent.\n * @param props\n * @param props.locale\n * @param props.timeZone\n * @param props.mode\n */\nexport const useLocalizationProps = ( {\n\tlocale,\n\ttimeZone,\n\tmode,\n}: {\n\tlocale: NonNullable< BaseProps[ 'locale' ] >;\n\ttimeZone: BaseProps[ 'timeZone' ];\n\tmode: 'single' | 'range';\n} ) => {\n\treturn useMemo( () => {\n\t\t// ie. April 2025\n\t\tconst monthNameFormatter = new Intl.DateTimeFormat( locale.code, {\n\t\t\tyear: 'numeric',\n\t\t\tmonth: 'long',\n\t\t\ttimeZone,\n\t\t} );\n\t\t// ie. M, T, W, T, F, S, S\n\t\tconst weekdayNarrowFormatter = new Intl.DateTimeFormat( locale.code, {\n\t\t\tweekday: 'narrow',\n\t\t\ttimeZone,\n\t\t} );\n\t\t// ie. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday\n\t\tconst weekdayLongFormatter = new Intl.DateTimeFormat( locale.code, {\n\t\t\tweekday: 'long',\n\t\t\ttimeZone,\n\t\t} );\n\t\t// ie. Monday, April 29, 2025\n\t\tconst fullDateFormatter = new Intl.DateTimeFormat( locale.code, {\n\t\t\tweekday: 'long',\n\t\t\tyear: 'numeric',\n\t\t\tmonth: 'long',\n\t\t\tday: 'numeric',\n\t\t\ttimeZone,\n\t\t} );\n\n\t\t// Note: the following props should be intended as defaults, and should\n\t\t// be overridden by consumer props if listed as public props.\n\t\treturn {\n\t\t\t'aria-label':\n\t\t\t\tmode === 'single'\n\t\t\t\t\t? __( 'Date calendar' )\n\t\t\t\t\t: __( 'Date range calendar' ),\n\t\t\tlabels: {\n\t\t\t\t/**\n\t\t\t\t * The label for the month grid.\n\t\t\t\t * @param date\n\t\t\t\t */\n\t\t\t\tlabelGrid: ( date: Date ) => monthNameFormatter.format( date ),\n\t\t\t\t/**\n\t\t\t\t * The label for the gridcell, when the calendar is not interactive.\n\t\t\t\t * @param date\n\t\t\t\t * @param modifiers\n\t\t\t\t */\n\t\t\t\tlabelGridcell: (\n\t\t\t\t\tdate: Date,\n\t\t\t\t\t/** The modifiers for the day. */\n\t\t\t\t\tmodifiers?: Modifiers\n\t\t\t\t) => {\n\t\t\t\t\tconst formattedDate = fullDateFormatter.format( date );\n\t\t\t\t\tlet label = formattedDate;\n\t\t\t\t\tif ( modifiers?.today ) {\n\t\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t\t// translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n\t\t\t\t\t\t\t__( 'Today, %s' ),\n\t\t\t\t\t\t\tformattedDate\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn label;\n\t\t\t\t},\n\t\t\t\t/** The label for the \"next month\" button. */\n\t\t\t\tlabelNext: () => __( 'Go to the Next Month' ),\n\t\t\t\t/** The label for the \"previous month\" button. */\n\t\t\t\tlabelPrevious: () => __( 'Go to the Previous Month' ),\n\t\t\t\t/**\n\t\t\t\t * The label for the day button.\n\t\t\t\t * @param date\n\t\t\t\t * @param modifiers\n\t\t\t\t */\n\t\t\t\tlabelDayButton: (\n\t\t\t\t\tdate: Date,\n\t\t\t\t\t/** The modifiers for the day. */\n\t\t\t\t\tmodifiers?: Modifiers\n\t\t\t\t) => {\n\t\t\t\t\tconst formattedDate = fullDateFormatter.format( date );\n\t\t\t\t\tlet label = formattedDate;\n\t\t\t\t\tif ( modifiers?.today ) {\n\t\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t\t// translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n\t\t\t\t\t\t\t__( 'Today, %s' ),\n\t\t\t\t\t\t\tformattedDate\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif ( modifiers?.selected ) {\n\t\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t\t// translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n\t\t\t\t\t\t\t__( '%s, selected' ),\n\t\t\t\t\t\t\tformattedDate\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn label;\n\t\t\t\t},\n\t\t\t\t/**\n\t\t\t\t * The label for the weekday.\n\t\t\t\t * @param date\n\t\t\t\t */\n\t\t\t\tlabelWeekday: ( date: Date ) =>\n\t\t\t\t\tweekdayLongFormatter.format( date ),\n\t\t\t},\n\t\t\tlocale,\n\t\t\tdir: isLocaleRTL( locale.code ) ? 'rtl' : 'ltr',\n\t\t\tformatters: {\n\t\t\t\tformatWeekdayName: ( date: Date ) => {\n\t\t\t\t\treturn weekdayNarrowFormatter.format( date );\n\t\t\t\t},\n\t\t\t\tformatCaption: ( date: Date ) => {\n\t\t\t\t\treturn monthNameFormatter.format( date );\n\t\t\t\t},\n\t\t\t},\n\t\t\ttimeZone,\n\t\t} as const;\n\t}, [ locale, timeZone, mode ] );\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,SAASE,WAAWA,CAAEC,UAAkB,EAAG;EAC1C,MAAMC,SAAS,GAAG,IAAIC,IA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QACIO,YAAY,EAAIZ,IAAU,IACzBN,oBAAoB,CAACO,MAAM,CAAED,IAAK;MACpC,CAAC;MACDjB,MAAM;MACN8B,GAAG,EAAExC,WAAW,CAAEU,MAAM,CAACM,IAAK,CAAC,GAAG,KAAK,GAAG,KAAK;MAC/CyB,UAAU,EAAE;QACXC,iBAAiB,EAAIf,IAAU,IAAM;UACpC,OAAOR,sBAAsB,CAACS,MAAM,CAAED,IAAK,CAAC;QAC7C,CAAC;QACDgB,aAAa,EAAIhB,IAAU,IAAM;UAChC,OAAOb,kBAAkB,CAACc,MAAM,CAAED,IAAK,CAAC;QACzC;MACD,CAAC;MACDhB;IACD,CAAC;EACF,CAAC,EAAE,CAAED,MAAM,EAAEC,QAAQ,EAAEC,IAAI,CAAG,CAAC;AAChC,CAAC;AAACgC,OAAA,CAAAnC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -44,7 +44,7 @@ function ControlPointButton({
44
44
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
45
45
  "aria-label": (0, _i18n.sprintf)(
46
46
  // translators: 1: gradient position e.g: 70. 2: gradient color code e.g: rgb(52,121,151).
47
- (0, _i18n.__)('Gradient control point at position %1$s%% with color code %2$s.'), position, color),
47
+ (0, _i18n.__)('Gradient control point at position %1$d%% with color code %2$s.'), position, color),
48
48
  "aria-describedby": descriptionId,
49
49
  "aria-haspopup": "true",
50
50
  "aria-expanded": isOpen,
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_colord","_compose","_element","_i18n","_icons","_button","_hStack","_colorPicker","_visuallyHidden","_colorPalette","_utils","_constants","_dropdownContentWrapper","_jsxRuntime","ControlPointButton","isOpen","position","color","additionalProps","instanceId","useInstanceId","descriptionId","jsxs","Fragment","children","jsx","default","sprintf","__","__next40pxDefaultSize","className","clsx","VisuallyHidden","id","GradientColorPickerDropdown","isRenderedInSidebar","props","popoverProps","useMemo","placement","offset","resize","mergedClassName","CustomColorPickerDropdown","ControlPoints","disableRemove","disableAlpha","gradientPickerDomRef","ignoreMarkerPosition","value","controlPoints","onChange","onStartControlPointChange","onStopControlPointChange","__experimentalIsRenderedInSidebar","controlPointMoveStateRef","useRef","onMouseMove","event","current","undefined","relativePosition","getHorizontalRelativeGradientPosition","clientX","initialPosition","index","significantMoveHappened","Math","abs","MINIMUM_SIGNIFICANT_MOVE","updateControlPointPosition","cleanEventListeners","window","removeEventListener","listenersActivated","cleanEventListenersRef","useEffect","map","point","onClose","renderToggle","onToggle","onClick","onMouseDown","addEventListener","onKeyDown","code","stopPropagation","clampPercent","KEYBOARD_CONTROL_POINT_VARIATION","renderContent","paddingSize","ColorPicker","enableAlpha","updateControlPointColor","colord","toRgbString","length","HStack","alignment","removeControlPoint","variant","style","left","transform","InsertPoint","onOpenInserter","onCloseInserter","insertPosition","alreadyInsertedPoint","setAlreadyInsertedPoint","useState","icon","plus","addControlPoint","updateControlPointColorByPosition","_default","exports"],"sources":["@wordpress/components/src/custom-gradient-picker/gradient-bar/control-points.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport { HStack } from '../../h-stack';\nimport { ColorPicker } from '../../color-picker';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport { CustomColorPickerDropdown } from '../../color-palette';\n\nimport {\n\taddControlPoint,\n\tclampPercent,\n\tremoveControlPoint,\n\tupdateControlPointColor,\n\tupdateControlPointColorByPosition,\n\tupdateControlPointPosition,\n\tgetHorizontalRelativeGradientPosition,\n} from './utils';\nimport {\n\tMINIMUM_SIGNIFICANT_MOVE,\n\tKEYBOARD_CONTROL_POINT_VARIATION,\n} from './constants';\nimport type { WordPressComponentProps } from '../../context';\nimport type {\n\tControlPointButtonProps,\n\tControlPointMoveState,\n\tControlPointsProps,\n\tInsertPointProps,\n} from '../types';\nimport type { CustomColorPickerDropdownProps } from '../../color-palette/types';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nfunction ControlPointButton( {\n\tisOpen,\n\tposition,\n\tcolor,\n\t...additionalProps\n}: WordPressComponentProps< ControlPointButtonProps, 'button', true > ) {\n\tconst instanceId = useInstanceId( ControlPointButton );\n\tconst descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`;\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: 1: gradient position e.g: 70. 2: gradient color code e.g: rgb(52,121,151).\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Gradient control point at position %1$s%% with color code %2$s.'\n\t\t\t\t\t),\n\t\t\t\t\tposition,\n\t\t\t\t\tcolor\n\t\t\t\t) }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'components-custom-gradient-picker__control-point-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-active': isOpen,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n\nfunction GradientColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tclassName,\n\t...props\n}: CustomColorPickerDropdownProps ) {\n\t// Open the popover below the gradient control/insertion point\n\tconst popoverProps = useMemo(\n\t\t() =>\n\t\t\t( {\n\t\t\t\tplacement: 'bottom',\n\t\t\t\toffset: 8,\n\t\t\t\t// Disabling resize as it would otherwise cause the popover to show\n\t\t\t\t// scrollbars while dragging the color picker's handle close to the\n\t\t\t\t// popover edge.\n\t\t\t\tresize: false,\n\t\t\t} ) as const,\n\t\t[]\n\t);\n\n\tconst mergedClassName = clsx(\n\t\t'components-custom-gradient-picker__control-point-dropdown',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<CustomColorPickerDropdown\n\t\t\tisRenderedInSidebar={ isRenderedInSidebar }\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tclassName={ mergedClassName }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ControlPoints( {\n\tdisableRemove,\n\tdisableAlpha,\n\tgradientPickerDomRef,\n\tignoreMarkerPosition,\n\tvalue: controlPoints,\n\tonChange,\n\tonStartControlPointChange,\n\tonStopControlPointChange,\n\t__experimentalIsRenderedInSidebar,\n}: ControlPointsProps ) {\n\tconst controlPointMoveStateRef = useRef< ControlPointMoveState >();\n\n\tconst onMouseMove = ( event: MouseEvent ) => {\n\t\tif (\n\t\t\tcontrolPointMoveStateRef.current === undefined ||\n\t\t\tgradientPickerDomRef.current === null\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst relativePosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientPickerDomRef.current\n\t\t);\n\n\t\tconst { initialPosition, index, significantMoveHappened } =\n\t\t\tcontrolPointMoveStateRef.current;\n\n\t\tif (\n\t\t\t! significantMoveHappened &&\n\t\t\tMath.abs( initialPosition - relativePosition ) >=\n\t\t\t\tMINIMUM_SIGNIFICANT_MOVE\n\t\t) {\n\t\t\tcontrolPointMoveStateRef.current.significantMoveHappened = true;\n\t\t}\n\n\t\tonChange(\n\t\t\tupdateControlPointPosition( controlPoints, index, relativePosition )\n\t\t);\n\t};\n\n\tconst cleanEventListeners = () => {\n\t\tif (\n\t\t\twindow &&\n\t\t\twindow.removeEventListener &&\n\t\t\tcontrolPointMoveStateRef.current &&\n\t\t\tcontrolPointMoveStateRef.current.listenersActivated\n\t\t) {\n\t\t\twindow.removeEventListener( 'mousemove', onMouseMove );\n\t\t\twindow.removeEventListener( 'mouseup', cleanEventListeners );\n\t\t\tonStopControlPointChange();\n\t\t\tcontrolPointMoveStateRef.current.listenersActivated = false;\n\t\t}\n\t};\n\n\t// Adding `cleanEventListeners` to the dependency array below requires the function itself to be wrapped in a `useCallback`\n\t// This memoization would prevent the event listeners from being properly cleaned.\n\t// Instead, we'll pass a ref to the function in our `useEffect` so `cleanEventListeners` itself is no longer a dependency.\n\tconst cleanEventListenersRef = useRef< () => void >();\n\tcleanEventListenersRef.current = cleanEventListeners;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tcleanEventListenersRef.current?.();\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t{ controlPoints.map( ( point, index ) => {\n\t\t\t\tconst initialPosition = point?.position;\n\t\t\t\treturn (\n\t\t\t\t\tignoreMarkerPosition !== initialPosition && (\n\t\t\t\t\t\t<GradientColorPickerDropdown\n\t\t\t\t\t\t\tisRenderedInSidebar={\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tonClose={ onStopControlPointChange }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<ControlPointButton\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current &&\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current\n\t\t\t\t\t\t\t\t\t\t\t\t.significantMoveHappened\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\t\t\t\t\tonStopControlPointChange();\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonMouseDown={ () => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\twindow &&\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current = {\n\t\t\t\t\t\t\t\t\t\t\t\tinitialPosition,\n\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\tsignificantMoveHappened: false,\n\t\t\t\t\t\t\t\t\t\t\t\tlistenersActivated: true,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\t\t'mousemove',\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseMove\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t\t\t\t\t\t\tcleanEventListeners\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\t\t\tif ( event.code === 'ArrowLeft' ) {\n\t\t\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpoint.position -\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\tevent.code === 'ArrowRight'\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpoint.position +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\t\t\tposition={ point.position }\n\t\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointColor(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcolord(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcolor\n\t\t\t\t\t\t\t\t\t\t\t\t\t).toRgbString()\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ ! disableRemove &&\n\t\t\t\t\t\t\t\t\t\tcontrolPoints.length > 2 && (\n\t\t\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-custom-gradient-picker__remove-control-point-wrapper\"\n\t\t\t\t\t\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tremoveControlPoint(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove Control Point'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownContentWrapper>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tleft: `${ point.position }%`,\n\t\t\t\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nfunction InsertPoint( {\n\tvalue: controlPoints,\n\tonChange,\n\tonOpenInserter,\n\tonCloseInserter,\n\tinsertPosition,\n\tdisableAlpha,\n\t__experimentalIsRenderedInSidebar,\n}: InsertPointProps ) {\n\tconst [ alreadyInsertedPoint, setAlreadyInsertedPoint ] = useState( false );\n\treturn (\n\t\t<GradientColorPickerDropdown\n\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\tclassName=\"components-custom-gradient-picker__inserter\"\n\t\t\tonClose={ () => {\n\t\t\t\tonCloseInserter();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\tonCloseInserter();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( false );\n\t\t\t\t\t\t\tonOpenInserter();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t} }\n\t\t\t\t\tclassName=\"components-custom-gradient-picker__insert-point-dropdown\"\n\t\t\t\t\ticon={ plus }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\tif ( ! alreadyInsertedPoint ) {\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\taddControlPoint(\n\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tsetAlreadyInsertedPoint( true );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\tupdateControlPointColorByPosition(\n\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t\tstyle={\n\t\t\t\tinsertPosition !== null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tleft: `${ insertPosition }%`,\n\t\t\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t\t }\n\t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AW,EAAC,MAAM;MAAAnE,QAAA,eACzC,IAAAX,WAAA,CAAAY,GAAA,EAAClB,YAAA,CAAAqF,WAAW;QACXC,WAAW,EAAG,CAAE/C,YAAc;QAC9BK,QAAQ,EAAKlC,KAAK,IAAM;UACvB,IAAK,CAAE4F,oBAAoB,EAAG;YAC7B1D,QAAQ,CACP,IAAA+D,sBAAe,EACdhE,aAAa,EACb0D,cAAc,EACd,IAAAb,cAAM,EAAE9E,KAAM,CAAC,CAAC+E,WAAW,CAAC,CAC7B,CACD,CAAC;YACDc,uBAAuB,CAAE,IAAK,CAAC;UAChC,CAAC,MAAM;YACN3D,QAAQ,CACP,IAAAgE,wCAAiC,EAChCjE,aAAa,EACb0D,cAAc,EACd,IAAAb,cAAM,EAAE9E,KAAM,CAAC,CAAC+E,WAAW,CAAC,CAC7B,CACD,CAAC;UACF;QACD;MAAG,CACH;IAAC,CACqB,CACtB;IACHM,KAAK,EACJM,cAAc,KAAK,IAAI,GACpB;MACAL,IAAI,EAAE,GAAIK,cAAc,GAAI;MAC5BJ,SAAS,EAAE;IACX,CAAC,GACD5C;EACH,CACD,CAAC;AAEJ;AACAhB,aAAa,CAAC6D,WAAW,GAAGA,WAAW;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAA3F,OAAA,GAEzBkB,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_colord","_compose","_element","_i18n","_icons","_button","_hStack","_colorPicker","_visuallyHidden","_colorPalette","_utils","_constants","_dropdownContentWrapper","_jsxRuntime","ControlPointButton","isOpen","position","color","additionalProps","instanceId","useInstanceId","descriptionId","jsxs","Fragment","children","jsx","default","sprintf","__","__next40pxDefaultSize","className","clsx","VisuallyHidden","id","GradientColorPickerDropdown","isRenderedInSidebar","props","popoverProps","useMemo","placement","offset","resize","mergedClassName","CustomColorPickerDropdown","ControlPoints","disableRemove","disableAlpha","gradientPickerDomRef","ignoreMarkerPosition","value","controlPoints","onChange","onStartControlPointChange","onStopControlPointChange","__experimentalIsRenderedInSidebar","controlPointMoveStateRef","useRef","onMouseMove","event","current","undefined","relativePosition","getHorizontalRelativeGradientPosition","clientX","initialPosition","index","significantMoveHappened","Math","abs","MINIMUM_SIGNIFICANT_MOVE","updateControlPointPosition","cleanEventListeners","window","removeEventListener","listenersActivated","cleanEventListenersRef","useEffect","map","point","onClose","renderToggle","onToggle","onClick","onMouseDown","addEventListener","onKeyDown","code","stopPropagation","clampPercent","KEYBOARD_CONTROL_POINT_VARIATION","renderContent","paddingSize","ColorPicker","enableAlpha","updateControlPointColor","colord","toRgbString","length","HStack","alignment","removeControlPoint","variant","style","left","transform","InsertPoint","onOpenInserter","onCloseInserter","insertPosition","alreadyInsertedPoint","setAlreadyInsertedPoint","useState","icon","plus","addControlPoint","updateControlPointColorByPosition","_default","exports"],"sources":["@wordpress/components/src/custom-gradient-picker/gradient-bar/control-points.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useRef, useState, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport { HStack } from '../../h-stack';\nimport { ColorPicker } from '../../color-picker';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport { CustomColorPickerDropdown } from '../../color-palette';\n\nimport {\n\taddControlPoint,\n\tclampPercent,\n\tremoveControlPoint,\n\tupdateControlPointColor,\n\tupdateControlPointColorByPosition,\n\tupdateControlPointPosition,\n\tgetHorizontalRelativeGradientPosition,\n} from './utils';\nimport {\n\tMINIMUM_SIGNIFICANT_MOVE,\n\tKEYBOARD_CONTROL_POINT_VARIATION,\n} from './constants';\nimport type { WordPressComponentProps } from '../../context';\nimport type {\n\tControlPointButtonProps,\n\tControlPointMoveState,\n\tControlPointsProps,\n\tInsertPointProps,\n} from '../types';\nimport type { CustomColorPickerDropdownProps } from '../../color-palette/types';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nfunction ControlPointButton( {\n\tisOpen,\n\tposition,\n\tcolor,\n\t...additionalProps\n}: WordPressComponentProps< ControlPointButtonProps, 'button', true > ) {\n\tconst instanceId = useInstanceId( ControlPointButton );\n\tconst descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`;\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: 1: gradient position e.g: 70. 2: gradient color code e.g: rgb(52,121,151).\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Gradient control point at position %1$d%% with color code %2$s.'\n\t\t\t\t\t),\n\t\t\t\t\tposition,\n\t\t\t\t\tcolor\n\t\t\t\t) }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\taria-haspopup=\"true\"\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'components-custom-gradient-picker__control-point-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-active': isOpen,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t{ ...additionalProps }\n\t\t\t/>\n\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t{ __(\n\t\t\t\t\t'Use your left or right arrow keys or drag and drop with the mouse to change the gradient position. Press the button to change the color or remove the control point.'\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n\nfunction GradientColorPickerDropdown( {\n\tisRenderedInSidebar,\n\tclassName,\n\t...props\n}: CustomColorPickerDropdownProps ) {\n\t// Open the popover below the gradient control/insertion point\n\tconst popoverProps = useMemo(\n\t\t() =>\n\t\t\t( {\n\t\t\t\tplacement: 'bottom',\n\t\t\t\toffset: 8,\n\t\t\t\t// Disabling resize as it would otherwise cause the popover to show\n\t\t\t\t// scrollbars while dragging the color picker's handle close to the\n\t\t\t\t// popover edge.\n\t\t\t\tresize: false,\n\t\t\t} ) as const,\n\t\t[]\n\t);\n\n\tconst mergedClassName = clsx(\n\t\t'components-custom-gradient-picker__control-point-dropdown',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<CustomColorPickerDropdown\n\t\t\tisRenderedInSidebar={ isRenderedInSidebar }\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tclassName={ mergedClassName }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ControlPoints( {\n\tdisableRemove,\n\tdisableAlpha,\n\tgradientPickerDomRef,\n\tignoreMarkerPosition,\n\tvalue: controlPoints,\n\tonChange,\n\tonStartControlPointChange,\n\tonStopControlPointChange,\n\t__experimentalIsRenderedInSidebar,\n}: ControlPointsProps ) {\n\tconst controlPointMoveStateRef = useRef< ControlPointMoveState >();\n\n\tconst onMouseMove = ( event: MouseEvent ) => {\n\t\tif (\n\t\t\tcontrolPointMoveStateRef.current === undefined ||\n\t\t\tgradientPickerDomRef.current === null\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst relativePosition = getHorizontalRelativeGradientPosition(\n\t\t\tevent.clientX,\n\t\t\tgradientPickerDomRef.current\n\t\t);\n\n\t\tconst { initialPosition, index, significantMoveHappened } =\n\t\t\tcontrolPointMoveStateRef.current;\n\n\t\tif (\n\t\t\t! significantMoveHappened &&\n\t\t\tMath.abs( initialPosition - relativePosition ) >=\n\t\t\t\tMINIMUM_SIGNIFICANT_MOVE\n\t\t) {\n\t\t\tcontrolPointMoveStateRef.current.significantMoveHappened = true;\n\t\t}\n\n\t\tonChange(\n\t\t\tupdateControlPointPosition( controlPoints, index, relativePosition )\n\t\t);\n\t};\n\n\tconst cleanEventListeners = () => {\n\t\tif (\n\t\t\twindow &&\n\t\t\twindow.removeEventListener &&\n\t\t\tcontrolPointMoveStateRef.current &&\n\t\t\tcontrolPointMoveStateRef.current.listenersActivated\n\t\t) {\n\t\t\twindow.removeEventListener( 'mousemove', onMouseMove );\n\t\t\twindow.removeEventListener( 'mouseup', cleanEventListeners );\n\t\t\tonStopControlPointChange();\n\t\t\tcontrolPointMoveStateRef.current.listenersActivated = false;\n\t\t}\n\t};\n\n\t// Adding `cleanEventListeners` to the dependency array below requires the function itself to be wrapped in a `useCallback`\n\t// This memoization would prevent the event listeners from being properly cleaned.\n\t// Instead, we'll pass a ref to the function in our `useEffect` so `cleanEventListeners` itself is no longer a dependency.\n\tconst cleanEventListenersRef = useRef< () => void >();\n\tcleanEventListenersRef.current = cleanEventListeners;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tcleanEventListenersRef.current?.();\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t{ controlPoints.map( ( point, index ) => {\n\t\t\t\tconst initialPosition = point?.position;\n\t\t\t\treturn (\n\t\t\t\t\tignoreMarkerPosition !== initialPosition && (\n\t\t\t\t\t\t<GradientColorPickerDropdown\n\t\t\t\t\t\t\tisRenderedInSidebar={\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tonClose={ onStopControlPointChange }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<ControlPointButton\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current &&\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current\n\t\t\t\t\t\t\t\t\t\t\t\t.significantMoveHappened\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\t\t\t\t\tonStopControlPointChange();\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonMouseDown={ () => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\twindow &&\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tcontrolPointMoveStateRef.current = {\n\t\t\t\t\t\t\t\t\t\t\t\tinitialPosition,\n\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\tsignificantMoveHappened: false,\n\t\t\t\t\t\t\t\t\t\t\t\tlistenersActivated: true,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\tonStartControlPointChange();\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\t\t'mousemove',\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseMove\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t\t\t\t\t\t\tcleanEventListeners\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\t\t\tif ( event.code === 'ArrowLeft' ) {\n\t\t\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpoint.position -\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\tevent.code === 'ArrowRight'\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t// Stop propagation of the key press event to avoid focus moving\n\t\t\t\t\t\t\t\t\t\t\t// to another editor area.\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointPosition(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclampPercent(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpoint.position +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKEYBOARD_CONTROL_POINT_VARIATION\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\t\t\tposition={ point.position }\n\t\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\t\t\t\t\tcolor={ point.color }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\tupdateControlPointColor(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcolord(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcolor\n\t\t\t\t\t\t\t\t\t\t\t\t\t).toRgbString()\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ ! disableRemove &&\n\t\t\t\t\t\t\t\t\t\tcontrolPoints.length > 2 && (\n\t\t\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-custom-gradient-picker__remove-control-point-wrapper\"\n\t\t\t\t\t\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tremoveControlPoint(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove Control Point'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownContentWrapper>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tleft: `${ point.position }%`,\n\t\t\t\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nfunction InsertPoint( {\n\tvalue: controlPoints,\n\tonChange,\n\tonOpenInserter,\n\tonCloseInserter,\n\tinsertPosition,\n\tdisableAlpha,\n\t__experimentalIsRenderedInSidebar,\n}: InsertPointProps ) {\n\tconst [ alreadyInsertedPoint, setAlreadyInsertedPoint ] = useState( false );\n\treturn (\n\t\t<GradientColorPickerDropdown\n\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\tclassName=\"components-custom-gradient-picker__inserter\"\n\t\t\tonClose={ () => {\n\t\t\t\tonCloseInserter();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isOpen ) {\n\t\t\t\t\t\t\tonCloseInserter();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetAlreadyInsertedPoint( false );\n\t\t\t\t\t\t\tonOpenInserter();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t} }\n\t\t\t\t\tclassName=\"components-custom-gradient-picker__insert-point-dropdown\"\n\t\t\t\t\ticon={ plus }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<ColorPicker\n\t\t\t\t\t\tenableAlpha={ ! disableAlpha }\n\t\t\t\t\t\tonChange={ ( color ) => {\n\t\t\t\t\t\t\tif ( ! alreadyInsertedPoint ) {\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\taddControlPoint(\n\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tsetAlreadyInsertedPoint( true );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\tupdateControlPointColorByPosition(\n\t\t\t\t\t\t\t\t\t\tcontrolPoints,\n\t\t\t\t\t\t\t\t\t\tinsertPosition,\n\t\t\t\t\t\t\t\t\t\tcolord( color ).toRgbString()\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t\tstyle={\n\t\t\t\tinsertPosition !== null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tleft: `${ insertPosition }%`,\n\t\t\t\t\t\t\ttransform: 'translateX( -50% )',\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t);\n}\nControlPoints.InsertPoint = InsertPoint;\n\nexport default Control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,WAAW;QACXC,WAAW,EAAG,CAAE/C,YAAc;QAC9BK,QAAQ,EAAKlC,KAAK,IAAM;UACvB,IAAK,CAAE4F,oBAAoB,EAAG;YAC7B1D,QAAQ,CACP,IAAA+D,sBAAe,EACdhE,aAAa,EACb0D,cAAc,EACd,IAAAb,cAAM,EAAE9E,KAAM,CAAC,CAAC+E,WAAW,CAAC,CAC7B,CACD,CAAC;YACDc,uBAAuB,CAAE,IAAK,CAAC;UAChC,CAAC,MAAM;YACN3D,QAAQ,CACP,IAAAgE,wCAAiC,EAChCjE,aAAa,EACb0D,cAAc,EACd,IAAAb,cAAM,EAAE9E,KAAM,CAAC,CAAC+E,WAAW,CAAC,CAC7B,CACD,CAAC;UACF;QACD;MAAG,CACH;IAAC,CACqB,CACtB;IACHM,KAAK,EACJM,cAAc,KAAK,IAAI,GACpB;MACAL,IAAI,EAAE,GAAIK,cAAc,GAAI;MAC5BJ,SAAS,EAAE;IACX,CAAC,GACD5C;EACH,CACD,CAAC;AAEJ;AACAhB,aAAa,CAAC6D,WAAW,GAAGA,WAAW;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAA3F,OAAA,GAEzBkB,aAAa","ignoreList":[]}
@@ -35,9 +35,9 @@ function defaultRenderSelectedValue(value) {
35
35
  return (0, _i18n.__)('Select an item');
36
36
  }
37
37
  if (Array.isArray(value)) {
38
- return value.length === 1 ? value[0] :
39
- // translators: %s: number of items selected (it will always be 2 or more items)
40
- (0, _i18n.sprintf)((0, _i18n.__)('%s items selected'), value.length);
38
+ return value.length === 1 ? value[0] : (0, _i18n.sprintf)(
39
+ // translators: %d: number of items selected (it will always be 2 or more items)
40
+ (0, _i18n._n)('%d item selected', '%d items selected', value.length), value.length);
41
41
  }
42
42
  return value;
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Ariakit","_interopRequireWildcard","require","_element","_i18n","_","Styled","_inputBase","_interopRequireDefault","_chevronDown","_baseControl","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CustomSelectContext","exports","createContext","undefined","defaultRenderSelectedValue","value","isValueEmpty","Array","isArray","length","__","sprintf","CustomSelectButton","renderSelectedValue","size","store","restProps","currentValue","useStoreState","computedRenderSelectedValue","useMemo","jsx","Select","hasCustomRenderProp","children","_CustomSelect","props","hideLabelFromVision","label","className","isLegacy","onSelectPopoverKeyDown","useCallback","stopPropagation","contextValue","jsxs","SelectLabel","render","VisuallyHidden","VisualLabel","as","__next40pxDefaultSize","suffix","showOnKeyDown","SelectPopover","gutter","sameWidth","slide","onKeyDown","flip","Provider","_default"],"sources":["@wordpress/components/src/custom-select-control-v2/custom-select.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useCallback, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '..';\nimport * as Styled from './styles';\nimport type {\n\tCustomSelectContext as CustomSelectContextType,\n\tCustomSelectStore,\n\tCustomSelectButtonProps,\n\tCustomSelectButtonSize,\n\t_CustomSelectInternalProps,\n\t_CustomSelectProps,\n} from './types';\nimport InputBase from '../input-control/input-base';\nimport SelectControlChevronDown from '../select-control/chevron-down';\nimport BaseControl from '../base-control';\n\nexport const CustomSelectContext =\n\tcreateContext< CustomSelectContextType >( undefined );\n\nfunction defaultRenderSelectedValue(\n\tvalue: CustomSelectButtonProps[ 'value' ]\n) {\n\tconst isValueEmpty = Array.isArray( value )\n\t\t? value.length === 0\n\t\t: value === undefined || value === null;\n\n\tif ( isValueEmpty ) {\n\t\treturn __( 'Select an item' );\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.length === 1\n\t\t\t? value[ 0 ]\n\t\t\t: // translators: %s: number of items selected (it will always be 2 or more items)\n\t\t\t sprintf( __( '%s items selected' ), value.length );\n\t}\n\n\treturn value;\n}\n\nconst CustomSelectButton = ( {\n\trenderSelectedValue,\n\tsize = 'default',\n\tstore,\n\t...restProps\n}: Omit<\n\tReact.ComponentProps< typeof Ariakit.Select > &\n\t\tCustomSelectButtonProps &\n\t\tCustomSelectButtonSize &\n\t\tCustomSelectStore,\n\t'onChange'\n> ) => {\n\tconst { value: currentValue } = Ariakit.useStoreState( store );\n\n\tconst computedRenderSelectedValue = useMemo(\n\t\t() => renderSelectedValue ?? defaultRenderSelectedValue,\n\t\t[ renderSelectedValue ]\n\t);\n\n\treturn (\n\t\t<Styled.Select\n\t\t\t{ ...restProps }\n\t\t\tsize={ size }\n\t\t\thasCustomRenderProp={ !! renderSelectedValue }\n\t\t\tstore={ store }\n\t\t>\n\t\t\t{ computedRenderSelectedValue( currentValue ) }\n\t\t</Styled.Select>\n\t);\n};\n\nfunction _CustomSelect(\n\tprops: _CustomSelectInternalProps &\n\t\t_CustomSelectProps &\n\t\tCustomSelectStore &\n\t\tCustomSelectButtonSize\n) {\n\tconst {\n\t\tchildren,\n\t\thideLabelFromVision = false,\n\t\tlabel,\n\t\tsize,\n\t\tstore,\n\t\tclassName,\n\t\tisLegacy = false,\n\t\t...restProps\n\t} = props;\n\n\tconst onSelectPopoverKeyDown: React.KeyboardEventHandler< HTMLDivElement > =\n\t\tuseCallback(\n\t\t\t( e ) => {\n\t\t\t\tif ( isLegacy ) {\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ isLegacy ]\n\t\t);\n\n\tconst contextValue = useMemo( () => ( { store, size } ), [ store, size ] );\n\n\treturn (\n\t\t// Where should `restProps` be forwarded to?\n\t\t<div className={ className }>\n\t\t\t<Ariakit.SelectLabel\n\t\t\t\tstore={ store }\n\t\t\t\trender={\n\t\t\t\t\thideLabelFromVision ? (\n\t\t\t\t\t\t// @ts-expect-error `children` are passed via the render prop\n\t\t\t\t\t\t<VisuallyHidden />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// @ts-expect-error `children` are passed via the render prop\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"div\" />\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</Ariakit.SelectLabel>\n\t\t\t<InputBase\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ <SelectControlChevronDown /> }\n\t\t\t>\n\t\t\t\t<CustomSelectButton\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tsize={ size }\n\t\t\t\t\tstore={ store }\n\t\t\t\t\t// Match legacy behavior (move selection rather than open the popover)\n\t\t\t\t\tshowOnKeyDown={ ! isLegacy }\n\t\t\t\t/>\n\t\t\t\t<Styled.SelectPopover\n\t\t\t\t\tgutter={ 12 }\n\t\t\t\t\tstore={ store }\n\t\t\t\t\tsameWidth\n\t\t\t\t\tslide={ false }\n\t\t\t\t\tonKeyDown={ onSelectPopoverKeyDown }\n\t\t\t\t\t// Match legacy behavior\n\t\t\t\t\tflip={ ! isLegacy }\n\t\t\t\t>\n\t\t\t\t\t<CustomSelectContext.Provider value={ contextValue }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</CustomSelectContext.Provider>\n\t\t\t\t</Styled.SelectPopover>\n\t\t\t</InputBase>\n\t\t</div>\n\t);\n}\n\nexport default _CustomSelect;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AASA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,YAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,YAAA,GAAAF,sBAAA,CAAAN,OAAA;AAA0C,IAAAS,WAAA,GAAAT,OAAA;AAAA,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CAC5B,CAAC,eACF,IAAAnD,WAAA,CAAA0C,GAAA,EAAC/C,MAAM,CAACsE,aAAa;UACpBC,MAAM,EAAG,EAAI;UACb9B,KAAK,EAAGA,KAAO;UACf+B,SAAS;UACTC,KAAK,EAAG,KAAO;UACfC,SAAS,EAAGjB;UACZ;UAAA;UACAkB,IAAI,EAAG,CAAEnB,QAAU;UAAAN,QAAA,eAEnB,IAAA7C,WAAA,CAAA0C,GAAA,EAACrB,mBAAmB,CAACkD,QAAQ;YAAC7C,KAAK,EAAG6B,YAAc;YAAAV,QAAA,EACjDA;UAAQ,CACmB;QAAC,CACV,CAAC;MAAA,CACb,CAAC;IAAA,CACR;EAAC;AAER;AAAC,IAAA2B,QAAA,GAAAlD,OAAA,CAAAf,OAAA,GAEcuC,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["Ariakit","_interopRequireWildcard","require","_element","_i18n","_","Styled","_inputBase","_interopRequireDefault","_chevronDown","_baseControl","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CustomSelectContext","exports","createContext","undefined","defaultRenderSelectedValue","value","isValueEmpty","Array","isArray","length","__","sprintf","_n","CustomSelectButton","renderSelectedValue","size","store","restProps","currentValue","useStoreState","computedRenderSelectedValue","useMemo","jsx","Select","hasCustomRenderProp","children","_CustomSelect","props","hideLabelFromVision","label","className","isLegacy","onSelectPopoverKeyDown","useCallback","stopPropagation","contextValue","jsxs","SelectLabel","render","VisuallyHidden","VisualLabel","as","__next40pxDefaultSize","suffix","showOnKeyDown","SelectPopover","gutter","sameWidth","slide","onKeyDown","flip","Provider","_default"],"sources":["@wordpress/components/src/custom-select-control-v2/custom-select.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useCallback, useMemo } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '..';\nimport * as Styled from './styles';\nimport type {\n\tCustomSelectContext as CustomSelectContextType,\n\tCustomSelectStore,\n\tCustomSelectButtonProps,\n\tCustomSelectButtonSize,\n\t_CustomSelectInternalProps,\n\t_CustomSelectProps,\n} from './types';\nimport InputBase from '../input-control/input-base';\nimport SelectControlChevronDown from '../select-control/chevron-down';\nimport BaseControl from '../base-control';\n\nexport const CustomSelectContext =\n\tcreateContext< CustomSelectContextType >( undefined );\n\nfunction defaultRenderSelectedValue(\n\tvalue: CustomSelectButtonProps[ 'value' ]\n) {\n\tconst isValueEmpty = Array.isArray( value )\n\t\t? value.length === 0\n\t\t: value === undefined || value === null;\n\n\tif ( isValueEmpty ) {\n\t\treturn __( 'Select an item' );\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.length === 1\n\t\t\t? value[ 0 ]\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %d: number of items selected (it will always be 2 or more items)\n\t\t\t\t\t_n( '%d item selected', '%d items selected', value.length ),\n\t\t\t\t\tvalue.length\n\t\t\t );\n\t}\n\n\treturn value;\n}\n\nconst CustomSelectButton = ( {\n\trenderSelectedValue,\n\tsize = 'default',\n\tstore,\n\t...restProps\n}: Omit<\n\tReact.ComponentProps< typeof Ariakit.Select > &\n\t\tCustomSelectButtonProps &\n\t\tCustomSelectButtonSize &\n\t\tCustomSelectStore,\n\t'onChange'\n> ) => {\n\tconst { value: currentValue } = Ariakit.useStoreState( store );\n\n\tconst computedRenderSelectedValue = useMemo(\n\t\t() => renderSelectedValue ?? defaultRenderSelectedValue,\n\t\t[ renderSelectedValue ]\n\t);\n\n\treturn (\n\t\t<Styled.Select\n\t\t\t{ ...restProps }\n\t\t\tsize={ size }\n\t\t\thasCustomRenderProp={ !! renderSelectedValue }\n\t\t\tstore={ store }\n\t\t>\n\t\t\t{ computedRenderSelectedValue( currentValue ) }\n\t\t</Styled.Select>\n\t);\n};\n\nfunction _CustomSelect(\n\tprops: _CustomSelectInternalProps &\n\t\t_CustomSelectProps &\n\t\tCustomSelectStore &\n\t\tCustomSelectButtonSize\n) {\n\tconst {\n\t\tchildren,\n\t\thideLabelFromVision = false,\n\t\tlabel,\n\t\tsize,\n\t\tstore,\n\t\tclassName,\n\t\tisLegacy = false,\n\t\t...restProps\n\t} = props;\n\n\tconst onSelectPopoverKeyDown: React.KeyboardEventHandler< HTMLDivElement > =\n\t\tuseCallback(\n\t\t\t( e ) => {\n\t\t\t\tif ( isLegacy ) {\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ isLegacy ]\n\t\t);\n\n\tconst contextValue = useMemo( () => ( { store, size } ), [ store, size ] );\n\n\treturn (\n\t\t// Where should `restProps` be forwarded to?\n\t\t<div className={ className }>\n\t\t\t<Ariakit.SelectLabel\n\t\t\t\tstore={ store }\n\t\t\t\trender={\n\t\t\t\t\thideLabelFromVision ? (\n\t\t\t\t\t\t// @ts-expect-error `children` are passed via the render prop\n\t\t\t\t\t\t<VisuallyHidden />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// @ts-expect-error `children` are passed via the render prop\n\t\t\t\t\t\t<BaseControl.VisualLabel as=\"div\" />\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</Ariakit.SelectLabel>\n\t\t\t<InputBase\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ <SelectControlChevronDown /> }\n\t\t\t>\n\t\t\t\t<CustomSelectButton\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tsize={ size }\n\t\t\t\t\tstore={ store }\n\t\t\t\t\t// Match legacy behavior (move selection rather than open the popover)\n\t\t\t\t\tshowOnKeyDown={ ! isLegacy }\n\t\t\t\t/>\n\t\t\t\t<Styled.SelectPopover\n\t\t\t\t\tgutter={ 12 }\n\t\t\t\t\tstore={ store }\n\t\t\t\t\tsameWidth\n\t\t\t\t\tslide={ false }\n\t\t\t\t\tonKeyDown={ onSelectPopoverKeyDown }\n\t\t\t\t\t// Match legacy behavior\n\t\t\t\t\tflip={ ! isLegacy }\n\t\t\t\t>\n\t\t\t\t\t<CustomSelectContext.Provider value={ contextValue }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</CustomSelectContext.Provider>\n\t\t\t\t</Styled.SelectPopover>\n\t\t\t</InputBase>\n\t\t</div>\n\t);\n}\n\nexport default _CustomSelect;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AASA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,YAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,YAAA,GAAAF,sBAAA,CAAAN,OAAA;AAA0C,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAU,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAA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}
@@ -236,7 +236,7 @@ function getDayLabel(date, isSelected, numEvents) {
236
236
  (0, _i18n._n)('%1$s. Selected. There is %2$d event', '%1$s. Selected. There are %2$d events', numEvents), localizedDate, numEvents);
237
237
  } else if (isSelected) {
238
238
  return (0, _i18n.sprintf)(
239
- // translators: %s: The calendar date.
239
+ // translators: 1: The calendar date.
240
240
  (0, _i18n.__)('%1$s. Selected'), localizedDate);
241
241
  } else if (numEvents > 0) {
242
242
  return (0, _i18n.sprintf)(