@blakesteve/roster 5.10.0 → 5.12.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 (55) hide show
  1. package/README.md +202 -11
  2. package/dist/components/atoms/Chip/chip-variants.cjs +1 -1
  3. package/dist/components/atoms/Chip/chip-variants.js +8 -2
  4. package/dist/components/atoms/Combobox/Combobox.cjs +1 -1
  5. package/dist/components/atoms/Combobox/Combobox.js +20 -18
  6. package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
  7. package/dist/components/atoms/MultiSelect/MultiSelect.js +22 -20
  8. package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
  9. package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
  10. package/dist/components/atoms/Select/Select.cjs +1 -1
  11. package/dist/components/atoms/Select/Select.js +19 -17
  12. package/dist/components/atoms/Select/select-variants.cjs +1 -1
  13. package/dist/components/atoms/Select/select-variants.js +11 -2
  14. package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
  15. package/dist/components/molecules/Carousel/Carousel.js +31 -29
  16. package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
  17. package/dist/components/molecules/FileUpload/FileUpload.js +21 -19
  18. package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
  19. package/dist/components/molecules/LiquidTabs/LiquidTabs.js +22 -20
  20. package/dist/components/molecules/Menu/Menu.cjs +1 -1
  21. package/dist/components/molecules/Menu/Menu.js +133 -124
  22. package/dist/components/molecules/RadioGroup/RadioGroup.cjs +1 -1
  23. package/dist/components/molecules/RadioGroup/RadioGroup.js +23 -21
  24. package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
  25. package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +79 -0
  26. package/dist/components/molecules/RangeSlider/RangeSlider.js +166 -0
  27. package/dist/components/molecules/Slider/Slider.cjs +1 -0
  28. package/dist/components/molecules/Slider/Slider.d.ts +91 -0
  29. package/dist/components/molecules/Slider/Slider.js +130 -0
  30. package/dist/components/molecules/Slider/track-parts.cjs +1 -0
  31. package/dist/components/molecules/Slider/track-parts.d.ts +65 -0
  32. package/dist/components/molecules/Slider/track-parts.js +121 -0
  33. package/dist/components/molecules/Slider/track.cjs +1 -0
  34. package/dist/components/molecules/Slider/track.d.ts +115 -0
  35. package/dist/components/molecules/Slider/track.js +152 -0
  36. package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
  37. package/dist/components/organisms/Dialog/Dialog.js +19 -17
  38. package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
  39. package/dist/components/organisms/ModerationQueue/ModerationQueue.js +45 -43
  40. package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
  41. package/dist/components/organisms/Navbar/Navbar.js +24 -22
  42. package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
  43. package/dist/components/organisms/Sheet/Sheet.js +25 -23
  44. package/dist/index.d.ts +2 -0
  45. package/dist/internal/key-focus.cjs +1 -0
  46. package/dist/internal/key-focus.d.ts +7 -0
  47. package/dist/internal/key-focus.js +60 -0
  48. package/dist/internal/popup.cjs +1 -1
  49. package/dist/internal/popup.d.ts +15 -1
  50. package/dist/internal/popup.js +17 -12
  51. package/dist/meta.json +3 -3
  52. package/dist/roster.cjs +1 -1
  53. package/dist/roster.css +1 -1
  54. package/dist/roster.js +67 -63
  55. package/package.json +1 -1
@@ -2,17 +2,18 @@
2
2
  import { jsxs as c, jsx as s } from "react/jsx-runtime";
3
3
  import "react";
4
4
  import { Description as p } from "../../../node_modules/@headlessui/react/dist/components/description/description.js";
5
- import { Field as S } from "../../../node_modules/@headlessui/react/dist/components/field/field.js";
5
+ import { Field as R } from "../../../node_modules/@headlessui/react/dist/components/field/field.js";
6
6
  import { Label as f } from "../../../node_modules/@headlessui/react/dist/components/label/label.js";
7
- import { RadioGroup as j, Radio as D } from "../../../node_modules/@headlessui/react/dist/components/radio-group/radio-group.js";
7
+ import { RadioGroup as S, Radio as j } from "../../../node_modules/@headlessui/react/dist/components/radio-group/radio-group.js";
8
8
  import { cn as t } from "../../../lib/utils.js";
