@c9up/nebula 0.2.4 → 0.2.6
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 +4 -4
- package/dist/atoms/AspectRatio.d.ts +10 -4
- package/dist/atoms/AspectRatio.js +21 -6
- package/dist/atoms/NativeSelect.d.ts +16 -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/diff.d.ts +46 -0
- package/dist/cli/diff.js +73 -2
- package/dist/console/DiffCommand.js +6 -11
- package/dist/molecules/Accordion.js +1 -2
- package/dist/molecules/Collapsible.js +1 -2
- package/dist/molecules/Resizable.d.ts +6 -0
- package/dist/molecules/Resizable.js +8 -2
- package/dist/organisms/Agenda.d.ts +200 -0
- package/dist/organisms/Agenda.js +762 -0
- 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/Dialog.js +7 -7
- package/dist/organisms/Sidebar.d.ts +5 -7
- package/dist/organisms/Sidebar.js +23 -6
- package/dist/organisms/Sonner.js +11 -4
- package/dist/organisms/index.d.ts +2 -1
- package/dist/organisms/index.js +2 -1
- package/dist/primitives/floatingSurface.js +60 -36
- package/dist/primitives/menuParts.js +3 -3
- package/dist/primitives/portal.d.ts +15 -0
- package/dist/primitives/portal.js +18 -1
- package/nebula.css +1 -1
- package/package.json +1 -1
- package/registry.json +13 -0
- package/src/atoms/AspectRatio.ts +21 -6
- package/src/atoms/NativeSelect.ts +20 -1
- package/src/atoms/Progress.ts +21 -5
- package/src/atoms/Switch.ts +7 -1
- package/src/cli/diff.ts +123 -2
- package/src/console/DiffCommand.ts +12 -15
- package/src/molecules/Accordion.ts +1 -2
- package/src/molecules/Collapsible.ts +1 -3
- package/src/molecules/Resizable.ts +8 -2
- package/src/organisms/Agenda.ts +1061 -0
- package/src/organisms/AlertDialog.ts +3 -5
- package/src/organisms/Chart.ts +633 -125
- package/src/organisms/Dialog.ts +6 -7
- package/src/organisms/Sidebar.ts +28 -6
- package/src/organisms/Sonner.ts +11 -4
- package/src/organisms/index.ts +26 -0
- package/src/primitives/floatingSurface.ts +74 -40
- package/src/primitives/menuParts.ts +3 -3
- package/src/primitives/portal.ts +27 -1
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/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. */
|
|
@@ -46,9 +52,32 @@ export interface DiffOptions {
|
|
|
46
52
|
defaultLanguage?: Language;
|
|
47
53
|
}
|
|
48
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[];
|
|
75
|
+
}
|
|
76
|
+
|
|
49
77
|
export interface DiffResult {
|
|
50
78
|
entries: DiffEntry[];
|
|
51
79
|
language: Language;
|
|
80
|
+
update: UpdatePlan;
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
/**
|
|
@@ -94,7 +123,99 @@ export function diff(options: DiffOptions): DiffResult {
|
|
|
94
123
|
}
|
|
95
124
|
|
|
96
125
|
entries.sort((a, b) => a.file.localeCompare(b.file));
|
|
97
|
-
|
|
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
|
+
};
|
|
98
219
|
}
|
|
99
220
|
|
|
100
221
|
function compare(hashes: {
|
|
@@ -79,14 +79,20 @@ export default class NebulaDiffCommand {
|
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
if (outdated.length > 0) {
|
|
82
|
+
const { components, uncovered } = result.update;
|
|
83
|
+
if (components.length > 0) {
|
|
86
84
|
out.push(
|
|
87
85
|
"",
|
|
88
|
-
|
|
89
|
-
` 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}`),
|
|
90
96
|
);
|
|
91
97
|
}
|
|
92
98
|
out.push("");
|
|
@@ -94,15 +100,6 @@ export default class NebulaDiffCommand {
|
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
/** `molecules/InputGroup.js` → `input-group`, as the registry names it. */
|
|
98
|
-
function componentOf(entry: { file: string }): string {
|
|
99
|
-
const base = entry.file.split("/").pop() ?? entry.file;
|
|
100
|
-
return base
|
|
101
|
-
.replace(/\.(ts|js)$/, "")
|
|
102
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
103
|
-
.toLowerCase();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
103
|
// Fails the build if the class drifts from what the kernel dispatches against.
|
|
107
104
|
const _contract: NebulaCommandClass = NebulaDiffCommand;
|
|
108
105
|
void _contract;
|
|
@@ -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>`;
|
|
@@ -117,14 +117,20 @@ export interface ResizablePanelProps {
|
|
|
117
117
|
* share and the second takes the rest. The parts are upstream's so a layout
|
|
118
118
|
* written against them reads the same; a third panel would simply have no
|
|
119
119
|
* share of its own.
|
|
120
|
+
*
|
|
121
|
+
* The share is written through the CSSOM (`.style`), never as a `style`
|
|
122
|
+
* attribute: a Content-Security-Policy without `'unsafe-inline'` blocks the
|
|
123
|
+
* attribute, and the CSSOM is not subject to it. A property is not written by
|
|
124
|
+
* the server, so until hydration both panes carry `flex-1` and split the room
|
|
125
|
+
* evenly — the right layout for the default share, and never a collapsed one.
|
|
120
126
|
*/
|
|
121
127
|
export const ResizablePanel = component<ResizablePanelProps>((props) => {
|
|
122
128
|
const group = inject(ResizableContext);
|
|
123
129
|
const first = group.claimPanel() === 1;
|
|
124
130
|
return html`<div
|
|
125
131
|
data-slot="resizable-panel"
|
|
126
|
-
class="${() => cn("overflow-hidden",
|
|
127
|
-
style="${() => (first ? `flex: 0 0 ${group.size()}%` : "")}"
|
|
132
|
+
class="${() => cn("flex-1 overflow-hidden", read(props.class))}"
|
|
133
|
+
.style="${() => (first ? `flex: 0 0 ${group.size()}%` : "")}"
|
|
128
134
|
>${slot(props.children)}</div>`;
|
|
129
135
|
});
|
|
130
136
|
|