@c9up/nebula 0.1.9 → 0.2.1

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 (132) hide show
  1. package/dist/atoms/Avatar.d.ts +36 -9
  2. package/dist/atoms/Avatar.js +66 -27
  3. package/dist/atoms/index.d.ts +1 -1
  4. package/dist/atoms/index.js +1 -1
  5. package/dist/configure.d.ts +6 -0
  6. package/dist/configure.js +4 -22
  7. package/dist/lib/children.d.ts +30 -0
  8. package/dist/lib/id.d.ts +13 -29
  9. package/dist/lib/id.js +13 -39
  10. package/dist/lib/motion.d.ts +10 -0
  11. package/dist/lib/motion.js +10 -0
  12. package/dist/molecules/Accordion.d.ts +36 -15
  13. package/dist/molecules/Accordion.js +68 -45
  14. package/dist/molecules/Breadcrumb.d.ts +29 -11
  15. package/dist/molecules/Breadcrumb.js +52 -52
  16. package/dist/molecules/Collapsible.d.ts +18 -17
  17. package/dist/molecules/Collapsible.js +42 -34
  18. package/dist/molecules/Field.d.ts +66 -30
  19. package/dist/molecules/Field.js +106 -55
  20. package/dist/molecules/InputGroup.d.ts +39 -21
  21. package/dist/molecules/InputGroup.js +43 -27
  22. package/dist/molecules/InputOTP.d.ts +26 -3
  23. package/dist/molecules/InputOTP.js +109 -76
  24. package/dist/molecules/Message.js +5 -4
  25. package/dist/molecules/Pagination.d.ts +36 -11
  26. package/dist/molecules/Pagination.js +58 -74
  27. package/dist/molecules/RadioGroup.d.ts +25 -17
  28. package/dist/molecules/RadioGroup.js +47 -43
  29. package/dist/molecules/Resizable.d.ts +32 -7
  30. package/dist/molecules/Resizable.js +76 -49
  31. package/dist/molecules/Tabs.d.ts +49 -11
  32. package/dist/molecules/Tabs.js +107 -51
  33. package/dist/molecules/ToggleGroup.d.ts +16 -10
  34. package/dist/molecules/ToggleGroup.js +37 -21
  35. package/dist/molecules/index.d.ts +11 -11
  36. package/dist/molecules/index.js +11 -11
  37. package/dist/organisms/AlertDialog.d.ts +80 -28
  38. package/dist/organisms/AlertDialog.js +192 -67
  39. package/dist/organisms/Carousel.d.ts +25 -3
  40. package/dist/organisms/Carousel.js +75 -43
  41. package/dist/organisms/Combobox.d.ts +2 -1
  42. package/dist/organisms/Combobox.js +46 -16
  43. package/dist/organisms/Command.d.ts +73 -32
  44. package/dist/organisms/Command.js +209 -131
  45. package/dist/organisms/CommandDialog.js +5 -5
  46. package/dist/organisms/ContextMenu.d.ts +41 -19
  47. package/dist/organisms/ContextMenu.js +112 -71
  48. package/dist/organisms/DataTable.js +42 -8
  49. package/dist/organisms/Dialog.d.ts +97 -31
  50. package/dist/organisms/Dialog.js +193 -68
  51. package/dist/organisms/Drawer.d.ts +33 -10
  52. package/dist/organisms/Drawer.js +130 -52
  53. package/dist/organisms/DropdownMenu.d.ts +58 -11
  54. package/dist/organisms/DropdownMenu.js +137 -50
  55. package/dist/organisms/Form.js +9 -11
  56. package/dist/organisms/HoverCard.d.ts +39 -19
  57. package/dist/organisms/HoverCard.js +116 -40
  58. package/dist/organisms/Menubar.d.ts +55 -19
  59. package/dist/organisms/Menubar.js +166 -82
  60. package/dist/organisms/NavigationMenu.d.ts +77 -31
  61. package/dist/organisms/NavigationMenu.js +169 -98
  62. package/dist/organisms/Popover.d.ts +72 -12
  63. package/dist/organisms/Popover.js +132 -25
  64. package/dist/organisms/Questionnaire.js +5 -5
  65. package/dist/organisms/Select.d.ts +99 -18
  66. package/dist/organisms/Select.js +253 -111
  67. package/dist/organisms/Sheet.d.ts +57 -13
  68. package/dist/organisms/Sheet.js +141 -54
  69. package/dist/organisms/Sidebar.d.ts +146 -56
  70. package/dist/organisms/Sidebar.js +236 -128
  71. package/dist/organisms/Tooltip.d.ts +88 -14
  72. package/dist/organisms/Tooltip.js +210 -47
  73. package/dist/organisms/index.d.ts +15 -15
  74. package/dist/organisms/index.js +15 -15
  75. package/dist/primitives/floating.js +25 -0
  76. package/dist/primitives/floatingSurface.d.ts +11 -0
  77. package/dist/primitives/floatingSurface.js +8 -0
  78. package/dist/primitives/menu.d.ts +45 -1
  79. package/dist/primitives/menu.js +45 -14
  80. package/dist/primitives/menuParts.d.ts +113 -0
  81. package/dist/primitives/menuParts.js +207 -0
  82. package/dist/stubs.d.ts +13 -0
  83. package/dist/stubs.js +14 -0
  84. package/nebula.css +1 -1
  85. package/package.json +4 -3
  86. package/registry.json +18 -6
  87. package/src/atoms/Avatar.ts +141 -37
  88. package/src/atoms/index.ts +13 -1
  89. package/src/configure.ts +10 -23
  90. package/src/lib/children.ts +31 -0
  91. package/src/lib/id.ts +11 -39
  92. package/src/lib/motion.ts +12 -0
  93. package/src/molecules/Accordion.ts +120 -60
  94. package/src/molecules/Breadcrumb.ts +77 -76
  95. package/src/molecules/Collapsible.ts +77 -41
  96. package/src/molecules/Field.ts +187 -72
  97. package/src/molecules/InputGroup.ts +88 -35
  98. package/src/molecules/InputOTP.ts +150 -86
  99. package/src/molecules/Message.ts +6 -4
  100. package/src/molecules/Pagination.ts +96 -101
  101. package/src/molecules/RadioGroup.ts +70 -59
  102. package/src/molecules/Resizable.ts +138 -75
  103. package/src/molecules/Tabs.ts +187 -74
  104. package/src/molecules/ToggleGroup.ts +77 -38
  105. package/src/molecules/index.ts +85 -8
  106. package/src/organisms/AlertDialog.ts +319 -82
  107. package/src/organisms/Carousel.ts +129 -52
  108. package/src/organisms/Combobox.ts +64 -19
  109. package/src/organisms/Command.ts +342 -159
  110. package/src/organisms/CommandDialog.ts +6 -6
  111. package/src/organisms/ContextMenu.ts +185 -83
  112. package/src/organisms/DataTable.ts +56 -10
  113. package/src/organisms/Dialog.ts +312 -102
  114. package/src/organisms/Drawer.ts +219 -71
  115. package/src/organisms/DropdownMenu.ts +219 -61
  116. package/src/organisms/Form.ts +48 -34
  117. package/src/organisms/HoverCard.ts +187 -53
  118. package/src/organisms/Menubar.ts +247 -87
  119. package/src/organisms/NavigationMenu.ts +306 -128
  120. package/src/organisms/Popover.ts +215 -39
  121. package/src/organisms/Questionnaire.ts +9 -6
  122. package/src/organisms/Select.ts +397 -130
  123. package/src/organisms/Sheet.ts +252 -83
  124. package/src/organisms/Sidebar.ts +438 -185
  125. package/src/organisms/Tooltip.ts +315 -65
  126. package/src/organisms/index.ts +284 -14
  127. package/src/primitives/floating.ts +33 -0
  128. package/src/primitives/floatingSurface.ts +19 -0
  129. package/src/primitives/menu.ts +79 -18
  130. package/src/primitives/menuParts.ts +371 -0
  131. package/src/stubs.ts +16 -0
  132. package/stubs/config/nebula.stub +21 -0
