@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.
Files changed (82) hide show
  1. package/dist/components/breadcrumb.d.ts +4 -0
  2. package/dist/components/breadcrumb.js +1 -0
  3. package/dist/components/button.d.ts +18 -0
  4. package/dist/components/button.js +1 -0
  5. package/dist/components/card.d.ts +5 -0
  6. package/dist/components/card.js +1 -0
  7. package/dist/components/checkbox.d.ts +8 -0
  8. package/dist/components/checkbox.js +1 -0
  9. package/dist/components/collection.d.ts +6 -0
  10. package/dist/components/collection.js +1 -0
  11. package/dist/components/container.d.ts +4 -0
  12. package/dist/components/container.js +1 -0
  13. package/dist/components/control.d.ts +1 -0
  14. package/dist/components/control.js +1 -0
  15. package/dist/components/counter.d.ts +8 -0
  16. package/dist/components/counter.js +1 -0
  17. package/dist/components/dialog.d.ts +6 -0
  18. package/dist/components/dialog.js +1 -0
  19. package/dist/components/field.d.ts +7 -0
  20. package/dist/components/field.js +1 -0
  21. package/dist/components/heading.d.ts +7 -0
  22. package/dist/components/heading.js +1 -0
  23. package/dist/components/icon.d.ts +3 -0
  24. package/dist/components/icon.js +1 -0
  25. package/dist/components/input.d.ts +12 -0
  26. package/dist/components/input.js +1 -0
  27. package/dist/components/link.d.ts +6 -0
  28. package/dist/components/link.js +1 -0
  29. package/dist/components/navigate.d.ts +7 -0
  30. package/dist/components/navigate.js +1 -0
  31. package/dist/components/popover.d.ts +10 -0
  32. package/dist/components/popover.js +1 -0
  33. package/dist/components/progress.d.ts +5 -0
  34. package/dist/components/progress.js +1 -0
  35. package/dist/components/radio.d.ts +10 -0
  36. package/dist/components/radio.js +1 -0
  37. package/dist/components/range.d.ts +8 -0
  38. package/dist/components/range.js +1 -0
  39. package/dist/components/rating.d.ts +8 -0
  40. package/dist/components/rating.js +1 -0
  41. package/dist/components/select.d.ts +16 -0
  42. package/dist/components/select.js +1 -0
  43. package/dist/components/separator.d.ts +11 -0
  44. package/dist/components/separator.js +1 -0
  45. package/dist/components/sheet.d.ts +8 -0
  46. package/dist/components/sheet.js +1 -0
  47. package/dist/components/switch.d.ts +8 -0
  48. package/dist/components/switch.js +1 -0
  49. package/dist/components/upload.d.ts +10 -0
  50. package/dist/components/upload.js +1 -0
  51. package/dist/index.d.ts +25 -0
  52. package/dist/index.js +1 -0
  53. package/dist/module/index.d.ts +35 -0
  54. package/dist/module/index.js +123 -0
  55. package/dist/types/index.d.ts +20 -0
  56. package/dist/vue/components/breadcrumb.vue +20 -0
  57. package/dist/vue/components/button.vue +124 -0
  58. package/dist/vue/components/card.vue +53 -0
  59. package/dist/vue/components/checkbox.vue +54 -0
  60. package/dist/vue/components/collection.vue +51 -0
  61. package/dist/vue/components/container.vue +19 -0
  62. package/dist/vue/components/counter.vue +61 -0
  63. package/dist/vue/components/dialog.vue +76 -0
  64. package/dist/vue/components/field.vue +38 -0
  65. package/dist/vue/components/heading.vue +34 -0
  66. package/dist/vue/components/icon.vue +49 -0
  67. package/dist/vue/components/input.vue +82 -0
  68. package/dist/vue/components/link.vue +33 -0
  69. package/dist/vue/components/navigate.vue +30 -0
  70. package/dist/vue/components/popover.vue +123 -0
  71. package/dist/vue/components/progress.vue +44 -0
  72. package/dist/vue/components/radio.vue +59 -0
  73. package/dist/vue/components/range.vue +56 -0
  74. package/dist/vue/components/rating.vue +56 -0
  75. package/dist/vue/components/select.vue +99 -0
  76. package/dist/vue/components/separator.vue +31 -0
  77. package/dist/vue/components/sheet.vue +71 -0
  78. package/dist/vue/components/switch.vue +72 -0
  79. package/dist/vue/components/upload.vue +133 -0
  80. package/dist/vue/index.d.ts +25 -0
  81. package/dist/vue/index.js +25 -0
  82. package/package.json +46 -0
