@eightshift/ui-components 4.0.0 → 5.0.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 (144) hide show
  1. package/package.json +101 -101
  2. package/dist/Button-CvzGKGCo.js +0 -185
  3. package/dist/Collection-ddre1L5v.js +0 -2332
  4. package/dist/Color-MV5kBVXr.js +0 -2452
  5. package/dist/ColorSwatch-BqQfVu4L.js +0 -64
  6. package/dist/ComboBox-jQ-dk95U.js +0 -1906
  7. package/dist/Dialog-DX1aiYyE.js +0 -2300
  8. package/dist/FieldError-52GVSGgC.js +0 -42
  9. package/dist/FocusScope-Cri5BFRz.js +0 -831
  10. package/dist/Form-Cq3fu75_.js +0 -5
  11. package/dist/Group-_emcIVxI.js +0 -48
  12. package/dist/Heading-B2153VXe.js +0 -16
  13. package/dist/Hidden-rE6uR-lr.js +0 -41
  14. package/dist/Input-BxpFEIXV.js +0 -133
  15. package/dist/Label-icmbmNdI.js +0 -17
  16. package/dist/List-BYNHbol3.js +0 -593
  17. package/dist/ListBox-mJ4nQaL7.js +0 -581
  18. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  19. package/dist/OverlayArrow-BB0CWwdq.js +0 -629
  20. package/dist/RSPContexts-2lR5GG9p.js +0 -14
  21. package/dist/Select-aab027f3.esm--EmXjiL3.js +0 -2469
  22. package/dist/Separator-D9moUgP8.js +0 -322
  23. package/dist/Slider-rz2XRMGm.js +0 -853
  24. package/dist/Text-DVSAPY-K.js +0 -16
  25. package/dist/VisuallyHidden-f9zX67a_.js +0 -48
  26. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  27. package/dist/assets/index.css +0 -37
  28. package/dist/assets/style-admin.css +0 -5255
  29. package/dist/assets/style-editor.css +0 -5255
  30. package/dist/assets/style.css +0 -5261
  31. package/dist/assets/wp-font-enhancements.css +0 -8
  32. package/dist/assets/wp-ui-enhancements.css +0 -299
  33. package/dist/components/animated-visibility/animated-visibility.js +0 -105
  34. package/dist/components/base-control/base-control.js +0 -86
  35. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
  36. package/dist/components/button/button.js +0 -387
  37. package/dist/components/checkbox/checkbox.js +0 -320
  38. package/dist/components/color-pickers/color-picker.js +0 -272
  39. package/dist/components/color-pickers/color-swatch.js +0 -58
  40. package/dist/components/color-pickers/gradient-editor.js +0 -534
  41. package/dist/components/color-pickers/solid-color-picker.js +0 -1567
  42. package/dist/components/component-toggle/component-toggle.js +0 -158
  43. package/dist/components/container-panel/container-panel.js +0 -131
  44. package/dist/components/draggable/draggable-context.js +0 -5
  45. package/dist/components/draggable/draggable-handle.js +0 -46
  46. package/dist/components/draggable/draggable.js +0 -6207
  47. package/dist/components/draggable-list/draggable-list-context.js +0 -5
  48. package/dist/components/draggable-list/draggable-list-item.js +0 -77
  49. package/dist/components/draggable-list/draggable-list.js +0 -151
  50. package/dist/components/expandable/expandable.js +0 -342
  51. package/dist/components/index.js +0 -137
  52. package/dist/components/input-field/input-field.js +0 -231
  53. package/dist/components/item-collection/item-collection.js +0 -59
  54. package/dist/components/layout/hstack.js +0 -30
  55. package/dist/components/layout/vstack.js +0 -30
  56. package/dist/components/link-input/link-input.js +0 -293
  57. package/dist/components/matrix-align/matrix-align.js +0 -134
  58. package/dist/components/menu/menu.js +0 -285
  59. package/dist/components/modal/modal.js +0 -305
  60. package/dist/components/notice/notice.js +0 -123
  61. package/dist/components/number-picker/number-picker.js +0 -292
  62. package/dist/components/option-select/option-select.js +0 -264
  63. package/dist/components/options-panel/options-panel.js +0 -158
  64. package/dist/components/placeholders/file-placeholder.js +0 -42
  65. package/dist/components/placeholders/image-placeholder.js +0 -88
  66. package/dist/components/placeholders/media-placeholder.js +0 -63
  67. package/dist/components/popover/popover.js +0 -207
  68. package/dist/components/radio/radio.js +0 -579
  69. package/dist/components/repeater/repeater-context.js +0 -5
  70. package/dist/components/repeater/repeater-item.js +0 -119
  71. package/dist/components/repeater/repeater.js +0 -280
  72. package/dist/components/responsive/mini-responsive.js +0 -498
  73. package/dist/components/responsive/responsive-legacy.js +0 -343
  74. package/dist/components/responsive/responsive.js +0 -580
  75. package/dist/components/responsive-preview/responsive-preview.js +0 -123
  76. package/dist/components/rich-label/rich-label.js +0 -66
  77. package/dist/components/select/async-multi-select.js +0 -157
  78. package/dist/components/select/async-single-select.js +0 -137
  79. package/dist/components/select/custom-select-default-components.js +0 -38
  80. package/dist/components/select/multi-select-components.js +0 -8
  81. package/dist/components/select/multi-select.js +0 -151
  82. package/dist/components/select/react-select-component-wrappers.js +0 -90
  83. package/dist/components/select/shared.js +0 -26
  84. package/dist/components/select/single-select.js +0 -131
  85. package/dist/components/select/styles.js +0 -49
  86. package/dist/components/select/v2/async-select.js +0 -297
  87. package/dist/components/select/v2/shared.js +0 -24
  88. package/dist/components/select/v2/single-select.js +0 -990
  89. package/dist/components/slider/column-config-slider.js +0 -210
  90. package/dist/components/slider/slider.js +0 -343
  91. package/dist/components/slider/utils.js +0 -84
  92. package/dist/components/spacer/spacer.js +0 -97
  93. package/dist/components/tabs/tabs.js +0 -702
  94. package/dist/components/toggle/switch.js +0 -155
  95. package/dist/components/toggle/toggle.js +0 -64
  96. package/dist/components/toggle-button/toggle-button.js +0 -324
  97. package/dist/components/tooltip/tooltip.js +0 -525
  98. package/dist/context-D2KUdwNL.js +0 -92
  99. package/dist/default-i18n-CT_oS1Fy.js +0 -922
  100. package/dist/filterDOMProps-EDDcM64A.js +0 -28
  101. package/dist/icons/block-icon.js +0 -42
  102. package/dist/icons/generic-color-swatch.js +0 -113
  103. package/dist/icons/icons.js +0 -30371
  104. package/dist/icons/index.js +0 -11
  105. package/dist/icons/jsx-svg.js +0 -50
  106. package/dist/index-641ee5b8.esm-BPz6U6sJ.js +0 -3137
  107. package/dist/index-BKGQ6jGS.js +0 -44
  108. package/dist/index-BYHhzLf-.js +0 -444
  109. package/dist/index.js +0 -139
  110. package/dist/lite-DVmmD_-j.js +0 -7
  111. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  112. package/dist/multi-select-components-BlZZoNXC.js +0 -3744
  113. package/dist/number-GajL10e1.js +0 -36
  114. package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
  115. package/dist/react-select-async.esm-CwUoej5h.js +0 -107
  116. package/dist/react-select.esm-DcwYxadV.js +0 -15
  117. package/dist/style-admin.js +0 -1
  118. package/dist/style-editor.js +0 -1
  119. package/dist/style.js +0 -1
  120. package/dist/textSelection-0UUS8Yfg.js +0 -46
  121. package/dist/useButton-BpOKDWEN.js +0 -71
  122. package/dist/useEvent-B0b-6KBr.js +0 -23
  123. package/dist/useFocusRing-CV5l3lf6.js +0 -107
  124. package/dist/useFormReset-C5OggHsw.js +0 -22
  125. package/dist/useFormValidation-DhDNSjws.js +0 -224
  126. package/dist/useHover-DwDr6ozG.js +0 -900
  127. package/dist/useLabel-D7HkNEHT.js +0 -27
  128. package/dist/useLabels-D8cxd1Z8.js +0 -23
  129. package/dist/useListState-UGlN5-7P.js +0 -161
  130. package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
  131. package/dist/useNumberField-CEAj7Mrj.js +0 -1204
  132. package/dist/useNumberFormatter-321rAb4J.js +0 -13
  133. package/dist/usePress-DNW8qpY6.js +0 -664
  134. package/dist/useSingleSelectListState-DC0wWTUM.js +0 -38
  135. package/dist/useToggle-BrpmSOB-.js +0 -59
  136. package/dist/useToggleState-CmQX3SoX.js +0 -19
  137. package/dist/utilities/array-helpers.js +0 -56
  138. package/dist/utilities/debounce-throttle.js +0 -123
  139. package/dist/utilities/es-dash.js +0 -376
  140. package/dist/utilities/index.js +0 -27
  141. package/dist/utilities/text-helpers.js +0 -136
  142. package/dist/utils-DkCSC521.js +0 -370
  143. package/dist/wp/wp-font-enhancements.js +0 -1
  144. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,293 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-CvzGKGCo.js";