@@ -1,9 +1,21 @@
1
1
  /**
2
2
  * Tabs — one panel visible at a time.
3
3
  *
4
+ * Tabs({ defaultValue: "account", children: () => html`
5
+ * ${TabsList({ children: html`
6
+ * ${TabsTrigger({ value: "account", children: "Account" })}
7
+ * ${TabsTrigger({ value: "password", children: "Password" })}
8
+ * ` })}
9
+ * ${TabsContent({ value: "account", children: "…" })}
10
+ * ${TabsContent({ value: "password", children: "…" })}
11
+ * ` })
12
+ *
4
13
  * The WAI-ARIA tabs pattern in full: the tab list is a single tab stop with
5
14
  * arrows moving between tabs, each tab points at its panel with
6
- * `aria-controls`, and each panel points back with `aria-labelledby`.
15
+ * `aria-controls`, and each panel points back with `aria-labelledby`. A
16
+ * trigger and its panel find each other through the shared `value` — the ids
17
+ * are minted once per value by the context, so neither has to know the other
18
+ * exists.
7
19
  *
8
20
  * Activation is automatic — moving to a tab selects it — which is the right
9
21
  * default when panels are already rendered and switching costs nothing. The
@@ -15,23 +27,49 @@
15
27
  * the accessibility tree, which is the behaviour `display: none` would give
16
28
  * without also removing them from the DOM.
17
29
  */
18
- import type { Child, Slot } from "../lib/children.js";
30
+ import type { Parts, Slot } from "../lib/children.js";
31
+ import { type VariantProps } from "../lib/cva.js";
19
32
  import { type Reactive } from "../lib/props.js";
