@blakesteve/roster 5.9.0 → 5.11.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 (42) hide show
  1. package/README.md +206 -25
  2. package/dist/components/atoms/Button/button-variants.js +1 -1
  3. package/dist/components/atoms/Eyebrow/eyebrow-variants.d.ts +2 -2
  4. package/dist/components/atoms/Input/input-variants.js +1 -1
  5. package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
  6. package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
  7. package/dist/components/atoms/Select/select-variants.cjs +1 -1
  8. package/dist/components/atoms/Select/select-variants.js +11 -2
  9. package/dist/components/atoms/Skeleton/Skeleton.cjs +1 -1
  10. package/dist/components/atoms/Skeleton/Skeleton.d.ts +19 -3
  11. package/dist/components/atoms/Skeleton/Skeleton.js +38 -33
  12. package/dist/components/atoms/ThemeToggle/ThemeToggle.d.ts +1 -1
  13. package/dist/components/molecules/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  14. package/dist/components/molecules/CheckboxGroup/checkbox-group-variants.d.ts +1 -1
  15. package/dist/components/molecules/Menu/Menu.cjs +1 -1
  16. package/dist/components/molecules/Menu/Menu.js +60 -53
  17. package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
  18. package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +74 -0
  19. package/dist/components/molecules/RangeSlider/RangeSlider.js +164 -0
  20. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -1
  21. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +13 -4
  22. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +35 -35
  23. package/dist/components/molecules/Slider/Slider.cjs +1 -0
  24. package/dist/components/molecules/Slider/Slider.d.ts +87 -0
  25. package/dist/components/molecules/Slider/Slider.js +128 -0
  26. package/dist/components/molecules/Slider/track-parts.cjs +1 -0
  27. package/dist/components/molecules/Slider/track-parts.d.ts +64 -0
  28. package/dist/components/molecules/Slider/track-parts.js +121 -0
  29. package/dist/components/molecules/Slider/track.cjs +1 -0
  30. package/dist/components/molecules/Slider/track.d.ts +115 -0
  31. package/dist/components/molecules/Slider/track.js +152 -0
  32. package/dist/components/molecules/Toast/Toaster.d.ts +1 -1
  33. package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
  34. package/dist/components/organisms/Navbar/Navbar.js +37 -37
  35. package/dist/index.d.ts +2 -0
  36. package/dist/lib/utils.cjs +1 -1
  37. package/dist/lib/utils.js +4 -1
  38. package/dist/meta.json +3 -3
  39. package/dist/roster.cjs +1 -1
  40. package/dist/roster.css +1 -1
  41. package/dist/roster.js +67 -63
  42. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ import { SliderSnapPoint } from './track';
