@stealthscale/component-actions 0.2.2 → 0.2.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/dist/cyclonedx/bom.json +1 -1
- package/dist/index.js +1 -996
- package/dist/pages/button/button.js +323 -0
- package/dist/pages/button/button.props.js +3 -0
- package/dist/pages/clipboard/clipboard.js +400 -0
- package/dist/pages/clipboard/clipboard.props.js +3 -0
- package/dist/pages/color-mode-toggle/color-mode-toggle.js +176 -0
- package/dist/pages/color-mode-toggle/color-mode-toggle.props.js +3 -0
- package/dist/pages/download-trigger/download-trigger.js +401 -0
- package/dist/pages/download-trigger/download-trigger.props.js +3 -0
- package/dist/pages/pages.json +74 -0
- package/dist/pages/swap/swap.js +379 -0
- package/dist/pages/swap/swap.props.js +3 -0
- package/dist/pages/toggle-group/toggle-group.js +326 -0
- package/dist/pages/toggle-group/toggle-group.props.js +3 -0
- package/dist/shared-Dv6Wx5nA.js +997 -0
- package/dist/theme.js +1 -1
- package/locales/en/specimen/button.json +39 -0
- package/locales/en/specimen/clipboard.json +33 -0
- package/locales/en/specimen/color-mode-toggle.json +14 -0
- package/locales/en/specimen/download-trigger.json +34 -0
- package/locales/en/specimen/swap.json +30 -0
- package/locales/en/specimen/toggle-group.json +48 -0
- package/package.json +5 -4
- /package/dist/{recipe-BhcK7PNL.js → recipes-BhcK7PNL.js} +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { a as download, b as Button, i as DownloadTrigger } from "../../shared-Dv6Wx5nA.js";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Room, Sample, specimen, useWords } from "@stealthscale/specimen";
|
|
7
|
+
import { ChevronDownIcon, DownloadIcon, LoaderCircleIcon } from "lucide-react";
|
|
8
|
+
import { Icon } from "@stealthscale/component-typography";
|
|
9
|
+
import { Table } from "@stealthscale/component-collections";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
11
|
+
import { Menu } from "@stealthscale/component-disclosure";
|
|
12
|
+
//#region src/download-trigger/examples/compressed.example.tsx
|
|
13
|
+
var compressed_example_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
Compressed: () => Compressed,
|
|
15
|
+
source: () => source$3
|
|
16
|
+
});
|
|
17
|
+
const ROWS = 2e4;
|
|
18
|
+
function Compressed() {
|
|
19
|
+
const { t } = useWords("download-trigger");
|
|
20
|
+
const [pending, setPending] = useState(false);
|
|
21
|
+
async function compress() {
|
|
22
|
+
setPending(true);
|
|
23
|
+
try {
|
|
24
|
+
const lines = Array.from({ length: ROWS }, (_, row) => `payout-${row},settled,${row * 7}`);
|
|
25
|
+
const gzip = new Blob([["payout,state,amount", ...lines].join("\n")]).stream().pipeThrough(new CompressionStream("gzip"));
|
|
26
|
+
return await new Response(gzip, { headers: { "Content-Type": "application/gzip" } }).blob();
|
|
27
|
+
} finally {
|
|
28
|
+
setPending(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ jsxs(DownloadTrigger, {
|
|
32
|
+
"aria-disabled": pending,
|
|
33
|
+
data: compress,
|
|
34
|
+
fileName: "payouts.csv.gz",
|
|
35
|
+
onClick: (event) => {
|
|
36
|
+
if (pending) event.preventDefault();
|
|
37
|
+
},
|
|
38
|
+
variant: "outline",
|
|
39
|
+
children: [pending ? /* @__PURE__ */ jsx(Icon, {
|
|
40
|
+
"aria-hidden": false,
|
|
41
|
+
"aria-label": t("compressing"),
|
|
42
|
+
as: LoaderCircleIcon,
|
|
43
|
+
motion: "spin"
|
|
44
|
+
}) : /* @__PURE__ */ jsx(DownloadIcon, { size: "1em" }), t("payouts")]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const source$3 = "import { type ReactElement, useState } from \"react\";\n\nimport { DownloadIcon, LoaderCircleIcon } from \"lucide-react\";\n\nimport { Icon } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DownloadTrigger } from \"@stealthscale/component-actions\";\n\nconst ROWS = 20_000;\n\nexport function Compressed(): ReactElement {\n const { t } = useWords(\"download-trigger\");\n const [pending, setPending] = useState(false);\n\n async function compress(): Promise<Blob> {\n setPending(true);\n\n try {\n const lines = Array.from({ length: ROWS }, (_, row) => `payout-${row},settled,${row * 7}`);\n const text = new Blob([[\"payout,state,amount\", ...lines].join(\"\\n\")]);\n const gzip = text.stream().pipeThrough(new CompressionStream(\"gzip\"));\n\n return await new Response(gzip, { headers: { \"Content-Type\": \"application/gzip\" } }).blob();\n } finally {\n setPending(false);\n }\n }\n\n return (\n <DownloadTrigger\n aria-disabled={pending}\n data={compress}\n fileName=\"payouts.csv.gz\"\n onClick={(event) => {\n if (pending) event.preventDefault();\n }}\n variant=\"outline\"\n >\n {pending ? (\n <Icon\n aria-hidden={false}\n aria-label={t(\"compressing\")}\n as={LoaderCircleIcon}\n motion=\"spin\"\n />\n ) : (\n <DownloadIcon size=\"1em\" />\n )}\n {t(\"payouts\")}\n </DownloadTrigger>\n );\n}\n";
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/download-trigger/examples/exports.example.tsx
|
|
50
|
+
var exports_example_exports = /* @__PURE__ */ __exportAll({
|
|
51
|
+
Exports: () => Exports,
|
|
52
|
+
source: () => source$2
|
|
53
|
+
});
|
|
54
|
+
const EXPORTS = [
|
|
55
|
+
{
|
|
56
|
+
data: "account,amount\nBridge Ledger,4120.00\nHalden & Co,880.40",
|
|
57
|
+
fileName: "ledger.csv",
|
|
58
|
+
mimeType: "text/csv"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
data: JSON.stringify({
|
|
62
|
+
held: 12,
|
|
63
|
+
raised: 240,
|
|
64
|
+
settled: 3
|
|
65
|
+
}, void 0, 2),
|
|
66
|
+
fileName: "totals.json",
|
|
67
|
+
mimeType: "application/json"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
data: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\"><rect width=\"48\" height=\"48\" rx=\"10\"/></svg>",
|
|
71
|
+
fileName: "mark.svg",
|
|
72
|
+
mimeType: "image/svg+xml"
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
function triggerOf(row) {
|
|
76
|
+
return /* @__PURE__ */ jsx(DownloadTrigger, {
|
|
77
|
+
"aria-label": row.label,
|
|
78
|
+
data: row.data,
|
|
79
|
+
fileName: row.fileName,
|
|
80
|
+
mimeType: row.mimeType,
|
|
81
|
+
shape: "square",
|
|
82
|
+
size: "sm",
|
|
83
|
+
variant: "ghost",
|
|
84
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, { size: "1em" })
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function Exports() {
|
|
88
|
+
const $ = c(29);
|
|
89
|
+
const { i18n, t } = useWords("download-trigger");
|
|
90
|
+
let t0;
|
|
91
|
+
if ($[0] !== i18n.language) {
|
|
92
|
+
t0 = new Intl.NumberFormat(i18n.language, {
|
|
93
|
+
style: "unit",
|
|
94
|
+
unit: "byte",
|
|
95
|
+
unitDisplay: "long"
|
|
96
|
+
});
|
|
97
|
+
$[0] = i18n.language;
|
|
98
|
+
$[1] = t0;
|
|
99
|
+
} else t0 = $[1];
|
|
100
|
+
const size = t0;
|
|
101
|
+
let t1;
|
|
102
|
+
if ($[2] !== t) {
|
|
103
|
+
t1 = t("exports");
|
|
104
|
+
$[2] = t;
|
|
105
|
+
$[3] = t1;
|
|
106
|
+
} else t1 = $[3];
|
|
107
|
+
let t2;
|
|
108
|
+
if ($[4] !== t) {
|
|
109
|
+
t2 = t("file");
|
|
110
|
+
$[4] = t;
|
|
111
|
+
$[5] = t2;
|
|
112
|
+
} else t2 = $[5];
|
|
113
|
+
let t3;
|
|
114
|
+
if ($[6] !== t2) {
|
|
115
|
+
t3 = {
|
|
116
|
+
key: "fileName",
|
|
117
|
+
label: t2,
|
|
118
|
+
rowHeader: true
|
|
119
|
+
};
|
|
120
|
+
$[6] = t2;
|
|
121
|
+
$[7] = t3;
|
|
122
|
+
} else t3 = $[7];
|
|
123
|
+
let t4;
|
|
124
|
+
if ($[8] !== size) {
|
|
125
|
+
t4 = (row) => size.format(new Blob([row.data]).size);
|
|
126
|
+
$[8] = size;
|
|
127
|
+
$[9] = t4;
|
|
128
|
+
} else t4 = $[9];
|
|
129
|
+
let t5;
|
|
130
|
+
if ($[10] !== t) {
|
|
131
|
+
t5 = t("size");
|
|
132
|
+
$[10] = t;
|
|
133
|
+
$[11] = t5;
|
|
134
|
+
} else t5 = $[11];
|
|
135
|
+
let t6;
|
|
136
|
+
if ($[12] !== t4 || $[13] !== t5) {
|
|
137
|
+
t6 = {
|
|
138
|
+
cell: t4,
|
|
139
|
+
key: "size",
|
|
140
|
+
label: t5,
|
|
141
|
+
numeric: true
|
|
142
|
+
};
|
|
143
|
+
$[12] = t4;
|
|
144
|
+
$[13] = t5;
|
|
145
|
+
$[14] = t6;
|
|
146
|
+
} else t6 = $[14];
|
|
147
|
+
let t7;
|
|
148
|
+
if ($[15] !== t) {
|
|
149
|
+
t7 = t("download");
|
|
150
|
+
$[15] = t;
|
|
151
|
+
$[16] = t7;
|
|
152
|
+
} else t7 = $[16];
|
|
153
|
+
let t8;
|
|
154
|
+
if ($[17] !== t7) {
|
|
155
|
+
t8 = {
|
|
156
|
+
cell: triggerOf,
|
|
157
|
+
key: "download",
|
|
158
|
+
label: t7
|
|
159
|
+
};
|
|
160
|
+
$[17] = t7;
|
|
161
|
+
$[18] = t8;
|
|
162
|
+
} else t8 = $[18];
|
|
163
|
+
let t9;
|
|
164
|
+
if ($[19] !== t3 || $[20] !== t6 || $[21] !== t8) {
|
|
165
|
+
t9 = [
|
|
166
|
+
t3,
|
|
167
|
+
t6,
|
|
168
|
+
t8
|
|
169
|
+
];
|
|
170
|
+
$[19] = t3;
|
|
171
|
+
$[20] = t6;
|
|
172
|
+
$[21] = t8;
|
|
173
|
+
$[22] = t9;
|
|
174
|
+
} else t9 = $[22];
|
|
175
|
+
let t10;
|
|
176
|
+
if ($[23] !== t) {
|
|
177
|
+
t10 = EXPORTS.map((t11) => {
|
|
178
|
+
const { data, fileName, mimeType } = t11;
|
|
179
|
+
return {
|
|
180
|
+
data,
|
|
181
|
+
fileName,
|
|
182
|
+
label: t("save", { file: fileName }),
|
|
183
|
+
mimeType
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
$[23] = t;
|
|
187
|
+
$[24] = t10;
|
|
188
|
+
} else t10 = $[24];
|
|
189
|
+
let t11;
|
|
190
|
+
if ($[25] !== t1 || $[26] !== t10 || $[27] !== t9) {
|
|
191
|
+
t11 = /* @__PURE__ */ jsx(Table.Simple, {
|
|
192
|
+
caption: t1,
|
|
193
|
+
columns: t9,
|
|
194
|
+
rows: t10,
|
|
195
|
+
rowToKey: _temp$1
|
|
196
|
+
});
|
|
197
|
+
$[25] = t1;
|
|
198
|
+
$[26] = t10;
|
|
199
|
+
$[27] = t9;
|
|
200
|
+
$[28] = t11;
|
|
201
|
+
} else t11 = $[28];
|
|
202
|
+
return t11;
|
|
203
|
+
}
|
|
204
|
+
function _temp$1(row_0) {
|
|
205
|
+
return row_0.fileName;
|
|
206
|
+
}
|
|
207
|
+
const source$2 = "import { type ReactElement } from \"react\";\n\nimport { DownloadIcon } from \"lucide-react\";\n\nimport { Table } from \"@stealthscale/component-collections\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DownloadTrigger } from \"@stealthscale/component-actions\";\n\ninterface Export {\n readonly data: string;\n readonly fileName: string;\n readonly label: string;\n readonly mimeType: string;\n}\n\nconst EXPORTS = [\n {\n data: \"account,amount\\nBridge Ledger,4120.00\\nHalden & Co,880.40\",\n fileName: \"ledger.csv\",\n mimeType: \"text/csv\",\n },\n {\n data: JSON.stringify({ held: 12, raised: 240, settled: 3 }, undefined, 2),\n fileName: \"totals.json\",\n mimeType: \"application/json\",\n },\n {\n data: '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\"><rect width=\"48\" height=\"48\" rx=\"10\"/></svg>',\n fileName: \"mark.svg\",\n mimeType: \"image/svg+xml\",\n },\n];\n\nfunction triggerOf(row: Export): ReactElement {\n return (\n <DownloadTrigger\n aria-label={row.label}\n data={row.data}\n fileName={row.fileName}\n mimeType={row.mimeType}\n shape=\"square\"\n size=\"sm\"\n variant=\"ghost\"\n >\n <DownloadIcon size=\"1em\" />\n </DownloadTrigger>\n );\n}\n\nexport function Exports(): ReactElement {\n const { i18n, t } = useWords(\"download-trigger\");\n const size = new Intl.NumberFormat(i18n.language, {\n style: \"unit\",\n unit: \"byte\",\n unitDisplay: \"long\",\n });\n\n return (\n <Table.Simple<Export>\n caption={t(\"exports\")}\n columns={[\n { key: \"fileName\", label: t(\"file\"), rowHeader: true },\n {\n cell: (row) => size.format(new Blob([row.data]).size),\n key: \"size\",\n label: t(\"size\"),\n numeric: true,\n },\n { cell: triggerOf, key: \"download\", label: t(\"download\") },\n ]}\n rows={EXPORTS.map(({ data, fileName, mimeType }) => ({\n data,\n fileName,\n label: t(\"save\", { file: fileName }),\n mimeType,\n }))}\n rowToKey={(row) => row.fileName}\n />\n );\n}\n";
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/download-trigger/examples/formats.example.tsx
|
|
210
|
+
var formats_example_exports = /* @__PURE__ */ __exportAll({
|
|
211
|
+
Formats: () => Formats,
|
|
212
|
+
source: () => source$1
|
|
213
|
+
});
|
|
214
|
+
const ACCOUNTS = [{
|
|
215
|
+
account: "Bridge Ledger",
|
|
216
|
+
amount: 4120
|
|
217
|
+
}, {
|
|
218
|
+
account: "Halden & Co",
|
|
219
|
+
amount: 880.4
|
|
220
|
+
}];
|
|
221
|
+
const FORMATS = [
|
|
222
|
+
{
|
|
223
|
+
data: ["account,amount", ...ACCOUNTS.map((row) => `${row.account},${row.amount}`)].join("\n"),
|
|
224
|
+
fileName: "ledger.csv",
|
|
225
|
+
key: "csv",
|
|
226
|
+
mimeType: "text/csv"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
data: JSON.stringify(ACCOUNTS, void 0, 2),
|
|
230
|
+
fileName: "ledger.json",
|
|
231
|
+
key: "json",
|
|
232
|
+
mimeType: "application/json"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
data: ["| Account | Amount |", "| --- | --- |"].concat(ACCOUNTS.map((row) => `| ${row.account} | ${row.amount} |`)).join("\n"),
|
|
236
|
+
fileName: "ledger.md",
|
|
237
|
+
key: "markdown",
|
|
238
|
+
mimeType: "text/markdown"
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
function Formats() {
|
|
242
|
+
const $ = c(12);
|
|
243
|
+
const { t } = useWords("download-trigger");
|
|
244
|
+
let t0;
|
|
245
|
+
if ($[0] !== t) {
|
|
246
|
+
t0 = t("export");
|
|
247
|
+
$[0] = t;
|
|
248
|
+
$[1] = t0;
|
|
249
|
+
} else t0 = $[1];
|
|
250
|
+
let t1;
|
|
251
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
252
|
+
t1 = /* @__PURE__ */ jsx(Menu.Indicator, { children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: "1em" }) });
|
|
253
|
+
$[2] = t1;
|
|
254
|
+
} else t1 = $[2];
|
|
255
|
+
let t2;
|
|
256
|
+
if ($[3] !== t0) {
|
|
257
|
+
t2 = /* @__PURE__ */ jsxs(Menu.Trigger, {
|
|
258
|
+
as: Button,
|
|
259
|
+
children: [t0, t1]
|
|
260
|
+
});
|
|
261
|
+
$[3] = t0;
|
|
262
|
+
$[4] = t2;
|
|
263
|
+
} else t2 = $[4];
|
|
264
|
+
let t3;
|
|
265
|
+
if ($[5] !== t) {
|
|
266
|
+
t3 = FORMATS.map((format_0) => /* @__PURE__ */ jsx(Menu.Item, {
|
|
267
|
+
value: format_0.key,
|
|
268
|
+
children: t(`formats.${format_0.key}`)
|
|
269
|
+
}, format_0.key));
|
|
270
|
+
$[5] = t;
|
|
271
|
+
$[6] = t3;
|
|
272
|
+
} else t3 = $[6];
|
|
273
|
+
let t4;
|
|
274
|
+
if ($[7] !== t3) {
|
|
275
|
+
t4 = createPortal(/* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: t3 }) }), document.body);
|
|
276
|
+
$[7] = t3;
|
|
277
|
+
$[8] = t4;
|
|
278
|
+
} else t4 = $[8];
|
|
279
|
+
let t5;
|
|
280
|
+
if ($[9] !== t2 || $[10] !== t4) {
|
|
281
|
+
t5 = /* @__PURE__ */ jsxs(Menu.Root, {
|
|
282
|
+
onSelect: _temp,
|
|
283
|
+
children: [t2, t4]
|
|
284
|
+
});
|
|
285
|
+
$[9] = t2;
|
|
286
|
+
$[10] = t4;
|
|
287
|
+
$[11] = t5;
|
|
288
|
+
} else t5 = $[11];
|
|
289
|
+
return t5;
|
|
290
|
+
}
|
|
291
|
+
function _temp(t0) {
|
|
292
|
+
const { value } = t0;
|
|
293
|
+
const format = FORMATS.find((each) => each.key === value);
|
|
294
|
+
if (format !== void 0) download(format);
|
|
295
|
+
}
|
|
296
|
+
const source$1 = "import { type ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { ChevronDownIcon } from \"lucide-react\";\n\nimport { Menu } from \"@stealthscale/component-disclosure\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Button, download } from \"@stealthscale/component-actions\";\n\nconst ACCOUNTS = [\n { account: \"Bridge Ledger\", amount: 4120 },\n { account: \"Halden & Co\", amount: 880.4 },\n];\n\nconst FORMATS = [\n {\n data: [\"account,amount\", ...ACCOUNTS.map((row) => `${row.account},${row.amount}`)].join(\"\\n\"),\n fileName: \"ledger.csv\",\n key: \"csv\",\n mimeType: \"text/csv\",\n },\n {\n data: JSON.stringify(ACCOUNTS, undefined, 2),\n fileName: \"ledger.json\",\n key: \"json\",\n mimeType: \"application/json\",\n },\n {\n data: [\"| Account | Amount |\", \"| --- | --- |\"]\n .concat(ACCOUNTS.map((row) => `| ${row.account} | ${row.amount} |`))\n .join(\"\\n\"),\n fileName: \"ledger.md\",\n key: \"markdown\",\n mimeType: \"text/markdown\",\n },\n] as const;\n\nexport function Formats(): ReactElement {\n const { t } = useWords(\"download-trigger\");\n\n return (\n <Menu.Root\n onSelect={({ value }) => {\n const format = FORMATS.find((each) => each.key === value);\n\n if (format !== undefined) void download(format);\n }}\n >\n <Menu.Trigger as={Button}>\n {t(\"export\")}\n <Menu.Indicator>\n <ChevronDownIcon size=\"1em\" />\n </Menu.Indicator>\n </Menu.Trigger>\n {createPortal(\n <Menu.Positioner>\n <Menu.Content>\n {FORMATS.map((format) => (\n <Menu.Item key={format.key} value={format.key}>\n {t(`formats.${format.key}`)}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Positioner>,\n document.body,\n )}\n </Menu.Root>\n );\n}\n";
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/download-trigger/examples/ledger.example.tsx
|
|
299
|
+
var ledger_example_exports = /* @__PURE__ */ __exportAll({
|
|
300
|
+
Ledger: () => Ledger,
|
|
301
|
+
source: () => source
|
|
302
|
+
});
|
|
303
|
+
const LEDGER = [
|
|
304
|
+
"account,state,amount",
|
|
305
|
+
"Bridge Ledger,settled,4120.00",
|
|
306
|
+
"Halden & Co,held,880.40",
|
|
307
|
+
"Perrin Freight,queued,12500.00"
|
|
308
|
+
].join("\n");
|
|
309
|
+
function Ledger() {
|
|
310
|
+
const $ = c(5);
|
|
311
|
+
const { t } = useWords("download-trigger");
|
|
312
|
+
let t0;
|
|
313
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
314
|
+
t0 = /* @__PURE__ */ jsx(DownloadIcon, { size: "1em" });
|
|
315
|
+
$[0] = t0;
|
|
316
|
+
} else t0 = $[0];
|
|
317
|
+
let t1;
|
|
318
|
+
if ($[1] !== t) {
|
|
319
|
+
t1 = t("ledger");
|
|
320
|
+
$[1] = t;
|
|
321
|
+
$[2] = t1;
|
|
322
|
+
} else t1 = $[2];
|
|
323
|
+
let t2;
|
|
324
|
+
if ($[3] !== t1) {
|
|
325
|
+
t2 = /* @__PURE__ */ jsxs(DownloadTrigger, {
|
|
326
|
+
data: LEDGER,
|
|
327
|
+
fileName: "ledger.csv",
|
|
328
|
+
mimeType: "text/csv",
|
|
329
|
+
variant: "outline",
|
|
330
|
+
children: [t0, t1]
|
|
331
|
+
});
|
|
332
|
+
$[3] = t1;
|
|
333
|
+
$[4] = t2;
|
|
334
|
+
} else t2 = $[4];
|
|
335
|
+
return t2;
|
|
336
|
+
}
|
|
337
|
+
const source = "import { type ReactElement } from \"react\";\n\nimport { DownloadIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DownloadTrigger } from \"@stealthscale/component-actions\";\n\nconst LEDGER = [\n \"account,state,amount\",\n \"Bridge Ledger,settled,4120.00\",\n \"Halden & Co,held,880.40\",\n \"Perrin Freight,queued,12500.00\",\n].join(\"\\n\");\n\nexport function Ledger(): ReactElement {\n const { t } = useWords(\"download-trigger\");\n\n return (\n <DownloadTrigger data={LEDGER} fileName=\"ledger.csv\" mimeType=\"text/csv\" variant=\"outline\">\n <DownloadIcon size=\"1em\" />\n {t(\"ledger\")}\n </DownloadTrigger>\n );\n}\n";
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/download-trigger/download-trigger.specimen.tsx
|
|
340
|
+
/**
|
|
341
|
+
* Catalogue page for the download trigger.
|
|
342
|
+
*
|
|
343
|
+
* @remarks
|
|
344
|
+
* Every scene is hand-written and renders a component from `examples/`. The trigger binds the
|
|
345
|
+
* button recipe, and the button's page shows that recipe's axes. The words are keys under
|
|
346
|
+
* `download-trigger` in the `specimen` namespace, stored in
|
|
347
|
+
* `locales/en/specimen/download-trigger.json`.
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* Hand-written scene for a trigger with visible text.
|
|
351
|
+
*/
|
|
352
|
+
const lone = {
|
|
353
|
+
about: "download-trigger.lone.about",
|
|
354
|
+
draw: () => /* @__PURE__ */ jsx(Sample, { children: /* @__PURE__ */ jsx(Ledger, {}) }),
|
|
355
|
+
example: ledger_example_exports,
|
|
356
|
+
title: "download-trigger.lone.title"
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Hand-written scene for three kinds of file in a table, each saved by an icon-only trigger.
|
|
360
|
+
*/
|
|
361
|
+
const kinds = {
|
|
362
|
+
about: "download-trigger.kinds.about",
|
|
363
|
+
draw: () => /* @__PURE__ */ jsx(Room, {
|
|
364
|
+
size: "sm",
|
|
365
|
+
children: /* @__PURE__ */ jsx(Exports, {})
|
|
366
|
+
}),
|
|
367
|
+
example: exports_example_exports,
|
|
368
|
+
title: "download-trigger.kinds.title"
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Hand-written scene for data built by a promise when the trigger is pressed.
|
|
372
|
+
*/
|
|
373
|
+
const built = {
|
|
374
|
+
about: "download-trigger.built.about",
|
|
375
|
+
draw: () => /* @__PURE__ */ jsx(Sample, { children: /* @__PURE__ */ jsx(Compressed, {}) }),
|
|
376
|
+
example: compressed_example_exports,
|
|
377
|
+
title: "download-trigger.built.title"
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Hand-written scene for `download` called from the rows of a menu.
|
|
381
|
+
*/
|
|
382
|
+
const menu = {
|
|
383
|
+
about: "download-trigger.menu.about",
|
|
384
|
+
draw: () => /* @__PURE__ */ jsx(Sample, { children: /* @__PURE__ */ jsx(Formats, {}) }),
|
|
385
|
+
example: formats_example_exports,
|
|
386
|
+
title: "download-trigger.menu.title"
|
|
387
|
+
};
|
|
388
|
+
var download_trigger_specimen_default = specimen({
|
|
389
|
+
about: "download-trigger.about",
|
|
390
|
+
id: "components/actions/download-trigger",
|
|
391
|
+
imports: "import { download, DownloadTrigger } from \"@stealthscale/component-actions\";",
|
|
392
|
+
scenes: [
|
|
393
|
+
lone,
|
|
394
|
+
kinds,
|
|
395
|
+
built,
|
|
396
|
+
menu
|
|
397
|
+
],
|
|
398
|
+
title: "download-trigger.title"
|
|
399
|
+
});
|
|
400
|
+
//#endregion
|
|
401
|
+
export { built, download_trigger_specimen_default as default, kinds, lone, menu };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const dropped = {"DownloadTriggerProps": {"conditions": 284, "foreign": 1051}, "ButtonProps": {"conditions": 284, "foreign": 1051}, "IconButtonProps": {"conditions": 284, "foreign": 1049}};
|
|
2
|
+
export const parts = {"DownloadTriggerProps": [{"accepts": "(() => Promise<DownloadableData> | DownloadableData) | DownloadableData", "fallback": "", "kind": "option", "name": "data", "refers": [], "required": true, "says": "Contents of the file, or a function called on every download that returns them or a promise of them."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "fileName", "refers": [], "required": true, "says": "Name the browser saves the file under, extension included."}, {"accepts": "FileMimeType", "fallback": "", "kind": "option", "name": "mimeType", "refers": ["file-utils.FileMimeType"], "required": false, "says": "Type of text data. A `Blob` or a `File` keeps its own type."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "ButtonProps": [{"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "IconButtonProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "aria-label", "refers": [], "required": false, "says": "Defines a string value that labels the current element. The accessible name a screen reader announces in place of the icon."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "aria-labelledby", "refers": [], "required": false, "says": "Identifies the element (or elements) that labels the current element. The id of the element whose text names the control."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}]};
|
|
3
|
+
export const shapes = {"kit.Lift": [{"accepts": "", "name": "\"floating\"", "says": ""}, {"accepts": "", "name": "\"raised\"", "says": ""}], "kit.Scale": [{"accepts": "", "name": "\"2xl\"", "says": ""}, {"accepts": "", "name": "\"3xl\"", "says": ""}, {"accepts": "", "name": "\"4xl\"", "says": ""}, {"accepts": "", "name": "\"lg\"", "says": ""}, {"accepts": "", "name": "\"md\"", "says": ""}, {"accepts": "", "name": "\"sm\"", "says": ""}, {"accepts": "", "name": "\"xl\"", "says": ""}, {"accepts": "", "name": "\"xs\"", "says": ""}], "file-utils.FileMimeType": [{"accepts": "", "name": "\"application/*\"", "says": ""}, {"accepts": "", "name": "\"application/json\"", "says": ""}, {"accepts": "", "name": "\"application/msword\"", "says": ""}, {"accepts": "", "name": "\"application/pdf\"", "says": ""}, {"accepts": "", "name": "\"application/rtf\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.microsoft.portable-executable\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.ms-excel\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.ms-powerpoint\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"", "says": ""}, {"accepts": "", "name": "\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"", "says": ""}, {"accepts": "", "name": "\"application/x-7z-compressed\"", "says": ""}, {"accepts": "", "name": "\"application/x-rar\"", "says": ""}, {"accepts": "", "name": "\"application/x-tar\"", "says": ""}, {"accepts": "", "name": "\"application/xml\"", "says": ""}, {"accepts": "", "name": "\"application/zip\"", "says": ""}, {"accepts": "", "name": "\"audio/*\"", "says": ""}, {"accepts": "", "name": "\"audio/aac\"", "says": ""}, {"accepts": "", "name": "\"audio/flac\"", "says": ""}, {"accepts": "", "name": "\"audio/mpeg\"", "says": ""}, {"accepts": "", "name": "\"audio/ogg\"", "says": ""}, {"accepts": "", "name": "\"audio/wav\"", "says": ""}, {"accepts": "", "name": "\"audio/webm\"", "says": ""}, {"accepts": "", "name": "\"audio/x-m4a\"", "says": ""}, {"accepts": "", "name": "\"font/*\"", "says": ""}, {"accepts": "", "name": "\"font/eot\"", "says": ""}, {"accepts": "", "name": "\"font/otf\"", "says": ""}, {"accepts": "", "name": "\"font/svg\"", "says": ""}, {"accepts": "", "name": "\"font/ttf\"", "says": ""}, {"accepts": "", "name": "\"font/woff\"", "says": ""}, {"accepts": "", "name": "\"font/woff2\"", "says": ""}, {"accepts": "", "name": "\"image/*\"", "says": ""}, {"accepts": "", "name": "\"image/avif\"", "says": ""}, {"accepts": "", "name": "\"image/bmp\"", "says": ""}, {"accepts": "", "name": "\"image/gif\"", "says": ""}, {"accepts": "", "name": "\"image/heic\"", "says": ""}, {"accepts": "", "name": "\"image/jpeg\"", "says": ""}, {"accepts": "", "name": "\"image/png\"", "says": ""}, {"accepts": "", "name": "\"image/svg+xml\"", "says": ""}, {"accepts": "", "name": "\"image/webp\"", "says": ""}, {"accepts": "", "name": "\"text/*\"", "says": ""}, {"accepts": "", "name": "\"text/css\"", "says": ""}, {"accepts": "", "name": "\"text/csv\"", "says": ""}, {"accepts": "", "name": "\"text/html\"", "says": ""}, {"accepts": "", "name": "\"text/markdown\"", "says": ""}, {"accepts": "", "name": "\"text/plain\"", "says": ""}, {"accepts": "", "name": "\"video/*\"", "says": ""}, {"accepts": "", "name": "\"video/mp4\"", "says": ""}, {"accepts": "", "name": "\"video/ogg\"", "says": ""}, {"accepts": "", "name": "\"video/quicktime\"", "says": ""}, {"accepts": "", "name": "\"video/webm\"", "says": ""}, {"accepts": "", "name": "\"video/x-msvideo\"", "says": ""}, {"accepts": "", "name": "AnyString", "says": ""}]};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"pages": [
|
|
4
|
+
{
|
|
5
|
+
"about": "button.about",
|
|
6
|
+
"group": "",
|
|
7
|
+
"id": "components/actions/button",
|
|
8
|
+
"module": "button/button.js",
|
|
9
|
+
"namespace": "",
|
|
10
|
+
"props": "button/button.props.js",
|
|
11
|
+
"specimen": "src/button/button.specimen.tsx",
|
|
12
|
+
"title": "button.title"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"about": "clipboard.about",
|
|
16
|
+
"group": "",
|
|
17
|
+
"id": "components/actions/clipboard",
|
|
18
|
+
"module": "clipboard/clipboard.js",
|
|
19
|
+
"namespace": "",
|
|
20
|
+
"props": "clipboard/clipboard.props.js",
|
|
21
|
+
"specimen": "src/clipboard/clipboard.specimen.tsx",
|
|
22
|
+
"title": "clipboard.title"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"about": "color-mode-toggle.about",
|
|
26
|
+
"group": "",
|
|
27
|
+
"id": "components/actions/color-mode-toggle",
|
|
28
|
+
"module": "color-mode-toggle/color-mode-toggle.js",
|
|
29
|
+
"namespace": "",
|
|
30
|
+
"props": "color-mode-toggle/color-mode-toggle.props.js",
|
|
31
|
+
"specimen": "src/color-mode-toggle/color-mode-toggle.specimen.tsx",
|
|
32
|
+
"title": "color-mode-toggle.title"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"about": "download-trigger.about",
|
|
36
|
+
"group": "",
|
|
37
|
+
"id": "components/actions/download-trigger",
|
|
38
|
+
"module": "download-trigger/download-trigger.js",
|
|
39
|
+
"namespace": "",
|
|
40
|
+
"props": "download-trigger/download-trigger.props.js",
|
|
41
|
+
"specimen": "src/download-trigger/download-trigger.specimen.tsx",
|
|
42
|
+
"title": "download-trigger.title"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"about": "swap.about",
|
|
46
|
+
"group": "",
|
|
47
|
+
"id": "components/actions/swap",
|
|
48
|
+
"module": "swap/swap.js",
|
|
49
|
+
"namespace": "",
|
|
50
|
+
"props": "swap/swap.props.js",
|
|
51
|
+
"specimen": "src/swap/swap.specimen.tsx",
|
|
52
|
+
"title": "swap.title"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"about": "toggle-group.about",
|
|
56
|
+
"group": "",
|
|
57
|
+
"id": "components/actions/toggle-group",
|
|
58
|
+
"module": "toggle-group/toggle-group.js",
|
|
59
|
+
"namespace": "",
|
|
60
|
+
"props": "toggle-group/toggle-group.props.js",
|
|
61
|
+
"specimen": "src/toggle-group/toggle-group.specimen.tsx",
|
|
62
|
+
"title": "toggle-group.title"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"requires": {
|
|
66
|
+
"@stealthscale/component-collections": "^0.1.0",
|
|
67
|
+
"@stealthscale/component-disclosure": "^0.2.0",
|
|
68
|
+
"@stealthscale/component-forms": "^0.3.0",
|
|
69
|
+
"@stealthscale/component-typography": "^0.3.0",
|
|
70
|
+
"@stealthscale/specimen": "^0.3.0",
|
|
71
|
+
"lucide-react": "^1.52.0",
|
|
72
|
+
"react-dom": "^19.3.0"
|
|
73
|
+
}
|
|
74
|
+
}
|