@eightshift/ui-components 5.6.1 → 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.
Files changed (146) hide show
  1. package/dist/{Button-CQ5ZZJ2w.js → Button-BXjXzdW_.js} +13 -13
  2. package/dist/{Dialog-BMgMUQuN.js → Dialog-D8bjn-nh.js} +404 -77
  3. package/dist/{FieldError-B8BgFmIQ.js → FieldError-DwBG6m1U.js} +2 -2
  4. package/dist/{FocusScope-B5vxRkHm.js → FocusScope-BMk5oZCk.js} +8 -8
  5. package/dist/{Heading-B5aEynOM.js → Heading-BmRX4BRL.js} +3 -3
  6. package/dist/{Hidden-rE6uR-lr.js → Hidden-Rfj-STx7.js} +4 -4
  7. package/dist/{Input-8yja_IHC.js → Input-CNNksOWg.js} +11 -11
  8. package/dist/{Label-DWVaNd2E.js → Label-D8a3eYb-.js} +4 -4
  9. package/dist/{List-BiAnh5G5.js → List-BGHOoFf0.js} +8 -8
  10. package/dist/{ListBox-DggfiuO_.js → ListBox-Dd37zMvs.js} +40 -41
  11. package/dist/{OverlayArrow-DraDOoRn.js → OverlayArrow-DokC40S3.js} +6 -6
  12. package/dist/{PortalProvider---wyKpMr.js → PortalProvider-CHPnqDSH.js} +2 -2
  13. package/dist/RadioGroup-BVFvITWO.js +371 -0
  14. package/dist/{SearchField-DWGdCvnn.js → SearchField-CHYnN-jt.js} +16 -16
  15. package/dist/{SelectionManager-B6-b5NM2.js → SelectionManager-N8X7T_4D.js} +44 -46
  16. package/dist/{SharedElementTransition-fML-zIv6.js → SharedElementTransition-BDT84GtD.js} +3 -3
  17. package/dist/{Slider-DfU6bRtH.js → Slider-CL5CM9S8.js} +23 -23
  18. package/dist/{Text-AxKZjtFm.js → Text-ztX6G1zR.js} +3 -3
  19. package/dist/{VisuallyHidden-CgnIuZJ2.js → VisuallyHidden-DTUuKFiI.js} +4 -4
  20. package/dist/assets/style-admin.css +12156 -2
  21. package/dist/assets/style-editor.css +12156 -2
  22. package/dist/assets/style.css +12162 -2
  23. package/dist/assets/wp-overrides/allow-full-width-blocks.css +6 -0
  24. package/dist/assets/wp-overrides/fix-label-text-case.css +29 -0
  25. package/dist/assets/wp-overrides/increase-sidebar-width.css +4 -0
  26. package/dist/assets/wp-overrides/make-block-messages-nicer.css +155 -0
  27. package/dist/assets/wp-overrides/replace-fonts.css +8 -0
  28. package/dist/assets/wp-overrides/restyle-tooltips.css +194 -0
  29. package/dist/assets/wp-overrides/round-corners.css +200 -0
  30. package/dist/assets/wp-overrides/unify-button-sizes.css +5 -0
  31. package/dist/clsx-DgYk2OaC.js +16 -0
  32. package/dist/{Color-WxFE7lQB.js → color-swatch-CFIuSPcO.js} +124 -6
  33. package/dist/components/animated-visibility/animated-visibility.js +25 -17
  34. package/dist/components/base-control/base-control.js +8 -5
  35. package/dist/components/base-control/container.js +204 -0
  36. package/dist/components/button/button.js +249 -155
  37. package/dist/components/checkbox/checkbox.js +96 -37
  38. package/dist/components/color-pickers/color-picker.js +16 -7
  39. package/dist/components/color-pickers/color-swatch.js +5 -57
  40. package/dist/components/color-pickers/gradient-editor.js +161 -138
  41. package/dist/components/color-pickers/solid-color-picker.js +308 -206
  42. package/dist/components/component-toggle/component-toggle.js +12 -8
  43. package/dist/components/container-panel/container-panel.js +54 -31
  44. package/dist/components/draggable/draggable-handle.js +8 -7
  45. package/dist/components/draggable/draggable.js +2 -2
  46. package/dist/components/draggable-list/draggable-list-item.js +21 -12
  47. package/dist/components/draggable-list/draggable-list.js +19 -21
  48. package/dist/components/expandable/expandable.js +56 -28
  49. package/dist/components/index.js +7 -21
  50. package/dist/components/input-field/input-field.js +112 -35
  51. package/dist/components/item-collection/item-collection.js +1 -1
  52. package/dist/components/link-input/link-input.js +181 -121
  53. package/dist/components/matrix-align/matrix-align.js +54 -20
  54. package/dist/components/menu/menu.js +26 -34
  55. package/dist/components/modal/modal.js +31 -28
  56. package/dist/components/notice/notice.js +45 -28
  57. package/dist/components/number-picker/number-picker.js +151 -101
  58. package/dist/components/option-select/option-select.js +40 -4
  59. package/dist/components/options-panel/options-panel.js +52 -25
  60. package/dist/components/placeholders/file-picker-shell.js +10 -9
  61. package/dist/components/placeholders/file-placeholder.js +14 -6
  62. package/dist/components/placeholders/image-placeholder.js +14 -4
  63. package/dist/components/placeholders/media-placeholder.js +11 -4
  64. package/dist/components/popover/popover.js +14 -11
  65. package/dist/components/portal-provider/portal-provider.js +1 -1
  66. package/dist/components/radio/radio.js +118 -429
  67. package/dist/components/repeater/repeater-item.js +7 -10
  68. package/dist/components/repeater/repeater.js +9 -15
  69. package/dist/components/responsive/mini-responsive.js +53 -61
  70. package/dist/components/responsive/responsive-legacy.js +1 -1
  71. package/dist/components/responsive/responsive.js +27 -27
  72. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  73. package/dist/components/rich-label/rich-label.js +5 -5
  74. package/dist/components/select/async-multi-select.js +467 -100
  75. package/dist/components/select/{v2/async-select.js → async-select.js} +182 -105
  76. package/dist/components/select/multi-select.js +437 -83
  77. package/dist/components/select/shared.js +14 -42
  78. package/dist/components/select/single-select.js +349 -54
  79. package/dist/components/slider/column-config-slider.js +138 -45
  80. package/dist/components/slider/slider.js +265 -205
  81. package/dist/components/slider/utils.js +32 -1
  82. package/dist/components/smart-image/smart-image.js +25 -4
  83. package/dist/components/smart-image/worker-inline.js +1 -1
  84. package/dist/components/spacer/spacer.js +2 -2
  85. package/dist/components/tabs/tabs.js +370 -101
  86. package/dist/components/toggle/switch.js +174 -39
  87. package/dist/components/toggle/toggle.js +6 -3
  88. package/dist/components/toggle-button/toggle-button.js +140 -56
  89. package/dist/components/tooltip/tooltip.js +27 -26
  90. package/dist/{context-DMOmz986.js → context-BQvmiUqb.js} +3 -3
  91. package/dist/{default-i18n-DBm-GqWM.js → default-i18n-CnQeC5Pl.js} +10 -10
  92. package/dist/{general-Ck8IV7xJ.js → general-B6pOveVp.js} +11 -10
  93. package/dist/icons/icons.js +28 -9
  94. package/dist/icons/jsx-svg.js +1 -1
  95. package/dist/icons/spinner.js +3 -1
  96. package/dist/{index-Dq3gT5pW.js → index-BHpUy2Ix.js} +1 -1
  97. package/dist/{index-D8-Zjpbd.js → index-oFgxU4zs.js} +3 -3
  98. package/dist/index.js +6 -20
  99. package/dist/proxy-0B6wWuDe.js +7409 -0
  100. package/dist/{react-jsx-parser.min-VUl-CuCv.js → react-jsx-parser.min-B_hvYYa1.js} +5 -5
  101. package/dist/{Select-BvggcFOX.js → shared-DwjRce5e.js} +170 -36
  102. package/dist/{textSelection-DbCKqaw8.js → textSelection-CwHUtNVX.js} +1 -1
  103. package/dist/{useButton-v9ngEj50.js → useButton-DdZrS1Kz.js} +3 -3
  104. package/dist/{useEvent-BifIGnVS.js → useEvent-BD7Olibq.js} +1 -1
  105. package/dist/{useFilter-BlkUH1Ma.js → useFilter-bhxeEDg8.js} +1 -1
  106. package/dist/{useFocusRing-Cgm0R4Cf.js → useFocusRing-D3b7Kh4P.js} +1 -1
  107. package/dist/{useFormReset-yV9VVy9R.js → useFormReset-WUv2PdFO.js} +1 -1
  108. package/dist/{useFormValidation-CeNsUGWK.js → useFormValidation-DQeXkyLm.js} +2 -2
  109. package/dist/{useHover-BRDW3y7-.js → useHover-Bycb7BsD.js} +7 -7
  110. package/dist/{useLabel-C8umX0gk.js → useLabel-Bnv4-T24.js} +2 -2
  111. package/dist/{useLabels-Cdxi6JSa.js → useLabels-B49ptFDX.js} +1 -1
  112. package/dist/{useListState-RdLrYsMP.js → useListState-ZKhRO8ML.js} +1 -1
  113. package/dist/{useLocalizedStringFormatter-eaZiN2tE.js → useLocalizedStringFormatter-NETP-8H8.js} +1 -1
  114. package/dist/{useNumberField-D16dDfYF.js → useNumberField-D2fUHql3.js} +10 -10
  115. package/dist/{useNumberFormatter-BCmkV-7c.js → useNumberFormatter-DGvuRCn7.js} +1 -1
  116. package/dist/{usePress-DJskZBH9.js → usePress-B8OteQMu.js} +6 -6
  117. package/dist/{useSingleSelectListState-n0AVMr3Y.js → useSingleSelectListState-BBTu4shO.js} +2 -2
  118. package/dist/{useToggle-DSBDAfdw.js → useToggle-BZhaYwZl.js} +4 -4
  119. package/dist/{useToggleState-CzN79ary.js → useToggleState-VkXJjsru.js} +1 -1
  120. package/dist/utilities/general.js +1 -1
  121. package/dist/utilities/index.js +1 -1
  122. package/dist/{utils-cvK1vxO7.js → utils-DGpXyJOJ.js} +29 -42
  123. package/dist/workers/image-analysis.worker.js +3 -3
  124. package/package.json +26 -22
  125. package/dist/ColorSwatch-xVS3rMYS.js +0 -66
  126. package/dist/Select-ef7c0426.esm-CmTkSxDx.js +0 -2474
  127. package/dist/Separator-B-xeqOkC.js +0 -344
  128. package/dist/assets/wp-font-enhancements.css +0 -2
  129. package/dist/assets/wp-ui-enhancements.css +0 -2
  130. package/dist/components/select/async-single-select.js +0 -138
  131. package/dist/components/select/custom-select-default-components.js +0 -38
  132. package/dist/components/select/multi-select-components.js +0 -8
  133. package/dist/components/select/react-select-component-wrappers.js +0 -90
  134. package/dist/components/select/styles.js +0 -49
  135. package/dist/components/select/v2/async-multi-select.js +0 -432
  136. package/dist/components/select/v2/multi-select.js +0 -403
  137. package/dist/components/select/v2/shared.js +0 -69
  138. package/dist/components/select/v2/single-select.js +0 -358
  139. package/dist/index-641ee5b8.esm-DVp0njHa.js +0 -3139
  140. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  141. package/dist/multi-select-components-CT_W0Cy9.js +0 -3744
  142. package/dist/react-select-async.esm-Zl1LPaPb.js +0 -107
  143. package/dist/react-select.esm-Bu36HujU.js +0 -15
  144. package/dist/useDragAndDrop-C08ZXv4F.js +0 -3925
  145. package/dist/wp/wp-font-enhancements.js +0 -1
  146. 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 $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-cvK1vxO7.js";
