@c9up/nebula 0.2.3 → 0.2.5
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.
- package/README.md +9 -8
- package/dist/atoms/AspectRatio.d.ts +10 -4
- package/dist/atoms/AspectRatio.js +21 -6
- package/dist/atoms/Avatar.d.ts +14 -0
- package/dist/atoms/Avatar.js +46 -8
- package/dist/atoms/NativeSelect.d.ts +10 -0
- package/dist/atoms/NativeSelect.js +4 -1
- package/dist/atoms/Progress.d.ts +9 -1
- package/dist/atoms/Progress.js +21 -5
- package/dist/atoms/Switch.d.ts +7 -1
- package/dist/atoms/Switch.js +7 -1
- package/dist/cli/add.d.ts +2 -0
- package/dist/cli/add.js +4 -1
- package/dist/cli/diff.d.ts +48 -0
- package/dist/cli/diff.js +77 -3
- package/dist/cli/projectConfig.d.ts +16 -0
- package/dist/cli/projectConfig.js +61 -0
- package/dist/console/AddCommand.js +6 -1
- package/dist/console/DiffCommand.js +12 -12
- package/dist/lib/icons.d.ts +8 -0
- package/dist/lib/icons.js +8 -0
- package/dist/lib/image.js +12 -1
- package/dist/molecules/Accordion.js +1 -2
- package/dist/molecules/Collapsible.js +1 -2
- package/dist/molecules/InputOTP.d.ts +12 -0
- package/dist/molecules/InputOTP.js +68 -27
- package/dist/molecules/Resizable.d.ts +6 -0
- package/dist/molecules/Resizable.js +8 -2
- package/dist/molecules/index.d.ts +1 -1
- package/dist/molecules/index.js +1 -1
- package/dist/organisms/AlertDialog.js +4 -5
- package/dist/organisms/Chart.d.ts +103 -15
- package/dist/organisms/Chart.js +518 -99
- package/dist/organisms/Combobox.d.ts +13 -0
- package/dist/organisms/Combobox.js +5 -2
- package/dist/organisms/Command.js +56 -8
- package/dist/organisms/Dialog.js +7 -7
- package/dist/organisms/Form.d.ts +15 -0
- package/dist/organisms/Form.js +10 -0
- package/dist/organisms/Select.d.ts +6 -4
- package/dist/organisms/Select.js +1 -0
- package/dist/organisms/Sidebar.d.ts +9 -9
- package/dist/organisms/Sidebar.js +77 -32
- package/dist/organisms/Sonner.d.ts +243 -0
- package/dist/organisms/Sonner.js +916 -0
- package/dist/organisms/Toaster.d.ts +9 -0
- package/dist/organisms/Toaster.js +28 -5
- package/dist/organisms/Tooltip.d.ts +4 -0
- package/dist/organisms/index.d.ts +7 -1
- package/dist/organisms/index.js +7 -1
- package/dist/primitives/dismissable.d.ts +11 -4
- package/dist/primitives/dismissable.js +8 -6
- package/dist/primitives/floating.d.ts +5 -1
- package/dist/primitives/floating.js +8 -1
- package/dist/primitives/menu.js +2 -1
- package/dist/primitives/menuParts.js +3 -3
- package/dist/primitives/modalSurface.js +70 -36
- package/dist/primitives/portal.d.ts +15 -0
- package/dist/primitives/portal.js +18 -1
- package/dist/primitives/presence.js +8 -5
- package/nebula.css +2 -2
- package/package.json +1 -1
- package/registry.json +13 -0
- package/src/atoms/AspectRatio.ts +21 -6
- package/src/atoms/Avatar.ts +54 -7
- package/src/atoms/NativeSelect.ts +14 -1
- package/src/atoms/Progress.ts +21 -5
- package/src/atoms/Switch.ts +7 -1
- package/src/cli/add.ts +7 -1
- package/src/cli/diff.ts +130 -3
- package/src/cli/projectConfig.ts +71 -0
- package/src/console/AddCommand.ts +6 -1
- package/src/console/DiffCommand.ts +18 -16
- package/src/lib/icons.ts +28 -0
- package/src/lib/image.ts +13 -1
- package/src/molecules/Accordion.ts +1 -2
- package/src/molecules/Collapsible.ts +1 -3
- package/src/molecules/InputOTP.ts +81 -27
- package/src/molecules/Resizable.ts +8 -2
- package/src/molecules/index.ts +3 -0
- package/src/organisms/AlertDialog.ts +3 -5
- package/src/organisms/Chart.ts +633 -125
- package/src/organisms/Combobox.ts +18 -2
- package/src/organisms/Command.ts +66 -7
- package/src/organisms/Dialog.ts +6 -7
- package/src/organisms/Form.ts +21 -0
- package/src/organisms/Select.ts +7 -4
- package/src/organisms/Sidebar.ts +75 -25
- package/src/organisms/Sonner.ts +1373 -0
- package/src/organisms/Toaster.ts +30 -6
- package/src/organisms/Tooltip.ts +4 -0
- package/src/organisms/index.ts +29 -0
- package/src/primitives/dismissable.ts +16 -8
- package/src/primitives/floating.ts +13 -2
- package/src/primitives/menu.ts +2 -1
- package/src/primitives/menuParts.ts +3 -3
- package/src/primitives/modalSurface.ts +77 -40
- package/src/primitives/portal.ts +27 -1
- package/src/primitives/presence.ts +12 -9
|
@@ -44,7 +44,17 @@ export interface NativeSelectProps {
|
|
|
44
44
|
required?: Reactive<boolean>;
|
|
45
45
|
invalid?: Reactive<boolean>;
|
|
46
46
|
describedBy?: Reactive<string | undefined>;
|
|
47
|
+
/** Styles the `<select>` itself. To change the control's width, use `wrapperClass`. */
|
|
47
48
|
class?: Reactive<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Sizes the control: the wrapper the chevron is positioned against.
|
|
51
|
+
*
|
|
52
|
+
* A width through `class` narrows the `<select>` and leaves the chevron at
|
|
53
|
+
* the end of a full-width wrapper, with empty space between the control and
|
|
54
|
+
* its own indicator. Merged over the wrapper's `w-full`, so `w-40` here
|
|
55
|
+
* replaces it rather than competing with it.
|
|
56
|
+
*/
|
|
57
|
+
wrapperClass?: Reactive<string>;
|
|
48
58
|
onValueChange?: (value: string, event: Event) => void;
|
|
49
59
|
}
|
|
50
60
|
|
|
@@ -95,7 +105,10 @@ export const NativeSelect = component<NativeSelectProps>((props) => {
|
|
|
95
105
|
${option.label}
|
|
96
106
|
</option>`;
|
|
97
107
|
|
|
98
|
-
return html`<div
|
|
108
|
+
return html`<div
|
|
109
|
+
data-slot="native-select"
|
|
110
|
+
class="${() => cn("relative inline-flex w-full items-center", read(props.wrapperClass))}"
|
|
111
|
+
>
|
|
99
112
|
<select
|
|
100
113
|
id="${props.id}"
|
|
101
114
|
name="${props.name}"
|
package/src/atoms/Progress.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Progress — a determinate progress bar.
|
|
3
3
|
*
|
|
4
|
-
* The fill is a full-width
|
|
4
|
+
* The fill is a full-width shape translated left by the remaining percentage,
|
|
5
5
|
* rather than a width animation. Transforms are composited off the main
|
|
6
6
|
* thread; animating `width` relayouts the bar on every frame, which is visible
|
|
7
7
|
* on a long upload.
|
|
8
8
|
*
|
|
9
|
+
* The shape is an SVG `<rect>` moved by its `transform` ATTRIBUTE, not a `<div>`
|
|
10
|
+
* moved by a `style` attribute. A Content-Security-Policy without
|
|
11
|
+
* `'unsafe-inline'` blocks every `style` attribute; an SVG presentation
|
|
12
|
+
* attribute is not a style attribute and passes. A `.style` property would pass
|
|
13
|
+
* too, but the server does not write properties, so the bar would read full
|
|
14
|
+
* until hydration — the attribute is in the server's markup, right from the
|
|
15
|
+
* first paint.
|
|
16
|
+
*
|
|
9
17
|
* A `value` of `null` means indeterminate, and drops `aria-valuenow` — the
|
|
10
18
|
* ARIA spec is explicit that an absent value is how "unknown progress" is
|
|
11
19
|
* expressed, and reporting `0` instead tells the user it has not started.
|
|
@@ -55,10 +63,18 @@ export const Progress = component<ProgressProps>((props) => {
|
|
|
55
63
|
read(props.class),
|
|
56
64
|
)}"
|
|
57
65
|
>
|
|
58
|
-
|
|
66
|
+
<svg
|
|
59
67
|
data-slot="progress-indicator"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
aria-hidden="true"
|
|
69
|
+
focusable="false"
|
|
70
|
+
viewBox="0 0 100 1"
|
|
71
|
+
preserveAspectRatio="none"
|
|
72
|
+
class="fill-primary block h-full w-full"
|
|
73
|
+
><rect
|
|
74
|
+
width="100"
|
|
75
|
+
height="1"
|
|
76
|
+
transform="${() => `translate(${percent() - 100} 0)`}"
|
|
77
|
+
class="transition-transform"
|
|
78
|
+
/></svg>
|
|
63
79
|
</div>`;
|
|
64
80
|
});
|
package/src/atoms/Switch.ts
CHANGED
|
@@ -15,8 +15,14 @@ import { component, html } from "@c9up/aurora";
|
|
|
15
15
|
import { cn } from "../lib/cn.js";
|
|
16
16
|
import { accessor, type Reactive, read } from "../lib/props.js";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The off fill names the unchecked state, as upstream's `data-[state=unchecked]:`
|
|
20
|
+
* does. Left bare, `dark:bg-input/80` weighed as much as `checked:bg-primary`
|
|
21
|
+
* and came later in the stylesheet, so a switch that was on looked off in the
|
|
22
|
+
* dark theme.
|
|
23
|
+
*/
|
|
18
24
|
export const switchTrackClasses =
|
|
19
|
-
"peer absolute inset-0 size-full appearance-none rounded-full border border-transparent
|
|
25
|
+
"peer absolute inset-0 size-full appearance-none rounded-full border border-transparent shadow-xs outline-none transition-colors checked:bg-primary not-checked:bg-input dark:not-checked:bg-input/80 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50";
|
|
20
26
|
|
|
21
27
|
export interface SwitchProps {
|
|
22
28
|
id?: string;
|
package/src/cli/add.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface AddOptions {
|
|
|
27
27
|
paths?: Partial<NebulaPaths>;
|
|
28
28
|
/** Overrides both the detected language and the configured one. */
|
|
29
29
|
language?: Language;
|
|
30
|
+
/** The configured language: used when the tree says nothing. */
|
|
31
|
+
defaultLanguage?: Language;
|
|
30
32
|
force?: boolean;
|
|
31
33
|
/** Print what would happen and write nothing. */
|
|
32
34
|
dryRun?: boolean;
|
|
@@ -80,7 +82,11 @@ export function add(options: AddOptions): AddResult {
|
|
|
80
82
|
options.cwd,
|
|
81
83
|
options.paths?.components ?? defaultPaths.components,
|
|
82
84
|
);
|
|
83
|
-
const language =
|
|
85
|
+
const language =
|
|
86
|
+
options.language ??
|
|
87
|
+
detectLanguage(target) ??
|
|
88
|
+
options.defaultLanguage ??
|
|
89
|
+
"js";
|
|
84
90
|
|
|
85
91
|
// The compiled output is what a browser can load. It ships in the package
|
|
86
92
|
// and `prepublishOnly` rebuilds it, so an installed copy always has it;
|
package/src/cli/diff.ts
CHANGED
|
@@ -18,7 +18,13 @@ import { join } from "node:path";
|
|
|
18
18
|
import { defaultPaths, type Language, type NebulaPaths } from "../config.js";
|
|
19
19
|
import { detectLanguage } from "./add.js";
|
|
20
20
|
import { hashOf, readManifest } from "./manifest.js";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
loadRegistry,
|
|
23
|
+
packageRoot,
|
|
24
|
+
type Registry,
|
|
25
|
+
type RegistryItem,
|
|
26
|
+
resolveItems,
|
|
27
|
+
} from "./registry.js";
|
|
22
28
|
|
|
23
29
|
export type DiffState =
|
|
24
30
|
/** Copy, record and package all agree. */
|
|
@@ -42,11 +48,36 @@ export interface DiffOptions {
|
|
|
42
48
|
cwd: string;
|
|
43
49
|
paths?: Partial<NebulaPaths>;
|
|
44
50
|
language?: Language;
|
|
51
|
+
/** The configured language: used when the tree says nothing. */
|
|
52
|
+
defaultLanguage?: Language;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* How to bring the outdated files up to date with `nebula:add --force`.
|
|
57
|
+
*
|
|
58
|
+
* `nebula:add` takes registry names, never file paths: a shared file such as
|
|
59
|
+
* `lib/icons.ts` or `primitives/menu.ts` has no name of its own and travels
|
|
60
|
+
* with the components that use it. So the outdated files are mapped back to
|
|
61
|
+
* the installed components whose copy would bring them along.
|
|
62
|
+
*/
|
|
63
|
+
export interface UpdatePlan {
|
|
64
|
+
/**
|
|
65
|
+
* Registry names to pass to `nebula:add --force`, sorted. Each one re-copies
|
|
66
|
+
* only files that are outdated or untouched — never one you edited, and
|
|
67
|
+
* never one whose history is unknown.
|
|
68
|
+
*/
|
|
69
|
+
components: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Outdated files none of those names can reach without overwriting a file
|
|
72
|
+
* you changed, or that no installed component carries any more.
|
|
73
|
+
*/
|
|
74
|
+
uncovered: string[];
|
|
45
75
|
}
|
|
46
76
|
|
|
47
77
|
export interface DiffResult {
|
|
48
78
|
entries: DiffEntry[];
|
|
49
79
|
language: Language;
|
|
80
|
+
update: UpdatePlan;
|
|
50
81
|
}
|
|
51
82
|
|
|
52
83
|
/**
|
|
@@ -58,7 +89,11 @@ export interface DiffResult {
|
|
|
58
89
|
export function diff(options: DiffOptions): DiffResult {
|
|
59
90
|
const paths = { ...defaultPaths, ...options.paths };
|
|
60
91
|
const target = join(options.cwd, paths.components);
|
|
61
|
-
const language =
|
|
92
|
+
const language =
|
|
93
|
+
options.language ??
|
|
94
|
+
detectLanguage(target) ??
|
|
95
|
+
options.defaultLanguage ??
|
|
96
|
+
"js";
|
|
62
97
|
|
|
63
98
|
const root = packageRoot(join(options.cwd, "package.json"));
|
|
64
99
|
const sourceRoot = join(root, language === "ts" ? "src" : "dist");
|
|
@@ -88,7 +123,99 @@ export function diff(options: DiffOptions): DiffResult {
|
|
|
88
123
|
}
|
|
89
124
|
|
|
90
125
|
entries.sort((a, b) => a.file.localeCompare(b.file));
|
|
91
|
-
|
|
126
|
+
const toCopy = (file: string): string =>
|
|
127
|
+
language === "ts" ? file : file.replace(/\.ts$/, ".js");
|
|
128
|
+
const update = planUpdate(registry, entries, {
|
|
129
|
+
installed: (item) =>
|
|
130
|
+
existsSync(join(target, toCopy(`${item.layer}/${item.title}.ts`))),
|
|
131
|
+
toCopy,
|
|
132
|
+
});
|
|
133
|
+
return { entries, language, update };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface PlanOptions {
|
|
137
|
+
/**
|
|
138
|
+
* Whether the project has this component. Its own file — the registry
|
|
139
|
+
* names an item after it — being in the tree is what says so.
|
|
140
|
+
*/
|
|
141
|
+
installed: (item: RegistryItem) => boolean;
|
|
142
|
+
/** A registry path (`.ts`) as it is spelled in the copied tree. */
|
|
143
|
+
toCopy: (file: string) => string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Pick the registry names that update the outdated files, losing nothing.
|
|
148
|
+
*
|
|
149
|
+
* A component qualifies when it is installed and everything `nebula:add
|
|
150
|
+
* --force` would rewrite for it — its files and those of every component it
|
|
151
|
+
* pulls in — is outdated or untouched. One edited, conflicting or unknown file
|
|
152
|
+
* in that set rules it out: the suggestion is printed as safe to run as is.
|
|
153
|
+
*
|
|
154
|
+
* Among those, a greedy cover keeps the command short: the component reaching
|
|
155
|
+
* the most outdated files still left goes first, ties broken by name. A shared
|
|
156
|
+
* file then rides along with a component that needed re-copying anyway, rather
|
|
157
|
+
* than every component that happens to import it being listed.
|
|
158
|
+
*/
|
|
159
|
+
export function planUpdate(
|
|
160
|
+
registry: Registry,
|
|
161
|
+
entries: readonly DiffEntry[],
|
|
162
|
+
options: PlanOptions,
|
|
163
|
+
): UpdatePlan {
|
|
164
|
+
const states = new Map(entries.map((entry) => [entry.file, entry.state]));
|
|
165
|
+
const outdated = new Set(
|
|
166
|
+
entries
|
|
167
|
+
.filter((entry) => entry.state === "outdated")
|
|
168
|
+
.map((entry) => entry.file),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const candidates: { name: string; reaches: Set<string> }[] = [];
|
|
172
|
+
for (const item of registry.items) {
|
|
173
|
+
if (!options.installed(item)) continue;
|
|
174
|
+
const rewritten = new Set(
|
|
175
|
+
resolveItems(registry, [item.name]).flatMap((entry) =>
|
|
176
|
+
entry.files.map(options.toCopy),
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
const lossy = [...rewritten].some((file) => {
|
|
180
|
+
const state = states.get(file);
|
|
181
|
+
return state !== undefined && state !== "outdated";
|
|
182
|
+
});
|
|
183
|
+
if (lossy) continue;
|
|
184
|
+
const reaches = new Set(
|
|
185
|
+
[...rewritten].filter((file) => outdated.has(file)),
|
|
186
|
+
);
|
|
187
|
+
if (reaches.size > 0) candidates.push({ name: item.name, reaches });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const left = new Set(outdated);
|
|
191
|
+
const components: string[] = [];
|
|
192
|
+
while (left.size > 0) {
|
|
193
|
+
let best: { name: string; count: number } | undefined;
|
|
194
|
+
for (const candidate of candidates) {
|
|
195
|
+
let count = 0;
|
|
196
|
+
for (const file of candidate.reaches) if (left.has(file)) count += 1;
|
|
197
|
+
if (count === 0) continue;
|
|
198
|
+
if (
|
|
199
|
+
best === undefined ||
|
|
200
|
+
count > best.count ||
|
|
201
|
+
(count === best.count && candidate.name < best.name)
|
|
202
|
+
) {
|
|
203
|
+
best = { name: candidate.name, count };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (best === undefined) break;
|
|
207
|
+
const chosen = best.name;
|
|
208
|
+
components.push(chosen);
|
|
209
|
+
for (const candidate of candidates) {
|
|
210
|
+
if (candidate.name !== chosen) continue;
|
|
211
|
+
for (const file of candidate.reaches) left.delete(file);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
components: components.sort(),
|
|
217
|
+
uncovered: [...left].sort(),
|
|
218
|
+
};
|
|
92
219
|
}
|
|
93
220
|
|
|
94
221
|
function compare(hashes: {
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { pathToFileURL } from "node:url";
|
|
14
|
+
import type { Language, NebulaPaths } from "../config.js";
|
|
15
|
+
|
|
16
|
+
export interface ProjectConfig {
|
|
17
|
+
paths?: Partial<NebulaPaths>;
|
|
18
|
+
language?: Language;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Tried in order; the first that exists is the config. */
|
|
22
|
+
const CANDIDATES = ["nebula.ts", "nebula.js", "nebula.mjs"];
|
|
23
|
+
|
|
24
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function pathsOf(
|
|
29
|
+
value: unknown,
|
|
30
|
+
file: string,
|
|
31
|
+
): Partial<NebulaPaths> | undefined {
|
|
32
|
+
if (value === undefined) return undefined;
|
|
33
|
+
if (!isRecord(value)) {
|
|
34
|
+
throw new Error(`${file}: \`paths\` must be an object.`);
|
|
35
|
+
}
|
|
36
|
+
const paths: Partial<NebulaPaths> = {};
|
|
37
|
+
for (const key of ["components", "css", "output"] as const) {
|
|
38
|
+
const entry = value[key];
|
|
39
|
+
if (entry === undefined) continue;
|
|
40
|
+
if (typeof entry !== "string" || entry === "") {
|
|
41
|
+
throw new Error(`${file}: \`paths.${key}\` must be a non-empty string.`);
|
|
42
|
+
}
|
|
43
|
+
paths[key] = entry;
|
|
44
|
+
}
|
|
45
|
+
return paths;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function languageOf(value: unknown, file: string): Language | undefined {
|
|
49
|
+
if (value === undefined) return undefined;
|
|
50
|
+
if (value === "ts" || value === "js") return value;
|
|
51
|
+
throw new Error(`${file}: \`language\` must be "ts" or "js".`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The config under `<cwd>/config`, or nothing when the app has none. */
|
|
55
|
+
export async function loadProjectConfig(cwd: string): Promise<ProjectConfig> {
|
|
56
|
+
for (const name of CANDIDATES) {
|
|
57
|
+
const file = join(cwd, "config", name);
|
|
58
|
+
if (!existsSync(file)) continue;
|
|
59
|
+
const label = `config/${name}`;
|
|
60
|
+
const loaded: unknown = await import(pathToFileURL(file).href);
|
|
61
|
+
const config = isRecord(loaded) ? loaded.default : undefined;
|
|
62
|
+
if (!isRecord(config)) {
|
|
63
|
+
throw new Error(`${label} must export its config as the default export.`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
paths: pathsOf(config.paths, label),
|
|
67
|
+
language: languageOf(config.language, label),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { add } from "../cli/add.js";
|
|
15
|
+
import { loadProjectConfig } from "../cli/projectConfig.js";
|
|
15
16
|
import { argument, flag, type NebulaCommandClass } from "./contract.js";
|
|
16
17
|
|
|
17
18
|
export default class NebulaAddCommand {
|
|
@@ -70,12 +71,16 @@ export default class NebulaAddCommand {
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
const cwd = process.cwd();
|
|
75
|
+
const config = await loadProjectConfig(cwd);
|
|
73
76
|
const result = add({
|
|
74
|
-
cwd
|
|
77
|
+
cwd,
|
|
75
78
|
names: this.components,
|
|
76
79
|
force: this.force,
|
|
77
80
|
dryRun: this.dryRun,
|
|
81
|
+
paths: config.paths,
|
|
78
82
|
language: this.ts ? "ts" : this.js ? "js" : undefined,
|
|
83
|
+
defaultLanguage: config.language,
|
|
79
84
|
});
|
|
80
85
|
|
|
81
86
|
const out: string[] = [""];
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { type DiffState, diff } from "../cli/diff.js";
|
|
11
|
+
import { loadProjectConfig } from "../cli/projectConfig.js";
|
|
11
12
|
import { flag, type NebulaCommandClass } from "./contract.js";
|
|
12
13
|
|
|
13
14
|
/** What each state means, and what to do about it. */
|
|
@@ -54,9 +55,13 @@ export default class NebulaDiffCommand {
|
|
|
54
55
|
js = false;
|
|
55
56
|
|
|
56
57
|
async run(): Promise<void> {
|
|
58
|
+
const cwd = process.cwd();
|
|
59
|
+
const config = await loadProjectConfig(cwd);
|
|
57
60
|
const result = diff({
|
|
58
|
-
cwd
|
|
61
|
+
cwd,
|
|
62
|
+
paths: config.paths,
|
|
59
63
|
language: this.ts ? "ts" : this.js ? "js" : undefined,
|
|
64
|
+
defaultLanguage: config.language,
|
|
60
65
|
});
|
|
61
66
|
|
|
62
67
|
if (result.entries.length === 0) {
|
|
@@ -74,14 +79,20 @@ export default class NebulaDiffCommand {
|
|
|
74
79
|
);
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
);
|
|
80
|
-
if (outdated.length > 0) {
|
|
82
|
+
const { components, uncovered } = result.update;
|
|
83
|
+
if (components.length > 0) {
|
|
81
84
|
out.push(
|
|
82
85
|
"",
|
|
83
|
-
|
|
84
|
-
` ream nebula:add --force ${
|
|
86
|
+
" Outdated files that can be updated with no loss — the components that carry them:",
|
|
87
|
+
` ream nebula:add --force ${components.join(" ")}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (uncovered.length > 0) {
|
|
91
|
+
out.push(
|
|
92
|
+
"",
|
|
93
|
+
" Outdated, but no installed component can re-copy them without overwriting",
|
|
94
|
+
" a file you changed (or none carries them any more). Compare by hand:",
|
|
95
|
+
...uncovered.map((file) => ` ${file}`),
|
|
85
96
|
);
|
|
86
97
|
}
|
|
87
98
|
out.push("");
|
|
@@ -89,15 +100,6 @@ export default class NebulaDiffCommand {
|
|
|
89
100
|
}
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
/** `molecules/InputGroup.js` → `input-group`, as the registry names it. */
|
|
93
|
-
function componentOf(entry: { file: string }): string {
|
|
94
|
-
const base = entry.file.split("/").pop() ?? entry.file;
|
|
95
|
-
return base
|
|
96
|
-
.replace(/\.(ts|js)$/, "")
|
|
97
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
98
|
-
.toLowerCase();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
103
|
// Fails the build if the class drifts from what the kernel dispatches against.
|
|
102
104
|
const _contract: NebulaCommandClass = NebulaDiffCommand;
|
|
103
105
|
void _contract;
|
package/src/lib/icons.ts
CHANGED
|
@@ -133,6 +133,34 @@ export const GripVerticalIcon = (props?: IconProps): TemplateResult =>
|
|
|
133
133
|
props,
|
|
134
134
|
);
|
|
135
135
|
|
|
136
|
+
/** Lucide `circle-check` — shadcn's Sonner success icon. */
|
|
137
|
+
export const CircleCheckIcon = (props?: IconProps): TemplateResult =>
|
|
138
|
+
svg(
|
|
139
|
+
html`<circle cx="12" cy="12" r="10" /><path d="m16 9-5.5 5.5L8 12" />`,
|
|
140
|
+
props,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
/** Lucide `info` — shadcn's Sonner info icon. */
|
|
144
|
+
export const InfoIcon = (props?: IconProps): TemplateResult =>
|
|
145
|
+
svg(
|
|
146
|
+
html`<circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" />`,
|
|
147
|
+
props,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
/** Lucide `triangle-alert` — shadcn's Sonner warning icon. */
|
|
151
|
+
export const TriangleAlertIcon = (props?: IconProps): TemplateResult =>
|
|
152
|
+
svg(
|
|
153
|
+
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" />`,
|
|
154
|
+
props,
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
/** Lucide `octagon-x` — shadcn's Sonner error icon. */
|
|
158
|
+
export const OctagonXIcon = (props?: IconProps): TemplateResult =>
|
|
159
|
+
svg(
|
|
160
|
+
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" />`,
|
|
161
|
+
props,
|
|
162
|
+
);
|
|
163
|
+
|
|
136
164
|
/** The arc Lucide uses for `loader-circle`; spun by the Spinner's animation. */
|
|
137
165
|
export const LoaderIcon = (props?: IconProps): TemplateResult =>
|
|
138
166
|
svg(html`<path d="M21 12a9 9 0 1 1-6.219-8.56" />`, props);
|
package/src/lib/image.ts
CHANGED
|
@@ -351,6 +351,18 @@ export function setImageEndpoint(path: string): void {
|
|
|
351
351
|
endpoint = path;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
/**
|
|
355
|
+
* A root-relative `src` as the path under the endpoint's public roots.
|
|
356
|
+
*
|
|
357
|
+
* `/photos/hero.png` is how a page names a public file, and the endpoint
|
|
358
|
+
* resolves `src` inside its roots, refusing an absolute path: sent as is,
|
|
359
|
+
* every variant is a 404. Exactly one slash goes, so a protocol-relative
|
|
360
|
+
* `//host/…` stays what it is and is left to an application's own resolver.
|
|
361
|
+
*/
|
|
362
|
+
function relativeToRoots(src: string): string {
|
|
363
|
+
return src.startsWith("/") && !src.startsWith("//") ? src.slice(1) : src;
|
|
364
|
+
}
|
|
365
|
+
|
|
354
366
|
/**
|
|
355
367
|
* The resolver used when an application installs none.
|
|
356
368
|
*
|
|
@@ -360,7 +372,7 @@ export function setImageEndpoint(path: string): void {
|
|
|
360
372
|
*/
|
|
361
373
|
export const defaultImageResolver: ImageUrlResolver = (src, transform) => {
|
|
362
374
|
const params = new URLSearchParams({
|
|
363
|
-
src,
|
|
375
|
+
src: relativeToRoots(src),
|
|
364
376
|
w: String(Math.round(transform.width)),
|
|
365
377
|
});
|
|
366
378
|
if (transform.format !== undefined) params.set("f", transform.format);
|
|
@@ -182,8 +182,7 @@ export const AccordionContent = component<AccordionContentProps>((props) => {
|
|
|
182
182
|
data-state="${() => (item.open() ? "open" : "closed")}"
|
|
183
183
|
aria-labelledby="${item.triggerId}"
|
|
184
184
|
?inert="${() => !item.open()}"
|
|
185
|
-
class="grid text-sm transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none"
|
|
186
|
-
style="${() => `grid-template-rows: ${item.open() ? "1fr" : "0fr"}`}"
|
|
185
|
+
class="grid grid-rows-[0fr] text-sm transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none data-[state=open]:grid-rows-[1fr]"
|
|
187
186
|
><div class="overflow-hidden"><div
|
|
188
187
|
class="${() => cn("pt-0 pb-4", read(props.class))}"
|
|
189
188
|
>${slot(props.children)}</div></div></div>`;
|
|
@@ -115,9 +115,7 @@ export const CollapsibleContent = component<CollapsibleContentProps>(
|
|
|
115
115
|
data-state="${() => (collapsible.open() ? "open" : "closed")}"
|
|
116
116
|
aria-labelledby="${collapsible.triggerId}"
|
|
117
117
|
?inert="${() => !collapsible.open()}"
|
|
118
|
-
class="grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none"
|
|
119
|
-
style="${() =>
|
|
120
|
-
`grid-template-rows: ${collapsible.open() ? "1fr" : "0fr"}`}"
|
|
118
|
+
class="grid grid-rows-[0fr] transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none data-[state=open]:grid-rows-[1fr]"
|
|
121
119
|
><div class="${() => cn("overflow-hidden", read(props.class))}">${slot(
|
|
122
120
|
props.children,
|
|
123
121
|
)}</div></div>`;
|