20
- export interface TabItem {
21
- value: string;
22
- label: Child;
23
- content: Slot;
24
- disabled?: boolean;
25
- }
33
+ export declare const tabsListVariants: (props?: (import("../index.js").VariantSelection<{
34
+ variant: {
35
+ default: string;
36
+ line: string;
37
+ };
38
+ }> & import("../index.js").ClassOverrides) | undefined) => string;
39
+ export type TabsListVariants = VariantProps<typeof tabsListVariants>;
26
40
  export interface TabsProps {
27
- items: readonly TabItem[];
28
- /** Selected at first render. Defaults to the first enabled tab. */
41
+ /** Selected at first render. Defaults to the first trigger built. */
29
42
  defaultValue?: string;
43
+ value?: Reactive<string | undefined>;
30
44
  orientation?: "horizontal" | "vertical";
31
45
  /** Selecting follows focus. Default `true`. */
32
46
  activateOnFocus?: boolean;
33
47
  onValueChange?: (value: string) => void;
34
48
  class?: Reactive<string>;
35
- listClass?: Reactive<string>;
49
+ children?: Parts;
36
50
  }
37
51
  export declare const Tabs: (props?: TabsProps | undefined) => import("@c9up/aurora").TemplateResult;
52
+ export interface TabsListProps extends TabsListVariants {
53
+ children?: Slot;
54
+ class?: Reactive<string>;
55
+ }
56
+ /**
57
+ * The row of triggers, and the single tab stop that holds them.
58
+ *
59
+ * `rovingFocus` is wired here rather than in `Tabs`: it needs the element the
60
+ * tabs are actually in, and only this part has one.
61
+ */
62
+ export declare const TabsList: (props?: TabsListProps | undefined) => import("@c9up/aurora").TemplateResult;
63
+ export interface TabsTriggerProps {
64
+ value: string;
65
+ children?: Slot;
66
+ disabled?: boolean;
67
+ class?: Reactive<string>;
68
+ }
69
+ export declare const TabsTrigger: (props?: TabsTriggerProps | undefined) => import("@c9up/aurora").TemplateResult;
70
+ export interface TabsContentProps {
71
+ value: string;
72
+ children?: Slot;
73
+ class?: Reactive<string>;
74
+ }
75
+ export declare const TabsContent: (props?: TabsContentProps | undefined) => import("@c9up/aurora").TemplateResult;
@@ -1,9 +1,21 @@
1
1
  /**
2
2
  * Tabs — one panel visible at a time.
3
3
  *
4
+ * Tabs({ defaultValue: "account", children: () => html`
5
+ * ${TabsList({ children: html`
6
+ * ${TabsTrigger({ value: "account", children: "Account" })}
7
+ * ${TabsTrigger({ value: "password", children: "Password" })}
8
+ * ` })}
9
+ * ${TabsContent({ value: "account", children: "…" })}
10
+ * ${TabsContent({ value: "password", children: "…" })}
11
+ * ` })
12
+ *
4
13
  * The WAI-ARIA tabs pattern in full: the tab list is a single tab stop with
5
14
  * arrows moving between tabs, each tab points at its panel with
6
- * `aria-controls`, and each panel points back with `aria-labelledby`.
15
+ * `aria-controls`, and each panel points back with `aria-labelledby`. A
16
+ * trigger and its panel find each other through the shared `value` — the ids
17
+ * are minted once per value by the context, so neither has to know the other
18
+ * exists.
7
19
  *
8
20
  * Activation is automatic — moving to a tab selects it — which is the right
9
21
  * default when panels are already rendered and switching costs nothing. The
@@ -15,95 +27,139 @@
15
27
  * the accessibility tree, which is the behaviour `display: none` would give
16
28
  * without also removing them from the DOM.
17
29
  */
18
- import { component, html, onMount, onUnmount, signal } from "@c9up/aurora";
30
+ import { component, createContext, html, inject, onMount, onUnmount, provide, signal, } from "@c9up/aurora";
19
31
  import { slot } from "../lib/children.js";
20
32
  import { cn } from "../lib/cn.js";
33
+ import { cva } from "../lib/cva.js";
21
34
  import { uid } from "../lib/id.js";
22
35
  import { read } from "../lib/props.js";
23
36
  import { rovingFocus } from "../primitives/rovingFocus.js";
