@c9up/nebula 0.1.9 → 0.2.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 (122) 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/lib/children.d.ts +30 -0
  6. package/dist/lib/motion.d.ts +10 -0
  7. package/dist/lib/motion.js +10 -0
  8. package/dist/molecules/Accordion.d.ts +36 -15
  9. package/dist/molecules/Accordion.js +68 -45
  10. package/dist/molecules/Breadcrumb.d.ts +29 -11
  11. package/dist/molecules/Breadcrumb.js +52 -52
  12. package/dist/molecules/Collapsible.d.ts +18 -17
  13. package/dist/molecules/Collapsible.js +42 -34
  14. package/dist/molecules/Field.d.ts +66 -30
  15. package/dist/molecules/Field.js +106 -55
  16. package/dist/molecules/InputGroup.d.ts +39 -21
  17. package/dist/molecules/InputGroup.js +43 -27
  18. package/dist/molecules/InputOTP.d.ts +26 -3
  19. package/dist/molecules/InputOTP.js +109 -76
  20. package/dist/molecules/Message.js +5 -4
  21. package/dist/molecules/Pagination.d.ts +36 -11
  22. package/dist/molecules/Pagination.js +58 -74
  23. package/dist/molecules/RadioGroup.d.ts +25 -17
  24. package/dist/molecules/RadioGroup.js +47 -43
  25. package/dist/molecules/Resizable.d.ts +32 -7
  26. package/dist/molecules/Resizable.js +76 -49
  27. package/dist/molecules/Tabs.d.ts +49 -11
  28. package/dist/molecules/Tabs.js +107 -51
  29. package/dist/molecules/ToggleGroup.d.ts +16 -10
  30. package/dist/molecules/ToggleGroup.js +37 -21
  31. package/dist/molecules/index.d.ts +11 -11
  32. package/dist/molecules/index.js +11 -11
  33. package/dist/organisms/AlertDialog.d.ts +80 -28
  34. package/dist/organisms/AlertDialog.js +192 -67
  35. package/dist/organisms/Carousel.d.ts +25 -3
  36. package/dist/organisms/Carousel.js +75 -43
  37. package/dist/organisms/Combobox.d.ts +2 -1
  38. package/dist/organisms/Combobox.js +46 -16
  39. package/dist/organisms/Command.d.ts +73 -32
  40. package/dist/organisms/Command.js +209 -131
  41. package/dist/organisms/CommandDialog.js +5 -5
  42. package/dist/organisms/ContextMenu.d.ts +41 -19
  43. package/dist/organisms/ContextMenu.js +112 -71
  44. package/dist/organisms/DataTable.js +42 -8
  45. package/dist/organisms/Dialog.d.ts +97 -31
  46. package/dist/organisms/Dialog.js +193 -68
  47. package/dist/organisms/Drawer.d.ts +33 -10
  48. package/dist/organisms/Drawer.js +130 -52
  49. package/dist/organisms/DropdownMenu.d.ts +58 -11
  50. package/dist/organisms/DropdownMenu.js +137 -50
  51. package/dist/organisms/Form.js +9 -11
  52. package/dist/organisms/HoverCard.d.ts +39 -19
  53. package/dist/organisms/HoverCard.js +116 -40
  54. package/dist/organisms/Menubar.d.ts +55 -19
  55. package/dist/organisms/Menubar.js +166 -82
  56. package/dist/organisms/NavigationMenu.d.ts +77 -31
  57. package/dist/organisms/NavigationMenu.js +169 -98
  58. package/dist/organisms/Popover.d.ts +72 -12
  59. package/dist/organisms/Popover.js +132 -25
  60. package/dist/organisms/Questionnaire.js +5 -5
  61. package/dist/organisms/Select.d.ts +99 -18
  62. package/dist/organisms/Select.js +253 -111
  63. package/dist/organisms/Sheet.d.ts +57 -13
  64. package/dist/organisms/Sheet.js +141 -54
  65. package/dist/organisms/Sidebar.d.ts +146 -56
  66. package/dist/organisms/Sidebar.js +236 -128
  67. package/dist/organisms/Tooltip.d.ts +88 -14
  68. package/dist/organisms/Tooltip.js +210 -47
  69. package/dist/organisms/index.d.ts +15 -15
  70. package/dist/organisms/index.js +15 -15
  71. package/dist/primitives/floating.js +25 -0
  72. package/dist/primitives/floatingSurface.d.ts +11 -0
  73. package/dist/primitives/floatingSurface.js +8 -0
  74. package/dist/primitives/menu.d.ts +45 -1
  75. package/dist/primitives/menu.js +45 -14
  76. package/dist/primitives/menuParts.d.ts +113 -0
  77. package/dist/primitives/menuParts.js +207 -0
  78. package/nebula.css +1 -1
  79. package/package.json +3 -3
  80. package/registry.json +18 -6
  81. package/src/atoms/Avatar.ts +141 -37
  82. package/src/atoms/index.ts +13 -1
  83. package/src/lib/children.ts +31 -0
  84. package/src/lib/motion.ts +12 -0
  85. package/src/molecules/Accordion.ts +120 -60
  86. package/src/molecules/Breadcrumb.ts +77 -76
  87. package/src/molecules/Collapsible.ts +77 -41
  88. package/src/molecules/Field.ts +187 -72
  89. package/src/molecules/InputGroup.ts +88 -35
  90. package/src/molecules/InputOTP.ts +150 -86
  91. package/src/molecules/Message.ts +6 -4
  92. package/src/molecules/Pagination.ts +96 -101
  93. package/src/molecules/RadioGroup.ts +70 -59
  94. package/src/molecules/Resizable.ts +138 -75
  95. package/src/molecules/Tabs.ts +187 -74
  96. package/src/molecules/ToggleGroup.ts +77 -38
  97. package/src/molecules/index.ts +85 -8
  98. package/src/organisms/AlertDialog.ts +319 -82
  99. package/src/organisms/Carousel.ts +129 -52
  100. package/src/organisms/Combobox.ts +64 -19
  101. package/src/organisms/Command.ts +342 -159
  102. package/src/organisms/CommandDialog.ts +6 -6
  103. package/src/organisms/ContextMenu.ts +185 -83
  104. package/src/organisms/DataTable.ts +56 -10
  105. package/src/organisms/Dialog.ts +312 -102
  106. package/src/organisms/Drawer.ts +219 -71
  107. package/src/organisms/DropdownMenu.ts +219 -61
  108. package/src/organisms/Form.ts +48 -34
  109. package/src/organisms/HoverCard.ts +187 -53
  110. package/src/organisms/Menubar.ts +247 -87
  111. package/src/organisms/NavigationMenu.ts +306 -128
  112. package/src/organisms/Popover.ts +215 -39
  113. package/src/organisms/Questionnaire.ts +9 -6
  114. package/src/organisms/Select.ts +397 -130
  115. package/src/organisms/Sheet.ts +252 -83
  116. package/src/organisms/Sidebar.ts +438 -185
  117. package/src/organisms/Tooltip.ts +315 -65
  118. package/src/organisms/index.ts +284 -14
  119. package/src/primitives/floating.ts +33 -0
  120. package/src/primitives/floatingSurface.ts +19 -0
  121. package/src/primitives/menu.ts +79 -18
  122. package/src/primitives/menuParts.ts +371 -0