3
- import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5, a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "../../Label-DWVaNd2E.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-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 "../../lite-DVmmD_-j.js";
5
+ import { c as clsx } from "../../clsx-DgYk2OaC.js";
7
6
  import { NumberPicker } from "../number-picker/number-picker.js";
8
- import { useState, useContext } from "react";
9
- import { generateMarkers } from "./utils.js";
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
- NumberInputField,
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
- fieldIndex: Array.isArray(value) ? currentThumbIndex : 0,
133
+ "aria-label": label || __("Slider value", "eightshift-ui-components"),
134
+ value,
135
+ onChange,
123
136
  min,
124
137
  max,
125
138
  step,
126
- focusedThumb: currentThumbIndex,
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("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: before }),
135
- /* @__PURE__ */ jsx($6f909507e6374d18$export$105594979f116971, { className: clsx("es:isolate es:grid es:grid-cols-1 es:grid-rows-1", vertical ? "es:mx-auto es:h-40 es:w-4" : "es:h-4 es:w-full es:grow"), children: ({ state }) => {
136
- let activeBarLeft;
137
- let activeBarBottom;
138
- let activeBarWidth;
139
- let activeBarHeight;
140
- let activeBarOffset = false;
141
- let shouldRoundStart = false;
142
- let shouldRoundEnd = false;
143
- const currValue = state.getThumbValue(0);
144
- if (vertical && !noActiveHighlight) {
145
- if (Array.isArray(value)) {
146
- activeBarBottom = state.getThumbPercent(0) * 100;
147
- activeBarHeight = state.getThumbPercent(value.length - 1) * 100 - activeBarBottom;
148
- } else if (startPoint && currValue >= startPoint) {
149
- activeBarBottom = state.getValuePercent(startPoint) * 100;
150
- activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
151
- activeBarOffset = true;
152
- } else if (startPoint && currValue < startPoint) {
153
- activeBarBottom = state.getThumbPercent(0) * 100;
154
- activeBarHeight = state.getValuePercent(startPoint) * 100 - activeBarBottom;
155
- } else if (min < 0 && currValue >= 0) {
156
- activeBarBottom = state.getValuePercent(0) * 100;
157
- activeBarHeight = state.getThumbPercent(0) * 100 - activeBarBottom;
158
- } else if (min < 0 && currValue < 0) {
159
- activeBarBottom = state.getThumbPercent(0) * 100;
160
- activeBarHeight = state.getValuePercent(0) * 100 - activeBarBottom;
161
- } else {
162
- activeBarBottom = state.getValuePercent(min) * 100;
163
- activeBarHeight = state.getThumbPercent(0) * 100;
164
- shouldRoundEnd = true;
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
- } else if (!noActiveHighlight) {
167
- if (Array.isArray(value)) {
168
- activeBarLeft = state.getThumbPercent(0) * 100;
169
- activeBarWidth = state.getThumbPercent(value.length - 1) * 100 - activeBarLeft;
170
- } else if (startPoint && currValue >= startPoint) {
171
- activeBarLeft = state.getValuePercent(startPoint) * 100;
172
- activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
173
- } else if (startPoint && currValue < startPoint) {
174
- activeBarLeft = state.getThumbPercent(0) * 100;
175
- activeBarWidth = state.getValuePercent(startPoint) * 100 - activeBarLeft;
176
- } else if (min < 0 && currValue >= 0) {
177
- activeBarLeft = state.getValuePercent(0) * 100;
178
- activeBarWidth = state.getThumbPercent(0) * 100 - activeBarLeft;
179
- activeBarOffset = true;
180
- } else if (min < 0 && currValue < 0) {
181
- activeBarLeft = state.getThumbPercent(0) * 100;
182
- activeBarWidth = state.getValuePercent(0) * 100 - activeBarLeft;
183
- } else {
184
- activeBarLeft = state.getValuePercent(min) * 100;
185
- activeBarWidth = state.getThumbPercent(0) * 100;
186
- shouldRoundStart = true;
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(Fragment, { children: [
190
- /* @__PURE__ */ jsx(
191
- "div",
192
- {
193
- className: clsx(
194
- "es:relative es:col-start-1 es:row-start-1 es:rounded-full es:border",
195
- !vertical && "es:h-1.5 es:w-full es:self-center",
196
- vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
197
- disabled ? "es:border-secondary-200 es:bg-white" : "es:border-secondary-300 es:bg-secondary-50 es:shadow-sm"
198
- ),
199
- style: trackStyle
200
- }
201
- ),
202
- !noActiveHighlight && /* @__PURE__ */ jsx(
203
- "div",
204
- {
205
- className: clsx(
206
- "es:absolute es:col-start-1 es:row-start-1 es:border",
207
- !vertical && "es:h-1.5 es:w-full es:self-center",
208
- vertical && "es:h-full es:w-1.5 es:flex-col es:justify-self-center",
209
- !vertical && shouldRoundStart && "es:rounded-l-full",
210
- !vertical && shouldRoundEnd && "es:rounded-r-full",
211
- vertical && shouldRoundStart && "es:rounded-t-full",
212
- vertical && shouldRoundEnd && "es:rounded-b-full",
213
- !vertical && activeBarOffset && "es:-translate-x-px",
214
- vertical && activeBarOffset && "es:translate-y-px",
215
- disabled ? "es:border-secondary-200 es:bg-secondary-50" : "es:border-accent-500 es:bg-accent-500/30"
216
- ),
217
- style: {
218
- bottom: vertical ? `${activeBarBottom}%` : null,
219
- height: vertical ? `${activeBarHeight}%` : null,
220
- width: vertical ? null : `${activeBarWidth}%`,
221
- left: vertical ? null : `${activeBarLeft}%`
222
- }
223
- }
224
- ),
225
- markers && /* @__PURE__ */ jsx(
226
- "div",
227
- {
228
- className: clsx(
229
- "es:relative es:col-start-1 es:row-start-1",
230
- !vertical && "es:h-1 es:w-full es:self-center",
231
- vertical && "es:h-full es:w-1 es:flex-col es:justify-self-center"
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
- children: markerData.map(([rawDotValue, labelData], index) => {
234
- const dotValue = parseFloat(rawDotValue);
235
- let isWithinActiveBar = false;
236
- if (Array.isArray(value)) {
237
- isWithinActiveBar = value[0] <= dotValue && dotValue <= value[value.length - 1];
238
- } else if (startPoint && dotValue >= startPoint) {
239
- isWithinActiveBar = dotValue >= startPoint && dotValue <= currValue && dotValue !== startPoint;
240
- } else if (startPoint && dotValue < startPoint) {
241
- isWithinActiveBar = dotValue <= startPoint && dotValue >= currValue && dotValue !== startPoint;
242
- } else if (min < 0 && dotValue >= 0) {
243
- isWithinActiveBar = dotValue >= 0 && dotValue <= currValue && dotValue !== 0;
244
- } else if (min < 0 && dotValue < 0) {
245
- isWithinActiveBar = dotValue <= 0 && dotValue >= currValue && dotValue !== 0;
246
- } else {
247
- isWithinActiveBar = dotValue <= currValue && dotValue > min && dotValue < max;
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:absolute",
254
- vertical ? "es:h-px es:w-1" : "es:h-1 es:w-px es:translate-x-1/2",
255
- !(dotValue === min || dotValue === max || dotValue === startPoint && !noActiveHighlight || min < 0 && dotValue === 0 && !noActiveHighlight || isWithinActiveBar) && "es:bg-secondary-300",
256
- !noActiveHighlight && isWithinActiveBar && "es:bg-accent-500/75"
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
- left: vertical ? null : `${state.getValuePercent(dotValue) * 100}%`,
260
- top: vertical ? `calc(${state.getValuePercent(dotValue) * 100}%)` : null
261
- },
262
- children: /* @__PURE__ */ jsx(
263
- "span",
264
- {
265
- className: clsx(
266
- "es:absolute es:select-none es:text-xs es:transition-colors",
267
- vertical ? "es:left-3.5 es:top-0 es:-translate-y-1/2" : "es:left-0 es:top-2.5 es:-translate-x-1/2",
268
- (Array.isArray(value) ? value.includes(Number(dotValue)) : value === Number(dotValue) && !disabled) ? "es:text-accent-700" : "es:text-secondary-300"
269
- ),
270
- children: markers && markers !== "dots" && labelData
271
- }
272
- )
383
+ gridColumn: vertical ? null : val,
384
+ gridRow: vertical ? val : null,
385
+ ...extraStyles,
386
+ ...trackStyle
387
+ }
273
388
  },
274
- index
389
+ i
275
390
  );
276
391
  })
277
- }
278
- ),
279
- /* @__PURE__ */ jsx("div", { className: "es:relative es:col-start-1 es:row-start-1 es:p-px", children: state.values.map((_, i) => /* @__PURE__ */ jsxs(
280
- $6f909507e6374d18$export$2c1b491743890dec,
281
- {
282
- index: i,
283
- "aria-label": thumbLabels?.[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("div", { className: "es:flex es:shrink-0 es:items-center es:gap-1", children: after })
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-DBm-GqWM.js";
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
  };