@eightshift/ui-components 5.0.0 → 5.0.1

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/dist/Button-wERNNG0T.js +185 -0
  2. package/dist/Collection-CKsHTyhc.js +2363 -0
  3. package/dist/Color-BhgbJF5x.js +2452 -0
  4. package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
  5. package/dist/ComboBox-D1LPUwWP.js +1906 -0
  6. package/dist/Dialog-D190gMbE.js +2298 -0
  7. package/dist/FieldError-DeUh5Wkw.js +42 -0
  8. package/dist/FocusScope-C-plSxbS.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-C5iZpSAM.js +48 -0
  11. package/dist/Heading-D-Pboe4p.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input--mF4XVE1.js +133 -0
  14. package/dist/Label-Fp6AwSRn.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-4oW9kh3R.js +582 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-BpB9uB_I.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-B88tj5YD.js +323 -0
  22. package/dist/Slider-CyJzC1bp.js +853 -0
  23. package/dist/Text-DRpwWot2.js +16 -0
  24. package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5864 -0
  28. package/dist/assets/style-editor.css +5864 -0
  29. package/dist/assets/style.css +5870 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +377 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +320 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +6979 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +291 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +579 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +991 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +704 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BYWrbm1z.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30371 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-CFozsmNS.js +28321 -0
  107. package/dist/index-wl5606BX.js +44 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-CCcyjiRP.js +46 -0
  120. package/dist/useButton-BOHxkGQF.js +50 -0
  121. package/dist/useEvent-D5o_CqDH.js +23 -0
  122. package/dist/useFocusRing-nMG2uzxS.js +107 -0
  123. package/dist/useFormReset-DlmRL87g.js +22 -0
  124. package/dist/useFormValidation-D0_aaK-e.js +224 -0
  125. package/dist/useHover-VO5tcIli.js +890 -0
  126. package/dist/useLabel-BKH4fVA4.js +27 -0
  127. package/dist/useLabels-ntF3rFY0.js +23 -0
  128. package/dist/useListState-Cq2Nvr-v.js +161 -0
  129. package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
  130. package/dist/useNumberField-C9dmERhP.js +1207 -0
  131. package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
  132. package/dist/usePress-DjNo5790.js +677 -0
  133. package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
  134. package/dist/useToggle-CQaXLe-O.js +59 -0
  135. package/dist/useToggleState-C3DLdez5.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-B94NDG0v.js +370 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +8 -8