@@ -11,64 +11,48 @@
11
11
  */
12
12
 
13
13
  import { component, html } from "@c9up/aurora";
14
+ import { Button, type ButtonVariants } from "../atoms/Button.js";
14
15
  import { Input, type InputProps } from "../atoms/Input.js";
16
+ import { Textarea, type TextareaProps } from "../atoms/Textarea.js";
15
17
  import { type Slot, slot } from "../lib/children.js";
16
18
  import { cn } from "../lib/cn.js";
17
19
  import { type Reactive, read } from "../lib/props.js";
18
- import { styledDiv } from "../lib/styled.js";
20
+
21
+ export const inputGroupControlClasses =
22
+ "flex-1 rounded-none border-0 bg-transparent px-0 shadow-none outline-none focus-visible:border-0 focus-visible:ring-0 disabled:opacity-100 dark:bg-transparent";
19
23
 
20
24
  export interface InputGroupProps {
21
25
  children?: Slot;
22
- /** Before the input — an icon or a static prefix. */
23
- leading?: Slot;
24
- /** After the input — a unit, a button, a spinner. */
25
- trailing?: Slot;
26
26
  invalid?: Reactive<boolean>;
27
27
  disabled?: Reactive<boolean>;
28
28
  class?: Reactive<string>;
29
29
  }
30
30
 
