@setsquare/ui 0.2.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +132 -0
  2. package/NOTICE +1 -1
  3. package/README.md +17 -7
  4. package/dist/index.d.ts +11 -4
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +5 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/page-items.d.ts +10 -0
  9. package/dist/lib/page-items.d.ts.map +1 -0
  10. package/dist/lib/page-items.js +26 -0
  11. package/dist/lib/page-items.js.map +1 -0
  12. package/dist/lint/index.d.ts +5 -0
  13. package/dist/lint/index.d.ts.map +1 -1
  14. package/dist/lint/index.js +84 -3
  15. package/dist/lint/index.js.map +1 -1
  16. package/dist/shell/sidebar.d.ts +23 -0
  17. package/dist/shell/sidebar.d.ts.map +1 -1
  18. package/dist/shell/sidebar.js +22 -3
  19. package/dist/shell/sidebar.js.map +1 -1
  20. package/dist/styles/theme.css +550 -0
  21. package/dist/styles/tokens.css +17 -0
  22. package/dist/testing/index.d.ts +57 -2
  23. package/dist/testing/index.d.ts.map +1 -1
  24. package/dist/testing/index.js +276 -11
  25. package/dist/testing/index.js.map +1 -1
  26. package/dist/tokens.json +45 -0
  27. package/dist/ui/breadcrumbs.d.ts +9 -1
  28. package/dist/ui/breadcrumbs.d.ts.map +1 -1
  29. package/dist/ui/breadcrumbs.js +3 -3
  30. package/dist/ui/breadcrumbs.js.map +1 -1
  31. package/dist/ui/button-styles.d.ts.map +1 -1
  32. package/dist/ui/button-styles.js +16 -6
  33. package/dist/ui/button-styles.js.map +1 -1
  34. package/dist/ui/combo-box.d.ts +6 -1
  35. package/dist/ui/combo-box.d.ts.map +1 -1
  36. package/dist/ui/combo-box.js +2 -2
  37. package/dist/ui/combo-box.js.map +1 -1
  38. package/dist/ui/drop-indicator.d.ts +21 -0
  39. package/dist/ui/drop-indicator.d.ts.map +1 -0
  40. package/dist/ui/drop-indicator.js +20 -0
  41. package/dist/ui/drop-indicator.js.map +1 -0
  42. package/dist/ui/feature-card.d.ts.map +1 -1
  43. package/dist/ui/feature-card.js.map +1 -1
  44. package/dist/ui/grid-list.d.ts +10 -3
  45. package/dist/ui/grid-list.d.ts.map +1 -1
  46. package/dist/ui/grid-list.js +18 -7
  47. package/dist/ui/grid-list.js.map +1 -1
  48. package/dist/ui/pagination.d.ts +69 -14
  49. package/dist/ui/pagination.d.ts.map +1 -1
  50. package/dist/ui/pagination.js +177 -32
  51. package/dist/ui/pagination.js.map +1 -1
  52. package/dist/ui/switch.d.ts +2 -1
  53. package/dist/ui/switch.d.ts.map +1 -1
  54. package/dist/ui/switch.js +5 -2
  55. package/dist/ui/switch.js.map +1 -1
  56. package/dist/ui/tabs.d.ts +82 -15
  57. package/dist/ui/tabs.d.ts.map +1 -1
  58. package/dist/ui/tabs.js +274 -16
  59. package/dist/ui/tabs.js.map +1 -1
  60. package/dist/ui/time-of-day-icon.d.ts.map +1 -1
  61. package/dist/ui/time-of-day-icon.js.map +1 -1
  62. package/dist/ui/toolbar.d.ts +22 -0
  63. package/dist/ui/toolbar.d.ts.map +1 -0
  64. package/dist/ui/toolbar.js +22 -0
  65. package/dist/ui/toolbar.js.map +1 -0
  66. package/dist/ui/tree.d.ts +98 -0
  67. package/dist/ui/tree.d.ts.map +1 -0
  68. package/dist/ui/tree.js +75 -0
  69. package/dist/ui/tree.js.map +1 -0
  70. package/package.json +21 -25
  71. package/templates/next/page-transition.tsx +1 -1
@@ -7,8 +7,13 @@ export interface GridListProps<T extends object> extends Omit<RACGridListProps<T
7
7
  }
8
8
  /**
9
9
  * A list of items people act on — members, files, integrations — where each row can hold its own buttons.
10
- * Arrow keys move between rows, Tab reaches the buttons in a row. With `selectionMode="multiple"` every row
11
- * gets a SelectionCheckbox; Space or a click on the row toggles it. The list is `relative` because it scrolls.
10
+ * ↑ ↓ move between rows and → through a row's own controls; Tab leaves the list. With
11
+ * `selectionMode="multiple"` every row gets a SelectionCheckbox; Space or a click on the row toggles it. The list is `relative` because it scrolls,
12
+ * and because React Aria positions its drop indicators absolutely.
13
+ *
14
+ * Drag and drop: pass `dragAndDropHooks` from React Aria's `useDragAndDrop`, with
15
+ * `renderDropIndicator: (target) => <DropIndicator target={target} />`. Every draggable row then shows a drag
16
+ * button, which is how a keyboard or screen reader drag starts.
12
17
  */
13
18
  export declare function GridList<T extends object>({ className, ...props }: GridListProps<T>): import("react").JSX.Element;
