@jfrader/ui 0.4.0 → 0.5.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 +2 -0
- package/dist/{accordion-Bd-j04hW.js → accordion-xCI_u0BV.js} +2 -2
- package/dist/accordion.js +1 -1
- package/dist/{alert-BBqaKI4k.js → alert-DS_einpy.js} +1 -1
- package/dist/alert.js +1 -1
- package/dist/announcement-bar-B58xempt.js +382 -0
- package/dist/announcement-bar.js +2 -0
- package/dist/avatar-group-DOQQuV51.js +138 -0
- package/dist/avatar-group.js +2 -0
- package/dist/bottom-sheet-DPJBFkie.js +673 -0
- package/dist/bottom-sheet.js +2 -0
- package/dist/{breadcrumbs-DVAOxfvL.js → breadcrumbs-Cfw_hgt2.js} +1 -1
- package/dist/breadcrumbs.js +1 -1
- package/dist/{button-P2e7_44z.js → button-C92uYFJW.js} +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar-B3Svu0X2.js +447 -0
- package/dist/calendar.js +1 -1
- package/dist/carousel-IvPqN-oM.js +472 -0
- package/dist/carousel.js +2 -0
- package/dist/{checkbox-COYG6L7d.js → checkbox-cFquiSdy.js} +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/chip-group-DTQd_M-G.js +289 -0
- package/dist/chip-group.js +2 -0
- package/dist/code-block/shiki.js +147 -0
- package/dist/code-block-ahnRi-g8.js +292 -0
- package/dist/code-block.js +2 -0
- package/dist/collection-registry-k6JcD3Jr.js +44 -0
- package/dist/combobox-Bhzvu9ma.js +334 -0
- package/dist/combobox.js +1 -1
- package/dist/command-palette-BQ5LleGb.js +384 -0
- package/dist/command-palette.js +1 -1
- package/dist/copy-button-ByiA6D3R.js +252 -0
- package/dist/copy-button.js +2 -0
- package/dist/countdown-Dp_TD1VP.js +293 -0
- package/dist/countdown.js +2 -0
- package/dist/date-picker-5zKSSuFF.js +255 -0
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker-B5uFWsm-.js +562 -0
- package/dist/date-range-picker.js +2 -0
- package/dist/{dialog-xaydbXl2.js → dialog-ciiv9H2b.js} +19 -19
- package/dist/dialog.js +1 -1
- package/dist/drawer-DsASTiP-.js +553 -0
- package/dist/drawer.js +2 -0
- package/dist/empty-state-CDgrjPPf.js +142 -0
- package/dist/empty-state.js +2 -0
- package/dist/expandable-card-C-qJcZ14.js +340 -0
- package/dist/expandable-card.js +2 -0
- package/dist/field-anatomy-COVdNpf5.js +84 -0
- package/dist/file-dropzone-pR4v7owg.js +457 -0
- package/dist/file-dropzone.js +2 -0
- package/dist/filter-toolbar-D5KEKTSe.js +312 -0
- package/dist/filter-toolbar.js +2 -0
- package/dist/hold-to-confirm-DjB2EVjM.js +294 -0
- package/dist/hold-to-confirm.js +2 -0
- package/dist/hover-card-B-nrCIy2.js +347 -0
- package/dist/hover-card.js +2 -0
- package/dist/image-compare-ciuhPtQZ.js +415 -0
- package/dist/image-compare.js +2 -0
- package/dist/index.js +79 -38
- package/dist/inline-edit-C0eeml65.js +535 -0
- package/dist/inline-edit.js +2 -0
- package/dist/input-control-DmMuAuPS.js +34 -0
- package/dist/json-viewer-BcySQfjZ.js +798 -0
- package/dist/json-viewer.js +2 -0
- package/dist/listbox-style-WX-RASp1.js +59 -0
- package/dist/{media-D_eA_I-e.js → media-8yrN85VT.js} +2 -2
- package/dist/mention-input-BcQKX2EJ.js +599 -0
- package/dist/mention-input.js +2 -0
- package/dist/menu-xwOOUtWP.js +275 -0
- package/dist/menu.js +1 -1
- package/dist/metric-card-Bh9K4fZs.js +118 -0
- package/dist/metric-card.js +2 -0
- package/dist/multi-select-Pce_IYnz.js +590 -0
- package/dist/multi-select.js +2 -0
- package/dist/{navigation-DhnKriOp.js → navigation-sP5fiuQS.js} +4 -4
- package/dist/navigation.js +1 -1
- package/dist/overlay-layer-SeUyyEPD.js +64 -0
- package/dist/overlay-portal-C4JZFq2M.js +15 -0
- package/dist/{pagination-DYdwsxwe.js → pagination-DmXZ8E85.js} +1 -1
- package/dist/pagination.js +1 -1
- package/dist/password-field-03pWRkuY.js +250 -0
- package/dist/password-field.js +2 -0
- package/dist/popover-QHcEvf9c.js +119 -0
- package/dist/popover.js +1 -1
- package/dist/{progress-BpJswTG4.js → progress-CbOWBUdA.js} +4 -4
- package/dist/progress.js +1 -1
- package/dist/radio-cards-D2QZENI_.js +455 -0
- package/dist/radio-cards.js +2 -0
- package/dist/{radio-group-Ce0_IWQr.js → radio-group-E6mMRgo7.js} +4 -4
- package/dist/radio-group.js +1 -1
- package/dist/resizable-panels-BhjUVXZZ.js +519 -0
- package/dist/resizable-panels.js +2 -0
- package/dist/scroll-area-CcZyiSOQ.js +371 -0
- package/dist/scroll-area.js +2 -0
- package/dist/search-field-IxF0IJXm.js +274 -0
- package/dist/search-field.js +2 -0
- package/dist/segmented-control-yO1K1nbi.js +326 -0
- package/dist/segmented-control.js +2 -0
- package/dist/select-n_H52W1Z.js +292 -0
- package/dist/select.js +1 -1
- package/dist/signature-pad-q2SAsrdD.js +640 -0
- package/dist/signature-pad.js +2 -0
- package/dist/{skeleton-OoFlOEXO.js → skeleton-XQQDkCHd.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/slider-t0B5cecO.js +477 -0
- package/dist/slider.js +2 -0
- package/dist/sortable-data-table-tirqlLY2.js +365 -0
- package/dist/sortable-data-table.js +2 -0
- package/dist/{spinner-C2YDoiMn.js → spinner-DtxvDPdM.js} +1 -1
- package/dist/spinner.js +1 -1
- package/dist/split-button-Cb3EHs64.js +268 -0
- package/dist/split-button.js +2 -0
- package/dist/stepper-CruHbXxX.js +480 -0
- package/dist/stepper.js +2 -0
- package/dist/swipe-actions-DiZC57-3.js +418 -0
- package/dist/swipe-actions.js +2 -0
- package/dist/{switch-Dr-qjmT4.js → switch-qwv8jQnR.js} +1 -1
- package/dist/switch.js +1 -1
- package/dist/{tabs-CK_g1RKa.js → tabs-CAVJndX1.js} +2 -2
- package/dist/tabs.js +1 -1
- package/dist/tag-input-DSRCyrX2.js +418 -0
- package/dist/tag-input.js +2 -0
- package/dist/{text-field-D60ok14S.js → text-field-C8TWG-tY.js} +6 -5
- package/dist/text-field.js +1 -1
- package/dist/{textarea-DyfjtP0A.js → textarea-BrW0XcG_.js} +6 -5
- package/dist/textarea.js +1 -1
- package/dist/time-picker-Db8D49cP.js +305 -0
- package/dist/time-picker.js +2 -0
- package/dist/timeline-k3nURuCP.js +618 -0
- package/dist/timeline.js +2 -0
- package/dist/toast-BHxI32ZA.js +352 -0
- package/dist/toast-stack-DqrAzdg5.js +183 -0
- package/dist/toast-stack.js +2 -0
- package/dist/toast.js +1 -1
- package/dist/{toggle-group-CI0e7hFm.js → toggle-group-fcjzpifI.js} +4 -4
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip-CkeiW9C1.js +113 -0
- package/dist/tooltip.js +1 -1
- package/dist/tree-view-C2liIxqy.js +360 -0
- package/dist/tree-view.js +2 -0
- package/dist/types/components/announcement-bar/announcement-bar.d.ts +75 -0
- package/dist/types/components/announcement-bar/index.d.ts +2 -0
- package/dist/types/components/avatar-group/avatar-group.d.ts +43 -0
- package/dist/types/components/avatar-group/index.d.ts +2 -0
- package/dist/types/components/bottom-sheet/bottom-sheet.d.ts +60 -0
- package/dist/types/components/bottom-sheet/index.d.ts +2 -0
- package/dist/types/components/calendar/calendar.d.ts +25 -1
- package/dist/types/components/calendar/index.d.ts +1 -1
- package/dist/types/components/carousel/carousel.d.ts +73 -0
- package/dist/types/components/carousel/index.d.ts +2 -0
- package/dist/types/components/chip-group/chip-group.d.ts +54 -0
- package/dist/types/components/chip-group/index.d.ts +1 -0
- package/dist/types/components/code-block/code-block.d.ts +58 -0
- package/dist/types/components/code-block/index.d.ts +1 -0
- package/dist/types/components/code-block/shiki.d.ts +3 -0
- package/dist/types/components/combobox/combobox.d.ts +1 -1
- package/dist/types/components/command-palette/command-palette.d.ts +1 -1
- package/dist/types/components/copy-button/copy-button.d.ts +49 -0
- package/dist/types/components/copy-button/index.d.ts +2 -0
- package/dist/types/components/countdown/countdown.d.ts +37 -0
- package/dist/types/components/countdown/index.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +1 -1
- package/dist/types/components/date-range-picker/date-range-picker.d.ts +103 -0
- package/dist/types/components/date-range-picker/index.d.ts +2 -0
- package/dist/types/components/drawer/drawer.d.ts +59 -0
- package/dist/types/components/drawer/index.d.ts +2 -0
- package/dist/types/components/empty-state/empty-state.d.ts +36 -0
- package/dist/types/components/empty-state/index.d.ts +2 -0
- package/dist/types/components/expandable-card/expandable-card.d.ts +28 -0
- package/dist/types/components/expandable-card/index.d.ts +2 -0
- package/dist/types/components/field/field-anatomy.d.ts +4 -2
- package/dist/types/components/file-dropzone/file-dropzone.d.ts +93 -0
- package/dist/types/components/file-dropzone/index.d.ts +2 -0
- package/dist/types/components/filter-toolbar/filter-toolbar.d.ts +70 -0
- package/dist/types/components/filter-toolbar/index.d.ts +1 -0
- package/dist/types/components/hold-to-confirm/hold-to-confirm.d.ts +32 -0
- package/dist/types/components/hold-to-confirm/index.d.ts +2 -0
- package/dist/types/components/hover-card/hover-card.d.ts +97 -0
- package/dist/types/components/hover-card/index.d.ts +2 -0
- package/dist/types/components/image-compare/image-compare.d.ts +54 -0
- package/dist/types/components/image-compare/index.d.ts +1 -0
- package/dist/types/components/inline-edit/index.d.ts +2 -0
- package/dist/types/components/inline-edit/inline-edit.d.ts +93 -0
- package/dist/types/components/json-viewer/index.d.ts +2 -0
- package/dist/types/components/json-viewer/json-viewer.d.ts +82 -0
- package/dist/types/components/mention-input/index.d.ts +2 -0
- package/dist/types/components/mention-input/mention-input.d.ts +87 -0
- package/dist/types/components/menu/menu.d.ts +23 -5
- package/dist/types/components/metric-card/index.d.ts +1 -0
- package/dist/types/components/metric-card/metric-card.d.ts +37 -0
- package/dist/types/components/multi-select/index.d.ts +2 -0
- package/dist/types/components/multi-select/multi-select.d.ts +73 -0
- package/dist/types/components/password-field/index.d.ts +2 -0
- package/dist/types/components/password-field/password-field.d.ts +34 -0
- package/dist/types/components/popover/popover.d.ts +1 -1
- package/dist/types/components/radio-cards/index.d.ts +1 -0
- package/dist/types/components/radio-cards/radio-cards.d.ts +42 -0
- package/dist/types/components/resizable-panels/index.d.ts +2 -0
- package/dist/types/components/resizable-panels/resizable-panels.d.ts +42 -0
- package/dist/types/components/scroll-area/index.d.ts +2 -0
- package/dist/types/components/scroll-area/scroll-area.d.ts +34 -0
- package/dist/types/components/search-field/index.d.ts +1 -0
- package/dist/types/components/search-field/search-field.d.ts +31 -0
- package/dist/types/components/segmented-control/index.d.ts +2 -0
- package/dist/types/components/segmented-control/segmented-control.d.ts +32 -0
- package/dist/types/components/select/select.d.ts +1 -1
- package/dist/types/components/signature-pad/index.d.ts +2 -0
- package/dist/types/components/signature-pad/signature-pad.d.ts +104 -0
- package/dist/types/components/slider/index.d.ts +1 -0
- package/dist/types/components/slider/slider.d.ts +70 -0
- package/dist/types/components/sortable-data-table/index.d.ts +1 -0
- package/dist/types/components/sortable-data-table/sortable-data-table.d.ts +76 -0
- package/dist/types/components/split-button/index.d.ts +2 -0
- package/dist/types/components/split-button/split-button.d.ts +55 -0
- package/dist/types/components/stepper/index.d.ts +2 -0
- package/dist/types/components/stepper/stepper.d.ts +85 -0
- package/dist/types/components/swipe-actions/index.d.ts +2 -0
- package/dist/types/components/swipe-actions/swipe-actions.d.ts +44 -0
- package/dist/types/components/tag-input/index.d.ts +2 -0
- package/dist/types/components/tag-input/tag-input.d.ts +66 -0
- package/dist/types/components/time-picker/index.d.ts +2 -0
- package/dist/types/components/time-picker/time-picker.d.ts +48 -0
- package/dist/types/components/timeline/index.d.ts +2 -0
- package/dist/types/components/timeline/timeline.d.ts +66 -0
- package/dist/types/components/toast/toast.d.ts +37 -2
- package/dist/types/components/toast-stack/index.d.ts +2 -0
- package/dist/types/components/toast-stack/toast-stack.d.ts +28 -0
- package/dist/types/components/tooltip/tooltip.d.ts +1 -1
- package/dist/types/components/tree-view/index.d.ts +1 -0
- package/dist/types/components/tree-view/tree-view.d.ts +47 -0
- package/dist/types/components/usage-meter/index.d.ts +2 -0
- package/dist/types/components/usage-meter/usage-meter.d.ts +83 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/overlay/overlay-layer.d.ts +33 -0
- package/dist/types/overlay/use-overlay-floating.d.ts +11 -1
- package/dist/types/styling/media.d.ts +1 -0
- package/dist/types/styling/theme.d.ts +12 -0
- package/dist/types/utils/use-controlled-state.d.ts +2 -1
- package/dist/usage-meter-qyQ3rYVv.js +463 -0
- package/dist/usage-meter.js +2 -0
- package/dist/use-controlled-state-DpeVQZNR.js +20 -0
- package/dist/use-latest-callback-cj1OOQL6.js +11 -0
- package/dist/use-overlay-floating-DvJifLpF.js +31 -0
- package/package.json +175 -3
- package/dist/calendar-C9Yad_-w.js +0 -394
- package/dist/collection-registry-BTYi6zGh.js +0 -98
- package/dist/combobox-DiMC2g_u.js +0 -327
- package/dist/command-palette-V_2pEay7.js +0 -379
- package/dist/date-picker-C29Uo4Tx.js +0 -250
- package/dist/field-anatomy-D2ToMeRa.js +0 -109
- package/dist/menu-CGPTNRnF.js +0 -216
- package/dist/popover-CdRXjQqI.js +0 -113
- package/dist/select-BgG7WgSh.js +0 -286
- package/dist/toast-CjmELMZZ.js +0 -283
- package/dist/tooltip-CaL3rKbV.js +0 -108
- package/dist/use-controlled-state-CVXDa-qM.js +0 -21
- package/dist/use-overlay-floating-Bit-f0FU.js +0 -31
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { r as e, t } from "./sx-Dx9JUKp5.js";
|
|
3
|
+
import { n } from "./focus-ring-BK5W5_NY.js";
|
|
4
|
+
import { n as r, r as i } from "./media-8yrN85VT.js";
|
|
5
|
+
import { t as a } from "./use-controlled-state-DpeVQZNR.js";
|
|
6
|
+
import { t as o } from "./visually-hidden-BJdvqqvn.js";
|
|
7
|
+
import { t as s } from "./renderable-DzcIj1Lo.js";
|
|
8
|
+
import { useEffect as c, useId as ee, useMemo as te, useRef as l, useState as u } from "react";
|
|
9
|
+
import { vars as d } from "@jfrader/tokens/vars";
|
|
10
|
+
import { createElement as ne } from "@emotion/react";
|
|
11
|
+
import { jsx as f, jsxs as p } from "@emotion/react/jsx-runtime";
|
|
12
|
+
import { MotionConfig as re, motion as ie, useReducedMotion as ae } from "motion/react";
|
|
13
|
+
//#region src/components/slider/slider.tsx
|
|
14
|
+
var m = 1e-7, oe = {
|
|
15
|
+
type: "spring",
|
|
16
|
+
stiffness: 420,
|
|
17
|
+
damping: 30
|
|
18
|
+
}, se = 8, ce = e({
|
|
19
|
+
label: "slider",
|
|
20
|
+
display: "grid",
|
|
21
|
+
gap: d.space[2],
|
|
22
|
+
minInlineSize: 0,
|
|
23
|
+
inlineSize: "100%",
|
|
24
|
+
fontFamily: d.font.sans,
|
|
25
|
+
fontSize: d.textSize.sm,
|
|
26
|
+
lineHeight: d.lineHeight.base,
|
|
27
|
+
color: d.color.text
|
|
28
|
+
}), le = e({
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexWrap: "wrap",
|
|
31
|
+
justifyContent: "space-between",
|
|
32
|
+
gap: d.space[2],
|
|
33
|
+
alignItems: "baseline"
|
|
34
|
+
}), ue = e({ fontWeight: d.fontWeight.medium }), de = e({
|
|
35
|
+
fontVariantNumeric: "tabular-nums",
|
|
36
|
+
overflowWrap: "anywhere"
|
|
37
|
+
}), fe = e({ color: d.color.textMuted }), pe = e({ color: d.color.dangerText }), me = e({
|
|
38
|
+
display: "flex",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
gap: d.space[3],
|
|
41
|
+
minInlineSize: 0,
|
|
42
|
+
paddingBlockStart: d.space[8]
|
|
43
|
+
}), he = e({
|
|
44
|
+
position: "relative",
|
|
45
|
+
flex: 1,
|
|
46
|
+
minInlineSize: d.space[8],
|
|
47
|
+
marginInline: d.space[4],
|
|
48
|
+
touchAction: "pan-y",
|
|
49
|
+
userSelect: "none",
|
|
50
|
+
cursor: "pointer",
|
|
51
|
+
"&[data-disabled]": { cursor: "default" }
|
|
52
|
+
}), ge = {
|
|
53
|
+
sm: e({ minBlockSize: d.space[8] }),
|
|
54
|
+
md: e({ minBlockSize: d.space[10] })
|
|
55
|
+
}, _e = e({
|
|
56
|
+
position: "absolute",
|
|
57
|
+
insetInline: 0,
|
|
58
|
+
insetBlockStart: "50%",
|
|
59
|
+
transform: "translateY(-50%)",
|
|
60
|
+
blockSize: d.space[1],
|
|
61
|
+
boxSizing: "border-box",
|
|
62
|
+
border: `1px solid ${d.color.borderControl}`,
|
|
63
|
+
borderRadius: d.radius.full,
|
|
64
|
+
background: d.color.surfaceInset,
|
|
65
|
+
pointerEvents: "none",
|
|
66
|
+
[r]: {
|
|
67
|
+
forcedColorAdjust: "none",
|
|
68
|
+
background: "Canvas",
|
|
69
|
+
borderColor: "CanvasText"
|
|
70
|
+
}
|
|
71
|
+
}), ve = e({
|
|
72
|
+
position: "absolute",
|
|
73
|
+
insetBlock: 0,
|
|
74
|
+
background: d.color.accent,
|
|
75
|
+
borderRadius: d.radius.full,
|
|
76
|
+
[r]: { background: "Highlight" }
|
|
77
|
+
}), ye = e({
|
|
78
|
+
position: "absolute",
|
|
79
|
+
insetBlockStart: "50%",
|
|
80
|
+
transform: "translate(-50%, -50%)",
|
|
81
|
+
"&:dir(rtl)": { transform: "translate(50%, -50%)" },
|
|
82
|
+
inlineSize: d.space[8],
|
|
83
|
+
blockSize: d.space[8],
|
|
84
|
+
display: "grid",
|
|
85
|
+
placeItems: "center",
|
|
86
|
+
borderRadius: d.radius.full,
|
|
87
|
+
cursor: "grab",
|
|
88
|
+
"&:focus-visible": {
|
|
89
|
+
...n,
|
|
90
|
+
zIndex: 2
|
|
91
|
+
},
|
|
92
|
+
"&[data-dragging]": {
|
|
93
|
+
cursor: "grabbing",
|
|
94
|
+
zIndex: 3
|
|
95
|
+
},
|
|
96
|
+
"&[aria-disabled=\"true\"]": { cursor: "default" }
|
|
97
|
+
}), be = e({
|
|
98
|
+
inlineSize: d.space[6],
|
|
99
|
+
blockSize: d.space[6],
|
|
100
|
+
boxSizing: "border-box",
|
|
101
|
+
border: `2px solid ${d.color.borderControl}`,
|
|
102
|
+
borderRadius: d.radius.full,
|
|
103
|
+
background: d.color.surfaceRaised,
|
|
104
|
+
boxShadow: d.shadow.raised,
|
|
105
|
+
pointerEvents: "none",
|
|
106
|
+
[r]: {
|
|
107
|
+
forcedColorAdjust: "none",
|
|
108
|
+
background: "Canvas",
|
|
109
|
+
borderColor: "CanvasText",
|
|
110
|
+
boxShadow: "none"
|
|
111
|
+
}
|
|
112
|
+
}), xe = e({
|
|
113
|
+
position: "absolute",
|
|
114
|
+
insetBlockEnd: `calc(100% + ${d.space[2]})`,
|
|
115
|
+
paddingInline: d.space[2],
|
|
116
|
+
paddingBlock: d.space[1],
|
|
117
|
+
inlineSize: "max-content",
|
|
118
|
+
maxInlineSize: "min(24rem, 80vw)",
|
|
119
|
+
overflowWrap: "anywhere",
|
|
120
|
+
border: `1px solid ${d.color.borderControl}`,
|
|
121
|
+
borderRadius: d.radius.md,
|
|
122
|
+
background: d.color.surfaceRaised,
|
|
123
|
+
color: d.color.text,
|
|
124
|
+
boxShadow: d.shadow.raised,
|
|
125
|
+
pointerEvents: "none",
|
|
126
|
+
fontSize: d.textSize.xs,
|
|
127
|
+
opacity: 0,
|
|
128
|
+
transition: `opacity ${d.motion.duration.fast} ${d.motion.easeStandard}`,
|
|
129
|
+
"[data-dragging] > &, [data-slider-thumb]:focus-visible > &": { opacity: 1 },
|
|
130
|
+
[i]: { transitionDuration: "0s" },
|
|
131
|
+
[r]: {
|
|
132
|
+
borderColor: "CanvasText",
|
|
133
|
+
boxShadow: "none"
|
|
134
|
+
}
|
|
135
|
+
}), Se = e({
|
|
136
|
+
position: "absolute",
|
|
137
|
+
insetBlockStart: "50%",
|
|
138
|
+
transform: "translate(-50%, -50%)",
|
|
139
|
+
inlineSize: d.space[1],
|
|
140
|
+
blockSize: d.space[2],
|
|
141
|
+
border: `1px solid ${d.color.borderControl}`,
|
|
142
|
+
background: d.color.surfaceRaised,
|
|
143
|
+
boxSizing: "border-box",
|
|
144
|
+
pointerEvents: "none",
|
|
145
|
+
[r]: {
|
|
146
|
+
background: "Canvas",
|
|
147
|
+
borderColor: "CanvasText"
|
|
148
|
+
}
|
|
149
|
+
}), Ce = e({
|
|
150
|
+
display: "flex",
|
|
151
|
+
flexWrap: "wrap",
|
|
152
|
+
gap: d.space[2]
|
|
153
|
+
}), we = e({
|
|
154
|
+
minBlockSize: d.space[8],
|
|
155
|
+
minInlineSize: d.space[8],
|
|
156
|
+
paddingBlock: d.space[1],
|
|
157
|
+
paddingInline: d.space[2],
|
|
158
|
+
font: "inherit",
|
|
159
|
+
overflowWrap: "anywhere",
|
|
160
|
+
maxInlineSize: "100%",
|
|
161
|
+
color: d.color.text,
|
|
162
|
+
background: d.color.surfaceRaised,
|
|
163
|
+
border: `1px solid ${d.color.borderControl}`,
|
|
164
|
+
borderRadius: d.radius.md,
|
|
165
|
+
cursor: "pointer",
|
|
166
|
+
"&:focus-visible": n,
|
|
167
|
+
"&:disabled": { cursor: "default" },
|
|
168
|
+
[r]: { borderColor: "ButtonText" }
|
|
169
|
+
});
|
|
170
|
+
function h(e, t) {
|
|
171
|
+
return typeof e == "number" ? e === t : typeof t != "number" && e[0] === t[0] && e[1] === t[1];
|
|
172
|
+
}
|
|
173
|
+
function Te(...e) {
|
|
174
|
+
return e.filter(Boolean).join(" ") || void 0;
|
|
175
|
+
}
|
|
176
|
+
function g(e) {
|
|
177
|
+
return s(e) && e !== "";
|
|
178
|
+
}
|
|
179
|
+
function Ee(e, t) {
|
|
180
|
+
return typeof e == "function" ? e(t) : e;
|
|
181
|
+
}
|
|
182
|
+
function _(e) {
|
|
183
|
+
let { ref: n, type: r = "single", value: i, defaultValue: s, label: d, description: _, error: De, invalid: Oe = !1, disabled: v = !1, min: y = 0, max: b = 100, step: x = 1, largeStep: S, minStepsBetweenThumbs: C = 0, marks: ke = [], thumbLabels: w, locale: Ae, formatOptions: je, formatValue: T, showValue: Me = !0, start: Ne, end: Pe, name: E, size: Fe = "md", slotProps: D, onValueChange: Ie, onValueCommit: Le, className: Re, sx: ze, onKeyDown: Be, "aria-label": Ve, "aria-labelledby": He, "aria-describedby": Ue, "aria-invalid": We, ...Ge } = e, O = r === "range", k = (b - y) / x;
|
|
184
|
+
if (![
|
|
185
|
+
y,
|
|
186
|
+
b,
|
|
187
|
+
x,
|
|
188
|
+
k
|
|
189
|
+
].every(Number.isFinite) || b <= y || x <= 0 || !Number.isSafeInteger(Math.round(k)) || Math.abs(k - Math.round(k)) > m) throw Error("Slider requires finite min < max, a positive step, and max aligned to min + n * step.");
|
|
190
|
+
if (!Number.isInteger(C) || C < 0 || C > Math.round(k)) throw Error("Slider minStepsBetweenThumbs must be a nonnegative integer that fits the domain.");
|
|
191
|
+
if (S !== void 0 && (!Number.isFinite(S) || S <= 0)) throw Error("Slider largeStep must be finite and positive.");
|
|
192
|
+
let A = C * x, j = Math.max(1, Math.round((S ?? (b - y) / 10) / x)) * x, M = (e) => {
|
|
193
|
+
if (!Number.isFinite(e)) throw Error("Slider values must be finite.");
|
|
194
|
+
let t = Math.max(0, Math.min(Math.round(k), Math.round((e - y) / x))), n = y + t * x, r = Number(n.toPrecision(15));
|
|
195
|
+
return Math.abs(r - n) <= x * m ? r : n;
|
|
196
|
+
}, Ke = (e) => {
|
|
197
|
+
if (!O) {
|
|
198
|
+
if (typeof e != "number") throw Error("Slider single mode requires a number.");
|
|
199
|
+
return M(e);
|
|
200
|
+
}
|
|
201
|
+
if (typeof e == "number" || e.length !== 2 || e[0] > e[1]) throw Error("Slider range requires an ordered [lower, upper] tuple.");
|
|
202
|
+
let t = M(e[0]), n = M(e[1]);
|
|
203
|
+
if ((n - t) / x + m < C) throw Error("Slider range values must respect minStepsBetweenThumbs.");
|
|
204
|
+
return [t, n];
|
|
205
|
+
}, [qe] = u(() => Ke(s ?? (O ? [y, b] : y))), Je = (t) => {
|
|
206
|
+
e.type, e.onValueChange?.(t);
|
|
207
|
+
}, N = (t) => {
|
|
208
|
+
e.type, e.onValueCommit?.(t);
|
|
209
|
+
}, [Ye, Xe, Ze] = a(i, qe, Je), P = Ke(Ye ?? qe), F = typeof P == "number" ? [P] : P, I = ee(), L = te(() => new Intl.NumberFormat(Ae, je), [Ae, je]), R = (e) => T ? T(e, L) : L.format(e), Qe = typeof P == "number" ? R(P) : !T && "formatRange" in L ? L.formatRange(P[0], P[1]) : `${R(P[0])} – ${R(P[1])}`, z = ae(), B = l(null), V = l(null), $e = l(0), [H, U] = u(null), [et, tt] = u(0), W = (e) => O ? [e === 0 ? y : F[0] + A, e === 0 ? F[1] - A : b] : [y, b], G = (e, t) => {
|
|
210
|
+
let [n, r] = W(e), i = M(Math.max(n, Math.min(r, t)));
|
|
211
|
+
return O ? e === 0 ? [i, F[1]] : [F[0], i] : i;
|
|
212
|
+
}, K = (e) => {
|
|
213
|
+
h(P, e) || Xe(e);
|
|
214
|
+
}, q = (e) => {
|
|
215
|
+
let t = V.current;
|
|
216
|
+
t && (V.current = null, U(null), tt(0), t.control.hasPointerCapture(t.pointerId) && t.control.releasePointerCapture(t.pointerId), e && !h(t.initial, t.candidate) && N(t.candidate));
|
|
217
|
+
};
|
|
218
|
+
c(() => {
|
|
219
|
+
v && q(!1);
|
|
220
|
+
}, [v]), c(() => () => {
|
|
221
|
+
let e = V.current;
|
|
222
|
+
V.current = null, e?.control.hasPointerCapture(e.pointerId) && e.control.releasePointerCapture(e.pointerId);
|
|
223
|
+
}, []), c(() => {
|
|
224
|
+
let e = B.current?.closest("form");
|
|
225
|
+
if (!e) return;
|
|
226
|
+
let t = (e) => {
|
|
227
|
+
queueMicrotask(() => {
|
|
228
|
+
e.defaultPrevented || (q(!1), Ze());
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
|
|
232
|
+
}, [Ze]);
|
|
233
|
+
let nt = (e) => B.current?.querySelector(`[data-slider-thumb="${e}"]`)?.focus(), J = () => B.current?.matches(":dir(rtl)") ?? !1, rt = (e) => {
|
|
234
|
+
let t = B.current.getBoundingClientRect(), n = t.width > 0 ? (e - t.left) / t.width : 0;
|
|
235
|
+
return y + (J() ? 1 - n : n) * (b - y);
|
|
236
|
+
}, it = (e) => O ? Math.abs(e - F[0]) === Math.abs(e - F[1]) ? $e.current : Math.abs(e - F[0]) < Math.abs(e - F[1]) ? 0 : 1 : 0, at = (e) => {
|
|
237
|
+
let t = V.current;
|
|
238
|
+
if (!t || e.pointerId !== t.pointerId || v) return;
|
|
239
|
+
t.coincident && e.clientX !== t.originX && (t.thumb = e.clientX > t.originX === J() ? 0 : 1, t.coincident = !1, U(t.thumb), nt(t.thumb));
|
|
240
|
+
let n = rt(e.clientX - t.offset), r = G(t.thumb, n), [i, a] = W(t.thumb);
|
|
241
|
+
tt(z ? 0 : Math.max(-8, Math.min(se, (n - Math.max(i, Math.min(a, n))) * (J() ? -1 : 1)))), h(t.candidate, r) || (t.candidate = r, K(r));
|
|
242
|
+
}, ot = (e) => {
|
|
243
|
+
if (e.defaultPrevented || v || V.current || !e.isPrimary || e.button !== 0) return;
|
|
244
|
+
let t = e.target.closest("[data-slider-thumb]"), n = t ? Number(t.dataset.sliderThumb) : it(rt(e.clientX)), r = t?.getBoundingClientRect(), i = r ? e.clientX - (r.left + r.width / 2) : 0;
|
|
245
|
+
V.current = {
|
|
246
|
+
pointerId: e.pointerId,
|
|
247
|
+
thumb: n,
|
|
248
|
+
offset: i,
|
|
249
|
+
originX: e.clientX,
|
|
250
|
+
coincident: O && F[0] === F[1],
|
|
251
|
+
initial: P,
|
|
252
|
+
candidate: P,
|
|
253
|
+
control: e.currentTarget
|
|
254
|
+
}, e.currentTarget.setPointerCapture(e.pointerId), e.preventDefault(), U(n), nt(n), t || at(e);
|
|
255
|
+
}, st = (e, t) => {
|
|
256
|
+
if (v || e.defaultPrevented) return;
|
|
257
|
+
let n = J() ? -1 : 1, r = e.shiftKey ? j : x, [i, a] = W(t), o = {
|
|
258
|
+
ArrowRight: F[t] + r * n,
|
|
259
|
+
ArrowLeft: F[t] - r * n,
|
|
260
|
+
ArrowUp: F[t] + r,
|
|
261
|
+
ArrowDown: F[t] - r,
|
|
262
|
+
PageUp: F[t] + j,
|
|
263
|
+
PageDown: F[t] - j,
|
|
264
|
+
Home: i,
|
|
265
|
+
End: a
|
|
266
|
+
}[e.key];
|
|
267
|
+
if (o === void 0) return;
|
|
268
|
+
e.preventDefault();
|
|
269
|
+
let s = G(t, o);
|
|
270
|
+
h(P, s) || (K(s), N(s));
|
|
271
|
+
}, Y = Array.from(new Map(ke.flatMap((e) => {
|
|
272
|
+
let t = typeof e == "number" ? { value: e } : e;
|
|
273
|
+
return Number.isFinite(t.value) && t.value >= y && t.value <= b ? [[M(t.value), {
|
|
274
|
+
...t,
|
|
275
|
+
value: M(t.value)
|
|
276
|
+
}]] : [];
|
|
277
|
+
})).values()), X = (e) => (e - y) / (b - y) * 100, ct = O ? X(F[0]) : 0, lt = X(F[+!!O]), Z = g(d), Q = g(_), $ = g(De);
|
|
278
|
+
return /* @__PURE__ */ f(re, {
|
|
279
|
+
reducedMotion: "user",
|
|
280
|
+
children: /* @__PURE__ */ f(t, {
|
|
281
|
+
className: Re,
|
|
282
|
+
styles: ce,
|
|
283
|
+
sx: ze,
|
|
284
|
+
children: (e) => /* @__PURE__ */ p("div", {
|
|
285
|
+
...Ge,
|
|
286
|
+
ref: n,
|
|
287
|
+
className: e,
|
|
288
|
+
"data-ui": "slider",
|
|
289
|
+
"data-disabled": v || void 0,
|
|
290
|
+
onKeyDown: (e) => {
|
|
291
|
+
Be?.(e);
|
|
292
|
+
let t = e.target.closest("[data-slider-thumb]");
|
|
293
|
+
t && B.current?.contains(t) && st(e, Number(t.dataset.sliderThumb));
|
|
294
|
+
},
|
|
295
|
+
children: [
|
|
296
|
+
(Z || Me) && /* @__PURE__ */ p("div", {
|
|
297
|
+
css: le,
|
|
298
|
+
children: [Z && /* @__PURE__ */ f("span", {
|
|
299
|
+
...D?.label,
|
|
300
|
+
id: `${I}-label`,
|
|
301
|
+
css: [ue, D?.label?.css],
|
|
302
|
+
children: d
|
|
303
|
+
}), Me && /* @__PURE__ */ f("span", {
|
|
304
|
+
...D?.readout,
|
|
305
|
+
"aria-hidden": "true",
|
|
306
|
+
css: [de, D?.readout?.css],
|
|
307
|
+
children: Qe
|
|
308
|
+
})]
|
|
309
|
+
}),
|
|
310
|
+
Q && /* @__PURE__ */ f("div", {
|
|
311
|
+
...D?.description,
|
|
312
|
+
id: `${I}-description`,
|
|
313
|
+
css: [fe, D?.description?.css],
|
|
314
|
+
children: _
|
|
315
|
+
}),
|
|
316
|
+
$ && /* @__PURE__ */ f("div", {
|
|
317
|
+
...D?.error,
|
|
318
|
+
id: `${I}-error`,
|
|
319
|
+
role: "alert",
|
|
320
|
+
css: [pe, D?.error?.css],
|
|
321
|
+
children: De
|
|
322
|
+
}),
|
|
323
|
+
/* @__PURE__ */ p("div", {
|
|
324
|
+
css: me,
|
|
325
|
+
children: [
|
|
326
|
+
g(Ne) && /* @__PURE__ */ f("div", {
|
|
327
|
+
...D?.start,
|
|
328
|
+
children: Ne
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ p("div", {
|
|
331
|
+
...D?.control,
|
|
332
|
+
ref: (e) => {
|
|
333
|
+
B.current = e;
|
|
334
|
+
let t = D?.control?.ref;
|
|
335
|
+
if (typeof t == "function") return t(e);
|
|
336
|
+
t && (t.current = e);
|
|
337
|
+
},
|
|
338
|
+
css: [
|
|
339
|
+
he,
|
|
340
|
+
ge[Fe],
|
|
341
|
+
D?.control?.css
|
|
342
|
+
],
|
|
343
|
+
"data-ui": "slider-control",
|
|
344
|
+
"data-disabled": v || void 0,
|
|
345
|
+
onPointerDown: (e) => {
|
|
346
|
+
D?.control?.onPointerDown?.(e), ot(e);
|
|
347
|
+
},
|
|
348
|
+
onPointerMove: (e) => {
|
|
349
|
+
D?.control?.onPointerMove?.(e), e.defaultPrevented || at(e);
|
|
350
|
+
},
|
|
351
|
+
onPointerUp: (e) => {
|
|
352
|
+
D?.control?.onPointerUp?.(e), V.current?.pointerId === e.pointerId && q(!0);
|
|
353
|
+
},
|
|
354
|
+
onPointerCancel: (e) => {
|
|
355
|
+
D?.control?.onPointerCancel?.(e), V.current?.pointerId === e.pointerId && q(!1);
|
|
356
|
+
},
|
|
357
|
+
onLostPointerCapture: (e) => {
|
|
358
|
+
D?.control?.onLostPointerCapture?.(e), V.current?.pointerId === e.pointerId && q(!1);
|
|
359
|
+
},
|
|
360
|
+
children: [
|
|
361
|
+
/* @__PURE__ */ f("div", {
|
|
362
|
+
...D?.track,
|
|
363
|
+
"data-ui": "slider-track",
|
|
364
|
+
"aria-hidden": "true",
|
|
365
|
+
css: [_e, D?.track?.css],
|
|
366
|
+
children: /* @__PURE__ */ f("div", {
|
|
367
|
+
...D?.fill,
|
|
368
|
+
"data-ui": "slider-fill",
|
|
369
|
+
css: [ve, D?.fill?.css],
|
|
370
|
+
style: {
|
|
371
|
+
...D?.fill?.style,
|
|
372
|
+
insetInlineStart: `${ct}%`,
|
|
373
|
+
inlineSize: `${lt - ct}%`
|
|
374
|
+
}
|
|
375
|
+
})
|
|
376
|
+
}),
|
|
377
|
+
Y.map((e, t) => /* @__PURE__ */ f("span", {
|
|
378
|
+
"aria-hidden": "true",
|
|
379
|
+
css: Se,
|
|
380
|
+
style: { insetInlineStart: `${X(e.value)}%` }
|
|
381
|
+
}, t)),
|
|
382
|
+
F.map((e, t) => {
|
|
383
|
+
let n = Ee(D?.thumb, t), [r, i] = W(t);
|
|
384
|
+
return /* @__PURE__ */ ne("div", {
|
|
385
|
+
...n,
|
|
386
|
+
key: t,
|
|
387
|
+
id: `${I}-thumb-${t}`,
|
|
388
|
+
"data-slider-thumb": t,
|
|
389
|
+
"data-dragging": H === t || void 0,
|
|
390
|
+
role: "slider",
|
|
391
|
+
tabIndex: v ? -1 : 0,
|
|
392
|
+
"aria-orientation": "horizontal",
|
|
393
|
+
"aria-disabled": v,
|
|
394
|
+
"aria-invalid": $ || Oe ? !0 : n?.["aria-invalid"] ?? We,
|
|
395
|
+
"aria-valuemin": r,
|
|
396
|
+
"aria-valuemax": i,
|
|
397
|
+
"aria-valuenow": e,
|
|
398
|
+
"aria-valuetext": R(e),
|
|
399
|
+
"aria-label": n?.["aria-label"] ?? (O ? w?.[t] : Ve),
|
|
400
|
+
"aria-labelledby": Te(He, n?.["aria-labelledby"], O ? `${I}-name-${t}` : Z && `${I}-label`),
|
|
401
|
+
"aria-describedby": Te(Ue, n?.["aria-describedby"], Q && `${I}-description`, $ && `${I}-error`),
|
|
402
|
+
css: [ye, n?.css],
|
|
403
|
+
style: {
|
|
404
|
+
...n?.style,
|
|
405
|
+
insetInlineStart: `${X(e)}%`
|
|
406
|
+
},
|
|
407
|
+
onFocus: (e) => {
|
|
408
|
+
$e.current = t, n?.onFocus?.(e);
|
|
409
|
+
},
|
|
410
|
+
onKeyDown: (e) => {
|
|
411
|
+
n?.onKeyDown?.(e);
|
|
412
|
+
}
|
|
413
|
+
}, /* @__PURE__ */ f(ie.span, {
|
|
414
|
+
"aria-hidden": "true",
|
|
415
|
+
css: be,
|
|
416
|
+
animate: {
|
|
417
|
+
scale: z ? 1 : H === t ? .95 : 1,
|
|
418
|
+
x: z ? 0 : H === t ? et : 0
|
|
419
|
+
},
|
|
420
|
+
transition: z ? { duration: 0 } : oe
|
|
421
|
+
}), O && /* @__PURE__ */ f("span", {
|
|
422
|
+
id: `${I}-name-${t}`,
|
|
423
|
+
css: o,
|
|
424
|
+
children: w?.[t]
|
|
425
|
+
}), /* @__PURE__ */ f("span", {
|
|
426
|
+
...D?.bubble,
|
|
427
|
+
"data-ui": "slider-bubble",
|
|
428
|
+
"aria-hidden": "true",
|
|
429
|
+
css: [xe, D?.bubble?.css],
|
|
430
|
+
style: {
|
|
431
|
+
...D?.bubble?.style,
|
|
432
|
+
...X(e) <= 50 ? { insetInlineStart: 0 } : { insetInlineEnd: 0 }
|
|
433
|
+
},
|
|
434
|
+
children: R(e)
|
|
435
|
+
}));
|
|
436
|
+
})
|
|
437
|
+
]
|
|
438
|
+
}),
|
|
439
|
+
g(Pe) && /* @__PURE__ */ f("div", {
|
|
440
|
+
...D?.end,
|
|
441
|
+
children: Pe
|
|
442
|
+
})
|
|
443
|
+
]
|
|
444
|
+
}),
|
|
445
|
+
Y.some((e) => g(e.label)) && /* @__PURE__ */ f("div", {
|
|
446
|
+
css: Ce,
|
|
447
|
+
children: Y.map((e, t) => {
|
|
448
|
+
if (!g(e.label)) return null;
|
|
449
|
+
let n = Ee(D?.mark, t);
|
|
450
|
+
return /* @__PURE__ */ ne("button", {
|
|
451
|
+
...n,
|
|
452
|
+
key: t,
|
|
453
|
+
type: "button",
|
|
454
|
+
disabled: v,
|
|
455
|
+
css: [we, n?.css],
|
|
456
|
+
onClick: (t) => {
|
|
457
|
+
if (n?.onClick?.(t), v || t.defaultPrevented) return;
|
|
458
|
+
let r = G(it(e.value), e.value);
|
|
459
|
+
h(P, r) || (K(r), N(r));
|
|
460
|
+
}
|
|
461
|
+
}, e.label);
|
|
462
|
+
})
|
|
463
|
+
}),
|
|
464
|
+
E !== void 0 && F.map((e, t) => /* @__PURE__ */ f("input", {
|
|
465
|
+
type: "hidden",
|
|
466
|
+
disabled: v,
|
|
467
|
+
name: typeof E == "string" ? E : E[t],
|
|
468
|
+
value: e
|
|
469
|
+
}, t))
|
|
470
|
+
]
|
|
471
|
+
})
|
|
472
|
+
})
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
_.displayName = "Slider";
|
|
476
|
+
//#endregion
|
|
477
|
+
export { _ as t };
|
package/dist/slider.js
ADDED