@eightshift/ui-components 5.6.0 → 6.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.
- package/dist/{Button-BhEIfWLY.js → Button-BXjXzdW_.js} +13 -13
- package/dist/{Dialog-B8p4Ymh7.js → Dialog-D8bjn-nh.js} +404 -77
- package/dist/{FieldError-B8BgFmIQ.js → FieldError-DwBG6m1U.js} +2 -2
- package/dist/{FocusScope-B5vxRkHm.js → FocusScope-BMk5oZCk.js} +8 -8
- package/dist/{Heading-B5aEynOM.js → Heading-BmRX4BRL.js} +3 -3
- package/dist/{Hidden-rE6uR-lr.js → Hidden-Rfj-STx7.js} +4 -4
- package/dist/{Input-8yja_IHC.js → Input-CNNksOWg.js} +11 -11
- package/dist/{Label-DWVaNd2E.js → Label-D8a3eYb-.js} +4 -4
- package/dist/{List-Bll1lQEW.js → List-BGHOoFf0.js} +8 -8
- package/dist/{ListBox-CEpKw7yC.js → ListBox-Dd37zMvs.js} +40 -41
- package/dist/{OverlayArrow-DDfa8khI.js → OverlayArrow-DokC40S3.js} +6 -6
- package/dist/{PortalProvider---wyKpMr.js → PortalProvider-CHPnqDSH.js} +2 -2
- package/dist/RadioGroup-BVFvITWO.js +371 -0
- package/dist/{SearchField-D6mPli0i.js → SearchField-CHYnN-jt.js} +16 -16
- package/dist/{SelectionManager-D77bfEbg.js → SelectionManager-N8X7T_4D.js} +44 -46
- package/dist/{SharedElementTransition-BjRNHsjx.js → SharedElementTransition-BDT84GtD.js} +3 -3
- package/dist/{Slider-DfU6bRtH.js → Slider-CL5CM9S8.js} +23 -23
- package/dist/{Text-AxKZjtFm.js → Text-ztX6G1zR.js} +3 -3
- package/dist/{VisuallyHidden-CgnIuZJ2.js → VisuallyHidden-DTUuKFiI.js} +4 -4
- package/dist/assets/style-admin.css +12156 -2
- package/dist/assets/style-editor.css +12156 -2
- package/dist/assets/style.css +12162 -2
- package/dist/assets/wp-overrides/allow-full-width-blocks.css +6 -0
- package/dist/assets/wp-overrides/fix-label-text-case.css +29 -0
- package/dist/assets/wp-overrides/increase-sidebar-width.css +4 -0
- package/dist/assets/wp-overrides/make-block-messages-nicer.css +155 -0
- package/dist/assets/wp-overrides/replace-fonts.css +8 -0
- package/dist/assets/wp-overrides/restyle-tooltips.css +194 -0
- package/dist/assets/wp-overrides/round-corners.css +200 -0
- package/dist/assets/wp-overrides/unify-button-sizes.css +5 -0
- package/dist/clsx-DgYk2OaC.js +16 -0
- package/dist/{Color-WxFE7lQB.js → color-swatch-CFIuSPcO.js} +124 -6
- package/dist/components/animated-visibility/animated-visibility.js +25 -17
- package/dist/components/base-control/base-control.js +8 -5
- package/dist/components/base-control/container.js +204 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -1
- package/dist/components/button/button.js +249 -155
- package/dist/components/checkbox/checkbox.js +96 -37
- package/dist/components/color-pickers/color-picker.js +16 -7
- package/dist/components/color-pickers/color-swatch.js +5 -57
- package/dist/components/color-pickers/gradient-editor.js +161 -138
- package/dist/components/color-pickers/solid-color-picker.js +308 -206
- package/dist/components/component-toggle/component-toggle.js +12 -8
- package/dist/components/container-panel/container-panel.js +54 -31
- package/dist/components/draggable/draggable-handle.js +8 -7
- package/dist/components/draggable/draggable.js +2 -2
- package/dist/components/draggable-list/draggable-list-item.js +21 -12
- package/dist/components/draggable-list/draggable-list.js +19 -21
- package/dist/components/expandable/expandable.js +56 -28
- package/dist/components/index.js +7 -21
- package/dist/components/input-field/input-field.js +112 -35
- package/dist/components/item-collection/item-collection.js +1 -1
- package/dist/components/link-input/link-input.js +181 -121
- package/dist/components/matrix-align/matrix-align.js +54 -21
- package/dist/components/menu/menu.js +26 -34
- package/dist/components/modal/modal.js +31 -28
- package/dist/components/notice/notice.js +45 -28
- package/dist/components/number-picker/number-picker.js +151 -101
- package/dist/components/option-select/option-select.js +40 -4
- package/dist/components/options-panel/options-panel.js +52 -25
- package/dist/components/placeholders/file-picker-shell.js +10 -10
- package/dist/components/placeholders/file-placeholder.js +14 -6
- package/dist/components/placeholders/image-placeholder.js +14 -4
- package/dist/components/placeholders/media-placeholder.js +11 -4
- package/dist/components/popover/popover.js +14 -11
- package/dist/components/portal-provider/portal-provider.js +1 -1
- package/dist/components/radio/radio.js +118 -429
- package/dist/components/repeater/repeater-item.js +7 -10
- package/dist/components/repeater/repeater.js +9 -15
- package/dist/components/responsive/mini-responsive.js +53 -62
- package/dist/components/responsive/responsive-legacy.js +1 -2
- package/dist/components/responsive/responsive.js +27 -28
- package/dist/components/responsive-preview/responsive-preview.js +1 -2
- package/dist/components/rich-label/rich-label.js +5 -5
- package/dist/components/select/async-multi-select.js +467 -100
- package/dist/components/select/{v2/async-select.js → async-select.js} +182 -106
- package/dist/components/select/multi-select.js +437 -83
- package/dist/components/select/shared.js +14 -42
- package/dist/components/select/single-select.js +349 -54
- package/dist/components/slider/column-config-slider.js +138 -45
- package/dist/components/slider/slider.js +265 -205
- package/dist/components/slider/utils.js +32 -1
- package/dist/components/smart-image/smart-image.js +27 -6
- package/dist/components/smart-image/worker-inline.js +1 -1
- package/dist/components/spacer/spacer.js +2 -2
- package/dist/components/tabs/tabs.js +370 -101
- package/dist/components/toggle/switch.js +174 -39
- package/dist/components/toggle/toggle.js +6 -3
- package/dist/components/toggle-button/toggle-button.js +140 -56
- package/dist/components/tooltip/tooltip.js +27 -26
- package/dist/{context-DMOmz986.js → context-BQvmiUqb.js} +3 -3
- package/dist/{default-i18n-DBm-GqWM.js → default-i18n-CnQeC5Pl.js} +10 -10
- package/dist/{general-6STKQIrk.js → general-B6pOveVp.js} +13 -12
- package/dist/icons/icons.js +28 -9
- package/dist/icons/jsx-svg.js +1 -1
- package/dist/icons/spinner.js +3 -1
- package/dist/{index-Dq3gT5pW.js → index-BHpUy2Ix.js} +1 -1
- package/dist/{index-DjyEH0Gg.js → index-oFgxU4zs.js} +6 -4
- package/dist/index.js +6 -20
- package/dist/proxy-0B6wWuDe.js +7409 -0
- package/dist/{react-jsx-parser.min-VUl-CuCv.js → react-jsx-parser.min-B_hvYYa1.js} +5 -5
- package/dist/{Select-CHzjZxXy.js → shared-DwjRce5e.js} +170 -36
- package/dist/{textSelection-DbCKqaw8.js → textSelection-CwHUtNVX.js} +1 -1
- package/dist/{useButton-B2EaQJT_.js → useButton-DdZrS1Kz.js} +3 -3
- package/dist/{useEvent-BifIGnVS.js → useEvent-BD7Olibq.js} +1 -1
- package/dist/{useFilter-BPcJ-Jzv.js → useFilter-bhxeEDg8.js} +1 -1
- package/dist/{useFocusRing-Cgm0R4Cf.js → useFocusRing-D3b7Kh4P.js} +1 -1
- package/dist/{useFormReset-yV9VVy9R.js → useFormReset-WUv2PdFO.js} +1 -1
- package/dist/{useFormValidation-CeNsUGWK.js → useFormValidation-DQeXkyLm.js} +2 -2
- package/dist/{useHover-BRDW3y7-.js → useHover-Bycb7BsD.js} +7 -7
- package/dist/{useLabel-C8umX0gk.js → useLabel-Bnv4-T24.js} +2 -2
- package/dist/{useLabels-Cdxi6JSa.js → useLabels-B49ptFDX.js} +1 -1
- package/dist/{useListState-DZycqxCn.js → useListState-ZKhRO8ML.js} +1 -1
- package/dist/{useLocalizedStringFormatter-eaZiN2tE.js → useLocalizedStringFormatter-NETP-8H8.js} +1 -1
- package/dist/{useNumberField-CEA9Q4w_.js → useNumberField-D2fUHql3.js} +10 -10
- package/dist/{useNumberFormatter-BCmkV-7c.js → useNumberFormatter-DGvuRCn7.js} +1 -1
- package/dist/{usePress-BCEPS3hl.js → usePress-B8OteQMu.js} +6 -6
- package/dist/{useSingleSelectListState-BFZEfeqI.js → useSingleSelectListState-BBTu4shO.js} +2 -2
- package/dist/{useToggle-DNoP2bvV.js → useToggle-BZhaYwZl.js} +4 -4
- package/dist/{useToggleState-CzN79ary.js → useToggleState-VkXJjsru.js} +1 -1
- package/dist/utilities/general.js +2 -2
- package/dist/utilities/hash.js +30 -0
- package/dist/utilities/index.js +4 -6
- package/dist/{utils-cvK1vxO7.js → utils-DGpXyJOJ.js} +29 -42
- package/dist/workers/image-analysis.worker.js +3 -3
- package/package.json +26 -23
- package/dist/ColorSwatch-xVS3rMYS.js +0 -66
- package/dist/Select-ef7c0426.esm-BJmjGGzK.js +0 -2474
- package/dist/Separator-DcqCdD4k.js +0 -344
- package/dist/_commonjsHelpers-BhWcALO8.js +0 -38
- package/dist/assets/wp-font-enhancements.css +0 -2
- package/dist/assets/wp-ui-enhancements.css +0 -2
- package/dist/components/select/async-single-select.js +0 -138
- package/dist/components/select/custom-select-default-components.js +0 -38
- package/dist/components/select/multi-select-components.js +0 -8
- package/dist/components/select/react-select-component-wrappers.js +0 -90
- package/dist/components/select/styles.js +0 -49
- package/dist/components/select/v2/async-multi-select.js +0 -433
- package/dist/components/select/v2/multi-select.js +0 -404
- package/dist/components/select/v2/shared.js +0 -69
- package/dist/components/select/v2/single-select.js +0 -358
- package/dist/index-641ee5b8.esm-DiwvO-RP.js +0 -3139
- package/dist/modifiers.esm-BuJQPI1X.js +0 -31
- package/dist/multi-select-components-B3KuDyYd.js +0 -3744
- package/dist/react-select-async.esm-_4pk-41v.js +0 -107
- package/dist/react-select.esm-BeuAkAyY.js +0 -15
- package/dist/sha256-C56UDWfQ.js +0 -533
- package/dist/useDragAndDrop-DUXKDS0N.js +0 -3925
- package/dist/wp/wp-font-enhancements.js +0 -1
- package/dist/wp/wp-ui-enhancements.js +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $ as $
|
|
3
|
-
import { $ as $
|
|
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-DfU6bRtH.js";
|
|
2
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-D8a3eYb-.js";
|
|
3
|
+
import { $ as $6f909507e6374d18$export$472062a354075cee, a as $6f909507e6374d18$export$105594979f116971, b as $6f909507e6374d18$export$2c1b491743890dec, c as $6f909507e6374d18$export$a590f758a961cb5b } from "../../Slider-CL5CM9S8.js";
|
|
5
4
|
import { BaseControl } from "../base-control/base-control.js";
|
|
6
|
-
import { c as clsx } from "../../
|
|
5
|
+
import { c as clsx } from "../../clsx-DgYk2OaC.js";
|
|
7
6
|
import { NumberPicker } from "../number-picker/number-picker.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { generateMarkers, generateGridTemplate } from "./utils.js";
|
|
8
|
+
import { HStack } from "../layout/hstack.js";
|
|
9
|
+
import { A as AnimatePresence, m as motion } from "../../proxy-0B6wWuDe.js";
|
|
10
10
|
/**
|
|
11
11
|
* A single/multi-thumb slider component.
|
|
12
12
|
*
|
|
@@ -22,7 +22,6 @@ import { generateMarkers } from "./utils.js";
|
|
|
22
22
|
* @param {Number} [props.step=1] - The step value of the slider.
|
|
23
23
|
* @param {Number} [props.startPoint] - The starting point of the slider.
|
|
24
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
25
|
* @param {Number | Number[]} props.value - The current value of the slider.
|
|
27
26
|
* @param {Function} props.onChange - Function to run when the value changes.
|
|
28
27
|
* @param {Function} props.onChangeEnd - Function to run when the value change ends.
|
|
@@ -33,9 +32,13 @@ import { generateMarkers } from "./utils.js";
|
|
|
33
32
|
* @param {JSX.Element} [props.after] - Element to display after the slider.
|
|
34
33
|
* @param {string[]} [props.thumbLabels] - ARIA labels for the thumbs.
|
|
35
34
|
* @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`.
|
|
35
|
+
* @param {Function} [props.tooltipContent] - If provided, the function will format the tooltip content. `(value) => JSX.Element`.
|
|
36
36
|
* @param {string} [props.labelClassName] - Additional classes to pass to the label.
|
|
37
37
|
* @param {Object<string, any>} [props.trackStyle] - Additional style for the track.
|
|
38
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.flat] - If `true`, component will look more flat. Useful for nested layer of controls.
|
|
40
|
+
* @param {boolean} [props.trackBgGradientSupport] - If `true`, parts of the track will get additional background size and position settings to make the gradient more seamless. Supported only in horizontal mode. BETA!
|
|
41
|
+
* @param {boolean} [props.noActiveHighlight] - If `true`, the active area highlight will not be shown.
|
|
39
42
|
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
40
43
|
*
|
|
41
44
|
* @returns {JSX.Element} The Slider component.
|
|
@@ -61,9 +64,8 @@ const Slider = (props) => {
|
|
|
61
64
|
min = 0,
|
|
62
65
|
max = 100,
|
|
63
66
|
step = 1,
|
|
64
|
-
startPoint,
|
|
67
|
+
startPoint: rawStartPoint,
|
|
65
68
|
markers,
|
|
66
|
-
noActiveHighlight = false,
|
|
67
69
|
value,
|
|
68
70
|
onChange,
|
|
69
71
|
onChangeEnd,
|
|
@@ -74,16 +76,24 @@ const Slider = (props) => {
|
|
|
74
76
|
after,
|
|
75
77
|
thumbLabels,
|
|
76
78
|
thumbContent,
|
|
79
|
+
tooltipContent = (value2) => value2,
|
|
77
80
|
labelClassName,
|
|
78
81
|
trackStyle,
|
|
82
|
+
trackContainerStyle,
|
|
83
|
+
trackBgGradientSupport,
|
|
84
|
+
noActiveHighlight,
|
|
79
85
|
markerStep = step,
|
|
86
|
+
flat,
|
|
80
87
|
hidden,
|
|
81
88
|
...other
|
|
82
89
|
} = props;
|
|
83
|
-
const [currentThumbIndex, setCurrentThumbIndex] = useState(-1);
|
|
84
90
|
if (hidden) {
|
|
85
91
|
return null;
|
|
86
92
|
}
|
|
93
|
+
let startPoint = rawStartPoint;
|
|
94
|
+
if (Array.isArray(value) && rawStartPoint) {
|
|
95
|
+
startPoint = null;
|
|
96
|
+
}
|
|
87
97
|
let generatedMarkers = {};
|
|
88
98
|
if (typeof markers === "object" && Object.keys(markers).length > 0) {
|
|
89
99
|
generatedMarkers = markers;
|
|
@@ -91,8 +101,9 @@ const Slider = (props) => {
|
|
|
91
101
|
if (markers === true || markers === "dots") {
|
|
92
102
|
generatedMarkers = generateMarkers(min, max, markerStep);
|
|
93
103
|
}
|
|
94
|
-
const markerEntries = Object.entries(generatedMarkers);
|
|
104
|
+
const markerEntries = Object.entries(generatedMarkers).toSorted((a, b) => parseFloat(a[0]) - parseFloat(b[0]));
|
|
95
105
|
const markerData = vertical ? markerEntries.toReversed() : markerEntries;
|
|
106
|
+
const isRange = Array.isArray(value);
|
|
96
107
|
return /* @__PURE__ */ jsx(
|
|
97
108
|
$6f909507e6374d18$export$472062a354075cee,
|
|
98
109
|
{
|
|
@@ -115,231 +126,280 @@ const Slider = (props) => {
|
|
|
115
126
|
help,
|
|
116
127
|
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
117
128
|
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
|
-
|
|
129
|
+
(!inputField || inputField && isRange) && /* @__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(" – ") }),
|
|
130
|
+
inputField && !isRange && /* @__PURE__ */ jsx(
|
|
131
|
+
NumberPicker,
|
|
121
132
|
{
|
|
122
|
-
|
|
133
|
+
"aria-label": label || __("Slider value", "eightshift-ui-components"),
|
|
134
|
+
value,
|
|
135
|
+
onChange,
|
|
123
136
|
min,
|
|
124
137
|
max,
|
|
125
138
|
step,
|
|
126
|
-
|
|
127
|
-
setFocusedThumb: setCurrentThumbIndex
|
|
139
|
+
size: "small"
|
|
128
140
|
}
|
|
129
141
|
)
|
|
130
142
|
] }),
|
|
131
143
|
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
132
144
|
className: labelClassName,
|
|
133
145
|
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(
|
|
135
|
-
/* @__PURE__ */ jsx($6f909507e6374d18$export$105594979f116971, { className: clsx("es:isolate
|
|
136
|
-
|
|
137
|
-
let
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
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;
|
|
146
|
+
before && /* @__PURE__ */ jsx(HStack, { children: before }),
|
|
147
|
+
/* @__PURE__ */ jsx($6f909507e6374d18$export$105594979f116971, { className: clsx("es:isolate", vertical && "es:mx-auto es:h-48", !vertical && "es:grow"), children: ({ state }) => {
|
|
148
|
+
const thumbPositions = state.values.map((_, i) => Math.round(state.getThumbPercent(i) * 100));
|
|
149
|
+
let gridTemplate = generateGridTemplate(thumbPositions, startPoint ? [startPoint] : [], { spaceBetween: 3 });
|
|
150
|
+
if (vertical) {
|
|
151
|
+
gridTemplate.reverse();
|
|
152
|
+
}
|
|
153
|
+
const tracks = gridTemplate.map((v) => {
|
|
154
|
+
if (v.startsWith("minmax")) {
|
|
155
|
+
return parseFloat(v.replace("minmax(0, ", "").replace("fr)", ""));
|
|
156
|
+
}
|
|
157
|
+
if (v.endsWith("fr")) {
|
|
158
|
+
return parseFloat(v.replace("fr", ""));
|
|
165
159
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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;
|
|
160
|
+
return null;
|
|
161
|
+
});
|
|
162
|
+
const trackIndices = gridTemplate.map((v, index) => {
|
|
163
|
+
if (v.startsWith("minmax") || v.endsWith("fr")) {
|
|
164
|
+
return index;
|
|
187
165
|
}
|
|
166
|
+
return null;
|
|
167
|
+
}).filter(Boolean);
|
|
168
|
+
const markerIndices = gridTemplate.map((colWidth, index) => {
|
|
169
|
+
if (colWidth === "auto" || colWidth.endsWith("px")) {
|
|
170
|
+
return index + 1;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}).filter(Boolean);
|
|
174
|
+
if (vertical) {
|
|
175
|
+
markerIndices.reverse();
|
|
188
176
|
}
|
|
189
|
-
return /* @__PURE__ */ jsxs(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
177
|
+
return /* @__PURE__ */ jsxs(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
className: clsx("es:grid", trackBgGradientSupport && "es:@container", vertical && "es:justify-items-center es:h-full", !vertical && "es:items-center"),
|
|
181
|
+
style: {
|
|
182
|
+
gridTemplateColumns: vertical ? "1fr" : gridTemplate.join(" "),
|
|
183
|
+
gridTemplateRows: vertical ? gridTemplate.join(" ") : "1fr",
|
|
184
|
+
...trackContainerStyle
|
|
185
|
+
},
|
|
186
|
+
children: [
|
|
187
|
+
markers && /* @__PURE__ */ jsx(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
className: clsx(
|
|
191
|
+
"es:flex es:justify-between",
|
|
192
|
+
!vertical && ["es:w-fill es:self-center", "es:row-1 es:mx-0.75"],
|
|
193
|
+
vertical && ["es:h-fill es:flex es:flex-col es:justify-self-center", "es:col-1 es:my-0.75"]
|
|
194
|
+
),
|
|
195
|
+
style: {
|
|
196
|
+
gridColumn: vertical ? null : `1 / span ${gridTemplate.length}`,
|
|
197
|
+
gridRow: vertical ? `1 / span ${gridTemplate.length}` : null
|
|
198
|
+
},
|
|
199
|
+
children: markerData.map(([rawDotValue, labelData], index) => {
|
|
200
|
+
const dotValue = parseFloat(rawDotValue);
|
|
201
|
+
let isWithinActiveBar = false;
|
|
202
|
+
if (isRange) {
|
|
203
|
+
isWithinActiveBar = dotValue > state.values[0] && dotValue < state.values.at(-1);
|
|
204
|
+
} else if (startPoint) {
|
|
205
|
+
if (state.values[0] < startPoint) {
|
|
206
|
+
isWithinActiveBar = dotValue > state.values[0] && dotValue <= startPoint;
|
|
207
|
+
} else {
|
|
208
|
+
isWithinActiveBar = dotValue >= startPoint && dotValue < state.values[0];
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
isWithinActiveBar = dotValue < state.values[0];
|
|
212
|
+
}
|
|
213
|
+
return /* @__PURE__ */ jsx(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
className: clsx(
|
|
217
|
+
"es:relative",
|
|
218
|
+
"es:size-0.75 es:place-self-center es:rounded-2xl",
|
|
219
|
+
!disabled && isWithinActiveBar && "es:bg-accent-50",
|
|
220
|
+
!disabled && !isWithinActiveBar && "es:bg-surface-500",
|
|
221
|
+
disabled && isWithinActiveBar && "es:bg-secondary-300",
|
|
222
|
+
disabled && !isWithinActiveBar && "es:bg-secondary-400",
|
|
223
|
+
state.values.includes(dotValue) && "es:opacity-0"
|
|
224
|
+
),
|
|
225
|
+
children: /* @__PURE__ */ jsx(
|
|
226
|
+
"span",
|
|
227
|
+
{
|
|
228
|
+
className: clsx(
|
|
229
|
+
"es:absolute es:transition",
|
|
230
|
+
!vertical && "es:top-5 es:-translate-x-1/4 es:-rotate-90 es:text-end",
|
|
231
|
+
vertical && "es:left-5 es:-translate-y-1/4 es:text-start",
|
|
232
|
+
"es:select-none es:text-10 es:tracking-wide es:tabular-nums",
|
|
233
|
+
isWithinActiveBar ? "es:text-surface-400" : "es:text-surface-300",
|
|
234
|
+
disabled && "es:opacity-0"
|
|
235
|
+
),
|
|
236
|
+
children: markers && markers !== "dots" && labelData
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
},
|
|
240
|
+
index
|
|
241
|
+
);
|
|
242
|
+
})
|
|
243
|
+
}
|
|
232
244
|
),
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
state.values.map((_, i) => {
|
|
246
|
+
return /* @__PURE__ */ jsxs(
|
|
247
|
+
$6f909507e6374d18$export$2c1b491743890dec,
|
|
248
|
+
{
|
|
249
|
+
index: i,
|
|
250
|
+
"aria-label": thumbLabels?.[i],
|
|
251
|
+
className: clsx(
|
|
252
|
+
!vertical && ["es:h-10 es:w-0.75", "es:row-1"],
|
|
253
|
+
vertical && ["es:w-10 es:h-0.75", "es:col-1"],
|
|
254
|
+
"es:z-20",
|
|
255
|
+
"es:static! es:rounded-md es:transition es:duration-300",
|
|
256
|
+
"es:origin-center",
|
|
257
|
+
"es:hover:ring-[0.25px] es:focus-visible:ring-[0.5px] es:dragging:ring-[1px] es:ring-accent-500",
|
|
258
|
+
"es:transform-none!",
|
|
259
|
+
"es:dragging:es:bg-accent-600 es:disabled:bg-secondary-400",
|
|
260
|
+
"es:focus-visible:outline-2 es:outline-offset-2 es:outline-accent-500/40",
|
|
261
|
+
"es:bg-accent-500",
|
|
262
|
+
"es:hover:ring-accent-600",
|
|
263
|
+
"es:dragging:bg-accent-600 es:dragging:ring-accent-600",
|
|
264
|
+
!disabled && "es:hover:not-dragging:cursor-grab",
|
|
265
|
+
"es:justify-self-center",
|
|
266
|
+
!flat && !disabled && "es:shadow-xs es:shadow-black/5"
|
|
267
|
+
),
|
|
268
|
+
style: {
|
|
269
|
+
gridColumn: vertical ? null : markerIndices[i],
|
|
270
|
+
gridRow: vertical ? markerIndices[i] : null
|
|
271
|
+
},
|
|
272
|
+
children: [
|
|
273
|
+
thumbContent && thumbContent(i),
|
|
274
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: i === state.focusedThumb && /* @__PURE__ */ jsx(
|
|
275
|
+
motion.div,
|
|
276
|
+
{
|
|
277
|
+
className: clsx(
|
|
278
|
+
"es:absolute es:text-nowrap es:w-fit es:min-w-5 es:h-6",
|
|
279
|
+
!vertical && "es:bottom-12 es:-translate-x-1/2",
|
|
280
|
+
vertical && "es:left-12 es:-translate-y-1/2",
|
|
281
|
+
"es:bg-surface-50/80 es:text-surface-700",
|
|
282
|
+
"es:backdrop-blur-xs",
|
|
283
|
+
"es:text-12 es:leading-none",
|
|
284
|
+
"es:py-1 es:px-2 es:rounded-lg",
|
|
285
|
+
"es:text-center",
|
|
286
|
+
"es:line-clamp-1",
|
|
287
|
+
"es:flex es:items-center es:justify-center es:gap-1",
|
|
288
|
+
"es:shadow",
|
|
289
|
+
"es:icon:size-2 es:icon:stroke-3"
|
|
290
|
+
),
|
|
291
|
+
initial: { y: 2, opacity: 0, scale: 0.85 },
|
|
292
|
+
animate: { y: 0, opacity: 1, scale: 1 },
|
|
293
|
+
exit: { y: 6, opacity: 0, scale: 0.85 },
|
|
294
|
+
children: tooltipContent(state.values[i])
|
|
295
|
+
}
|
|
296
|
+
) })
|
|
297
|
+
]
|
|
298
|
+
},
|
|
299
|
+
i
|
|
300
|
+
);
|
|
301
|
+
}),
|
|
302
|
+
gridTemplate.map((colWidth, i) => {
|
|
303
|
+
if (colWidth === "auto" || colWidth.endsWith("px")) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
if (colWidth.endsWith("rem")) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
let val = i + 1;
|
|
310
|
+
let activeStyle = [
|
|
311
|
+
"es:transition es:duration-300",
|
|
312
|
+
!flat && !disabled && "es:shadow-xs es:shadow-black/5",
|
|
313
|
+
!disabled && [
|
|
314
|
+
"es:bg-accent-500 es:from-accent-100/15 es:to-accent-100/0 es:from-25%",
|
|
315
|
+
vertical ? "es:bg-linear-to-r" : "es:bg-linear-to-b",
|
|
316
|
+
"es:inset-ring es:inset-ring-accent-700/10",
|
|
317
|
+
"es:inset-shadow-sm es:inset-shadow-accent-50/30"
|
|
318
|
+
],
|
|
319
|
+
disabled && "es:bg-secondary-400"
|
|
320
|
+
];
|
|
321
|
+
const inactiveStyle = [
|
|
322
|
+
!disabled && [
|
|
323
|
+
"es:bg-surface-200",
|
|
324
|
+
vertical ? "es:bg-linear-to-r" : "es:bg-linear-to-b",
|
|
325
|
+
"es:from-surface-700/0 es:to-surface-700/5 es:from-25%",
|
|
326
|
+
"es:inset-ring es:inset-ring-surface-300/20"
|
|
327
|
+
],
|
|
328
|
+
disabled && "es:bg-secondary-200"
|
|
329
|
+
];
|
|
330
|
+
if (noActiveHighlight) {
|
|
331
|
+
activeStyle = inactiveStyle;
|
|
332
|
+
}
|
|
333
|
+
const extraStyles = {};
|
|
334
|
+
if (trackBgGradientSupport) {
|
|
335
|
+
let bgOffset = 0;
|
|
336
|
+
if (i === trackIndices.at(-1)) {
|
|
337
|
+
bgOffset = 100;
|
|
338
|
+
} else if (i > 0) {
|
|
339
|
+
bgOffset = tracks.slice(0, startPoint && state.values[0] > startPoint ? i + 1 : i).reduce((acc, val2) => val2 ? acc + val2 : acc, 0);
|
|
340
|
+
}
|
|
341
|
+
extraStyles.backgroundSize = "100cqw 100%";
|
|
342
|
+
extraStyles.backgroundPositionX = `${bgOffset}%`;
|
|
248
343
|
}
|
|
249
344
|
return /* @__PURE__ */ jsx(
|
|
250
345
|
"div",
|
|
251
346
|
{
|
|
252
347
|
className: clsx(
|
|
253
|
-
"es:
|
|
254
|
-
|
|
255
|
-
!
|
|
256
|
-
!
|
|
348
|
+
"es:rounded-sm",
|
|
349
|
+
"es:transition es:duration-300 es:ease-spring-smooth",
|
|
350
|
+
!flat && !disabled && "es:shadow-xs es:shadow-black/5",
|
|
351
|
+
!vertical && [
|
|
352
|
+
"es:h-6 es:row-1",
|
|
353
|
+
i === 0 && "es:rounded-l-xl",
|
|
354
|
+
i === gridTemplate.length - 1 && "es:rounded-r-xl",
|
|
355
|
+
!isRange && [
|
|
356
|
+
!startPoint && [state.values[0] > min && i < markerIndices[0] && activeStyle, i > markerIndices[0] && inactiveStyle],
|
|
357
|
+
startPoint && [
|
|
358
|
+
state.values[0] < startPoint && i === markerIndices[0] + 1 && activeStyle,
|
|
359
|
+
state.values[0] > startPoint && i === markerIndices[0] - 3 && activeStyle,
|
|
360
|
+
state.values[0] <= startPoint && i !== markerIndices[0] + 1 && inactiveStyle,
|
|
361
|
+
state.values[0] >= startPoint && i !== markerIndices[0] - 3 && inactiveStyle
|
|
362
|
+
]
|
|
363
|
+
],
|
|
364
|
+
isRange && [i > markerIndices[0] && i < markerIndices.at(-1) && activeStyle, (i < markerIndices[0] || i > markerIndices.at(-1)) && inactiveStyle]
|
|
365
|
+
],
|
|
366
|
+
vertical && [
|
|
367
|
+
"es:w-6 es:col-1",
|
|
368
|
+
i === 0 && "es:rounded-t-xl",
|
|
369
|
+
i === gridTemplate.length - 1 && "es:rounded-b-xl",
|
|
370
|
+
!isRange && [
|
|
371
|
+
!startPoint && [state.values[0] > min && i > markerIndices[0] && activeStyle, i < markerIndices.at(-1) && inactiveStyle],
|
|
372
|
+
startPoint && [
|
|
373
|
+
state.values.at(-1) > startPoint && i === markerIndices.at(-1) + 1 && activeStyle,
|
|
374
|
+
state.values.at(-1) < startPoint && i === markerIndices.at(-1) - 3 && activeStyle,
|
|
375
|
+
state.values.at(-1) >= startPoint && i !== markerIndices.at(-1) + 1 && inactiveStyle,
|
|
376
|
+
state.values.at(-1) <= startPoint && i !== markerIndices.at(-1) - 3 && inactiveStyle
|
|
377
|
+
]
|
|
378
|
+
],
|
|
379
|
+
isRange && [i < markerIndices[0] && i > markerIndices.at(-1) && activeStyle, (i > markerIndices[0] || i < markerIndices.at(-1)) && inactiveStyle]
|
|
380
|
+
]
|
|
257
381
|
),
|
|
258
382
|
style: {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
)
|
|
383
|
+
gridColumn: vertical ? null : val,
|
|
384
|
+
gridRow: vertical ? val : null,
|
|
385
|
+
...extraStyles,
|
|
386
|
+
...trackStyle
|
|
387
|
+
}
|
|
273
388
|
},
|
|
274
|
-
|
|
389
|
+
i
|
|
275
390
|
);
|
|
276
391
|
})
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
$6f909507e6374d18$export$2c1b491743890dec,
|
|
281
|
-
{
|
|
282
|
-
index: i,
|
|
283
|
-
"aria-label": 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
|
-
] });
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
);
|
|
306
395
|
} }),
|
|
307
|
-
after && /* @__PURE__ */ jsx(
|
|
396
|
+
after && /* @__PURE__ */ jsx(HStack, { children: after })
|
|
308
397
|
] })
|
|
309
398
|
}
|
|
310
399
|
)
|
|
311
400
|
}
|
|
312
401
|
);
|
|
313
402
|
};
|
|
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
403
|
export {
|
|
344
404
|
Slider
|
|
345
405
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as sprintf } from "../../sprintf-DmNrJSYG.js";
|
|
2
|
-
import { _ as __, a as _n } from "../../default-i18n-
|
|
2
|
+
import { _ as __, a as _n } from "../../default-i18n-CnQeC5Pl.js";
|
|
3
3
|
/**
|
|
4
4
|
* Generates an array of markers based on the provided minimum and maximum values and step.
|
|
5
5
|
* If the step is less than 10, only markers divisible by 5 and 10 are included.
|
|
@@ -89,7 +89,38 @@ const getColumnConfigOutputText = (columns, offset, width, showOuterAsGutter = f
|
|
|
89
89
|
}
|
|
90
90
|
return sprintf(_n("%s col from %s", "%s cols from %s", width, "eightshift-ui-components"), width, showOuterAsGutter ? offset - 1 : offset);
|
|
91
91
|
};
|
|
92
|
+
const generateGridTemplate = (points = [], splitPoint = null, { spaceBetween = 0, pointWidth = 3, vertical = false } = {}) => {
|
|
93
|
+
const gap = spaceBetween / 16;
|
|
94
|
+
const allPoints = [...points, ...splitPoint !== null && !points.includes(splitPoint) ? [splitPoint] : []].sort((a, b) => a - b);
|
|
95
|
+
if (allPoints.length === 0) {
|
|
96
|
+
return ["minmax(0, 100fr)"];
|
|
97
|
+
}
|
|
98
|
+
const segments = [];
|
|
99
|
+
let lastPosition = 0;
|
|
100
|
+
allPoints.forEach((point) => {
|
|
101
|
+
if (point > lastPosition) {
|
|
102
|
+
const segmentPercent = point - lastPosition;
|
|
103
|
+
segments.push(`${segmentPercent}fr`);
|
|
104
|
+
if (gap > 0) {
|
|
105
|
+
segments.push(`${gap}rem`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (points.includes(point)) {
|
|
109
|
+
segments.push(`${pointWidth}px`);
|
|
110
|
+
if (gap > 0) {
|
|
111
|
+
segments.push(`${gap}rem`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
lastPosition = point;
|
|
115
|
+
});
|
|
116
|
+
if (lastPosition < 100) {
|
|
117
|
+
const segmentPercent = 100 - lastPosition;
|
|
118
|
+
segments.push(`minmax(0, ${segmentPercent}fr)`);
|
|
119
|
+
}
|
|
120
|
+
return segments;
|
|
121
|
+
};
|
|
92
122
|
export {
|
|
123
|
+
generateGridTemplate,
|
|
93
124
|
generateMarkers,
|
|
94
125
|
getColumnConfigOutputText
|
|
95
126
|
};
|