14
19
  export interface GridListItemProps extends Omit<RACGridListItemProps, 'className' | 'children'> {
@@ -17,8 +22,10 @@ export interface GridListItemProps extends Omit<RACGridListItemProps, 'className
17
22
  description?: ReactNode;
18
23
  /** Buttons for this row only. Name them with the row ("Remove Priya Shah"). */
19
24
  actions?: ReactNode;
25
+ /** Words for the drag button, when the row can be dragged. React Aria's own ("Drag {name}") by default. */
26
+ dragLabel?: string;
20
27
  className?: string;
21
28
  }
22
29
  /** Selected: brand-subtle, the 3px sidebar-primary marker and a ticked box — the same signals as a table row. */
23
- export declare function GridListItem({ children, description, actions, className, ...props }: GridListItemProps): import("react").JSX.Element;
30
+ export declare function GridListItem({ children, description, actions, dragLabel, className, ...props }: GridListItemProps): import("react").JSX.Element;
24
31
  //# sourceMappingURL=grid-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid-list.d.ts","sourceRoot":"","sources":["../../src/ui/grid-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAGL,KAAK,iBAAiB,IAAI,oBAAoB,EAC9C,KAAK,aAAa,IAAI,gBAAgB,EACvC,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;IAC7F,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CA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AAC;IAC7F,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,2GAA2G;IAC3G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iHAAiH;AACjH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,+BAgDnB"}
@@ -1,21 +1,32 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { GridList as RACGridList, GridListItem as RACGridListItem, } from 'react-aria-components';
3
+ import { GripVertical } from 'lucide-react';
4
+ import { Button as RACButton, GridList as RACGridList, GridListItem as RACGridListItem, } from 'react-aria-components';
4
5
  import { cn } from '../lib/cn.js';
5
6
  import { SelectionCheckbox } from './checkbox.js';
6
7
  /**
7
8
  * A list of items people act on — members, files, integrations — where each row can hold its own buttons.
8
- * Arrow keys move between rows, Tab reaches the buttons in a row. With `selectionMode="multiple"` every row
9
- * gets a SelectionCheckbox; Space or a click on the row toggles it. The list is `relative` because it scrolls.
9
+ * ↑ ↓ move between rows and → through a row's own controls; Tab leaves the list. With
10
+ * `selectionMode="multiple"` every row gets a SelectionCheckbox; Space or a click on the row toggles it. The list is `relative` because it scrolls,
11
+ * and because React Aria positions its drop indicators absolutely.
12
+ *
13
+ * Drag and drop: pass `dragAndDropHooks` from React Aria's `useDragAndDrop`, with
14
+ * `renderDropIndicator: (target) => <DropIndicator target={target} />`. Every draggable row then shows a drag
15
+ * button, which is how a keyboard or screen reader drag starts.
10
16
  */
11
17
  export function GridList({ className, ...props }) {
12
- return (_jsx(RACGridList, { ...props, className: cn('relative flex max-h-[inherit] flex-col overflow-auto rounded-lg border border-border bg-card text-sm outline-none data-focus-visible:focus-ring', className) }));
18
+ return (_jsx(RACGridList, { ...props, className: cn('relative flex max-h-[inherit] flex-col overflow-auto rounded-lg border border-border bg-card text-sm outline-none data-focus-visible:focus-ring', 'data-drop-target:bg-brand-subtle data-drop-target:outline-2 data-drop-target:outline-solid data-drop-target:outline-brand data-drop-target:-outline-offset-2', className) }));
13
19
  }
14
20
  /** Selected: brand-subtle, the 3px sidebar-primary marker and a ticked box — the same signals as a table row. */
15
- export function GridListItem({ children, description, actions, className, ...props }) {
21
+ export function GridListItem({ children, description, actions, dragLabel, className, ...props }) {
16
22
  const textValue = props.textValue ?? (typeof children === 'string' ? children : undefined);
17
- return (_jsx(RACGridListItem, { ...props, textValue: textValue, className: cn(
23
+ return (_jsx(RACGridListItem, { ...props, textValue: textValue, className: ({ allowsDragging }) => cn(
18
24
  // React Aria sets data-hovered only on a row that can be selected or has an action: the pointer then.
19
- 'group/item relative flex min-h-[calc(var(--control-height)+12px)] cursor-default items-center gap-3 border-b border-border px-3 py-1.5 outline-none last:border-b-0', 'data-hovered:cursor-pointer data-disabled:cursor-not-allowed data-hovered:bg-accent data-selected:bg-brand-subtle data-selected:shadow-[inset_3px_0_0_var(--sidebar-primary)] data-focus-visible:focus-ring-inset data-disabled:opacity-60', className), children: ({ selectionMode, selectionBehavior }) => (_jsxs(_Fragment, { children: [selectionMode !== 'none' && selectionBehavior === 'toggle' && (_jsx(SelectionCheckbox, { className: "-ml-1" })), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "leading-5 font-medium text-foreground", children: children }), description && (_jsx("span", { className: "text-[13px] leading-5 text-muted-foreground", children: description }))] }), actions && _jsx("span", { className: "flex shrink-0 items-center gap-1", children: actions })] })) }));
25
+ 'group/item relative flex min-h-[calc(var(--control-height)+12px)] cursor-default items-center gap-3 border-b border-border py-1.5 pe-3 outline-none last:border-b-0',
26
+ // A draggable row starts with its drag button, whose target is wider than its paint: the row gives it
27
+ // the start padding rather than the button reaching into it.
28
+ allowsDragging ? 'ps-1' : 'ps-3', 'data-hovered:cursor-pointer data-disabled:cursor-not-allowed data-hovered:bg-accent data-selected:bg-brand-subtle data-selected:shadow-[inset_3px_0_0_var(--sidebar-primary)] data-focus-visible:focus-ring-inset data-disabled:opacity-60', 'data-dragging:opacity-50 data-drop-target:bg-brand-subtle data-drop-target:outline-2 data-drop-target:outline-solid data-drop-target:outline-brand data-drop-target:-outline-offset-2',
29
+ // Forced colours drop the selected ground and the inset marker: draw the marker in Highlight instead.
30
+ "forced-colors:data-selected:before:absolute forced-colors:data-selected:before:inset-y-1 forced-colors:data-selected:before:start-0 forced-colors:data-selected:before:w-[3px] forced-colors:data-selected:before:bg-[Highlight] forced-colors:data-selected:before:forced-color-adjust-none forced-colors:data-selected:before:content-['']", className), children: ({ selectionMode, selectionBehavior, allowsDragging }) => (_jsxs(_Fragment, { children: [allowsDragging && (_jsx(RACButton, { slot: "drag", "aria-label": dragLabel, className: "group/grid-drag relative flex min-h-target min-w-target shrink-0 cursor-grab items-center justify-center outline-none", children: _jsx("span", { className: "flex size-control-sm items-center justify-center rounded-md text-muted-foreground group-data-focus-visible/grid-drag:focus-ring group-data-hovered/grid-drag:bg-muted group-data-hovered/grid-drag:text-foreground", children: _jsx(GripVertical, { "aria-hidden": "true", className: "size-4" }) }) })), selectionMode !== 'none' && selectionBehavior === 'toggle' && (_jsx(SelectionCheckbox, { className: "-ml-1" })), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "leading-5 font-medium text-foreground", children: children }), description && (_jsx("span", { className: "text-[13px] leading-5 text-muted-foreground", children: description }))] }), actions && _jsx("span", { className: "flex shrink-0 items-center gap-1", children: actions })] })) }));
20
31
  }