31
31
  /**
32
- * Strip the inner input of its own chrome.
33
- *
34
- * Put these ON the input. The group cannot do it from the outside: a descendant
35
- * variant like `[&_input]:border-0` has to exist as a literal for Tailwind to
36
- * generate a rule for it, and building one by joining this string at runtime
37
- * produces class names no stylesheet ever defines — the input keeps its border
38
- * and draws a second one inside the group's, with nothing raised to say so.
32
+ * InputGroup — a control with things attached to it.
39
33
  *
40
- * {@link InputGroupInput} applies them for you. This export is for a caller
41
- * passing a plain `<input>` instead.
34
+ * The border, the ring and the invalid state live on the GROUP, not on the
35
+ * control: an input with its own border inside a bordered group draws two
36
+ * rectangles, and a focus ring around the input alone leaves the addons
37
+ * outside it. So the control gives all of that up — that is the whole of
38
+ * `inputGroupControlClasses` — and `focus-within` moves the ring to the group.
42
39
  */
43
- export const inputGroupControlClasses =
44
- "flex-1 border-0 bg-transparent px-0 shadow-none outline-none focus-visible:border-0 focus-visible:ring-0 disabled:opacity-100";
45
-
46
- export const InputGroup = component<InputGroupProps>((props) => {
47
- return html`<div
40
+ export const InputGroup = component<InputGroupProps>(
41
+ (props) => html`<div
48
42
  data-slot="input-group"
49
43
  data-disabled="${() => (read(props.disabled) === true ? "" : undefined)}"
50
44
  aria-invalid="${() => (read(props.invalid) === true ? "true" : undefined)}"
51
45
  class="${() =>
52
46
  cn(
53
- "border-input dark:bg-input/30 flex h-9 w-full min-w-0 items-center gap-2 rounded-md border bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow]",
47
+ "group/input-group border-input dark:bg-input/30 relative flex h-9 w-full min-w-0 items-center gap-2 rounded-md border bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none",
54
48
  "focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
55
49
  "aria-invalid:border-destructive aria-invalid:ring-destructive/20",
56
50
  "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
57
51
  read(props.class),
58
52
  )}"
59
- >
60
- ${slot(props.leading)}${slot(props.children)}${slot(props.trailing)}
61
- </div>`;
62
- });
53
+ >${slot(props.children)}</div>`,
54
+ );
63
55
 
