@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
|
@@ -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
|
|
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
|
|
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");
|
|
@@ -57,22 +62,17 @@ export default class NebulaDiffCommand {
|
|
|
57
62
|
for (const entry of result.entries) {
|
|
58
63
|
out.push(` ${entry.state.padEnd(9)} ${entry.file.padEnd(width)} ${EXPLAIN[entry.state]}`);
|
|
59
64
|
}
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
out.push("",
|
|
65
|
+
const { components, uncovered } = result.update;
|
|
66
|
+
if (components.length > 0) {
|
|
67
|
+
out.push("", " Outdated files that can be updated with no loss — the components that carry them:", ` ream nebula:add --force ${components.join(" ")}`);
|
|
68
|
+
}
|
|
69
|
+
if (uncovered.length > 0) {
|
|
70
|
+
out.push("", " Outdated, but no installed component can re-copy them without overwriting", " a file you changed (or none carries them any more). Compare by hand:", ...uncovered.map((file) => ` ${file}`));
|
|
63
71
|
}
|
|
64
72
|
out.push("");
|
|
65
73
|
process.stdout.write(out.join("\n"));
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
/** `molecules/InputGroup.js` → `input-group`, as the registry names it. */
|
|
69
|
-
function componentOf(entry) {
|
|
70
|
-
const base = entry.file.split("/").pop() ?? entry.file;
|
|
71
|
-
return base
|
|
72
|
-
.replace(/\.(ts|js)$/, "")
|
|
73
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
74
|
-
.toLowerCase();
|
|
75
|
-
}
|
|
76
76
|
// Fails the build if the class drifts from what the kernel dispatches against.
|
|
77
77
|
const _contract = NebulaDiffCommand;
|
|
78
78
|
void _contract;
|
package/dist/lib/icons.d.ts
CHANGED
|
@@ -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)
|
|
@@ -109,8 +109,7 @@ export const AccordionContent = component((props) => {
|
|
|
109
109
|
data-state="${() => (item.open() ? "open" : "closed")}"
|
|
110
110
|
aria-labelledby="${item.triggerId}"
|
|
111
111
|
?inert="${() => !item.open()}"
|
|
112
|
-
class="grid text-sm transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none"
|
|
113
|
-
style="${() => `grid-template-rows: ${item.open() ? "1fr" : "0fr"}`}"
|
|
112
|
+
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]"
|
|
114
113
|
><div class="overflow-hidden"><div
|
|
115
114
|
class="${() => cn("pt-0 pb-4", read(props.class))}"
|
|
116
115
|
>${slot(props.children)}</div></div></div>`;
|
|
@@ -73,7 +73,6 @@ export const CollapsibleContent = component((props) => {
|
|
|
73
73
|
data-state="${() => (collapsible.open() ? "open" : "closed")}"
|
|
74
74
|
aria-labelledby="${collapsible.triggerId}"
|
|
75
75
|
?inert="${() => !collapsible.open()}"
|
|
76
|
-
class="grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none"
|
|
77
|
-
style="${() => `grid-template-rows: ${collapsible.open() ? "1fr" : "0fr"}`}"
|
|
76
|
+
class="grid grid-rows-[0fr] transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none data-[state=open]:grid-rows-[1fr]"
|
|
78
77
|
><div class="${() => cn("overflow-hidden", read(props.class))}">${slot(props.children)}</div></div>`;
|
|
79
78
|
});
|
|
@@ -19,9 +19,21 @@
|
|
|
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";
|
|
25
37
|
/** Each box's accessible name from its position. Default `"Character 2 of 6"`. */
|
|
26
38
|
slotLabel?: (position: number, length: number) => string;
|
|
27
39
|
name?: string;
|
|
@@ -25,6 +25,10 @@ import { uid } from "../lib/id.js";
|
|
|
25
25
|
import { read, readOr } from "../lib/props.js";
|
|
26
26
|
const slotClasses = "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";
|
|
27
27
|
const InputOTPContext = createContext("InputOTP");
|
|
28
|
+
/** input-otp's patterns, for the `pattern` prop. */
|
|
29
|
+
export const REGEXP_ONLY_DIGITS = "^\\d+$";
|
|
30
|
+
export const REGEXP_ONLY_CHARS = "^[a-zA-Z]+$";
|
|
31
|
+
export const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]+$";
|
|
28
32
|
export const InputOTP = component((props) => {
|
|
29
33
|
const length = props.length ?? 6;
|
|
30
34
|
const groupId = uid("input-otp");
|
|
@@ -58,8 +62,45 @@ export const InputOTP = component((props) => {
|
|
|
58
62
|
next[index] = character;
|
|
59
63
|
commit(next);
|
|
60
64
|
}
|
|
65
|
+
const pattern = typeof props.pattern === "string"
|
|
66
|
+
? new RegExp(props.pattern)
|
|
67
|
+
: props.pattern;
|
|
68
|
+
function accepts(next) {
|
|
69
|
+
const joined = next.join("");
|
|
70
|
+
return pattern === undefined || joined === "" || pattern.test(joined);
|
|
71
|
+
}
|
|
72
|
+
/** Put the boxes back to what the code holds. */
|
|
73
|
+
function reflect() {
|
|
74
|
+
const inputs = boxes();
|
|
75
|
+
characters().forEach((character, position) => {
|
|
76
|
+
const input = inputs[position];
|
|
77
|
+
if (input !== undefined)
|
|
78
|
+
input.value = character;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Share a run of characters out over the boxes from `index`: a paste, and
|
|
83
|
+
* a whole code an autofill or an IME put into one box.
|
|
84
|
+
*/
|
|
85
|
+
function spread(index, text) {
|
|
86
|
+
const next = [...characters()];
|
|
87
|
+
let cursor = index;
|
|
88
|
+
for (const character of text) {
|
|
89
|
+
if (cursor >= length)
|
|
90
|
+
break;
|
|
91
|
+
next[cursor] = character;
|
|
92
|
+
cursor += 1;
|
|
93
|
+
}
|
|
94
|
+
if (accepts(next))
|
|
95
|
+
commit(next);
|
|
96
|
+
// The boxes are uncontrolled between keystrokes, so writing the signal
|
|
97
|
+
// alone would leave the characters invisible — or a refused fill in place.
|
|
98
|
+
reflect();
|
|
99
|
+
focusBox(Math.min(cursor, length - 1));
|
|
100
|
+
}
|
|
61
101
|
provide(InputOTPContext, {
|
|
62
102
|
length,
|
|
103
|
+
inputMode: props.inputMode ?? "numeric",
|
|
63
104
|
disabled: () => readOr(props.disabled, false),
|
|
64
105
|
slotLabel: props.slotLabel ??
|
|
65
106
|
((position, total) => `Character ${position} of ${total}`),
|
|
@@ -72,12 +113,30 @@ export const InputOTP = component((props) => {
|
|
|
72
113
|
const target = event.target;
|
|
73
114
|
if (!(target instanceof HTMLInputElement))
|
|
74
115
|
return;
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
116
|
+
const value = target.value;
|
|
117
|
+
// One key pressed in a box already holding a character: the box holds
|
|
118
|
+
// both, and the one just typed is what counts.
|
|
119
|
+
const typed = event instanceof InputEvent &&
|
|
120
|
+
event.inputType === "insertText" &&
|
|
121
|
+
event.data !== null &&
|
|
122
|
+
[...event.data].length === 1
|
|
123
|
+
? event.data
|
|
124
|
+
: undefined;
|
|
125
|
+
if ([...value].length > 1 && typed === undefined) {
|
|
126
|
+
// A whole code at once: autofill, a password manager, an IME.
|
|
127
|
+
spread(index, value);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const character = typed ?? value;
|
|
131
|
+
const next = [...characters()];
|
|
132
|
+
next[index] = character;
|
|
133
|
+
if (!accepts(next)) {
|
|
134
|
+
target.value = characters()[index] ?? "";
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
target.value = character;
|
|
138
|
+
commit(next);
|
|
139
|
+
if (character !== "" && index < length - 1)
|
|
81
140
|
focusBox(index + 1);
|
|
82
141
|
},
|
|
83
142
|
onKeyDown(index, event) {
|
|
@@ -104,25 +163,7 @@ export const InputOTP = component((props) => {
|
|
|
104
163
|
if (pasted === "")
|
|
105
164
|
return;
|
|
106
165
|
event.preventDefault();
|
|
107
|
-
|
|
108
|
-
let cursor = index;
|
|
109
|
-
for (const character of pasted) {
|
|
110
|
-
if (cursor >= length)
|
|
111
|
-
break;
|
|
112
|
-
next[cursor] = character;
|
|
113
|
-
cursor += 1;
|
|
114
|
-
}
|
|
115
|
-
commit(next);
|
|
116
|
-
// Reflect into the DOM: the boxes are uncontrolled between keystrokes,
|
|
117
|
-
// so writing the signal alone would leave the pasted characters
|
|
118
|
-
// invisible.
|
|
119
|
-
const inputs = boxes();
|
|
120
|
-
next.forEach((character, position) => {
|
|
121
|
-
const input = inputs[position];
|
|
122
|
-
if (input !== undefined)
|
|
123
|
-
input.value = character;
|
|
124
|
-
});
|
|
125
|
-
focusBox(Math.min(cursor, length - 1));
|
|
166
|
+
spread(index, pasted);
|
|
126
167
|
},
|
|
127
168
|
});
|
|
128
169
|
return html `<div
|
|
@@ -155,9 +196,9 @@ export const InputOTPSlot = component((props) => {
|
|
|
155
196
|
data-slot="input-otp-slot"
|
|
156
197
|
data-otp-index="${index}"
|
|
157
198
|
type="text"
|
|
158
|
-
inputmode="
|
|
199
|
+
inputmode="${otp.inputMode}"
|
|
159
200
|
autocomplete="${index === 0 ? "one-time-code" : "off"}"
|
|
160
|
-
maxlength="
|
|
201
|
+
maxlength="${otp.length}"
|
|
161
202
|
aria-label="${otp.slotLabel(index + 1, otp.length)}"
|
|
162
203
|
?disabled="${() => otp.disabled()}"
|
|
163
204
|
class="${() => cn(slotClasses, read(props.class))}"
|
|
@@ -45,6 +45,12 @@ export interface ResizablePanelProps {
|
|
|
45
45
|
* share and the second takes the rest. The parts are upstream's so a layout
|
|
46
46
|
* written against them reads the same; a third panel would simply have no
|
|
47
47
|
* share of its own.
|
|
48
|
+
*
|
|
49
|
+
* The share is written through the CSSOM (`.style`), never as a `style`
|
|
50
|
+
* attribute: a Content-Security-Policy without `'unsafe-inline'` blocks the
|
|
51
|
+
* attribute, and the CSSOM is not subject to it. A property is not written by
|
|
52
|
+
* the server, so until hydration both panes carry `flex-1` and split the room
|
|
53
|
+
* evenly — the right layout for the default share, and never a collapsed one.
|
|
48
54
|
*/
|
|
49
55
|
export declare const ResizablePanel: (props?: ResizablePanelProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
50
56
|
export interface ResizableHandleProps {
|
|
@@ -67,14 +67,20 @@ export const ResizablePanelGroup = component((props) => {
|
|
|
67
67
|
* share and the second takes the rest. The parts are upstream's so a layout
|
|
68
68
|
* written against them reads the same; a third panel would simply have no
|
|
69
69
|
* share of its own.
|
|
70
|
+
*
|
|
71
|
+
* The share is written through the CSSOM (`.style`), never as a `style`
|
|
72
|
+
* attribute: a Content-Security-Policy without `'unsafe-inline'` blocks the
|
|
73
|
+
* attribute, and the CSSOM is not subject to it. A property is not written by
|
|
74
|
+
* the server, so until hydration both panes carry `flex-1` and split the room
|
|
75
|
+
* evenly — the right layout for the default share, and never a collapsed one.
|
|
70
76
|
*/
|
|
71
77
|
export const ResizablePanel = component((props) => {
|
|
72
78
|
const group = inject(ResizableContext);
|
|
73
79
|
const first = group.claimPanel() === 1;
|
|
74
80
|
return html `<div
|
|
75
81
|
data-slot="resizable-panel"
|
|
76
|
-
class="${() => cn("overflow-hidden",
|
|
77
|
-
style="${() => (first ? `flex: 0 0 ${group.size()}%` : "")}"
|
|
82
|
+
class="${() => cn("flex-1 overflow-hidden", read(props.class))}"
|
|
83
|
+
.style="${() => (first ? `flex: 0 0 ${group.size()}%` : "")}"
|
|
78
84
|
>${slot(props.children)}</div>`;
|
|
79
85
|
});
|
|
80
86
|
/**
|
|
@@ -26,7 +26,7 @@ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type Col
|
|
|
26
26
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyProps, EmptyTitle, } from "./Empty.js";
|
|
27
27
|
export { Field, FieldContent, FieldDescription, FieldError, type FieldErrorProps, FieldGroup, type FieldIds, FieldLabel, FieldLegend, type FieldLegendProps, type FieldProps, type FieldSectionProps, FieldSeparator, type FieldSeparatorProps, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
|
|
28
28
|
export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, InputGroupInput, type InputGroupProps, InputGroupText, InputGroupTextarea, type InputGroupTextProps, inputGroupControlClasses, } from "./InputGroup.js";
|
|
29
|
-
export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, } from "./InputOTP.js";
|
|
29
|
+
export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, } from "./InputOTP.js";
|
|
30
30
|
export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, type ItemProps, ItemSeparator, ItemTitle, type ItemVariants, itemVariants, } from "./Item.js";
|
|
31
31
|
export { Message, type MessageProps } from "./Message.js";
|
|
32
32
|
export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, type PaginationLabels, PaginationLink, type PaginationLinkProps, type PaginationNavProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
|
package/dist/molecules/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "./Collapsi
|
|
|
26
26
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "./Empty.js";
|
|
27
27
|
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
|
|
28
28
|
export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupControlClasses, } from "./InputGroup.js";
|
|
29
|
-
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "./InputOTP.js";
|
|
29
|
+
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, } from "./InputOTP.js";
|
|
30
30
|
export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemSeparator, ItemTitle, itemVariants, } from "./Item.js";
|
|
31
31
|
export { Message } from "./Message.js";
|
|
32
32
|
export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, pageWindow, } from "./Pagination.js";
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* Escape still closes, and it cancels rather than confirms — it is the
|
|
28
28
|
* keyboard spelling of the same safe way out.
|
|
29
29
|
*/
|
|
30
|
-
import { component, createContext, html, inject,
|
|
30
|
+
import { component, createContext, html, inject, provide, } from "@c9up/aurora";
|
|
31
31
|
import { buttonVariants } from "../atoms/Button.js";
|
|
32
32
|
import { slot } from "../lib/children.js";
|
|
33
33
|
import { cn } from "../lib/cn.js";
|
|
@@ -36,7 +36,7 @@ import { fadeInOut, zoomInOut } from "../lib/motion.js";
|
|
|
36
36
|
import { read } from "../lib/props.js";
|
|
37
37
|
import { controllable } from "../primitives/controllable.js";
|
|
38
38
|
import { modalSurface } from "../primitives/modalSurface.js";
|
|
39
|
-
import {
|
|
39
|
+
import { portalOnMount } from "../primitives/portal.js";
|
|
40
40
|
import { dialogBackdropClasses } from "./Dialog.js";
|
|
41
41
|
const panelClasses = "group/alert-dialog-content bg-background fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none data-[size=sm]:max-w-xs sm:max-w-lg";
|
|
42
42
|
const AlertDialogContext = createContext("AlertDialog");
|
|
@@ -141,11 +141,10 @@ export const AlertDialogOverlay = component((props) => html `<div
|
|
|
141
141
|
* than standing in as a passthrough.
|
|
142
142
|
*/
|
|
143
143
|
export const AlertDialogPortal = component((props) => {
|
|
144
|
-
|
|
144
|
+
portalOnMount(html `${slot(props.children)}`, {
|
|
145
145
|
container: props.container,
|
|
146
|
+
slot: "alert-dialog-portal",
|
|
146
147
|
});
|
|
147
|
-
mounted.host.setAttribute("data-slot", "alert-dialog-portal");
|
|
148
|
-
onUnmount(() => mounted.close());
|
|
149
148
|
return html ``;
|
|
150
149
|
});
|
|
151
150
|
export const AlertDialogHeader = component((props) => html `<div
|
|
@@ -8,17 +8,32 @@
|
|
|
8
8
|
* the shadcn chart examples are and what dashboards overwhelmingly need.
|
|
9
9
|
*
|
|
10
10
|
* Anything beyond that — stacked bars with negative values, dual axes, brushes,
|
|
11
|
-
* candlesticks — is a charting library's
|
|
12
|
-
* install one rather than have this
|
|
11
|
+
* candlesticks, horizontal bars, heatmaps, funnels — is a charting library's
|
|
12
|
+
* job, and an app needing one should install one rather than have this
|
|
13
|
+
* component grow into a bad copy.
|
|
13
14
|
*
|
|
14
15
|
* The colours come from `--chart-1` … `--chart-5`, so a chart re-themes with
|
|
15
16
|
* the rest of the design system instead of carrying its own palette.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* **Geometry.** Text is never stretched. The drawing is two SVGs in pixel
|
|
19
|
+
* space — the value axis in a fixed gutter, the plot at full width — with
|
|
20
|
+
* every horizontal position written as a percentage of the plot's width and
|
|
21
|
+
* every vertical one in pixels. Only the curves and bars live in a nested SVG
|
|
22
|
+
* stretched to the plot (`preserveAspectRatio="none"`), with strokes that do
|
|
23
|
+
* not scale. Everything is an attribute: no `style` attribute, which a strict
|
|
24
|
+
* Content-Security-Policy blocks, and the server's markup is the chart.
|
|
25
|
+
*
|
|
26
|
+
* **Missing values.** A value that is absent, `null` or not a finite number is
|
|
27
|
+
* a gap: the line breaks, the area stops, no bar is drawn, and the table says
|
|
28
|
+
* so. Drawing it as `0` would invent a number.
|
|
29
|
+
*
|
|
30
|
+
* **Reading it.** An SVG chart is invisible to a screen reader whatever ARIA is
|
|
31
|
+
* put on it, so the same data is emitted as a real `<table>`, visually hidden.
|
|
32
|
+
* The plot also takes focus: the arrow keys walk the categories, and what the
|
|
33
|
+
* pointer or the keyboard points at is shown in a tooltip and announced in a
|
|
34
|
+
* live region.
|
|
21
35
|
*/
|
|
36
|
+
import { type TemplateResult } from "@c9up/aurora";
|
|
22
37
|
import { type Reactive } from "../lib/props.js";
|
|
23
38
|
export interface ChartSeries {
|
|
24
39
|
key: string;
|
|
@@ -26,30 +41,103 @@ export interface ChartSeries {
|
|
|
26
41
|
/** Any CSS colour. Defaults to `--chart-1`…`--chart-5` by position. */
|
|
27
42
|
color?: string;
|
|
28
43
|
}
|
|
29
|
-
/**
|
|
30
|
-
export type
|
|
44
|
+
/** A category label as a datum may hold it. */
|
|
45
|
+
export type ChartCategory = string | number | Date;
|
|
46
|
+
/**
|
|
47
|
+
* One row: a category plus one numeric value per series key. A value that is
|
|
48
|
+
* missing, `null` or not a finite number is a gap.
|
|
49
|
+
*/
|
|
50
|
+
export type ChartDatum = Record<string, string | number | Date | null | undefined>;
|
|
51
|
+
/** One end of the value axis: a number, or `"auto"` to fit the data. */
|
|
52
|
+
export type ChartBound = number | "auto";
|
|
31
53
|
export interface ChartProps {
|
|
32
54
|
data: readonly ChartDatum[];
|
|
33
55
|
series: readonly ChartSeries[];
|
|
34
56
|
/** Key in each datum holding the category label. */
|
|
35
57
|
categoryKey: string;
|
|
36
58
|
type?: "line" | "area" | "bar";
|
|
59
|
+
/** The chart's height in pixels, category labels included. Default `240`. */
|
|
37
60
|
height?: number;
|
|
38
61
|
/** Announced as the chart's name, and used as the data table's caption. */
|
|
39
62
|
label: string;
|
|
40
|
-
/** Draw horizontal
|
|
63
|
+
/** Draw a horizontal gridline at each value tick. Default `true`. */
|
|
41
64
|
grid?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The value axis' range, `[min, max]`. Each end is a number, or `"auto"` to
|
|
67
|
+
* fit the data and round outwards to a tick. Default `["auto", "auto"]`.
|
|
68
|
+
*/
|
|
69
|
+
domain?: readonly [ChartBound, ChartBound];
|
|
70
|
+
/**
|
|
71
|
+
* Stretch an `"auto"` end to include zero. Default `true`. Always on for
|
|
72
|
+
* bars: a bar is measured from zero, and one that starts elsewhere
|
|
73
|
+
* exaggerates every difference.
|
|
74
|
+
*/
|
|
75
|
+
zero?: boolean;
|
|
76
|
+
/** Draw the smallest value at the top — a ranking, where 1 is best. */
|
|
77
|
+
reversed?: boolean;
|
|
78
|
+
/** About how many ticks the value axis gets. Default `5`. */
|
|
79
|
+
tickCount?: number;
|
|
80
|
+
/** Formats a value on the axis, in the tooltip and in the table. */
|
|
81
|
+
formatValue?: (value: number) => string;
|
|
82
|
+
/** Formats a category on the axis, in the tooltip and in the table. */
|
|
83
|
+
formatCategory?: (category: ChartCategory) => string;
|
|
84
|
+
/** BCP 47 locale for the default formatters. Default: the runtime's own. */
|
|
85
|
+
locale?: string;
|
|
86
|
+
/** What a screen reader calls the plot. Default `"chart"`. */
|
|
87
|
+
roleDescription?: string;
|
|
88
|
+
/**
|
|
89
|
+
* How a screen reader is told to read the plot. Default `"Arrow keys read
|
|
90
|
+
* each category."`.
|
|
91
|
+
*/
|
|
92
|
+
keyboardHint?: string;
|
|
42
93
|
class?: Reactive<string>;
|
|
43
94
|
}
|
|
44
95
|
/**
|
|
45
|
-
* The
|
|
96
|
+
* The range the data covers.
|
|
97
|
+
*
|
|
98
|
+
* Gaps are skipped. With `zero` (the default), the range always includes zero.
|
|
99
|
+
* A flat range is widened — to `0`–`1` when it sits on zero, by a tenth of its
|
|
100
|
+
* value either side otherwise — so there is always something to scale
|
|
101
|
+
* against, and no data at all reads as `0`–`1`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function valueRange(data: readonly ChartDatum[], series: readonly ChartSeries[], options?: {
|
|
104
|
+
zero?: boolean;
|
|
105
|
+
}): {
|
|
106
|
+
min: number;
|
|
107
|
+
max: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Round ticks covering `min`–`max`, about `count` of them.
|
|
46
111
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* misleading chart — and it is not a choice worth exposing as an option.
|
|
112
|
+
* The range is widened outwards to the nearest tick, so the first and last
|
|
113
|
+
* ticks are the axis' ends.
|
|
50
114
|
*/
|
|
51
|
-
export declare function
|
|
115
|
+
export declare function niceTicks(min: number, max: number, count?: number): {
|
|
52
116
|
min: number;
|
|
53
117
|
max: number;
|
|
118
|
+
step: number;
|
|
119
|
+
ticks: number[];
|
|
54
120
|
};
|
|
55
|
-
export
|
|
121
|
+
export interface ValueAxisOptions {
|
|
122
|
+
domain?: readonly [ChartBound, ChartBound];
|
|
123
|
+
zero?: boolean;
|
|
124
|
+
tickCount?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The value axis a chart draws: its ends and its ticks.
|
|
128
|
+
*
|
|
129
|
+
* An `"auto"` end fits the data and is rounded outwards to a tick. A number is
|
|
130
|
+
* kept exactly and is a tick itself, with any round tick too close to it
|
|
131
|
+
* dropped so the two labels do not collide.
|
|
132
|
+
*/
|
|
133
|
+
export declare function valueAxis(data: readonly ChartDatum[], series: readonly ChartSeries[], options?: ValueAxisOptions): {
|
|
134
|
+
min: number;
|
|
135
|
+
max: number;
|
|
136
|
+
ticks: number[];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Which category labels fit: every `step`-th one, the smallest step at which
|
|
140
|
+
* the widest label no longer reaches its neighbour.
|
|
141
|
+
*/
|
|
142
|
+
export declare function visibleCategories(count: number, widestLabel: number, plotWidth: number): number[];
|
|
143
|
+
export declare const Chart: (props?: ChartProps | undefined) => TemplateResult;
|