21
32
  //# sourceMappingURL=grid-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid-list.js","sourceRoot":"","sources":["../../src/ui/grid-list.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EACL,QAAQ,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AAE,EAAE,CAAC,CACzD,8BACG,cAAc,IAAI,CACjB,KAAC,SAAS,IACR,IAAI,EAAC,MAAM,gBACC,SAAS,EACrB,SAAS,EAAC,uHAAuH,YAEjI,eAAM,SAAS,EAAC,oNAAoN,YAClO,KAAC,YAAY,mBAAa,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,GACjD,GACG,CACb,EACA,aAAa,KAAK,MAAM,IAAI,iBAAiB,KAAK,QAAQ,IAAI,CAC7D,KAAC,iBAAiB,IAAC,SAAS,EAAC,OAAO,GAAG,CACxC,EACD,gBAAM,SAAS,EAAC,8BAA8B,aAC5C,eAAM,SAAS,EAAC,uCAAuC,YAAE,QAAQ,GAAQ,EACxE,WAAW,IAAI,CACd,eAAM,SAAS,EAAC,6CAA6C,YAAE,WAAW,GAAQ,CACnF,IACI,EACN,OAAO,IAAI,eAAM,SAAS,EAAC,kCAAkC,YAAE,OAAO,GAAQ,IAC9E,CACJ,GACe,CACnB,CAAC;AACJ,CAAC"}
@@ -1,30 +1,85 @@
1
- /** Pagination's words, for the `labels` prop. `{page}` is a page number. */
1
+ /** Pagination's words, for the `labels` prop. `{noun}` is what the list holds, from `labels.noun`. */
2
2
  export interface PaginationLabels {
3
3
  /** Names the navigation landmark. */
4
4
  pagination: string;
5
+ /** What the list holds: "projects". */
6
+ noun: string;
7
+ /** The range, in bold: "21–30 of 212". What sits between `{from}` and `{to}` is shown, and read as `rangeTo`. */
8
+ range: string;
9
+ /** Read in place of the dash between the two figures: " to ". */
10
+ rangeTo: string;
11
+ /** The range of an empty list. */
12
+ empty: string;
13
+ rowsPerPage: string;
14
+ /** A page link's name around its number, which is all it shows: "Page {page} of {noun}". */
15
+ page: string;
5
16
  previous: string;
6
17
  next: string;
7
- /** A page link's name around its number, which is all it shows: "Page {page}". */
8
- page: string;
18
+ /** The page field's label, above 20 pages. */
19
+ field: string;
20
+ /** After the field: "of {last}". */
21
+ of: string;
22
+ go: string;
23
+ outOfRange: string;
24
+ /** Said once a page has taken longer than `--duration-loading-delay` to arrive. */
25
+ loading: string;
26
+ errorPrefix: string;
9
27
  }
