@eightshift/ui-components 0.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.
- package/README.md +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-BsiH7-5Y.js";
|
|
3
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5, a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "../../Label-BPzS-sR7.js";
|
|
4
|
+
import { $ as $6f909507e6374d18$export$472062a354075cee, c as $6f909507e6374d18$export$a590f758a961cb5b, a as $6f909507e6374d18$export$105594979f116971, b as $6f909507e6374d18$export$2c1b491743890dec, d as $6f909507e6374d18$export$1e7083018727fa60 } from "../../Slider-Pyh2V4bY.js";
|
|
5
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
6
|
+
import { classnames } from "../../utilities/classnames.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
|
+
*
|
|
39
|
+
* @returns {JSX.Element} The Slider component.
|
|
40
|
+
*
|
|
41
|
+
* @typedef {'dots' | 'lines' | 'true' | Object<Number, string>} SliderMarkerType
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <Slider
|
|
45
|
+
* label='My slider'
|
|
46
|
+
* value={sliderValue}
|
|
47
|
+
* onChange={setSliderValue}
|
|
48
|
+
* />
|
|
49
|
+
*
|
|
50
|
+
* @preserve
|
|
51
|
+
*/
|
|
52
|
+
const Slider = (props) => {
|
|
53
|
+
const {
|
|
54
|
+
icon,
|
|
55
|
+
label,
|
|
56
|
+
subtitle,
|
|
57
|
+
help,
|
|
58
|
+
actions,
|
|
59
|
+
min = 0,
|
|
60
|
+
max = 100,
|
|
61
|
+
step = 1,
|
|
62
|
+
startPoint,
|
|
63
|
+
markers,
|
|
64
|
+
noActiveHighlight = false,
|
|
65
|
+
value,
|
|
66
|
+
onChange,
|
|
67
|
+
onChangeEnd,
|
|
68
|
+
disabled,
|
|
69
|
+
inputField = false,
|
|
70
|
+
vertical = false,
|
|
71
|
+
before,
|
|
72
|
+
after,
|
|
73
|
+
thumbLabels,
|
|
74
|
+
thumbContent,
|
|
75
|
+
labelClassName,
|
|
76
|
+
trackStyle,
|
|
77
|
+
...other
|
|
78
|
+
} = props;
|
|
79
|
+
const [currentThumbIndex, setCurrentThumbIndex] = useState(-1);
|
|
80
|
+
let generatedMarkers = {};
|
|
81
|
+
if (typeof markers === "object" && Object.keys(markers).length > 0) {
|
|
82
|
+
generatedMarkers = markers;
|
|
83
|
+
}
|
|
84
|
+
if (markers === true || markers === "dots") {
|
|
85
|
+
generatedMarkers = generateMarkers(min, max, step);
|
|
86
|
+
}
|
|
87
|
+
const markerEntries = Object.entries(generatedMarkers);
|
|
88
|
+
const markerData = vertical ? markerEntries.toReversed() : markerEntries;
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
$6f909507e6374d18$export$472062a354075cee,
|
|
91
|
+
{
|
|
92
|
+
value,
|
|
93
|
+
onChange,
|
|
94
|
+
minValue: min,
|
|
95
|
+
maxValue: max,
|
|
96
|
+
step,
|
|
97
|
+
isDisabled: disabled,
|
|
98
|
+
orientation: vertical ? "vertical" : "horizontal",
|
|
99
|
+
className: "es-uic-w-full es-uic-pb-3.5",
|
|
100
|
+
onChangeEnd,
|
|
101
|
+
...other,
|
|
102
|
+
children: /* @__PURE__ */ jsxs(
|
|
103
|
+
BaseControl,
|
|
104
|
+
{
|
|
105
|
+
icon,
|
|
106
|
+
label,
|
|
107
|
+
subtitle,
|
|
108
|
+
help,
|
|
109
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
+
actions,
|
|
111
|
+
!inputField && /* @__PURE__ */ jsx(
|
|
112
|
+
$6f909507e6374d18$export$a590f758a961cb5b,
|
|
113
|
+
{
|
|
114
|
+
className: classnames("es-uic-text-xs es-uic-tabular-nums es-uic-text-gray-600"),
|
|
115
|
+
children: ({ state }) => state.values.map((_, i) => state.getThumbValueLabel(i)).join(" – ")
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
inputField && /* @__PURE__ */ jsx(
|
|
119
|
+
NumberInputField,
|
|
120
|
+
{
|
|
121
|
+
fieldIndex: Array.isArray(value) ? currentThumbIndex : 0,
|
|
122
|
+
min,
|
|
123
|
+
max,
|
|
124
|
+
step,
|
|
125
|
+
focusedThumb: currentThumbIndex,
|
|
126
|
+
setFocusedThumb: setCurrentThumbIndex
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
] }),
|
|
130
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
131
|
+
className: labelClassName,
|
|
132
|
+
controlContainerClassName: classnames(
|
|
133
|
+
"es-uic-flex es-uic-items-center es-uic-gap-2.5 !es-uic-space-y-0",
|
|
134
|
+
vertical && "es-uic-flex-col"
|
|
135
|
+
),
|
|
136
|
+
children: [
|
|
137
|
+
before && /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-shrink-0 es-uic-items-center es-uic-gap-1", children: before }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
$6f909507e6374d18$export$105594979f116971,
|
|
140
|
+
{
|
|
141
|
+
className: classnames(
|
|
142
|
+
"es-uic-isolate es-uic-grid es-uic-grid-cols-1 es-uic-grid-rows-1",
|
|
143
|
+
vertical ? "es-uic-mx-auto es-uic-h-40 es-uic-w-4" : "es-uic-h-4 es-uic-w-full es-uic-grow"
|
|
144
|
+
),
|
|
145
|
+
children: ({ state }) => {
|
|
146
|
+
let activeBarLeft;
|
|
147
|
+
let activeBarBottom;
|
|
148
|
+
let activeBarWidth;
|
|
149
|
+
let activeBarHeight;
|
|
150
|
+
let activeBarOffset = false;
|
|
151
|
+
let shouldRoundStart = false;
|
|
152
|
+
let shouldRoundEnd = false;
|
|
153
|
+
const currValue = state.getThumbValue(0);
|
|
154
|
+
if (vertical && !noActiveHighlight) {
|
|
155
|
+
if (Array.isArray(value)) {
|
|
156
|
+
activeBarBottom = state.getThumbPercent(0) * 100;
|
|
157
|
+
activeBarHeight = state.getThumbPercent(value.length - 1) * 100 - activeBarBottom;
|
|
158
|
+
} else if (startPoint && currValue >= startPoint) {
|
|
159
|
+
activeBarBottom = state.getValuePercent(startPoint) * 100;
|
|
160
|
+
activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
|
|
161
|
+
activeBarOffset = true;
|
|
162
|
+
} else if (startPoint && currValue < startPoint) {
|
|
163
|
+
activeBarBottom = state.getThumbPercent(0) * 100;
|
|
164
|
+
activeBarHeight = state.getValuePercent(startPoint) * 100 - activeBarBottom;
|
|
165
|
+
} else if (min < 0 && currValue >= 0) {
|
|
166
|
+
activeBarBottom = state.getValuePercent(0) * 100;
|
|
167
|
+
activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
|
|
168
|
+
} else if (min < 0 && currValue < 0) {
|
|
169
|
+
activeBarBottom = state.getThumbPercent(0) * 100;
|
|
170
|
+
activeBarHeight = state.getValuePercent(0) * 100 - activeBarBottom;
|
|
171
|
+
} else {
|
|
172
|
+
activeBarBottom = state.getValuePercent(min) * 100;
|
|
173
|
+
activeBarHeight = state.getThumbPercent(0) * 100;
|
|
174
|
+
shouldRoundEnd = true;
|
|
175
|
+
}
|
|
176
|
+
} else if (!noActiveHighlight) {
|
|
177
|
+
if (Array.isArray(value)) {
|
|
178
|
+
activeBarLeft = state.getThumbPercent(0) * 100;
|
|
179
|
+
activeBarWidth = state.getThumbPercent(value.length - 1) * 100 - activeBarLeft;
|
|
180
|
+
} else if (startPoint && currValue >= startPoint) {
|
|
181
|
+
activeBarLeft = state.getValuePercent(startPoint) * 100;
|
|
182
|
+
activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
|
|
183
|
+
} else if (startPoint && currValue < startPoint) {
|
|
184
|
+
activeBarLeft = state.getThumbPercent(0) * 100;
|
|
185
|
+
activeBarWidth = state.getValuePercent(startPoint) * 100 - activeBarLeft;
|
|
186
|
+
} else if (min < 0 && currValue >= 0) {
|
|
187
|
+
activeBarLeft = state.getValuePercent(0) * 100;
|
|
188
|
+
activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
|
|
189
|
+
activeBarOffset = true;
|
|
190
|
+
} else if (min < 0 && currValue < 0) {
|
|
191
|
+
activeBarLeft = state.getThumbPercent(0) * 100;
|
|
192
|
+
activeBarWidth = state.getValuePercent(0) * 100 - activeBarLeft;
|
|
193
|
+
} else {
|
|
194
|
+
activeBarLeft = state.getValuePercent(min) * 100;
|
|
195
|
+
activeBarWidth = state.getThumbPercent(0) * 100;
|
|
196
|
+
shouldRoundStart = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
className: classnames(
|
|
204
|
+
"es-uic-relative es-uic-col-start-1 es-uic-row-start-1 es-uic-rounded-full es-uic-border",
|
|
205
|
+
!vertical && "es-uic-h-1.5 es-uic-w-full es-uic-self-center",
|
|
206
|
+
vertical && "es-uic-h-full es-uic-w-1.5 es-uic-flex-col es-uic-justify-self-center",
|
|
207
|
+
disabled ? "es-uic-border-gray-200 es-uic-bg-white" : "es-uic-border-gray-300 es-uic-bg-gray-50 es-uic-shadow-sm"
|
|
208
|
+
),
|
|
209
|
+
style: trackStyle
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
!noActiveHighlight && /* @__PURE__ */ jsx(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
className: classnames(
|
|
216
|
+
"es-uic-absolute es-uic-col-start-1 es-uic-row-start-1 es-uic-border",
|
|
217
|
+
!vertical && "es-uic-h-1.5 es-uic-w-full es-uic-self-center",
|
|
218
|
+
vertical && "es-uic-h-full es-uic-w-1.5 es-uic-flex-col es-uic-justify-self-center",
|
|
219
|
+
!vertical && shouldRoundStart && "es-uic-rounded-l-full",
|
|
220
|
+
!vertical && shouldRoundEnd && "es-uic-rounded-r-full",
|
|
221
|
+
vertical && shouldRoundStart && "es-uic-rounded-t-full",
|
|
222
|
+
vertical && shouldRoundEnd && "es-uic-rounded-b-full",
|
|
223
|
+
!vertical && activeBarOffset && "-es-uic-translate-x-px",
|
|
224
|
+
vertical && activeBarOffset && "es-uic-translate-y-px",
|
|
225
|
+
disabled ? "es-uic-border-gray-200 es-uic-bg-gray-50" : "es-uic-border-teal-500 es-uic-bg-teal-500/30"
|
|
226
|
+
),
|
|
227
|
+
style: {
|
|
228
|
+
bottom: vertical ? `${activeBarBottom}%` : null,
|
|
229
|
+
height: vertical ? `${activeBarHeight}%` : null,
|
|
230
|
+
width: vertical ? null : `${activeBarWidth}%`,
|
|
231
|
+
left: vertical ? null : `${activeBarLeft}%`
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
markers && /* @__PURE__ */ jsx(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: classnames(
|
|
239
|
+
"es-uic-relative es-uic-col-start-1 es-uic-row-start-1",
|
|
240
|
+
!vertical && "es-uic-h-1 es-uic-w-full es-uic-self-center",
|
|
241
|
+
vertical && "es-uic-h-full es-uic-w-1 es-uic-flex-col es-uic-justify-self-center"
|
|
242
|
+
),
|
|
243
|
+
children: markerData.map(([rawDotValue, labelData], index) => {
|
|
244
|
+
const dotValue = parseFloat(rawDotValue);
|
|
245
|
+
let isWithinActiveBar = false;
|
|
246
|
+
if (Array.isArray(value)) {
|
|
247
|
+
isWithinActiveBar = value[0] <= dotValue && dotValue <= value[value.length - 1];
|
|
248
|
+
} else if (startPoint && dotValue >= startPoint) {
|
|
249
|
+
isWithinActiveBar = dotValue >= startPoint && dotValue <= currValue && dotValue !== startPoint;
|
|
250
|
+
} else if (startPoint && dotValue < startPoint) {
|
|
251
|
+
isWithinActiveBar = dotValue <= startPoint && dotValue >= currValue && dotValue !== startPoint;
|
|
252
|
+
} else if (min < 0 && dotValue >= 0) {
|
|
253
|
+
isWithinActiveBar = dotValue >= 0 && dotValue <= currValue && dotValue !== 0;
|
|
254
|
+
} else if (min < 0 && dotValue < 0) {
|
|
255
|
+
isWithinActiveBar = dotValue <= 0 && dotValue >= currValue && dotValue !== 0;
|
|
256
|
+
} else {
|
|
257
|
+
isWithinActiveBar = dotValue <= currValue && dotValue > min && dotValue < max;
|
|
258
|
+
}
|
|
259
|
+
return /* @__PURE__ */ jsx(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
className: classnames(
|
|
263
|
+
"es-uic-absolute",
|
|
264
|
+
vertical ? "es-uic-h-px es-uic-w-1" : "es-uic-h-1 es-uic-w-px es-uic-translate-x-1/2",
|
|
265
|
+
!(dotValue === min || dotValue === max || dotValue === startPoint && !noActiveHighlight || min < 0 && dotValue === 0 && !noActiveHighlight || isWithinActiveBar) && "es-uic-bg-gray-300",
|
|
266
|
+
!noActiveHighlight && isWithinActiveBar && "es-uic-bg-teal-500/75"
|
|
267
|
+
),
|
|
268
|
+
style: {
|
|
269
|
+
left: vertical ? null : `${state.getValuePercent(dotValue) * 100}%`,
|
|
270
|
+
top: vertical ? `calc(${state.getValuePercent(dotValue) * 100}%)` : null
|
|
271
|
+
},
|
|
272
|
+
children: /* @__PURE__ */ jsx(
|
|
273
|
+
"span",
|
|
274
|
+
{
|
|
275
|
+
className: classnames(
|
|
276
|
+
"es-uic-absolute es-uic-select-none es-uic-text-xs es-uic-transition-colors",
|
|
277
|
+
vertical ? "es-uic-left-3.5 es-uic-top-0 -es-uic-translate-y-1/2" : "es-uic-left-0 es-uic-top-2.5 -es-uic-translate-x-1/2",
|
|
278
|
+
(Array.isArray(value) ? value.includes(Number(dotValue)) : value === Number(dotValue) && !disabled) ? "es-uic-text-teal-700" : "es-uic-text-gray-300"
|
|
279
|
+
),
|
|
280
|
+
children: markers && markers !== "dots" && labelData
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
},
|
|
284
|
+
index
|
|
285
|
+
);
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
),
|
|
289
|
+
/* @__PURE__ */ jsx("div", { className: "es-uic-relative es-uic-col-start-1 es-uic-row-start-1 es-uic-p-px", children: state.values.map((_, i) => /* @__PURE__ */ jsxs(
|
|
290
|
+
$6f909507e6374d18$export$2c1b491743890dec,
|
|
291
|
+
{
|
|
292
|
+
index: i,
|
|
293
|
+
"aria-label": thumbLabels == null ? void 0 : thumbLabels[i],
|
|
294
|
+
className: classnames(
|
|
295
|
+
"es-uic-absolute es-uic-size-3.5 es-uic-rounded-full es-uic-border es-uic-transition es-uic-duration-300",
|
|
296
|
+
vertical ? "!-es-uic-translate-y-1/2 !es-uic-translate-x-0" : "!-es-uic-translate-x-1/2 !es-uic-translate-y-0",
|
|
297
|
+
"es-uic-shadow dragging:es-uic-bg-teal-600 disabled:es-uic-border-gray-200 disabled:es-uic-bg-gray-100 disabled:es-uic-shadow-none",
|
|
298
|
+
"focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
|
|
299
|
+
"es-uic-border-teal-600 es-uic-bg-teal-500 es-uic-shadow-teal-600/50"
|
|
300
|
+
),
|
|
301
|
+
onFocus: () => {
|
|
302
|
+
if (state.values.length < 2) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
setCurrentThumbIndex(i);
|
|
306
|
+
},
|
|
307
|
+
children: [
|
|
308
|
+
inputField && state.values.length > 1 && currentThumbIndex === i && /* @__PURE__ */ jsx("div", { className: "es-uic-m-0.5 es-uic-size-2 es-uic-rounded-full es-uic-bg-teal-100" }),
|
|
309
|
+
thumbContent && thumbContent(i)
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
i
|
|
313
|
+
)) })
|
|
314
|
+
] });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
after && /* @__PURE__ */ jsx("div", { className: "es-uic-flex es-uic-shrink-0 es-uic-items-center es-uic-gap-1", children: after })
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
const NumberInputField = (props) => {
|
|
326
|
+
const { ...other } = props;
|
|
327
|
+
const state = useContext($6f909507e6374d18$export$1e7083018727fa60);
|
|
328
|
+
const labelProps = $64fa3d84918910a7$export$fabf2dc03a41866e($01b77f81d0f07f68$export$75b6ee27786ba447);
|
|
329
|
+
const isSingleValue = state.values.length === 1;
|
|
330
|
+
const fieldIndex = isSingleValue ? 0 : props.focusedThumb ?? 0;
|
|
331
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
332
|
+
/* @__PURE__ */ jsx(
|
|
333
|
+
NumberPicker,
|
|
334
|
+
{
|
|
335
|
+
"aria-labelledby": labelProps.id,
|
|
336
|
+
value: state.values[fieldIndex] ?? null,
|
|
337
|
+
onChange: (v) => state.setThumbValue(fieldIndex, v),
|
|
338
|
+
size: "compact",
|
|
339
|
+
min: state.getThumbMinValue(fieldIndex),
|
|
340
|
+
max: state.getThumbMaxValue(fieldIndex),
|
|
341
|
+
onBlur: () => {
|
|
342
|
+
if (isSingleValue) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
props.setFocusedThumb(-1);
|
|
346
|
+
},
|
|
347
|
+
className: fieldIndex === -1 && !isSingleValue ? "es-uic-invisible" : "",
|
|
348
|
+
...other
|
|
349
|
+
}
|
|
350
|
+
),
|
|
351
|
+
fieldIndex === -1 && !isSingleValue && /* @__PURE__ */ jsx(
|
|
352
|
+
$6f909507e6374d18$export$a590f758a961cb5b,
|
|
353
|
+
{
|
|
354
|
+
className: classnames("es-uic-text-xs es-uic-tabular-nums es-uic-text-gray-600"),
|
|
355
|
+
children: ({ state: state2 }) => state2.values.map((_, i) => state2.getThumbValueLabel(i)).join(" – ")
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
] });
|
|
359
|
+
};
|
|
360
|
+
export {
|
|
361
|
+
Slider
|
|
362
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an array of markers based on the provided minimum and maximum values and step.
|
|
3
|
+
* If the step is less than 10, only markers divisible by 5 and 10 are included.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} min - The minimum value for the markers.
|
|
6
|
+
* @param {number} max - The maximum value for the markers.
|
|
7
|
+
* @param {number} [step=10] - The step between each marker. Default is 10.
|
|
8
|
+
*
|
|
9
|
+
* @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.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* generateMarkers(-20, 50, 10); // { '-20': '-20', '-10': '-10', '0': '0', '10': '10', '20': '20', '30': '30', '40': '40', '50': '50' }
|
|
13
|
+
*
|
|
14
|
+
* @preserve
|
|
15
|
+
*/
|
|
16
|
+
const generateMarkers = (min, max, step = 10) => {
|
|
17
|
+
const smallStep = step < 10 && Math.abs(max - min) > 20;
|
|
18
|
+
const markers = [];
|
|
19
|
+
if (min < 0) {
|
|
20
|
+
for (let i = min; i < 0; i += step) {
|
|
21
|
+
markers.push(i.toString());
|
|
22
|
+
}
|
|
23
|
+
for (let i = 0; i <= max; i += step) {
|
|
24
|
+
markers.push(i.toString());
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
for (let i = min; i <= max; i += step) {
|
|
28
|
+
markers.push(i.toString());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return markers.reduce((acc, marker) => {
|
|
32
|
+
if (smallStep && marker % 5 !== 0) {
|
|
33
|
+
return acc;
|
|
34
|
+
}
|
|
35
|
+
if (smallStep && marker % 10 !== 0) {
|
|
36
|
+
acc[marker] = "";
|
|
37
|
+
} else {
|
|
38
|
+
acc[marker] = marker;
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
generateMarkers
|
|
45
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
3
|
+
/**
|
|
4
|
+
* A simple spacer/divider component, with optional text or icon.
|
|
5
|
+
*
|
|
6
|
+
* @component
|
|
7
|
+
* @param {Object} props - Component props.
|
|
8
|
+
* @param {SpacerSize} [props.size='m'] - The size of the spacer. Can be 's' or 'm'.
|
|
9
|
+
* @param {boolean} [props.border=false] - Whether to show a border in the middle.
|
|
10
|
+
* @param {string} [props.className] - Additional classes to add.
|
|
11
|
+
* @param {string} [props.text] - Text to display.
|
|
12
|
+
* @param {JSX.Element} [props.icon] - Icon to display.
|
|
13
|
+
* @param {boolean} [props.vertical=false] - Whether the spacer is vertical.
|
|
14
|
+
*
|
|
15
|
+
* @returns {JSX.Element} The Spacer component.
|
|
16
|
+
*
|
|
17
|
+
* @typedef {'px' | 'xs' | 's' | 'm'} SpacerSize
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <Spacer />
|
|
21
|
+
*
|
|
22
|
+
* <Spacer border />
|
|
23
|
+
*
|
|
24
|
+
* <Spacer vertical />
|
|
25
|
+
* <Spacer vertical border />
|
|
26
|
+
*
|
|
27
|
+
* <Spacer text='My divider' icon={icons.myIcon} />
|
|
28
|
+
*
|
|
29
|
+
* @preserve
|
|
30
|
+
*/
|
|
31
|
+
const Spacer = (props) => {
|
|
32
|
+
const { size = "m", border, className, text, icon, vertical = false } = props;
|
|
33
|
+
const sizes = {
|
|
34
|
+
px: {
|
|
35
|
+
sizeHorizontal: "es-uic-h-px",
|
|
36
|
+
sizeHorizontalBorder: "es-uic-h-px",
|
|
37
|
+
sizeVertical: "es-uic-w-px",
|
|
38
|
+
sizeVerticalBorder: "es-uic-w-px"
|
|
39
|
+
},
|
|
40
|
+
xs: {
|
|
41
|
+
sizeHorizontal: "es-uic-h-1",
|
|
42
|
+
sizeHorizontalBorder: "es-uic-h-0.5",
|
|
43
|
+
sizeVertical: "es-uic-w-1",
|
|
44
|
+
sizeVerticalBorder: "es-uic-w-0.5"
|
|
45
|
+
},
|
|
46
|
+
s: {
|
|
47
|
+
sizeHorizontal: "es-uic-h-2.5",
|
|
48
|
+
sizeHorizontalBorder: "es-uic-h-1",
|
|
49
|
+
sizeVertical: "es-uic-w-2.5",
|
|
50
|
+
sizeVerticalBorder: "es-uic-w-1"
|
|
51
|
+
},
|
|
52
|
+
m: {
|
|
53
|
+
sizeHorizontal: "es-uic-h-5",
|
|
54
|
+
sizeHorizontalBorder: "es-uic-h-2",
|
|
55
|
+
sizeVertical: "es-uic-w-5",
|
|
56
|
+
sizeVerticalBorder: "es-uic-w-2"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const spaceClass = classnames(
|
|
60
|
+
vertical ? "es-uic-h-full" : "es-uic-w-full",
|
|
61
|
+
!vertical && !border && sizes[size].sizeHorizontal,
|
|
62
|
+
!vertical && border && sizes[size].sizeHorizontalBorder,
|
|
63
|
+
vertical && !border && sizes[size].sizeVertical,
|
|
64
|
+
vertical && border && sizes[size].sizeVerticalBorder,
|
|
65
|
+
className
|
|
66
|
+
);
|
|
67
|
+
if (text || icon) {
|
|
68
|
+
return /* @__PURE__ */ jsxs("div", { className: classnames("es-uic-flex es-uic-items-center es-uic-gap-1.5", className), children: [
|
|
69
|
+
icon && /* @__PURE__ */ jsx("span", { className: "es-uic-shrink-0 es-uic-rounded es-uic-bg-gray-500 es-uic-p-0.5 es-uic-text-gray-50 es-uic-shadow-sm [&>svg]:es-uic-size-5.5", children: icon }),
|
|
70
|
+
text && /* @__PURE__ */ jsx("span", { className: "es-uic-shrink-0 es-uic-text-balance es-uic-text-sm es-uic-text-gray-500", children: text }),
|
|
71
|
+
border && /* @__PURE__ */ jsx("div", { className: "es-uic-h-px es-uic-w-full es-uic-bg-gray-300" })
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
if (border) {
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
76
|
+
size !== "px" && /* @__PURE__ */ jsx("div", { className: spaceClass }),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: classnames(
|
|
81
|
+
"es-uic-bg-gray-300",
|
|
82
|
+
vertical ? "es-uic-h-full es-uic-w-px" : "es-uic-h-px es-uic-w-full"
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
size !== "px" && /* @__PURE__ */ jsx("div", { className: spaceClass })
|
|
87
|
+
] });
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ jsx("div", { className: spaceClass });
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
Spacer
|
|
93
|
+
};
|