@yarcl/react 0.1.0 → 0.2.0
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 +14 -2
- package/{src/apply.ts → dist/apply.d.ts} +4 -23
- package/dist/apply.js +37 -0
- package/dist/classes.d.ts +13 -0
- package/dist/classes.js +22 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +58 -0
- package/dist/color.js +49 -32
- package/dist/components/Accordion.d.ts +96 -0
- package/dist/components/Accordion.js +148 -0
- package/dist/components/Alert.d.ts +60 -0
- package/dist/components/Alert.js +61 -0
- package/dist/components/Avatar.d.ts +100 -0
- package/dist/components/Avatar.js +89 -0
- package/dist/components/Badge.d.ts +44 -0
- package/dist/components/Badge.js +43 -0
- package/dist/components/Breadcrumb.d.ts +77 -0
- package/dist/components/Breadcrumb.js +126 -0
- package/dist/components/Button.d.ts +18 -0
- package/dist/components/Button.js +33 -0
- package/dist/components/ButtonGroup.d.ts +29 -0
- package/dist/components/ButtonGroup.js +37 -0
- package/dist/components/Card.d.ts +36 -0
- package/dist/components/Card.js +26 -0
- package/dist/components/Checkbox.d.ts +28 -0
- package/dist/components/Checkbox.js +38 -0
- package/dist/components/Combobox.d.ts +75 -0
- package/dist/components/Combobox.js +362 -0
- package/dist/components/CommandPalette.d.ts +92 -0
- package/dist/components/CommandPalette.js +293 -0
- package/dist/components/DatePicker.d.ts +157 -0
- package/dist/components/DatePicker.js +230 -0
- package/dist/components/Dialog.d.ts +25 -0
- package/dist/components/Dialog.js +29 -0
- package/dist/components/Divider.d.ts +23 -0
- package/dist/components/Divider.js +25 -0
- package/dist/components/Drawer.d.ts +21 -0
- package/dist/components/Drawer.js +25 -0
- package/dist/components/EmptyState.d.ts +51 -0
- package/dist/components/EmptyState.js +47 -0
- package/dist/components/Field.d.ts +27 -0
- package/dist/components/Field.js +59 -0
- package/dist/components/Heading.d.ts +26 -0
- package/dist/components/Heading.js +25 -0
- package/dist/components/HoverCard.d.ts +47 -0
- package/dist/components/HoverCard.js +53 -0
- package/dist/components/IconButton.d.ts +19 -0
- package/dist/components/IconButton.js +32 -0
- package/dist/components/Inline.d.ts +21 -0
- package/dist/components/Inline.js +24 -0
- package/dist/components/Input.d.ts +19 -0
- package/dist/components/Input.js +25 -0
- package/dist/components/Label.d.ts +46 -0
- package/dist/components/Label.js +33 -0
- package/dist/components/Link.d.ts +27 -0
- package/dist/components/Link.js +26 -0
- package/dist/components/Menu.d.ts +73 -0
- package/dist/components/Menu.js +143 -0
- package/dist/components/Modal.d.ts +45 -0
- package/dist/components/Modal.js +110 -0
- package/dist/components/NumberInput.d.ts +49 -0
- package/dist/components/NumberInput.js +130 -0
- package/dist/components/Pagination.d.ts +86 -0
- package/dist/components/Pagination.js +119 -0
- package/dist/components/Popover.d.ts +72 -0
- package/dist/components/Popover.js +87 -0
- package/dist/components/Progress.d.ts +60 -0
- package/dist/components/Progress.js +59 -0
- package/dist/components/Radio.d.ts +32 -0
- package/dist/components/Radio.js +47 -0
- package/dist/components/RadioGroup.d.ts +57 -0
- package/dist/components/RadioGroup.js +68 -0
- package/dist/components/Select.d.ts +47 -0
- package/dist/components/Select.js +138 -0
- package/dist/components/Skeleton.d.ts +46 -0
- package/dist/components/Skeleton.js +40 -0
- package/dist/components/Slider.d.ts +126 -0
- package/dist/components/Slider.js +166 -0
- package/dist/components/Spinner.d.ts +23 -0
- package/dist/components/Spinner.js +23 -0
- package/dist/components/Stack.d.ts +35 -0
- package/dist/components/Stack.js +24 -0
- package/dist/components/Switch.d.ts +27 -0
- package/dist/components/Switch.js +33 -0
- package/dist/components/Table.d.ts +71 -0
- package/dist/components/Table.js +61 -0
- package/dist/components/Tabs.d.ts +66 -0
- package/dist/components/Tabs.js +109 -0
- package/dist/components/Text.d.ts +32 -0
- package/dist/components/Text.js +28 -0
- package/dist/components/Textarea.d.ts +15 -0
- package/dist/components/Textarea.js +24 -0
- package/dist/components/Toast.d.ts +90 -0
- package/dist/components/Toast.js +156 -0
- package/dist/components/ToggleGroup.d.ts +79 -0
- package/dist/components/ToggleGroup.js +101 -0
- package/dist/components/Tooltip.d.ts +46 -0
- package/dist/components/Tooltip.js +62 -0
- package/dist/components/VisuallyHidden.d.ts +18 -0
- package/dist/components/VisuallyHidden.js +22 -0
- package/dist/contrast.d.ts +32 -0
- package/dist/css.d.ts +2 -2
- package/dist/css.js +193 -157
- package/dist/define.d.ts +40 -15
- package/dist/define.js +30 -27
- package/dist/demo.d.ts +2 -0
- package/dist/demo.js +2 -0
- package/dist/esbuild.cjs +5 -0
- package/dist/esbuild.d.ts +4 -0
- package/dist/esbuild.js +6 -0
- package/dist/field-context.d.ts +16 -0
- package/dist/field-context.js +17 -0
- package/dist/floating.d.ts +12 -0
- package/dist/floating.js +52 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +12 -0
- package/{src/index.ts → dist/index.d.ts} +11 -33
- package/dist/index.js +50 -0
- package/dist/init.d.ts +18 -0
- package/dist/init.js +224 -0
- package/dist/plugin.d.ts +10 -26
- package/dist/plugin.js +152 -78
- package/dist/reference/DemoYarcl.d.ts +12 -0
- package/dist/reference/DemoYarcl.js +312 -0
- package/dist/reference/DesignReference.d.ts +24 -0
- package/dist/reference/DesignReference.js +403 -0
- package/dist/reference/index.js +2 -0
- package/dist/rollup.cjs +5 -0
- package/dist/rollup.d.ts +4 -0
- package/dist/rollup.js +6 -0
- package/dist/rspack.cjs +5 -0
- package/dist/rspack.d.ts +4 -0
- package/dist/rspack.js +6 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +30 -0
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +33 -0
- package/{src → dist}/styles.css +224 -106
- package/dist/themes/bloom.d.ts +295 -0
- package/dist/themes/bloom.js +202 -0
- package/dist/themes/brutalist.d.ts +277 -0
- package/dist/themes/brutalist.js +199 -0
- package/dist/themes/compact.d.ts +274 -0
- package/dist/themes/compact.js +200 -0
- package/dist/themes/contract.d.ts +23 -0
- package/dist/themes/editorial.d.ts +277 -0
- package/dist/themes/editorial.js +183 -0
- package/dist/themes/index.d.ts +1425 -0
- package/dist/themes/index.js +45 -0
- package/{src/types.ts → dist/types.d.ts} +40 -37
- package/dist/vite.cjs +5 -0
- package/dist/vite.d.ts +4 -0
- package/dist/vite.js +6 -0
- package/dist/webpack.cjs +5 -0
- package/dist/webpack.d.ts +4 -0
- package/dist/webpack.js +6 -0
- package/dist/yarcl.config.d.ts +276 -0
- package/dist/yarcl.config.js +273 -0
- package/package.json +69 -17
- package/src/classes.ts +0 -23
- package/src/color.ts +0 -48
- package/src/components/Accordion.tsx +0 -274
- package/src/components/Alert.tsx +0 -85
- package/src/components/Badge.tsx +0 -79
- package/src/components/Breadcrumb.tsx +0 -239
- package/src/components/Button.tsx +0 -58
- package/src/components/ButtonGroup.tsx +0 -61
- package/src/components/Card.tsx +0 -50
- package/src/components/Checkbox.tsx +0 -49
- package/src/components/Combobox.tsx +0 -522
- package/src/components/CommandPalette.tsx +0 -452
- package/src/components/DatePicker.tsx +0 -432
- package/src/components/Dialog.tsx +0 -39
- package/src/components/Divider.tsx +0 -34
- package/src/components/Drawer.tsx +0 -31
- package/src/components/Field.tsx +0 -61
- package/src/components/Heading.tsx +0 -40
- package/src/components/HoverCard.tsx +0 -108
- package/src/components/IconButton.tsx +0 -59
- package/src/components/Inline.tsx +0 -42
- package/src/components/Input.tsx +0 -28
- package/src/components/Label.tsx +0 -58
- package/src/components/Link.tsx +0 -41
- package/src/components/Menu.tsx +0 -207
- package/src/components/Modal.tsx +0 -164
- package/src/components/NumberInput.tsx +0 -208
- package/src/components/Pagination.tsx +0 -227
- package/src/components/Popover.tsx +0 -140
- package/src/components/Progress.tsx +0 -122
- package/src/components/Radio.tsx +0 -59
- package/src/components/RadioGroup.tsx +0 -114
- package/src/components/Select.tsx +0 -197
- package/src/components/Skeleton.tsx +0 -95
- package/src/components/Slider.tsx +0 -315
- package/src/components/Spinner.tsx +0 -38
- package/src/components/Stack.tsx +0 -57
- package/src/components/Switch.tsx +0 -42
- package/src/components/Table.tsx +0 -99
- package/src/components/Tabs.tsx +0 -159
- package/src/components/Text.tsx +0 -67
- package/src/components/Textarea.tsx +0 -26
- package/src/components/Toast.tsx +0 -190
- package/src/components/ToggleGroup.tsx +0 -227
- package/src/components/Tooltip.tsx +0 -78
- package/src/contrast.ts +0 -82
- package/src/css.ts +0 -228
- package/src/define.check.ts +0 -259
- package/src/define.ts +0 -379
- package/src/field-context.ts +0 -31
- package/src/floating.tsx +0 -61
- package/src/hooks.ts +0 -19
- package/src/plugin.ts +0 -94
- package/src/reference/DesignReference.tsx +0 -374
- package/src/runtime.ts +0 -38
- package/src/themes/bloom.ts +0 -72
- package/src/themes/brutalist.ts +0 -63
- package/src/themes/compact.ts +0 -63
- package/src/themes/contract.ts +0 -24
- package/src/themes/editorial.ts +0 -55
- package/src/themes/index.ts +0 -47
- package/src/yarcl.config.ts +0 -104
- /package/{src/reference/index.ts → dist/reference/index.d.ts} +0 -0
- /package/{src → dist}/reference/reference.css +0 -0
package/dist/plugin.js
CHANGED
|
@@ -1,80 +1,154 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { runnerImport } from 'vite';
|
|
5
1
|
import { generateCss } from "./css.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const consumerConfig = resolve(root, config);
|
|
43
|
-
target = existsSync(consumerConfig) ? consumerConfig : defaultConfig;
|
|
44
|
-
return {
|
|
45
|
-
resolve: { alias: { '@yarcl/config': target } },
|
|
46
|
-
optimizeDeps: {
|
|
47
|
-
exclude: [PACKAGE],
|
|
48
|
-
include: ['@floating-ui/react', 'date-fns', 'date-fns/locale', 'date-fns/locale/en-US'].map((dep) => `${PACKAGE} > ${dep}`),
|
|
49
|
-
},
|
|
50
|
-
ssr: { noExternal: [PACKAGE] },
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
resolveId(id) {
|
|
54
|
-
if (id === VIRTUAL_CSS)
|
|
55
|
-
return RESOLVED_CSS;
|
|
56
|
-
},
|
|
57
|
-
async load(id) {
|
|
58
|
-
if (id !== RESOLVED_CSS)
|
|
59
|
-
return;
|
|
60
|
-
const { module, dependencies } = await runnerImport(target, {
|
|
61
|
-
configFile: false,
|
|
62
|
-
root,
|
|
63
|
-
ssr: { noExternal: [PACKAGE] },
|
|
64
|
-
logLevel: 'error',
|
|
65
|
-
});
|
|
66
|
-
watched = new Set([target, ...dependencies.map((dep) => resolve(root, dep))]);
|
|
67
|
-
watched.forEach((file) => this.addWatchFile(file));
|
|
68
|
-
return generateCss(module.default, (message) => this.warn(message));
|
|
69
|
-
},
|
|
70
|
-
handleHotUpdate({ file, server, modules }) {
|
|
71
|
-
if (!watched.has(file))
|
|
72
|
-
return;
|
|
73
|
-
const css = server.moduleGraph.getModuleById(RESOLVED_CSS);
|
|
74
|
-
if (!css)
|
|
75
|
-
return;
|
|
76
|
-
server.moduleGraph.invalidateModule(css);
|
|
77
|
-
return [...modules, css];
|
|
78
|
-
},
|
|
79
|
-
};
|
|
2
|
+
import { assertConfigMapping } from "./setup.js";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, extname, resolve } from "node:path";
|
|
7
|
+
import { createJiti } from "jiti";
|
|
8
|
+
import { createUnplugin } from "unplugin";
|
|
9
|
+
//#region src/plugin.ts
|
|
10
|
+
var VIRTUAL_CSS = "@yarcl/react/styles.css";
|
|
11
|
+
var RESOLVED_CSS = `\0${VIRTUAL_CSS}`;
|
|
12
|
+
var CONFIG_MODULE = "@yarcl/config";
|
|
13
|
+
var PACKAGE = "@yarcl/react";
|
|
14
|
+
var selfRequire = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
15
|
+
var extensions = [
|
|
16
|
+
"",
|
|
17
|
+
".ts",
|
|
18
|
+
".tsx",
|
|
19
|
+
".mts",
|
|
20
|
+
".cts",
|
|
21
|
+
".js",
|
|
22
|
+
".jsx",
|
|
23
|
+
".mjs",
|
|
24
|
+
".cjs",
|
|
25
|
+
".json"
|
|
26
|
+
];
|
|
27
|
+
var importPattern = /(?:\bimport\s*(?:[\s\S]*?\sfrom\s*)?|\bexport\s*[\s\S]*?\sfrom\s*|\bimport\s*\()(['"])(\.{1,2}\/[^'"]+)\1/g;
|
|
28
|
+
function localDependency(importer, specifier) {
|
|
29
|
+
const candidate = resolve(dirname(importer), specifier);
|
|
30
|
+
for (const extension of extensions) {
|
|
31
|
+
const file = `${candidate}${extension}`;
|
|
32
|
+
if (existsSync(file)) return file;
|
|
33
|
+
}
|
|
34
|
+
for (const extension of extensions.slice(1)) {
|
|
35
|
+
const file = resolve(candidate, `index${extension}`);
|
|
36
|
+
if (existsSync(file)) return file;
|
|
37
|
+
}
|
|
80
38
|
}
|
|
39
|
+
async function configDependencies(entry) {
|
|
40
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
41
|
+
const visit = async (file) => {
|
|
42
|
+
if (dependencies.has(file)) return;
|
|
43
|
+
dependencies.add(file);
|
|
44
|
+
if (extname(file) === ".json") return;
|
|
45
|
+
const imports = [...(await readFile(file, "utf8")).matchAll(importPattern)].map((match) => localDependency(file, match[2])).filter((dependency) => dependency !== void 0);
|
|
46
|
+
await Promise.all(imports.map(visit));
|
|
47
|
+
};
|
|
48
|
+
await visit(entry);
|
|
49
|
+
return dependencies;
|
|
50
|
+
}
|
|
51
|
+
function defaultConfig() {
|
|
52
|
+
return selfRequire.resolve("@yarcl/react/defaults");
|
|
53
|
+
}
|
|
54
|
+
/** Shared yarcl plugin implementation used by every build-tool adapter. */
|
|
55
|
+
var yarclPlugin = createUnplugin((options = {}, meta) => {
|
|
56
|
+
const configPath = options.config ?? "src/yarcl.config.ts";
|
|
57
|
+
let root = resolve(options.root ?? process.cwd());
|
|
58
|
+
let target = "";
|
|
59
|
+
let componentStyles = "";
|
|
60
|
+
let generatedStyles = "";
|
|
61
|
+
let staticStyles = "";
|
|
62
|
+
let referenceStyles = "";
|
|
63
|
+
let watched = /* @__PURE__ */ new Set();
|
|
64
|
+
const prepare = () => {
|
|
65
|
+
assertConfigMapping(root, configPath, meta.framework);
|
|
66
|
+
const consumerConfig = resolve(root, configPath);
|
|
67
|
+
const fallback = defaultConfig();
|
|
68
|
+
target = existsSync(consumerConfig) ? consumerConfig : fallback;
|
|
69
|
+
staticStyles = resolve(dirname(fallback), "styles.css");
|
|
70
|
+
referenceStyles = resolve(dirname(fallback), "reference/reference.css");
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
name: "yarcl",
|
|
74
|
+
enforce: "pre",
|
|
75
|
+
buildStart() {
|
|
76
|
+
prepare();
|
|
77
|
+
},
|
|
78
|
+
resolveId: {
|
|
79
|
+
filter: { id: /^(?:@yarcl\/config|@yarcl\/react\/styles\.css)$/ },
|
|
80
|
+
handler(id) {
|
|
81
|
+
if (id === CONFIG_MODULE) return meta.framework === "esbuild" ? void 0 : target;
|
|
82
|
+
if (id === VIRTUAL_CSS) return RESOLVED_CSS;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
load: {
|
|
86
|
+
filter: { id: /(?:@yarcl\/react\/styles\.css|\/(?:styles|reference)\.css)$/ },
|
|
87
|
+
async handler(id) {
|
|
88
|
+
if (meta.framework === "rollup" && (id === staticStyles || id === referenceStyles)) {
|
|
89
|
+
componentStyles += `${await readFile(id, "utf8")}\n`;
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
if (id !== RESOLVED_CSS) return;
|
|
93
|
+
const config = await createJiti(resolve(root, "package.json"), { moduleCache: false }).import(target, { default: true });
|
|
94
|
+
watched = existsSync(target) ? await configDependencies(target) : /* @__PURE__ */ new Set([target]);
|
|
95
|
+
watched.forEach((file) => this.addWatchFile(file));
|
|
96
|
+
const css = generateCss(config, (message) => this.warn(message));
|
|
97
|
+
if (meta.framework === "rollup") {
|
|
98
|
+
generatedStyles = css;
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
return css;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
rollup: { generateBundle() {
|
|
105
|
+
this.emitFile({
|
|
106
|
+
type: "asset",
|
|
107
|
+
fileName: "yarcl.css",
|
|
108
|
+
source: `${generatedStyles}\n${componentStyles}`
|
|
109
|
+
});
|
|
110
|
+
} },
|
|
111
|
+
vite: {
|
|
112
|
+
config(userConfig) {
|
|
113
|
+
root = resolve(options.root ?? userConfig.root ?? process.cwd());
|
|
114
|
+
return {
|
|
115
|
+
optimizeDeps: {
|
|
116
|
+
exclude: [PACKAGE],
|
|
117
|
+
include: [
|
|
118
|
+
"@floating-ui/react",
|
|
119
|
+
"date-fns",
|
|
120
|
+
"date-fns/locale",
|
|
121
|
+
"date-fns/locale/en-US"
|
|
122
|
+
].map((dependency) => `${PACKAGE} > ${dependency}`)
|
|
123
|
+
},
|
|
124
|
+
ssr: { noExternal: [PACKAGE] }
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
handleHotUpdate({ file, server, modules }) {
|
|
128
|
+
if (!watched.has(file)) return;
|
|
129
|
+
const css = server.moduleGraph.getModuleById(RESOLVED_CSS);
|
|
130
|
+
if (!css) return;
|
|
131
|
+
server.moduleGraph.invalidateModule(css);
|
|
132
|
+
return [...modules, css];
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
webpack(compiler) {
|
|
136
|
+
root = resolve(options.root ?? compiler.context);
|
|
137
|
+
},
|
|
138
|
+
rspack(compiler) {
|
|
139
|
+
root = resolve(options.root ?? compiler.context);
|
|
140
|
+
},
|
|
141
|
+
esbuild: {
|
|
142
|
+
config(buildOptions) {
|
|
143
|
+
root = resolve(options.root ?? buildOptions.absWorkingDir ?? process.cwd());
|
|
144
|
+
prepare();
|
|
145
|
+
},
|
|
146
|
+
setup(build) {
|
|
147
|
+
build.onResolve({ filter: /^@yarcl\/config$/ }, () => ({ path: target }));
|
|
148
|
+
},
|
|
149
|
+
loader: "css"
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
//#endregion
|
|
154
|
+
export { yarclPlugin };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@yarcl/react/styles.css';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
/** Props for {@link DemoYarcl}. */
|
|
4
|
+
export interface DemoYarclProps {
|
|
5
|
+
/** Page heading. */
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A package-wide demo for validating a yarcl installation and previewing its active config.
|
|
10
|
+
* Import from `@yarcl/react/demo`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function DemoYarcl({ title }: DemoYarclProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { ButtonGroup } from "../components/ButtonGroup.js";
|
|
2
|
+
import { Spinner } from "../components/Spinner.js";
|
|
3
|
+
import { Button } from "../components/Button.js";
|
|
4
|
+
import { ToggleGroup } from "../components/ToggleGroup.js";
|
|
5
|
+
import { IconButton } from "../components/IconButton.js";
|
|
6
|
+
import { Input } from "../components/Input.js";
|
|
7
|
+
import { Textarea } from "../components/Textarea.js";
|
|
8
|
+
import { NumberInput } from "../components/NumberInput.js";
|
|
9
|
+
import { Checkbox } from "../components/Checkbox.js";
|
|
10
|
+
import { RadioGroup } from "../components/RadioGroup.js";
|
|
11
|
+
import { Radio } from "../components/Radio.js";
|
|
12
|
+
import { Switch } from "../components/Switch.js";
|
|
13
|
+
import { Slider } from "../components/Slider.js";
|
|
14
|
+
import { Label } from "../components/Label.js";
|
|
15
|
+
import { Field } from "../components/Field.js";
|
|
16
|
+
import { Text } from "../components/Text.js";
|
|
17
|
+
import { Heading } from "../components/Heading.js";
|
|
18
|
+
import { Link } from "../components/Link.js";
|
|
19
|
+
import { Breadcrumb } from "../components/Breadcrumb.js";
|
|
20
|
+
import { Stack } from "../components/Stack.js";
|
|
21
|
+
import { Inline } from "../components/Inline.js";
|
|
22
|
+
import { Card } from "../components/Card.js";
|
|
23
|
+
import { Divider } from "../components/Divider.js";
|
|
24
|
+
import { VisuallyHidden } from "../components/VisuallyHidden.js";
|
|
25
|
+
import { Popover } from "../components/Popover.js";
|
|
26
|
+
import { Tooltip } from "../components/Tooltip.js";
|
|
27
|
+
import { HoverCard } from "../components/HoverCard.js";
|
|
28
|
+
import { Menu } from "../components/Menu.js";
|
|
29
|
+
import { Select } from "../components/Select.js";
|
|
30
|
+
import { Badge } from "../components/Badge.js";
|
|
31
|
+
import { Combobox } from "../components/Combobox.js";
|
|
32
|
+
import { DatePicker } from "../components/DatePicker.js";
|
|
33
|
+
import { Dialog } from "../components/Dialog.js";
|
|
34
|
+
import { Drawer } from "../components/Drawer.js";
|
|
35
|
+
import { CommandPalette } from "../components/CommandPalette.js";
|
|
36
|
+
import { Toaster } from "../components/Toast.js";
|
|
37
|
+
import { Accordion } from "../components/Accordion.js";
|
|
38
|
+
import { Tabs } from "../components/Tabs.js";
|
|
39
|
+
import { Pagination } from "../components/Pagination.js";
|
|
40
|
+
import { Table } from "../components/Table.js";
|
|
41
|
+
import { Avatar, AvatarGroup } from "../components/Avatar.js";
|
|
42
|
+
import { Alert } from "../components/Alert.js";
|
|
43
|
+
import { Skeleton } from "../components/Skeleton.js";
|
|
44
|
+
import { Progress } from "../components/Progress.js";
|
|
45
|
+
import { EmptyState } from "../components/EmptyState.js";
|
|
46
|
+
import { DesignReference } from "./DesignReference.js";
|
|
47
|
+
import "@yarcl/react/styles.css";
|
|
48
|
+
import "../styles.css";
|
|
49
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
50
|
+
//#region src/reference/DemoYarcl.tsx
|
|
51
|
+
var components = [
|
|
52
|
+
Accordion,
|
|
53
|
+
Alert,
|
|
54
|
+
Avatar,
|
|
55
|
+
AvatarGroup,
|
|
56
|
+
Badge,
|
|
57
|
+
Breadcrumb,
|
|
58
|
+
Button,
|
|
59
|
+
ButtonGroup,
|
|
60
|
+
Card,
|
|
61
|
+
Checkbox,
|
|
62
|
+
Combobox,
|
|
63
|
+
CommandPalette,
|
|
64
|
+
DatePicker,
|
|
65
|
+
Dialog,
|
|
66
|
+
Divider,
|
|
67
|
+
Drawer,
|
|
68
|
+
EmptyState,
|
|
69
|
+
Field,
|
|
70
|
+
Heading,
|
|
71
|
+
HoverCard,
|
|
72
|
+
IconButton,
|
|
73
|
+
Inline,
|
|
74
|
+
Input,
|
|
75
|
+
Label,
|
|
76
|
+
Link,
|
|
77
|
+
Menu,
|
|
78
|
+
NumberInput,
|
|
79
|
+
Pagination,
|
|
80
|
+
Popover,
|
|
81
|
+
Progress,
|
|
82
|
+
Radio,
|
|
83
|
+
RadioGroup,
|
|
84
|
+
Select,
|
|
85
|
+
Skeleton,
|
|
86
|
+
Slider,
|
|
87
|
+
Spinner,
|
|
88
|
+
Stack,
|
|
89
|
+
Switch,
|
|
90
|
+
Table,
|
|
91
|
+
Tabs,
|
|
92
|
+
Text,
|
|
93
|
+
Textarea,
|
|
94
|
+
Toaster,
|
|
95
|
+
ToggleGroup,
|
|
96
|
+
Tooltip,
|
|
97
|
+
VisuallyHidden
|
|
98
|
+
];
|
|
99
|
+
var options = [{
|
|
100
|
+
value: "first",
|
|
101
|
+
label: "First option"
|
|
102
|
+
}, {
|
|
103
|
+
value: "second",
|
|
104
|
+
label: "Second option"
|
|
105
|
+
}];
|
|
106
|
+
/**
|
|
107
|
+
* A package-wide demo for validating a yarcl installation and previewing its active config.
|
|
108
|
+
* Import from `@yarcl/react/demo`.
|
|
109
|
+
*/
|
|
110
|
+
function DemoYarcl({ title = "yarcl demo" }) {
|
|
111
|
+
const componentNames = components.map((component) => component.name).join(",");
|
|
112
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
113
|
+
"data-yarcl-components": componentNames,
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx(DesignReference, { title }),
|
|
116
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
117
|
+
/* @__PURE__ */ jsx(Heading, {
|
|
118
|
+
level: 2,
|
|
119
|
+
children: "Components"
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
122
|
+
/* @__PURE__ */ jsxs(Inline, { children: [
|
|
123
|
+
/* @__PURE__ */ jsx(Button, { children: "Button" }),
|
|
124
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
125
|
+
"aria-label": "Add item",
|
|
126
|
+
children: "+"
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx(Badge, { children: "Badge" }),
|
|
129
|
+
/* @__PURE__ */ jsx(Avatar, { name: "Ada Lovelace" }),
|
|
130
|
+
/* @__PURE__ */ jsxs(AvatarGroup, {
|
|
131
|
+
"aria-label": "Team",
|
|
132
|
+
children: [/* @__PURE__ */ jsx(Avatar, { name: "Ada Lovelace" }), /* @__PURE__ */ jsx(Avatar, { name: "Grace Hopper" })]
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx(Spinner, { label: "Loading" })
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ jsxs(ButtonGroup, {
|
|
137
|
+
"aria-label": "Actions",
|
|
138
|
+
children: [/* @__PURE__ */ jsx(Button, { children: "Save" }), /* @__PURE__ */ jsx(Button, { children: "Cancel" })]
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsxs(ToggleGroup, {
|
|
141
|
+
type: "single",
|
|
142
|
+
defaultValue: "one",
|
|
143
|
+
"aria-label": "View",
|
|
144
|
+
children: [/* @__PURE__ */ jsx(ToggleGroup.Item, {
|
|
145
|
+
value: "one",
|
|
146
|
+
children: "One"
|
|
147
|
+
}), /* @__PURE__ */ jsx(ToggleGroup.Item, {
|
|
148
|
+
value: "two",
|
|
149
|
+
children: "Two"
|
|
150
|
+
})]
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsx(Field, {
|
|
153
|
+
label: "Name",
|
|
154
|
+
children: /* @__PURE__ */ jsx(Input, { placeholder: "Ada Lovelace" })
|
|
155
|
+
}),
|
|
156
|
+
/* @__PURE__ */ jsx(Label, {
|
|
157
|
+
htmlFor: "yarcl-demo-notes",
|
|
158
|
+
children: "Notes"
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx(Textarea, { id: "yarcl-demo-notes" }),
|
|
161
|
+
/* @__PURE__ */ jsx(NumberInput, {
|
|
162
|
+
"aria-label": "Quantity",
|
|
163
|
+
defaultValue: 1
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ jsxs(Inline, { children: [
|
|
166
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
167
|
+
defaultChecked: true,
|
|
168
|
+
children: "Checkbox"
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx(Radio, {
|
|
171
|
+
name: "yarcl-demo-radio",
|
|
172
|
+
value: "radio",
|
|
173
|
+
defaultChecked: true,
|
|
174
|
+
children: "Radio"
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx(Switch, {
|
|
177
|
+
defaultChecked: true,
|
|
178
|
+
children: "Switch"
|
|
179
|
+
})
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsxs(RadioGroup, {
|
|
182
|
+
label: "Choice",
|
|
183
|
+
defaultValue: "first",
|
|
184
|
+
children: [/* @__PURE__ */ jsx(Radio, {
|
|
185
|
+
value: "first",
|
|
186
|
+
children: "First"
|
|
187
|
+
}), /* @__PURE__ */ jsx(Radio, {
|
|
188
|
+
value: "second",
|
|
189
|
+
children: "Second"
|
|
190
|
+
})]
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
193
|
+
"aria-label": "Amount",
|
|
194
|
+
defaultValue: 50
|
|
195
|
+
}),
|
|
196
|
+
/* @__PURE__ */ jsx(Select, {
|
|
197
|
+
"aria-label": "Select option",
|
|
198
|
+
options,
|
|
199
|
+
defaultValue: "first"
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
202
|
+
"aria-label": "Search options",
|
|
203
|
+
options
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsx(DatePicker, { "aria-label": "Choose date" }),
|
|
206
|
+
/* @__PURE__ */ jsx(Progress, {
|
|
207
|
+
value: 60,
|
|
208
|
+
label: "Progress",
|
|
209
|
+
showValue: true
|
|
210
|
+
}),
|
|
211
|
+
/* @__PURE__ */ jsx(Alert, {
|
|
212
|
+
title: "Installation works",
|
|
213
|
+
children: "Every public component is available to this build."
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsx(Skeleton, {
|
|
216
|
+
lines: 2,
|
|
217
|
+
"aria-label": "Loading content"
|
|
218
|
+
}),
|
|
219
|
+
/* @__PURE__ */ jsx(EmptyState, {
|
|
220
|
+
title: "Nothing here",
|
|
221
|
+
description: "This is the empty state component."
|
|
222
|
+
}),
|
|
223
|
+
/* @__PURE__ */ jsxs(Breadcrumb, {
|
|
224
|
+
"aria-label": "Breadcrumb",
|
|
225
|
+
children: [/* @__PURE__ */ jsx(Breadcrumb.Item, {
|
|
226
|
+
href: "#",
|
|
227
|
+
children: "Home"
|
|
228
|
+
}), /* @__PURE__ */ jsx(Breadcrumb.Item, { children: "Demo" })]
|
|
229
|
+
}),
|
|
230
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
231
|
+
"Text with a ",
|
|
232
|
+
/* @__PURE__ */ jsx(Link, {
|
|
233
|
+
href: "#",
|
|
234
|
+
children: "link"
|
|
235
|
+
}),
|
|
236
|
+
" and ",
|
|
237
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: "accessible context" }),
|
|
238
|
+
"."
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxs(Inline, { children: [
|
|
241
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
242
|
+
content: "Tooltip content",
|
|
243
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Tooltip" })
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ jsx(HoverCard, {
|
|
246
|
+
content: "Hover card content",
|
|
247
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Hover card" })
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { children: "Popover" }) }), /* @__PURE__ */ jsx(Popover.Content, { children: "Popover content" })] }),
|
|
250
|
+
/* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(Menu.Trigger, { children: /* @__PURE__ */ jsx(Button, { children: "Menu" }) }), /* @__PURE__ */ jsx(Menu.Content, { children: /* @__PURE__ */ jsx(Menu.Item, { children: "Menu item" }) })] }),
|
|
251
|
+
/* @__PURE__ */ jsx(Dialog, {
|
|
252
|
+
trigger: /* @__PURE__ */ jsx(Button, { children: "Dialog" }),
|
|
253
|
+
title: "Dialog"
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ jsx(Drawer, {
|
|
256
|
+
trigger: /* @__PURE__ */ jsx(Button, { children: "Drawer" }),
|
|
257
|
+
title: "Drawer"
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsx(CommandPalette, {
|
|
260
|
+
commands: [],
|
|
261
|
+
trigger: /* @__PURE__ */ jsx(Button, { children: "Commands" })
|
|
262
|
+
})
|
|
263
|
+
] }),
|
|
264
|
+
/* @__PURE__ */ jsxs(Tabs, {
|
|
265
|
+
defaultValue: "first",
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ jsxs(Tabs.List, {
|
|
268
|
+
"aria-label": "Demo tabs",
|
|
269
|
+
children: [/* @__PURE__ */ jsx(Tabs.Trigger, {
|
|
270
|
+
value: "first",
|
|
271
|
+
children: "First"
|
|
272
|
+
}), /* @__PURE__ */ jsx(Tabs.Trigger, {
|
|
273
|
+
value: "second",
|
|
274
|
+
children: "Second"
|
|
275
|
+
})]
|
|
276
|
+
}),
|
|
277
|
+
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
278
|
+
value: "first",
|
|
279
|
+
children: "First panel"
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
282
|
+
value: "second",
|
|
283
|
+
children: "Second panel"
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
}),
|
|
287
|
+
/* @__PURE__ */ jsx(Accordion, {
|
|
288
|
+
type: "single",
|
|
289
|
+
defaultValue: "first",
|
|
290
|
+
children: /* @__PURE__ */ jsxs(Accordion.Item, {
|
|
291
|
+
value: "first",
|
|
292
|
+
children: [/* @__PURE__ */ jsx(Accordion.Trigger, { children: "Details" }), /* @__PURE__ */ jsx(Accordion.Content, { children: "Accordion content" })]
|
|
293
|
+
})
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ jsx(Pagination, {
|
|
296
|
+
count: 5,
|
|
297
|
+
"aria-label": "Demo pages"
|
|
298
|
+
}),
|
|
299
|
+
/* @__PURE__ */ jsx(Table, {
|
|
300
|
+
caption: "Demo table",
|
|
301
|
+
children: /* @__PURE__ */ jsx(Table.Body, { children: /* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.HeaderCell, {
|
|
302
|
+
scope: "row",
|
|
303
|
+
children: "Status"
|
|
304
|
+
}), /* @__PURE__ */ jsx(Table.Cell, { children: "Ready" })] }) })
|
|
305
|
+
})
|
|
306
|
+
] }) }),
|
|
307
|
+
/* @__PURE__ */ jsx(Toaster, {})
|
|
308
|
+
]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
export { DemoYarcl };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import './reference.css';
|
|
3
|
+
/** Props for {@link DesignReference}. */
|
|
4
|
+
export interface DesignReferenceProps {
|
|
5
|
+
/**
|
|
6
|
+
* Page heading.
|
|
7
|
+
* @default 'Design reference'
|
|
8
|
+
*/
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A living reference of the active design system, rendered from the consumer's config:
|
|
13
|
+
* colors with contrast ratios, the size scale with live controls, radii, variants, spacing,
|
|
14
|
+
* shadows, fonts, text styles, heading levels, density, other tokens and defaults.
|
|
15
|
+
* Import from `@yarcl/react/reference`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { DesignReference } from '@yarcl/react/reference';
|
|
20
|
+
*
|
|
21
|
+
* <DesignReference title="Acme design system" />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function DesignReference({ title }: DesignReferenceProps): import("react").JSX.Element;
|