@@ -0,0 +1,210 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
3
+ import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-Fp6AwSRn.js";
4
+ import { $ as $6f909507e6374d18$export$472062a354075cee, a as $6f909507e6374d18$export$105594979f116971, b as $6f909507e6374d18$export$2c1b491743890dec, c as $6f909507e6374d18$export$a590f758a961cb5b } from "../../Slider-CyJzC1bp.js";
5
+ import { BaseControl } from "../base-control/base-control.js";
6
+ import { icons } from "../../icons/icons.js";
7
+ import { getColumnConfigOutputText } from "./utils.js";
8
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
9
+ /**
10
+ * A two-thumb slider for selecting a range of columns.
11
+ *
12
+ * @component
13
+ * @param {Object} props - Component props.
14
+ * @param {JSX.Element} [props.icon] - Icon to display within the slider.
15
+ * @param {string} [props.help] - The help text shown below the slider.
16
+ * @param {string} [props.label] - The label of the slider.
17
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display next to the label.
18
+ * @param {string} [props.subtitle] - The subtitle of the slider.
19
+ * @param {Number} [props.columns=12] - Number of columns.
20
+ * @param {boolean} [props.disableWidth] - If `true`, the width thumb is disabled.
21
+ * @param {boolean} [props.disableOffset] - If `true`, the offset thumb is disabled.
22
+ * @param {boolean} [props.showOuterAsGutter] - If `true`, the outer columns are displayed with a special icons instead of the column numbers. Other numbers are offset by 1.
23
+ * @param {Number | Number[]} props.value - The current value of the slider.
24
+ * @param {Function} props.onChange - Function to run when the value changes.
25
+ * @param {Function} props.onChangeEnd - Function to run when the value change ends.
26
+ * @param {boolean} [props.disabled] - If `true`, the slider is disabled.
27
+ * @param {string} [props.labelClassName] - Additional classes to pass to the label.
28
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
29
+ *
30
+ * @returns {JSX.Element} The ColumnConfigSlider component.
31
+ *
32
+ * @example
33
+ * <ColumnConfigSlider
34
+ * label='My slider'
35
+ * value={sliderValue}
36
+ * onChange={setSliderValue}
37
+ * />
38
+ *
39
+ * @preserve
40
+ */
41
+ const ColumnConfigSlider = (props) => {
42
+ const {
43
+ icon,
44
+ help,
45
+ label,
46
+ actions,
47
+ subtitle,
48
+ columns = 12,
49
+ disableWidth,
50
+ disableOffset,
51
+ showOuterAsGutter,
52
+ value,
53
+ onChange,
54
+ onChangeEnd,
55
+ disabled,
56
+ labelClassName,
57
+ hidden,
58
+ ...other
59
+ } = props;
60
+ if (hidden) {
61
+ return null;
62
+ }
63
+ const markerData = [...Array(columns).keys()];
64
+ const thumbLabels = [__("Offset", "eightshift-ui-components"), __("Width", "eightshift-ui-components")];
65
+ return /* @__PURE__ */ jsx(
66
+ $6f909507e6374d18$export$472062a354075cee,
67
+ {
68
+ value,
69
+ onChange,
70
+ minValue: 1,
71
+ maxValue: columns,
72
+ step: 1,
73
+ isDisabled: disabled,
74
+ orientation: "horizontal",
75
+ className: "es:w-full",
76
+ onChangeEnd,
77
+ ...other,
78
+ children: /* @__PURE__ */ jsx(
79
+ BaseControl,
80
+ {
81
+ icon,
82
+ label,
83
+ subtitle,
84
+ help,
85
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
86
+ actions,
87
+ /* @__PURE__ */ jsx(ColumnConfigSliderOutput, { showOuterAsGutter })
88
+ ] }),
89
+ labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
90
+ className: labelClassName,
91
+ controlContainerClassName: "es:flex es:items-center es:gap-2.5 es:space-y-0!",
92
+ children: /* @__PURE__ */ jsx(
93
+ $6f909507e6374d18$export$105594979f116971,
94
+ {
95
+ className: "es:isolate es:grid es:h-10 es:w-full es:grid-rows-1",
96
+ style: { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` },
97
+ children: ({ state }) => {
98
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
99
+ /* @__PURE__ */ jsx(
100
+ "div",
101
+ {
102
+ className: clsx(
103
+ "es:col-span-full es:row-span-1 es:row-start-1 es:h-full es:w-full es:grow es:rounded-lg es:border",
104
+ disabled ? "es:border-secondary-200 es:bg-white" : "es:border-secondary-300 es:bg-secondary-50 es:shadow-xs"
105
+ )
106
+ }
107
+ ),
108
+ markerData.slice(0, -1).map((marker) => /* @__PURE__ */ jsx(
109
+ "div",
110
+ {
111
+ className: clsx(
112
+ "es:row-span-1 es:row-start-1 es:h-full es:w-px es:justify-self-center",
113
+ marker >= value[0] - 1 && marker < value[1] ? "es:bg-accent-700/25" : "es:bg-secondary-300",
114
+ (marker === value[0] - 2 || marker === value[1] - 1) && "es:hidden"
115
+ ),
116
+ style: { gridColumn: `${marker + 1} / span 2` }
117
+ },
118
+ marker
119
+ )),
120
+ /* @__PURE__ */ jsx(
121
+ "div",
122
+ {
123
+ className: clsx(
124
+ "es:pointer-events-none es:col-start-1 es:row-start-1 es:border",
125
+ "es:h-full es:w-full es:self-center es:rounded-lg",
126
+ disabled ? "es:border-secondary-200 es:bg-secondary-50" : "es:border-accent-500 es:bg-accent-500/30"
127
+ ),
128
+ style: {
129
+ gridColumn: `${value[0]} / span ${value[1] - value[0] + 1}`
130
+ }
131
+ }
132
+ ),
133
+ markerData.map((marker, index) => {
134
+ return /* @__PURE__ */ jsxs(
135
+ "span",
136
+ {
137
+ className: clsx(
138
+ "es:row-span-1 es:row-start-1 es:select-none es:place-self-center es:text-xs es:transition-colors",
139
+ "es:inset-y-0 es:my-auto es:h-fit es:pl-px es:text-center",
140
+ "es:icon:size-3 es:icon:stroke-[1.5]",
141
+ marker >= value[0] - 1 && marker < value[1] ? "es:text-accent-700" : "es:text-secondary-400"
142
+ ),
143
+ style: { gridColumn: `${index + 1} / span 1` },
144
+ children: [
145
+ showOuterAsGutter && marker === 0 && icons.chevronLeft,
146
+ showOuterAsGutter && marker === columns - 1 && icons.chevronRight,
147
+ showOuterAsGutter && marker > 0 && marker < columns - 1 && marker,
148
+ !showOuterAsGutter && marker + 1
149
+ ]
150
+ },
151
+ marker
152
+ );
153
+ }),
154
+ state.values.map((_, i) => /* @__PURE__ */ jsx(
155
+ $6f909507e6374d18$export$2c1b491743890dec,
156
+ {
157
+ index: i,
158
+ "aria-label": thumbLabels == null ? void 0 : thumbLabels[i],
159
+ isDisabled: i === 0 && disableOffset || i === 1 && disableWidth,
160
+ className: clsx(
161
+ "es:static! es:row-span-1 es:row-start-1 es:h-6 es:w-1.5 es:rounded-full es:border es:transition es:duration-300",
162
+ i === 0 && "es:translate-y-1/2! es:self-center es:justify-self-start",
163
+ i === 1 && "es:translate-x-full! es:translate-y-1/2! es:self-center es:justify-self-end",
164
+ "es:shadow dragging:es:bg-accent-600 es:disabled:opacity-0",
165
+ "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
166
+ "es:border-accent-600 es:bg-accent-500 es:shadow-accent-600/50",
167
+ "es:hover:cursor-grab dragging:es:cursor-grabbing"
168
+ ),
169
+ style: {
170
+ gridColumn: `${state.values[i]} / span 1`
171
+ }
172
+ },
173
+ i
174
+ ))
175
+ ] });
176
+ }
177
+ }
178
+ )
179
+ }
180
+ )
181
+ }
182
+ );
183
+ };
184
+ /**
185
+ * The output for the ColumnConfigSlider component.
186
+ *
187
+ * Meant to be used within the ColumnConfigSlider component, e.g in help or actions.
188
+ *
189
+ * @component
190
+ * @param {Object} props - Component props.
191
+ * @param {boolean} [props.showOuterAsGutter] - If `true`, the outer columns are displayed with a special icons instead of the column numbers. Other numbers are offset by 1.
192
+ *
193
+ * @returns {JSX.Element} The ColumnConfigSliderOutput component.
194
+ *
195
+ * @example
196
+ * <ColumnConfigSliderOutput />
197
+ *
198
+ * @preserve
199
+ */
200
+ const ColumnConfigSliderOutput = ({ showOuterAsGutter }) => /* @__PURE__ */ jsx($6f909507e6374d18$export$a590f758a961cb5b, { className: clsx("es:text-xs es:tabular-nums es:text-secondary-600"), children: ({ state }) => {
201
+ const columns = state.getThumbMaxValue(1);
202
+ const offset = parseInt(state.getThumbValueLabel(0));
203
+ const endOffset = parseInt(state.getThumbValueLabel(1));
204
+ const width = endOffset - offset + 1;
205
+ return getColumnConfigOutputText(columns, offset, width, showOuterAsGutter);
206
+ } });
207
+ export {
208
+ ColumnConfigSlider,
209
+ ColumnConfigSliderOutput
210
+ };
@@ -0,0 +1,345 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-B94NDG0v.js";
3
+ import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5, a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "../../Label-Fp6AwSRn.js";
4
+ import { $ as $6f909507e6374d18$export$472062a354075cee, a as $6f909507e6374d18$export$105594979f116971, b as $6f909507e6374d18$export$2c1b491743890dec, c as $6f909507e6374d18$export$a590f758a961cb5b, d as $6f909507e6374d18$export$1e7083018727fa60 } from "../../Slider-CyJzC1bp.js";
5
+ import { BaseControl } from "../base-control/base-control.js";
6
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
7
+ import { NumberPicker } from "../number-picker/number-picker.js";
8
+ import { useState, useContext } from "react";
9
+ import { generateMarkers } from "./utils.js";
10
+ /**
11
+ * A single/multi-thumb slider component.
12
+ *
13
+ * @component
14
+ * @param {Object} props - Component props.
15
+ * @param {JSX.Element} [props.icon] - Icon to display within the slider.
16
+ * @param {string} [props.label] - The label of the slider.
17
+ * @param {string} [props.subtitle] - The subtitle of the slider.
18
+ * @param {string} [props.help] - The help text shown below the slider.
19
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display next to the label.
20
+ * @param {Number} [props.min=0] - The minimum value of the slider.
21
+ * @param {Number} [props.max=100] - The maximum value of the slider.
22
+ * @param {Number} [props.step=1] - The step value of the slider.
23
+ * @param {Number} [props.startPoint] - The starting point of the slider.
24
+ * @param {SliderMarkerType} [props.markers] - The markers to display on the slider. If `true`, markers are auto-generated, with labels. If set to `dots`, markers are auto-generated, but do not show labels next to dots. If an object is provided, the keys are the values of the markers, and the values are the labels.
25
+ * @param {boolean} [props.noActiveHighlight=false] - If `true`, the highlight of the active value will not be displayed.
26
+ * @param {Number | Number[]} props.value - The current value of the slider.
27
+ * @param {Function} props.onChange - Function to run when the value changes.
28
+ * @param {Function} props.onChangeEnd - Function to run when the value change ends.
29
+ * @param {boolean} [props.disabled] - If `true`, the slider is disabled.
30
+ * @param {boolean} [props.inputField=false] - If `true`, the slider will display an input field for the value. For multi-thumb sliders, the input field will be displayed for the focused thumb.
31
+ * @param {boolean} [props.vertical=false] - If `true`, the slider will be displayed vertically.
32
+ * @param {JSX.Element} [props.before] - Element to display before the slider.
33
+ * @param {JSX.Element} [props.after] - Element to display after the slider.
34
+ * @param {string[]} [props.thumbLabels] - ARIA labels for the thumbs.
35
+ * @param {Function} [props.thumbContent] - If provided, the function will be called with the current value of the thumb, and the return value will be displayed within the thumb. `(currentIndex: number) => JSX.Element`.
36
+ * @param {string} [props.labelClassName] - Additional classes to pass to the label.
37
+ * @param {Object<string, any>} [props.trackStyle] - Additional style for the track.
38
+ * @param {Number} [props.markerStep] - If provided, this value is used to generate markers instead of the step value. Useful when using small steps with a larger range.
39
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
40
+ *
41
+ * @returns {JSX.Element} The Slider component.
42
+ *
43
+ * @typedef {'dots' | 'lines' | 'true' | Object<Number, string>} SliderMarkerType
44
+ *
45
+ * @example
46
+ * <Slider
47
+ * label='My slider'
48
+ * value={sliderValue}
49
+ * onChange={setSliderValue}
50
+ * />
51
+ *
52
+ * @preserve
53
+ */
54
+ const Slider = (props) => {
55
+ const {
56
+ icon,
57
+ label,
58
+ subtitle,
59
+ help,
60
+ actions,
61
+ min = 0,
62
+ max = 100,
63
+ step = 1,
64
+ startPoint,
65
+ markers,
66
+ noActiveHighlight = false,
67
+ value,
68
+ onChange,
69
+ onChangeEnd,
70
+ disabled,
71
+ inputField = false,
72
+ vertical = false,
73
+ before,
74
+ after,
75
+ thumbLabels,
76
+ thumbContent,
77
+ labelClassName,
78
+ trackStyle,
79
+ markerStep = step,
80
+ hidden,
81
+ ...other
82
+ } = props;
83
+ const [currentThumbIndex, setCurrentThumbIndex] = useState(-1);
84
+ if (hidden) {
85
+ return null;
86
+ }
87
+ let generatedMarkers = {};
88
+ if (typeof markers === "object" && Object.keys(markers).length > 0) {
89
+ generatedMarkers = markers;
90
+ }
91
+ if (markers === true || markers === "dots") {
92
+ generatedMarkers = generateMarkers(min, max, markerStep);
93
+ }
94
+ const markerEntries = Object.entries(generatedMarkers);
95
+ const markerData = vertical ? markerEntries.toReversed() : markerEntries;
96
+ return /* @__PURE__ */ jsx(
97
+ $6f909507e6374d18$export$472062a354075cee,
98
+ {
99
+ value,
100
+ onChange,
101
+ minValue: min,
102
+ maxValue: max,
103
+ step,
104
+ isDisabled: disabled,
105
+ orientation: vertical ? "vertical" : "horizontal",
106
+ className: clsx("es:w-full", (markerEntries == null ? void 0 : markerEntries.some(([_, value2]) => (value2 == null ? void 0 : value2.length) > 0)) && "es:pb-3.5"),
107
+ onChangeEnd,
108
+ ...other,
109
+ children: /* @__PURE__ */ jsx(
110
+ BaseControl,
111
+ {
112
+ icon,
113
+ label,
114
+ subtitle,
115
+ help,
116
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
117
+ actions,
118
+ !inputField && /* @__PURE__ */ jsx($6f909507e6374d18$export$a590f758a961cb5b, { className: clsx("es:text-xs es:tabular-nums es:text-secondary-600"), children: ({ state }) => state.values.map((_, i) => state.getThumbValueLabel(i)).join(" – ") }),
119
+ inputField && /* @__PURE__ */ jsx(
120
+ NumberInputField,
121
+ {
122
+ fieldIndex: Array.isArray(value) ? currentThumbIndex : 0,
123
+ min,
124
+ max,
125
+ step,
126
+ focusedThumb: currentThumbIndex,
127
+ setFocusedThumb: setCurrentThumbIndex
128
+ }
129
+ )
130
+ ] }),
131
+ labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
132
+ className: labelClassName,
133
+ children: /* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:items-center es:gap-2.5 es:space-y-0!", vertical && "es:flex-col"), children: [
134
+ before && /* @__PURE__ */ jsx("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: before }),
135
+ /* @__PURE__ */ jsx($6f909507e6374d18$export$105594979f116971, { className: clsx("es:isolate es:grid es:grid-cols-1 es:grid-rows-1", vertical ? "es:mx-auto es:h-40 es:w-4" : "es:h-4 es:w-full es:grow"), children: ({ state }) => {
136
+ let activeBarLeft;
137
+ let activeBarBottom;
138
+ let activeBarWidth;
139
+ let activeBarHeight;
140
+ let activeBarOffset = false;
141
+ let shouldRoundStart = false;
142
+ let shouldRoundEnd = false;
143
+ const currValue = state.getThumbValue(0);
144
+ if (vertical && !noActiveHighlight) {
145
+ if (Array.isArray(value)) {
146
+ activeBarBottom = state.getThumbPercent(0) * 100;
147
+ activeBarHeight = state.getThumbPercent(value.length - 1) * 100 - activeBarBottom;
148
+ } else if (startPoint && currValue >= startPoint) {
149
+ activeBarBottom = state.getValuePercent(startPoint) * 100;
150
+ activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
151
+ activeBarOffset = true;
152
+ } else if (startPoint && currValue < startPoint) {
153
+ activeBarBottom = state.getThumbPercent(0) * 100;
154
+ activeBarHeight = state.getValuePercent(startPoint) * 100 - activeBarBottom;
155
+ } else if (min < 0 && currValue >= 0) {
156
+ activeBarBottom = state.getValuePercent(0) * 100;
157
+ activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
158
+ } else if (min < 0 && currValue < 0) {
159
+ activeBarBottom = state.getThumbPercent(0) * 100;
160
+ activeBarHeight = state.getValuePercent(0) * 100 - activeBarBottom;
161
+ } else {
162
+ activeBarBottom = state.getValuePercent(min) * 100;
163
+ activeBarHeight = state.getThumbPercent(0) * 100;
164
+ shouldRoundEnd = true;
165
+ }
166
+ } else if (!noActiveHighlight) {
167
+ if (Array.isArray(value)) {
168
+ activeBarLeft = state.getThumbPercent(0) * 100;
169
+ activeBarWidth = state.getThumbPercent(value.length - 1) * 100 - activeBarLeft;
170
+ } else if (startPoint && currValue >= startPoint) {
171
+ activeBarLeft = state.getValuePercent(startPoint) * 100;
172
+ activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
173
+ } else if (startPoint && currValue < startPoint) {
174
+ activeBarLeft = state.getThumbPercent(0) * 100;
175
+ activeBarWidth = state.getValuePercent(startPoint) * 100 - activeBarLeft;
176
+ } else if (min < 0 && currValue >= 0) {
177
+ activeBarLeft = state.getValuePercent(0) * 100;
178
+ activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
179
+ activeBarOffset = true;
180
+ } else if (min < 0 && currValue < 0) {
181
+ activeBarLeft = state.getThumbPercent(0) * 100;
182
+ activeBarWidth = state.getValuePercent(0) * 100 - activeBarLeft;
183
+ } else {
184
+ activeBarLeft = state.getValuePercent(min) * 100;
185
+ activeBarWidth = state.getThumbPercent(0) * 100;
186
+ shouldRoundStart = true;
187
+ }
188
+ }
189
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
190
+ /* @__PURE__ */ jsx(
191
+ "div",
192
+ {
193
+ className: clsx(
194
+ "es:relative es:col-start-1 es:row-start-1 es:rounded-full es:border",
195
+ !vertical && "es:h-1.5 es:w-full es:self-center",
196
+ vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
197
+ disabled ? "es:border-secondary-200 es:bg-white" : "es:border-secondary-300 es:bg-secondary-50 es:shadow-xs"
198
+ ),
199
+ style: trackStyle
200
+ }
201
+ ),
202
+ !noActiveHighlight && /* @__PURE__ */ jsx(
203
+ "div",
204
+ {
205
+ className: clsx(
206
+ "es:absolute es:col-start-1 es:row-start-1 es:border",
207
+ !vertical && "es:h-1.5 es:w-full es:self-center",
208
+ vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
209
+ !vertical && shouldRoundStart && "es:rounded-l-full",
210
+ !vertical && shouldRoundEnd && "es:rounded-r-full",
211
+ vertical && shouldRoundStart && "es:rounded-t-full",
212
+ vertical && shouldRoundEnd && "es:rounded-b-full",
213
+ !vertical && activeBarOffset && "es:-translate-x-px",
214
+ vertical && activeBarOffset && "es:translate-y-px",
215
+ disabled ? "es:border-secondary-200 es:bg-secondary-50" : "es:border-accent-500 es:bg-accent-500/30"
216
+ ),
217
+ style: {
218
+ bottom: vertical ? `${activeBarBottom}%` : null,
219
+ height: vertical ? `${activeBarHeight}%` : null,
220
+ width: vertical ? null : `${activeBarWidth}%`,
221
+ left: vertical ? null : `${activeBarLeft}%`
222
+ }
223
+ }
224
+ ),
225
+ markers && /* @__PURE__ */ jsx(
226
+ "div",
227
+ {
228
+ className: clsx(
229
+ "es:relative es:col-start-1 es:row-start-1",
230
+ !vertical && "es:h-1 es:w-full es:self-center",
231
+ vertical && "es:h-full es:w-1 es:flex-col es:justify-self-center"
232
+ ),
233
+ children: markerData.map(([rawDotValue, labelData], index) => {
234
+ const dotValue = parseFloat(rawDotValue);
235
+ let isWithinActiveBar = false;
236
+ if (Array.isArray(value)) {
237
+ isWithinActiveBar = value[0] <= dotValue && dotValue <= value[value.length - 1];
238
+ } else if (startPoint && dotValue >= startPoint) {
239
+ isWithinActiveBar = dotValue >= startPoint && dotValue <= currValue && dotValue !== startPoint;
240
+ } else if (startPoint && dotValue < startPoint) {
241
+ isWithinActiveBar = dotValue <= startPoint && dotValue >= currValue && dotValue !== startPoint;
242
+ } else if (min < 0 && dotValue >= 0) {
243
+ isWithinActiveBar = dotValue >= 0 && dotValue <= currValue && dotValue !== 0;
244
+ } else if (min < 0 && dotValue < 0) {
245
+ isWithinActiveBar = dotValue <= 0 && dotValue >= currValue && dotValue !== 0;
246
+ } else {
247
+ isWithinActiveBar = dotValue <= currValue && dotValue > min && dotValue < max;
248
+ }
249
+ return /* @__PURE__ */ jsx(
250
+ "div",
251
+ {
252
+ className: clsx(
253
+ "es:absolute",
254
+ vertical ? "es:h-px es:w-1" : "es:h-1 es:w-px es:translate-x-1/2",
255
+ !(dotValue === min || dotValue === max || dotValue === startPoint && !noActiveHighlight || min < 0 && dotValue === 0 && !noActiveHighlight || isWithinActiveBar) && "es:bg-secondary-300",
256
+ !noActiveHighlight && isWithinActiveBar && "es:bg-accent-500/75"
257
+ ),
258
+ style: {
259
+ left: vertical ? null : `${state.getValuePercent(dotValue) * 100}%`,
260
+ top: vertical ? `calc(${state.getValuePercent(dotValue) * 100}%)` : null
261
+ },
262
+ children: /* @__PURE__ */ jsx(
263
+ "span",
264
+ {
265
+ className: clsx(
266
+ "es:absolute es:select-none es:text-xs es:transition-colors",
267
+ vertical ? "es:left-3.5 es:top-0 es:-translate-y-1/2" : "es:left-0 es:top-2.5 es:-translate-x-1/2",
268
+ (Array.isArray(value) ? value.includes(Number(dotValue)) : value === Number(dotValue) && !disabled) ? "es:text-accent-700" : "es:text-secondary-300"
269
+ ),
270
+ children: markers && markers !== "dots" && labelData
271
+ }
272
+ )
273
+ },
274
+ index
275
+ );
276
+ })
277
+ }
278
+ ),
279
+ /* @__PURE__ */ jsx("div", { className: "es:relative es:col-start-1 es:row-start-1 es:p-px", children: state.values.map((_, i) => /* @__PURE__ */ jsxs(
280
+ $6f909507e6374d18$export$2c1b491743890dec,
281
+ {
282
+ index: i,
283
+ "aria-label": thumbLabels == null ? void 0 : thumbLabels[i],
284
+ className: clsx(
285
+ "es:absolute es:size-3.5 es:rounded-full es:border es:transition es:duration-300",
286
+ vertical ? "es:translate-x-1/2!" : "es:translate-y-1/2!",
287
+ "es:shadow dragging:es:bg-accent-600 es:disabled:border-secondary-200 es:disabled:bg-secondary-100 es:disabled:shadow-none",
288
+ "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
289
+ "es:border-accent-600 es:bg-accent-500 es:shadow-accent-600/50",
290
+ "es:hover:cursor-grab dragging:es:cursor-grabbing"
291
+ ),
292
+ onFocus: () => {
293
+ if (state.values.length < 2) {
294
+ return;
295
+ }
296
+ setCurrentThumbIndex(i);
297
+ },
298
+ children: [
299
+ inputField && state.values.length > 1 && currentThumbIndex === i && /* @__PURE__ */ jsx("div", { className: "es:m-0.5 es:size-2 es:rounded-full es:bg-accent-100" }),
300
+ thumbContent && thumbContent(i)
301
+ ]
302
+ },
303
+ i
304
+ )) })
305
+ ] });
306
+ } }),
307
+ after && /* @__PURE__ */ jsx("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: after })
308
+ ] })
309
+ }
310
+ )
311
+ }
312
+ );
313
+ };
314
+ const NumberInputField = (props) => {
315
+ const { ...other } = props;
316
+ const state = useContext($6f909507e6374d18$export$1e7083018727fa60);
317
+ const labelProps = $64fa3d84918910a7$export$fabf2dc03a41866e($01b77f81d0f07f68$export$75b6ee27786ba447);
318
+ const isSingleValue = state.values.length === 1;
319
+ const fieldIndex = isSingleValue ? 0 : props.focusedThumb ?? 0;
320
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
321
+ /* @__PURE__ */ jsx(
322
+ NumberPicker,
323
+ {
324
+ "aria-labelledby": labelProps.id,
325
+ value: state.values[fieldIndex] ?? null,
326
+ onChange: (v) => state.setThumbValue(fieldIndex, v),
327
+ size: "compact",
328
+ min: state.getThumbMinValue(fieldIndex),
329
+ max: state.getThumbMaxValue(fieldIndex),
330
+ onBlur: () => {
331
+ if (isSingleValue) {
332
+ return;
333
+ }
334
+ props.setFocusedThumb(-1);
335
+ },
336
+ className: fieldIndex === -1 && !isSingleValue ? "es:invisible" : "",
337
+ ...other
338
+ }
339
+ ),
340
+ fieldIndex === -1 && !isSingleValue && /* @__PURE__ */ jsx($6f909507e6374d18$export$a590f758a961cb5b, { className: clsx("es:text-xs es:tabular-nums es:text-secondary-600"), children: ({ state: state2 }) => state2.values.map((_, i) => state2.getThumbValueLabel(i)).join(" – ") })
341
+ ] });
342
+ };
343
+ export {
344
+ Slider
345
+ };
@@ -0,0 +1,94 @@
1
+ import { _ as __, s as sprintf, a as _n } from "../../default-i18n-CT_oS1Fy.js";
2
+ /**
3
+ * Generates an array of markers based on the provided minimum and maximum values and step.
4
+ * If the step is less than 10, only markers divisible by 5 and 10 are included.
5
+ *
6
+ * @param {number} min - The minimum value for the markers.
7
+ * @param {number} max - The maximum value for the markers.
8
+ * @param {number} [step=10] - The step between each marker. Default is 10.
9
+ *
10
+ * @returns {Object} An object where the keys are the marker values and the values are either the marker value (if divisible by 10) or an empty string.
11
+ *
12
+ * @example
13
+ * generateMarkers(-20, 50, 10); // { '-20': '-20', '-10': '-10', '0': '0', '10': '10', '20': '20', '30': '30', '40': '40', '50': '50' }
14
+ *
15
+ * @preserve
16
+ */
17
+ const generateMarkers = (min, max, step = 10) => {
18
+ const smallStep = step < 10 && Math.abs(max - min) > 20;
19
+ if (step < 1 && Math.abs(max - min) > 2) {
20
+ step = 1;
21
+ }
22
+ if (step < 0.1 && Math.abs(max - min) > 0.2) {
23
+ step = 0.1;
24
+ }
25
+ const markers = [];
26
+ if (min < 0) {
27
+ for (let i = min; i < 0; i += step) {
28
+ markers.push(i.toString());
29
+ }
30
+ for (let i = 0; i <= max; i += step) {
31
+ markers.push(i.toString());
32
+ }
33
+ } else {
34
+ for (let i = min; i <= max; i += step) {
35
+ markers.push(i.toString());
36
+ }
37
+ }
38
+ return markers.reduce((acc, marker) => {
39
+ if (smallStep && marker % 5 !== 0) {
40
+ return acc;
41
+ }
42
+ if (smallStep && marker % 10 !== 0) {
43
+ acc[marker] = "";
44
+ } else {
45
+ if (marker < 1) {
46
+ acc[marker] = parseFloat(marker).toFixed(step < 0.1 ? 2 : 1).replace(".0", "");
47
+ } else {
48
+ acc[marker] = marker;
49
+ }
50
+ }
51
+ return acc;
52
+ }, {});
53
+ };
54
+ /**
55
+ * Returns a human-readable string representing the column configuration.
56
+ *
57
+ * @param {Number} columns - Number of columns.
58
+ * @param {Number} offset - Offset of the column.
59
+ * @param {Number} width - Width of the column.
60
+ * @param {boolean} [showOuterAsGutter=false] - If `true`, the outer columns are skipped when counting.
61
+ *
62
+ * @returns {string} Configuration info in a human-readable format.
63
+ *
64
+ * @example
65
+ * const output = getColumnConfigOutputText(12, 1, 6); // => '6 cols from 1'
66
+ *
67
+ * @preserve
68
+ */
69
+ const getColumnConfigOutputText = (columns, offset, width, showOuterAsGutter = false) => {
70
+ const endOffset = offset + width - 1;
71
+ if (offset === 1 && endOffset === columns) {
72
+ return __("Full-width", "eightshift-ui-components");
73
+ }
74
+ if (showOuterAsGutter && width === 1 && offset === 1) {
75
+ return __("Start gutter", "eightshift-ui-components");
76
+ }
77
+ if (showOuterAsGutter && width === 1 && endOffset === columns) {
78
+ return __("End gutter", "eightshift-ui-components");
79
+ }
80
+ if (width === 1) {
81
+ return sprintf(__("Col %d", "eightshift-ui-components"), offset);
82
+ }
83
+ if (offset === 1 && endOffset < columns) {
84
+ return sprintf(__("To col %d", "eightshift-ui-components"), showOuterAsGutter ? endOffset - 1 : endOffset);
85
+ }
86
+ if (offset > 1 && endOffset === columns) {
87
+ return sprintf(__("From col %d", "eightshift-ui-components"), showOuterAsGutter ? offset - 1 : offset);
88
+ }
89
+ return sprintf(_n("%s col from %s", "%s cols from %s", width, "eightshift-ui-components"), width, showOuterAsGutter ? offset - 1 : offset);
90
+ };
91
+ export {
92
+ generateMarkers,
93
+ getColumnConfigOutputText
94
+ };