@techsio/ui-kit 0.57.0 → 0.58.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/README.md +128 -133
- package/dist/atoms/action-icon.js +9 -8
- package/dist/atoms/button.js +78 -18
- package/dist/atoms/checkbox.js +77 -17
- package/dist/atoms/hotkeys.js +26 -7
- package/dist/atoms/icon.js +5 -5
- package/dist/atoms/image.js +107 -2
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +14 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +293 -76
- package/dist/atoms/rating.js +306 -73
- package/dist/atoms/skeleton.js +18 -14
- package/dist/atoms/status-text.js +31 -18
- package/dist/atoms/textarea.js +59 -12
- package/dist/atoms/tooltip.js +64 -43
- package/dist/hotkeys.js +1 -0
- package/dist/internal/choice-control.js +173 -0
- package/dist/internal/combobox-query-sync.js +11 -0
- package/dist/internal/date-picker-coordinator.js +56 -40
- package/dist/internal/date-picker-dom.js +44 -0
- package/dist/internal/date-picker-input.js +30 -0
- package/dist/internal/described-by.js +23 -18
- package/dist/internal/form-control-lifecycle.js +122 -0
- package/dist/internal/molecules/command.context.js +1 -0
- package/dist/internal/molecules/drawer.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
- package/dist/internal/numeric-input-editing.js +87 -0
- package/dist/internal/organisms/sidebar.context.js +1 -0
- package/dist/internal/organisms/sidebar.focus.js +1 -0
- package/dist/internal/overlay-portal.js +72 -0
- package/dist/internal/reduced-motion.js +1 -0
- package/dist/internal/use-effective-disabled.js +8 -0
- package/dist/molecules/accordion.js +44 -30
- package/dist/molecules/availability-status.js +1 -0
- package/dist/molecules/breadcrumb.js +11 -11
- package/dist/molecules/carousel.js +279 -97
- package/dist/molecules/cascade-select.js +327 -81
- package/dist/molecules/chart.js +276 -38
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +535 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +571 -119
- package/dist/molecules/dialog.js +81 -47
- package/dist/molecules/drawer.js +54 -5
- package/dist/molecules/file-upload.js +373 -37
- package/dist/molecules/form-checkbox.js +65 -22
- package/dist/molecules/form-error-summary.js +29 -5
- package/dist/molecules/form-input.js +26 -30
- package/dist/molecules/form-numeric-input.js +11 -9
- package/dist/molecules/form-textarea.js +26 -23
- package/dist/molecules/menu.js +170 -47
- package/dist/molecules/pagination.js +100 -28
- package/dist/molecules/phone-input.js +172 -37
- package/dist/molecules/popover.js +53 -26
- package/dist/molecules/price-block.js +1 -0
- package/dist/molecules/product-card.js +23 -18
- package/dist/molecules/quantity-field.js +4 -2
- package/dist/molecules/radio-card.js +102 -30
- package/dist/molecules/radio-group.js +108 -31
- package/dist/molecules/search-form.js +116 -13
- package/dist/molecules/select.js +226 -81
- package/dist/molecules/slider.js +141 -30
- package/dist/molecules/steps.js +181 -50
- package/dist/molecules/switch.js +85 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +146 -51
- package/dist/molecules/totals-summary.js +2 -1
- package/dist/molecules/tour.js +9 -5
- package/dist/molecules/tree-view.js +255 -109
- package/dist/molecules/vertical-navigation.js +8 -4
- package/dist/organisms/data-table.fields.js +25 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +580 -151
- package/dist/organisms/footer.js +18 -11
- package/dist/organisms/gallery.js +61 -24
- package/dist/organisms/header.js +106 -32
- package/dist/organisms/line-item.js +1 -0
- package/dist/organisms/sidebar.js +1 -0
- package/dist/organisms/table.js +22 -7
- package/dist/src/atoms/action-icon.d.ts +10 -10
- package/dist/src/atoms/action-icon.d.ts.map +1 -1
- package/dist/src/atoms/badge.d.ts +3 -3
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +35 -24
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +6 -5
- package/dist/src/atoms/checkbox.d.ts.map +1 -1
- package/dist/src/atoms/hotkeys.d.ts +3 -2
- package/dist/src/atoms/hotkeys.d.ts.map +1 -1
- package/dist/src/atoms/icon.d.ts +18 -17
- package/dist/src/atoms/icon.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +14 -6
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +23 -14
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +4 -4
- package/dist/src/atoms/label.d.ts.map +1 -1
- package/dist/src/atoms/link-button.d.ts +54 -31
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +30 -9
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +23 -19
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +54 -26
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +9 -9
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +21 -13
- package/dist/src/atoms/status-text.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +22 -20
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +5 -5
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/hotkeys.d.ts +1 -1
- package/dist/src/hotkeys.d.ts.map +1 -1
- package/dist/src/internal/choice-control.d.ts +18 -0
- package/dist/src/internal/choice-control.d.ts.map +1 -0
- package/dist/src/internal/combobox-query-sync.d.ts +4 -0
- package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
- package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
- package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
- package/dist/src/internal/date-picker-dom.d.ts +10 -0
- package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
- package/dist/src/internal/date-picker-input.d.ts +7 -0
- package/dist/src/internal/date-picker-input.d.ts.map +1 -0
- package/dist/src/internal/described-by.d.ts +7 -1
- package/dist/src/internal/described-by.d.ts.map +1 -1
- package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
- package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
- package/dist/src/internal/numeric-input-editing.d.ts +13 -0
- package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
- package/dist/src/internal/overlay-portal.d.ts +18 -0
- package/dist/src/internal/overlay-portal.d.ts.map +1 -0
- package/dist/src/internal/use-effective-disabled.d.ts +4 -0
- package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +25 -19
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/availability-status.d.ts +4 -1
- package/dist/src/molecules/availability-status.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +2 -2
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +51 -52
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/cascade-select.d.ts +23 -8
- package/dist/src/molecules/cascade-select.d.ts.map +1 -1
- package/dist/src/molecules/chart.d.ts +7 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +19 -3
- package/dist/src/molecules/color-select.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +23 -5
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/command.d.ts +1 -1
- package/dist/src/molecules/date-picker.d.ts +7 -3
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +7 -3
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts +4 -4
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/file-upload.d.ts +11 -6
- package/dist/src/molecules/file-upload.d.ts.map +1 -1
- package/dist/src/molecules/form-checkbox.d.ts +7 -2
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-error-summary.d.ts +4 -3
- package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +5 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +5 -5
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +5 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +17 -3
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +1 -1
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +4 -1
- package/dist/src/molecules/phone-input.d.ts.map +1 -1
- package/dist/src/molecules/popover.d.ts +7 -1
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/price-block.d.ts +1 -1
- package/dist/src/molecules/price-block.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +20 -25
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/quantity-field.d.ts +1 -1
- package/dist/src/molecules/quantity-field.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +10 -3
- package/dist/src/molecules/radio-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-group.d.ts +15 -6
- package/dist/src/molecules/radio-group.d.ts.map +1 -1
- package/dist/src/molecules/search-form.d.ts +37 -12
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +34 -29
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +23 -2
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +30 -10
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +54 -33
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +11 -11
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +25 -13
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/molecules/totals-summary.d.ts +1 -1
- package/dist/src/molecules/totals-summary.d.ts.map +1 -1
- package/dist/src/molecules/tour.d.ts +1 -1
- package/dist/src/molecules/tour.d.ts.map +1 -1
- package/dist/src/molecules/tree-view.d.ts +16 -20
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/molecules/vertical-navigation.d.ts +2 -2
- package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +24 -3
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts +4 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/organisms/data-table.helpers.d.ts +5 -12
- package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +5 -5
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +11 -9
- package/dist/src/organisms/gallery.d.ts.map +1 -1
- package/dist/src/organisms/header.d.ts +24 -22
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +14 -14
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +8 -6
- package/dist/src/templates/accordion.d.ts.map +1 -1
- package/dist/src/templates/breadcrumb.d.ts +1 -1
- package/dist/src/templates/breadcrumb.d.ts.map +1 -1
- package/dist/src/templates/carousel.d.ts +3 -3
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/facet-filter-panel.d.ts +9 -3
- package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +2 -2
- package/dist/src/templates/gallery.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/numeric-input.d.ts.map +1 -1
- package/dist/src/templates/popover.d.ts +4 -2
- package/dist/src/templates/popover.d.ts.map +1 -1
- package/dist/src/templates/product-card.d.ts +12 -4
- package/dist/src/templates/product-card.d.ts.map +1 -1
- package/dist/src/templates/search-suggestions.d.ts +1 -1
- package/dist/src/templates/select.d.ts +7 -2
- package/dist/src/templates/select.d.ts.map +1 -1
- package/dist/src/templates/tabs.d.ts +8 -7
- package/dist/src/templates/tabs.d.ts.map +1 -1
- package/dist/src/theme/theme-config.d.ts +9 -16
- package/dist/src/theme/theme-config.d.ts.map +1 -1
- package/dist/src/theme/theme-provider.d.ts +16 -21
- package/dist/src/theme/theme-provider.d.ts.map +1 -1
- package/dist/src/theme/theme-toggle.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/templates/accordion.js +3 -1
- package/dist/templates/breadcrumb.js +11 -4
- package/dist/templates/carousel.js +3 -6
- package/dist/templates/facet-filter-panel.js +121 -52
- package/dist/templates/gallery.js +6 -2
- package/dist/templates/numeric-input.js +6 -1
- package/dist/templates/popover.js +6 -1
- package/dist/templates/product-card.js +52 -26
- package/dist/templates/select.js +6 -1
- package/dist/templates/tabs.js +4 -2
- package/dist/theme/theme-config.js +8 -16
- package/dist/theme/theme-provider.js +89 -63
- package/dist/theme/theme-toggle.js +17 -9
- package/dist/utils.js +11 -1
- package/package.json +9 -5
- package/src/tokens/_base.css +4 -3
- package/src/tokens/_business-atoms.css +103 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4144 -0
- package/src/tokens/_semantic.css +1 -23
- package/src/tokens/_tokens-base.css +36 -32
- package/src/tokens/_typography.css +2 -1
- package/src/tokens/components/_form-control.css +149 -6
- package/src/tokens/components/_popup-surface.css +15 -29
- package/src/tokens/components/atoms/_action-icon.css +49 -0
- package/src/tokens/components/atoms/_button.css +67 -0
- package/src/tokens/components/atoms/_checkbox.css +47 -4
- package/src/tokens/components/atoms/_hotkeys.css +2 -0
- package/src/tokens/components/atoms/_icon.css +60 -7
- package/src/tokens/components/atoms/_image.css +18 -0
- package/src/tokens/components/atoms/_input.css +20 -0
- package/src/tokens/components/atoms/_label.css +3 -7
- package/src/tokens/components/atoms/_link.css +47 -5
- package/src/tokens/components/atoms/_numeric-input.css +111 -2
- package/src/tokens/components/atoms/_rating.css +55 -6
- package/src/tokens/components/atoms/_skeleton.css +12 -2
- package/src/tokens/components/atoms/_status-text.css +35 -5
- package/src/tokens/components/atoms/_textarea.css +32 -3
- package/src/tokens/components/atoms/_tooltip.css +25 -0
- package/src/tokens/components/molecules/_accordion.css +46 -5
- package/src/tokens/components/molecules/_breadcrumb.css +15 -4
- package/src/tokens/components/molecules/_carousel.css +67 -0
- package/src/tokens/components/molecules/_cascade-select.css +104 -0
- package/src/tokens/components/molecules/_chart.css +12 -14
- package/src/tokens/components/molecules/_color-select.css +21 -0
- package/src/tokens/components/molecules/_combobox.css +81 -0
- package/src/tokens/components/molecules/_command.css +1 -0
- package/src/tokens/components/molecules/_date-picker.css +66 -10
- package/src/tokens/components/molecules/_dialog.css +36 -4
- package/src/tokens/components/molecules/_drawer.css +39 -3
- package/src/tokens/components/molecules/_file-upload.css +16 -1
- package/src/tokens/components/molecules/_menu.css +17 -0
- package/src/tokens/components/molecules/_pagination.css +19 -0
- package/src/tokens/components/molecules/_phone-input.css +20 -5
- package/src/tokens/components/molecules/_popover.css +34 -0
- package/src/tokens/components/molecules/_product-card.css +49 -0
- package/src/tokens/components/molecules/_radio-card.css +35 -0
- package/src/tokens/components/molecules/_radio-group.css +8 -0
- package/src/tokens/components/molecules/_select.css +33 -0
- package/src/tokens/components/molecules/_slider.css +5 -0
- package/src/tokens/components/molecules/_steps.css +52 -0
- package/src/tokens/components/molecules/_switch.css +59 -10
- package/src/tokens/components/molecules/_tabs.css +61 -3
- package/src/tokens/components/molecules/_toast.css +60 -0
- package/src/tokens/components/molecules/_totals-summary.css +22 -22
- package/src/tokens/components/molecules/_tour.css +16 -1
- package/src/tokens/components/molecules/_tree-view.css +27 -3
- package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
- package/src/tokens/components/organisms/_data-table.css +97 -0
- package/src/tokens/components/organisms/_footer.css +9 -0
- package/src/tokens/components/organisms/_gallery.css +11 -0
- package/src/tokens/components/organisms/_header.css +22 -0
- package/src/tokens/components/organisms/_sidebar.css +1 -1
- package/src/tokens/components/organisms/_table.css +31 -0
- package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
- package/src/tokens/figma/akros/variables.css +6 -6
- package/src/tokens/figma/brand-overrides.css +162 -57
- package/src/tokens/figma/business/variables.css +6 -6
- package/src/tokens/figma/cyber/variables.css +115 -38
- package/src/tokens/figma/cyber-dark/variables.css +115 -38
- package/src/tokens/figma/dark/variables.css +4 -4
- package/src/tokens/figma/light/variables.css +43 -40
- package/src/tokens/figma/{neo → n1}/variables.css +114 -114
- package/src/tokens/figma/variables.css +639 -240
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
package/dist/molecules/slider.js
CHANGED
|
@@ -1,32 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
-
import {
|
|
3
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { connect, machine } from "@zag-js/slider";
|
|
5
|
+
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
6
|
import { Label } from "../atoms/label.js";
|
|
5
7
|
import { StatusText } from "../atoms/status-text.js";
|
|
8
|
+
import { joinDescribedBy } from "../internal/described-by.js";
|
|
9
|
+
import { subscribeOwnerFormReset } from "../internal/form-control-lifecycle.js";
|
|
10
|
+
import { useEffectiveDisabled } from "../internal/use-effective-disabled.js";
|
|
6
11
|
import { slugify, tv } from "../utils.js";
|
|
7
|
-
|
|
12
|
+
const sliderResetValues = new WeakMap();
|
|
13
|
+
const nativeSliderMachine = {
|
|
14
|
+
...machine,
|
|
15
|
+
implementations: {
|
|
16
|
+
...machine.implementations,
|
|
17
|
+
actions: {
|
|
18
|
+
...machine.implementations?.actions,
|
|
19
|
+
dispatchChangeEvent (params) {
|
|
20
|
+
const resetValue = sliderResetValues.get(params.context);
|
|
21
|
+
sliderResetValues.delete(params.context);
|
|
22
|
+
if (resetValue === JSON.stringify(params.context.get("value"))) return;
|
|
23
|
+
machine.implementations?.actions?.dispatchChangeEvent?.(params);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
effects: {
|
|
27
|
+
...machine.implementations?.effects,
|
|
28
|
+
trackFormControlState () {}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
8
32
|
const sliderVariants = tv({
|
|
9
33
|
slots: {
|
|
10
34
|
root: [
|
|
11
|
-
"flex w-full flex-col gap-slider",
|
|
35
|
+
"flex w-full min-w-0 flex-col gap-slider",
|
|
12
36
|
"data-[orientation=vertical]:h-full",
|
|
13
37
|
"data-disabled:cursor-not-allowed"
|
|
14
38
|
],
|
|
15
39
|
header: [
|
|
16
|
-
"flex items-center justify-between"
|
|
40
|
+
"flex min-w-0 flex-wrap items-center justify-between gap-slider"
|
|
17
41
|
],
|
|
18
42
|
value: [
|
|
19
|
-
"
|
|
43
|
+
"wrap-anywhere min-w-0 tabular-nums"
|
|
20
44
|
],
|
|
21
45
|
label: [
|
|
22
|
-
"block font-medium"
|
|
46
|
+
"wrap-anywhere block min-w-0 font-medium"
|
|
23
47
|
],
|
|
24
48
|
control: [
|
|
25
|
-
"relative grid place-items-center",
|
|
49
|
+
"relative grid min-h-slider-control place-items-center",
|
|
50
|
+
"data-markers:mb-slider-marker-label",
|
|
26
51
|
"data-[orientation=vertical]:h-full data-[orientation=vertical]:grid-rows-1"
|
|
27
52
|
],
|
|
28
53
|
track: [
|
|
29
|
-
"flex-1 rounded-slider-track bg-slider-track-bg",
|
|
54
|
+
"form-control-readonly flex-1 rounded-slider-track bg-slider-track-bg",
|
|
30
55
|
"data-[orientation=horizontal]:w-full",
|
|
31
56
|
"data-[orientation=vertical]:h-full",
|
|
32
57
|
"data-disabled:bg-slider-track-bg-disabled",
|
|
@@ -46,7 +71,7 @@ const sliderVariants = tv({
|
|
|
46
71
|
"transition-colors duration-200 motion-reduce:transition-none"
|
|
47
72
|
],
|
|
48
73
|
thumb: [
|
|
49
|
-
"flex items-center justify-center",
|
|
74
|
+
"form-control-readonly flex items-center justify-center",
|
|
50
75
|
"rounded-slider-thumb bg-slider-thumb-bg",
|
|
51
76
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
|
|
52
77
|
"focus-visible:outline-slider-ring",
|
|
@@ -56,7 +81,7 @@ const sliderVariants = tv({
|
|
|
56
81
|
"border-(length:--border-width-slider) border-slider-border",
|
|
57
82
|
"data-disabled:border-slider-border-disabled",
|
|
58
83
|
"hover:bg-slider-thumb-bg-hover",
|
|
59
|
-
"cursor-grab data-disabled:cursor-not-allowed data-dragging:cursor-grabbing",
|
|
84
|
+
"cursor-grab data-disabled:cursor-not-allowed data-dragging:cursor-grabbing data-readonly:cursor-default",
|
|
60
85
|
"shadow-slider-thumb"
|
|
61
86
|
],
|
|
62
87
|
markerGroup: [
|
|
@@ -82,6 +107,7 @@ const sliderVariants = tv({
|
|
|
82
107
|
variants: {
|
|
83
108
|
size: {
|
|
84
109
|
sm: {
|
|
110
|
+
root: "text-slider-sm",
|
|
85
111
|
track: [
|
|
86
112
|
"h-slider-track-sm data-[orientation=vertical]:w-slider-track-sm"
|
|
87
113
|
],
|
|
@@ -91,6 +117,7 @@ const sliderVariants = tv({
|
|
|
91
117
|
]
|
|
92
118
|
},
|
|
93
119
|
md: {
|
|
120
|
+
root: "text-slider-md",
|
|
94
121
|
track: [
|
|
95
122
|
"h-slider-track-md data-[orientation=vertical]:w-slider-track-md"
|
|
96
123
|
],
|
|
@@ -100,6 +127,7 @@ const sliderVariants = tv({
|
|
|
100
127
|
]
|
|
101
128
|
},
|
|
102
129
|
lg: {
|
|
130
|
+
root: "text-slider-lg",
|
|
103
131
|
track: [
|
|
104
132
|
"h-slider-track-lg data-[orientation=vertical]:w-slider-track-lg"
|
|
105
133
|
],
|
|
@@ -124,17 +152,24 @@ const clampNumber = (value, min, max)=>{
|
|
|
124
152
|
};
|
|
125
153
|
const countDecimals = (value)=>{
|
|
126
154
|
if (!Number.isFinite(value)) return 0;
|
|
127
|
-
const [,
|
|
128
|
-
return
|
|
155
|
+
const [coefficient = "", exponent = "0"] = value.toString().toLowerCase().split("e");
|
|
156
|
+
return Math.max(0, (coefficient.split(".")[1]?.length ?? 0) - Number(exponent));
|
|
129
157
|
};
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
return
|
|
158
|
+
const ariaNumber = (value)=>{
|
|
159
|
+
const text = String(value);
|
|
160
|
+
const [coefficient = "", exponent] = text.split("e");
|
|
161
|
+
if (void 0 === exponent) return value;
|
|
162
|
+
const sign = coefficient.startsWith("-") ? "-" : "";
|
|
163
|
+
const unsigned = coefficient.replace("-", "");
|
|
164
|
+
const digits = unsigned.replace(".", "");
|
|
165
|
+
const point = (unsigned.split(".")[0]?.length ?? 0) + Number(exponent);
|
|
166
|
+
const decimal = point <= 0 ? `0.${"0".repeat(-point)}${digits}` : digits.padEnd(point, "0").slice(0, point) + (point < digits.length ? `.${digits.slice(point)}` : "");
|
|
167
|
+
return `${sign}${decimal}`;
|
|
134
168
|
};
|
|
135
169
|
const snapToStep = (value, min, step)=>{
|
|
136
170
|
const snappedValue = Math.round((value - min) / step) * step + min;
|
|
137
|
-
|
|
171
|
+
const precision = Math.min(100, Math.max(countDecimals(min), countDecimals(step)));
|
|
172
|
+
return Number(snappedValue.toFixed(precision));
|
|
138
173
|
};
|
|
139
174
|
const resolveThumbCount = (value, defaultValue)=>{
|
|
140
175
|
if (Array.isArray(value) && value.length > 0) return value.length;
|
|
@@ -209,11 +244,20 @@ const apiValueFallback = (value, defaultValue, fallbackValues)=>{
|
|
|
209
244
|
if (Array.isArray(defaultValue) && defaultValue.length > 0) return defaultValue;
|
|
210
245
|
return fallbackValues;
|
|
211
246
|
};
|
|
212
|
-
function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, helpText, showHelpTextIcon = true, value, origin, thumbAlignment = "center", defaultValue = [
|
|
247
|
+
function Slider({ id, name, form, label, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, validateStatus, helpText, showHelpTextIcon = true, value, origin, thumbAlignment = "center", defaultValue = [
|
|
213
248
|
25,
|
|
214
249
|
75
|
|
215
|
-
], min = 0, max = 100, step = 1, minStepsBetweenThumbs = 0, disabled = false, readOnly = false, dir = "ltr", orientation = "horizontal", size = "md", showMarkers = false, markerCount = 5, showValueText = false, formatRangeText, formatValue = (val)=>val.toString(), className, onChange, onChangeEnd }) {
|
|
250
|
+
], min = 0, max = 100, step = 1, minStepsBetweenThumbs = 0, disabled: explicitDisabled = false, readOnly = false, dir = "ltr", orientation = "horizontal", size = "md", showMarkers = false, markerCount = 5, showValueText = false, formatRangeText, getAriaValueText, getThumbProps, formatValue = (val)=>val.toString(), className, onChange, onChangeEnd }) {
|
|
216
251
|
const generatedId = useId();
|
|
252
|
+
const disabledProbeRef = useRef(null);
|
|
253
|
+
const resetting = useRef(false);
|
|
254
|
+
const [disabledElement, setDisabledElement] = useState(null);
|
|
255
|
+
const disabled = useEffectiveDisabled(disabledElement, explicitDisabled);
|
|
256
|
+
const probeRef = useMemo(()=>(node)=>{
|
|
257
|
+
disabledProbeRef.current = node;
|
|
258
|
+
setDisabledElement(node);
|
|
259
|
+
}, []);
|
|
260
|
+
const interactionBlocked = ()=>disabled || readOnly || disabledProbeRef.current?.matches(":disabled");
|
|
217
261
|
const uniqueId = id || generatedId;
|
|
218
262
|
const helpTextId = `${uniqueId}-help`;
|
|
219
263
|
const thumbCount = resolveThumbCount(value, defaultValue);
|
|
@@ -223,10 +267,18 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
223
267
|
const resolvedValue = isControlled ? normalizeSliderValues(value, fallbackValues, resolvedConfig) : void 0;
|
|
224
268
|
const resolvedDefaultValue = isControlled ? void 0 : normalizeSliderValues(defaultValue, fallbackValues, resolvedConfig);
|
|
225
269
|
const valueTextValues = apiValueFallback(resolvedValue, resolvedDefaultValue, fallbackValues);
|
|
226
|
-
|
|
270
|
+
useEffect(()=>{
|
|
271
|
+
if (!("u" > typeof process && process.env?.NODE_ENV === "production") && thumbCount > 1 && (ariaLabel?.length !== thumbCount || ariaLabel.some((thumbName)=>!thumbName.trim()) || new Set(ariaLabel).size !== thumbCount)) console.warn("[Slider] Provide a distinct aria-label for every thumb, even with a visible label.");
|
|
272
|
+
}, [
|
|
273
|
+
ariaLabel,
|
|
274
|
+
thumbCount
|
|
275
|
+
]);
|
|
276
|
+
const service = useMachine(nativeSliderMachine, {
|
|
227
277
|
id: uniqueId,
|
|
228
278
|
name,
|
|
279
|
+
form,
|
|
229
280
|
"aria-label": ariaLabel,
|
|
281
|
+
getAriaValueText: getAriaValueText ?? (({ value: thumbValue })=>formatValue(thumbValue)),
|
|
230
282
|
value: resolvedValue,
|
|
231
283
|
defaultValue: resolvedDefaultValue,
|
|
232
284
|
min: resolvedConfig.min,
|
|
@@ -239,10 +291,34 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
239
291
|
readOnly,
|
|
240
292
|
dir,
|
|
241
293
|
orientation,
|
|
242
|
-
onValueChange: (details)=>
|
|
243
|
-
|
|
294
|
+
onValueChange: (details)=>{
|
|
295
|
+
if (!(resetting.current || interactionBlocked())) onChange?.(details.value);
|
|
296
|
+
},
|
|
297
|
+
onValueChangeEnd: (details)=>{
|
|
298
|
+
if (!(resetting.current || interactionBlocked())) onChangeEnd?.(details.value);
|
|
299
|
+
}
|
|
244
300
|
});
|
|
245
|
-
const api =
|
|
301
|
+
const api = connect(service, normalizeProps);
|
|
302
|
+
const reset = useRef(()=>void 0);
|
|
303
|
+
reset.current = ()=>{
|
|
304
|
+
resetting.current = true;
|
|
305
|
+
try {
|
|
306
|
+
if (!isControlled) {
|
|
307
|
+
const initial = service.context.initial("value");
|
|
308
|
+
if (JSON.stringify(initial) !== JSON.stringify(service.context.get("value"))) sliderResetValues.set(service.context, JSON.stringify(initial));
|
|
309
|
+
service.context.set("value", initial);
|
|
310
|
+
}
|
|
311
|
+
const inputs = disabledProbeRef.current?.parentElement?.querySelectorAll("input[hidden]") ?? [];
|
|
312
|
+
const restored = isControlled ? resolvedValue : service.context.get("value");
|
|
313
|
+
for (const [index, input] of Array.from(inputs).entries())input.value = String(restored?.[index] ?? "");
|
|
314
|
+
} finally{
|
|
315
|
+
resetting.current = false;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
useEffect(()=>{
|
|
319
|
+
const input = disabledProbeRef.current;
|
|
320
|
+
return input ? subscribeOwnerFormReset(input, ()=>reset.current()) : void 0;
|
|
321
|
+
}, []);
|
|
246
322
|
const { root, label: labelSlot, control, track, range, thumb, header, value: valueSlot, markerGroup, marker, markerLine, markerText } = sliderVariants({
|
|
247
323
|
className,
|
|
248
324
|
size
|
|
@@ -252,12 +328,32 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
252
328
|
className
|
|
253
329
|
}),
|
|
254
330
|
...api.getRootProps(),
|
|
331
|
+
onKeyDownCapture: (event)=>{
|
|
332
|
+
if (interactionBlocked()) event.stopPropagation();
|
|
333
|
+
},
|
|
334
|
+
onPointerDownCapture: (event)=>{
|
|
335
|
+
if (interactionBlocked()) {
|
|
336
|
+
if (readOnly && !disabled) {
|
|
337
|
+
const target = event.target;
|
|
338
|
+
target.closest('[data-part="thumb"]')?.focus();
|
|
339
|
+
}
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
event.stopPropagation();
|
|
342
|
+
}
|
|
343
|
+
},
|
|
255
344
|
children: [
|
|
345
|
+
/*#__PURE__*/ jsx("input", {
|
|
346
|
+
"data-part": "disabled-probe",
|
|
347
|
+
form: form,
|
|
348
|
+
ref: probeRef,
|
|
349
|
+
type: "hidden"
|
|
350
|
+
}),
|
|
256
351
|
(label || showValueText) && /*#__PURE__*/ jsxs("div", {
|
|
257
352
|
className: header(),
|
|
258
353
|
children: [
|
|
259
354
|
/*#__PURE__*/ jsx(Label, {
|
|
260
355
|
className: labelSlot(),
|
|
356
|
+
size: size,
|
|
261
357
|
...api.getLabelProps(),
|
|
262
358
|
children: label
|
|
263
359
|
}),
|
|
@@ -266,7 +362,7 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
266
362
|
...api.getValueTextProps(),
|
|
267
363
|
children: [
|
|
268
364
|
/*#__PURE__*/ jsx("b", {
|
|
269
|
-
children: formatRangeText ? formatRangeText(api.value
|
|
365
|
+
children: formatRangeText ? formatRangeText(api.value ?? valueTextValues) : (api.value ?? valueTextValues).map(formatValue).join(" – ")
|
|
270
366
|
}),
|
|
271
367
|
" "
|
|
272
368
|
]
|
|
@@ -276,11 +372,13 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
276
372
|
/*#__PURE__*/ jsxs("div", {
|
|
277
373
|
className: control(),
|
|
278
374
|
...api.getControlProps(),
|
|
375
|
+
"data-markers": showMarkers && "horizontal" === orientation ? "" : void 0,
|
|
279
376
|
children: [
|
|
280
377
|
/*#__PURE__*/ jsxs("div", {
|
|
281
378
|
className: track(),
|
|
282
379
|
...api.getTrackProps(),
|
|
283
380
|
"data-invalid": "error" === validateStatus,
|
|
381
|
+
"data-readonly": readOnly ? "" : void 0,
|
|
284
382
|
children: [
|
|
285
383
|
/*#__PURE__*/ jsx("div", {
|
|
286
384
|
className: range(),
|
|
@@ -317,21 +415,34 @@ function Slider({ id, name, label, "aria-label": ariaLabel, validateStatus, help
|
|
|
317
415
|
}),
|
|
318
416
|
api.value.map((_, index)=>/*#__PURE__*/ jsx("div", {
|
|
319
417
|
className: thumb(),
|
|
320
|
-
...api.getThumbProps({
|
|
418
|
+
...mergeProps(api.getThumbProps({
|
|
321
419
|
index
|
|
322
|
-
}),
|
|
323
|
-
"aria-describedby": helpText ? helpTextId : void 0,
|
|
420
|
+
}), getThumbProps?.(index) ?? {}),
|
|
421
|
+
"aria-describedby": joinDescribedBy(ariaDescribedBy, helpText ? helpTextId : void 0),
|
|
422
|
+
"aria-errormessage": "error" === validateStatus ? joinDescribedBy(ariaErrorMessage, helpText ? helpTextId : void 0) : void 0,
|
|
423
|
+
"aria-invalid": "error" === validateStatus || void 0,
|
|
424
|
+
"aria-labelledby": ariaLabel?.[index] ? void 0 : api.getLabelProps().id,
|
|
425
|
+
"aria-readonly": readOnly || void 0,
|
|
426
|
+
"aria-valuemax": ariaNumber(api.getThumbMax(index)),
|
|
427
|
+
"aria-valuemin": ariaNumber(api.getThumbMin(index)),
|
|
428
|
+
"aria-valuenow": ariaNumber(api.value[index] ?? 0),
|
|
429
|
+
"data-readonly": readOnly ? "" : void 0,
|
|
430
|
+
role: "slider",
|
|
431
|
+
tabIndex: api.getThumbProps({
|
|
432
|
+
index
|
|
433
|
+
}).tabIndex,
|
|
324
434
|
children: /*#__PURE__*/ jsx("input", {
|
|
325
435
|
...api.getHiddenInputProps({
|
|
326
436
|
index
|
|
327
|
-
})
|
|
437
|
+
}),
|
|
438
|
+
disabled: disabled
|
|
328
439
|
})
|
|
329
440
|
}, `thumb-${index}`))
|
|
330
441
|
]
|
|
331
442
|
}),
|
|
332
443
|
helpText && /*#__PURE__*/ jsx(StatusText, {
|
|
333
444
|
id: helpTextId,
|
|
334
|
-
showIcon: showHelpTextIcon,
|
|
445
|
+
showIcon: validateStatus && "default" !== validateStatus ? true : showHelpTextIcon,
|
|
335
446
|
size: size,
|
|
336
447
|
status: validateStatus,
|
|
337
448
|
children: helpText
|