@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,210 +0,0 @@
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-icmbmNdI.js";
4
- import { $ as $6f909507e6374d18$export$472062a354075cee, a as $6f909507e6374d18$export$105594979f116971, b as $6f909507e6374d18$export$2c1b491743890dec, c as $6f909507e6374d18$export$a590f758a961cb5b } from "../../Slider-rz2XRMGm.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
- };
@@ -1,343 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-DkCSC521.js";
3
- import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5, a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "../../Label-icmbmNdI.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-rz2XRMGm.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 {boolean} [props.hidden] - If `true`, the component is not rendered.
39
- *
40
- * @returns {JSX.Element} The Slider component.
41
- *
42
- * @typedef {'dots' | 'lines' | 'true' | Object<Number, string>} SliderMarkerType
43
- *
44
- * @example
45
- * <Slider
46
- * label='My slider'
47
- * value={sliderValue}
48
- * onChange={setSliderValue}
49
- * />
50
- *
51
- * @preserve
52
- */
53
- const Slider = (props) => {
54
- const {
55
- icon,
56
- label,
57
- subtitle,
58
- help,
59
- actions,
60
- min = 0,
61
- max = 100,
62
- step = 1,
63
- startPoint,
64
- markers,
65
- noActiveHighlight = false,
66
- value,
67
- onChange,
68
- onChangeEnd,
69
- disabled,
70
- inputField = false,
71
- vertical = false,
72
- before,
73
- after,
74
- thumbLabels,
75
- thumbContent,
76
- labelClassName,
77
- trackStyle,
78
- hidden,
79
- ...other
80
- } = props;
81
- const [currentThumbIndex, setCurrentThumbIndex] = useState(-1);
82
- if (hidden) {
83
- return null;
84
- }
85
- let generatedMarkers = {};
86
- if (typeof markers === "object" && Object.keys(markers).length > 0) {
87
- generatedMarkers = markers;
88
- }
89
- if (markers === true || markers === "dots") {
90
- generatedMarkers = generateMarkers(min, max, step);
91
- }
92
- const markerEntries = Object.entries(generatedMarkers);
93
- const markerData = vertical ? markerEntries.toReversed() : markerEntries;
94
- return /* @__PURE__ */ jsx(
95
- $6f909507e6374d18$export$472062a354075cee,
96
- {
97
- value,
98
- onChange,
99
- minValue: min,
100
- maxValue: max,
101
- step,
102
- isDisabled: disabled,
103
- orientation: vertical ? "vertical" : "horizontal",
104
- className: clsx("es:w-full", (markerEntries == null ? void 0 : markerEntries.some(([_, value2]) => (value2 == null ? void 0 : value2.length) > 0)) && "es:pb-3.5"),
105
- onChangeEnd,
106
- ...other,
107
- children: /* @__PURE__ */ jsx(
108
- BaseControl,
109
- {
110
- icon,
111
- label,
112
- subtitle,
113
- help,
114
- actions: /* @__PURE__ */ jsxs(Fragment, { children: [
115
- actions,
116
- !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(" – ") }),
117
- inputField && /* @__PURE__ */ jsx(
118
- NumberInputField,
119
- {
120
- fieldIndex: Array.isArray(value) ? currentThumbIndex : 0,
121
- min,
122
- max,
123
- step,
124
- focusedThumb: currentThumbIndex,
125
- setFocusedThumb: setCurrentThumbIndex
126
- }
127
- )
128
- ] }),
129
- labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
130
- className: labelClassName,
131
- children: /* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:items-center es:gap-2.5 es:space-y-0!", vertical && "es:flex-col"), children: [
132
- before && /* @__PURE__ */ jsx("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: before }),
133
- /* @__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 }) => {
134
- let activeBarLeft;
135
- let activeBarBottom;
136
- let activeBarWidth;
137
- let activeBarHeight;
138
- let activeBarOffset = false;
139
- let shouldRoundStart = false;
140
- let shouldRoundEnd = false;
141
- const currValue = state.getThumbValue(0);
142
- if (vertical && !noActiveHighlight) {
143
- if (Array.isArray(value)) {
144
- activeBarBottom = state.getThumbPercent(0) * 100;
145
- activeBarHeight = state.getThumbPercent(value.length - 1) * 100 - activeBarBottom;
146
- } else if (startPoint && currValue >= startPoint) {
147
- activeBarBottom = state.getValuePercent(startPoint) * 100;
148
- activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
149
- activeBarOffset = true;
150
- } else if (startPoint && currValue < startPoint) {
151
- activeBarBottom = state.getThumbPercent(0) * 100;
152
- activeBarHeight = state.getValuePercent(startPoint) * 100 - activeBarBottom;
153
- } else if (min < 0 && currValue >= 0) {
154
- activeBarBottom = state.getValuePercent(0) * 100;
155
- activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
156
- } else if (min < 0 && currValue < 0) {
157
- activeBarBottom = state.getThumbPercent(0) * 100;
158
- activeBarHeight = state.getValuePercent(0) * 100 - activeBarBottom;
159
- } else {
160
- activeBarBottom = state.getValuePercent(min) * 100;
161
- activeBarHeight = state.getThumbPercent(0) * 100;
162
- shouldRoundEnd = true;
163
- }
164
- } else if (!noActiveHighlight) {
165
- if (Array.isArray(value)) {
166
- activeBarLeft = state.getThumbPercent(0) * 100;
167
- activeBarWidth = state.getThumbPercent(value.length - 1) * 100 - activeBarLeft;
168
- } else if (startPoint && currValue >= startPoint) {
169
- activeBarLeft = state.getValuePercent(startPoint) * 100;
170
- activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
171
- } else if (startPoint && currValue < startPoint) {
172
- activeBarLeft = state.getThumbPercent(0) * 100;
173
- activeBarWidth = state.getValuePercent(startPoint) * 100 - activeBarLeft;
174
- } else if (min < 0 && currValue >= 0) {
175
- activeBarLeft = state.getValuePercent(0) * 100;
176
- activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
177
- activeBarOffset = true;
178
- } else if (min < 0 && currValue < 0) {
179
- activeBarLeft = state.getThumbPercent(0) * 100;
180
- activeBarWidth = state.getValuePercent(0) * 100 - activeBarLeft;
181
- } else {
182
- activeBarLeft = state.getValuePercent(min) * 100;
183
- activeBarWidth = state.getThumbPercent(0) * 100;
184
- shouldRoundStart = true;
185
- }
186
- }
187
- return /* @__PURE__ */ jsxs(Fragment, { children: [
188
- /* @__PURE__ */ jsx(
189
- "div",
190
- {
191
- className: clsx(
192
- "es:relative es:col-start-1 es:row-start-1 es:rounded-full es:border",
193
- !vertical && "es:h-1.5 es:w-full es:self-center",
194
- vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
195
- disabled ? "es:border-secondary-200 es:bg-white" : "es:border-secondary-300 es:bg-secondary-50 es:shadow-xs"
196
- ),
197
- style: trackStyle
198
- }
199
- ),
200
- !noActiveHighlight && /* @__PURE__ */ jsx(
201
- "div",
202
- {
203
- className: clsx(
204
- "es:absolute es:col-start-1 es:row-start-1 es:border",
205
- !vertical && "es:h-1.5 es:w-full es:self-center",
206
- vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
207
- !vertical && shouldRoundStart && "es:rounded-l-full",
208
- !vertical && shouldRoundEnd && "es:rounded-r-full",
209
- vertical && shouldRoundStart && "es:rounded-t-full",
210
- vertical && shouldRoundEnd && "es:rounded-b-full",
211
- !vertical && activeBarOffset && "es:-translate-x-px",
212
- vertical && activeBarOffset && "es:translate-y-px",
213
- disabled ? "es:border-secondary-200 es:bg-secondary-50" : "es:border-accent-500 es:bg-accent-500/30"
214
- ),
215
- style: {
216
- bottom: vertical ? `${activeBarBottom}%` : null,
217
- height: vertical ? `${activeBarHeight}%` : null,
218
- width: vertical ? null : `${activeBarWidth}%`,
219
- left: vertical ? null : `${activeBarLeft}%`
220
- }
221
- }
222
- ),
223
- markers && /* @__PURE__ */ jsx(
224
- "div",
225
- {
226
- className: clsx(
227
- "es:relative es:col-start-1 es:row-start-1",
228
- !vertical && "es:h-1 es:w-full es:self-center",
229
- vertical && "es:h-full es:w-1 es:flex-col es:justify-self-center"
230
- ),
231
- children: markerData.map(([rawDotValue, labelData], index) => {
232
- const dotValue = parseFloat(rawDotValue);
233
- let isWithinActiveBar = false;
234
- if (Array.isArray(value)) {
235
- isWithinActiveBar = value[0] <= dotValue && dotValue <= value[value.length - 1];
236
- } else if (startPoint && dotValue >= startPoint) {
237
- isWithinActiveBar = dotValue >= startPoint && dotValue <= currValue && dotValue !== startPoint;
238
- } else if (startPoint && dotValue < startPoint) {
239
- isWithinActiveBar = dotValue <= startPoint && dotValue >= currValue && dotValue !== startPoint;
240
- } else if (min < 0 && dotValue >= 0) {
241
- isWithinActiveBar = dotValue >= 0 && dotValue <= currValue && dotValue !== 0;
242
- } else if (min < 0 && dotValue < 0) {
243
- isWithinActiveBar = dotValue <= 0 && dotValue >= currValue && dotValue !== 0;
244
- } else {
245
- isWithinActiveBar = dotValue <= currValue && dotValue > min && dotValue < max;
246
- }
247
- return /* @__PURE__ */ jsx(
248
- "div",
249
- {
250
- className: clsx(
251
- "es:absolute",
252
- vertical ? "es:h-px es:w-1" : "es:h-1 es:w-px es:translate-x-1/2",
253
- !(dotValue === min || dotValue === max || dotValue === startPoint && !noActiveHighlight || min < 0 && dotValue === 0 && !noActiveHighlight || isWithinActiveBar) && "es:bg-secondary-300",
254
- !noActiveHighlight && isWithinActiveBar && "es:bg-accent-500/75"
255
- ),
256
- style: {
257
- left: vertical ? null : `${state.getValuePercent(dotValue) * 100}%`,
258
- top: vertical ? `calc(${state.getValuePercent(dotValue) * 100}%)` : null
259
- },
260
- children: /* @__PURE__ */ jsx(
261
- "span",
262
- {
263
- className: clsx(
264
- "es:absolute es:select-none es:text-xs es:transition-colors",
265
- 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",
266
- (Array.isArray(value) ? value.includes(Number(dotValue)) : value === Number(dotValue) && !disabled) ? "es:text-accent-700" : "es:text-secondary-300"
267
- ),
268
- children: markers && markers !== "dots" && labelData
269
- }
270
- )
271
- },
272
- index
273
- );
274
- })
275
- }
276
- ),
277
- /* @__PURE__ */ jsx("div", { className: "es:relative es:col-start-1 es:row-start-1 es:p-px", children: state.values.map((_, i) => /* @__PURE__ */ jsxs(
278
- $6f909507e6374d18$export$2c1b491743890dec,
279
- {
280
- index: i,
281
- "aria-label": thumbLabels == null ? void 0 : thumbLabels[i],
282
- className: clsx(
283
- "es:absolute es:size-3.5 es:rounded-full es:border es:transition es:duration-300",
284
- vertical ? "es:translate-x-1/2!" : "es:translate-y-1/2!",
285
- "es:shadow dragging:es:bg-accent-600 es:disabled:border-secondary-200 es:disabled:bg-secondary-100 es:disabled:shadow-none",
286
- "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
287
- "es:border-accent-600 es:bg-accent-500 es:shadow-accent-600/50",
288
- "es:hover:cursor-grab dragging:es:cursor-grabbing"
289
- ),
290
- onFocus: () => {
291
- if (state.values.length < 2) {
292
- return;
293
- }
294
- setCurrentThumbIndex(i);
295
- },
296
- children: [
297
- 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" }),
298
- thumbContent && thumbContent(i)
299
- ]
300
- },
301
- i
302
- )) })
303
- ] });
304
- } }),
305
- after && /* @__PURE__ */ jsx("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: after })
306
- ] })
307
- }
308
- )
309
- }
310
- );
311
- };
312
- const NumberInputField = (props) => {
313
- const { ...other } = props;
314
- const state = useContext($6f909507e6374d18$export$1e7083018727fa60);
315
- const labelProps = $64fa3d84918910a7$export$fabf2dc03a41866e($01b77f81d0f07f68$export$75b6ee27786ba447);
316
- const isSingleValue = state.values.length === 1;
317
- const fieldIndex = isSingleValue ? 0 : props.focusedThumb ?? 0;
318
- return /* @__PURE__ */ jsxs(Fragment, { children: [
319
- /* @__PURE__ */ jsx(
320
- NumberPicker,
321
- {
322
- "aria-labelledby": labelProps.id,
323
- value: state.values[fieldIndex] ?? null,
324
- onChange: (v) => state.setThumbValue(fieldIndex, v),
325
- size: "compact",
326
- min: state.getThumbMinValue(fieldIndex),
327
- max: state.getThumbMaxValue(fieldIndex),
328
- onBlur: () => {
329
- if (isSingleValue) {
330
- return;
331
- }
332
- props.setFocusedThumb(-1);
333
- },
334
- className: fieldIndex === -1 && !isSingleValue ? "es:invisible" : "",
335
- ...other
336
- }
337
- ),
338
- 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(" – ") })
339
- ] });
340
- };
341
- export {
342
- Slider
343
- };
@@ -1,84 +0,0 @@
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
- const markers = [];
20
- if (min < 0) {
21
- for (let i = min; i < 0; i += step) {
22
- markers.push(i.toString());
23
- }
24
- for (let i = 0; i <= max; i += step) {
25
- markers.push(i.toString());
26
- }
27
- } else {
28
- for (let i = min; i <= max; i += step) {
29
- markers.push(i.toString());
30
- }
31
- }
32
- return markers.reduce((acc, marker) => {
33
- if (smallStep && marker % 5 !== 0) {
34
- return acc;
35
- }
36
- if (smallStep && marker % 10 !== 0) {
37
- acc[marker] = "";
38
- } else {
39
- acc[marker] = marker;
40
- }
41
- return acc;
42
- }, {});
43
- };
44
- /**
45
- * Returns a human-readable string representing the column configuration.
46
- *
47
- * @param {Number} columns - Number of columns.
48
- * @param {Number} offset - Offset of the column.
49
- * @param {Number} width - Width of the column.
50
- * @param {boolean} [showOuterAsGutter=false] - If `true`, the outer columns are skipped when counting.
51
- *
52
- * @returns {string} Configuration info in a human-readable format.
53
- *
54
- * @example
55
- * const output = getColumnConfigOutputText(12, 1, 6); // => '6 cols from 1'
56
- *
57
- * @preserve
58
- */
59
- const getColumnConfigOutputText = (columns, offset, width, showOuterAsGutter = false) => {
60
- const endOffset = offset + width - 1;
61
- if (offset === 1 && endOffset === columns) {
62
- return __("Full-width", "eightshift-ui-components");
63
- }
64
- if (showOuterAsGutter && width === 1 && offset === 1) {
65
- return __("Start gutter", "eightshift-ui-components");
66
- }
67
- if (showOuterAsGutter && width === 1 && endOffset === columns) {
68
- return __("End gutter", "eightshift-ui-components");
69
- }
70
- if (width === 1) {
71
- return sprintf(__("Col %d", "eightshift-ui-components"), offset);
72
- }
73
- if (offset === 1 && endOffset < columns) {
74
- return sprintf(__("To col %d", "eightshift-ui-components"), showOuterAsGutter ? endOffset - 1 : endOffset);
75
- }
76
- if (offset > 1 && endOffset === columns) {
77
- return sprintf(__("From col %d", "eightshift-ui-components"), showOuterAsGutter ? offset - 1 : offset);
78
- }
79
- return sprintf(_n("%s col from %s", "%s cols from %s", width, "eightshift-ui-components"), width, showOuterAsGutter ? offset - 1 : offset);
80
- };
81
- export {
82
- generateMarkers,
83
- getColumnConfigOutputText
84
- };