@revojs/ui 0.1.58
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/components/breadcrumb.d.ts +4 -0
- package/dist/components/breadcrumb.js +1 -0
- package/dist/components/button.d.ts +18 -0
- package/dist/components/button.js +1 -0
- package/dist/components/card.d.ts +5 -0
- package/dist/components/card.js +1 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.js +1 -0
- package/dist/components/collection.d.ts +6 -0
- package/dist/components/collection.js +1 -0
- package/dist/components/container.d.ts +4 -0
- package/dist/components/container.js +1 -0
- package/dist/components/control.d.ts +1 -0
- package/dist/components/control.js +1 -0
- package/dist/components/counter.d.ts +8 -0
- package/dist/components/counter.js +1 -0
- package/dist/components/dialog.d.ts +6 -0
- package/dist/components/dialog.js +1 -0
- package/dist/components/field.d.ts +7 -0
- package/dist/components/field.js +1 -0
- package/dist/components/heading.d.ts +7 -0
- package/dist/components/heading.js +1 -0
- package/dist/components/icon.d.ts +3 -0
- package/dist/components/icon.js +1 -0
- package/dist/components/input.d.ts +12 -0
- package/dist/components/input.js +1 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +1 -0
- package/dist/components/navigate.d.ts +7 -0
- package/dist/components/navigate.js +1 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.js +1 -0
- package/dist/components/progress.d.ts +5 -0
- package/dist/components/progress.js +1 -0
- package/dist/components/radio.d.ts +10 -0
- package/dist/components/radio.js +1 -0
- package/dist/components/range.d.ts +8 -0
- package/dist/components/range.js +1 -0
- package/dist/components/rating.d.ts +8 -0
- package/dist/components/rating.js +1 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.js +1 -0
- package/dist/components/separator.d.ts +11 -0
- package/dist/components/separator.js +1 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +1 -0
- package/dist/components/upload.d.ts +10 -0
- package/dist/components/upload.js +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +1 -0
- package/dist/module/index.d.ts +35 -0
- package/dist/module/index.js +123 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/vue/components/breadcrumb.vue +20 -0
- package/dist/vue/components/button.vue +124 -0
- package/dist/vue/components/card.vue +53 -0
- package/dist/vue/components/checkbox.vue +54 -0
- package/dist/vue/components/collection.vue +51 -0
- package/dist/vue/components/container.vue +19 -0
- package/dist/vue/components/counter.vue +61 -0
- package/dist/vue/components/dialog.vue +76 -0
- package/dist/vue/components/field.vue +38 -0
- package/dist/vue/components/heading.vue +34 -0
- package/dist/vue/components/icon.vue +49 -0
- package/dist/vue/components/input.vue +82 -0
- package/dist/vue/components/link.vue +33 -0
- package/dist/vue/components/navigate.vue +30 -0
- package/dist/vue/components/popover.vue +123 -0
- package/dist/vue/components/progress.vue +44 -0
- package/dist/vue/components/radio.vue +59 -0
- package/dist/vue/components/range.vue +56 -0
- package/dist/vue/components/rating.vue +56 -0
- package/dist/vue/components/select.vue +99 -0
- package/dist/vue/components/separator.vue +31 -0
- package/dist/vue/components/sheet.vue +71 -0
- package/dist/vue/components/switch.vue +72 -0
- package/dist/vue/components/upload.vue +133 -0
- package/dist/vue/index.d.ts +25 -0
- package/dist/vue/index.js +25 -0
- package/package.json +46 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ButtonType = "button" | "submit";
|
|
2
|
+
export type ButtonSize = "default" | "icon";
|
|
3
|
+
export type ButtonFont = "normal" | "medium" | "semibold";
|
|
4
|
+
export type ButtonLayout = "left" | "center" | "right";
|
|
5
|
+
export type ButtonText = "sm" | "md";
|
|
6
|
+
export type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive" | "danger" | "text";
|
|
7
|
+
export interface ButtonProps {
|
|
8
|
+
iconPrefix?: string;
|
|
9
|
+
iconSuffix?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
font?: ButtonFont;
|
|
12
|
+
layout?: ButtonLayout;
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
text?: ButtonText;
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
type?: ButtonType;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ControlInteraction = "disabled" | "enabled";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface InputProps {
|
|
2
|
+
modelValue?: string | number;
|
|
3
|
+
type?: string;
|
|
4
|
+
iconPrefix?: string;
|
|
5
|
+
iconSuffix?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
spellcheck?: boolean;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ButtonLayout } from "./button";
|
|
2
|
+
export interface PopoverProps {
|
|
3
|
+
modelValue?: boolean;
|
|
4
|
+
triggerLabel?: string;
|
|
5
|
+
triggerClass?: string;
|
|
6
|
+
triggerLayout?: ButtonLayout;
|
|
7
|
+
contentClass?: string;
|
|
8
|
+
matchTriggerWidth?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SelectValue = string | number;
|
|
2
|
+
export type SelectValueState = "placeholder" | "selected";
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: SelectValue;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectProps {
|
|
9
|
+
modelValue?: SelectValue;
|
|
10
|
+
options: Array<SelectOption>;
|
|
11
|
+
label?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
2
|
+
export type DividerVariant = SeparatorOrientation;
|
|
3
|
+
export interface SeparatorProps {
|
|
4
|
+
orientation?: SeparatorOrientation;
|
|
5
|
+
variant?: DividerVariant;
|
|
6
|
+
decorative?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DividerProps {
|
|
9
|
+
variant?: DividerVariant;
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type * from "./components/breadcrumb";
|
|
2
|
+
export type * from "./components/button";
|
|
3
|
+
export type * from "./components/card";
|
|
4
|
+
export type * from "./components/checkbox";
|
|
5
|
+
export type * from "./components/collection";
|
|
6
|
+
export type * from "./components/container";
|
|
7
|
+
export type * from "./components/control";
|
|
8
|
+
export type * from "./components/counter";
|
|
9
|
+
export type * from "./components/dialog";
|
|
10
|
+
export type * from "./components/field";
|
|
11
|
+
export type * from "./components/heading";
|
|
12
|
+
export type * from "./components/icon";
|
|
13
|
+
export type * from "./components/input";
|
|
14
|
+
export type * from "./components/link";
|
|
15
|
+
export type * from "./components/navigate";
|
|
16
|
+
export type * from "./components/popover";
|
|
17
|
+
export type * from "./components/progress";
|
|
18
|
+
export type * from "./components/radio";
|
|
19
|
+
export type * from "./components/range";
|
|
20
|
+
export type * from "./components/rating";
|
|
21
|
+
export type * from "./components/select";
|
|
22
|
+
export type * from "./components/separator";
|
|
23
|
+
export type * from "./components/sheet";
|
|
24
|
+
export type * from "./components/switch";
|
|
25
|
+
export type * from "./components/upload";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type TailwindColorName = "amber" | "blue" | "cyan" | "emerald" | "fuchsia" | "gray" | "green" | "indigo" | "lime" | "neutral" | "orange" | "pink" | "purple" | "red" | "rose" | "sky" | "slate" | "stone" | "teal" | "violet" | "yellow" | "zinc";
|
|
2
|
+
export type TailwindColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
3
|
+
export type TailwindColorOpacity = 0 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100;
|
|
4
|
+
export type TailwindBaseColor = "black" | "current" | "inherit" | "transparent" | "white";
|
|
5
|
+
export type TailwindPaletteColor = TailwindBaseColor | `${TailwindColorName}-${TailwindColorShade}`;
|
|
6
|
+
export type TailwindColor = TailwindPaletteColor | `${TailwindPaletteColor}/${TailwindColorOpacity}`;
|
|
7
|
+
export type TailwindRadius = "rounded-none" | "rounded-xs" | "rounded-sm" | "rounded-md" | "rounded-lg" | "rounded-xl" | "rounded-2xl" | "rounded-3xl" | "rounded-4xl" | "rounded-full";
|
|
8
|
+
export interface UiTheme {
|
|
9
|
+
background: TailwindColor;
|
|
10
|
+
foreground: TailwindColor;
|
|
11
|
+
card: TailwindColor;
|
|
12
|
+
cardForeground: TailwindColor;
|
|
13
|
+
popover: TailwindColor;
|
|
14
|
+
popoverForeground: TailwindColor;
|
|
15
|
+
primary: TailwindColor;
|
|
16
|
+
primaryForeground: TailwindColor;
|
|
17
|
+
secondary: TailwindColor;
|
|
18
|
+
secondaryForeground: TailwindColor;
|
|
19
|
+
muted: TailwindColor;
|
|
20
|
+
mutedForeground: TailwindColor;
|
|
21
|
+
accent: TailwindColor;
|
|
22
|
+
accentForeground: TailwindColor;
|
|
23
|
+
destructive: TailwindColor;
|
|
24
|
+
destructiveForeground: TailwindColor;
|
|
25
|
+
border: TailwindColor;
|
|
26
|
+
input: TailwindColor;
|
|
27
|
+
ring: TailwindColor;
|
|
28
|
+
}
|
|
29
|
+
export interface UiConfig {
|
|
30
|
+
radius: TailwindRadius;
|
|
31
|
+
light: UiTheme;
|
|
32
|
+
dark: UiTheme;
|
|
33
|
+
}
|
|
34
|
+
declare const _default: import("revojs/module").Module<"ui", UiConfig, []>;
|
|
35
|
+
export default _default;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from "fs";
|
|
2
|
+
import { addTypes, addVirtual, defineModule, useModule } from "revojs/module";
|
|
3
|
+
//#region src/module/index.ts
|
|
4
|
+
function resolveUiClasses(source, ui) {
|
|
5
|
+
const classes = new Array();
|
|
6
|
+
for (const [, inner] of source.matchAll(/`([^`]*config\.[^`]*)`/g)) for (const token of inner.replace(/\$\{config\.([^}]+)\}/g, (_match, path) => String(path.split(".").reduce((value, key) => value[key], ui))).split(/\s+/)) if (token) classes.push(token);
|
|
7
|
+
for (const [, path] of source.replace(/`[^`]*`/g, "").matchAll(/config\.([A-Za-z0-9_.]+)/g)) {
|
|
8
|
+
const value = path.split(".").reduce((current, key) => current[key], ui);
|
|
9
|
+
if (typeof value === "string" && value) classes.push(value);
|
|
10
|
+
}
|
|
11
|
+
return classes;
|
|
12
|
+
}
|
|
13
|
+
var module_default = defineModule({
|
|
14
|
+
name: "ui",
|
|
15
|
+
config: () => ({
|
|
16
|
+
radius: "rounded-md",
|
|
17
|
+
light: {
|
|
18
|
+
background: "white",
|
|
19
|
+
foreground: "neutral-950",
|
|
20
|
+
card: "white",
|
|
21
|
+
cardForeground: "neutral-950",
|
|
22
|
+
popover: "white",
|
|
23
|
+
popoverForeground: "neutral-950",
|
|
24
|
+
primary: "neutral-900",
|
|
25
|
+
primaryForeground: "neutral-50",
|
|
26
|
+
secondary: "neutral-100",
|
|
27
|
+
secondaryForeground: "neutral-900",
|
|
28
|
+
muted: "neutral-100",
|
|
29
|
+
mutedForeground: "neutral-500",
|
|
30
|
+
accent: "neutral-100",
|
|
31
|
+
accentForeground: "neutral-900",
|
|
32
|
+
destructive: "red-600",
|
|
33
|
+
destructiveForeground: "white",
|
|
34
|
+
border: "neutral-200",
|
|
35
|
+
input: "neutral-200",
|
|
36
|
+
ring: "neutral-400"
|
|
37
|
+
},
|
|
38
|
+
dark: {
|
|
39
|
+
background: "neutral-950",
|
|
40
|
+
foreground: "neutral-50",
|
|
41
|
+
card: "neutral-900",
|
|
42
|
+
cardForeground: "neutral-50",
|
|
43
|
+
popover: "neutral-900",
|
|
44
|
+
popoverForeground: "neutral-50",
|
|
45
|
+
primary: "neutral-200",
|
|
46
|
+
primaryForeground: "neutral-900",
|
|
47
|
+
secondary: "neutral-800",
|
|
48
|
+
secondaryForeground: "neutral-50",
|
|
49
|
+
muted: "neutral-800",
|
|
50
|
+
mutedForeground: "neutral-400",
|
|
51
|
+
accent: "neutral-800",
|
|
52
|
+
accentForeground: "neutral-50",
|
|
53
|
+
destructive: "red-400",
|
|
54
|
+
destructiveForeground: "white",
|
|
55
|
+
border: "white/10",
|
|
56
|
+
input: "white/15",
|
|
57
|
+
ring: "neutral-500"
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
setup(config) {
|
|
61
|
+
const { fromModule } = useModule(import.meta.url);
|
|
62
|
+
const ui = config.ui;
|
|
63
|
+
const classes = /* @__PURE__ */ new Set();
|
|
64
|
+
const manifest = JSON.parse(readFileSync("package.json", "utf8"));
|
|
65
|
+
const iconPackages = [...new Set(Object.keys({
|
|
66
|
+
...manifest.dependencies,
|
|
67
|
+
...manifest.devDependencies,
|
|
68
|
+
...manifest.optionalDependencies
|
|
69
|
+
}).filter((name) => name.startsWith("@iconify-json/")))].sort();
|
|
70
|
+
let componentsDir = "";
|
|
71
|
+
addVirtual(config, "ui/icons", () => {
|
|
72
|
+
return `export default {${iconPackages.map((name) => `${JSON.stringify(name.slice(14))}: () => import(${JSON.stringify(`${name}/icons.json`)}).then((module) => module.default)`).join(",")}};`;
|
|
73
|
+
});
|
|
74
|
+
addTypes(config, "ui-icons", () => "declare module \"#ui/icons\" { import type { IconifyJSON } from \"@iconify/types\"; const icons: Record<string, () => Promise<IconifyJSON>>; export default icons; }");
|
|
75
|
+
for (const directory of [fromModule("../vue/components"), fromModule("../../src/vue/components")]) {
|
|
76
|
+
let entries;
|
|
77
|
+
try {
|
|
78
|
+
entries = readdirSync(directory).filter((entry) => entry.endsWith(".vue"));
|
|
79
|
+
} catch {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
componentsDir = directory;
|
|
83
|
+
for (const entry of entries) for (const token of resolveUiClasses(readFileSync(`${directory}/${entry}`, "utf8"), ui)) classes.add(token);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (!componentsDir) return;
|
|
87
|
+
const dynamics = [...classes].join(" ");
|
|
88
|
+
return { vite: { plugins: [{
|
|
89
|
+
name: "@revojs/ui",
|
|
90
|
+
enforce: "pre",
|
|
91
|
+
transform(code, key) {
|
|
92
|
+
if (!key.split("?", 1)[0].endsWith(".css")) return;
|
|
93
|
+
if (!code.includes("@import \"tailwindcss\"") && !code.includes("@import 'tailwindcss'")) return;
|
|
94
|
+
const sourceDirective = `@source "${componentsDir}";`;
|
|
95
|
+
const inlineDirective = `@source inline("${dynamics}");`;
|
|
96
|
+
const baseDirective = `@layer base {
|
|
97
|
+
* {
|
|
98
|
+
@apply border-${ui.light.border} outline-${ui.light.ring};
|
|
99
|
+
|
|
100
|
+
@variant dark {
|
|
101
|
+
@apply border-${ui.dark.border} outline-${ui.dark.ring};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
body {
|
|
106
|
+
@apply bg-${ui.light.background} text-${ui.light.foreground};
|
|
107
|
+
|
|
108
|
+
@variant dark {
|
|
109
|
+
@apply bg-${ui.dark.background} text-${ui.dark.foreground};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}`;
|
|
113
|
+
let result = code;
|
|
114
|
+
if (!result.includes(sourceDirective)) result += `\n${sourceDirective}`;
|
|
115
|
+
if (dynamics && !result.includes(inlineDirective)) result += `\n${inlineDirective}`;
|
|
116
|
+
if (!result.includes(baseDirective)) result += `\n${baseDirective}`;
|
|
117
|
+
if (result !== code) return result;
|
|
118
|
+
}
|
|
119
|
+
}] } };
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
//#endregion
|
|
123
|
+
export { module_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare module "#config/ui" {
|
|
2
|
+
import type { UiConfig } from "@revojs/ui/module";
|
|
3
|
+
|
|
4
|
+
const config: UiConfig;
|
|
5
|
+
export default config;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module "#ui/icons" {
|
|
9
|
+
import type { IconifyJSON } from "@iconify/types";
|
|
10
|
+
|
|
11
|
+
const icons: Record<string, () => Promise<IconifyJSON>>;
|
|
12
|
+
export default icons;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module "*.vue" {
|
|
16
|
+
import type { DefineComponent } from "vue";
|
|
17
|
+
|
|
18
|
+
const component: DefineComponent;
|
|
19
|
+
export default component;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nav aria-label="Breadcrumb">
|
|
3
|
+
<ol class="flex flex-wrap items-center gap-2 text-sm">
|
|
4
|
+
<li v-for="([label, href], index) in routes" :key="href" class="flex items-center gap-2">
|
|
5
|
+
<span v-if="index" aria-hidden="true" class="opacity-40"> / </span>
|
|
6
|
+
|
|
7
|
+
<Link :href="href" :label="label" :variant="index === routes.length - 1 ? 'primary' : 'muted'" />
|
|
8
|
+
</li>
|
|
9
|
+
</ol>
|
|
10
|
+
</nav>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import type { BreadcrumbRoute } from "../../components/breadcrumb.ts";
|
|
15
|
+
import Link from "./link.vue";
|
|
16
|
+
|
|
17
|
+
defineProps<{
|
|
18
|
+
routes: Array<BreadcrumbRoute>;
|
|
19
|
+
}>();
|
|
20
|
+
</script>
|