@@ -0,0 +1,4 @@
1
+ export type BreadcrumbRoute = [label: string, href: string];
2
+ export interface BreadcrumbProps {
3
+ routes: Array<BreadcrumbRoute>;
4
+ }
@@ -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,5 @@
1
+ export interface CardProps {
2
+ label?: string;
3
+ title?: string;
4
+ description?: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface CheckboxProps {
2
+ modelValue?: boolean;
3
+ label?: string;
4
+ description?: string;
5
+ name?: string;
6
+ required?: boolean;
7
+ disabled?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export type CollectionColumns = 1 | 2 | 3 | 4;
2
+ export interface CollectionProps<T = unknown> {
3
+ items?: Array<T>;
4
+ columns?: CollectionColumns;
5
+ emptyLabel?: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export type ContainerSize = "3xl" | "5xl" | "7xl";
2
+ export interface ContainerProps {
3
+ size?: ContainerSize;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type ControlInteraction = "disabled" | "enabled";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface CounterProps {
2
+ modelValue?: number;
3
+ label?: string;
4
+ min?: number;
5
+ max?: number;
6
+ step?: number;
7
+ disabled?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface DialogProps {
2
+ modelValue?: boolean;
3
+ title?: string;
4
+ description?: string;
5
+ closeLabel?: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface FieldProps {
2
+ label?: string;
3
+ description?: string;
4
+ error?: string;
5
+ required?: boolean;
6
+ disabled?: boolean;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export type HeadingLayout = "left" | "center" | "right";
2
+ export type HeadingText = "sm" | "xl" | "3xl";
3
+ export interface HeadingProps {
4
+ label?: string;
5
+ text?: HeadingText;
6
+ layout?: HeadingLayout;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface IconProps {
2
+ name: string;
3
+ }
@@ -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,6 @@
1
+ export type LinkVariant = "primary" | "muted";
2
+ export interface LinkProps {
3
+ href?: string;
4
+ label?: string;
5
+ variant?: LinkVariant;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface NavigateProps {
2
+ href: string;
3
+ label?: string;
4
+ iconPrefix?: string;
5
+ iconSuffix?: string;
6
+ active?: boolean;
7
+ }
@@ -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,5 @@
1
+ export interface ProgressProps {
2
+ value?: number;
3
+ max?: number;
4
+ label?: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export type RadioValue = string | number;
2
+ export interface RadioProps {
3
+ modelValue?: RadioValue;
4
+ value: RadioValue;
5
+ label?: string;
6
+ description?: string;
7
+ name?: string;
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface RangeProps {
2
+ modelValue?: number;
3
+ label?: string;
4
+ min?: number;
5
+ max?: number;
6
+ step?: number;
7
+ disabled?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export type RatingState = "active" | "inactive";
2
+ export interface RatingProps {
3
+ modelValue?: number;
4
+ max?: number;
5
+ label?: string;
6
+ readonly?: boolean;
7
+ disabled?: boolean;
8
+ }
@@ -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,8 @@
1
+ export type SheetSide = "top" | "right" | "bottom" | "left";
2
+ export interface SheetProps {
3
+ modelValue?: boolean;
4
+ side?: SheetSide;
5
+ title?: string;
6
+ description?: string;
7
+ closeLabel?: string;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export type SwitchState = "checked" | "unchecked";
2
+ export interface SwitchProps {
3
+ modelValue?: boolean;
4
+ label?: string;
5
+ description?: string;
6
+ name?: string;
7
+ disabled?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export type UploadState = "idle" | "over";
2
+ export interface UploadProps {
3
+ modelValue?: Blob | File;
4
+ label?: string;
5
+ description?: string;
6
+ accept?: string;
7
+ name?: string;
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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>