@c9up/nebula 0.2.2 → 0.2.4

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 (116) hide show
  1. package/README.md +8 -7
  2. package/dist/atoms/Avatar.d.ts +14 -0
  3. package/dist/atoms/Avatar.js +46 -8
  4. package/dist/atoms/Checkbox.d.ts +1 -1
  5. package/dist/atoms/Checkbox.js +1 -1
  6. package/dist/atoms/Input.d.ts +5 -0
  7. package/dist/atoms/Input.js +1 -0
  8. package/dist/cli/add.d.ts +2 -0
  9. package/dist/cli/add.js +4 -1
  10. package/dist/cli/diff.d.ts +2 -0
  11. package/dist/cli/diff.js +4 -1
  12. package/dist/cli/projectConfig.d.ts +16 -0
  13. package/dist/cli/projectConfig.js +61 -0
  14. package/dist/console/AddCommand.js +6 -1
  15. package/dist/console/DiffCommand.js +6 -1
  16. package/dist/lib/children.d.ts +13 -8
  17. package/dist/lib/children.js +5 -0
  18. package/dist/lib/icons.d.ts +8 -0
  19. package/dist/lib/icons.js +8 -0
  20. package/dist/lib/image.js +12 -1
  21. package/dist/molecules/Breadcrumb.d.ts +11 -2
  22. package/dist/molecules/Breadcrumb.js +2 -2
  23. package/dist/molecules/InputOTP.d.ts +14 -0
  24. package/dist/molecules/InputOTP.js +71 -28
  25. package/dist/molecules/Pagination.d.ts +34 -2
  26. package/dist/molecules/Pagination.js +15 -6
  27. package/dist/molecules/PieceMap.d.ts +72 -0
  28. package/dist/molecules/PieceMap.js +78 -0
  29. package/dist/molecules/Resizable.d.ts +2 -0
  30. package/dist/molecules/Resizable.js +1 -1
  31. package/dist/molecules/index.d.ts +4 -3
  32. package/dist/molecules/index.js +2 -1
  33. package/dist/organisms/Calendar.d.ts +13 -0
  34. package/dist/organisms/Calendar.js +2 -2
  35. package/dist/organisms/Carousel.d.ts +8 -0
  36. package/dist/organisms/Carousel.js +8 -5
  37. package/dist/organisms/Combobox.d.ts +13 -0
  38. package/dist/organisms/Combobox.js +5 -2
  39. package/dist/organisms/Command.js +56 -8
  40. package/dist/organisms/DataTable.d.ts +23 -1
  41. package/dist/organisms/DataTable.js +57 -27
  42. package/dist/organisms/DatePicker.d.ts +7 -0
  43. package/dist/organisms/DatePicker.js +2 -1
  44. package/dist/organisms/DateRangePicker.d.ts +2 -0
  45. package/dist/organisms/DateRangePicker.js +2 -1
  46. package/dist/organisms/Dialog.d.ts +13 -3
  47. package/dist/organisms/Dialog.js +12 -5
  48. package/dist/organisms/Form.d.ts +15 -0
  49. package/dist/organisms/Form.js +10 -0
  50. package/dist/organisms/Questionnaire.d.ts +4 -0
  51. package/dist/organisms/Questionnaire.js +5 -2
  52. package/dist/organisms/Select.d.ts +25 -4
  53. package/dist/organisms/Select.js +116 -15
  54. package/dist/organisms/Sheet.d.ts +2 -0
  55. package/dist/organisms/Sheet.js +2 -1
  56. package/dist/organisms/Sidebar.d.ts +10 -2
  57. package/dist/organisms/Sidebar.js +62 -29
  58. package/dist/organisms/Sonner.d.ts +243 -0
  59. package/dist/organisms/Sonner.js +909 -0
  60. package/dist/organisms/Toaster.d.ts +11 -0
  61. package/dist/organisms/Toaster.js +34 -9
  62. package/dist/organisms/Tooltip.d.ts +4 -0
  63. package/dist/organisms/index.d.ts +8 -2
  64. package/dist/organisms/index.js +7 -1
  65. package/dist/primitives/dismissable.d.ts +11 -4
  66. package/dist/primitives/dismissable.js +8 -6
  67. package/dist/primitives/floating.d.ts +5 -1
  68. package/dist/primitives/floating.js +32 -2
  69. package/dist/primitives/menu.js +2 -1
  70. package/dist/primitives/modalSurface.js +70 -36
  71. package/dist/primitives/presence.js +8 -5
  72. package/dist/templates/SettingsLayout.d.ts +2 -0
  73. package/dist/templates/SettingsLayout.js +1 -1
  74. package/nebula.css +2 -2
  75. package/package.json +3 -3
  76. package/registry.json +26 -0
  77. package/src/atoms/Avatar.ts +54 -7
  78. package/src/atoms/Checkbox.ts +1 -1
  79. package/src/atoms/Input.ts +6 -0
  80. package/src/cli/add.ts +7 -1
  81. package/src/cli/diff.ts +7 -1
  82. package/src/cli/projectConfig.ts +71 -0
  83. package/src/console/AddCommand.ts +6 -1
  84. package/src/console/DiffCommand.ts +6 -1
  85. package/src/lib/children.ts +15 -7
  86. package/src/lib/icons.ts +28 -0
  87. package/src/lib/image.ts +13 -1
  88. package/src/molecules/Breadcrumb.ts +15 -4
  89. package/src/molecules/InputOTP.ts +88 -28
  90. package/src/molecules/Pagination.ts +50 -8
  91. package/src/molecules/PieceMap.ts +136 -0
  92. package/src/molecules/Resizable.ts +3 -1
  93. package/src/molecules/index.ts +17 -0
  94. package/src/organisms/Calendar.ts +16 -2
  95. package/src/organisms/Carousel.ts +17 -5
  96. package/src/organisms/Combobox.ts +18 -2
  97. package/src/organisms/Command.ts +66 -7
  98. package/src/organisms/DataTable.ts +95 -30
  99. package/src/organisms/DatePicker.ts +10 -2
  100. package/src/organisms/DateRangePicker.ts +4 -2
  101. package/src/organisms/Dialog.ts +17 -5
  102. package/src/organisms/Form.ts +21 -0
  103. package/src/organisms/Questionnaire.ts +10 -2
  104. package/src/organisms/Select.ts +140 -16
  105. package/src/organisms/Sheet.ts +5 -1
  106. package/src/organisms/Sidebar.ts +62 -23
  107. package/src/organisms/Sonner.ts +1366 -0
  108. package/src/organisms/Toaster.ts +38 -10
  109. package/src/organisms/Tooltip.ts +4 -0
  110. package/src/organisms/index.ts +30 -1
  111. package/src/primitives/dismissable.ts +16 -8
  112. package/src/primitives/floating.ts +40 -3
  113. package/src/primitives/menu.ts +2 -1
  114. package/src/primitives/modalSurface.ts +77 -40
  115. package/src/primitives/presence.ts +12 -9
  116. package/src/templates/SettingsLayout.ts +3 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ Part of **[Ream](https://github.com/C9up/ream)** — a Rust-powered, AdonisJS-co
8
8
 
9
9
  shadcn/ui is React. [Aurora](https://github.com/C9up/aurora) is a tagged-template DOM runtime with signals and no build step. nebula is the shadcn component set — the same markup, the same Tailwind classes, the same behaviour — written for Aurora.
10
10
 
11
- Seventy-four components across four atomic layers, plus the headless behaviour layer Radix would otherwise provide. Every component in shadcn's registry has a counterpart; several are deliberately narrower, and the [parity section](#parity-with-shadcn) says exactly which.
11
+ Seventy-six components across four atomic layers, plus the headless behaviour layer Radix would otherwise provide. Every component in shadcn's registry has a counterpart; several are deliberately narrower, and the [parity section](#parity-with-shadcn) says exactly which.
12
12
 
13
13
  ## Installation
14
14
 
@@ -67,9 +67,9 @@ shadcn stands on Radix, `clsx`, `tailwind-merge`, `class-variance-authority`, `l
67
67
  | `class-variance-authority` | `lib/cva.ts` — reimplemented, and it runs its result through `cn` |
68
68
  | Radix UI | `primitives/` — focus trap, dismissable layers, roving focus, type-ahead, presence, portals |
69
69
  | `@floating-ui/dom` | `primitives/floating.ts` — offset, flip, shift, arrow, available height |
70
- | `lucide-react` | `lib/icons.ts` — the eighteen glyphs the set needs, inlined |
70
+ | `lucide-react` | `lib/icons.ts` — the twenty-six glyphs the set needs, inlined |
71
71
  | `cmdk` | `organisms/Command.ts` |
72
- | `sonner` | `organisms/Toaster.ts` |
72
+ | `sonner` | `organisms/Sonner.ts` |
73
73
  | `react-day-picker` + `date-fns` | `organisms/Calendar.ts` — `Date` and `Intl` |
74
74
  | `@tanstack/react-table` | `organisms/DataTable.ts` — sort, filter, page, select |
75
75
  | `recharts` | `organisms/Chart.ts` — line, area and bar, as inline SVG |
@@ -90,7 +90,8 @@ Two of shadcn's entries have no direct counterpart on purpose. `DirectionProvide
90
90
  | DataTable | TanStack Table (column grouping, virtualisation, pinning, faceted filters, server-side) | sort, filter, page, select — in memory |
91
91
  | Sidebar | ~15 parts | the parts that are not re-skinned atoms — see below |
92
92
  | Carousel | embla (loop, autoplay, N slides per view) | scroll-snap, one slide per view, no loop or autoplay |
93
- | Toaster | Base UI's manager (display priority, anchored toasts, typed payload) — or sonner, with six positions | five variants, promise toasts, update and dedup by id, action, `onClose`, pause on hover, four corners |
93
+ | Sonner | sonner, in full | sonner's `toast` API and Toaster props, six positions, the stack that fans out on hover, rich colours, `Alt+T`; no swipe to dismiss, no `getHistory`, and `toast.promise` returns `{ id, unwrap }` |
94
+ | Toaster (deprecated) | Base UI's manager (display priority, anchored toasts, typed payload) — shadcn has deprecated it for sonner, and so has nebula | five variants, promise toasts, update and dedup by id, action, `onClose`, pause on hover, four corners |
94
95
  | Resizable | arbitrary nesting, persisted layouts, collapse-to-zero | two panes, one handle |
95
96
  | Combobox | single, multi-select and creatable recipes | single-select |
96
97
  | ScrollArea | scrollbars redrawn by Radix | native scrollbars, styled |
@@ -194,13 +195,13 @@ resources/pages/
194
195
  The rule is composition, not complexity. Slider is an atom though it is interactive, because it is one input. Card is a molecule though it is trivial, because it assembles parts.
195
196
 
196
197
  <details>
197
- <summary><strong>All 74 components</strong></summary>
198
+ <summary><strong>All 76 components</strong></summary>
198
199
 
199
200
  **atoms (22)** — AccessibleIcon, AspectRatio, Avatar, Badge, Button, Checkbox, Image, Input, Kbd, Label, Marker, NativeSelect, Progress, ScrollArea, Separator, Skeleton, Slider, Spinner, Switch, Textarea, Toggle, VisuallyHidden
200
201
 
201
- **molecules (23)** — Accordion, Alert, Attachment, Breadcrumb, Bubble, ButtonGroup, Card, Collapsible, Empty, Field, InputGroup, InputOTP, Item, Message, Pagination, Picture, RadioGroup, Resizable, Table, Tabs, ToggleGroup, Toolbar, Typography
202
+ **molecules (24)** — Accordion, Alert, Attachment, Breadcrumb, Bubble, ButtonGroup, Card, Collapsible, Empty, Field, InputGroup, InputOTP, Item, Message, Pagination, Picture, PieceMap, RadioGroup, Resizable, Table, Tabs, ToggleGroup, Toolbar, Typography
202
203
 
203
- **organisms (26)** — AlertDialog, Calendar, Carousel, Chart, Combobox, Command, CommandDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, Dialog, Drawer, DropdownMenu, Form, HoverCard, Menubar, MessageScroller, NavigationMenu, Popover, Questionnaire, Select, Sheet, Sidebar, Toaster, Tooltip
204
+ **organisms (27)** — AlertDialog, Calendar, Carousel, Chart, Combobox, Command, CommandDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, Dialog, Drawer, DropdownMenu, Form, HoverCard, Menubar, MessageScroller, NavigationMenu, Popover, Questionnaire, Select, Sheet, Sidebar, Sonner, Toaster, Tooltip
204
205
 
205
206
  **templates (3)** — AppShell, AuthLayout, SettingsLayout
206
207
 
@@ -26,8 +26,22 @@ export declare const Avatar: (props?: AvatarProps | undefined) => import("@c9up/
26
26
  export interface AvatarImageProps {
27
27
  src?: Reactive<string | undefined>;
28
28
  alt?: Reactive<string>;
29
+ /**
30
+ * Sent with the request for the picture. `"no-referrer"` keeps the page's
31
+ * URL from a host the picture comes from — a user-supplied avatar URL.
32
+ */
33
+ referrerPolicy?: ReferrerPolicy;
34
+ crossOrigin?: "anonymous" | "use-credentials";
29
35
  class?: Reactive<string>;
30
36
  }
37
+ /**
38
+ * The picture, once it has loaded.
39
+ *
40
+ * As Radix's `useImageLoadingStatus`: the source is preloaded off-document,
41
+ * with its referrer policy and CORS mode, and tried again whenever it
42
+ * changes — a broken avatar replaced by a new upload shows the new one. The
43
+ * `<img>` is rendered only once loaded, so a broken picture is never painted.
44
+ */
31
45
  export declare const AvatarImage: (props?: AvatarImageProps | undefined) => import("@c9up/aurora").TemplateResult;
32
46
  export interface AvatarFallbackProps {
33
47
  children?: Slot;
@@ -15,7 +15,7 @@
15
15
  * the fallback reads it, and neither knows the other exists. Radix needs the
16
16
  * same three pieces for the same reason.
17
17
  */
18
- import { component, createContext, html, inject, provide, signal, } from "@c9up/aurora";
18
+ import { component, createContext, effect, html, inject, onMount, provide, signal, } from "@c9up/aurora";
19
19
  import { slot } from "../lib/children.js";
20
20
  import { cn } from "../lib/cn.js";
21
21
  import { read, readOr } from "../lib/props.js";
@@ -35,23 +35,61 @@ export const Avatar = component((props) => {
35
35
  class="${() => cn("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6", read(props.class))}"
36
36
  >${props.children?.()}</span>`;
37
37
  });
38
+ /**
39
+ * The picture, once it has loaded.
40
+ *
41
+ * As Radix's `useImageLoadingStatus`: the source is preloaded off-document,
42
+ * with its referrer policy and CORS mode, and tried again whenever it
43
+ * changes — a broken avatar replaced by a new upload shows the new one. The
44
+ * `<img>` is rendered only once loaded, so a broken picture is never painted.
45
+ */
38
46
  export const AvatarImage = component((props) => {
39
47
  const avatar = inject(AvatarContext);
40
- const hasSrc = () => {
48
+ const source = () => {
41
49
  const src = read(props.src);
42
- return src !== undefined && src !== "";
50
+ return src === undefined || src === "" ? undefined : src;
43
51
  };
44
52
  // Reported during setup, so the fallback built after it already reads the
45
53
  // right state rather than flashing through `absent`.
46
- avatar.setState(hasSrc() ? "pending" : "absent");
47
- return html `${() => hasSrc() && avatar.state() !== "failed"
54
+ avatar.setState(source() === undefined ? "absent" : "pending");
55
+ onMount(() => effect(() => {
56
+ const src = source();
57
+ if (src === undefined) {
58
+ avatar.setState("absent");
59
+ return;
60
+ }
61
+ avatar.setState("pending");
62
+ // A load still in flight for a source it has moved past must not
63
+ // decide the state of the current one.
64
+ let current = true;
65
+ const settle = (next) => {
66
+ if (current)
67
+ avatar.setState(next);
68
+ };
69
+ const image = new Image();
70
+ image.addEventListener("load", () => {
71
+ settle(image.naturalWidth > 0 ? "loaded" : "failed");
72
+ });
73
+ image.addEventListener("error", () => settle("failed"));
74
+ if (props.referrerPolicy !== undefined) {
75
+ image.referrerPolicy = props.referrerPolicy;
76
+ }
77
+ image.crossOrigin = props.crossOrigin ?? null;
78
+ image.src = src;
79
+ if (image.complete && image.naturalWidth > 0)
80
+ settle("loaded");
81
+ return () => {
82
+ current = false;
83
+ };
84
+ }));
85
+ return html `${() => avatar.state() === "loaded"
48
86
  ? html `<img
49
87
  data-slot="avatar-image"
50
- src="${() => read(props.src)}"
88
+ src="${source}"
51
89
  alt="${() => readOr(props.alt, "")}"
90
+ referrerpolicy="${props.referrerPolicy}"
91
+ crossorigin="${props.crossOrigin}"
52
92
  class="${() => cn("aspect-square size-full object-cover", read(props.class))}"
53
- @load="${() => avatar.setState("loaded")}"
54
- @error="${() => avatar.setState("failed")}"
55
93
  />`
56
94
  : null}`;
57
95
  });
@@ -16,7 +16,7 @@
16
16
  * it exists only in the DOM.
17
17
  */
18
18
  import { type Reactive } from "../lib/props.js";
19
- export declare const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20";
19
+ export declare const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:checked:bg-primary dark:indeterminate:bg-primary";
20
20
  export interface CheckboxProps {
21
21
  id?: string;
22
22
  name?: string;
@@ -19,7 +19,7 @@ import { component, html } from "@c9up/aurora";
19
19
  import { cn } from "../lib/cn.js";
20
20
  import { CheckIcon, MinusIcon } from "../lib/icons.js";
21
21
  import { accessor, read } from "../lib/props.js";
22
- export const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20";
22
+ export const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:checked:bg-primary dark:indeterminate:bg-primary";
23
23
  function inputChecked(event) {
24
24
  const target = event.target;
25
25
  return target instanceof HTMLInputElement ? target.checked : false;
@@ -27,6 +27,11 @@ export interface InputProps {
27
27
  invalid?: Reactive<boolean>;
28
28
  /** Names the element describing the error, for screen readers. */
29
29
  describedBy?: Reactive<string | undefined>;
30
+ /**
31
+ * The field's accessible name (`aria-label`), for a field no `<label>`
32
+ * names. A placeholder is not one: it disappears as soon as the user types.
33
+ */
34
+ label?: Reactive<string | undefined>;
30
35
  class?: Reactive<string>;
31
36
  onInput?: (value: string, event: Event) => void;
32
37
  onChange?: (value: string, event: Event) => void;
@@ -37,6 +37,7 @@ export const Input = component((props) => {
37
37
  autocomplete="${props.autocomplete}"
38
38
  aria-invalid="${() => (read(props.invalid) === true ? "true" : undefined)}"
39
39
  aria-describedby="${accessor(props.describedBy, undefined)}"
40
+ aria-label="${accessor(props.label, undefined)}"
40
41
  ?disabled="${accessor(props.disabled, false)}"
41
42
  ?readonly="${accessor(props.readonly, false)}"
42
43
  ?required="${accessor(props.required, false)}"
package/dist/cli/add.d.ts CHANGED
@@ -21,6 +21,8 @@ export interface AddOptions {
21
21
  paths?: Partial<NebulaPaths>;
22
22
  /** Overrides both the detected language and the configured one. */
23
23
  language?: Language;
24
+ /** The configured language: used when the tree says nothing. */
25
+ defaultLanguage?: Language;
24
26
  force?: boolean;
25
27
  /** Print what would happen and write nothing. */
26
28
  dryRun?: boolean;
package/dist/cli/add.js CHANGED
@@ -60,7 +60,10 @@ export function add(options) {
60
60
  const registry = loadRegistry(join(root, "registry.json"));
61
61
  const items = resolveItems(registry, options.names);
62
62
  const target = join(options.cwd, options.paths?.components ?? defaultPaths.components);
63
- const language = options.language ?? detectLanguage(target) ?? "js";
63
+ const language = options.language ??
64
+ detectLanguage(target) ??
65
+ options.defaultLanguage ??
66
+ "js";
64
67
  // The compiled output is what a browser can load. It ships in the package
65
68
  // and `prepublishOnly` rebuilds it, so an installed copy always has it;
66
69
  // inside this workspace it needs `pnpm build` first.
@@ -33,6 +33,8 @@ export interface DiffOptions {
33
33
  cwd: string;
34
34
  paths?: Partial<NebulaPaths>;
35
35
  language?: Language;
36
+ /** The configured language: used when the tree says nothing. */
37
+ defaultLanguage?: Language;
36
38
  }
37
39
  export interface DiffResult {
38
40
  entries: DiffEntry[];
package/dist/cli/diff.js CHANGED
@@ -27,7 +27,10 @@ import { loadRegistry, packageRoot } from "./registry.js";
27
27
  export function diff(options) {
28
28
  const paths = { ...defaultPaths, ...options.paths };
29
29
  const target = join(options.cwd, paths.components);
30
- const language = options.language ?? detectLanguage(target) ?? "js";
30
+ const language = options.language ??
31
+ detectLanguage(target) ??
32
+ options.defaultLanguage ??
33
+ "js";
31
34
  const root = packageRoot(join(options.cwd, "package.json"));
32
35
  const sourceRoot = join(root, language === "ts" ? "src" : "dist");
33
36
  const registry = loadRegistry(join(root, "registry.json"));
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The app's `config/nebula.ts`, as the copying commands read it.
3
+ *
4
+ * shadcn's CLI reads `components.json` on every `add` and `diff`; these read
5
+ * the config file the same way. Imported directly rather than taken from the
6
+ * booted application: the console kernel hands the app — and its config —
7
+ * only to a command that starts it, and starting it opens the connections a
8
+ * file copy has no use for, and fails where they are not running.
9
+ */
10
+ import type { Language, NebulaPaths } from "../config.js";
11
+ export interface ProjectConfig {
12
+ paths?: Partial<NebulaPaths>;
13
+ language?: Language;
14
+ }
15
+ /** The config under `<cwd>/config`, or nothing when the app has none. */
16
+ export declare function loadProjectConfig(cwd: string): Promise<ProjectConfig>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The app's `config/nebula.ts`, as the copying commands read it.
3
+ *
4
+ * shadcn's CLI reads `components.json` on every `add` and `diff`; these read
5
+ * the config file the same way. Imported directly rather than taken from the
6
+ * booted application: the console kernel hands the app — and its config —
7
+ * only to a command that starts it, and starting it opens the connections a
8
+ * file copy has no use for, and fails where they are not running.
9
+ */
10
+ import { existsSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ import { pathToFileURL } from "node:url";
13
+ /** Tried in order; the first that exists is the config. */
14
+ const CANDIDATES = ["nebula.ts", "nebula.js", "nebula.mjs"];
15
+ function isRecord(value) {
16
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17
+ }
18
+ function pathsOf(value, file) {
19
+ if (value === undefined)
20
+ return undefined;
21
+ if (!isRecord(value)) {
22
+ throw new Error(`${file}: \`paths\` must be an object.`);
23
+ }
24
+ const paths = {};
25
+ for (const key of ["components", "css", "output"]) {
26
+ const entry = value[key];
27
+ if (entry === undefined)
28
+ continue;
29
+ if (typeof entry !== "string" || entry === "") {
30
+ throw new Error(`${file}: \`paths.${key}\` must be a non-empty string.`);
31
+ }
32
+ paths[key] = entry;
33
+ }
34
+ return paths;
35
+ }
36
+ function languageOf(value, file) {
37
+ if (value === undefined)
38
+ return undefined;
39
+ if (value === "ts" || value === "js")
40
+ return value;
41
+ throw new Error(`${file}: \`language\` must be "ts" or "js".`);
42
+ }
43
+ /** The config under `<cwd>/config`, or nothing when the app has none. */
44
+ export async function loadProjectConfig(cwd) {
45
+ for (const name of CANDIDATES) {
46
+ const file = join(cwd, "config", name);
47
+ if (!existsSync(file))
48
+ continue;
49
+ const label = `config/${name}`;
50
+ const loaded = await import(pathToFileURL(file).href);
51
+ const config = isRecord(loaded) ? loaded.default : undefined;
52
+ if (!isRecord(config)) {
53
+ throw new Error(`${label} must export its config as the default export.`);
54
+ }
55
+ return {
56
+ paths: pathsOf(config.paths, label),
57
+ language: languageOf(config.language, label),
58
+ };
59
+ }
60
+ return {};
61
+ }
@@ -11,6 +11,7 @@
11
11
  * of a Rust binary, and that binary is not on crates.io.
12
12
  */
13
13
  import { add } from "../cli/add.js";
14
+ import { loadProjectConfig } from "../cli/projectConfig.js";
14
15
  import { argument, flag } from "./contract.js";
15
16
  export default class NebulaAddCommand {
16
17
  static commandName = "nebula:add";
@@ -57,12 +58,16 @@ export default class NebulaAddCommand {
57
58
  process.exitCode = 1;
58
59
  return;
59
60
  }
61
+ const cwd = process.cwd();
62
+ const config = await loadProjectConfig(cwd);
60
63
  const result = add({
61
- cwd: process.cwd(),
64
+ cwd,
62
65
  names: this.components,
63
66
  force: this.force,
64
67
  dryRun: this.dryRun,
68
+ paths: config.paths,
65
69
  language: this.ts ? "ts" : this.js ? "js" : undefined,
70
+ defaultLanguage: config.language,
66
71
  });
67
72
  const out = [""];
68
73
  for (const path of result.written)
@@ -7,6 +7,7 @@
7
7
  * is the one place it becomes visible.
8
8
  */
9
9
  import { diff } from "../cli/diff.js";
10
+ import { loadProjectConfig } from "../cli/projectConfig.js";
10
11
  import { flag } from "./contract.js";
11
12
  /** What each state means, and what to do about it. */
12
13
  const EXPLAIN = {
@@ -44,9 +45,13 @@ export default class NebulaDiffCommand {
44
45
  ts = false;
45
46
  js = false;
46
47
  async run() {
48
+ const cwd = process.cwd();
49
+ const config = await loadProjectConfig(cwd);
47
50
  const result = diff({
48
- cwd: process.cwd(),
51
+ cwd,
52
+ paths: config.paths,
49
53
  language: this.ts ? "ts" : this.js ? "js" : undefined,
54
+ defaultLanguage: config.language,
50
55
  });
51
56
  if (result.entries.length === 0) {
52
57
  process.stdout.write("\n Every copied component matches the installed package.\n\n");
@@ -12,9 +12,11 @@
12
12
  * — Aurora never re-renders a component, so a plain value read at setup is
13
13
  * frozen for the lifetime of the node.
14
14
  */
15
- import type { TemplateResult } from "@c9up/aurora";
15
+ import { type Each, type TemplateResult } from "@c9up/aurora";
16
16
  import type { Reactive } from "./props.js";
17
- export type Child = TemplateResult | Node | string | number | boolean | null | undefined | readonly Child[];
17
+ export type Child = TemplateResult
18
+ /** A keyed list from aurora's `each`, which keeps its rows by key. */
19
+ | Each | Node | string | number | boolean | null | undefined | readonly Child[];
18
20
  /** Content that may be constant or recomputed. */
19
21
  export type Slot = Reactive<Child>;
20
22
  /**
@@ -32,13 +34,16 @@ export type Slot = Reactive<Child>;
32
34
  * `Parts` names it so the type makes the requirement, rather than a blank
33
35
  * surface at runtime.
34
36
  *
35
- * Called ONCE, during setup — the structure of a compound component is fixed,
36
- * and its moving pieces are signals inside the parts.
37
+ * Called ONCE, during setup. What changes goes in an accessor inside it, and
38
+ * parts built there still reach their provider — Aurora calls the accessor
39
+ * with the providers it was written under — so a list of options can follow a
40
+ * signal:
37
41
  *
38
- * The same rule read from the other end: a part that READS context must be
39
- * built eagerly too, so it must not be hidden inside a `Slot`. `Slot` exists
40
- * for content that CHANGES, and the renderer calls it later, by which time
41
- * there is no context left to read:
42
+ * SelectContent({ children: () => html`${() => roles().map((r) => SelectItem(…))}` })
43
+ *
44
+ * A part that has to be KNOWN at setup is the exception. `DialogTitle` names
45
+ * the panel, and the panel reads whether there is a title before it renders
46
+ * its children, so a title built later in an accessor leaves it unnamed:
42
47
  *
43
48
  * DialogHeader({ children: html`${DialogTitle(…)}` }) // ✓ a value
44
49
  * DialogHeader({ children: () => html`${DialogTitle(…)}` }) // ✗ too late
@@ -12,6 +12,7 @@
12
12
  * — Aurora never re-renders a component, so a plain value read at setup is
13
13
  * frozen for the lifetime of the node.
14
14
  */
15
+ import { isEach } from "@c9up/aurora";
15
16
  /**
16
17
  * Bind content into a template so it stays live.
17
18
  *
@@ -23,5 +24,9 @@
23
24
  export function slot(content) {
24
25
  if (content === undefined)
25
26
  return () => null;
27
+ // A keyed list is a function too, but it is content, not an accessor for
28
+ // content: handed over as the value, it keeps its rows by key.
29
+ if (isEach(content))
30
+ return () => content;
26
31
  return typeof content === "function" ? content : () => content;
27
32
  }
@@ -40,5 +40,13 @@ export declare const ArrowRightIcon: (props?: IconProps) => TemplateResult;
40
40
  export declare const CalendarIcon: (props?: IconProps) => TemplateResult;
41
41
  export declare const PanelLeftIcon: (props?: IconProps) => TemplateResult;
42
42
  export declare const GripVerticalIcon: (props?: IconProps) => TemplateResult;
43
+ /** Lucide `circle-check` — shadcn's Sonner success icon. */
44
+ export declare const CircleCheckIcon: (props?: IconProps) => TemplateResult;
45
+ /** Lucide `info` — shadcn's Sonner info icon. */
46
+ export declare const InfoIcon: (props?: IconProps) => TemplateResult;
47
+ /** Lucide `triangle-alert` — shadcn's Sonner warning icon. */
48
+ export declare const TriangleAlertIcon: (props?: IconProps) => TemplateResult;
49
+ /** Lucide `octagon-x` — shadcn's Sonner error icon. */
50
+ export declare const OctagonXIcon: (props?: IconProps) => TemplateResult;
43
51
  /** The arc Lucide uses for `loader-circle`; spun by the Spinner's animation. */
44
52
  export declare const LoaderIcon: (props?: IconProps) => TemplateResult;
package/dist/lib/icons.js CHANGED
@@ -75,5 +75,13 @@ export const GripVerticalIcon = (props) => svg(html `<circle cx="9" cy="12" r="1
75
75
  cy="19"
76
76
  r="1"
77
77
  />`, props);
78
+ /** Lucide `circle-check` — shadcn's Sonner success icon. */
79
+ export const CircleCheckIcon = (props) => svg(html `<circle cx="12" cy="12" r="10" /><path d="m16 9-5.5 5.5L8 12" />`, props);
80
+ /** Lucide `info` — shadcn's Sonner info icon. */
81
+ export const InfoIcon = (props) => svg(html `<circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" />`, props);
82
+ /** Lucide `triangle-alert` — shadcn's Sonner warning icon. */
83
+ export const TriangleAlertIcon = (props) => svg(html `<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /><path d="M12 9v4" /><path d="M12 17h.01" />`, props);
84
+ /** Lucide `octagon-x` — shadcn's Sonner error icon. */
85
+ export const OctagonXIcon = (props) => svg(html `<path d="m15 9-6 6" /><path d="M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z" /><path d="m9 9 6 6" />`, props);
78
86
  /** The arc Lucide uses for `loader-circle`; spun by the Spinner's animation. */
79
87
  export const LoaderIcon = (props) => svg(html `<path d="M21 12a9 9 0 1 1-6.219-8.56" />`, props);
package/dist/lib/image.js CHANGED
@@ -224,6 +224,17 @@ let endpoint = "/__image";
224
224
  export function setImageEndpoint(path) {
225
225
  endpoint = path;
226
226
  }
227
+ /**
228
+ * A root-relative `src` as the path under the endpoint's public roots.
229
+ *
230
+ * `/photos/hero.png` is how a page names a public file, and the endpoint
231
+ * resolves `src` inside its roots, refusing an absolute path: sent as is,
232
+ * every variant is a 404. Exactly one slash goes, so a protocol-relative
233
+ * `//host/…` stays what it is and is left to an application's own resolver.
234
+ */
235
+ function relativeToRoots(src) {
236
+ return src.startsWith("/") && !src.startsWith("//") ? src.slice(1) : src;
237
+ }
227
238
  /**
228
239
  * The resolver used when an application installs none.
229
240
  *
@@ -233,7 +244,7 @@ export function setImageEndpoint(path) {
233
244
  */
234
245
  export const defaultImageResolver = (src, transform) => {
235
246
  const params = new URLSearchParams({
236
- src,
247
+ src: relativeToRoots(src),
237
248
  w: String(Math.round(transform.width)),
238
249
  });
239
250
  if (transform.format !== undefined)
@@ -26,7 +26,11 @@ export interface BreadcrumbProps {
26
26
  children?: Slot;
27
27
  class?: Reactive<string>;
28
28
  }
29
- export declare const Breadcrumb: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
29
+ export interface BreadcrumbNavProps extends BreadcrumbProps {
30
+ /** The `<nav>`'s accessible name. Default `"breadcrumb"`. */
31
+ "aria-label"?: string;
32
+ }
33
+ export declare const Breadcrumb: (props?: BreadcrumbNavProps | undefined) => import("@c9up/aurora").TemplateResult;
30
34
  export declare const BreadcrumbList: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
31
35
  export declare const BreadcrumbItem: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
32
36
  export interface BreadcrumbLinkProps extends BreadcrumbProps {
@@ -43,5 +47,10 @@ export declare const BreadcrumbLink: (props?: BreadcrumbLinkProps | undefined) =
43
47
  export declare const BreadcrumbPage: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
44
48
  /** The chevron. Defaults to one; give children to replace it. */
45
49
  export declare const BreadcrumbSeparator: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
50
+ export interface BreadcrumbEllipsisProps {
51
+ /** The hidden text. Default `"More"`. */
52
+ label?: string;
53
+ class?: Reactive<string>;
54
+ }
46
55
  /** Stands in for ancestors that did not fit. */
47
- export declare const BreadcrumbEllipsis: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
56
+ export declare const BreadcrumbEllipsis: (props?: BreadcrumbEllipsisProps | undefined) => import("@c9up/aurora").TemplateResult;
@@ -27,7 +27,7 @@ import { ChevronRightIcon, MoreHorizontalIcon } from "../lib/icons.js";
27
27
  import { read } from "../lib/props.js";
28
28
  export const Breadcrumb = component((props) => html `<nav
29
29
  data-slot="breadcrumb"
30
- aria-label="breadcrumb"
30
+ aria-label="${props["aria-label"] ?? "breadcrumb"}"
31
31
  class="${() => cn(read(props.class))}"
32
32
  >${slot(props.children)}</nav>`);
33
33
  export const BreadcrumbList = component((props) => html `<ol
@@ -70,4 +70,4 @@ export const BreadcrumbEllipsis = component((props) => html `<span
70
70
  role="presentation"
71
71
  aria-hidden="true"
72
72
  class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
73
- >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">More</span></span>`);
73
+ >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? "More"}</span></span>`);
@@ -19,9 +19,23 @@
19
19
  */
20
20
  import type { Parts, Slot } from "../lib/children.js";
21
21
  import { type Reactive } from "../lib/props.js";
22
+ /** input-otp's patterns, for the `pattern` prop. */
23
+ export declare const REGEXP_ONLY_DIGITS = "^\\d+$";
24
+ export declare const REGEXP_ONLY_CHARS = "^[a-zA-Z]+$";
25
+ export declare const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]+$";
22
26
  export interface InputOTPProps {
23
27
  /** Number of boxes. Default `6` — and it must match the slots built. */
24
28
  length?: number;
29
+ /**
30
+ * What the code may hold, tested against the whole value as input-otp
31
+ * does: a character or a fill that would not match is refused. None by
32
+ * default, as input-otp; `REGEXP_ONLY_DIGITS` for a numeric code.
33
+ */
34
+ pattern?: RegExp | string;
35
+ /** The on-screen keyboard. Default `"numeric"`. */
36
+ inputMode?: "numeric" | "text";
37
+ /** Each box's accessible name from its position. Default `"Character 2 of 6"`. */
38
+ slotLabel?: (position: number, length: number) => string;
25
39
  name?: string;
26
40
  disabled?: Reactive<boolean>;
27
41
  class?: Reactive<string>;