10
- export interface PaginationProps {
11
- /** The current page, from 1. */
12
- page: number;
13
- pageCount: number;
28
+ /**
29
+ * A Laravel API Resource collection's `meta`. Only these fields are read; `links` and `path` point at the API,
30
+ * not at the page people are on, so they are never used.
31
+ */
32
+ export interface PaginationMeta {
33
+ current_page: number;
34
+ from: number | null;
35
+ last_page: number;
36
+ per_page: number;
37
+ to: number | null;
38
+ total: number;
39
+ }
40
+ interface PaginationBase {
14
41
  /**
15
42
  * Where a page is: a function, or a string with `{page}` in it ("/projects?page={page}&sort=name"), which a
16
- * server component can pass where it can't pass a function.
43
+ * server component can pass where it can't pass a function. Keep the rest of the query (sort, filters,
44
+ * `per_page`) in it.
17
45
  */
18
46
  href: string | ((page: number) => string);
47
+ /** The query parameter the page number goes in, for the page field's form. Default `page`. */
48
+ pageParam?: string;
49
+ /** Above this many pages the numbers give way to a "Page [n] of N" field. Default 20. */
50
+ fieldAbove?: number;
19
51
  labels?: Partial<PaginationLabels>;
20
52
  className?: string;
21
53
  }
54
+ export type PaginationProps = PaginationBase & ({
55
+ /** The list's meta: the range, rows per page and the pages all come from it. */
56
+ meta: PaginationMeta;
57
+ /**
58
+ * Rows per page, which the product applies in place: re-fetch with the new size and give back the new
59
+ * meta. `page` is the page that holds the first row being looked at, so it stays in view. Without it
60
+ * there's no Rows per page.
61
+ */
62
+ onPerPageChange?: (perPage: number, page: number) => void;
63
+ /** Default 10, 25, 50. */
64
+ perPageOptions?: number[];
65
+ page?: never;
66
+ pageCount?: never;
67
+ } | {
68
+ /** The current page, from 1. */
69
+ page: number;
70
+ pageCount: number;
71
+ meta?: never;
72
+ onPerPageChange?: never;
73
+ perPageOptions?: never;
74
+ });
22
75
  /**
23
- * Links to the pages of a long list: Previous, the first and last pages, the ones either side of the current one,
24
- * and Next. Every page is a link, so it works with JavaScript off and goes through your router's
25
- * `RouterProvider` when it is on. The current page is marked `aria-current="page"` and painted as the primary
26
- * button: fill and weight, not colour alone. Previous and Next are left out at the ends rather than disabled.
27
- * Nothing renders for a single page.
76
+ * The footer of a long list: Rows per page, the range ("21–30 of 212 projects") and the pages. Up to 20 pages
77
+ * it shows numbers, seven slots at most, so the row never changes length; above that, a "Page [n] of N" field.
78
+ * Every page is a link, so it works with JavaScript off, and goes through your router's `RouterProvider` when it
79
+ * is on; the field is a GET form that keeps the rest of the query. The current page is `aria-current="page"`,
80
+ * painted as the primary button: fill and weight, not colour alone. Previous and Next are left out at the ends,
81
+ * with their place kept.
28
82
  */
29
- export declare function Pagination({ page, pageCount, href, labels: given, className }: PaginationProps): import("react").JSX.Element | null;
83
+ export declare function Pagination(props: PaginationProps): import("react").JSX.Element | null;
84
+ export {};
30
85
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/ui/pagination.tsx"],"names":[],"mappings":"AAQA,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;CACd;AASD,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,eAAe,sCA4C9F"}
1
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AS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAC1C,CACI;IACE,gFAAgF;IAChF,IAAI,EAAE,cAAc,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,CACJ,CAAC;AAOJ;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,sCA+LhD"}
@@ -1,48 +1,193 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Link } from 'react-aria-components';
4
- import { ChevronLeft, ChevronRight } from 'lucide-react';
3
+ import { useEffect, useId, useLayoutEffect, useRef, useState, } from 'react';
4
+ import { Link, useLocale } from 'react-aria-components';
5
+ import { ChevronLeft, ChevronRight, CircleAlert } from 'lucide-react';
5
6
  import { cn } from '../lib/cn.js';
6
7
  import { fill, withLabels } from '../lib/labels.js';
8
+ import { pageItems } from '../lib/page-items.js';
9
+ import { Button } from './button.js';
10
+ import { Option } from './list-box.js';
11
+ import { Select } from './select.js';
7
12
  const paginationLabels = {
8
13
  pagination: 'Pagination',
9
- previous: 'Previous',
10
- next: 'Next',
11
- page: 'Page {page}',
14
+ noun: 'results',
15
+ range: '{from}–{to} of {total}',
16
+ rangeTo: ' to ',
17
+ empty: 'No {noun}',
18
+ rowsPerPage: 'Rows per page',
19
+ page: 'Page {page} of {noun}',
20
+ previous: 'Previous page of {noun}',
21
+ next: 'Next page of {noun}',
22
+ field: 'Page',
23
+ of: 'of {last}',
24
+ go: 'Go',
25
+ outOfRange: 'Enter a page from 1 to {last}',
26
+ loading: 'Loading page {page}…',
27
+ errorPrefix: 'Error: ',
12
28
  };
13
- /** First, last, and the pages either side of the current one, with a gap where pages are left out. */
14
- function pageWindow(current, last) {
15
- const pages = [...new Set([1, last, current - 1, current, current + 1])]
16
- .filter((n) => n >= 1 && n <= last)
17
- .toSorted((a, b) => a - b);
18
- const out = [];
19
- let previous = 0;
20
- for (const n of pages) {
21
- if (n - previous > 1)
22
- out.push({ key: `gap-${previous}-${n}`, gap: true });
23
- out.push({ key: `page-${n}`, page: n });
24
- previous = n;
25
- }
26
- return out;
27
- }
29
+ /** An arrow's place, the same with the arrow or without, so the row keeps its length at the ends. */
30
+ const arrowSlot = 'flex w-[max(var(--target-min),var(--control-height))] min-h-target';
28
31
  /**
29
- * Links to the pages of a long list: Previous, the first and last pages, the ones either side of the current one,
30
- * and Next. Every page is a link, so it works with JavaScript off and goes through your router's
31
- * `RouterProvider` when it is on. The current page is marked `aria-current="page"` and painted as the primary
32
- * button: fill and weight, not colour alone. Previous and Next are left out at the ends rather than disabled.
33
- * Nothing renders for a single page.
32
+ * The footer of a long list: Rows per page, the range ("21–30 of 212 projects") and the pages. Up to 20 pages
33
+ * it shows numbers, seven slots at most, so the row never changes length; above that, a "Page [n] of N" field.
34
+ * Every page is a link, so it works with JavaScript off, and goes through your router's `RouterProvider` when it
35
+ * is on; the field is a GET form that keeps the rest of the query. The current page is `aria-current="page"`,
36
+ * painted as the primary button: fill and weight, not colour alone. Previous and Next are left out at the ends,
37
+ * with their place kept.
34
38
  */