2
+ /** The label and the visible number above the track. The number is hidden from screen readers, which hear it as the value. */
3
+ export declare function SliderHeader(props: {
4
+ labelId: string;
5
+ label?: string;
6
+ readout: string;
7
+ empty: boolean;
8
+ disabled: boolean;
9
+ labelClassName?: string;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ /**
12
+ * The rail, from the start edge's inset to the end edge's: a light surface
13
+ * edged in the control border's color. With no value it's all there is of
14
+ * the slider, so its edge carries the 3:1 a control's does.
15
+ */
16
+ export declare function Rail(): import("react/jsx-runtime").JSX.Element;
17
+ /** The filled part of the rail, between two shares of it. */
18
+ export declare function Fill({ from, to, dragging }: {
19
+ from: number;
20
+ to: number;
21
+ dragging: boolean;
22
+ }): import("react/jsx-runtime").JSX.Element;
23
+ /**
24
+ * Each snap point's mark: a bead set in the rail, its edge's color on the
25
+ * bare rail and the page's on the fill, so it shows on either.
26
+ */
27
+ export declare function Marks({ points, at, filled }: {
28
+ points: SliderSnapPoint[];
29
+ at: (v: number) => number;
30
+ filled: (v: number) => boolean;
31
+ }): import("react/jsx-runtime").JSX.Element[];
32
+ /**
33
+ * A chip for each snap point, under the track, in a group named as the
34
+ * slider is so the chips are heard as its presets.
35
+ *
36
+ * The clearance is what Chip's 44px target asks of its layout: it reaches up
37
+ * to 8px above and below the chip, so the row sits 8px under the track (the
38
+ * column's 6px and 2px more), where it can't take the bottom of a thumb's
39
+ * target, and wrapped rows are 16px apart. A short label is widened to 44
40
+ * too, since the target is only as wide as the chip, and no chip shrinks: a
41
+ * min-width replaces the flex item's own floor of its label's width, so in a
42
+ * row narrower than a label the chip would otherwise squeeze to 44 under it.
43
+ *
44
+ * A chip only ever moves a value to itself: pressed again, it stays, as a
45
+ * preset does. Pressed swaps outline for solid, as Chip's own selectable
46
+ * does, so it reads without color.
47
+ */
48
+ export declare function SnapChips(props: {
49
+ points: SliderSnapPoint[];
50
+ labelledBy: string | undefined;
51
+ label: string | undefined;
52
+ pressed: (v: number) => boolean;
53
+ pick: (v: number) => void;
54
+ disabled: boolean;
55
+ chipClassName?: string;
56
+ }): import("react/jsx-runtime").JSX.Element | null;
57
+ /** The helper text, or the error in its place. */
58
+ export declare function Message(props: {
59
+ id: string;
60
+ helperText?: string;
61
+ errorMessage?: string;
62
+ disabled: boolean;
63
+ className?: string;
64
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,121 @@
1
+ "use client";
2
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
3
+ import { cn as a } from "../../../lib/utils.js";
4
+ import { Chip as o } from "../../atoms/Chip/Chip.js";
5
+ import { INSET as n, along as i, CAP as c } from "./track.js";
6
+ function g(t) {
7
+ return /* @__PURE__ */ d("div", { className: "rst:flex rst:items-baseline rst:justify-between rst:gap-3", children: [
8
+ t.label ? /* @__PURE__ */ e(
9
+ "span",
10
+ {
11
+ id: t.labelId,
12
+ className: a("rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]", t.disabled && "rst:opacity-50", t.labelClassName),
13
+ children: t.label
14
+ }
15
+ ) : /* @__PURE__ */ e("span", {}),
16
+ /* @__PURE__ */ e(
17
+ "span",
18
+ {
19
+ "aria-hidden": "true",
20
+ "data-slider-readout": "",
21
+ className: a(
22
+ "rst:text-sm rst:tabular-nums",
23
+ t.empty ? "rst:text-gray-500 rst:dark:text-gray-400" : "rst:font-semibold rst:text-[var(--roster-control-text)]",
24
+ t.disabled && "rst:opacity-50"
25
+ ),
26
+ children: t.readout
27
+ }
28
+ )
29
+ ] });
30
+ }
31
+ function x() {
32
+ return /* @__PURE__ */ e(
33
+ "span",
34
+ {
35
+ "aria-hidden": "true",
36
+ "data-slider-rail": "",
37
+ 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",
38
+ style: { insetInline: n }
39
+ }
40
+ );
41
+ }
42
+ function h({ from: t, to: r, dragging: l }) {
43
+ return /* @__PURE__ */ e(
44
+ "span",
45
+ {
46
+ "aria-hidden": "true",
47
+ "data-slider-fill": "",
48
+ className: a(
49
+ "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",
50
+ "rst:forced-colors:forced-color-adjust-none rst:forced-colors:bg-[Highlight]",
51
+ !l && "rst:transition-[inset-inline-start,width] rst:duration-150 rst:ease-out rst:motion-reduce:transition-none"
52
+ ),
53
+ style: { insetInlineStart: i(t), width: `calc((100% - ${2 * n}px) * ${r - t})` }
54
+ }
55
+ );
56
+ }
57
+ function y({ points: t, at: r, filled: l }) {
58
+ return t.map((s) => /* @__PURE__ */ e(
59
+ "span",
60
+ {
61
+ "aria-hidden": "true",
62
+ "data-slider-mark": "",
63
+ "data-filled": l(s.value) ? "" : void 0,
64
+ className: a(
65
+ "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",
66
+ "rst:transition-colors rst:duration-150 rst:motion-reduce:transition-none rst:forced-colors:forced-color-adjust-none",
67
+ l(s.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]"
68
+ ),
69
+ style: { insetInlineStart: i(r(s.value), n + c) }
70
+ },
71
+ `${s.value}:${s.label}`
72
+ ));
73
+ }
74
+ function v(t) {
75
+ return t.points.length === 0 ? null : /* @__PURE__ */ e(
76
+ "div",
77
+ {
78
+ role: "group",
79
+ "aria-labelledby": t.labelledBy,
80
+ "aria-label": t.labelledBy ? void 0 : t.label,
81
+ className: "rst:mt-0.5 rst:flex rst:flex-wrap rst:gap-x-2 rst:gap-y-4",
82
+ "data-slider-snaps": "",
83
+ children: t.points.map((r) => /* @__PURE__ */ e(
84
+ o,
85
+ {
86
+ selected: t.pressed(r.value),
87
+ onSelectedChange: () => t.pick(r.value),
88
+ variant: t.pressed(r.value) ? "solid" : "outline",
89
+ colorScheme: t.pressed(r.value) ? "primary" : "neutral",
90
+ disabled: t.disabled,
91
+ className: a("rst:min-w-11 rst:shrink-0 rst:justify-center", t.chipClassName),
92
+ children: r.label
93
+ },
94
+ `${r.value}:${r.label}`
95
+ ))
96
+ }
97
+ );
98
+ }
99
+ function N(t) {
100
+ return !t.helperText && !t.errorMessage ? null : /* @__PURE__ */ e(
101
+ "p",
102
+ {
103
+ id: t.id,
104
+ className: a(
105
+ "rst:m-0 rst:text-xs rst:text-left",
106
+ t.errorMessage ? "rst:text-error-600 rst:dark:text-error-400 rst:font-medium" : "rst:text-gray-500 rst:dark:text-gray-400",
107
+ t.disabled && "rst:opacity-50",
108
+ t.className
109
+ ),
110
+ children: t.errorMessage || t.helperText
111
+ }
112
+ );
113
+ }
114
+ export {
115
+ h as Fill,
116
+ y as Marks,
117
+ N as Message,
118
+ x as Rail,
119
+ g as SliderHeader,
120
+ v as SnapChips
121
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),A=require("../../../lib/utils.cjs"),p=22,E=5,I=(t,s=p)=>`calc(${s}px + (100% - ${2*s}px) * ${t})`,X=t=>{const[s,n="0"]=String(t).split("e"),c=s.indexOf(".");return Math.max(0,(c===-1?0:s.length-c-1)-Number(n))};function D(t,s,n,c){const o=Math.max(X(n),X(t)),u=h.useCallback(b=>Math.min(s,Math.max(t,b)),[t,s]),l=h.useCallback((b,M=0)=>{const g=(b-t)/n,C=Math.round(g),R=M===0||Math.abs(g-C)<1e-6?C:M>0?Math.floor(g):Math.ceil(g);return u(Number((t+R*n).toFixed(o)))},[t,n,o,u]),T=h.useCallback(b=>s===t?0:(b-t)/(s-t),[t,s]);return{clamp:u,snap:l,at:T,coarse:c??Math.max(n,l(t+(s-t)/10)-t)}}function L(t,s,n){if(t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)return;const c=u=>Math.min(n.ceiling,Math.max(n.floor,u)),o=u=>s===null?n.start:c(n.scale.snap(s+u,u>0?1:-1));switch(t.key){case(n.rtl?"ArrowLeft":"ArrowRight"):case"ArrowUp":return o(n.step);case(n.rtl?"ArrowRight":"ArrowLeft"):case"ArrowDown":return o(-n.step);case"PageUp":return o(n.scale.coarse);case"PageDown":return o(-n.scale.coarse);case"Home":return n.floor;case"End":return n.ceiling;default:return}}function N(t){const[s,n]=h.useState(!1),c=h.useRef(null),o=()=>!!t.trackRef.current&&getComputedStyle(t.trackRef.current).direction==="rtl",u=()=>t.trackRef.current.getBoundingClientRect(),l=r=>{const e=u();let a=(r-e.left-p)/Math.max(1,e.width-2*p);return a=Math.min(1,Math.max(0,a)),o()&&(a=1-a),t.scale.snap(t.min+a*(t.max-t.min))},T=r=>{const e=u();return e.left+p+(e.width-2*p)*(o()?1-t.scale.at(r):t.scale.at(r))},b=r=>t.values().some((e,a)=>e!==r[a]),M=(r,e)=>{try{r.setPointerCapture(e)}catch{}n(!0)},g=(r,e,a)=>{const f=c.current;!f||f.id!==e||(c.current=null,f.mode==="drag"&&(n(!1),r.hasPointerCapture(e)&&r.releasePointerCapture(e),a&&b(f.from)&&t.commit()))},C=(r,e)=>{if(r.thumb!=="either")return r.thumb;const a=t.values()[r.tied[0]];if(e!==a)return r.thumb=e>a?r.tied[r.tied.length-1]:r.tied[0],t.focus(r.thumb),r.thumb};return{dragging:s,rtl:o,handlers:{onPointerDown:r=>{if(t.own.down?.(r),t.disabled||r.button!==0)return;if(c.current){if(!r.isPrimary)return;g(r.currentTarget,c.current.id,!1)}r.preventDefault();const e=r.currentTarget,a=t.values(),f=a.map((i,k)=>({v:i,i:k})).filter(i=>i.v!==null),P=i=>Math.abs(r.clientX-T(i)),d=f.reduce((i,k)=>!i||P(k.v)<P(i.v)?k:i,void 0),m=!!d&&P(d.v)<=p,w=d?f.filter(i=>i.v===d.v).map(i=>i.i):[0];let y=d?d.i:0;if(w.length>1){const i=l(r.clientX);y=m?"either":i<d.v?w[0]:w[w.length-1]}const S=m?T(d.v)-r.clientX:0,x={id:r.pointerId,x:r.clientX,y:r.clientY,thumb:y,tied:w,grab:S,from:a};if(r.pointerType==="mouse"||m){t.focus(y==="either"?w[0]:y),c.current={...x,mode:"drag"},M(e,r.pointerId),!m&&y!=="either"&&t.set(y,l(r.clientX),!1);return}c.current={...x,mode:"pending"}},onPointerMove:r=>{t.own.move?.(r);const e=c.current;if(!e||e.id!==r.pointerId)return;if(e.mode==="pending"){const P=Math.abs(r.clientX-e.x),d=Math.abs(r.clientY-e.y);if(P>7&&P>d){e.mode="drag",M(r.currentTarget,r.pointerId);const m=C(e,l(r.clientX));m!==void 0&&(t.focus(m),t.set(m,l(r.clientX),!1))}else d>10&&(c.current=null);return}const a=l(r.clientX+e.grab),f=C(e,a);f!==void 0&&t.set(f,a,!1)},onPointerUp:r=>{t.own.up?.(r);const e=c.current;if(e&&e.id===r.pointerId&&e.mode==="pending"){c.current=null,e.thumb!=="either"&&(t.focus(e.thumb),t.set(e.thumb,l(r.clientX),!0));return}g(r.currentTarget,r.pointerId,!0)},onPointerCancel:r=>{t.own.cancel?.(r),g(r.currentTarget,r.pointerId,!0)},onLostPointerCapture:r=>{t.own.lost?.(r),r.target===r.currentTarget&&g(r.currentTarget,r.pointerId,!0)}}}}function U(t){const s=h.useRef(t);return h.useLayoutEffect(()=>{s.current=t}),s}function F(t,s,n,c){const o=h.useRef(n);h.useEffect(()=>{o.current=n}),h.useEffect(()=>{const u=t.current?.form;if(!u||s)return;const l=()=>o.current();return u.addEventListener("reset",l),()=>u.removeEventListener("reset",l)},[t,s,c])}const K=(t,s,n)=>t.filter(c=>c.value>=s&&c.value<=n).sort((c,o)=>c.value-o.value),$=(t,s)=>s===null||t.length===0?void 0:t.reduce((n,c)=>Math.abs(c.value-s)<Math.abs(n.value-s)?c:n,t[0]),q=t=>A.cn("rst:relative rst:h-11 rst:w-full rst:touch-pan-y rst:select-none rst:rounded-md",t?"rst:cursor-not-allowed rst:opacity-50":"rst:cursor-pointer"),H=(t,s,n)=>A.cn("rst:absolute rst:top-1/2 rst:size-5 rst:-translate-x-1/2 rst:-translate-y-1/2 rst:rounded-full rst:rtl:translate-x-1/2","rst:border-2 rst:border-primary-600 rst:bg-white rst:elevation-control rst:dark:border-primary-400 rst:dark:bg-gray-900","rst:forced-colors:border-[Highlight]",s,!t&&"rst:transition-[inset-inline-start] rst:duration-150 rst:ease-out rst:motion-reduce:transition-none",n);exports.CAP=E;exports.INSET=p;exports.along=I;exports.inRange=K;exports.keyTarget=L;exports.nearestPoint=$;exports.thumbClasses=H;exports.trackClasses=q;exports.useCommitted=U;exports.useFormReset=F;exports.useScale=D;exports.useTrackPress=N;
@@ -0,0 +1,115 @@
1
+ import { KeyboardEvent, PointerEvent, RefObject } from 'react';
2
+ /** A named stop on the track: a chip under it moves a thumb there. */
3
+ export interface SliderSnapPoint {
4
+ value: number;
5
+ label: string;
6
+ }
7
+ export declare const INSET = 22;
8
+ export declare const CAP = 5;
9
+ /** A place along the rail, as a share of it from the start edge, for `inset-inline-start`. */
10
+ export declare const along: (share: number, inset?: number) => string;
11
+ export interface Scale {
12
+ clamp: (n: number) => number;
13
+ /**
14
+ * The nearest value on a step, in range. `toward` takes the next one that
15
+ * way instead, for a key from a value between steps (a controlled value off
16
+ * the grid, or a `max` that isn't on it): Left from 1 on a 0.3 step lands on
17
+ * 0.9, not 0.6.
18
+ */
19
+ snap: (raw: number, toward?: -1 | 0 | 1) => number;
20
+ /** PageUp and PageDown's move. */
21
+ coarse: number;
22
+ /** A value's share of the range, from `min`. */
23
+ at: (v: number) => number;
24
+ }
25
+ export declare function useScale(min: number, max: number, step: number, pageStep: number | undefined): Scale;
26
+ /**
27
+ * Where a key takes a thumb, or `undefined` for a key that isn't the
28
+ * slider's. The arrows step by `step` and the Page keys by the scale's
29
+ * `coarse`, Home and End go to `floor` and `ceiling`, and a thumb with no
30
+ * value goes to `start` on an arrow or Page key rather than stepping from
31
+ * anywhere. A combination is the app's or the browser's, and so is a key its
32
+ * owner has already handled.
33
+ */
34
+ export declare function keyTarget(event: KeyboardEvent, now: number | null, o: {
35
+ scale: Scale;
36
+ step: number;
37
+ start: number;
38
+ floor: number;
39
+ ceiling: number;
40
+ rtl: boolean;
41
+ }): number | undefined;
42
+ type Handler = ((event: PointerEvent<HTMLDivElement>) => void) | undefined;
43
+ /**
44
+ * The track's pointer, for any number of thumbs.
45
+ *
46
+ * A mouse press, or one on a thumb, drags at once. A touch on the track waits
47
+ * to see which way it goes: across is a drag, down the page is a scroll and
48
+ * sets nothing, and no movement is a tap, set when the finger lifts. A press
49
+ * takes the thumb nearest it, worked out from the values rather than from
50
+ * the drawn thumbs, which may still be easing there. Two thumbs on one spot
51
+ * are told apart by the way the drag first moves: up the range takes the
52
+ * higher one. A press on a thumb keeps where it landed on it, rather than
53
+ * jumping the thumb to the pointer.
54
+ */
55
+ export declare function useTrackPress(o: {
56
+ trackRef: RefObject<HTMLDivElement | null>;
57
+ disabled: boolean;
58
+ scale: Scale;
59
+ min: number;
60
+ max: number;
61
+ /** The values the thumbs are at, by index; `null` for one not placed. */
62
+ values: () => (number | null)[];
63
+ set: (thumb: number, value: number, finished: boolean) => void;
64
+ focus: (thumb: number) => void;
65
+ /** A drag that moved something has ended. */
66
+ commit: () => void;
67
+ /** The consumer's own handlers, called first. */
68
+ own: {
69
+ down: Handler;
70
+ move: Handler;
71
+ up: Handler;
72
+ cancel: Handler;
73
+ lost: Handler;
74
+ };
75
+ }): {
76
+ dragging: boolean;
77
+ rtl: () => boolean;
78
+ handlers: {
79
+ onPointerDown: (event: PointerEvent<HTMLDivElement>) => void;
80
+ onPointerMove: (event: PointerEvent<HTMLDivElement>) => void;
81
+ onPointerUp: (event: PointerEvent<HTMLDivElement>) => void;
82
+ onPointerCancel: (event: PointerEvent<HTMLDivElement>) => void;
83
+ onLostPointerCapture: (event: PointerEvent<HTMLDivElement>) => void;
84
+ };
85
+ };
86
+ /**
87
+ * Keeps a ref on the values the thumbs are at, for the keys and the pointer
88
+ * to step from. Set the moment a change is made, so input that arrives
89
+ * before a render counts every press, and never read from the drawn thumbs,
90
+ * which ease toward the values after them. Each render brings it back to the
91
+ * values, which a controlling owner may have set from outside, or declined.
92
+ */
93
+ export declare function useCommitted<T>(value: T): RefObject<T>;
94
+ /**
95
+ * A form's reset puts an uncontrolled slider back where it started, as it
96
+ * does a native input. A controlled one is its owner's to reset.
97
+ */
98
+ export declare function useFormReset(input: RefObject<HTMLInputElement | null>, controlled: boolean, reset: () => void, name: string | undefined): void;
99
+ /** Snap points in range, in the track's order, low to high from its start, whatever order they came in. */
100
+ export declare const inRange: (points: SliderSnapPoint[], min: number, max: number) => SliderSnapPoint[];
101
+ /** The snap point nearest a value. Halfway between two, the lower one's. */
102
+ export declare const nearestPoint: (points: SliderSnapPoint[], value: number | null) => SliderSnapPoint | undefined;
103
+ /**
104
+ * The track's classes. 44px tall, a thumb's whole target. pan-y: a finger
105
+ * moving down the page still scrolls it; across, it drags.
106
+ */
107
+ export declare const trackClasses: (disabled: boolean) => string;
108
+ /**
109
+ * A thumb's classes: drawn where its value is, eased there unless it's being
110
+ * dragged. Its target is the 44px around it, which the track's height and
111
+ * inset keep on the track. `ring` is the focus ring, for whichever state
112
+ * shows it.
113
+ */
114
+ export declare const thumbClasses: (dragging: boolean, ring: string, className?: string) => string;
115
+ export {};
@@ -0,0 +1,152 @@
1
+ "use client";
2
+ import { useCallback as T, useRef as k, useLayoutEffect as E, useEffect as A, useState as S } from "react";
3
+ import { cn as I } from "../../../lib/utils.js";
4
+ const P = 22, Y = 5, z = (t, s = P) => `calc(${s}px + (100% - ${2 * s}px) * ${t})`, D = (t) => {
5
+ const [s, n = "0"] = String(t).split("e"), c = s.indexOf(".");
6
+ return Math.max(0, (c === -1 ? 0 : s.length - c - 1) - Number(n));
7
+ };
8
+ function B(t, s, n, c) {
9
+ const a = Math.max(D(n), D(t)), i = T((g) => Math.min(s, Math.max(t, g)), [t, s]), l = T(
10
+ (g, M = 0) => {
11
+ const h = (g - t) / n, y = Math.round(h), R = M === 0 || Math.abs(h - y) < 1e-6 ? y : M > 0 ? Math.floor(h) : Math.ceil(h);
12
+ return i(Number((t + R * n).toFixed(a)));
13
+ },
14
+ [t, n, a, i]
15
+ ), x = T((g) => s === t ? 0 : (g - t) / (s - t), [t, s]);
16
+ return { clamp: i, snap: l, at: x, coarse: c ?? Math.max(n, l(t + (s - t) / 10) - t) };
17
+ }
18
+ function O(t, s, n) {
19
+ if (t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey) return;
20
+ const c = (i) => Math.min(n.ceiling, Math.max(n.floor, i)), a = (i) => s === null ? n.start : c(n.scale.snap(s + i, i > 0 ? 1 : -1));
21
+ switch (t.key) {
22
+ case (n.rtl ? "ArrowLeft" : "ArrowRight"):
23
+ case "ArrowUp":
24
+ return a(n.step);
25
+ case (n.rtl ? "ArrowRight" : "ArrowLeft"):
26
+ case "ArrowDown":
27
+ return a(-n.step);
28
+ case "PageUp":
29
+ return a(n.scale.coarse);
30
+ case "PageDown":
31
+ return a(-n.scale.coarse);
32
+ case "Home":
33
+ return n.floor;
34
+ case "End":
35
+ return n.ceiling;
36
+ default:
37
+ return;
38
+ }
39
+ }
40
+ function j(t) {
41
+ const [s, n] = S(!1), c = k(null), a = () => !!t.trackRef.current && getComputedStyle(t.trackRef.current).direction === "rtl", i = () => t.trackRef.current.getBoundingClientRect(), l = (r) => {
42
+ const e = i();
43
+ let o = (r - e.left - P) / Math.max(1, e.width - 2 * P);
44
+ return o = Math.min(1, Math.max(0, o)), a() && (o = 1 - o), t.scale.snap(t.min + o * (t.max - t.min));
45
+ }, x = (r) => {
46
+ const e = i();
47
+ return e.left + P + (e.width - 2 * P) * (a() ? 1 - t.scale.at(r) : t.scale.at(r));
48
+ }, g = (r) => t.values().some((e, o) => e !== r[o]), M = (r, e) => {
49
+ try {
50
+ r.setPointerCapture(e);
51
+ } catch {
52
+ }
53
+ n(!0);
54
+ }, h = (r, e, o) => {
55
+ const f = c.current;
56
+ !f || f.id !== e || (c.current = null, f.mode === "drag" && (n(!1), r.hasPointerCapture(e) && r.releasePointerCapture(e), o && g(f.from) && t.commit()));
57
+ }, y = (r, e) => {
58
+ if (r.thumb !== "either") return r.thumb;
59
+ const o = t.values()[r.tied[0]];
60
+ if (e !== o)
61
+ return r.thumb = e > o ? r.tied[r.tied.length - 1] : r.tied[0], t.focus(r.thumb), r.thumb;
62
+ };
63
+ return { dragging: s, rtl: a, handlers: { onPointerDown: (r) => {
64
+ if (t.own.down?.(r), t.disabled || r.button !== 0) return;
65
+ if (c.current) {
66
+ if (!r.isPrimary) return;
67
+ h(r.currentTarget, c.current.id, !1);
68
+ }
69
+ r.preventDefault();
70
+ const e = r.currentTarget, o = t.values(), f = o.map((u, C) => ({ v: u, i: C })).filter((u) => u.v !== null), b = (u) => Math.abs(r.clientX - x(u)), d = f.reduce((u, C) => !u || b(C.v) < b(u.v) ? C : u, void 0), m = !!d && b(d.v) <= P, p = d ? f.filter((u) => u.v === d.v).map((u) => u.i) : [0];
71
+ let w = d ? d.i : 0;
72
+ if (p.length > 1) {
73
+ const u = l(r.clientX);
74
+ w = m ? "either" : u < d.v ? p[0] : p[p.length - 1];
75
+ }
76
+ const L = m ? x(d.v) - r.clientX : 0, X = { id: r.pointerId, x: r.clientX, y: r.clientY, thumb: w, tied: p, grab: L, from: o };
77
+ if (r.pointerType === "mouse" || m) {
78
+ t.focus(w === "either" ? p[0] : w), c.current = { ...X, mode: "drag" }, M(e, r.pointerId), !m && w !== "either" && t.set(w, l(r.clientX), !1);
79
+ return;
80
+ }
81
+ c.current = { ...X, mode: "pending" };
82
+ }, onPointerMove: (r) => {
83
+ t.own.move?.(r);
84
+ const e = c.current;
85
+ if (!e || e.id !== r.pointerId) return;
86
+ if (e.mode === "pending") {
87
+ const b = Math.abs(r.clientX - e.x), d = Math.abs(r.clientY - e.y);
88
+ if (b > 7 && b > d) {
89
+ e.mode = "drag", M(r.currentTarget, r.pointerId);
90
+ const m = y(e, l(r.clientX));
91
+ m !== void 0 && (t.focus(m), t.set(m, l(r.clientX), !1));
92
+ } else d > 10 && (c.current = null);
93
+ return;
94
+ }
95
+ const o = l(r.clientX + e.grab), f = y(e, o);
96
+ f !== void 0 && t.set(f, o, !1);
97
+ }, onPointerUp: (r) => {
98
+ t.own.up?.(r);
99
+ const e = c.current;
100
+ if (e && e.id === r.pointerId && e.mode === "pending") {
101
+ c.current = null, e.thumb !== "either" && (t.focus(e.thumb), t.set(e.thumb, l(r.clientX), !0));
102
+ return;
103
+ }
104
+ h(r.currentTarget, r.pointerId, !0);
105
+ }, onPointerCancel: (r) => {
106
+ t.own.cancel?.(r), h(r.currentTarget, r.pointerId, !0);
107
+ }, onLostPointerCapture: (r) => {
108
+ t.own.lost?.(r), r.target === r.currentTarget && h(r.currentTarget, r.pointerId, !0);
109
+ } } };
110
+ }
111
+ function q(t) {
112
+ const s = k(t);
113
+ return E(() => {
114
+ s.current = t;
115
+ }), s;
116
+ }
117
+ function G(t, s, n, c) {
118
+ const a = k(n);
119
+ A(() => {
120
+ a.current = n;
121
+ }), A(() => {
122
+ const i = t.current?.form;
123
+ if (!i || s) return;
124
+ const l = () => a.current();
125
+ return i.addEventListener("reset", l), () => i.removeEventListener("reset", l);
126
+ }, [t, s, c]);
127
+ }
128
+ const J = (t, s, n) => t.filter((c) => c.value >= s && c.value <= n).sort((c, a) => c.value - a.value), Q = (t, s) => s === null || t.length === 0 ? void 0 : t.reduce((n, c) => Math.abs(c.value - s) < Math.abs(n.value - s) ? c : n, t[0]), V = (t) => I(
129
+ "rst:relative rst:h-11 rst:w-full rst:touch-pan-y rst:select-none rst:rounded-md",
130
+ t ? "rst:cursor-not-allowed rst:opacity-50" : "rst:cursor-pointer"
131
+ ), W = (t, s, n) => I(
132
+ "rst:absolute rst:top-1/2 rst:size-5 rst:-translate-x-1/2 rst:-translate-y-1/2 rst:rounded-full rst:rtl:translate-x-1/2",
133
+ "rst:border-2 rst:border-primary-600 rst:bg-white rst:elevation-control rst:dark:border-primary-400 rst:dark:bg-gray-900",
134
+ "rst:forced-colors:border-[Highlight]",
135
+ s,
136
+ !t && "rst:transition-[inset-inline-start] rst:duration-150 rst:ease-out rst:motion-reduce:transition-none",
137
+ n
138
+ );
139
+ export {
140
+ Y as CAP,
141
+ P as INSET,
142
+ z as along,
143
+ J as inRange,
144
+ O as keyTarget,
145
+ Q as nearestPoint,
146
+ W as thumbClasses,
147
+ V as trackClasses,
148
+ q as useCommitted,
149
+ G as useFormReset,
150
+ B as useScale,
151
+ j as useTrackPress
152
+ };
@@ -21,7 +21,7 @@ export interface ToasterProps extends Pick<HotToasterProps, "position" | "gutter
21
21
  * already depend on it at the same version and already write
22
22
  * `toast.success(...)`. Wrapping means their call sites do not move; what
23
23
  * changes is that the toast stops being styled with hardcoded hex in each app
24
- * — game-verdict pinned `#1a1f2e` and `#10b981`, mega-squad `#413f3c` and
24
+ * — one app pinned `#1a1f2e` and `#10b981`, the other `#413f3c` and
25
25
  * `#f3eee3`, neither of which is in either app's palette any more.
26
26
  *
27
27
  * The `children` render prop is used rather than `toastOptions`, so the body
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),y=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),f=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),n=require("../../../lib/utils.cjs"),cr=require("../../../lib/labels.cjs"),q=require("../../atoms/Button/Button.cjs"),E=require("../../atoms/Link/Link.cjs"),J=require("../../atoms/Badge/Badge.cjs"),dr=require("../../atoms/Avatar/Avatar.cjs"),Q=require("../../atoms/Switch/switch-variants.cjs"),d=require("../../molecules/Menu/Menu.cjs"),lr=require("./navbar-variants.cjs"),L=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),ur=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs");function T({on:s,size:e}){return r.jsx("span",{"aria-hidden":"true","data-testid":"navbar-theme-track","data-checked":s?"":void 0,className:n.cn(Q.switchTrackVariants({size:e,variant:"neutral"}),"rst:pointer-events-none"),children:r.jsx("span",{className:n.cn(Q.switchThumbVariants({size:e}))})})}const D="rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200",xr=n.cn(D,"rst:font-semibold rst:rounded-sm rst:hover:text-gray-900 rst:dark:hover:text-gray-100 rst:hover:focus:text-gray-900 rst:dark:hover:focus:text-gray-100"),W=new WeakMap;function hr(s){if(!s||typeof s=="string")return;let e=W.get(s);return e||(e=a=>r.jsx(s,{...a}),W.set(s,e)),e}const Y=n.cn(D,"rst:border rst:border-transparent rst:font-medium rst:text-gray-600 rst:dark:text-gray-400 rst:focus:text-gray-600 rst:dark:focus:text-gray-400 rst:hover:bg-gray-500/10 rst:dark:hover:bg-gray-400/15 rst:hover:focus:bg-gray-500/10 rst:dark:hover:focus:bg-gray-400/15"),Z=(s,e)=>typeof s=="function"?s({close:e}):s,mr={openMainMenu:"Open main menu",closeMainMenu:"Close menu",openUserMenu:"Open user menu",logIn:"Log In",logOut:"Log Out",darkMode:"Dark Mode",pendingInvitations:"Pending Invitations",inbox:s=>`Inbox (${s})`};function gr(s){return m.useSyncExternalStore(e=>{if(!s||typeof document>"u")return()=>{};const a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},()=>s&&document.documentElement.classList.contains("dark"),()=>!1)}function H(s,e){if(!e||!s)return!1;if(s.contains(e))return!0;const a=e.closest?.("[data-menu-panel]")?.getAttribute("data-menu-tree");return!!a&&!!s.querySelector(`[data-menu-tree="${CSS.escape(a)}"]`)}const yr='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function fr({close:s,panel:e,hamburger:a}){return m.useEffect(()=>{const x=p=>{const b=p.target;!H(e.current,b)&&!a.current?.contains(b)&&s()};return document.addEventListener("pointerdown",x,{capture:!0}),()=>document.removeEventListener("pointerdown",x,{capture:!0})},[s,e,a]),null}function pr({close:s,panel:e}){return m.useEffect(()=>{const a=p=>{H(e.current,p.target)||s()},x=requestAnimationFrame(()=>{e.current?.querySelector(yr)?.focus(),document.addEventListener("focusin",a)});return()=>{cancelAnimationFrame(x),document.removeEventListener("focusin",a)}},[s,e]),null}function vr({activePath:s,close:e}){const a=m.useRef(s);return m.useEffect(()=>{a.current!==s&&(a.current=s,e())},[s,e]),null}const br=({logoSrc:s,logoSize:e="2rem",logoHeight:a,logoWidth:x,logoClassName:p,brandName:b,items:_,activePath:w,routerElement:k,user:i,onLogin:M,onLogout:S,onInboxClick:j,onThemeToggle:v,actions:rr,brandElement:z,navActions:tr,userMenuItems:F=[],className:sr,variant:l="default",position:er="sticky",themeMode:O,labels:ar,notificationVariant:P="error",notificationFill:V="solid",...nr})=>{const o=cr.withLabels(mr,ar),ir=hr(k),N=(i?.notificationCount||0)>0,I=h=>typeof h=="number"?`${h}px`:h,$=a!==void 0||x!==void 0,G=$?{width:x===void 0?"auto":I(x),height:a===void 0?"auto":I(a)}:{width:I(e),height:I(e)},K=$&&"rst:object-contain rst:object-left rst:rtl:object-right",or=gr(O==="auto"),u=(O==="auto"?or?"dark":"light":O??(l==="white"||l==="default"?"light":"dark"))==="dark",A=l==="slate"||l==="primary"||l==="default"&&u||l==="white"&&u||l==="transparent"&&u,B=l==="primary"?{brand:"rst:text-primary-700-ink rst:hover:text-primary-700-ink/80 rst:dark:text-white rst:dark:hover:text-gray-200",linkBase:"rst:text-primary-700-ink/80 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:text-white",linkActive:"rst:text-primary-700-ink rst:font-semibold rst:hover:text-primary-700-ink/80 rst:dark:text-primary-400 rst:dark:hover:text-primary-300",hamburger:"rst:text-primary-700-ink/80 rst:hover:bg-primary-700-ink/10 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:bg-white/10 rst:dark:hover:text-white"}:{brand:A?"rst:text-white rst:dark:text-white rst:hover:text-gray-200 rst:dark:hover:text-gray-200":"rst:text-gray-900 rst:dark:text-gray-900 rst:hover:text-gray-600 rst:dark:hover:text-gray-600",linkBase:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-600 rst:dark:text-gray-600 rst:hover:text-gray-900 rst:dark:hover:text-gray-900",linkActive:A?"rst:text-primary-400 rst:dark:text-primary-400 rst:font-semibold rst:hover:text-primary-300 rst:dark:hover:text-primary-300":"rst:text-primary-600 rst:dark:text-primary-600 rst:font-semibold rst:hover:text-primary-700 rst:dark:hover:text-primary-700",hamburger:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:bg-white/10 rst:dark:hover:bg-white/10 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-500 rst:dark:text-gray-500 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-100 rst:hover:text-gray-700 rst:dark:hover:text-gray-700"},R=m.useRef(null),X=m.useRef(null);return r.jsx(L.Popover,{as:"nav",className:n.cn("rst:z-50",lr.navbarVariants({variant:l,position:er}),sr),...nr,children:({open:h,close:c})=>{const C=Z(rr,c),U=Z(tr,c);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rst:container rst:mx-auto rst:flex rst:items-center rst:justify-between rst:px-4 rst:h-16",children:[r.jsxs(E.Link,{as:k,href:"/",to:"/",variant:"neutral",underline:"none",className:n.cn("rst:flex rst:items-center rst:gap-3 rst:transition-opacity",B.brand),children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,p??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:text-xl rst:font-bold rst:tracking-tight",children:b})]}),r.jsxs("div",{className:"rst:hidden rst:md:flex rst:items-center rst:gap-8",children:[r.jsx("div",{className:"rst:flex rst:items-center rst:gap-6",children:_.map(t=>{const g=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,variant:"neutral",underline:"none",className:n.cn("rst:inline-flex rst:items-center rst:gap-1.5 rst:text-sm rst:transition-colors rst:duration-200",g?B.linkActive:B.linkBase),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]},t.path)})}),U,C??(i?r.jsx("div",{className:"rst:relative rst:ml-2",children:r.jsxs(d.Menu,{linkComponent:ir,children:[r.jsxs(d.MenuButton,{plain:!0,className:"rst:relative rst:flex rst:rounded-full rst:text-sm 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 rst:before:absolute rst:before:-inset-1.5 rst:before:content-['']",children:[r.jsx("span",{className:"rst:sr-only",children:o.openUserMenu}),r.jsx(dr.Avatar,{"aria-hidden":"true",alt:"",initials:i.initials,src:i.avatarSrc,size:"sm",shape:"circle",colorScheme:i.avatarColor??"primary"}),N&&r.jsx("div",{className:"rst:absolute rst:-top-1 rst:-right-2",children:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i.notificationCount})})]}),r.jsxs(d.MenuItems,{align:"end",offset:8,className:"rst:w-48 rst:min-w-0 rst:bg-white rst:dark:bg-gray-800 rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700",children:[(N&&j||v)&&r.jsxs(d.MenuGroup,{className:"rst:py-1",children:[N&&j&&r.jsx(d.MenuItem,{onSelect:j,className:Y,icon:r.jsx(y.FontAwesomeIcon,{icon:f.faInbox,className:"rst:text-primary-500 rst:w-4"}),children:o.inbox(i.notificationCount??0)}),v&&r.jsx(d.MenuCheckboxItem,{checked:u,onCheckedChange:()=>v(),closeOnSelect:!1,className:D,icon:r.jsx(y.FontAwesomeIcon,{icon:f.faMoon,className:n.cn("rst:w-4 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),indicator:r.jsx(T,{on:u,size:"xs"}),children:r.jsx("span",{className:"rst:font-medium",children:o.darkMode})})]}),F.length>0&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:F.map(t=>r.jsx(d.MenuItem,{href:t.path,badge:t.badge,className:xr,children:t.label},t.path))}),S&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:r.jsx(d.MenuItem,{onSelect:S,className:Y,icon:r.jsx(y.FontAwesomeIcon,{icon:f.faRightFromBracket,className:"rst:text-gray-400 rst:dark:text-gray-500 rst:w-4"}),children:o.logOut})})]})]})}):r.jsx(q.Button,{size:"sm",variant:"solid",colorScheme:"primary",onClick:M,children:o.logIn}))]}),r.jsx("div",{ref:X,"data-roster-hamburger":!0,className:"rst:flex rst:md:hidden",children:r.jsxs(L.PopoverButton,{className:n.cn("rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 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",B.hamburger),children:[r.jsx("span",{className:"rst:sr-only",children:o.openMainMenu}),h?r.jsx(y.FontAwesomeIcon,{icon:f.faXmark,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}):r.jsxs("div",{className:"rst:relative",children:[r.jsx(y.FontAwesomeIcon,{icon:f.faBars,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}),N&&r.jsx("span",{className:"rst:absolute rst:top-0 rst:right-0 rst:block rst:h-2.5 rst:w-2.5 rst:rounded-full rst:bg-error-500 rst:ring-2 rst:ring-transparent rst:transform rst:translate-x-1/4 rst:-translate-y-1/4"})]})]})})]}),h&&r.jsx(fr,{close:c,panel:R,hamburger:X}),h&&r.jsx(pr,{close:c,panel:R}),h&&r.jsx(vr,{activePath:w,close:c}),r.jsx(ur.Transition,{as:m.Fragment,enter:"rst:duration-200 rst:ease-out",enterFrom:"rst:opacity-0 rst:scale-95",enterTo:"rst:opacity-100 rst:scale-100",leave:"rst:duration-100 rst:ease-in",leaveFrom:"rst:opacity-100 rst:scale-100",leaveTo:"rst:opacity-0 rst:scale-95",children:r.jsx(L.PopoverPanel,{className:"rst:absolute rst:top-0 rst:inset-x-0 rst:z-50 rst:origin-top-right rst:transform rst:p-2 rst:transition rst:md:hidden",children:r.jsxs("div",{ref:R,"data-roster-mobile-panel":!0,className:"rst:rounded-lg rst:elevation-anchored rst:ring rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700 rst:bg-white rst:dark:bg-gray-800",children:[r.jsxs("div",{className:"rst:px-5 rst:pt-5 rst:pb-6",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:justify-between",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3",children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,p??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:font-bold rst:text-gray-900 rst:dark:text-white",children:b})]}),r.jsx("div",{className:"rst:-mr-2",children:r.jsxs(L.PopoverButton,{className:"rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:text-gray-400 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-700 rst:hover:text-gray-500 rst:dark:hover:text-white rst:focus:outline-hidden",children:[r.jsx("span",{className:"rst:sr-only",children:o.closeMainMenu}),r.jsx(y.FontAwesomeIcon,{icon:f.faXmark,className:"rst:h-6 rst:w-6","aria-hidden":"true"})]})})]}),r.jsxs("div",{className:"rst:mt-6",children:[U&&r.jsx("div",{className:"rst:mb-4",children:U}),r.jsxs("nav",{className:"rst:grid rst:gap-y-4",children:[_.map(t=>{const g=w===t.path;return r.jsx(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",g?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:r.jsxs("span",{className:n.cn("rst:ml-3 rst:inline-flex rst:items-center rst:gap-1.5 rst:text-base rst:font-medium",g?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]})},t.path)}),i&&F.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("hr",{className:"rst:border-gray-100 rst:dark:border-gray-700"}),F.map(t=>{const g=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",g?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:[r.jsx("span",{className:n.cn("rst:ml-3 rst:text-base rst:font-medium",g?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:t.label}),t.badge&&r.jsx("span",{className:"rst:ml-2 rst:inline-flex",children:t.badge})]},t.path)})]})]})]})]}),(i||C||M)&&r.jsx("div",{className:"rst:py-6 rst:px-5 rst:space-y-4",children:C||(!i&&M?r.jsx(q.Button,{variant:"solid",colorScheme:"primary",className:"rst:w-full rst:justify-center",onClick:()=>{M(),c()},children:o.logIn}):r.jsxs(r.Fragment,{children:[N&&j&&r.jsx(q.Button,{variant:"ghost",colorScheme:"neutral",onClick:()=>{j?.(),c()},className:"rst:w-full rst:justify-between rst:px-4 rst:text-base rst:font-medium rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",endIcon:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i?.notificationCount}),children:o.pendingInvitations}),v&&r.jsxs("div",{onClick:t=>{t.preventDefault(),v()},role:"switch","aria-checked":u,tabIndex:0,onKeyDown:t=>{t.repeat||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),v())},className:"rst:flex rst:w-full rst:items-center rst:justify-between rst:rounded-md rst:px-4 rst:py-2 rst:text-base rst:transition-colors rst:cursor-pointer rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3 rst:font-medium",children:[r.jsx(y.FontAwesomeIcon,{icon:f.faMoon,className:n.cn("rst:w-5 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),r.jsx("span",{children:o.darkMode})]}),r.jsx(T,{on:u,size:"sm"})]}),S&&r.jsx(q.Button,{variant:"outline",colorScheme:"error",className:"rst:w-full rst:justify-center",onClick:()=>{S?.(),c()},children:o.logOut})]}))})]})})})]})}})};exports.Navbar=br;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),f=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),p=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),n=require("../../../lib/utils.cjs"),cr=require("../../../lib/labels.cjs"),q=require("../../atoms/Button/Button.cjs"),E=require("../../atoms/Link/Link.cjs"),J=require("../../atoms/Badge/Badge.cjs"),dr=require("../../atoms/Avatar/Avatar.cjs"),Q=require("../../atoms/Switch/switch-variants.cjs"),d=require("../../molecules/Menu/Menu.cjs"),lr=require("./navbar-variants.cjs"),L=require("../../../node_modules/@headlessui/react/dist/components/popover/popover.cjs"),ur=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs");function T({on:s,size:e}){return r.jsx("span",{"aria-hidden":"true","data-testid":"navbar-theme-track","data-checked":s?"":void 0,className:n.cn(Q.switchTrackVariants({size:e,variant:"neutral"}),"rst:pointer-events-none"),children:r.jsx("span",{className:n.cn(Q.switchThumbVariants({size:e}))})})}const D="rst:gap-2 rst:px-4 rst:[&>[data-menu-lead]]:w-auto rst:text-gray-700 rst:dark:text-gray-200 rst:focus:bg-gray-50 rst:focus:text-gray-700 rst:dark:focus:bg-gray-700 rst:dark:focus:text-gray-200",xr=n.cn(D,"rst:font-semibold rst:rounded-sm rst:hover:text-gray-900 rst:dark:hover:text-gray-100 rst:hover:focus:text-gray-900 rst:dark:hover:focus:text-gray-100"),W=new WeakMap;function hr(s){if(!s||typeof s=="string")return;let e=W.get(s);return e||(e=a=>r.jsx(s,{...a}),W.set(s,e)),e}const Y=n.cn(D,"rst:border rst:border-transparent rst:font-medium rst:text-gray-600 rst:dark:text-gray-400 rst:focus:text-gray-600 rst:dark:focus:text-gray-400 rst:hover:bg-gray-500/10 rst:dark:hover:bg-gray-400/15 rst:hover:focus:bg-gray-500/10 rst:dark:hover:focus:bg-gray-400/15"),Z=(s,e)=>typeof s=="function"?s({close:e}):s,mr={openMainMenu:"Open main menu",closeMainMenu:"Close menu",openUserMenu:"Open user menu",logIn:"Log In",logOut:"Log Out",darkMode:"Dark Mode",pendingInvitations:"Pending Invitations",inbox:s=>`Inbox (${s})`};function gr(s){return m.useSyncExternalStore(e=>{if(!s||typeof document>"u")return()=>{};const a=new MutationObserver(e);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},()=>s&&document.documentElement.classList.contains("dark"),()=>!1)}function H(s,e){if(!e||!s)return!1;if(s.contains(e))return!0;const a=e.closest?.("[data-menu-panel]")?.getAttribute("data-menu-tree");return!!a&&!!s.querySelector(`[data-menu-tree="${CSS.escape(a)}"]`)}const yr='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function fr({close:s,panel:e,hamburger:a}){return m.useEffect(()=>{const x=g=>{const b=g.target;!H(e.current,b)&&!a.current?.contains(b)&&s()};return document.addEventListener("pointerdown",x,{capture:!0}),()=>document.removeEventListener("pointerdown",x,{capture:!0})},[s,e,a]),null}function pr({close:s,panel:e}){return m.useEffect(()=>{const a=g=>{g.target!==e.current?.parentElement&&(H(e.current,g.target)||s())},x=requestAnimationFrame(()=>{e.current?.querySelector(yr)?.focus(),document.addEventListener("focusin",a)});return()=>{cancelAnimationFrame(x),document.removeEventListener("focusin",a)}},[s,e]),null}function vr({activePath:s,close:e}){const a=m.useRef(s);return m.useEffect(()=>{a.current!==s&&(a.current=s,e())},[s,e]),null}const br=({logoSrc:s,logoSize:e="2rem",logoHeight:a,logoWidth:x,logoClassName:g,brandName:b,items:_,activePath:w,routerElement:k,user:i,onLogin:M,onLogout:S,onInboxClick:j,onThemeToggle:v,actions:rr,brandElement:z,navActions:tr,userMenuItems:F=[],className:sr,variant:l="default",position:er="sticky",themeMode:O,labels:ar,notificationVariant:P="error",notificationFill:V="solid",...nr})=>{const o=cr.withLabels(mr,ar),ir=hr(k),N=(i?.notificationCount||0)>0,I=h=>typeof h=="number"?`${h}px`:h,$=a!==void 0||x!==void 0,G=$?{width:x===void 0?"auto":I(x),height:a===void 0?"auto":I(a)}:{width:I(e),height:I(e)},K=$&&"rst:object-contain rst:object-left rst:rtl:object-right",or=gr(O==="auto"),u=(O==="auto"?or?"dark":"light":O??(l==="white"||l==="default"?"light":"dark"))==="dark",A=l==="slate"||l==="primary"||l==="default"&&u||l==="white"&&u||l==="transparent"&&u,B=l==="primary"?{brand:"rst:text-primary-700-ink rst:hover:text-primary-700-ink/80 rst:dark:text-white rst:dark:hover:text-gray-200",linkBase:"rst:text-primary-700-ink/80 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:text-white",linkActive:"rst:text-primary-700-ink rst:font-semibold rst:hover:text-primary-700-ink/80 rst:dark:text-primary-400 rst:dark:hover:text-primary-300",hamburger:"rst:text-primary-700-ink/80 rst:hover:bg-primary-700-ink/10 rst:hover:text-primary-700-ink rst:dark:text-gray-300 rst:dark:hover:bg-white/10 rst:dark:hover:text-white"}:{brand:A?"rst:text-white rst:dark:text-white rst:hover:text-gray-200 rst:dark:hover:text-gray-200":"rst:text-gray-900 rst:dark:text-gray-900 rst:hover:text-gray-600 rst:dark:hover:text-gray-600",linkBase:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-600 rst:dark:text-gray-600 rst:hover:text-gray-900 rst:dark:hover:text-gray-900",linkActive:A?"rst:text-primary-400 rst:dark:text-primary-400 rst:font-semibold rst:hover:text-primary-300 rst:dark:hover:text-primary-300":"rst:text-primary-600 rst:dark:text-primary-600 rst:font-semibold rst:hover:text-primary-700 rst:dark:hover:text-primary-700",hamburger:A?"rst:text-gray-300 rst:dark:text-gray-300 rst:hover:bg-white/10 rst:dark:hover:bg-white/10 rst:hover:text-white rst:dark:hover:text-white":"rst:text-gray-500 rst:dark:text-gray-500 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-100 rst:hover:text-gray-700 rst:dark:hover:text-gray-700"},R=m.useRef(null),X=m.useRef(null);return r.jsx(L.Popover,{as:"nav",className:n.cn("rst:z-50",lr.navbarVariants({variant:l,position:er}),sr),...nr,children:({open:h,close:c})=>{const C=Z(rr,c),U=Z(tr,c);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rst:container rst:mx-auto rst:flex rst:items-center rst:justify-between rst:px-4 rst:h-16",children:[r.jsxs(E.Link,{as:k,href:"/",to:"/",variant:"neutral",underline:"none",className:n.cn("rst:flex rst:items-center rst:gap-3 rst:transition-opacity",B.brand),children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:text-xl rst:font-bold rst:tracking-tight",children:b})]}),r.jsxs("div",{className:"rst:hidden rst:md:flex rst:items-center rst:gap-8",children:[r.jsx("div",{className:"rst:flex rst:items-center rst:gap-6",children:_.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,variant:"neutral",underline:"none",className:n.cn("rst:inline-flex rst:items-center rst:gap-1.5 rst:text-sm rst:transition-colors rst:duration-200",y?B.linkActive:B.linkBase),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]},t.path)})}),U,C??(i?r.jsx("div",{className:"rst:relative rst:ml-2",children:r.jsxs(d.Menu,{linkComponent:ir,children:[r.jsxs(d.MenuButton,{plain:!0,className:"rst:relative rst:flex rst:rounded-full rst:text-sm 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 rst:before:absolute rst:before:-inset-1.5 rst:before:content-['']",children:[r.jsx("span",{className:"rst:sr-only",children:o.openUserMenu}),r.jsx(dr.Avatar,{"aria-hidden":"true",alt:"",initials:i.initials,src:i.avatarSrc,size:"sm",shape:"circle",colorScheme:i.avatarColor??"primary"}),N&&r.jsx("div",{className:"rst:absolute rst:-top-1 rst:-right-2",children:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i.notificationCount})})]}),r.jsxs(d.MenuItems,{align:"end",offset:8,className:"rst:w-48 rst:min-w-0 rst:bg-white rst:dark:bg-gray-800 rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700",children:[(N&&j||v)&&r.jsxs(d.MenuGroup,{className:"rst:py-1",children:[N&&j&&r.jsx(d.MenuItem,{onSelect:j,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faInbox,className:"rst:text-primary-500 rst:w-4"}),children:o.inbox(i.notificationCount??0)}),v&&r.jsx(d.MenuCheckboxItem,{checked:u,onCheckedChange:()=>v(),closeOnSelect:!1,className:D,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-4 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),indicator:r.jsx(T,{on:u,size:"xs"}),children:r.jsx("span",{className:"rst:font-medium",children:o.darkMode})})]}),F.length>0&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:F.map(t=>r.jsx(d.MenuItem,{href:t.path,badge:t.badge,className:xr,children:t.label},t.path))}),S&&r.jsx(d.MenuGroup,{className:"rst:py-1",children:r.jsx(d.MenuItem,{onSelect:S,className:Y,icon:r.jsx(f.FontAwesomeIcon,{icon:p.faRightFromBracket,className:"rst:text-gray-400 rst:dark:text-gray-500 rst:w-4"}),children:o.logOut})})]})]})}):r.jsx(q.Button,{size:"sm",variant:"solid",colorScheme:"primary",onClick:M,children:o.logIn}))]}),r.jsx("div",{ref:X,"data-roster-hamburger":!0,className:"rst:flex rst:md:hidden",children:r.jsxs(L.PopoverButton,{className:n.cn("rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 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",B.hamburger),children:[r.jsx("span",{className:"rst:sr-only",children:o.openMainMenu}),h?r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}):r.jsxs("div",{className:"rst:relative",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faBars,className:"rst:block rst:h-6 rst:w-6","aria-hidden":"true"}),N&&r.jsx("span",{className:"rst:absolute rst:top-0 rst:right-0 rst:block rst:h-2.5 rst:w-2.5 rst:rounded-full rst:bg-error-500 rst:ring-2 rst:ring-transparent rst:transform rst:translate-x-1/4 rst:-translate-y-1/4"})]})]})})]}),h&&r.jsx(fr,{close:c,panel:R,hamburger:X}),h&&r.jsx(pr,{close:c,panel:R}),h&&r.jsx(vr,{activePath:w,close:c}),r.jsx(ur.Transition,{as:m.Fragment,enter:"rst:duration-200 rst:ease-out",enterFrom:"rst:opacity-0 rst:scale-95",enterTo:"rst:opacity-100 rst:scale-100",leave:"rst:duration-100 rst:ease-in",leaveFrom:"rst:opacity-100 rst:scale-100",leaveTo:"rst:opacity-0 rst:scale-95",children:r.jsx(L.PopoverPanel,{className:"rst:absolute rst:top-0 rst:inset-x-0 rst:z-50 rst:origin-top-right rst:transform rst:p-2 rst:transition rst:md:hidden",children:r.jsxs("div",{ref:R,"data-roster-mobile-panel":!0,className:"rst:rounded-lg rst:elevation-anchored rst:ring rst:ring-black/5 rst:dark:ring-white/10 rst:divide-y rst:divide-gray-100 rst:dark:divide-gray-700 rst:bg-white rst:dark:bg-gray-800",children:[r.jsxs("div",{className:"rst:px-5 rst:pt-5 rst:pb-6",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:justify-between",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3",children:[r.jsx("img",{src:s,alt:"",style:G,className:n.cn("rst:shrink-0",K,g??"rst:rounded-md")}),z??r.jsx("span",{className:"rst:font-bold rst:text-gray-900 rst:dark:text-white",children:b})]}),r.jsx("div",{className:"rst:-mr-2",children:r.jsxs(L.PopoverButton,{className:"rst:inline-flex rst:items-center rst:justify-center rst:rounded-md rst:p-2 rst:text-gray-400 rst:hover:bg-gray-100 rst:dark:hover:bg-gray-700 rst:hover:text-gray-500 rst:dark:hover:text-white rst:focus:outline-hidden",children:[r.jsx("span",{className:"rst:sr-only",children:o.closeMainMenu}),r.jsx(f.FontAwesomeIcon,{icon:p.faXmark,className:"rst:h-6 rst:w-6","aria-hidden":"true"})]})})]}),r.jsxs("div",{className:"rst:mt-6",children:[U&&r.jsx("div",{className:"rst:mb-4",children:U}),r.jsxs("nav",{className:"rst:grid rst:gap-y-4",children:[_.map(t=>{const y=w===t.path;return r.jsx(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:r.jsxs("span",{className:n.cn("rst:ml-3 rst:inline-flex rst:items-center rst:gap-1.5 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:[t.label,t.badge&&r.jsx("span",{className:"rst:inline-flex",children:t.badge})]})},t.path)}),i&&F.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("hr",{className:"rst:border-gray-100 rst:dark:border-gray-700"}),F.map(t=>{const y=w===t.path;return r.jsxs(E.Link,{as:k,href:t.path,to:t.path,onClick:()=>c(),variant:"neutral",underline:"none",className:n.cn("rst:-m-3 rst:flex rst:items-center rst:rounded-md rst:p-3 rst:transition-colors","rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700",y?"rst:bg-gray-50 rst:dark:bg-gray-700":"rst:text-gray-900 rst:dark:text-gray-100"),children:[r.jsx("span",{className:n.cn("rst:ml-3 rst:text-base rst:font-medium",y?"rst:text-primary-600 rst:dark:text-primary-400 rst:font-bold":"rst:text-gray-900 rst:dark:text-gray-100"),children:t.label}),t.badge&&r.jsx("span",{className:"rst:ml-2 rst:inline-flex",children:t.badge})]},t.path)})]})]})]})]}),(i||C||M)&&r.jsx("div",{className:"rst:py-6 rst:px-5 rst:space-y-4",children:C||(!i&&M?r.jsx(q.Button,{variant:"solid",colorScheme:"primary",className:"rst:w-full rst:justify-center",onClick:()=>{M(),c()},children:o.logIn}):r.jsxs(r.Fragment,{children:[N&&j&&r.jsx(q.Button,{variant:"ghost",colorScheme:"neutral",onClick:()=>{j?.(),c()},className:"rst:w-full rst:justify-between rst:px-4 rst:text-base rst:font-medium rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",endIcon:r.jsx(J.Badge,{fill:V,size:"xs",statusBadge:!0,variant:P,children:i?.notificationCount}),children:o.pendingInvitations}),v&&r.jsxs("div",{onClick:t=>{t.preventDefault(),v()},role:"switch","aria-checked":u,tabIndex:0,onKeyDown:t=>{t.repeat||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),v())},className:"rst:flex rst:w-full rst:items-center rst:justify-between rst:rounded-md rst:px-4 rst:py-2 rst:text-base rst:transition-colors rst:cursor-pointer rst:hover:bg-gray-50 rst:dark:hover:bg-gray-700 rst:text-gray-900 rst:dark:text-gray-100",children:[r.jsxs("div",{className:"rst:flex rst:items-center rst:gap-3 rst:font-medium",children:[r.jsx(f.FontAwesomeIcon,{icon:p.faMoon,className:n.cn("rst:w-5 rst:transition-colors",u?"rst:text-amber-500":"rst:text-gray-400")}),r.jsx("span",{children:o.darkMode})]}),r.jsx(T,{on:u,size:"sm"})]}),S&&r.jsx(q.Button,{variant:"outline",colorScheme:"error",className:"rst:w-full rst:justify-center",onClick:()=>{S?.(),c()},children:o.logOut})]}))})]})})})]})}})};exports.Navbar=br;