37
+ export const tabsListVariants = cva("group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none", {
38
+ variants: {
39
+ variant: {
40
+ default: "bg-muted",
41
+ line: "gap-1 bg-transparent",
42
+ },
43
+ },
44
+ defaultVariants: { variant: "default" },
45
+ });
46
+ const triggerClasses = "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
47
+ /** The filled look: the active tab gets a surface of its own. */
48
+ const triggerSurfaceClasses = "data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent";
49
+ /** The underlined look: a rule along the active tab's edge, faded in. */
50
+ const triggerUnderlineClasses = "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100";
51
+ const TabsContext = createContext("Tabs");
24
52
  export const Tabs = component((props) => {
25
53
  const orientation = props.orientation ?? "horizontal";
26
- const first = props.items.find((item) => item.disabled !== true);
27
- const active = signal(props.defaultValue ?? first?.value ?? "");
28
- const listId = uid("tabs-list");
29
- // Ids are minted once per tab, up front, because a tab and its panel each
30
- // need to name the other — one of them has to know both before rendering.
54
+ const internal = signal(props.defaultValue ?? "");
31
55
  const ids = new Map();
32
- for (const item of props.items) {
33
- ids.set(item.value, { tab: uid("tab"), panel: uid("tab-panel") });
56
+ function active() {
57
+ const external = read(props.value);
58
+ return external === undefined ? internal() : external;
34
59
  }
35
60
  function select(value) {
36
61
  if (active() === value)
37
62
  return;
38
- active(value);
63
+ internal(value);
39
64
  props.onValueChange?.(value);
40
65
  }
66
+ provide(TabsContext, {
67
+ orientation,
68
+ activateOnFocus: props.activateOnFocus !== false,
69
+ active,
70
+ select,
71
+ ids(value) {
72
+ let found = ids.get(value);
73
+ if (found === undefined) {
74
+ found = { tab: uid("tab"), panel: uid("tab-panel") };
75
+ ids.set(value, found);
76
+ }
77
+ return found;
78
+ },
79
+ registerTrigger(value, disabled) {
80
+ if (disabled)
81
+ return;
82
+ if (props.defaultValue !== undefined || internal() !== "")
83
+ return;
84
+ internal(value);
85
+ },
86
+ });
87
+ return html `<div
88
+ data-slot="tabs"
89
+ data-orientation="${orientation}"
90
+ class="${() => cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", read(props.class))}"
91
+ >${props.children?.()}</div>`;
92
+ });
93
+ /**
94
+ * The row of triggers, and the single tab stop that holds them.
95
+ *
96
+ * `rovingFocus` is wired here rather than in `Tabs`: it needs the element the
97
+ * tabs are actually in, and only this part has one.
98
+ */
99
+ export const TabsList = component((props) => {
100
+ const tabs = inject(TabsContext);
101
+ const listId = uid("tabs-list");
41
102
  let group;
42
103
  onMount(() => {
43
104
  group = rovingFocus({
44
105
  container: () => document.getElementById(listId),
45
106
  itemSelector: "[role='tab']",
46
- orientation,
107
+ orientation: tabs.orientation,
47
108
  onFocusChange: (item) => {
48
- if (props.activateOnFocus === false)
109
+ if (!tabs.activateOnFocus)
49
110
  return;
50
111
  const value = item.getAttribute("data-value");
51
112
  if (value !== null)
52
- select(value);
113
+ tabs.select(value);
53
114
  },
54
115
  onSelect: (item) => {
55
116
  const value = item.getAttribute("data-value");
56
117
  if (value !== null)
57
- select(value);
118
+ tabs.select(value);
58
119
  },
59
120
  });
60
121
  group.sync();
61
122
  });
62
123
  onUnmount(() => group?.destroy());
63
124
  return html `<div
64
- data-slot="tabs"
65
- data-orientation="${orientation}"
66
- class="${() => cn("flex gap-2", orientation === "vertical" ? "flex-row" : "flex-col", read(props.class))}"
67
- >
68
- <div
69
- role="tablist"
70
- data-slot="tabs-list"
71
- id="${listId}"
72
- aria-orientation="${orientation}"
73
- class="${() => cn("bg-muted text-muted-foreground inline-flex w-fit items-center justify-center rounded-lg p-[3px]", orientation === "vertical" ? "flex-col" : "h-9", read(props.listClass))}"
74
- >
75
- ${props.items.map((item) => renderTab(item, ids, active, select))}
76
- </div>
77
- ${props.items.map((item) => renderPanel(item, ids, active))}
78
- </div>`;
125
+ data-slot="tabs-list"
126
+ id="${listId}"
127
+ role="tablist"
128
+ data-variant="${props.variant ?? "default"}"
129
+ aria-orientation="${tabs.orientation}"
130
+ class="${() => cn(tabsListVariants({ variant: props.variant }), read(props.class))}"
131
+ >${slot(props.children)}</div>`;
79
132
  });
80
- function renderTab(item, ids, active, select) {
81
- const id = ids.get(item.value);
82
- const selected = () => active() === item.value;
133
+ export const TabsTrigger = component((props) => {
134
+ const tabs = inject(TabsContext);
135
+ const ids = tabs.ids(props.value);
136
+ tabs.registerTrigger(props.value, props.disabled === true);
137
+ const selected = () => tabs.active() === props.value;
83
138
  return html `<button
84
139
  type="button"
85
- role="tab"
86
140
  data-slot="tabs-trigger"
87
- data-value="${item.value}"
141
+ id="${ids.tab}"
142
+ role="tab"
143
+ data-value="${props.value}"
88
144
  data-state="${() => (selected() ? "active" : "inactive")}"
89
- data-disabled="${item.disabled === true ? "" : undefined}"
90
- id="${id?.tab}"
145
+ data-disabled="${props.disabled === true ? "" : undefined}"
91
146
  aria-selected="${() => (selected() ? "true" : "false")}"
92
- aria-controls="${id?.panel}"
93
- ?disabled="${item.disabled === true}"
94
- class="data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"
95
- @click="${() => select(item.value)}"
96
- >${item.label}</button>`;
97
- }
98
- function renderPanel(item, ids, active) {
99
- const id = ids.get(item.value);
147
+ aria-controls="${ids.panel}"
148
+ ?disabled="${props.disabled === true}"
149
+ class="${() => cn(triggerClasses, triggerSurfaceClasses, triggerUnderlineClasses, read(props.class))}"
150
+ @click="${() => tabs.select(props.value)}"
151
+ >${slot(props.children)}</button>`;
152
+ });
153
+ export const TabsContent = component((props) => {
154
+ const tabs = inject(TabsContext);
155
+ const ids = tabs.ids(props.value);
100
156
  return html `<div
101
- role="tabpanel"
102
157
  data-slot="tabs-content"
103
- id="${id?.panel}"
104
- aria-labelledby="${id?.tab}"
158
+ id="${ids.panel}"
159
+ role="tabpanel"
160
+ aria-labelledby="${ids.tab}"
105
161
  tabindex="0"
106
- ?hidden="${() => active() !== item.value}"
107
- class="flex-1 outline-none"
108
- >${slot(item.content)}</div>`;
109
- }
162
+ ?hidden="${() => tabs.active() !== props.value}"
163
+ class="${() => cn("flex-1 outline-none", read(props.class))}"
164
+ >${slot(props.children)}</div>`;
165
+ });
@@ -15,23 +15,29 @@
15
15
  * to weld the row into one shape.
16
16
  */
17
17
  import { type ToggleVariants } from "../atoms/Toggle.js";
18
- import type { Child } from "../lib/children.js";
18
+ import type { Parts, Slot } from "../lib/children.js";
19
19
  import { type Reactive } from "../lib/props.js";
20
- export interface ToggleGroupItem {
21
- value: string;
22
- label: Child;
23
- /** Required when the label is an icon alone. */
24
- ariaLabel?: string;
25
- disabled?: boolean;
26
- }
27
20
  export interface ToggleGroupProps {
28
- items: readonly ToggleGroupItem[];
29
21
  type?: "single" | "multiple";
30
22
  defaultValue?: string | readonly string[];
31
23
  variant?: Reactive<ToggleVariants["variant"]>;
32
24
  size?: Reactive<ToggleVariants["size"]>;
25
+ /** `"0"` joins the items into one bar; `"default"` spaces them. */
26
+ spacing?: "default" | "0";
33
27
  disabled?: Reactive<boolean>;
34
- class?: Reactive<string>;
35
28
  onValueChange?: (value: readonly string[]) => void;
29
+ class?: Reactive<string>;
30
+ children?: Parts;
36
31
  }
37
32
  export declare const ToggleGroup: (props?: ToggleGroupProps | undefined) => import("@c9up/aurora").TemplateResult;
33
+ export interface ToggleGroupItemProps {
34
+ value: string;
35
+ children?: Slot;
36
+ /** Required when the label is an icon alone. */
37
+ ariaLabel?: string;
38
+ disabled?: boolean;
39
+ variant?: ToggleVariants["variant"];
40
+ size?: ToggleVariants["size"];
41
+ class?: Reactive<string>;
42
+ }
43
+ export declare const ToggleGroupItem: (props?: ToggleGroupItemProps | undefined) => import("@c9up/aurora").TemplateResult;
@@ -14,12 +14,15 @@
14
14
  * standalone one cannot drift apart. Only the corner rounding is overridden,
15
15
  * to weld the row into one shape.
16
16
  */
17
- import { component, html, signal } from "@c9up/aurora";
17
+ import { component, createContext, html, inject, provide, signal, } from "@c9up/aurora";
18
18
  import { toggleVariants } from "../atoms/Toggle.js";
19
+ import { slot } from "../lib/children.js";
19
20
  import { cn } from "../lib/cn.js";
20
21
  import { read, readOr } from "../lib/props.js";
22
+ const ToggleGroupContext = createContext("ToggleGroup");
21
23
  export const ToggleGroup = component((props) => {
22
24
  const type = props.type ?? "single";
25
+ const spacing = props.spacing ?? "0";
23
26
  const selected = signal(props.defaultValue === undefined
24
27
  ? []
25
28
  : typeof props.defaultValue === "string"
@@ -37,32 +40,45 @@ export const ToggleGroup = component((props) => {
37
40
  selected(next);
38
41
  props.onValueChange?.(next);
39
42
  }
43
+ provide(ToggleGroupContext, {
44
+ type,
45
+ variant: read(props.variant),
46
+ size: read(props.size),
47
+ spacing,
48
+ disabled: () => readOr(props.disabled, false),
49
+ isOn: (value) => selected().includes(value),
50
+ toggle,
51
+ });
40
52
  return html `<div
41
53
  data-slot="toggle-group"
42
54
  role="${type === "single" ? "radiogroup" : "group"}"
43
- class="${() => cn("group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs", read(props.class))}"
44
55
  data-variant="${() => readOr(props.variant, "default")}"
45
- >
46
- ${props.items.map((item) => renderItem(item, props, type, selected, toggle))}
47
- </div>`;
56
+ data-size="${() => readOr(props.size, "default")}"
57
+ data-spacing="${spacing}"
58
+ class="${() => cn("group/toggle-group flex w-fit items-center rounded-md data-[spacing=default]:gap-1 data-[spacing=default]:data-[variant=outline]:shadow-xs", read(props.class))}"
59
+ >${props.children?.()}</div>`;
48
60
  });