3
- import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66, a as $d01f2c01039c0eec$export$72b9695b8216309a } from "../../ComboBox-jQ-dk95U.js";
4
- import { $ as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-_emcIVxI.js";
5
- import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-BxpFEIXV.js";
6
- import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-icmbmNdI.js";
7
- import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../ListBox-mJ4nQaL7.js";
8
- import { $ as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../Dialog-DX1aiYyE.js";
9
- import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
10
- import { icons } from "../../icons/icons.js";
11
- import { c as clsx } from "../../lite-DVmmD_-j.js";
12
- import { useRef, useState, useEffect, cloneElement } from "react";
13
- import { Spacer } from "../spacer/spacer.js";
14
- import { Tooltip } from "../tooltip/tooltip.js";
15
- import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
16
- import { BaseControl } from "../base-control/base-control.js";
17
- import { RichLabel } from "../rich-label/rich-label.js";
18
- /**
19
- * Component that allows URL selection, with a suggestionList of suggestions and type-to-search.
20
- *
21
- * @component
22
- * @param {Object} props - Component props.
23
- * @param {string} [props.url] - The current URL.
24
- * @param {Function} [props.onChange] - Function to run when the URL changes.
25
- * @param {string} [props.label] - Label to display.
26
- * @param {string} [props.subtitle] - Subtitle to display.
27
- * @param {string} [props.help] - Help text to display below the input.
28
- * @param {string} [props.placeholder] - Placeholder to show in the input field.
29
- * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
30
- * @param {JSX.Element} [props.icon=icons.globe] - Icon to display in the label.
31
- * @param {JSX.Element} [props.removeIcon=icons.clearAlt] - Icon to display in the input's clear button.
32
- * @param {boolean} [props.disabled=false] - If `true`, the input is disabled.
33
- * @param {Function} [props.fetchSuggestions] - A function that fetches suggestions based on the input value.
34
- * @param {string} [props.className] - Classes to pass to the input field.
35
- * @param {number} [props.inputDebounceDelay=500] - The delay in milliseconds before the input value is considered final.
36
- * @param {Function} [props.suggestionTypeIconOverride] - Allows overriding the default icon for the suggestion type, e.g. when using CPTs. Should be in the format: `(type) => icon or React component`.
37
- * @param {boolean} [props.showSuggestionsWhenEmpty] - If `true`, the suggestion list will be shown when down arrow is pressed even the input is empty.
38
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
39
- *
40
- * @returns {JSX.Element} The LinkInput component.
41
- *
42
- * @example
43
- * <LinkInput
44
- * url={url}
45
- * onChange={setUrl}
46
- * />
47
- *
48
- * @preserve
49
- */
50
- const LinkInput = (props) => {
51
- var _a;
52
- const {
53
- url = "",
54
- onChange,
55
- label = __("Link", "eightshift-ui-components"),
56
- subtitle,
57
- help,
58
- actions,
59
- placeholder = __("Type to search or enter URL", "eightshift-ui-components"),
60
- icon = icons.globe,
61
- removeIcon = icons.clearAlt,
62
- disabled = false,
63
- suggestionTypeIconOverride,
64
- showSuggestionsWhenEmpty,
65
- fetchSuggestions,
66
- className,
67
- hidden
68
- } = props;
69
- const canShowSuggestions = typeof fetchSuggestions !== "undefined";
70
- const triggerRef = useRef(null);
71
- const suggestionList = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
72
- initialFilterText: url,
73
- async load({ signal, filterText }) {
74
- if (!canShowSuggestions) {
75
- return {
76
- items: []
77
- };
78
- }
79
- const items = await fetchSuggestions(filterText, signal);
80
- return {
81
- items: items ?? []
82
- };
83
- }
84
- });
85
- const [shouldShowSuggestions, setShouldShowSuggestions] = useState(false);
86
- useEffect(() => {
87
- suggestionList.setFilterText(url);
88
- if (!canShowSuggestions) {
89
- setShouldShowSuggestions(false);
90
- return;
91
- }
92
- if (!showSuggestionsWhenEmpty && url.length < 1) {
93
- setShouldShowSuggestions(false);
94
- return;
95
- }
96
- setShouldShowSuggestions(
97
- !(showSuggestionsWhenEmpty !== true && url.trim().length < 4 || url.startsWith("#") || url.startsWith(":") || url.startsWith("mailto") || url.startsWith("tel") || url.startsWith("http") || url.startsWith("www"))
98
- );
99
- }, [url]);
100
- if (hidden) {
101
- return null;
102
- }
103
- return /* @__PURE__ */ jsxs(
104
- $d01f2c01039c0eec$export$72b9695b8216309a,
105
- {
106
- items: suggestionList.items,
107
- inputValue: suggestionList.filterText,
108
- onInputChange: (value) => {
109
- onChange({ url: value, isAnchor: value == null ? void 0 : value.includes("#") });
110
- suggestionList.setFilterText(value);
111
- },
112
- allowsCustomValue: true,
113
- allowsEmptyCollection: canShowSuggestions && shouldShowSuggestions,
114
- isDisabled: disabled,
115
- children: [
116
- /* @__PURE__ */ jsx(
117
- BaseControl,
118
- {
119
- as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
120
- icon,
121
- label,
122
- subtitle,
123
- actions,
124
- labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
125
- help,
126
- children: /* @__PURE__ */ jsxs(
127
- $a049562f99e7db0e$export$eb2fcfdbd7ba97d4,
128
- {
129
- className: "es:relative",
130
- ref: triggerRef,
131
- children: [
132
- /* @__PURE__ */ jsx(
133
- $3985021b0ad6602f$export$f5b8910cec6cf069,
134
- {
135
- placeholder: disabled ? null : placeholder,
136
- className: clsx(
137
- "es:min-h-10 es:w-full es:rounded-t-lg es:border es:border-secondary-300 es:py-2 es:pl-2 es:pr-1 es:text-sm es:shadow-xs es:transition es:selection:bg-accent-500/20 es:selection:text-accent-950",
138
- "es:any-focus:outline-hidden",
139
- "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
140
- "es:focus-visible:border-accent-500",
141
- "es:inset-ring es:inset-ring-secondary-100",
142
- "es:disabled:shadow-none! es:disabled:border-secondary-200 es:disabled:bg-secondary-50 es:disabled:text-secondary-500 es:disabled:cursor-default es:readonly:bg-secondary-50",
143
- !suggestionList.isLoading && "es:aria-[expanded=false]:rounded-b-lg",
144
- suggestionList.isLoading && "es:rounded-b-lg",
145
- (url == null ? void 0 : url.length) > 0 && "es:pr-10",
146
- className
147
- )
148
- }
149
- ),
150
- /* @__PURE__ */ jsx(
151
- AnimatedVisibility,
152
- {
153
- visible: !disabled && (url == null ? void 0 : url.length) > 0,
154
- className: "es:absolute es:inset-y-1 es:right-1",
155
- transition: "fade",
156
- children: /* @__PURE__ */ jsxs(
157
- $d2b4bc8c273e7be6$export$353f5b6fc5456de1,
158
- {
159
- slot: null,
160
- onPress: () => {
161
- suggestionList.setFilterText("");
162
- onChange({ url: void 0, isAnchor: false });
163
- },
164
- className: "es:any-focus:outline-hidden",
165
- children: [
166
- !(shouldShowSuggestions && suggestionList.isLoading) && /* @__PURE__ */ jsx(Tooltip, { text: __("Clear", "eightshift-ui-components"), children: /* @__PURE__ */ jsx(
167
- "div",
168
- {
169
- className: clsx(
170
- "es:flex es:size-8 es:items-center es:justify-center es:rounded es:bg-white/85 es:text-secondary-600 es:backdrop-blur es:transition es:cursor-pointer",
171
- "es:hover:bg-red-600/5 es:hover:text-red-600",
172
- "es:icon:size-6"
173
- ),
174
- children: removeIcon
175
- }
176
- ) }),
177
- shouldShowSuggestions && suggestionList.isLoading && /* @__PURE__ */ jsx("div", { className: "es:p-1.5", children: cloneElement(icons.loader, { className: "es:text-accent-600! es:stroke-2 es:motion-preset-spin es:motion-duration-1500" }) })
178
- ]
179
- }
180
- )
181
- }
182
- )
183
- ]
184
- }
185
- )
186
- }
187
- ),
188
- canShowSuggestions && shouldShowSuggestions && !suggestionList.isLoading && /* @__PURE__ */ jsxs(
189
- $07b14b47974efb58$export$5b6b19405a83ff9d,
190
- {
191
- "aria-label": __("URL suggestions", "eightshift-ui-components"),
192
- className: ({ isEntering, isExiting }) => clsx(
193
- "es:rounded-b-lg es:border es:border-secondary-300 es:bg-white es:shadow-lg es:outline-hidden",
194
- isEntering && "es:not-motion-reduce:motion-preset-slide-down-sm es:motion-reduce:motion-preset-fade es:motion-duration-300",
195
- isExiting && "es:not-motion-reduce:motion-translate-y-out-[-2.5%] es:motion-opacity-out-0 es:motion-duration-200",
196
- !shouldShowSuggestions && suggestionList.items.length < 1 && "es:invisible"
197
- ),
198
- offset: -2,
199
- style: {
200
- width: `${(_a = triggerRef.current) == null ? void 0 : _a.offsetWidth}px`
201
- },
202
- children: [
203
- shouldShowSuggestions && !suggestionList.isLoading && suggestionList.items.length === 0 && /* @__PURE__ */ jsx(
204
- RichLabel,
205
- {
206
- icon: icons.searchEmpty,
207
- label: __("No results", "eightshift-ui-components"),
208
- subtitle: __("Try a different search term.", "eightshift-ui-components"),
209
- className: "es:min-h-12 es:p-2"
210
- }
211
- ),
212
- !suggestionList.isLoading && suggestionList.items.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
213
- /* @__PURE__ */ jsx($eed445e0843c11d0$export$41f133550aa26f48, { className: "es:space-y-1 es:p-1", children: (item) => {
214
- const {
215
- label: title,
216
- value: url2,
217
- metadata: { subtype: rawSubtype }
218
- } = item;
219
- const subtype = rawSubtype ?? "page";
220
- let typeIcon = icons.file;
221
- if (subtype.toLowerCase() === "url") {
222
- typeIcon = icons.externalLink;
223
- } else if (subtype.toLowerCase() === "attachment") {
224
- typeIcon = icons.file;
225
- } else if (subtype.toLowerCase() === "category") {
226
- typeIcon = icons.layoutAlt;
227
- } else if (subtype.toLowerCase() === "internal") {
228
- typeIcon = icons.anchor;
229
- } else if (subtype.toLowerCase() === "eightshift-forms") {
230
- typeIcon = icons.formAlt;
231
- }
232
- if (suggestionTypeIconOverride) {
233
- const overrideIcon = suggestionTypeIconOverride(subtype);
234
- if (overrideIcon) {
235
- typeIcon = overrideIcon;
236
- }
237
- }
238
- return /* @__PURE__ */ jsx(
239
- $eed445e0843c11d0$export$a11e76429ed99b4,
240
- {
241
- id: item.value,
242
- className: clsx(
243
- "es:rounded es:p-1 es:text-sm es:transition",
244
- "es:hover:border-secondary-300 es:hover:bg-secondary-100",
245
- "es:focus-visible:border-secondary-300 es:focus-visible:bg-secondary-100",
246
- "selected:es:bg-accent-600/10 selected:es:text-accent-900 selected:focus-visible:es:bg-accent-600/15"
247
- ),
248
- textValue: url2,
249
- children: /* @__PURE__ */ jsx(
250
- RichLabel,
251
- {
252
- icon: typeIcon,
253
- label: title,
254
- subtitle: url2 == null ? void 0 : url2.replace(location.origin, "").replace(/\/$/, ""),
255
- noColor: true
256
- }
257
- )
258
- }
259
- );
260
- } }),
261
- /* @__PURE__ */ jsx(
262
- Spacer,
263
- {
264
- border: true,
265
- className: "es:opacity-40"
266
- }
267
- ),
268
- /* @__PURE__ */ jsxs("div", { className: "es:flex es:flex-wrap es:items-center es:justify-end es:gap-x-3 es:gap-y-1.5 es:p-2 es:text-sm es:text-secondary-500", children: [
269
- /* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
270
- /* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↓" }),
271
- /* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↑" }),
272
- __("Navigate", "eightshift-ui-components")
273
- ] }),
274
- /* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
275
- /* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↵" }),
276
- __("Select", "eightshift-ui-components")
277
- ] }),
278
- /* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
279
- /* @__PURE__ */ jsx("kbd", { className: "es:flex es:h-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:tracking-tighter es:px-0.5 es:text-secondary-600", children: "Esc" }),
280
- __("Hide", "eightshift-ui-components")
281
- ] })
282
- ] })
283
- ] })
284
- ]
285
- }
286
- )
287
- ]
288
- }
289
- );
290
- };
291
- export {
292
- LinkInput
293
- };
@@ -1,134 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
3
- import { icons } from "../../icons/icons.js";
4
- import { pascalCase, upperFirst, camelCase } from "../../utilities/es-dash.js";
5
- import { Menu, MenuItem } from "../menu/menu.js";
6
- import { BaseControl } from "../base-control/base-control.js";
7
- /**
8
- * A component that can provide a 3x3 or a 2x2 grid of positions to pick from.
9
- * Replaces the default Gutenberg `AlignmentMatrixControl`/`BlockAlignmentMatrixControl`/`BlockAlignmentMatrixToolbar`.
10
- *
11
- * @component
12
- * @param {Object} props - Component props.
13
- * @param {MatrixSize} [props.size='3x3'] - The size of the matrix. Can be either '3x3' or '2x2'.
14
- * @param {string} props.value - The currently selected value.
15
- * @param {Function} props.onChange - Function to run when the selection changes.
16
- * @param {string} [props.tooltip='Position'] - Tooltip text to display on the trigger button.
17
- * @param {string} [props.label] - Label to display.
18
- * @param {JSX.Element} [props.icon] - Icon to display within the button.
19
- * @param {string} [props.subtitle] - Subtitle to display.
20
- * @param {string} [props.popoverPosition='bottom'] - The position of the popover.
21
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
22
- *
23
- * @returns {JSX.Element} The MatrixAlign component.
24
- *
25
- * @typedef {'3x3' | '2x2'} MatrixSize
26
- * @typedef {'bottom' | 'bottom left' | 'bottom right' | 'bottom start' | 'bottom end' | 'top' | 'top left' | 'top right' | 'top start' | 'top end' | 'left' | 'left top' | 'left bottom' | 'start' | 'start top' | 'start bottom' | 'right' | 'right top' | 'right bottom' | 'end' | 'end top' | 'end bottom'} PopoverPosition
27
- *
28
- * @example
29
- * <MatrixAlign
30
- * size='3x3'
31
- * value='top left'
32
- * onChange={setAlignment}
33
- * />
34
- *
35
- * @preserve
36
- */
37
- const MatrixAlign = (props) => {
38
- const {
39
- size = "3x3",
40
- value,
41
- onChange,
42
- tooltip = __("Position", "eightshift-ui-components"),
43
- label,
44
- icon,
45
- subtitle,
46
- "aria-label": ariaLabel,
47
- hidden
48
- } = props;
49
- if (hidden) {
50
- return null;
51
- }
52
- const allSizeOptions = [
53
- {
54
- value: "top left",
55
- label: __("Top-left", "eightshift-ui-components"),
56
- availableOn: ["3x3", "2x2"]
57
- },
58
- {
59
- value: "top center",
60
- label: __("Top-center", "eightshift-ui-components"),
61
- availableOn: ["3x3"]
62
- },
63
- {
64
- value: "top right",
65
- label: __("Top-right", "eightshift-ui-components"),
66
- availableOn: ["3x3", "2x2"]
67
- },
68
- {
69
- value: "center left",
70
- label: __("Center-left", "eightshift-ui-components"),
71
- availableOn: ["3x3"]
72
- },
73
- {
74
- value: "center center",
75
- label: __("Center", "eightshift-ui-components"),
76
- availableOn: ["3x3"]
77
- },
78
- {
79
- value: "center right",
80
- label: __("Center-right", "eightshift-ui-components"),
81
- availableOn: ["3x3"]
82
- },
83
- {
84
- value: "bottom left",
85
- label: __("Bottom-left", "eightshift-ui-components"),
86
- availableOn: ["3x3", "2x2"]
87
- },
88
- {
89
- value: "bottom center",
90
- label: __("Bottom-center", "eightshift-ui-components"),
91
- availableOn: ["3x3"]
92
- },
93
- {
94
- value: "bottom right",
95
- label: __("Bottom-right", "eightshift-ui-components"),
96
- availableOn: ["3x3", "2x2"]
97
- }
98
- ];
99
- const sizeOptions = allSizeOptions.filter(({ availableOn }) => availableOn.includes(size));
100
- return /* @__PURE__ */ jsx(
101
- BaseControl,
102
- {
103
- icon,
104
- label,
105
- subtitle,
106
- inline: true,
107
- children: /* @__PURE__ */ jsx(
108
- Menu,
109
- {
110
- triggerIcon: icons[`position${size}${upperFirst(camelCase(value))}`],
111
- triggerProps: { "aria-label": ariaLabel },
112
- tooltip,
113
- keepOpen: true,
114
- children: sizeOptions.map(({ value: itemValue, label: label2 }) => {
115
- var _a;
116
- return /* @__PURE__ */ jsx(
117
- MenuItem,
118
- {
119
- endIcon: (_a = icons) == null ? void 0 : _a[`position${size}${pascalCase(itemValue)}`],
120
- selected: value === itemValue,
121
- onClick: () => onChange(itemValue),
122
- children: label2
123
- },
124
- itemValue
125
- );
126
- })
127
- }
128
- )
129
- }
130
- );
131
- };
132
- export {
133
- MatrixAlign
134
- };