64
- /**
65
- * The input that belongs inside an {@link InputGroup}.
66
- *
67
- * Same component as {@link Input}, with the group's stripping applied first so
68
- * a caller's own `class` still wins. This is where the classes have to live:
69
- * the group carries the border and the ring, and the input has to bring none
70
- * of its own.
71
- */
72
56
  export const InputGroupInput = component<InputProps>((props) =>
73
57
  Input({
74
58
  ...props,
@@ -76,7 +60,76 @@ export const InputGroupInput = component<InputProps>((props) =>
76
60
  }),
77
61
  );
78
62
 
79
- export const InputGroupAddon = styledDiv(
80
- "input-group-addon",
81
- "text-muted-foreground flex shrink-0 items-center gap-2 [&_svg:not([class*='size-'])]:size-4",
63
+ export const InputGroupTextarea = component<TextareaProps>((props) =>
64
+ Textarea({
65
+ ...props,
66
+ class: () =>
67
+ cn(inputGroupControlClasses, "resize-none py-3", read(props.class)),
68
+ }),
69
+ );
70
+
71
+ export interface InputGroupAddonProps {
72
+ children?: Slot;
73
+ /** Which end it sits at. `block-*` stacks it above or below the control. */
74
+ align?: "inline-start" | "inline-end" | "block-start" | "block-end";
75
+ class?: Reactive<string>;
76
+ }
77
+
78
+ /** An icon, a unit, a button — anything beside the control. */
79
+ export const InputGroupAddon = component<InputGroupAddonProps>(
80
+ (props) => html`<div
81
+ data-slot="input-group-addon"
82
+ data-align="${props.align ?? "inline-start"}"
83
+ class="${() =>
84
+ cn(
85
+ "text-muted-foreground flex shrink-0 items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
86
+ read(props.class),
87
+ )}"
88
+ >${slot(props.children)}</div>`,
89
+ );
90
+
91
+ export interface InputGroupButtonProps {
92
+ children?: Slot;
93
+ type?: "button" | "submit" | "reset";
94
+ variant?: ButtonVariants["variant"];
95
+ size?: ButtonVariants["size"];
96
+ disabled?: Reactive<boolean>;
97
+ onClick?: (event: MouseEvent) => void;
98
+ class?: Reactive<string>;
99
+ }
100
+
101
+ /**
102
+ * A button inside the group.
103
+ *
104
+ * `ghost` and the smallest size by default: a filled button the height of the
105
+ * field turns the group into two controls side by side, which is exactly what
106
+ * the group exists to avoid looking like.
107
+ */
108
+ export const InputGroupButton = component<InputGroupButtonProps>((props) =>
109
+ Button({
110
+ type: props.type ?? "button",
111
+ variant: props.variant ?? "ghost",
112
+ size: props.size ?? "sm",
113
+ disabled: props.disabled,
114
+ onClick: props.onClick,
115
+ class: () => cn("shadow-none", read(props.class)),
116
+ children: props.children,
117
+ }),
118
+ );
119
+
120
+ export interface InputGroupTextProps {
121
+ children?: Slot;
122
+ class?: Reactive<string>;
123
+ }
124
+
125
+ /** Static text in the group — a currency symbol, a domain suffix. */
126
+ export const InputGroupText = component<InputGroupTextProps>(
127
+ (props) => html`<span
128
+ data-slot="input-group-text"
129
+ class="${() =>
130
+ cn(
131
+ "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
132
+ read(props.class),
133
+ )}"
134
+ >${slot(props.children)}</span>`,
82
135
  );
@@ -18,31 +18,53 @@
18
18
  * one field, rather than six.
19
19
  */
20
20
 
21
- import { component, html, signal } from "@c9up/aurora";
21
+ import {
22
+ component,
23
+ createContext,
24
+ html,
25
+ inject,
26
+ provide,
27
+ signal,
28
+ } from "@c9up/aurora";
29
+ import type { Parts, Slot } from "../lib/children.js";
30
+ import { slot } from "../lib/children.js";
22
31
  import { cn } from "../lib/cn.js";
32
+ import { MinusIcon } from "../lib/icons.js";
23
33
  import { uid } from "../lib/id.js";
24
34
  import { type Reactive, read, readOr } from "../lib/props.js";
25
35
 
36
+ const slotClasses =
37
+ "border-input relative flex size-9 items-center justify-center border-y border-r text-center text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md focus:border-ring focus:ring-ring/50 focus:z-10 focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50";
38
+
39
+ interface InputOTPApi {
40
+ readonly length: number;
41
+ readonly disabled: () => boolean;
42
+ /** Claim the next box's index, in the order the slots are built. */
43
+ claimSlot(): number;
44
+ onInput(index: number, event: Event): void;
45
+ onKeyDown(index: number, event: KeyboardEvent): void;
46
+ onPaste(index: number, event: ClipboardEvent): void;
47
+ }
48
+
49
+ const InputOTPContext = createContext<InputOTPApi>("InputOTP");
50
+
26
51
  export interface InputOTPProps {
27
- /** Number of boxes. Default `6`. */
52
+ /** Number of boxes. Default `6` — and it must match the slots built. */
28
53
  length?: number;
29
54
  name?: string;
30
55
  disabled?: Reactive<boolean>;
31
- /** Insert a visual gap after this many boxes. `3` gives `123 456`. */
32
- groupAfter?: number;
33
56
  class?: Reactive<string>;
34
57
  onValueChange?: (value: string) => void;
35
58
  /** Fired once every box is filled. */
36
59
  onComplete?: (value: string) => void;
60
+ children?: Parts;
37
61
  }
38
62
 
39
- const slotClasses =
40
- "border-input relative flex size-9 items-center justify-center border-y border-r text-center text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md focus:border-ring focus:ring-ring/50 focus:z-10 focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50";
41
-
42
63
  export const InputOTP = component<InputOTPProps>((props) => {
43
64
  const length = props.length ?? 6;
44
65
  const groupId = uid("input-otp");
45
66
  const characters = signal<readonly string[]>(new Array(length).fill(""));
67
+ let claimed = 0;
46
68
 
47
69
  function boxes(): HTMLInputElement[] {
48
70
  const root = document.getElementById(groupId);
@@ -74,93 +96,135 @@ export const InputOTP = component<InputOTPProps>((props) => {
74
96
  commit(next);
75
97
  }
76
98
 
77
- function onInput(index: number, event: Event): void {
78
- const target = event.target;
79
- if (!(target instanceof HTMLInputElement)) return;
80
-
81
- // A box already holding a character receives the new one appended; keep
82
- // the last, which is what the user just typed.
83
- const typed = target.value.slice(-1);
84
- target.value = typed;
85
- write(index, typed);
86
- if (typed !== "" && index < length - 1) focusBox(index + 1);
87
- }
88
-
89
- function onKeyDown(index: number, event: KeyboardEvent): void {
90
- if (event.key === "Backspace") {
91
- if (characters()[index] === "" && index > 0) {
99
+ provide<InputOTPApi>(InputOTPContext, {
100
+ length,
101
+ disabled: () => readOr(props.disabled, false),
102
+ claimSlot() {
103
+ const index = claimed;
104
+ claimed += 1;
105
+ return index;
106
+ },
107
+ onInput(index, event) {
108
+ const target = event.target;
109
+ if (!(target instanceof HTMLInputElement)) return;
110
+
111
+ // A box already holding a character receives the new one appended; keep
112
+ // the last, which is what the user just typed.
113
+ const typed = target.value.slice(-1);
114
+ target.value = typed;
115
+ write(index, typed);
116
+ if (typed !== "" && index < length - 1) focusBox(index + 1);
117
+ },
118
+ onKeyDown(index, event) {
119
+ if (event.key === "Backspace") {
120
+ if (characters()[index] === "" && index > 0) {
121
+ event.preventDefault();
122
+ write(index - 1, "");
123
+ focusBox(index - 1);
124
+ }
125
+ return;
126
+ }
127
+ if (event.key === "ArrowLeft") {
92
128
  event.preventDefault();
93
- write(index - 1, "");
94
129
  focusBox(index - 1);
130
+ return;
95
131
  }
96
- return;
97
- }
98
- if (event.key === "ArrowLeft") {
99
- event.preventDefault();
100
- focusBox(index - 1);
101
- return;
102
- }
103
- if (event.key === "ArrowRight") {
132
+ if (event.key === "ArrowRight") {
133
+ event.preventDefault();
134
+ focusBox(index + 1);
135
+ }
136
+ },
137
+ onPaste(index, event) {
138
+ const pasted = event.clipboardData?.getData("text") ?? "";
139
+ if (pasted === "") return;
104
140
  event.preventDefault();
105
- focusBox(index + 1);
106
- }
107
- }
108
-
109
- function onPaste(index: number, event: ClipboardEvent): void {
110
- const pasted = event.clipboardData?.getData("text") ?? "";
111
- if (pasted === "") return;
112
- event.preventDefault();
113
-
114
- const next = [...characters()];
115
- let cursor = index;
116
- for (const character of pasted) {
117
- if (cursor >= length) break;
118
- next[cursor] = character;
119
- cursor += 1;
120
- }
121
- commit(next);
122
141
 
123
- // Reflect into the DOM: the boxes are uncontrolled between keystrokes, so
124
- // writing the signal alone would leave the pasted characters invisible.
125
- const inputs = boxes();
126
- next.forEach((character, position) => {
127
- const input = inputs[position];
128
- if (input !== undefined) input.value = character;
129
- });
130
- focusBox(Math.min(cursor, length - 1));
131
- }
132
-
133
- const indices = Array.from({ length }, (_unused, index) => index);
142
+ const next = [...characters()];
143
+ let cursor = index;
144
+ for (const character of pasted) {
145
+ if (cursor >= length) break;
146
+ next[cursor] = character;
147
+ cursor += 1;
148
+ }
149
+ commit(next);
150
+
151
+ // Reflect into the DOM: the boxes are uncontrolled between keystrokes,
152
+ // so writing the signal alone would leave the pasted characters
153
+ // invisible.
154
+ const inputs = boxes();
155
+ next.forEach((character, position) => {
156
+ const input = inputs[position];
157
+ if (input !== undefined) input.value = character;
158
+ });
159
+ focusBox(Math.min(cursor, length - 1));
160
+ },
161
+ });
134
162
 
135
163
  return html`<div
136
164
  data-slot="input-otp"
137
165
  id="${groupId}"
138
166
  class="${() => cn("flex items-center gap-2", read(props.class))}"
139
- >
140
- <div class="flex items-center">
141
- ${indices.map(
142
- (index) => html`${
143
- props.groupAfter !== undefined &&
144
- index > 0 &&
145
- index % props.groupAfter === 0
146
- ? html`<span aria-hidden="true" class="mx-1 text-muted-foreground">-</span>`
147
- : null
148
- }<input
149
- data-slot="input-otp-slot"
150
- data-otp-index="${index}"
151
- type="text"
152
- inputmode="numeric"
153
- autocomplete="${index === 0 ? "one-time-code" : "off"}"
154
- maxlength="1"
155
- aria-label="${`Character ${index + 1} of ${length}`}"
156
- ?disabled="${() => readOr(props.disabled, false)}"
157
- class="${slotClasses}"
158
- @input="${(event: Event) => onInput(index, event)}"
159
- @keydown="${(event: KeyboardEvent) => onKeyDown(index, event)}"
160
- @paste="${(event: ClipboardEvent) => onPaste(index, event)}"
161
- />`,
162
- )}
163
- </div>
164
- <input type="hidden" name="${props.name}" .value="${() => characters().join("")}" />
165
- </div>`;
167
+ >${props.children?.()}<input
168
+ type="hidden"
169
+ name="${props.name}"
170
+ .value="${() => characters().join("")}"
171
+ /></div>`;
172
+ });
173
+
174
+ export interface InputOTPGroupProps {
175
+ children?: Slot;
176
+ class?: Reactive<string>;
177
+ }
178
+
179
+ /** A run of boxes with no gap between them. */
180
+ export const InputOTPGroup = component<InputOTPGroupProps>(
181
+ (props) => html`<div
182
+ data-slot="input-otp-group"
183
+ class="${() => cn("flex items-center", read(props.class))}"
184
+ >${slot(props.children)}</div>`,
185
+ );
186
+
187
+ export interface InputOTPSlotProps {
188
+ class?: Reactive<string>;
189
+ }
190
+
191
+ /**
192
+ * One box.
193
+ *
194
+ * Claims its index as it is built, so the slots need no index prop and cannot
195
+ * be numbered wrongly. A real `<input>` per box rather than a single field
196
+ * with drawn cells: it is what gives each box its own caret, its own
197
+ * `autocomplete` and the one-time-code hint the platform fills from an SMS.
198
+ */
199
+ export const InputOTPSlot = component<InputOTPSlotProps>((props) => {
200
+ const otp = inject(InputOTPContext);
201
+ const index = otp.claimSlot();
202
+ return html`<input
203
+ data-slot="input-otp-slot"
204
+ data-otp-index="${index}"
205
+ type="text"
206
+ inputmode="numeric"
207
+ autocomplete="${index === 0 ? "one-time-code" : "off"}"
208
+ maxlength="1"
209
+ aria-label="${`Character ${index + 1} of ${otp.length}`}"
210
+ ?disabled="${() => otp.disabled()}"
211
+ class="${() => cn(slotClasses, read(props.class))}"
212
+ @input="${(event: Event) => otp.onInput(index, event)}"
213
+ @keydown="${(event: KeyboardEvent) => otp.onKeyDown(index, event)}"
214
+ @paste="${(event: ClipboardEvent) => otp.onPaste(index, event)}"
215
+ />`;
166
216
  });
217
+
218
+ export interface InputOTPSeparatorProps {
219
+ class?: Reactive<string>;
220
+ }
221
+
222
+ /** The dash between two groups. Decorative — the boxes carry the labels. */
223
+ export const InputOTPSeparator = component<InputOTPSeparatorProps>(
224
+ (props) => html`<div
225
+ data-slot="input-otp-separator"
226
+ role="separator"
227
+ aria-hidden="true"
228
+ class="${() => cn("text-muted-foreground mx-1", read(props.class))}"
229
+ >${MinusIcon({ class: "size-4" })}</div>`,
230
+ );
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { component, html } from "@c9up/aurora";
20
- import { Avatar } from "../atoms/Avatar.js";
20
+ import { Avatar, AvatarFallback, AvatarImage } from "../atoms/Avatar.js";
21
21
  import type { Child } from "../lib/children.js";
22
22
  import { type Slot, slot } from "../lib/children.js";
23
23
  import { cn } from "../lib/cn.js";
@@ -75,10 +75,12 @@ export const Message = component<MessageProps>((props) => {
75
75
  ${
76
76
  hasAvatar
77
77
  ? Avatar({
78
- src: props.avatarSrc,
79
- alt: typeof props.author === "string" ? props.author : "",
80
- fallback: props.avatarFallback,
81
78
  class: "size-7 shrink-0",
79
+ children: () =>
80
+ html`${AvatarImage({
81
+ src: props.avatarSrc,
82
+ alt: typeof props.author === "string" ? props.author : "",
83
+ })}${AvatarFallback({ children: props.avatarFallback })}`,
82
84
  })
83
85
  : null
84
86
  }