9
- import { isFieldInvalid as F, withoutInvalidProps as O } from "../../../internal/field-invalid.js";
10
- import { radioDotVariants as P, radioVariants as Z, radioOptionVariants as A, radioGroupOptionsVariants as B } from "./radio-group-variants.js";
11
- const K = {
9
+ import { isFieldInvalid as D, withoutInvalidProps as K } from "../../../internal/field-invalid.js";
10
+ import { radioDotVariants as O, radioVariants as P, radioOptionVariants as Z, radioGroupOptionsVariants as A } from "./radio-group-variants.js";
11
+ import { useKeyFocus as B } from "../../../internal/key-focus.js";
12
+ const W = {
12
13
  sm: "rst:text-xs",
13
14
  md: "rst:text-sm",
14
15
  lg: "rst:text-base"
15
- }, Y = ({
16
+ }, M = ({
16
17
  options: u,
17
18
  value: v,
18
19
  onChange: y,
@@ -30,13 +31,14 @@ const K = {
30
31
  labelClassName: k,
31
32
  optionLabelClassName: V,
32
33
  descriptionClassName: E,
33
- messageClassName: G,
34
- "aria-invalid": I,
34
+ messageClassName: F,
35
+ "aria-invalid": G,
35
36
  ...n
36
37
  }) => {
37
- const x = !!o, L = F(x, { ...n, "aria-invalid": I }), R = O(n), e = h ?? "md";
38
+ B();
39
+ const x = !!o, I = D(x, { ...n, "aria-invalid": G }), L = K(n), e = h ?? "md";
38
40
  return /* @__PURE__ */ c(
39
- j,
41
+ S,
40
42
  {
41
43
  value: v,
42
44
  onChange: y,
@@ -45,8 +47,8 @@ const K = {
45
47
  "rst:font-ui rst:flex rst:flex-col rst:gap-1.5 rst:min-w-0",
46
48
  b
47
49
  ),
48
- ...R,
49
- "aria-invalid": L || void 0,
50
+ ...L,
51
+ "aria-invalid": I || void 0,
50
52
  "aria-orientation": i,
51
53
  children: [
52
54
  d && /* @__PURE__ */ s(
@@ -64,24 +66,24 @@ const K = {
64
66
  "div",
65
67
  {
66
68
  className: t(
67
- B({ size: e, orientation: i }),
69
+ A({ size: e, orientation: i }),
68
70
  g
69
71
  ),
70
72
  children: u.map((r) => /* @__PURE__ */ c(
71
- S,
73
+ R,
72
74
  {
73
75
  disabled: a || r.disabled,
74
76
  className: t(
75
- A({ orientation: i, size: e }),
77
+ Z({ orientation: i, size: e }),
76
78
  w
77
79
  ),
78
80
  children: [
79
81
  /* @__PURE__ */ s(
80
- D,
82
+ j,
81
83
  {
82
84
  value: r.value,
83
85
  className: ({ checked: l }) => t(
84
- Z({ colorScheme: N, size: e, checked: l }),
86
+ P({ colorScheme: N, size: e, checked: l }),
85
87
  /* `self-start`, and no nudge. The circle's height equals the
86
88
  label's line-height at every size, so aligning their top
87
89
  edges puts the radio on the first line whether the label
@@ -94,7 +96,7 @@ const K = {
94
96
  "span",
95
97
  {
96
98
  className: t(
97
- P({ size: e }),
99
+ O({ size: e }),
98
100
  l ? "rst:opacity-100" : "rst:opacity-0"
99
101
  )
100
102
  }
@@ -120,7 +122,7 @@ const K = {
120
122
  "rst:cursor-pointer rst:select-none",
121
123
  "rst:text-[var(--roster-control-text)]",
122
124
  "rst:data-disabled:cursor-not-allowed rst:data-disabled:opacity-50",
123
- K[e],
125
+ W[e],
124
126
  V
125
127
  ),
126
128
  children: r.label
@@ -153,7 +155,7 @@ const K = {
153
155
  "rst:text-xs rst:text-left",
154
156
  x ? "rst:text-error-600 rst:dark:text-error-400 rst:font-medium" : "rst:text-gray-500 rst:dark:text-gray-400",
155
157
  a && "rst:opacity-50",
156
- G
158
+ F
157
159
  ),
158
160
  children: o || m
159
161
  }
@@ -163,5 +165,5 @@ const K = {
163
165
  );
164
166
  };
165
167
  export {
166
- Y as RadioGroup
168
+ M as RadioGroup
167
169
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("react"),G=require("../../../lib/utils.cjs"),ge=require("../../../lib/labels.cjs"),J=require("../../../internal/field-invalid.cjs"),o=require("../Slider/track.cjs"),h=require("../Slider/track-parts.cjs"),ve=require("../../../internal/key-focus.cjs"),he={low:"Minimum",high:"Maximum",valueText:(r,i)=>i?`${r}, ${i}`:r,range:(r,i)=>`${r} – ${i}`},pe=([r,i])=>r<=i?[r,i]:[i,r];function ye({value:r,defaultValue:i,onChange:Q,onCommit:F,min:g=0,max:v=100,step:B=1,pageStep:U,snapPoints:W=[],label:M,helperText:P,errorMessage:R,disabled:a=!1,name:p,formatValue:b=String,labels:X,className:Y,trackClassName:Z,thumbClassName:_,chipClassName:V,labelClassName:ee,messageClassName:se,"aria-invalid":te,"aria-labelledby":ne,"aria-describedby":re,...T}){ve.useKeyFocus();const y=ge.withLabels(he,X),j=d.useId(),C=`${j}-label`,N=`${j}-message`,w=[`${j}-low`,`${j}-high`],S=ne??(M?C:void 0),c=o.useScale(g,v,B,U),m=r!==void 0,[O,K]=d.useState(i??[g,v]),L=m?r:O,n=pe([c.clamp(L[0]),c.clamp(L[1])]),ie=J.isFieldInvalid(!!R,{...T,"aria-invalid":te}),D=J.withoutInvalidProps(T),f=o.useCommitted(n),[,ae]=d.useReducer(e=>e+1,0),k=(e,s,l)=>{const u=f.current,$=e===0?Math.min(s,u[1]):Math.max(s,u[0]);if($===u[e])return;const x=e===0?[$,u[1]]:[u[0],$];f.current=x,m?ae():K(x),Q?.(x),l&&F?.(x)},z=d.useRef(null),A=d.useRef(O);o.useFormReset(z,m,()=>{f.current=A.current,K(A.current)},p);const E=d.useRef(null),H=[d.useRef(null),d.useRef(null)],{dragging:q,rtl:oe,handlers:le}=o.useTrackPress({trackRef:E,disabled:a,scale:c,min:g,max:v,values:()=>f.current,set:k,focus:e=>H[e].current?.focus({preventScroll:!0}),commit:()=>F?.(f.current),own:{down:void 0,move:void 0,up:void 0,cancel:void 0,lost:void 0}}),ce=e=>s=>{if(a)return;const l=f.current,u=o.keyTarget(s,l[e],{scale:c,step:B,start:l[e],floor:e===0?g:l[0],ceiling:e===0?l[1]:v,rtl:oe()});u!==void 0&&(s.preventDefault(),k(e,u,!0))},ue=e=>{const[s,l]=f.current;k(e<=s?0:e>=l?1:e-s<=l-e?0:1,e,!0)},I=o.inRange(W,g,v),de=[P||R?N:void 0,re].filter(Boolean).join(" ")||void 0,fe="rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background";return t.jsxs("div",{...D,role:"group","aria-labelledby":S,className:G.cn("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5",Y),"data-range-slider":"",children:[t.jsx(h.SliderHeader,{labelId:C,label:M,readout:y.range(b(n[0]),b(n[1])),empty:!1,disabled:a,labelClassName:ee}),t.jsx("span",{id:w[0],hidden:!0,children:y.low}),t.jsx("span",{id:w[1],hidden:!0,children:y.high}),t.jsxs("div",{...le,ref:E,"data-dragging":q?"":void 0,className:G.cn(o.trackClasses(a),Z),children:[t.jsx(h.Rail,{}),t.jsx(h.Fill,{from:c.at(n[0]),to:c.at(n[1]),dragging:q}),t.jsx(h.Marks,{points:I,at:c.at,filled:e=>e>=n[0]&&e<=n[1]}),n.map((e,s)=>t.jsx("span",{ref:H[s],role:"slider",tabIndex:a?void 0:0,"aria-labelledby":[S,w[s]].filter(Boolean).join(" "),"aria-describedby":de,"aria-valuemin":s===0?g:n[0],"aria-valuemax":s===0?n[1]:v,"aria-valuenow":e,"aria-valuetext":y.valueText(b(e),o.nearestPoint(I,e)?.label),"aria-orientation":"horizontal","aria-disabled":a||void 0,"aria-invalid":ie||void 0,"data-slider-thumb":s===0?"low":"high",onKeyDown:ce(s),className:o.thumbClasses(q,fe,_),style:{insetInlineStart:o.along(c.at(e))}},s))]}),t.jsx(h.SnapChips,{points:I,labelledBy:S,label:D["aria-label"],pressed:e=>e===n[0]||e===n[1],pick:ue,disabled:a,chipClassName:V}),t.jsx(h.Message,{id:N,helperText:P,errorMessage:R,disabled:a,className:se}),p&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:z,type:"hidden",name:p,value:String(n[0]),disabled:a,readOnly:!0}),t.jsx("input",{type:"hidden",name:p,value:String(n[1]),disabled:a,readOnly:!0})]})]})}exports.RangeSlider=ye;
@@ -0,0 +1,79 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { SliderSnapPoint } from '../Slider/track';
3
+ /** A range's two values, low then high. */
4
+ export type RangeValue = [number, number];
5
+ /** Every word RangeSlider says. Pass any of them in `labels` to replace it. */
6
+ export interface RangeSliderLabels {
7
+ /** The low thumb's name, heard after the slider's label: "Price Minimum". */
8
+ low: string;
9
+ /** The high thumb's name. */
10
+ high: string;
11
+ /** What a screen reader hears for a thumb's value, with the nearest snap point's label when there is one: "40, Likely". */
12
+ valueText: (value: string, nearest: string | undefined) => string;
13
+ /** The number shown beside the label, both values in one: "20 – 80". */
14
+ range: (low: string, high: string) => string;
15
+ }
16
+ export interface RangeSliderProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
17
+ /** The two values, low then high. Pass it to control the slider; leave it out for one that starts from `defaultValue`. */
18
+ value?: RangeValue;
19
+ /** Where an uncontrolled slider starts. The whole range, `[min, max]`, by default. */
20
+ defaultValue?: RangeValue;
21
+ /** Each change: a tap, every step of a drag, a key, a snap point. */
22
+ onChange?: (value: RangeValue) => void;
23
+ /** Once a change is finished: a tap, the end of a drag, a key, a snap point. */
24
+ onCommit?: (value: RangeValue) => void;
25
+ /** The lowest value. */
26
+ min?: number;
27
+ /** The highest value. */
28
+ max?: number;
29
+ /** The smallest move: the arrows step by it, and every value lands on it. */
30
+ step?: number;
31
+ /** PageUp and PageDown's move. A tenth of the range, on a step, by default. */
32
+ pageStep?: number;
33
+ /**
34
+ * Named stops, any values and labels. Each gets a mark on the track and a
35
+ * chip under it, which does what a tap on its mark does: moves the nearer
36
+ * thumb there. A point outside `min` to `max` is left out.
37
+ */
38
+ snapPoints?: SliderSnapPoint[];
39
+ /**
40
+ * The slider's name, shown above the track. A node as well as a string, so
41
+ * it can carry markup; it names the group and each thumb by reference, so
42
+ * what's read is its text. A consumer's own `aria-labelledby` names it
43
+ * instead.
44
+ */
45
+ label?: ReactNode;
46
+ /** Supporting text under the slider. */
47
+ helperText?: string;
48
+ /** The message for an invalid value. Implies the error state. */
49
+ errorMessage?: string;
50
+ disabled?: boolean;
51
+ /** A form field name: both values are submitted under it, low then high, as a multiple select's are. */
52
+ name?: string;
53
+ /** How a value is written, in the readout and in what's said. */
54
+ formatValue?: (value: number) => string;
55
+ /** Every word the slider says, with English defaults. */
56
+ labels?: Partial<RangeSliderLabels>;
57
+ /** Classes for the track, the pointer's hit area. */
58
+ trackClassName?: string;
59
+ /** Classes for each thumb. */
60
+ thumbClassName?: string;
61
+ /** Classes for each snap chip. */
62
+ chipClassName?: string;
63
+ /** Classes for the label. */
64
+ labelClassName?: string;
65
+ /** Classes for the helper text or error message. */
66
+ messageClassName?: string;
67
+ }
68
+ /**
69
+ * Two values picked along one track, a low and a high: tapped, dragged,
70
+ * stepped with the keys, or set from a named snap point.
71
+ *
72
+ * Each thumb is a slider of its own to a screen reader and the keyboard, a
73
+ * tab stop named for the slider and for its end ("Price Minimum"), whose
74
+ * range runs to the other thumb: the thumbs meet, and never cross. The track
75
+ * takes a press for the nearer thumb. It starts at the whole range, and has
76
+ * no not-set state: the whole range is what "any" looks like.
77
+ */
78
+ declare function RangeSlider({ value: controlled, defaultValue, onChange, onCommit, min, max, step, pageStep, snapPoints, label, helperText, errorMessage, disabled, name, formatValue, labels: overrides, className, trackClassName, thumbClassName, chipClassName, labelClassName, messageClassName, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: RangeSliderProps): import("react/jsx-runtime").JSX.Element;
79
+ export { RangeSlider };
@@ -0,0 +1,166 @@
1
+ "use client";
2
+ import { jsxs as B, jsx as i, Fragment as ue } from "react/jsx-runtime";
3
+ import { useId as fe, useState as ge, useReducer as pe, useRef as g } from "react";
4
+ import { cn as q } from "../../../lib/utils.js";
5
+ import { withLabels as ve } from "../../../lib/labels.js";
6
+ import { isFieldInvalid as me, withoutInvalidProps as he } from "../../../internal/field-invalid.js";
7
+ import { useScale as ye, useCommitted as we, useFormReset as be, useTrackPress as Se, inRange as Re, along as $e, thumbClasses as ke, nearestPoint as Ie, trackClasses as xe, keyTarget as Be } from "../Slider/track.js";
8
+ import { SliderHeader as Fe, Rail as je, Fill as Ce, Marks as Me, SnapChips as Ne, Message as Te } from "../Slider/track-parts.js";
9
+ import { useKeyFocus as Ke } from "../../../internal/key-focus.js";
10
+ const Le = {
11
+ low: "Minimum",
12
+ high: "Maximum",
13
+ valueText: (n, o) => o ? `${n}, ${o}` : n,
14
+ range: (n, o) => `${n} – ${o}`
15
+ }, Oe = ([n, o]) => n <= o ? [n, o] : [o, n];
16
+ function Je({
17
+ value: n,
18
+ defaultValue: o,
19
+ onChange: G,
20
+ onCommit: F,
21
+ min: u = 0,
22
+ max: f = 100,
23
+ step: j = 1,
24
+ pageStep: J,
25
+ snapPoints: Q = [],
26
+ label: C,
27
+ helperText: M,
28
+ errorMessage: y,
29
+ disabled: s = !1,
30
+ name: p,
31
+ formatValue: w = String,
32
+ labels: U,
33
+ className: W,
34
+ trackClassName: X,
35
+ thumbClassName: Y,
36
+ chipClassName: Z,
37
+ labelClassName: _,
38
+ messageClassName: V,
39
+ "aria-invalid": ee,
40
+ "aria-labelledby": re,
41
+ "aria-describedby": te,
42
+ ...N
43
+ }) {
44
+ Ke();
45
+ const v = ve(Le, U), m = fe(), T = `${m}-label`, K = `${m}-message`, b = [`${m}-low`, `${m}-high`], S = re ?? (C ? T : void 0), l = ye(u, f, j, J), R = n !== void 0, [L, O] = ge(o ?? [u, f]), P = R ? n : L, t = Oe([l.clamp(P[0]), l.clamp(P[1])]), ne = me(!!y, { ...N, "aria-invalid": ee }), D = he(N), d = we(t), [, ie] = pe((e) => e + 1, 0), $ = (e, r, a) => {
46
+ const c = d.current, x = e === 0 ? Math.min(r, c[1]) : Math.max(r, c[0]);
47
+ if (x === c[e]) return;
48
+ const h = e === 0 ? [x, c[1]] : [c[0], x];
49
+ d.current = h, R ? ie() : O(h), G?.(h), a && F?.(h);
50
+ }, z = g(null), A = g(L);
51
+ be(
52
+ z,
53
+ R,
54
+ () => {
55
+ d.current = A.current, O(A.current);
56
+ },
57
+ p
58
+ );
59
+ const E = g(null), H = [g(null), g(null)], { dragging: k, rtl: oe, handlers: se } = Se({
60
+ trackRef: E,
61
+ disabled: s,
62
+ scale: l,
63
+ min: u,
64
+ max: f,
65
+ values: () => d.current,
66
+ set: $,
67
+ focus: (e) => H[e].current?.focus({ preventScroll: !0 }),
68
+ commit: () => F?.(d.current),
69
+ own: { down: void 0, move: void 0, up: void 0, cancel: void 0, lost: void 0 }
70
+ }), ae = (e) => (r) => {
71
+ if (s) return;
72
+ const a = d.current, c = Be(r, a[e], {
73
+ scale: l,
74
+ step: j,
75
+ start: a[e],
76
+ floor: e === 0 ? u : a[0],
77
+ ceiling: e === 0 ? a[1] : f,
78
+ rtl: oe()
79
+ });
80
+ c !== void 0 && (r.preventDefault(), $(e, c, !0));
81
+ }, le = (e) => {
82
+ const [r, a] = d.current;
83
+ $(e <= r ? 0 : e >= a ? 1 : e - r <= a - e ? 0 : 1, e, !0);
84
+ }, I = Re(Q, u, f), ce = [M || y ? K : void 0, te].filter(Boolean).join(" ") || void 0, de = "rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background";
85
+ return /* @__PURE__ */ B(
86
+ "div",
87
+ {
88
+ ...D,
89
+ role: "group",
90
+ "aria-labelledby": S,
91
+ className: q("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5", W),
92
+ "data-range-slider": "",
93
+ children: [
94
+ /* @__PURE__ */ i(
95
+ Fe,
96
+ {
97
+ labelId: T,
98
+ label: C,
99
+ readout: v.range(w(t[0]), w(t[1])),
100
+ empty: !1,
101
+ disabled: s,
102
+ labelClassName: _
103
+ }
104
+ ),
105
+ /* @__PURE__ */ i("span", { id: b[0], hidden: !0, children: v.low }),
106
+ /* @__PURE__ */ i("span", { id: b[1], hidden: !0, children: v.high }),
107
+ /* @__PURE__ */ B(
108
+ "div",
109
+ {
110
+ ...se,
111
+ ref: E,
112
+ "data-dragging": k ? "" : void 0,
113
+ className: q(xe(s), X),
114
+ children: [
115
+ /* @__PURE__ */ i(je, {}),
116
+ /* @__PURE__ */ i(Ce, { from: l.at(t[0]), to: l.at(t[1]), dragging: k }),
117
+ /* @__PURE__ */ i(Me, { points: I, at: l.at, filled: (e) => e >= t[0] && e <= t[1] }),
118
+ t.map((e, r) => /* @__PURE__ */ i(
119
+ "span",
120
+ {
121
+ ref: H[r],
122
+ role: "slider",
123
+ tabIndex: s ? void 0 : 0,
124
+ "aria-labelledby": [S, b[r]].filter(Boolean).join(" "),
125
+ "aria-describedby": ce,
126
+ "aria-valuemin": r === 0 ? u : t[0],
127
+ "aria-valuemax": r === 0 ? t[1] : f,
128
+ "aria-valuenow": e,
129
+ "aria-valuetext": v.valueText(w(e), Ie(I, e)?.label),
130
+ "aria-orientation": "horizontal",
131
+ "aria-disabled": s || void 0,
132
+ "aria-invalid": ne || void 0,
133
+ "data-slider-thumb": r === 0 ? "low" : "high",
134
+ onKeyDown: ae(r),
135
+ className: ke(k, de, Y),
136
+ style: { insetInlineStart: $e(l.at(e)) }
137
+ },
138
+ r
139
+ ))
140
+ ]
141
+ }
142
+ ),
143
+ /* @__PURE__ */ i(
144
+ Ne,
145
+ {
146
+ points: I,
147
+ labelledBy: S,
148
+ label: D["aria-label"],
149
+ pressed: (e) => e === t[0] || e === t[1],
150
+ pick: le,
151
+ disabled: s,
152
+ chipClassName: Z
153
+ }
154
+ ),
155
+ /* @__PURE__ */ i(Te, { id: K, helperText: M, errorMessage: y, disabled: s, className: V }),
156
+ p && /* @__PURE__ */ B(ue, { children: [
157
+ /* @__PURE__ */ i("input", { ref: z, type: "hidden", name: p, value: String(t[0]), disabled: s, readOnly: !0 }),
158
+ /* @__PURE__ */ i("input", { type: "hidden", name: p, value: String(t[1]), disabled: s, readOnly: !0 })
159
+ ] })
160
+ ]
161
+ }
162
+ );
163
+ }
164
+ export {
165
+ Je as RangeSlider
166
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),c=require("react"),z=require("../../../lib/utils.cjs"),be=require("../../../lib/labels.cjs"),A=require("../../../internal/field-invalid.cjs"),r=require("./track.cjs"),d=require("./track-parts.cjs"),pe=require("../../../internal/key-focus.cjs"),ye={notSet:"Not set",valueText:(v,f)=>f?`${v}, ${f}`:v};function Se({value:v,defaultValue:f,onChange:E,onCommit:m,min:i=0,max:a=100,step:q=1,pageStep:H,startValue:M,snapPoints:_=[],label:x,helperText:I,errorMessage:g,disabled:n=!1,name:b,formatValue:G=String,labels:J,className:Q,trackClassName:U,thumbClassName:W,chipClassName:X,labelClassName:Y,messageClassName:Z,"aria-invalid":V,"aria-labelledby":ee,onKeyDown:te,onPointerDown:se,onPointerMove:re,onPointerUp:ne,onPointerCancel:ie,onLostPointerCapture:le,...p}){pe.useKeyFocus();const y=be.withLabels(ye,J),F=c.useId(),N=`${F}-label`,P=`${F}-message`,B=ee??(x?N:void 0),l=r.useScale(i,a,q,H),C=l.snap(M??i+(a-i)/2),S=v!==void 0,[T,$]=c.useState(f===void 0?C:f),D=S?v:T,t=D===null?null:l.clamp(D),oe=A.isFieldInvalid(!!g,{...p,"aria-invalid":V}),K=A.withoutInvalidProps(p),o=r.useCommitted(t),[,ae]=c.useReducer(e=>e+1,0),j=(e,u)=>{e!==o.current&&(o.current=e,S?ae():$(e),E?.(e),u&&e!==null&&m?.(e))},L=c.useRef(null),O=c.useRef(T);r.useFormReset(L,S,()=>{o.current=O.current,$(O.current)},b);const h=c.useRef(null),{dragging:R,rtl:ue,handlers:ce}=r.useTrackPress({trackRef:h,disabled:n,scale:l,min:i,max:a,values:()=>[o.current],set:(e,u,ge)=>j(u,ge),focus:()=>h.current?.focus({preventScroll:!0}),commit:()=>o.current!==null&&m?.(o.current),own:{down:se,move:re,up:ne,cancel:ie,lost:le}}),de=e=>{if(te?.(e),n)return;const u=r.keyTarget(e,o.current,{scale:l,step:q,start:C,floor:i,ceiling:a,rtl:ue()});u!==void 0&&(e.preventDefault(),j(u,!0))},k=r.inRange(_,i,a),w=t===null?null:G(t),ve=w===null?y.notSet:y.valueText(w,r.nearestPoint(k,t)?.label),fe=[I||g?P:void 0,p["aria-describedby"]].filter(Boolean).join(" ")||void 0;return s.jsxs("div",{className:z.cn("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5",Q),"data-slider":"",children:[s.jsx(d.SliderHeader,{labelId:N,label:x,readout:w??y.notSet,empty:t===null,disabled:n,labelClassName:Y}),s.jsxs("div",{...K,...ce,ref:h,role:"slider",tabIndex:n?void 0:0,"aria-labelledby":B,"aria-describedby":fe,"aria-valuemin":i,"aria-valuemax":a,"aria-valuenow":t??void 0,"aria-valuetext":ve,"aria-orientation":"horizontal","aria-disabled":n||void 0,"aria-invalid":oe||void 0,"data-dragging":R?"":void 0,"data-empty":t===null?"":void 0,onKeyDown:de,className:z.cn(r.trackClasses(n),"rst:group/slider rst:focus-visible:outline-hidden",t===null&&"rst:focus-visible:ring-2 rst:focus-visible:ring-ring",U),children:[s.jsx(d.Rail,{}),t!==null&&s.jsx(d.Fill,{from:0,to:l.at(t),dragging:R}),s.jsx(d.Marks,{points:k,at:l.at,filled:e=>t!==null&&t>=e}),t!==null&&s.jsx("span",{"aria-hidden":"true","data-slider-thumb":"",className:r.thumbClasses(R,"rst:group-focus-visible/slider:ring-2 rst:group-focus-visible/slider:ring-ring rst:group-focus-visible/slider:ring-offset-2 rst:ring-offset-background",W),style:{insetInlineStart:r.along(l.at(t))}})]}),s.jsx(d.SnapChips,{points:k,labelledBy:B,label:K["aria-label"],pressed:e=>t===e,pick:e=>j(e,!0),disabled:n,chipClassName:X}),s.jsx(d.Message,{id:P,helperText:I,errorMessage:g,disabled:n,className:Z}),b&&s.jsx("input",{ref:L,type:"hidden",name:b,value:t===null?"":String(t),disabled:n,readOnly:!0})]})}exports.Slider=Se;
@@ -0,0 +1,91 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { SliderSnapPoint } from './track';
3
+ export type { SliderSnapPoint };
4
+ /** Every word Slider says. Pass any of them in `labels` to replace it. */
5
+ export interface SliderLabels {
6
+ /** Shown, and said, while there's no value. */
7
+ notSet: string;
8
+ /** What a screen reader hears for a value, with the nearest snap point's label when there is one: "72, Likely". */
9
+ valueText: (value: string, nearest: string | undefined) => string;
10
+ }
11
+ export interface SliderProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
12
+ /**
13
+ * The value, or `null` for not set: no thumb and an empty track. Pass it to
14
+ * control the slider, `null` included, which is how a consumer offers a
15
+ * clear. Leave it out for an uncontrolled slider that starts from
16
+ * `defaultValue`.
17
+ */
18
+ value?: number | null;
19
+ /**
20
+ * Where an uncontrolled slider starts: `startValue` when left out, the
21
+ * middle unless that's set. `null` starts it not set.
22
+ */
23
+ defaultValue?: number | null;
24
+ /** Each change: a tap, every step of a drag, a key, a snap point. */
25
+ onChange?: (value: number | null) => void;
26
+ /** Once a change is finished: a tap, the end of a drag, a key, a snap point. */
27
+ onCommit?: (value: number) => void;
28
+ /** The lowest value. */
29
+ min?: number;
30
+ /** The highest value. */
31
+ max?: number;
32
+ /** The smallest move: the arrows step by it, and every value lands on it. */
33
+ step?: number;
34
+ /** PageUp and PageDown's move. A tenth of the range, on a step, by default. */
35
+ pageStep?: number;
36
+ /**
37
+ * Where the thumb first appears: an uncontrolled slider's start when
38
+ * `defaultValue` is left out, and where the first arrow or Page key puts it
39
+ * on an empty slider. The middle of the range by default. Home and End go to
40
+ * `min` and `max`.
41
+ */
42
+ startValue?: number;
43
+ /**
44
+ * Named stops, any values and labels. Each gets a chip under the track that
45
+ * moves the thumb to it, and a mark on the track. A point outside `min` to
46
+ * `max` is left out, since the track can't show it.
47
+ */
48
+ snapPoints?: SliderSnapPoint[];
49
+ /**
50
+ * The slider's name, shown above the track. A node as well as a string, so
51
+ * it can carry markup; it names the slider by reference, so what's read is
52
+ * its text. A consumer's own `aria-labelledby` names it instead.
53
+ */
54
+ label?: ReactNode;
55
+ /** Supporting text under the slider. */
56
+ helperText?: string;
57
+ /** The message for an invalid value. Implies the error state. */
58
+ errorMessage?: string;
59
+ disabled?: boolean;
60
+ /** A form field name: the value is submitted under it, and an empty string while not set. */
61
+ name?: string;
62
+ /** How the value is written, in the readout and in what's said: `(v) => `${v}%`` for a percentage. */
63
+ formatValue?: (value: number) => string;
64
+ /** Every word the slider says, with English defaults. */
65
+ labels?: Partial<SliderLabels>;
66
+ /** Classes for the track's hit area, the element with the slider role. */
67
+ trackClassName?: string;
68
+ /** Classes for the thumb. */
69
+ thumbClassName?: string;
70
+ /** Classes for each snap chip. */
71
+ chipClassName?: string;
72
+ /** Classes for the label. */
73
+ labelClassName?: string;
74
+ /** Classes for the helper text or error message. */
75
+ messageClassName?: string;
76
+ }
77
+ /**
78
+ * A value picked along a track: tapped, dragged, stepped with the keys, or
79
+ * set from a named snap point.
80
+ *
81
+ * It starts with the thumb at `startValue`, the middle by default. Not set is
82
+ * there when it's asked for: `defaultValue={null}`, or `value={null}` when
83
+ * controlled, gives no thumb and an empty track, and a form takes that as a
84
+ * valid answer (an empty string under `name`). The first tap, drag or key sets
85
+ * it, and a consumer controlling `value` can set it back to `null`.
86
+ *
87
+ * One thumb. Two, for a range, is `RangeSlider`, on the same track, so
88
+ * `value` here stays a number.
89
+ */
90
+ declare function Slider({ value: controlled, defaultValue, onChange, onCommit, min, max, step, pageStep, startValue, snapPoints, label, helperText, errorMessage, disabled, name, formatValue, labels: overrides, className, trackClassName, thumbClassName, chipClassName, labelClassName, messageClassName, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, onKeyDown: onKeyDownProp, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onLostPointerCapture, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
91
+ export { Slider };
@@ -0,0 +1,130 @@
1
+ "use client";
2
+ import { jsxs as z, jsx as i } from "react/jsx-runtime";
3
+ import { useId as ve, useState as ge, useReducer as pe, useRef as w } from "react";
4
+ import { cn as A } from "../../../lib/utils.js";
5
+ import { withLabels as me } from "../../../lib/labels.js";
6
+ import { isFieldInvalid as be, withoutInvalidProps as ye } from "../../../internal/field-invalid.js";
7
+ import { useScale as Se, useCommitted as he, useFormReset as we, useTrackPress as ke, inRange as Re, nearestPoint as Ie, along as Ne, thumbClasses as Be, trackClasses as Ce, keyTarget as Fe } from "./track.js";
8
+ import { SliderHeader as $e, Rail as je, Fill as De, Marks as Ke, SnapChips as Le, Message as Pe } from "./track-parts.js";
9
+ import { useKeyFocus as Te } from "../../../internal/key-focus.js";
10
+ const Oe = {
11
+ notSet: "Not set",
12
+ valueText: (u, c) => c ? `${u}, ${c}` : u
13
+ };
14
+ function Me({
15
+ value: u,
16
+ defaultValue: c,
17
+ onChange: E,
18
+ onCommit: k,
19
+ min: n = 0,
20
+ max: o = 100,
21
+ step: R = 1,
22
+ pageStep: H,
23
+ startValue: _,
24
+ snapPoints: q = [],
25
+ label: I,
26
+ helperText: N,
27
+ errorMessage: d,
28
+ disabled: t = !1,
29
+ name: f,
30
+ formatValue: x = String,
31
+ labels: G,
32
+ className: J,
33
+ trackClassName: M,
34
+ thumbClassName: Q,
35
+ chipClassName: U,
36
+ labelClassName: W,
37
+ messageClassName: X,
38
+ "aria-invalid": Y,
39
+ "aria-labelledby": Z,
40
+ onKeyDown: V,
41
+ onPointerDown: ee,
42
+ onPointerMove: re,
43
+ onPointerUp: te,
44
+ onPointerCancel: ie,
45
+ onLostPointerCapture: ne,
46
+ ...v
47
+ }) {
48
+ Te();
49
+ const g = me(Oe, G), B = ve(), C = `${B}-label`, F = `${B}-message`, $ = Z ?? (I ? C : void 0), s = Se(n, o, R, H), j = s.snap(_ ?? n + (o - n) / 2), p = u !== void 0, [D, K] = ge(c === void 0 ? j : c), L = p ? u : D, r = L === null ? null : s.clamp(L), se = be(!!d, { ...v, "aria-invalid": Y }), P = ye(v), l = he(r), [, le] = pe((e) => e + 1, 0), m = (e, a) => {
50
+ e !== l.current && (l.current = e, p ? le() : K(e), E?.(e), a && e !== null && k?.(e));
51
+ }, T = w(null), O = w(D);
52
+ we(
53
+ T,
54
+ p,
55
+ () => {
56
+ l.current = O.current, K(O.current);
57
+ },
58
+ f
59
+ );
60
+ const b = w(null), { dragging: y, rtl: oe, handlers: ae } = ke({
61
+ trackRef: b,
62
+ disabled: t,
63
+ scale: s,
64
+ min: n,
65
+ max: o,
66
+ values: () => [l.current],
67
+ set: (e, a, fe) => m(a, fe),
68
+ focus: () => b.current?.focus({ preventScroll: !0 }),
69
+ commit: () => l.current !== null && k?.(l.current),
70
+ own: { down: ee, move: re, up: te, cancel: ie, lost: ne }
71
+ }), ue = (e) => {
72
+ if (V?.(e), t) return;
73
+ const a = Fe(e, l.current, { scale: s, step: R, start: j, floor: n, ceiling: o, rtl: oe() });
74
+ a !== void 0 && (e.preventDefault(), m(a, !0));
75
+ }, S = Re(q, n, o), h = r === null ? null : x(r), ce = h === null ? g.notSet : g.valueText(h, Ie(S, r)?.label), de = [N || d ? F : void 0, v["aria-describedby"]].filter(Boolean).join(" ") || void 0;
76
+ return /* @__PURE__ */ z("div", { className: A("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5", J), "data-slider": "", children: [
77
+ /* @__PURE__ */ i($e, { labelId: C, label: I, readout: h ?? g.notSet, empty: r === null, disabled: t, labelClassName: W }),
78
+ /* @__PURE__ */ z(
79
+ "div",
80
+ {
81
+ ...P,
82
+ ...ae,
83
+ ref: b,
84
+ role: "slider",
85
+ tabIndex: t ? void 0 : 0,
86
+ "aria-labelledby": $,
87
+ "aria-describedby": de,
88
+ "aria-valuemin": n,
89
+ "aria-valuemax": o,
90
+ "aria-valuenow": r ?? void 0,
91
+ "aria-valuetext": ce,
92
+ "aria-orientation": "horizontal",
93
+ "aria-disabled": t || void 0,
94
+ "aria-invalid": se || void 0,
95
+ "data-dragging": y ? "" : void 0,
96
+ "data-empty": r === null ? "" : void 0,
97
+ onKeyDown: ue,
98
+ className: A(
99
+ Ce(t),
100
+ "rst:group/slider rst:focus-visible:outline-hidden",
101
+ r === null && "rst:focus-visible:ring-2 rst:focus-visible:ring-ring",
102
+ M
103
+ ),
104
+ children: [
105
+ /* @__PURE__ */ i(je, {}),
106
+ r !== null && /* @__PURE__ */ i(De, { from: 0, to: s.at(r), dragging: y }),
107
+ /* @__PURE__ */ i(Ke, { points: S, at: s.at, filled: (e) => r !== null && r >= e }),
108
+ r !== null && /* @__PURE__ */ i("span", { "aria-hidden": "true", "data-slider-thumb": "", className: Be(y, "rst:group-focus-visible/slider:ring-2 rst:group-focus-visible/slider:ring-ring rst:group-focus-visible/slider:ring-offset-2 rst:ring-offset-background", Q), style: { insetInlineStart: Ne(s.at(r)) } })
109
+ ]
110
+ }
111
+ ),
112
+ /* @__PURE__ */ i(
113
+ Le,
114
+ {
115
+ points: S,
116
+ labelledBy: $,
117
+ label: P["aria-label"],
118
+ pressed: (e) => r === e,
119
+ pick: (e) => m(e, !0),
120
+ disabled: t,
121
+ chipClassName: U
122
+ }
123
+ ),
124
+ /* @__PURE__ */ i(Pe, { id: F, helperText: N, errorMessage: d, disabled: t, className: X }),
125
+ f && /* @__PURE__ */ i("input", { ref: T, type: "hidden", name: f, value: r === null ? "" : String(r), disabled: t, readOnly: !0 })
126
+ ] });
127
+ }
128
+ export {
129
+ Me as Slider
130
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("../../../lib/utils.cjs"),i=require("../../atoms/Chip/Chip.cjs"),s=require("./track.cjs");function d(t){return r.jsxs("div",{className:"rst:flex rst:items-baseline rst:justify-between rst:gap-3",children:[t.label?r.jsx("span",{id:t.labelId,className:a.cn("rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",t.disabled&&"rst:opacity-50",t.labelClassName),children:t.label}):r.jsx("span",{}),r.jsx("span",{"aria-hidden":"true","data-slider-readout":"",className:a.cn("rst:text-sm rst:tabular-nums",t.empty?"rst:text-gray-500 rst:dark:text-gray-400":"rst:font-semibold rst:text-[var(--roster-control-text)]",t.disabled&&"rst:opacity-50"),children:t.readout})]})}function o(){return r.jsx("span",{"aria-hidden":"true","data-slider-rail":"",className:"rst:absolute rst:top-1/2 rst:h-2.5 rst:-translate-y-1/2 rst:rounded-full rst:border rst:border-[var(--roster-control-border)] rst:bg-gray-100 rst:dark:bg-gray-800",style:{insetInline:s.INSET}})}function c({from:t,to:e,dragging:n}){return r.jsx("span",{"aria-hidden":"true","data-slider-fill":"",className:a.cn("rst:absolute rst:top-1/2 rst:h-2.5 rst:-translate-y-1/2 rst:rounded-full rst:bg-primary-600 rst:dark:bg-primary-400","rst:forced-colors:forced-color-adjust-none rst:forced-colors:bg-[Highlight]",!n&&"rst:transition-[inset-inline-start,width] rst:duration-150 rst:ease-out rst:motion-reduce:transition-none"),style:{insetInlineStart:s.along(t),width:`calc((100% - ${2*s.INSET}px) * ${e-t})`}})}function u({points:t,at:e,filled:n}){return t.map(l=>r.jsx("span",{"aria-hidden":"true","data-slider-mark":"","data-filled":n(l.value)?"":void 0,className:a.cn("rst:absolute rst:top-1/2 rst:size-1.5 rst:-translate-x-1/2 rst:-translate-y-1/2 rst:rounded-full rst:rtl:translate-x-1/2","rst:transition-colors rst:duration-150 rst:motion-reduce:transition-none rst:forced-colors:forced-color-adjust-none",n(l.value)?"rst:bg-white rst:dark:bg-gray-900 rst:forced-colors:bg-[Canvas]":"rst:bg-[var(--roster-control-border)] rst:forced-colors:bg-[CanvasText]"),style:{insetInlineStart:s.along(e(l.value),s.INSET+s.CAP)}},`${l.value}:${l.label}`))}function b(t){return t.points.length===0?null:r.jsx("div",{role:"group","aria-labelledby":t.labelledBy,"aria-label":t.labelledBy?void 0:t.label,className:"rst:mt-0.5 rst:flex rst:flex-wrap rst:gap-x-2 rst:gap-y-4","data-slider-snaps":"",children:t.points.map(e=>r.jsx(i.Chip,{selected:t.pressed(e.value),onSelectedChange:()=>t.pick(e.value),variant:t.pressed(e.value)?"solid":"outline",colorScheme:t.pressed(e.value)?"primary":"neutral",disabled:t.disabled,className:a.cn("rst:min-w-11 rst:shrink-0 rst:justify-center",t.chipClassName),children:e.label},`${e.value}:${e.label}`))})}function x(t){return!t.helperText&&!t.errorMessage?null:r.jsx("p",{id:t.id,className:a.cn("rst:m-0 rst:text-xs rst:text-left",t.errorMessage?"rst:text-error-600 rst:dark:text-error-400 rst:font-medium":"rst:text-gray-500 rst:dark:text-gray-400",t.disabled&&"rst:opacity-50",t.className),children:t.errorMessage||t.helperText})}exports.Fill=c;exports.Marks=u;exports.Message=x;exports.Rail=o;exports.SliderHeader=d;exports.SnapChips=b;