35
- export function Pagination({ page, pageCount, href, labels: given, className }) {
36
- if (pageCount <= 1)
37
- return null;
39
+ export function Pagination(props) {
40
+ const { href, pageParam = 'page', fieldAbove = 20, labels: given, className } = props;
41
+ const meta = props.meta;
42
+ const current = meta ? meta.current_page : props.page;
43
+ const last = Math.max(1, meta ? meta.last_page : props.pageCount);
38
44
  const labels = withLabels(paginationLabels, given);
45
+ const noun = labels.noun;
46
+ const { locale } = useLocale();
47
+ const format = (n) => new Intl.NumberFormat(locale).format(n);
39
48
  const to = (n) => (typeof href === 'function' ? href(n) : fill(href, { page: n }));
40
- // A page link shows its number; the words around it ("Page …") are for its name, which keeps the number (2.5.3).
49
+ // Which way the last change went, for the range's figures and the current page.
50
+ const [seen, setSeen] = useState({
51
+ page: current,
52
+ per: meta?.per_page,
53
+ moved: false,
54
+ forward: true,
55
+ });
56
+ if (seen.page !== current || seen.per !== meta?.per_page) {
57
+ setSeen({
58
+ page: current,
59
+ per: meta?.per_page,
60
+ moved: true,
61
+ forward: seen.page !== current ? current > seen.page : (meta?.per_page ?? 0) > (seen.per ?? 0),
62
+ });
63
+ }
64
+ // Pending: the control you used, from the moment it's pressed until the page changes.
65
+ const [pending, setPending] = useState(null);
66
+ const [sayingFor, setSayingFor] = useState(null);
67
+ const saying = !!pending && sayingFor === pending;
68
+ if (pending && pending.from !== current)
69
+ setPending(null);
70
+ useEffect(() => {
71
+ if (!pending)
72
+ return;
73
+ // The message waits as long as the mark does (--duration-loading-delay), so a fast page says nothing.
74
+ const delay = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--duration-loading-delay')) || 400;
75
+ const timer = setTimeout(() => setSayingFor(pending), delay);
76
+ return () => clearTimeout(timer);
77
+ }, [pending]);
78
+ // Focus after paging: Previous and Next keep it unless they've gone at an end; a page number moves it to the
79
+ // new current page; the field keeps it.
80
+ const intent = useRef(null);
81
+ const currentRef = useRef(null);
82
+ const fieldRef = useRef(null);
83
+ useLayoutEffect(() => {
84
+ const kind = intent.current;
85
+ intent.current = null;
86
+ if (!kind)
87
+ return;
88
+ const gone = (kind === 'prev' && current === 1) || (kind === 'next' && current === last);
89
+ if (kind === 'field')
90
+ fieldRef.current?.focus();
91
+ else if (kind === 'num' || gone)
92
+ (currentRef.current ?? fieldRef.current)?.focus();
93
+ }, [current, last]);
94
+ const press = (kind, page) => (e) => {
95
+ // A new tab or window leaves this page as it is.
96
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
97
+ return;
98
+ intent.current = kind;
99
+ setPending({ kind, page, from: current });
100
+ };
101
+ const fieldId = useId();
102
+ const [error, setError] = useState('');
103
+ const [errorPage, setErrorPage] = useState(current);
104
+ if (errorPage !== current) {
105
+ setErrorPage(current);
106
+ setError('');
107
+ }
108
+ const showSelect = !!meta && !!props.onPerPageChange;
109
+ const options = (meta && props.perPageOptions) || [10, 25, 50];
110
+ if (!meta && last <= 1)
111
+ return null;
112
+ const range = meta && (_jsx(Range, { meta: meta, labels: labels, format: format, moved: seen.moved, forward: seen.forward }));
113
+ return (_jsxs("div", { className: cn('@container/pagination relative w-full', className), children: [_jsxs("div", { className: "flex flex-wrap items-end justify-between gap-x-6 gap-y-3 @max-[560px]/pagination:flex-col @max-[560px]/pagination:items-stretch", children: [showSelect && (meta.total > Math.min(...options) || meta.last_page > 1) && (_jsx(Select, { label: labels.rowsPerPage, width: "xs", selectedKey: String(meta.per_page), onSelectionChange: (key) => {
114
+ const per = Number(key);
115
+ if (!per || per === meta.per_page)
116
+ return;
117
+ props.onPerPageChange?.(per, meta.from ? Math.floor((meta.from - 1) / per) + 1 : 1);
118
+ }, children: options.map((n) => (_jsx(Option, { id: String(n), children: format(n) }, n))) })), range && _jsx("div", { className: "flex min-h-control-target items-center", children: range }), last > 1 && (_jsxs("nav", { "aria-label": labels.pagination, "aria-busy": pending ? true : undefined, "data-moved": seen.moved ? '' : undefined, className: "relative min-w-0 @max-[560px]/pagination:self-start", style: { '--pagination-slot': `calc(${String(last).length}ch + 16px)` }, children: [_jsx("span", { role: "status", className: "sr-only", children: pending && saying ? fill(labels.loading, { page: format(pending.page) }) : '' }), _jsxs("div", { className: "flex items-center gap-1", children: [current > 1 ? (_jsx(Arrow, { href: to(current - 1), rel: "prev", label: fill(labels.previous, { noun }), pending: pending?.kind === 'prev', onPress: press('prev', current - 1) })) : (_jsx("span", { "aria-hidden": "true", className: arrowSlot })), last <= fieldAbove ? (_jsx(Numbers, { current: current, last: last, to: to, labels: labels, format: format, pending: pending, press: press, currentRef: currentRef })) : (_jsx(PageField, { id: fieldId, error: error, setError: setError, current: current, last: last, to: to, pageParam: pageParam, labels: labels, format: format, fieldRef: fieldRef, pending: pending?.kind === 'field', onGo: (n) => {
119
+ intent.current = 'field';
120
+ setPending({ kind: 'field', page: n, from: current });
121
+ } })), current < last ? (_jsx(Arrow, { href: to(current + 1), rel: "next", label: fill(labels.next, { noun }), pending: pending?.kind === 'next', onPress: press('next', current + 1) })) : (_jsx("span", { "aria-hidden": "true", className: arrowSlot }))] })] }))] }), last > fieldAbove && (_jsx("div", { role: "alert", id: `${fieldId}-error`, children: error && (_jsxs("p", { className: "mt-2 flex items-center gap-1.5 text-[13px] leading-5 font-semibold text-destructive", children: [_jsx(CircleAlert, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsxs("span", { children: [_jsx("span", { className: "sr-only", children: labels.errorPrefix }), error] })] })) }))] }));
122
+ }
123
+ /** "21–30 of 212 projects": the figures bold, the noun muted, and the dash read as "to". */
124
+ function Range({ meta, labels, format, moved, forward, }) {
125
+ if (!meta.total || meta.from == null || meta.to == null)
126
+ return (_jsx("p", { role: "status", className: "text-sm text-muted-foreground", children: fill(labels.empty, { noun: labels.noun }) }));
127
+ const match = /^(.*?)\{from\}(.*?)\{to\}(.*)$/.exec(labels.range);
128
+ const [, before = '', between = '', after = ''] = match ?? ['', '', '', labels.range];
129
+ const values = { total: format(meta.total), from: format(meta.from), to: format(meta.to) };
130
+ return (_jsxs("p", { role: "status", className: "text-sm text-muted-foreground tabular-nums", children: [_jsxs("span", { "data-direction": moved ? (forward ? 'forward' : 'back') : undefined, className: "pagination-roll font-semibold text-foreground", children: [fill(before, values), values.from, _jsx("span", { "aria-hidden": "true", children: between }), _jsx("span", { className: "sr-only", children: labels.rangeTo }), values.to, fill(after, values)] }, `${meta.from}-${meta.to}-${meta.total}`), ' ', labels.noun] }));
131
+ }
132
+ function Numbers({ current, last, to, labels, format, pending, press, currentRef, }) {
133
+ // A page link shows its number; the words around it are for its name, which keeps the number (2.5.3).
41
134
  const [before, after = ''] = labels.page.split('{page}');
42
- return (_jsx("nav", { "aria-label": labels.pagination, className: cn('min-w-0', className), children: _jsxs("ul", { role: "list", className: "flex flex-wrap items-center gap-1", children: [page > 1 && (_jsx("li", { children: _jsxs(PageLink, { href: to(page - 1), rel: "prev", children: [_jsx(ChevronLeft, { "aria-hidden": "true", className: "size-4" }), labels.previous] }) })), pageWindow(page, pageCount).map((entry) => 'gap' in entry ? (_jsx("li", { "aria-hidden": "true", className: "px-1 text-sm text-muted-foreground", children: "\u2026" }, entry.key)) : (_jsx("li", { children: _jsxs(PageLink, { href: to(entry.page), isCurrent: entry.page === page, children: [before && _jsx("span", { className: "sr-only", children: before }), entry.page, after && _jsx("span", { className: "sr-only", children: after })] }) }, entry.key))), page < pageCount && (_jsx("li", { children: _jsxs(PageLink, { href: to(page + 1), rel: "next", children: [labels.next, _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4" })] }) }))] }) }));
135
+ return (_jsx("ul", { role: "list", className: "flex min-w-0 flex-wrap gap-1", children: pageItems(current, last).map((item) => (_jsx("li", { className: "flex w-[max(var(--target-min),var(--control-height),var(--pagination-slot))] justify-center", children: typeof item === 'number' ? (_jsxs(PageLink, { href: to(item), isCurrent: item === current, pending: pending?.kind === 'num' && pending.page === item, onPress: press('num', item), ref: item === current ? currentRef : undefined, children: [before && _jsx("span", { className: "sr-only", children: fill(before, { noun: labels.noun }) }), format(item), after && _jsx("span", { className: "sr-only", children: fill(after, { noun: labels.noun }) })] })) : (_jsx("span", { "aria-hidden": "true", className: "inline-flex h-control w-full items-center justify-center text-sm tracking-[1px] text-muted-foreground", children: "\u2026" })) }, typeof item === 'number' ? `page-${item}` : item))) }));
136
+ }
137
+ /** "Page [n] of N", a GET form that keeps the rest of the query. With JavaScript it goes through the router. */
138
+ function PageField({ id, error, setError, current, last, to, pageParam, labels, format, fieldRef, pending, onGo, }) {
139
+ const [value, setValue] = useState(String(current));
140
+ // A new page shows its own number; the field itself stays, so focus stays in it.
141
+ const [shown, setShown] = useState(current);
142
+ if (shown !== current) {
143
+ setShown(current);
144
+ setValue(String(current));
145
+ }
146
+ const [target, setTarget] = useState(null);
147
+ const link = useRef(null);
148
+ // Where the form goes without JavaScript: the page's own path, with the rest of its query as hidden fields.
149
+ const url = new URL(to(1), 'http://pagination.invalid');
150
+ const action = /^[a-z][a-z\d+.-]*:/i.test(to(1)) ? url.origin + url.pathname : url.pathname;
151
+ const hidden = [...url.searchParams].filter(([name]) => name !== pageParam);
152
+ const changed = value.trim() !== '' && value.trim() !== String(current);
153
+ const digits = Math.max(2, String(last).length);
154
+ // Navigate through the same link machinery as the page links, so a RouterProvider handles it.
155
+ useEffect(() => {
156
+ if (target != null)
157
+ link.current?.click();
158
+ }, [target]);
159
+ const submit = (e) => {
160
+ e.preventDefault();
161
+ const raw = value.trim();
162
+ const n = /^\d+$/.test(raw) ? Number(raw) : NaN;
163
+ if (!(n >= 1 && n <= last)) {
164
+ setError(fill(labels.outOfRange, { last: format(last) }));
165
+ return;
166
+ }
167
+ if (n === current)
168
+ return;
169
+ onGo(n);
170
+ setTarget(n);
171
+ };
172
+ return (_jsxs("form", { action: action, method: "get", noValidate: true, onSubmit: submit, className: "mx-1 inline-flex min-w-0 flex-wrap items-center gap-2", children: [hidden.map(([name, v]) => (_jsx("input", { type: "hidden", name: name, value: v }, name))), _jsx("label", { htmlFor: id, className: "text-sm font-semibold text-foreground", children: labels.field }), _jsx("div", { "data-invalid": error ? '' : undefined, className: cn('field-paint flex has-[input:focus]:before:focus-ring data-invalid:before:border-destructive data-invalid:before:shadow-[inset_0_0_0_1px_var(--destructive)]', pending && 'pagination-field-pending'), children: _jsx("input", { ref: fieldRef, id: id, name: pageParam, inputMode: "numeric", autoComplete: "off", value: value, "aria-invalid": error ? true : undefined, "aria-describedby": `${id}-of ${id}-error`, onChange: (e) => {
173
+ setValue(e.target.value);
174
+ setError('');
175
+ }, onKeyDown: (e) => {
176
+ if (e.key !== 'Escape' || value === String(current))
177
+ return;
178
+ e.preventDefault();
179
+ setValue(String(current));
180
+ setError('');
181
+ }, style: { width: `calc(${digits + 1}ch + 2 * var(--control-pad-x) + 2px)` }, className: "field-input cursor-text px-(--control-pad-x) text-center text-sm font-bold text-foreground tabular-nums" }) }), _jsx("span", { id: `${id}-of`, className: "text-sm whitespace-nowrap text-muted-foreground tabular-nums", children: fill(labels.of, { last: format(last) }) }), changed && (_jsx("span", { className: "pagination-go inline-flex", children: _jsx(Button, { type: "submit", isPending: pending, children: labels.go }) })), target != null && (_jsx("span", { hidden: true, children: _jsx(Link, { ref: link, href: to(target), children: format(target) }) }))] }));
43
182
  }
44
183
  /** Three layers: the link is the target, at least --target-min both ways; the painted box carries hover, focus and current. */
45
- function PageLink({ href, rel, isCurrent, children, }) {
46
- return (_jsx(Link, { href: href, rel: rel, "aria-current": isCurrent ? 'page' : undefined, className: "group/page relative inline-flex min-h-target min-w-target cursor-pointer items-center justify-center no-underline outline-none", children: _jsx("span", { className: cn('inline-flex h-control min-w-control items-center justify-center gap-1 rounded-md px-2 text-sm font-medium text-foreground tabular-nums', 'group-data-hovered/page:bg-accent group-data-focus-visible/page:focus-ring', 'group-aria-[current=page]/page:bg-primary group-aria-[current=page]/page:font-bold group-aria-[current=page]/page:text-primary-foreground'), children: children }) }));
184
+ function PageLink({ href, rel, isCurrent, pending, onPress, ref, label, className, children, }) {
185
+ return (_jsx(Link, { ref: ref, href: href, rel: rel, "aria-current": isCurrent ? 'page' : undefined, "aria-label": label, "data-pending": pending ? '' : undefined, onPress: onPress, className: cn('group/page relative inline-flex min-h-target w-full min-w-target cursor-pointer items-center justify-center no-underline outline-none data-pending:cursor-wait', className), children: _jsx("span", { className: "pagination-paint group-data-focus-visible/page:focus-ring", children: children }) }));
186
+ }
187
+ function Arrow({ href, rel, label, pending, onPress, }) {
188
+ const Icon = rel === 'prev' ? ChevronLeft : ChevronRight;
189
+ return (_jsxs(PageLink, { href: href, rel: rel, pending: pending, onPress: onPress, className: arrowSlot, children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 transition-transform duration-(--duration-fast) motion-reduce:transition-none aaa:translate-x-0!', rel === 'prev'
190
+ ? 'group-data-hovered/page:-translate-x-0.5'
191
+ : 'group-data-hovered/page:translate-x-0.5') }), _jsx("span", { className: "sr-only", children: label })] }));
47
192
  }
48
193
  //# sourceMappingURL=pagination.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/ui/pagination.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYpD,MAAM,gBAAgB,GAAqB;IACzC,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,aAAa;CACpB,CAAC;AAiBF,sGAAsG;AACtG,SAAS,UAAU,CAAC,OAAe,EAAE,IAAY;IAC/C,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACrE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;SAClC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAA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, 'className' | 'childre
7
7
  }
8
8
  /**
9
9
  * On/off that takes effect immediately — confirm the change with a status message. Inside a form that is
10
- * submitted later, use a Checkbox. On: the thumb moves right and the track fills, never colour alone.
10
+ * submitted later, use a Checkbox. On: the thumb moves right and the track fills, never colour alone. In forced
11
+ * colours the track and thumb are drawn in the system's colours (Canvas and CanvasText, Highlight when on).
11
12
  */
12
13
  export declare function Switch({ children, description, className, ...props }: SwitchProps): import("react").JSX.Element;
13
14
  //# sourceMappingURL=switch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAuB,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGhG,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,UAAU,CAAC;IACjF,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BA+BjF"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAuB,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGhG,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,UAAU,CAAC;IACjF,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BAkCjF"}
package/dist/ui/switch.js CHANGED
@@ -4,9 +4,12 @@ import { Switch as RACSwitch } from 'react-aria-components';
4
4
  import { cn } from '../lib/cn.js';
5
5
  /**
6
6
  * On/off that takes effect immediately — confirm the change with a status message. Inside a form that is
7
- * submitted later, use a Checkbox. On: the thumb moves right and the track fills, never colour alone.
7
+ * submitted later, use a Checkbox. On: the thumb moves right and the track fills, never colour alone. In forced
8
+ * colours the track and thumb are drawn in the system's colours (Canvas and CanvasText, Highlight when on).
8
9
  */
9
10
  export function Switch({ children, description, className, ...props }) {
10
- return (_jsxs(RACSwitch, { ...props, className: cn('group/choice relative flex min-h-target cursor-pointer items-start gap-3 py-[calc((var(--target-min)-var(--choice-size))/2)] text-sm leading-5 text-foreground outline-none data-disabled:cursor-not-allowed data-disabled:opacity-60 data-readonly:cursor-default', className), children: [_jsx("span", { "aria-hidden": "true", className: cn('relative mt-[calc((20px-var(--choice-size))/2)] h-choice w-[calc(var(--choice-size)*1.8)] shrink-0 rounded-full border border-input bg-muted transition-colors duration-(--duration-fast)', 'group-data-focus-visible/choice:focus-ring group-data-selected/choice:border-primary group-data-selected/choice:bg-primary'), children: _jsx("span", { className: cn('absolute top-1/2 left-[2px] size-[calc(var(--choice-size)-6px)] -translate-y-1/2 rounded-full bg-muted-foreground', 'transition-[left] duration-(--duration-fast) motion-reduce:transition-none aaa:transition-none', 'group-data-selected/choice:left-[calc(100%-var(--choice-size)+4px)] group-data-selected/choice:bg-primary-foreground') }) }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { children: children }), description && _jsx("span", { className: "text-[13px] text-muted-foreground", children: description })] })] }));
11
+ return (_jsxs(RACSwitch, { ...props, className: cn('group/choice relative flex min-h-target cursor-pointer items-start gap-3 py-[calc((var(--target-min)-var(--choice-size))/2)] text-sm leading-5 text-foreground outline-none data-disabled:cursor-not-allowed data-disabled:opacity-60 data-readonly:cursor-default', className), children: [_jsx("span", { "aria-hidden": "true", className: cn('relative mt-[calc((20px-var(--choice-size))/2)] h-choice w-[calc(var(--choice-size)*1.8)] shrink-0 rounded-full border border-input bg-muted transition-colors duration-(--duration-fast)', 'group-data-focus-visible/choice:focus-ring group-data-selected/choice:border-primary group-data-selected/choice:bg-primary',
12
+ // Forced colours drop backgrounds, and with them the thumb: the system's colours, kept, draw it instead.
13
+ 'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:forced-color-adjust-none forced-colors:group-data-selected/choice:border-[Highlight] forced-colors:group-data-selected/choice:bg-[Highlight]'), children: _jsx("span", { className: cn('absolute top-1/2 left-[2px] size-[calc(var(--choice-size)-6px)] -translate-y-1/2 rounded-full bg-muted-foreground', 'transition-[left] duration-(--duration-fast) motion-reduce:transition-none aaa:transition-none', 'group-data-selected/choice:left-[calc(100%-var(--choice-size)+4px)] group-data-selected/choice:bg-primary-foreground', 'forced-colors:bg-[CanvasText] forced-colors:group-data-selected/choice:bg-[HighlightText]') }) }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { children: children }), description && _jsx("span", { className: "text-[13px] text-muted-foreground", children: description })] })] }));
11
14
  }
12
15
  //# sourceMappingURL=switch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,MAAM,IAAI,SAAS,EAAsC,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAQlC;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAe;IAChF,OAAO,CAEL,MAAC,SAAS,OACJ,KAAK,EACT,SAAS,EAAE,EAAE,CACX,oQAAoQ,EACpQ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