@sdxc/kit 2026.10.30 → 2026.11.3
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 +59 -0
- package/changelog.jsonl +346 -0
- package/config.schema.json +14 -0
- package/dist/ci/install.d.ts +15 -0
- package/dist/ci/install.js +27 -0
- package/dist/ci/locate.d.ts +23 -0
- package/dist/ci/locate.js +43 -0
- package/dist/cli.js +5 -0
- package/dist/commands/ci/list.d.ts +16 -0
- package/dist/commands/ci/list.js +24 -0
- package/dist/commands/ci/run.d.ts +65 -0
- package/dist/commands/ci/run.js +36 -0
- package/dist/commands/ci/signoff.d.ts +15 -0
- package/dist/commands/ci/signoff.js +15 -0
- package/dist/commands/ci/verify.d.ts +17 -0
- package/dist/commands/ci/verify.js +15 -0
- package/dist/commands/create.js +3 -0
- package/dist/commands/pkg.d.ts +16 -0
- package/dist/commands/pkg.js +71 -0
- package/dist/commands/routes.d.ts +1 -1
- package/dist/config.d.ts +10 -4
- package/dist/config.js +8 -0
- package/dist/contract.d.ts +60 -1
- package/dist/contract.js +46 -0
- package/dist/create/workspace.d.ts +15 -0
- package/dist/create/workspace.js +42 -0
- package/dist/doctor/checks.js +4 -0
- package/dist/doctor/ci.d.ts +15 -0
- package/dist/doctor/ci.js +63 -0
- package/dist/doctor/translations.d.ts +19 -0
- package/dist/doctor/translations.js +144 -0
- package/dist/make/declare.js +32 -11
- package/dist/package-manager.d.ts +2 -0
- package/dist/package-manager.js +16 -2
- package/dist/pkg/catalog.d.ts +12 -0
- package/dist/pkg/catalog.js +153 -0
- package/dist/pkg/resolve.d.ts +67 -0
- package/dist/pkg/resolve.js +147 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/package.json +10 -8
- package/registry/ui/accordion.json +2 -2
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/alert.json +2 -2
- package/registry/ui/aspect-ratio.json +2 -2
- package/registry/ui/avatar.json +6 -3
- package/registry/ui/badge.json +2 -2
- package/registry/ui/banner.json +16 -0
- package/registry/ui/breadcrumbs.json +2 -2
- package/registry/ui/button.json +5 -3
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/card.json +2 -2
- package/registry/ui/carousel.json +2 -2
- package/registry/ui/checkbox-group.json +2 -2
- package/registry/ui/checkbox.json +2 -2
- package/registry/ui/combobox.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/confirm.json +8 -4
- package/registry/ui/cta-group.json +2 -2
- package/registry/ui/date-field.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/description.json +2 -2
- package/registry/ui/dialog-dismiss.json +13 -0
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/disclosure.json +2 -2
- package/registry/ui/drawer.json +2 -2
- package/registry/ui/field-error.json +2 -2
- package/registry/ui/form.json +2 -2
- package/registry/ui/group.json +2 -2
- package/registry/ui/header.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/heading.json +3 -3
- package/registry/ui/highlight.json +3 -3
- package/registry/ui/hover-card.json +2 -2
- package/registry/ui/image-placeholder.json +2 -2
- package/registry/ui/input.json +2 -2
- package/registry/ui/item.json +2 -2
- package/registry/ui/keyboard.json +2 -2
- package/registry/ui/label.json +2 -2
- package/registry/ui/link-button.json +5 -3
- package/registry/ui/link.json +2 -2
- package/registry/ui/listbox.json +2 -2
- package/registry/ui/menu.json +2 -2
- package/registry/ui/meter.json +2 -2
- package/registry/ui/modal.json +2 -2
- package/registry/ui/nav-link.json +2 -2
- package/registry/ui/navigation-menu.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/otp-field.json +2 -2
- package/registry/ui/overlay-arrow.json +2 -2
- package/registry/ui/pagination.json +2 -2
- package/registry/ui/popover.json +2 -2
- package/registry/ui/progress-bar.json +2 -2
- package/registry/ui/property-list.json +18 -0
- package/registry/ui/radio-group.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/relative-time.json +17 -0
- package/registry/ui/scroll-area.json +2 -2
- package/registry/ui/search-field.json +2 -2
- package/registry/ui/section.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/selection-indicator.json +2 -2
- package/registry/ui/sentinel-row.json +2 -2
- package/registry/ui/separator.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sheet.json +2 -2
- package/registry/ui/sidebar.json +2 -2
- package/registry/ui/slider.json +2 -2
- package/registry/ui/spinner.json +2 -2
- package/registry/ui/status-dot.json +16 -0
- package/registry/ui/switch.json +2 -2
- package/registry/ui/tabs.json +2 -2
- package/registry/ui/tag-group.json +2 -2
- package/registry/ui/text-field.json +7 -3
- package/registry/ui/text.json +2 -2
- package/registry/ui/textarea.json +2 -2
- package/registry/ui/time-field.json +2 -2
- package/registry/ui/timeline.json +16 -0
- package/registry/ui/toggle-button.json +2 -2
- package/registry/ui/tooltip.json +2 -2
- package/registry/ui/typeset.json +2 -2
- package/registry/ui/youtube-embed.json +2 -2
- package/stubs/scaffold.controller.index.stub +1 -1
- package/templates/app/.config/sdxc/ci.ts +26 -0
- package/templates/app/.github/workflows/ci.yml +46 -0
- package/templates/app/README.md +4 -0
- package/templates/app/package.json +1 -0
- package/templates/app/public/_headers +4 -0
- package/registry/ui/attachment.json +0 -15
- package/registry/ui/bubble.json +0 -13
- package/registry/ui/chart.json +0 -13
- package/registry/ui/color-area.json +0 -13
- package/registry/ui/color-field.json +0 -20
- package/registry/ui/color-picker.json +0 -17
- package/registry/ui/color-slider.json +0 -13
- package/registry/ui/color-swatch-picker.json +0 -15
- package/registry/ui/color-swatch.json +0 -13
- package/registry/ui/color-wheel.json +0 -13
- package/registry/ui/context-menu.json +0 -16
- package/registry/ui/drop-indicator.json +0 -13
- package/registry/ui/drop-zone.json +0 -13
- package/registry/ui/empty.json +0 -15
- package/registry/ui/feature.json +0 -18
- package/registry/ui/file-trigger.json +0 -13
- package/registry/ui/grid-list.json +0 -18
- package/registry/ui/logo-cloud.json +0 -16
- package/registry/ui/marker.json +0 -13
- package/registry/ui/marketing-header.json +0 -18
- package/registry/ui/marketing-section.json +0 -16
- package/registry/ui/menubar.json +0 -13
- package/registry/ui/message-scroller.json +0 -16
- package/registry/ui/message.json +0 -13
- package/registry/ui/resizable.json +0 -13
- package/registry/ui/shortcut-list.json +0 -18
- package/registry/ui/skeleton.json +0 -13
- package/registry/ui/split.json +0 -16
- package/registry/ui/stat-strip.json +0 -16
- package/registry/ui/table.json +0 -16
- package/registry/ui/toast.json +0 -16
- package/registry/ui/toolbar.json +0 -13
- package/registry/ui/tree.json +0 -18
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@sdxc` packages `sdxc pkg` knows by name: those with a command line, each with what it
|
|
3
|
+
* does for `sdxc pkg --help`, and those without one, so a request for one gets an answer
|
|
4
|
+
* naming where to ask for it. A repository test holds both lists to the published packages.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Every package with a command line, by name, with what its command line does. */
|
|
10
|
+
export const PACKAGE_COMMAND_LINES = {
|
|
11
|
+
ci: "run a CI script locally or on a CI host, and sign green commits off on GitHub",
|
|
12
|
+
cron: "upcoming runs, descriptions and validation for cron schedules",
|
|
13
|
+
crypto: "tokens, digests, MACs, one-time codes and password hashes",
|
|
14
|
+
diagram: "Mermaid sequence, class, state and flowchart diagrams to SVG",
|
|
15
|
+
distill: "extract the article from a web page",
|
|
16
|
+
doh: "typed DNS over HTTPS lookups",
|
|
17
|
+
"email-address": "parse and check email addresses",
|
|
18
|
+
"email-auth": "check a domain's email-authentication DNS policies",
|
|
19
|
+
font: "inspect and subset fonts",
|
|
20
|
+
html: "read a served page by role and accessible name",
|
|
21
|
+
"http-signatures": "sign and verify HTTP message signatures",
|
|
22
|
+
icalendar: "check iCalendar files and expand their recurrences",
|
|
23
|
+
ip: "IPv4 and IPv6 addresses against the IANA special-purpose registries",
|
|
24
|
+
jscalendar: "convert, expand and validate RFC 8984 JSCalendar documents",
|
|
25
|
+
jscontact: "JSContact, vCard and jCard contacts",
|
|
26
|
+
jsdoc: "JSDoc from JavaScript and TypeScript sources as JSON",
|
|
27
|
+
"json-canonical": "RFC 8785 canonical JSON for hashing and signing",
|
|
28
|
+
"json-patch": "apply, diff and validate RFC 6902 JSON Patch documents",
|
|
29
|
+
jsonc: "check JSON with comments and strip it to plain JSON",
|
|
30
|
+
jsonpath: "RFC 9535 JSONPath queries over JSON documents",
|
|
31
|
+
jwt: "decode, verify and sign JSON Web Tokens, and generate their keys",
|
|
32
|
+
"merge-patch": "apply and compute RFC 7396 JSON merge patches",
|
|
33
|
+
openapi: "check OpenAPI 3.1 documents",
|
|
34
|
+
openpgp: "sign and verify with OpenPGP keys, inspect them and generate them",
|
|
35
|
+
qr: "QR codes as SVG or PNG",
|
|
36
|
+
rdap: "domain registration data from the registry, over RDAP",
|
|
37
|
+
robots: "read and evaluate robots.txt (RFC 9309)",
|
|
38
|
+
"security-headers": "audit and parse security response headers",
|
|
39
|
+
semver: "SemVer 2.0.0 validation, comparison and sorting",
|
|
40
|
+
sitemap: "read and check sitemaps",
|
|
41
|
+
typeid: "generate, parse and encode TypeIDs",
|
|
42
|
+
"user-agent": "read User-Agent strings",
|
|
43
|
+
uuid: "generate and validate UUIDs",
|
|
44
|
+
"web-push": "VAPID keys and test notifications for Web Push",
|
|
45
|
+
webmention: "discover, send and verify Webmentions",
|
|
46
|
+
"well-known": "read and check /.well-known/ documents",
|
|
47
|
+
"zone-file": "read, check and write RFC 1035 DNS zone files",
|
|
48
|
+
};
|
|
49
|
+
/** Every published package without a command line yet. */
|
|
50
|
+
export const PACKAGES_WITHOUT_COMMAND_LINES = [
|
|
51
|
+
"activitypub",
|
|
52
|
+
"api-client",
|
|
53
|
+
"assets-middleware",
|
|
54
|
+
"atom",
|
|
55
|
+
"attribution",
|
|
56
|
+
"auth",
|
|
57
|
+
"authz",
|
|
58
|
+
"backoff",
|
|
59
|
+
"billing",
|
|
60
|
+
"bracket-params",
|
|
61
|
+
"cache",
|
|
62
|
+
"captcha",
|
|
63
|
+
"catch-response-middleware",
|
|
64
|
+
"cbor",
|
|
65
|
+
"cli",
|
|
66
|
+
"cloudflare-mocks",
|
|
67
|
+
"cloudflare-pricing",
|
|
68
|
+
"codemod",
|
|
69
|
+
"csv",
|
|
70
|
+
"data-model",
|
|
71
|
+
"data-table-d1",
|
|
72
|
+
"data-table-sqlstorage",
|
|
73
|
+
"database-middleware",
|
|
74
|
+
"dates",
|
|
75
|
+
"digest-fields",
|
|
76
|
+
"duration",
|
|
77
|
+
"epub",
|
|
78
|
+
"expression",
|
|
79
|
+
"feed",
|
|
80
|
+
"file-storage-r2",
|
|
81
|
+
"flags",
|
|
82
|
+
"flags-engine",
|
|
83
|
+
"get-client-ip",
|
|
84
|
+
"health",
|
|
85
|
+
"highlight",
|
|
86
|
+
"honeypot",
|
|
87
|
+
"hostname",
|
|
88
|
+
"http",
|
|
89
|
+
"i18n",
|
|
90
|
+
"icons",
|
|
91
|
+
"idempotency",
|
|
92
|
+
"iife",
|
|
93
|
+
"jmap",
|
|
94
|
+
"jobs",
|
|
95
|
+
"json-feed",
|
|
96
|
+
"json-pointer",
|
|
97
|
+
"json-schema",
|
|
98
|
+
"jsonl",
|
|
99
|
+
"lazy-frame",
|
|
100
|
+
"lazy-route",
|
|
101
|
+
"link-header",
|
|
102
|
+
"location",
|
|
103
|
+
"logger",
|
|
104
|
+
"mail",
|
|
105
|
+
"markdown",
|
|
106
|
+
"math",
|
|
107
|
+
"messageformat",
|
|
108
|
+
"messaging",
|
|
109
|
+
"microformats",
|
|
110
|
+
"micropub",
|
|
111
|
+
"newsletter",
|
|
112
|
+
"no-www-middleware",
|
|
113
|
+
"opml",
|
|
114
|
+
"outbound",
|
|
115
|
+
"pagination",
|
|
116
|
+
"passkey",
|
|
117
|
+
"password-policy",
|
|
118
|
+
"pdf",
|
|
119
|
+
"png",
|
|
120
|
+
"privacy-pass",
|
|
121
|
+
"problem",
|
|
122
|
+
"random",
|
|
123
|
+
"raster",
|
|
124
|
+
"rate-limit",
|
|
125
|
+
"response",
|
|
126
|
+
"result",
|
|
127
|
+
"rss",
|
|
128
|
+
"saml",
|
|
129
|
+
"sample",
|
|
130
|
+
"scim",
|
|
131
|
+
"scitt",
|
|
132
|
+
"search",
|
|
133
|
+
"seo",
|
|
134
|
+
"server-timing",
|
|
135
|
+
"session-storage-kv",
|
|
136
|
+
"spam",
|
|
137
|
+
"strings",
|
|
138
|
+
"structured-fields",
|
|
139
|
+
"trace-context",
|
|
140
|
+
"trailing-slash-middleware",
|
|
141
|
+
"types",
|
|
142
|
+
"u",
|
|
143
|
+
"ui",
|
|
144
|
+
"uri-template",
|
|
145
|
+
"validate",
|
|
146
|
+
"webhooks",
|
|
147
|
+
"websub",
|
|
148
|
+
"workers-cache",
|
|
149
|
+
"x402",
|
|
150
|
+
"xml",
|
|
151
|
+
"yaml",
|
|
152
|
+
"zip",
|
|
153
|
+
];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `sdxc pkg <name>` turns a typed name into a command: the package it names (or the one a
|
|
3
|
+
* typo most likely meant), the copy installed at or above the working directory when there is
|
|
4
|
+
* one, and otherwise `bunx`, or `npx` without Bun, downloading the published package.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Where a request for a package's command line is posted, with the package in the title. */
|
|
10
|
+
export declare const REQUEST_URL = "https://github.com/sergiodxa/monorepo/discussions/new?category=ideas";
|
|
11
|
+
/** What a typed name refers to. */
|
|
12
|
+
export type PackageLookup = {
|
|
13
|
+
kind: "command-line";
|
|
14
|
+
name: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "without-command-line";
|
|
17
|
+
name: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "unknown";
|
|
20
|
+
name: string;
|
|
21
|
+
suggestion: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The package `input` names. The package name, its `@sdxc/` specifier and its `sdxc-` binary
|
|
25
|
+
* name all resolve, so pasting any of the three works; any other name is unknown, with the
|
|
26
|
+
* nearest name that has a command line as its suggestion.
|
|
27
|
+
*
|
|
28
|
+
* @example lookupPackage("@sdxc/uuid") // { kind: "command-line", name: "uuid" }
|
|
29
|
+
* @example lookupPackage("uiid") // { kind: "unknown", name: "uiid", suggestion: "uuid" }
|
|
30
|
+
*/
|
|
31
|
+
export declare function lookupPackage(input: string): PackageLookup;
|
|
32
|
+
/**
|
|
33
|
+
* The link that opens a request for `name`'s command line in the Ideas discussions, titled
|
|
34
|
+
* with the package alone so nothing else from the command line leaves the machine.
|
|
35
|
+
*/
|
|
36
|
+
export declare function requestURL(name: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* The binary of `@sdxc/<name>` installed at or above `cwd`, or declared by a workspace that
|
|
39
|
+
* contains `cwd`, or `null` when neither holds it. A workspace runs its checked-out source,
|
|
40
|
+
* and a project runs the version it installs.
|
|
41
|
+
*/
|
|
42
|
+
export declare function installedBinary(cwd: string, name: string): Promise<string | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether an executable named `program` is in one of `path`'s directories. On Windows the file
|
|
45
|
+
* carries an extension, so `bun.exe` and `bun.cmd` count as `bun` there.
|
|
46
|
+
*
|
|
47
|
+
* @param platform - The operating system, as `process.platform` names it
|
|
48
|
+
*/
|
|
49
|
+
export declare function onPath(program: string, path: string | undefined, platform?: NodeJS.Platform): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* The release the project around `cwd` pins its `@sdxc` packages to, or `null` outside a
|
|
52
|
+
* project or in one that pins none, so a downloaded command line matches the project's code.
|
|
53
|
+
*/
|
|
54
|
+
export declare function projectRelease(cwd: string): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* The command that runs `name`'s command line with `args`: the installed binary under Bun when
|
|
57
|
+
* Bun is on `PATH` and under Node otherwise, or the published package through `bunx --bun`,
|
|
58
|
+
* falling back to `npx`. Bun runs an installed binary that is still TypeScript source.
|
|
59
|
+
*
|
|
60
|
+
* A download takes the package's newest version at `release`, since a daily release republishes
|
|
61
|
+
* only the packages that changed, or the newest version when `release` is `null`.
|
|
62
|
+
*
|
|
63
|
+
* @param binary - The installed binary, from `installedBinary`, or `null` to download it
|
|
64
|
+
* @param bun - Whether `bun` is on `PATH`
|
|
65
|
+
* @param release - The project's release, from `projectRelease`
|
|
66
|
+
*/
|
|
67
|
+
export declare function packageCommand(name: string, args: readonly string[], binary: string | null, bun: boolean, release?: string | null): string[];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `sdxc pkg <name>` turns a typed name into a command: the package it names (or the one a
|
|
3
|
+
* typo most likely meant), the copy installed at or above the working directory when there is
|
|
4
|
+
* one, and otherwise `bunx`, or `npx` without Bun, downloading the published package.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { readFile, stat } from "node:fs/promises";
|
|
10
|
+
import { delimiter, dirname, join } from "node:path";
|
|
11
|
+
import { closest } from "@sdxc/cli";
|
|
12
|
+
import { isFailure, isSuccess, wrap } from "@sdxc/result";
|
|
13
|
+
import { findProjectRoot } from "../project.js";
|
|
14
|
+
import { currentRelease, readManifest } from "../upgrade/project.js";
|
|
15
|
+
import { PACKAGE_COMMAND_LINES, PACKAGES_WITHOUT_COMMAND_LINES } from "./catalog.js";
|
|
16
|
+
/** Where a request for a package's command line is posted, with the package in the title. */
|
|
17
|
+
export const REQUEST_URL = "https://github.com/sergiodxa/monorepo/discussions/new?category=ideas";
|
|
18
|
+
/**
|
|
19
|
+
* The package `input` names. The package name, its `@sdxc/` specifier and its `sdxc-` binary
|
|
20
|
+
* name all resolve, so pasting any of the three works; any other name is unknown, with the
|
|
21
|
+
* nearest name that has a command line as its suggestion.
|
|
22
|
+
*
|
|
23
|
+
* @example lookupPackage("@sdxc/uuid") // { kind: "command-line", name: "uuid" }
|
|
24
|
+
* @example lookupPackage("uiid") // { kind: "unknown", name: "uiid", suggestion: "uuid" }
|
|
25
|
+
*/
|
|
26
|
+
export function lookupPackage(input) {
|
|
27
|
+
let name = input
|
|
28
|
+
.trim()
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/^@sdxc\//, "")
|
|
31
|
+
.replace(/^sdxc-/, "");
|
|
32
|
+
if (Object.hasOwn(PACKAGE_COMMAND_LINES, name))
|
|
33
|
+
return { kind: "command-line", name };
|
|
34
|
+
if (PACKAGES_WITHOUT_COMMAND_LINES.includes(name))
|
|
35
|
+
return { kind: "without-command-line", name };
|
|
36
|
+
return { kind: "unknown", name, suggestion: closest(name, Object.keys(PACKAGE_COMMAND_LINES)) };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The link that opens a request for `name`'s command line in the Ideas discussions, titled
|
|
40
|
+
* with the package alone so nothing else from the command line leaves the machine.
|
|
41
|
+
*/
|
|
42
|
+
export function requestURL(name) {
|
|
43
|
+
return `${REQUEST_URL}&title=${encodeURIComponent(`Command line for @sdxc/${name}`)}`;
|
|
44
|
+
}
|
|
45
|
+
/** The `package.json` in `dir`, or `null` when it is missing or unreadable. */
|
|
46
|
+
async function manifestIn(dir) {
|
|
47
|
+
let read = await wrap(async () => {
|
|
48
|
+
return JSON.parse(await readFile(join(dir, "package.json"), "utf8"));
|
|
49
|
+
});
|
|
50
|
+
return isSuccess(read) ? read.data : null;
|
|
51
|
+
}
|
|
52
|
+
/** The path of the `sdxc-<name>` binary a package in `dir` declares, or `null`. */
|
|
53
|
+
function binaryOf(dir, manifest, name) {
|
|
54
|
+
let bin = manifest.bin;
|
|
55
|
+
let target = typeof bin === "string" ? bin : bin?.[`sdxc-${name}`];
|
|
56
|
+
return target === undefined ? null : join(dir, target);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The folder of the workspace package named `@sdxc/<name>` that the workspace root `dir`
|
|
60
|
+
* declares, through a `packages/*`-style pattern or an exact path, or `null`.
|
|
61
|
+
*/
|
|
62
|
+
async function workspacePackage(dir, manifest, name) {
|
|
63
|
+
let patterns = Array.isArray(manifest.workspaces)
|
|
64
|
+
? manifest.workspaces
|
|
65
|
+
: (manifest.workspaces?.packages ?? []);
|
|
66
|
+
for (let pattern of patterns) {
|
|
67
|
+
let folder = pattern.endsWith("/*")
|
|
68
|
+
? join(dir, pattern.slice(0, -2), name)
|
|
69
|
+
: join(dir, pattern);
|
|
70
|
+
let candidate = await manifestIn(folder);
|
|
71
|
+
if (candidate?.name === `@sdxc/${name}`)
|
|
72
|
+
return { folder, manifest: candidate };
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The binary of `@sdxc/<name>` installed at or above `cwd`, or declared by a workspace that
|
|
78
|
+
* contains `cwd`, or `null` when neither holds it. A workspace runs its checked-out source,
|
|
79
|
+
* and a project runs the version it installs.
|
|
80
|
+
*/
|
|
81
|
+
export async function installedBinary(cwd, name) {
|
|
82
|
+
let dir = cwd;
|
|
83
|
+
for (;;) {
|
|
84
|
+
let installed = join(dir, "node_modules", "@sdxc", name);
|
|
85
|
+
let manifest = await manifestIn(installed);
|
|
86
|
+
if (manifest !== null)
|
|
87
|
+
return binaryOf(installed, manifest, name);
|
|
88
|
+
let root = await manifestIn(dir);
|
|
89
|
+
let member = root === null ? null : await workspacePackage(dir, root, name);
|
|
90
|
+
if (member !== null)
|
|
91
|
+
return binaryOf(member.folder, member.manifest, name);
|
|
92
|
+
let parent = dirname(dir);
|
|
93
|
+
if (parent === dir)
|
|
94
|
+
return null;
|
|
95
|
+
dir = parent;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether an executable named `program` is in one of `path`'s directories. On Windows the file
|
|
100
|
+
* carries an extension, so `bun.exe` and `bun.cmd` count as `bun` there.
|
|
101
|
+
*
|
|
102
|
+
* @param platform - The operating system, as `process.platform` names it
|
|
103
|
+
*/
|
|
104
|
+
export async function onPath(program, path, platform = process.platform) {
|
|
105
|
+
let names = platform === "win32" ? [`${program}.exe`, `${program}.cmd`, program] : [program];
|
|
106
|
+
for (let dir of (path ?? "").split(delimiter)) {
|
|
107
|
+
if (dir === "")
|
|
108
|
+
continue;
|
|
109
|
+
for (let name of names) {
|
|
110
|
+
if (isSuccess(await wrap(() => stat(join(dir, name)))))
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The release the project around `cwd` pins its `@sdxc` packages to, or `null` outside a
|
|
118
|
+
* project or in one that pins none, so a downloaded command line matches the project's code.
|
|
119
|
+
*/
|
|
120
|
+
export async function projectRelease(cwd) {
|
|
121
|
+
let root = await findProjectRoot(cwd);
|
|
122
|
+
if (isFailure(root))
|
|
123
|
+
return null;
|
|
124
|
+
let manifest = await readManifest(root.data);
|
|
125
|
+
return isFailure(manifest) ? null : currentRelease(manifest.data.manifest);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The command that runs `name`'s command line with `args`: the installed binary under Bun when
|
|
129
|
+
* Bun is on `PATH` and under Node otherwise, or the published package through `bunx --bun`,
|
|
130
|
+
* falling back to `npx`. Bun runs an installed binary that is still TypeScript source.
|
|
131
|
+
*
|
|
132
|
+
* A download takes the package's newest version at `release`, since a daily release republishes
|
|
133
|
+
* only the packages that changed, or the newest version when `release` is `null`.
|
|
134
|
+
*
|
|
135
|
+
* @param binary - The installed binary, from `installedBinary`, or `null` to download it
|
|
136
|
+
* @param bun - Whether `bun` is on `PATH`
|
|
137
|
+
* @param release - The project's release, from `projectRelease`
|
|
138
|
+
*/
|
|
139
|
+
export function packageCommand(name, args, binary, bun, release = null) {
|
|
140
|
+
if (binary !== null)
|
|
141
|
+
return [bun ? "bun" : "node", binary, ...args];
|
|
142
|
+
let specifier = release === null ? `@sdxc/${name}` : `@sdxc/${name}@<=${release}`;
|
|
143
|
+
let program = `sdxc-${name}`;
|
|
144
|
+
if (bun)
|
|
145
|
+
return ["bunx", "--bun", "--package", specifier, program, ...args];
|
|
146
|
+
return ["npx", "--yes", "--package", specifier, program, ...args];
|
|
147
|
+
}
|
|
@@ -12,16 +12,16 @@ import * as s from "@sdxc/json-schema";
|
|
|
12
12
|
export declare const CHANGELOG_FILE = "changelog.jsonl";
|
|
13
13
|
/** One line of the changelog; unknown keys are ignored so a newer file still reads. */
|
|
14
14
|
declare const ENTRY_SCHEMA: s.Schema<{
|
|
15
|
-
type: string;
|
|
16
15
|
title: string;
|
|
16
|
+
type: string;
|
|
17
17
|
body: string;
|
|
18
18
|
release: string;
|
|
19
19
|
package: string;
|
|
20
20
|
breaking: boolean;
|
|
21
21
|
correctedIn?: string | undefined;
|
|
22
22
|
}, {
|
|
23
|
-
type: string;
|
|
24
23
|
title: string;
|
|
24
|
+
type: string;
|
|
25
25
|
body: string;
|
|
26
26
|
release: string;
|
|
27
27
|
package: string;
|
|
@@ -12,15 +12,15 @@ declare const MANIFEST_SCHEMA: s.Schema<{
|
|
|
12
12
|
name?: string | undefined;
|
|
13
13
|
dependencies?: Record<string, string> | undefined;
|
|
14
14
|
devDependencies?: Record<string, string> | undefined;
|
|
15
|
-
packageManager?: string | undefined;
|
|
16
15
|
optionalDependencies?: Record<string, string> | undefined;
|
|
16
|
+
packageManager?: string | undefined;
|
|
17
17
|
scripts?: Record<string, string> | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
name?: string | undefined;
|
|
20
20
|
dependencies?: Record<string, string> | undefined;
|
|
21
21
|
devDependencies?: Record<string, string> | undefined;
|
|
22
|
-
packageManager?: string | undefined;
|
|
23
22
|
optionalDependencies?: Record<string, string> | undefined;
|
|
23
|
+
packageManager?: string | undefined;
|
|
24
24
|
scripts?: Record<string, string> | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
/** The project's `package.json` fields the upgrade reads. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/kit",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.3",
|
|
4
4
|
"description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -14,22 +14,24 @@
|
|
|
14
14
|
"./lock.schema.json": "./lock.schema.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sdxc/
|
|
17
|
+
"@sdxc/ci": "2026.11.3",
|
|
18
|
+
"@sdxc/cli": "2026.11.3",
|
|
18
19
|
"@sdxc/codemod": "2026.10.29",
|
|
19
|
-
"@sdxc/cron": "2026.
|
|
20
|
-
"@sdxc/diagram": "2026.
|
|
20
|
+
"@sdxc/cron": "2026.11.3",
|
|
21
|
+
"@sdxc/diagram": "2026.11.3",
|
|
21
22
|
"@sdxc/iife": "2026.10.23",
|
|
22
23
|
"@sdxc/json-schema": "2026.10.24",
|
|
23
|
-
"@sdxc/jsonc": "2026.
|
|
24
|
-
"@sdxc/jsonl": "2026.
|
|
24
|
+
"@sdxc/jsonc": "2026.11.3",
|
|
25
|
+
"@sdxc/jsonl": "2026.11.3",
|
|
26
|
+
"@sdxc/messageformat": "2026.10.23",
|
|
25
27
|
"@sdxc/result": "2026.10.13",
|
|
26
|
-
"@sdxc/semver": "2026.
|
|
28
|
+
"@sdxc/semver": "2026.11.3",
|
|
27
29
|
"oxc-parser": "^0.154.0"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
30
32
|
"remix": "3.1.0"
|
|
31
33
|
},
|
|
32
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d1dd4030f8df68b8a170940a3f790ea8654d3676",
|
|
33
35
|
"publishConfig": {
|
|
34
36
|
"access": "public"
|
|
35
37
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accordion",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"disclosure"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"source": {
|
|
11
11
|
"path": "accordion.tsx",
|
|
12
|
-
"content": "/**\n * A set of expand/collapse sections built on {@link Disclosure}, stacked into\n * one divider-separated list. Each section holds its state on its native\n * `<details>` element; giving sibling {@link Accordion.Item}s the same `name`\n * makes the set exclusive through the platform's `<details name>` behavior,\n * closing whichever section was open as another opens.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { bg, borderEdge, fg } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { justify, shrink } from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, pb, pbe, pi } from \"@sdxc/u/size\";\nimport { hover, open, when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { pretty, text, textDecoration } from \"@sdxc/u/typography\";\n\nimport { Disclosure } from \"@sdxc/ui/disclosure\";\n\n/**\n * Prop types for {@link Accordion} and its compound parts.\n */\nexport namespace Accordion {\n\t/**\n\t * Props accepted by {@link Accordion}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** One or more {@link Accordion.Item} sections to stack into a list. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Disclosure.Props} accepts, unchanged: the section's\n\t * `open` state and, when set to the same value across siblings, the\n\t * `name` that makes the group exclusive.\n\t */\n\texport interface ItemProps extends Disclosure.Props {}\n\n\t/** Every prop {@link Disclosure.TriggerProps} accepts, unchanged. */\n\texport interface TriggerProps extends Disclosure.TriggerProps {}\n\n\t/** Every prop {@link Disclosure.PanelProps} accepts, unchanged. */\n\texport interface ContentProps extends Disclosure.PanelProps {}\n}\n\n/**\n * Renders the list's root host: a plain `<div>` that stacks\n * {@link Accordion.Item} sections in normal block flow
|
|
12
|
+
"content": "/**\n * A set of expand/collapse sections built on {@link Disclosure}, stacked into\n * one divider-separated list. Each section holds its state on its native\n * `<details>` element; giving sibling {@link Accordion.Item}s the same `name`\n * makes the set exclusive through the platform's `<details name>` behavior,\n * closing whichever section was open as another opens.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { bg, borderEdge, fg } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { justify, shrink } from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, pb, pbe, pi } from \"@sdxc/u/size\";\nimport { hover, open, when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { pretty, text, textDecoration } from \"@sdxc/u/typography\";\n\nimport { Disclosure } from \"@sdxc/ui/disclosure\";\n\n/**\n * Prop types for {@link Accordion} and its compound parts.\n */\nexport namespace Accordion {\n\t/**\n\t * Props accepted by {@link Accordion}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** One or more {@link Accordion.Item} sections to stack into a list. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Disclosure.Props} accepts, unchanged: the section's\n\t * `open` state and, when set to the same value across siblings, the\n\t * `name` that makes the group exclusive.\n\t */\n\texport interface ItemProps extends Disclosure.Props {}\n\n\t/** Every prop {@link Disclosure.TriggerProps} accepts, unchanged. */\n\texport interface TriggerProps extends Disclosure.TriggerProps {}\n\n\t/** Every prop {@link Disclosure.PanelProps} accepts, unchanged. */\n\texport interface ContentProps extends Disclosure.PanelProps {}\n}\n\n/**\n * Renders the list's root host: a plain `<div>` that stacks\n * {@link Accordion.Item} sections in normal block flow under one top rule, each\n * drawing the divider below it, so the list reads as one group. A landing FAQ\n * lays two of these in a container-query grid under a {@link LandingHeader},\n * sharing one `name` across columns so only one item opens at a time.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Accordion>\n * \t<Accordion.Item>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.refunds.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * \t<Accordion.Item>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.shipping.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.shipping.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * </Accordion>\n * @example\n * <Accordion>\n * \t<Accordion.Item name=\"faq\" open>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.refunds.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * \t<Accordion.Item name=\"faq\">\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.shipping.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.shipping.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * </Accordion>\n */\nexport function Accordion(handle: Handle<Accordion.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[is(\"full\"), borderEdge(\"block-start\", { color: \"neutral\", width: 1, style: \"solid\" })],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * Renders one section as {@link Disclosure} restyled into a flush list row:\n * only a block-end divider survives, and {@link Accordion} draws the top rule, so\n * every closed section is the same height. A trigger marked `aria-disabled=\"true\"`\n * dims the whole section.\n *\n * @param handle Runtime handle carrying the host `<details>`'s props.\n * @returns The render function producing the section's markup.\n * @example\n * <Accordion.Item>\n * \t<Accordion.Trigger>\n * \t\t{t(\"faq.refunds.question\")}\n * \t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t</Accordion.Trigger>\n * \t<Accordion.Content>\n * \t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t</Accordion.Content>\n * </Accordion.Item>\n * @example\n * <Accordion.Item name=\"faq\" open>\n * \t<Accordion.Trigger>\n * \t\t{t(\"faq.refunds.question\")}\n * \t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t</Accordion.Trigger>\n * \t<Accordion.Content>\n * \t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t</Accordion.Content>\n * </Accordion.Item>\n */\nAccordion.Item = function AccordionItem(handle: Handle<Accordion.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\tborderEdge(\"inline-start\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\tborderEdge(\"inline-end\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\tborderEdge(\"block-start\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\t\topen(when('& summary [data-slot=\"icon\"]', rotate(180))),\n\t\t\t\t\t\twhen('&:has(> summary[aria-disabled=\"true\"])', opacity(50)),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Accordion.TriggerProps.children} as the section's label row,\n * spread to opposite ends and underlined on hover. An icon element carrying\n * `data-slot=\"icon\"` rotates 180 degrees while its section is open.\n *\n * @param handle Runtime handle carrying the host `<summary>`'s props.\n * @returns The render function producing the label row's markup.\n * @example\n * <Accordion.Trigger>\n * \t{t(\"faq.refunds.question\")}\n * \t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * </Accordion.Trigger>\n * @example\n * <Accordion.Trigger aria-disabled=\"true\">\n * \t{t(\"faq.archived.question\")}\n * \t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * </Accordion.Trigger>\n */\nAccordion.Trigger = function AccordionTrigger(handle: Handle<Accordion.TriggerProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure.Trigger\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\t\tpb(4),\n\t\t\t\t\t\tpi(0),\n\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The row runs flush to the column edge, so the focus ring is drawn inside it\n\t\t\t\t\t\t * where an outer offset would be clipped by the band.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(\"&:focus-visible\", raw({ outlineOffset: \"-2px\" })),\n\t\t\t\t\t\thover([bg(\"transparent\"), textDecoration(\"underline\")]),\n\t\t\t\t\t\twhen('& [data-slot=\"icon\"]', [\n\t\t\t\t\t\t\tis(4),\n\t\t\t\t\t\t\tbs(4),\n\t\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\t\ttransition(\"transform\", { duration: \"200ms\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tmedia(\n\t\t\t\t\t\t\t\"(prefers-reduced-motion: reduce)\",\n\t\t\t\t\t\t\twhen('& [data-slot=\"icon\"]', transitionDuration(\"0s\")),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Accordion.ContentProps.children} as the section's revealed body:\n * {@link Disclosure.Panel} running edge to edge like its trigger, with block-end\n * padding and small, muted text sized for supporting copy.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body's markup.\n * @example\n * <Accordion.Content>\n * \t<p>{t(\"faq.refunds.answer\")}</p>\n * </Accordion.Content>\n */\nAccordion.Content = function AccordionContent(handle: Handle<Accordion.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure.Panel\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([pi(0), pbe(4), fg(\"neutral\"), text(\"sm\"), pretty()], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
13
13
|
},
|
|
14
14
|
"test": null
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alert-dialog",
|
|
3
|
-
"changedIn": "2026.
|
|
3
|
+
"changedIn": "2026.11.1",
|
|
4
4
|
"dependencies": [
|
|
5
5
|
"button",
|
|
6
6
|
"dialog",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"source": {
|
|
13
13
|
"path": "alert-dialog.tsx",
|
|
14
|
-
"content": "/**\n * An interruptive modal surface that demands an explicit response before a\n * page continues — confirming a destructive action, surfacing a blocking\n * error — built on the native `<dialog>` host of {@link Dialog}, widened for\n * its two-button layout and sealed against light dismiss. Its compound parts\n * cover a header, title, description, and a two-control footer.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fg } from \"@sdxc/u/color\";\nimport { flex, gap, justify, vstack } from \"@sdxc/u/layout\";\nimport { mbs } from \"@sdxc/u/size\";\nimport { balance, pretty, text, weight } from \"@sdxc/u/typography\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { Dialog } from \"@sdxc/ui/dialog\";\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/**\n * Invoker Commands verb {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} fall back to when `command` is omitted,\n * dismissing the ancestor AlertDialog named by `commandfor`.\n */\nconst DEFAULT_COMMAND = \"close\";\n\n/**\n * Native `button` `type` {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} always spell out, since the platform runs an\n * Invoker Command only from a button typed `\"button\"`, `<form>` or not.\n */\nconst DEFAULT_TYPE: NonNullable<Button.Props[\"type\"]> = \"button\";\n\n/** Semantic color role {@link AlertDialog.Action} falls back to when `color` is omitted. */\nconst DEFAULT_ACTION_COLOR: Button.Color = \"danger\";\n\n/** Visual weight {@link AlertDialog.Cancel} falls back to when `variant` is omitted. */\nconst DEFAULT_CANCEL_VARIANT: Button.Variant = \"outline\";\n\n/** Semantic color role {@link AlertDialog.Cancel} falls back to when `color` is omitted. */\nconst DEFAULT_CANCEL_COLOR: Button.Color = \"neutral\";\n\n/**\n * Prop types for {@link AlertDialog} and its compound parts.\n */\nexport namespace AlertDialog {\n\t/**\n\t * Every prop {@link Dialog} accepts, minus the ones this component fixes:\n\t * `role` is always `\"alertdialog\"` and `closedby`/`closedBy` always\n\t * `\"closerequest\"`, so the panel closes only on an explicit close request.\n\t */\n\texport interface Props extends Omit<Dialog.Props, \"role\" | \"closedby\" | \"closedBy\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Header}.\n\t */\n\texport interface HeaderProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Title}. Every native heading-element\n\t * attribute applies, since the rendered tag follows the nearest ambient\n\t * heading level, falling back to `<h1>`.\n\t */\n\texport interface TitleProps extends TagProps<\"h1\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Footer}.\n\t */\n\texport interface FooterProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Action}: every {@link Button.Props}\n\t * field except `commandfor`/`command`, which this type narrows.\n\t */\n\texport interface ActionProps extends Omit<Button.Props, \"commandfor\" | \"command\"> {\n\t\t/**\n\t\t * `id` of the ancestor {@link AlertDialog} this action dismisses.\n\t\t * Required for the default `type=\"button\"` action; a `type=\"submit\"`\n\t\t * action ends the interruption by submitting its enclosing form.\n\t\t */\n\t\tcommandfor?: string;\n\t\t/**\n\t\t * Invoker Commands verb dispatched to the target AlertDialog. Defaults\n\t\t * to `\"close\"`, and is dropped for a `\"submit\"` or `\"reset\"` action,\n\t\t * which the platform drives as a form control instead of an invoker.\n\t\t */\n\t\tcommand?: \"close\";\n\t}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Cancel}: every {@link Button.Props}\n\t * field except `commandfor`/`command`/`type`, which this type narrows.\n\t */\n\texport interface CancelProps extends Omit<Button.Props, \"commandfor\" | \"command\" | \"type\"> {\n\t\t/** `id` of the ancestor {@link AlertDialog} this cancel control dismisses. */\n\t\tcommandfor: string;\n\t\t/** Invoker Commands verb dispatched to the target AlertDialog. Defaults to `\"close\"`. */\n\t\tcommand?: \"close\";\n\t\t/**\n\t\t * Narrowed to the only value a cancel control carries, and always\n\t\t * rendered, since the platform runs its close command only from a\n\t\t * button typed `\"button\"`, including inside a `<form>`.\n\t\t */\n\t\ttype?: \"button\";\n\t}\n}\n\n/**\n * Renders the alert panel through {@link Dialog}, widened to fit a two-button\n * footer, with `role` fixed to `\"alertdialog\"` and `closedby` to\n * `\"closerequest\"` so the interruption clears through an explicit response.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <Button commandfor=\"delete-project\" command=\"show-modal\" color=\"danger\">{t(\"project.delete\")}</Button>\n * <AlertDialog id=\"delete-project\" aria-labelledby=\"delete-project-title\">\n * \t<AlertDialog.Header>\n * \t\t<AlertDialog.Title id=\"delete-project-title\">{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t\t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * \t</AlertDialog.Header>\n * \t<AlertDialog.Footer>\n * \t\t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t\t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * \t</AlertDialog.Footer>\n * </AlertDialog>\n */\nexport function AlertDialog(handle: Handle<AlertDialog.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Dialog {...rest} role=\"alertdialog\" closedby=\"closerequest\" mix={mix}>\n\t\t\t\t{children}\n\t\t\t</Dialog>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link AlertDialog.HeaderProps.children} as the panel's header\n * slot: a column stacking {@link AlertDialog.Title} and\n * {@link AlertDialog.Description} with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <AlertDialog.Header>\n * \t<AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * </AlertDialog.Header>\n */\nAlertDialog.Header = function AlertDialogHeader(handle: Handle<AlertDialog.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"header\" mix={[vstack({ gap: 2 }), mix]} />;\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.TitleProps.children} as the panel's heading,\n * inside the native heading element matching the nearest ancestor\n * `HeadingScope`'s depth, or `<h1>` where no scope wraps it.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the heading's markup.\n * @example\n * <AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n */\nAlertDialog.Title = function AlertDialogTitle(handle: Handle<AlertDialog.TitleProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle);\n\t\tlet Tag = TAG_BY_LEVEL[resolved];\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"title\"\n\t\t\t\tmix={[fg(\"neutral.emphasis\"), weight(\"semibold\"), text(\"lg\"), balance(), mix]}\n\t\t\t>\n\t\t\t\t{rest.children}\n\t\t\t</Tag>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.DescriptionProps.children} as the panel's\n * supporting copy, in a native `<p>` set to the panel's muted foreground\n * color so it reads as secondary to {@link AlertDialog.Title}.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n * @example\n * <AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n */\nAlertDialog.Description = function AlertDialogDescription(\n\thandle: Handle<AlertDialog.DescriptionProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p {...rest} data-slot=\"description\" mix={[fg(\"neutral.muted\"), text(\"sm\"), pretty(), mix]}>\n\t\t\t\t{rest.children}\n\t\t\t</p>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.FooterProps.children} as an end-aligned action\n * row. Compose {@link AlertDialog.Cancel} before {@link AlertDialog.Action}\n * so the emphasized, potentially destructive control renders last.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action row's markup.\n * @example\n * <AlertDialog.Footer>\n * \t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * </AlertDialog.Footer>\n */\nAlertDialog.Footer = function AlertDialogFooter(handle: Handle<AlertDialog.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"footer\" mix={[gap(2), mbs(6), flex(), justify(\"end\"), mix]} />;\n\t};\n};\n\n/**\n * Renders the panel's emphasized action as a danger-toned {@link Button},\n * typed `\"button\"` so its `command=\"close\"` reaches the {@link AlertDialog}\n * named by `commandfor`; `type=\"submit\"` submits the enclosing form instead.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the action's markup.\n * @example\n * <AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action commandfor=\"publish-post\" color=\"brand\">{t(\"actions.publish\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action type=\"submit\" name=\"intent\" value=\"delete\">{t(\"actions.delete\")}</AlertDialog.Action>\n */\nAlertDialog.Action = function AlertDialogAction(handle: Handle<AlertDialog.ActionProps>) {\n\treturn () => {\n\t\tlet { type, color, command, commandfor, ...rest } = handle.props;\n\t\tlet resolvedType = type ?? DEFAULT_TYPE;\n\t\tlet isInvoker = resolvedType === \"button\";\n\t\tlet resolvedColor = color ?? DEFAULT_ACTION_COLOR;\n\n\t\tif (import.meta.env?.DEV && isInvoker && !commandfor) {\n\t\t\tconsole.warn(\n\t\t\t\t'AlertDialog.Action: needs \"commandfor\" naming the panel it dismisses, or type=\"submit\" to submit its enclosing form instead — as rendered, pressing it does nothing.',\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={resolvedType}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommandfor={isInvoker ? commandfor : undefined}\n\t\t\t\tcommand={isInvoker ? (command ?? DEFAULT_COMMAND) : undefined}\n\t\t\t\tdata-slot=\"action\"\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the panel's dismiss control as an outline, neutral {@link Button}\n * with `type` fixed to `\"button\"`, so its `command=\"close\"` reaches the\n * {@link AlertDialog} named by `commandfor` from inside a `<form>` too.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the cancel control's markup.\n * @example\n * <AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n */\nAlertDialog.Cancel = function AlertDialogCancel(handle: Handle<AlertDialog.CancelProps>) {\n\treturn () => {\n\t\tlet { variant, color, command, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_CANCEL_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_CANCEL_COLOR;\n\t\tlet resolvedCommand = command ?? DEFAULT_COMMAND;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={DEFAULT_TYPE}\n\t\t\t\tvariant={resolvedVariant}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\tdata-slot=\"cancel\"\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
14
|
+
"content": "/**\n * An interruptive modal surface that demands an explicit response before a\n * page continues — confirming a destructive action, surfacing a blocking\n * error — built on the native `<dialog>` host of {@link Dialog}, widened for\n * its two-button layout and sealed against light dismiss. Its compound parts\n * cover a header, title, description, and a two-control footer.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fg } from \"@sdxc/u/color\";\nimport { mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, justify, vstack } from \"@sdxc/u/layout\";\nimport { mbs } from \"@sdxc/u/size\";\nimport { balance, pretty, text, weight } from \"@sdxc/u/typography\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { Dialog } from \"@sdxc/ui/dialog\";\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/**\n * Invoker Commands verb {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} fall back to when `command` is omitted,\n * dismissing the ancestor AlertDialog named by `commandfor`.\n */\nconst DEFAULT_COMMAND = \"close\";\n\n/**\n * Native `button` `type` {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} always spell out, since the platform runs an\n * Invoker Command only from a button typed `\"button\"`, `<form>` or not.\n */\nconst DEFAULT_TYPE: NonNullable<Button.Props[\"type\"]> = \"button\";\n\n/** Semantic color role {@link AlertDialog.Action} falls back to when `color` is omitted. */\nconst DEFAULT_ACTION_COLOR: Button.Color = \"danger\";\n\n/** Visual weight {@link AlertDialog.Cancel} falls back to when `variant` is omitted. */\nconst DEFAULT_CANCEL_VARIANT: Button.Variant = \"outline\";\n\n/** Semantic color role {@link AlertDialog.Cancel} falls back to when `color` is omitted. */\nconst DEFAULT_CANCEL_COLOR: Button.Color = \"neutral\";\n\n/**\n * Prop types for {@link AlertDialog} and its compound parts.\n */\nexport namespace AlertDialog {\n\t/**\n\t * Every prop {@link Dialog} accepts, minus the ones this component fixes:\n\t * `role` is always `\"alertdialog\"` and `closedby`/`closedBy` always\n\t * `\"closerequest\"`, so the panel closes only on an explicit close request.\n\t */\n\texport interface Props extends Omit<Dialog.Props, \"role\" | \"closedby\" | \"closedBy\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Header}.\n\t */\n\texport interface HeaderProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Title}. Every native heading-element\n\t * attribute applies, since the rendered tag follows the nearest ambient\n\t * heading level, falling back to `<h1>`.\n\t */\n\texport interface TitleProps extends TagProps<\"h1\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Footer}.\n\t */\n\texport interface FooterProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Action}: every {@link Button.Props}\n\t * field except `commandfor`/`command`, which this type narrows.\n\t */\n\texport interface ActionProps extends Omit<Button.Props, \"commandfor\" | \"command\"> {\n\t\t/**\n\t\t * `id` of the ancestor {@link AlertDialog} this action dismisses.\n\t\t * Required for the default `type=\"button\"` action; a `type=\"submit\"`\n\t\t * action ends the interruption by submitting its enclosing form.\n\t\t */\n\t\tcommandfor?: string;\n\t\t/**\n\t\t * Invoker Commands verb dispatched to the target AlertDialog. Defaults\n\t\t * to `\"close\"`, and is dropped for a `\"submit\"` or `\"reset\"` action,\n\t\t * which the platform drives as a form control instead of an invoker.\n\t\t */\n\t\tcommand?: \"close\";\n\t}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Cancel}: every {@link Button.Props}\n\t * field except `commandfor`/`command`/`type`, which this type narrows.\n\t */\n\texport interface CancelProps extends Omit<Button.Props, \"commandfor\" | \"command\" | \"type\"> {\n\t\t/** `id` of the ancestor {@link AlertDialog} this cancel control dismisses. */\n\t\tcommandfor: string;\n\t\t/** Invoker Commands verb dispatched to the target AlertDialog. Defaults to `\"close\"`. */\n\t\tcommand?: \"close\";\n\t\t/**\n\t\t * Narrowed to the only value a cancel control carries, and always\n\t\t * rendered, since the platform runs its close command only from a\n\t\t * button typed `\"button\"`, including inside a `<form>`.\n\t\t */\n\t\ttype?: \"button\";\n\t}\n}\n\n/**\n * Renders the alert panel through {@link Dialog}, widened to fit a two-button\n * footer, with `role` fixed to `\"alertdialog\"` and `closedby` to\n * `\"closerequest\"` so the interruption clears through an explicit response.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <Button commandfor=\"delete-project\" command=\"show-modal\" color=\"danger\">{t(\"project.delete\")}</Button>\n * <AlertDialog id=\"delete-project\" aria-labelledby=\"delete-project-title\">\n * \t<AlertDialog.Header>\n * \t\t<AlertDialog.Title id=\"delete-project-title\">{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t\t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * \t</AlertDialog.Header>\n * \t<AlertDialog.Footer>\n * \t\t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t\t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * \t</AlertDialog.Footer>\n * </AlertDialog>\n */\nexport function AlertDialog(handle: Handle<AlertDialog.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Dialog {...rest} role=\"alertdialog\" closedby=\"closerequest\" mix={mix}>\n\t\t\t\t{children}\n\t\t\t</Dialog>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link AlertDialog.HeaderProps.children} as the panel's header\n * slot: a column stacking {@link AlertDialog.Title} and\n * {@link AlertDialog.Description} with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <AlertDialog.Header>\n * \t<AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * </AlertDialog.Header>\n */\nAlertDialog.Header = function AlertDialogHeader(handle: Handle<AlertDialog.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"header\" mix={mergeMix(vstack({ gap: 2 }), mix)} />;\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.TitleProps.children} as the panel's heading,\n * inside the native heading element matching the nearest ancestor\n * `HeadingScope`'s depth, or `<h1>` where no scope wraps it.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the heading's markup.\n * @example\n * <AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n */\nAlertDialog.Title = function AlertDialogTitle(handle: Handle<AlertDialog.TitleProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle);\n\t\tlet Tag = TAG_BY_LEVEL[resolved];\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"title\"\n\t\t\t\tmix={mergeMix([fg(\"neutral.emphasis\"), weight(\"semibold\"), text(\"lg\"), balance()], mix)}\n\t\t\t>\n\t\t\t\t{rest.children}\n\t\t\t</Tag>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.DescriptionProps.children} as the panel's\n * supporting copy, in a native `<p>` set to the panel's muted foreground\n * color so it reads as secondary to {@link AlertDialog.Title}.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n * @example\n * <AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n */\nAlertDialog.Description = function AlertDialogDescription(\n\thandle: Handle<AlertDialog.DescriptionProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"description\"\n\t\t\t\tmix={mergeMix([fg(\"neutral.muted\"), text(\"sm\"), pretty()], mix)}\n\t\t\t>\n\t\t\t\t{rest.children}\n\t\t\t</p>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.FooterProps.children} as an end-aligned action\n * row. Compose {@link AlertDialog.Cancel} before {@link AlertDialog.Action}\n * so the emphasized, potentially destructive control renders last.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action row's markup.\n * @example\n * <AlertDialog.Footer>\n * \t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * </AlertDialog.Footer>\n */\nAlertDialog.Footer = function AlertDialogFooter(handle: Handle<AlertDialog.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"footer\"\n\t\t\t\tmix={mergeMix([gap(2), mbs(6), flex(), justify(\"end\")], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the panel's emphasized action as a danger-toned {@link Button},\n * typed `\"button\"` so its `command=\"close\"` reaches the {@link AlertDialog}\n * named by `commandfor`; `type=\"submit\"` submits the enclosing form instead.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the action's markup.\n * @example\n * <AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action commandfor=\"publish-post\" color=\"brand\">{t(\"actions.publish\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action type=\"submit\" name=\"intent\" value=\"delete\">{t(\"actions.delete\")}</AlertDialog.Action>\n */\nAlertDialog.Action = function AlertDialogAction(handle: Handle<AlertDialog.ActionProps>) {\n\treturn () => {\n\t\tlet { type, color, command, commandfor, ...rest } = handle.props;\n\t\tlet resolvedType = type ?? DEFAULT_TYPE;\n\t\tlet isInvoker = resolvedType === \"button\";\n\t\tlet resolvedColor = color ?? DEFAULT_ACTION_COLOR;\n\n\t\tif (import.meta.env?.DEV && isInvoker && !commandfor) {\n\t\t\tconsole.warn(\n\t\t\t\t'AlertDialog.Action: needs \"commandfor\" naming the panel it dismisses, or type=\"submit\" to submit its enclosing form instead — as rendered, pressing it does nothing.',\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={resolvedType}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommandfor={isInvoker ? commandfor : undefined}\n\t\t\t\tcommand={isInvoker ? (command ?? DEFAULT_COMMAND) : undefined}\n\t\t\t\tdata-slot=\"action\"\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the panel's dismiss control as an outline, neutral {@link Button}\n * with `type` fixed to `\"button\"`, so its `command=\"close\"` reaches the\n * {@link AlertDialog} named by `commandfor` from inside a `<form>` too.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the cancel control's markup.\n * @example\n * <AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n */\nAlertDialog.Cancel = function AlertDialogCancel(handle: Handle<AlertDialog.CancelProps>) {\n\treturn () => {\n\t\tlet { variant, color, command, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_CANCEL_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_CANCEL_COLOR;\n\t\tlet resolvedCommand = command ?? DEFAULT_COMMAND;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={DEFAULT_TYPE}\n\t\t\t\tvariant={resolvedVariant}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\tdata-slot=\"cancel\"\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
15
15
|
},
|
|
16
16
|
"test": {
|
|
17
17
|
"path": "alert-dialog.test.tsx",
|