49
- function renderItem(item, props, type, selected, toggle) {
50
- const on = () => selected().includes(item.value);
61
+ export const ToggleGroupItem = component((props) => {
62
+ const group = inject(ToggleGroupContext);
63
+ const on = () => group.isOn(props.value);
64
+ const single = group.type === "single";
51
65
  return html `<button
52
66
  type="button"
53
67
  data-slot="toggle-group-item"
54
68
  data-state="${() => (on() ? "on" : "off")}"
55
- data-value="${item.value}"
56
- role="${type === "single" ? "radio" : undefined}"
57
- aria-checked="${() => (type === "single" ? (on() ? "true" : "false") : undefined)}"
58
- aria-pressed="${() => (type === "multiple" ? (on() ? "true" : "false") : undefined)}"
59
- aria-label="${item.ariaLabel}"
60
- ?disabled="${() => item.disabled === true || readOr(props.disabled, false)}"
61
- class="${() => toggleVariants({
62
- variant: read(props.variant),
63
- size: read(props.size),
64
- class: "min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l aria-checked:bg-accent aria-checked:text-accent-foreground",
65
- })}"
66
- @click="${() => toggle(item.value)}"
67
- >${item.label}</button>`;
68
- }
69
+ data-value="${props.value}"
70
+ data-variant="${group.variant ?? props.variant ?? "default"}"
71
+ data-size="${group.size ?? props.size ?? "default"}"
72
+ data-spacing="${group.spacing}"
73
+ role="${single ? "radio" : undefined}"
74
+ aria-checked="${() => (single ? (on() ? "true" : "false") : undefined)}"
75
+ aria-pressed="${() => (single ? undefined : on() ? "true" : "false")}"
76
+ aria-label="${props.ariaLabel}"
77
+ ?disabled="${() => props.disabled === true || group.disabled()}"
78
+ class="${() => cn(toggleVariants({
79
+ variant: group.variant ?? props.variant,
80
+ size: group.size ?? props.size,
81
+ }), "w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10", "data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l", "aria-checked:bg-accent aria-checked:text-accent-foreground", read(props.class))}"
82
+ @click="${() => group.toggle(props.value)}"
83
+ >${slot(props.children)}</button>`;
84
+ });
@@ -14,25 +14,25 @@
14
14
  * clarity. The rendered markup is unchanged, so shadcn's CSS and its examples
15
15
  * still read across.
16
16
  */
17
- export { Accordion, type AccordionItem, type AccordionProps, } from "./Accordion.js";
17
+ export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, } from "./Accordion.js";
18
18
  export { Alert, AlertDescription, type AlertProps, AlertTitle, type AlertVariants, alertVariants, } from "./Alert.js";
19
19
  export { Attachment, type AttachmentProps, formatBytes, } from "./Attachment.js";
20
- export { Breadcrumb, type BreadcrumbProps, type Crumb } from "./Breadcrumb.js";
20
+ export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, type BreadcrumbProps, BreadcrumbSeparator, } from "./Breadcrumb.js";
21
21
  export { Bubble, type BubbleProps, type BubbleReaction, type BubbleVariants, bubbleVariants, } from "./Bubble.js";
22
22
  export { ButtonGroup, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, } from "./ButtonGroup.js";
23
23
  export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardTitle, } from "./Card.js";
24
- export { Collapsible, type CollapsibleProps } from "./Collapsible.js";
24
+ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, } from "./Collapsible.js";
25
25
  export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyProps, EmptyTitle, } from "./Empty.js";
26
- export { Field, FieldGroup, type FieldIds, type FieldProps, FieldSeparator, fieldIds, } from "./Field.js";
27
- export { InputGroup, InputGroupAddon, InputGroupInput, type InputGroupProps, inputGroupControlClasses, } from "./InputGroup.js";
28
- export { InputOTP, type InputOTPProps } from "./InputOTP.js";
26
+ export { Field, FieldContent, FieldDescription, FieldError, type FieldErrorProps, FieldGroup, type FieldIds, FieldLabel, FieldLegend, type FieldLegendProps, type FieldProps, type FieldSectionProps, FieldSeparator, type FieldSeparatorProps, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
27
+ export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, InputGroupInput, type InputGroupProps, InputGroupText, InputGroupTextarea, type InputGroupTextProps, inputGroupControlClasses, } from "./InputGroup.js";
28
+ export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, } from "./InputOTP.js";
29
29
  export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, type ItemProps, ItemSeparator, ItemTitle, type ItemVariants, itemVariants, } from "./Item.js";
30
30
  export { Message, type MessageProps } from "./Message.js";
31
- export { type PageSlot, Pagination, type PaginationProps, pageWindow, } from "./Pagination.js";
31
+ export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
32
32
  export { Picture, type PictureProps } from "./Picture.js";
33
- export { RadioGroup, type RadioGroupProps, type RadioOption, } from "./RadioGroup.js";
34
- export { Resizable, type ResizableProps } from "./Resizable.js";
33
+ export { RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, } from "./RadioGroup.js";
34
+ export { ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, } from "./Resizable.js";
35
35
  export { Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, TableHeader, type TableProps, TableRow, type TableRowProps, } from "./Table.js";
36
- export { type TabItem, Tabs, type TabsProps } from "./Tabs.js";
37
- export { ToggleGroup, type ToggleGroupItem, type ToggleGroupProps, } from "./ToggleGroup.js";
36
+ export { Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsListVariants, type TabsProps, TabsTrigger, type TabsTriggerProps, tabsListVariants, } from "./Tabs.js";
37
+ export { ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, } from "./ToggleGroup.js";
38
38
  export { Blockquote, H1, H2, H3, H4, InlineCode, Large, Lead, List, Muted, P, Small, type TypographyProps, } from "./Typography.js";
@@ -14,25 +14,25 @@
14
14
  * clarity. The rendered markup is unchanged, so shadcn's CSS and its examples
15
15
  * still read across.
16
16
  */
17
- export { Accordion, } from "./Accordion.js";
17
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "./Accordion.js";
18
18
  export { Alert, AlertDescription, AlertTitle, alertVariants, } from "./Alert.js";
19
19
  export { Attachment, formatBytes, } from "./Attachment.js";
20
- export { Breadcrumb } from "./Breadcrumb.js";
20
+ export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "./Breadcrumb.js";
21
21
  export { Bubble, bubbleVariants, } from "./Bubble.js";
22
22
  export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, } from "./ButtonGroup.js";
23
23
  export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./Card.js";
24
- export { Collapsible } from "./Collapsible.js";
24
+ export { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "./Collapsible.js";
25
25
  export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "./Empty.js";
26
- export { Field, FieldGroup, FieldSeparator, fieldIds, } from "./Field.js";
27
- export { InputGroup, InputGroupAddon, InputGroupInput, inputGroupControlClasses, } from "./InputGroup.js";
28
- export { InputOTP } from "./InputOTP.js";
26
+ export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
27
+ export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupControlClasses, } from "./InputGroup.js";
28
+ export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "./InputOTP.js";
29
29
  export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemSeparator, ItemTitle, itemVariants, } from "./Item.js";
30
30
  export { Message } from "./Message.js";
31
- export { Pagination, pageWindow, } from "./Pagination.js";
31
+ export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, pageWindow, } from "./Pagination.js";
32
32
  export { Picture } from "./Picture.js";
33
- export { RadioGroup, } from "./RadioGroup.js";
34
- export { Resizable } from "./Resizable.js";
33
+ export { RadioGroup, RadioGroupItem, } from "./RadioGroup.js";
34
+ export { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "./Resizable.js";
35
35
  export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "./Table.js";
36
- export { Tabs } from "./Tabs.js";
37
- export { ToggleGroup, } from "./ToggleGroup.js";
36
+ export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants, } from "./Tabs.js";
37
+ export { ToggleGroup, ToggleGroupItem, } from "./ToggleGroup.js";
38
38
  export { Blockquote, H1, H2, H3, H4, InlineCode, Large, Lead, List, Muted, P, Small, } from "./Typography.js";
@@ -1,40 +1,92 @@
1
1
  /**
2
- * AlertDialog — a modal that interrupts to ask something.
2
+ * AlertDialog — a modal that interrupts to ask a question.
3
3
  *
4
- * The differences from Dialog are all about refusing to be dismissed by
5
- * accident, because the user is being asked to confirm something they cannot
6
- * undo:
4
+ * AlertDialog({ children: () => html`
5
+ * ${AlertDialogTrigger({ children: "Delete" })}
6
+ * ${AlertDialogContent({ children: () => html`
7
+ * ${AlertDialogHeader({ children: html`
8
+ * ${AlertDialogTitle({ children: "Delete this?" })}
9
+ * ${AlertDialogDescription({ children: "It cannot be undone." })}
10
+ * ` })}
11
+ * ${AlertDialogFooter({ children: html`
12
+ * ${AlertDialogCancel({ children: "Cancel" })}
13
+ * ${AlertDialogAction({ children: "Delete", variant: "destructive" })}
14
+ * ` })}
15
+ * ` })}
16
+ * ` })
7
17
  *
8
- * - `role="alertdialog"`, which tells assistive technology this is not merely
9
- * a window but a message requiring a response.
10
- * - No close button and no backdrop dismissal. Both are the "click somewhere
11
- * else and it goes away" gesture, and an accidental dismissal of "delete
12
- * this?" reads as a cancel — the safe answer — but leaves the user unsure
13
- * which one they gave.
14
- * - Escape still closes. It is unambiguous and deliberate, and taking it away
15
- * would trap a keyboard user in the dialog.
16
- * - Focus starts on **Cancel**, not the action. The destructive button is the
17
- * one the user must reach for on purpose.
18
+ * Everything that distinguishes it from a Dialog is about refusing to let the
19
+ * question be dismissed by accident:
20
+ *
21
+ * - `role="alertdialog"`, which tells a screen reader this interrupts.
22
+ * - No outside-click dismissal. A decision has to be made, and clicking past
23
+ * it is not one.
24
+ * - Focus lands on the CANCEL button, not the confirming action. The safe
25
+ * choice is the one a hurried Enter should hit.
26
+ *
27
+ * Escape still closes, and it cancels rather than confirms — it is the
28
+ * keyboard spelling of the same safe way out.
18
29
  */
19
- import type { Child } from "../lib/children.js";
20
- import { type Slot } from "../lib/children.js";
30
+ import { type TemplateResult } from "@c9up/aurora";
31
+ import { type ButtonVariants } from "../atoms/Button.js";
32
+ import type { Parts, Slot } from "../lib/children.js";
21
33
  import { type Reactive } from "../lib/props.js";
22
34
  export interface AlertDialogProps {
23
- trigger?: Slot;
24
- title: Child;
25
- description: Child;
26
- /** Label for the confirming action. Default `"Continue"`. */
27
- actionLabel?: Child;
28
- /** Label for the way out. Default `"Cancel"`. */
29
- cancelLabel?: Child;
30
- /** Styles the action as destructive. */
31
- destructive?: boolean;
32
35
  open?: Reactive<boolean>;
33
36
  defaultOpen?: boolean;
34
37
  onOpenChange?: (open: boolean) => void;
35
38
  onConfirm?: () => void;
36
39
  onCancel?: () => void;
37
- triggerClass?: Reactive<string>;
38
- contentClass?: Reactive<string>;
40
+ children?: Parts;
41
+ }
42
+ export declare const AlertDialog: (props?: AlertDialogProps | undefined) => TemplateResult;
43
+ export interface AlertDialogTriggerProps {
44
+ children?: Slot;
45
+ class?: Reactive<string>;
46
+ }
47
+ export declare const AlertDialogTrigger: (props?: AlertDialogTriggerProps | undefined) => TemplateResult;
48
+ export interface AlertDialogContentProps {
49
+ children?: Parts;
50
+ size?: "default" | "sm";
51
+ class?: Reactive<string>;
39
52
  }
40
- export declare const AlertDialog: (props?: AlertDialogProps | undefined) => import("@c9up/aurora").TemplateResult;
53
+ export declare const AlertDialogContent: (props?: AlertDialogContentProps | undefined) => TemplateResult;
54
+ export interface AlertDialogSectionProps {
55
+ children?: Slot;
56
+ class?: Reactive<string>;
57
+ }
58
+ export declare const AlertDialogOverlay: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
59
+ export interface AlertDialogPortalProps {
60
+ children?: Slot;
61
+ container?: () => Element | null;
62
+ }
63
+ /**
64
+ * Mount children outside the component's own DOM position.
65
+ *
66
+ * `AlertDialogContent` does not need it — the dialog portals its whole overlay
67
+ * through `modalSurface`, which also owns the trap and the scroll lock. It is
68
+ * exported because upstream exports it, doing here what its name says rather
69
+ * than standing in as a passthrough.
70
+ */
71
+ export declare const AlertDialogPortal: (props?: AlertDialogPortalProps | undefined) => TemplateResult;
72
+ export declare const AlertDialogHeader: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
73
+ export declare const AlertDialogFooter: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
74
+ /** An icon block above the title — a warning glyph, a product mark. */
75
+ export declare const AlertDialogMedia: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
76
+ export declare const AlertDialogTitle: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
77
+ export declare const AlertDialogDescription: (props?: AlertDialogSectionProps | undefined) => TemplateResult;
78
+ export interface AlertDialogButtonProps {
79
+ children?: Slot;
80
+ variant?: ButtonVariants["variant"];
81
+ size?: ButtonVariants["size"];
82
+ class?: Reactive<string>;
83
+ }
84
+ /** The confirming action. */
85
+ export declare const AlertDialogAction: (props?: AlertDialogButtonProps | undefined) => TemplateResult;
86
+ /**
87
+ * The way out, and where focus lands.
88
+ *
89
+ * The safe choice is the one a hurried Enter should hit, which is why the
90
+ * surface focuses this rather than the action beside it.
91
+ */
92
+ export declare const AlertDialogCancel: (props?: AlertDialogButtonProps | undefined) => TemplateResult;