@byyuurin/ui 0.0.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.
Files changed (101) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +32 -0
  3. package/dist/components/Accordion.vue +104 -0
  4. package/dist/components/App.vue +57 -0
  5. package/dist/components/Button.vue +94 -0
  6. package/dist/components/Card.vue +76 -0
  7. package/dist/components/Checkbox.vue +104 -0
  8. package/dist/components/Drawer.vue +133 -0
  9. package/dist/components/Input.vue +169 -0
  10. package/dist/components/Link.vue +117 -0
  11. package/dist/components/Modal.vue +145 -0
  12. package/dist/components/ModalProvider.vue +10 -0
  13. package/dist/components/Popover.vue +97 -0
  14. package/dist/components/RadioGroup.vue +180 -0
  15. package/dist/components/Select.vue +258 -0
  16. package/dist/components/Switch.vue +99 -0
  17. package/dist/components/Tabs.vue +117 -0
  18. package/dist/components/Toast.vue +126 -0
  19. package/dist/components/Toaster.vue +143 -0
  20. package/dist/components/Tooltip.vue +71 -0
  21. package/dist/components/index.d.ts +18 -0
  22. package/dist/components/index.mjs +18 -0
  23. package/dist/composables/index.d.ts +4 -0
  24. package/dist/composables/index.mjs +4 -0
  25. package/dist/composables/useComponentIcons.d.ts +26 -0
  26. package/dist/composables/useComponentIcons.mjs +24 -0
  27. package/dist/composables/useModal.d.ts +15 -0
  28. package/dist/composables/useModal.mjs +51 -0
  29. package/dist/composables/useTheme.d.ts +8 -0
  30. package/dist/composables/useTheme.mjs +18 -0
  31. package/dist/composables/useToast.d.ts +24 -0
  32. package/dist/composables/useToast.mjs +48 -0
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.mjs +3 -0
  35. package/dist/internal/constants.d.ts +3 -0
  36. package/dist/internal/constants.mjs +21 -0
  37. package/dist/internal/extend-theme.d.ts +9 -0
  38. package/dist/internal/extend-theme.mjs +16 -0
  39. package/dist/internal/extend-theme.test.d.ts +1 -0
  40. package/dist/internal/extend-theme.test.mjs +45 -0
  41. package/dist/internal/index.d.ts +4 -0
  42. package/dist/internal/index.mjs +4 -0
  43. package/dist/internal/link.d.ts +15 -0
  44. package/dist/internal/link.mjs +4 -0
  45. package/dist/internal/styler.d.ts +5 -0
  46. package/dist/internal/styler.mjs +236 -0
  47. package/dist/internal/styler.test.d.ts +1 -0
  48. package/dist/internal/styler.test.mjs +10 -0
  49. package/dist/nuxt.d.ts +10 -0
  50. package/dist/nuxt.mjs +28 -0
  51. package/dist/resolver.d.ts +10 -0
  52. package/dist/resolver.mjs +18 -0
  53. package/dist/theme/accordion.d.ts +39 -0
  54. package/dist/theme/accordion.mjs +25 -0
  55. package/dist/theme/app.d.ts +10 -0
  56. package/dist/theme/app.mjs +9 -0
  57. package/dist/theme/button.d.ts +184 -0
  58. package/dist/theme/button.mjs +140 -0
  59. package/dist/theme/card.d.ts +43 -0
  60. package/dist/theme/card.mjs +11 -0
  61. package/dist/theme/checkbox.d.ts +97 -0
  62. package/dist/theme/checkbox.mjs +53 -0
  63. package/dist/theme/drawer.d.ts +72 -0
  64. package/dist/theme/drawer.mjs +72 -0
  65. package/dist/theme/index.d.ts +17 -0
  66. package/dist/theme/index.mjs +17 -0
  67. package/dist/theme/input.d.ts +159 -0
  68. package/dist/theme/input.mjs +133 -0
  69. package/dist/theme/link.d.ts +31 -0
  70. package/dist/theme/link.mjs +23 -0
  71. package/dist/theme/modal.d.ts +50 -0
  72. package/dist/theme/modal.mjs +54 -0
  73. package/dist/theme/popover.d.ts +27 -0
  74. package/dist/theme/popover.mjs +10 -0
  75. package/dist/theme/radioGroup.d.ts +131 -0
  76. package/dist/theme/radioGroup.mjs +67 -0
  77. package/dist/theme/select.d.ts +177 -0
  78. package/dist/theme/select.mjs +154 -0
  79. package/dist/theme/switch.d.ts +131 -0
  80. package/dist/theme/switch.mjs +78 -0
  81. package/dist/theme/tabs.d.ts +101 -0
  82. package/dist/theme/tabs.mjs +117 -0
  83. package/dist/theme/toast.d.ts +51 -0
  84. package/dist/theme/toast.mjs +27 -0
  85. package/dist/theme/toaster.d.ts +73 -0
  86. package/dist/theme/toaster.mjs +89 -0
  87. package/dist/theme/tooltip.d.ts +31 -0
  88. package/dist/theme/tooltip.mjs +8 -0
  89. package/dist/types/components.d.ts +18 -0
  90. package/dist/types/components.mjs +0 -0
  91. package/dist/types/index.d.ts +7 -0
  92. package/dist/types/index.mjs +2 -0
  93. package/dist/types/utils.d.ts +29 -0
  94. package/dist/types/utils.mjs +0 -0
  95. package/dist/unocss-preset.d.ts +37 -0
  96. package/dist/unocss-preset.mjs +164 -0
  97. package/dist/utils/index.d.ts +18 -0
  98. package/dist/utils/index.mjs +70 -0
  99. package/dist/utils/unocss.d.ts +3 -0
  100. package/dist/utils/unocss.mjs +50 -0
  101. package/package.json +103 -0
@@ -0,0 +1,117 @@
1
+ import { ct } from "@byyuurin/ui-kit";
2
+ export default ct({
3
+ slots: {
4
+ root: "flex items-center gap-2",
5
+ list: "relative flex p-1 group",
6
+ indicator: "absolute transition-all duration-200",
7
+ trigger: [
8
+ "group relative inline-flex items-center shrink-0 min-w-0 font-medium rounded-ui-tabs transition-colors",
9
+ "focus:outline-hidden",
10
+ "disabled:cursor-not-allowed disabled:opacity-50"
11
+ ],
12
+ content: "w-full focus:outline-none",
13
+ leadingIcon: "shrink-0",
14
+ label: "truncate"
15
+ },
16
+ variants: {
17
+ variant: {
18
+ solid: {
19
+ list: "bg-ui-cb/5 rounded-ui-tabs",
20
+ trigger: [
21
+ "data-[state=active]:color-ui-c1 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ui-fill/80",
22
+ "data-[state=inactive]:color-ui-cb/80 hover:data-[state=inactive]:not-disabled:color-ui-cb"
23
+ ],
24
+ indicator: "bg-ui-fill/90 rounded-ui-tabs shadow-xs"
25
+ },
26
+ soft: {
27
+ list: "bg-ui-c1 rounded-ui-tabs",
28
+ trigger: [
29
+ "data-[state=active]:color-ui-fill focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ui-fill",
30
+ "data-[state=inactive]:color-ui-cb/80 hover:data-[state=inactive]:not-disabled:color-ui-cb"
31
+ ],
32
+ indicator: "bg-ui-fill/10 rounded-ui-tabs shadow-xs"
33
+ },
34
+ link: {
35
+ list: "border-ui-cb/10",
36
+ indicator: "bg-ui-fill rounded-full",
37
+ trigger: [
38
+ "data-[state=active]:color-ui-base focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ui-base",
39
+ "data-[state=inactive]:color-ui-cb/80 hover:data-[state=inactive]:not-disabled:color-ui-cb"
40
+ ]
41
+ }
42
+ },
43
+ orientation: {
44
+ horizontal: {
45
+ root: "flex-col",
46
+ list: "w-full",
47
+ indicator: "left-0 w-[var(--reka-tabs-indicator-size)] translate-x-[var(--reka-tabs-indicator-position)]",
48
+ trigger: "justify-center"
49
+ },
50
+ vertical: {
51
+ list: "flex-col",
52
+ indicator: "top-0 h-[var(--reka-tabs-indicator-size)] translate-y-[var(--reka-tabs-indicator-position)]",
53
+ trigger: "flex-1 w-full"
54
+ }
55
+ },
56
+ size: {
57
+ xs: {
58
+ trigger: "px-2 py-1 text-xs gap-1",
59
+ leadingIcon: "size-4"
60
+ },
61
+ sm: {
62
+ trigger: "px-2.5 py-1.5 text-xs gap-1.5",
63
+ leadingIcon: "size-4"
64
+ },
65
+ md: {
66
+ trigger: "px-3 py-1.5 text-sm gap-1.5",
67
+ leadingIcon: "size-5"
68
+ },
69
+ lg: {
70
+ trigger: "px-3 py-2 text-sm gap-2",
71
+ leadingIcon: "size-5"
72
+ },
73
+ xl: {
74
+ trigger: "px-3 py-2 text-base gap-2",
75
+ leadingIcon: "size-6"
76
+ }
77
+ },
78
+ full: {
79
+ true: {
80
+ trigger: "w-full flex-1"
81
+ }
82
+ }
83
+ },
84
+ compoundVariants: [
85
+ {
86
+ orientation: "horizontal",
87
+ variant: ["solid", "soft"],
88
+ class: {
89
+ indicator: "inset-y-1"
90
+ }
91
+ },
92
+ {
93
+ orientation: "horizontal",
94
+ variant: "link",
95
+ class: {
96
+ list: "border-b -mb-px",
97
+ indicator: "-bottom-px h-px"
98
+ }
99
+ },
100
+ {
101
+ orientation: "vertical",
102
+ variant: ["solid", "soft"],
103
+ class: {
104
+ indicator: "inset-x-1",
105
+ list: "items-center rounded-[calc(var(--ui-radius-tabs)*0.66)]"
106
+ }
107
+ },
108
+ {
109
+ orientation: "vertical",
110
+ variant: "link",
111
+ class: {
112
+ list: "border-s -ms-px",
113
+ indicator: "-start-px w-px"
114
+ }
115
+ }
116
+ ]
117
+ });
@@ -0,0 +1,51 @@
1
+ declare const _default: {
2
+ base: undefined;
3
+ slots: {
4
+ root: string;
5
+ wrapper: string;
6
+ title: string;
7
+ description: string;
8
+ icon: string;
9
+ avatar: string;
10
+ avatarSize: string;
11
+ actions: string;
12
+ progress: string;
13
+ close: string;
14
+ };
15
+ variants: {
16
+ multiline: {
17
+ true: {
18
+ root: string;
19
+ actions: string;
20
+ };
21
+ false: {
22
+ root: string;
23
+ actions: string;
24
+ };
25
+ };
26
+ };
27
+ compoundVariants: import("@byyuurin/ui-kit/index").CVCompoundVariants<{
28
+ multiline: {
29
+ true: {
30
+ root: string;
31
+ actions: string;
32
+ };
33
+ false: {
34
+ root: string;
35
+ actions: string;
36
+ };
37
+ };
38
+ }, {
39
+ root: string;
40
+ wrapper: string;
41
+ title: string;
42
+ description: string;
43
+ icon: string;
44
+ avatar: string;
45
+ avatarSize: string;
46
+ actions: string;
47
+ progress: string;
48
+ close: string;
49
+ }, undefined>;
50
+ };
51
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import { ct } from "@byyuurin/ui-kit";
2
+ export default ct({
3
+ slots: {
4
+ root: "relative group overflow-hidden bg-ui-c1 shadow-lg rounded-ui-box ring ring-ui-c2 p-4 flex gap-2.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ui-c2",
5
+ wrapper: "w-0 flex-1 flex flex-col gap-1",
6
+ title: "text-base font-medium color-ui-cb",
7
+ description: "text-sm color-ui-cb/80",
8
+ icon: "shrink-0 size-6 color-ui-cb",
9
+ avatar: "shrink-0",
10
+ avatarSize: "2xl",
11
+ actions: "flex flex-wrap gap-1.5 shrink-0",
12
+ progress: "absolute inset-x-0 bottom-0 h-1 z-[-1] color-ui-base/80 bg-current",
13
+ close: "p-0.5"
14
+ },
15
+ variants: {
16
+ multiline: {
17
+ true: {
18
+ root: "items-start",
19
+ actions: "items-start mt-1"
20
+ },
21
+ false: {
22
+ root: "items-center",
23
+ actions: "items-center"
24
+ }
25
+ }
26
+ }
27
+ });
@@ -0,0 +1,73 @@
1
+ declare const _default: {
2
+ base: undefined;
3
+ slots: {
4
+ viewport: string[];
5
+ base: string[];
6
+ };
7
+ variants: {
8
+ position: {
9
+ 'top-left': {
10
+ viewport: string;
11
+ };
12
+ 'top-center': {
13
+ viewport: string;
14
+ };
15
+ 'top-right': {
16
+ viewport: string;
17
+ };
18
+ 'bottom-left': {
19
+ viewport: string;
20
+ };
21
+ 'bottom-center': {
22
+ viewport: string;
23
+ };
24
+ 'bottom-right': {
25
+ viewport: string;
26
+ };
27
+ };
28
+ swipeDirection: {
29
+ up: {
30
+ base: string;
31
+ };
32
+ right: {
33
+ base: string;
34
+ };
35
+ down: {
36
+ base: string;
37
+ };
38
+ left: {
39
+ base: string;
40
+ };
41
+ };
42
+ };
43
+ compoundVariants: ({
44
+ position: ("top-left" | "top-center" | "top-right")[];
45
+ class: {
46
+ viewport: string;
47
+ base: string;
48
+ };
49
+ swipeDirection?: undefined;
50
+ } | {
51
+ position: ("bottom-left" | "bottom-center" | "bottom-right")[];
52
+ class: {
53
+ viewport: string;
54
+ base: string;
55
+ };
56
+ swipeDirection?: undefined;
57
+ } | {
58
+ swipeDirection: ("right" | "left")[];
59
+ class: {
60
+ base: string[];
61
+ viewport?: undefined;
62
+ };
63
+ position?: undefined;
64
+ } | {
65
+ swipeDirection: ("up" | "down")[];
66
+ class: {
67
+ base: string[];
68
+ viewport?: undefined;
69
+ };
70
+ position?: undefined;
71
+ })[];
72
+ };
73
+ export default _default;
@@ -0,0 +1,89 @@
1
+ import { ct } from "@byyuurin/ui-kit";
2
+ export default ct({
3
+ slots: {
4
+ viewport: [
5
+ "fixed flex flex-col w-[calc(100%-2rem)] sm:w-96 z-[100] focus:outline-none",
6
+ "data-[expanded=true]:h-[var(--height)]"
7
+ ],
8
+ base: [
9
+ "pointer-events-auto absolute inset-x-0 z-[var(--index)] [transform:var(--transform)] transition-all duration-200 ease-out",
10
+ "[&[data-expanded=false][data-front=false]]:h-[var(--front-height)]",
11
+ "[&[data-expanded=false][data-front=false]>*]:invisible",
12
+ "data-[state=closed]:animate-[toast-closed_200ms_ease-in-out]",
13
+ "[&[data-state=closed][data-expanded=false][data-front=false]]:animate-[toast-collapsed-closed_200ms_ease-in-out]",
14
+ "data-[swipe=move]:transition-none"
15
+ ]
16
+ },
17
+ variants: {
18
+ position: {
19
+ "top-left": {
20
+ viewport: "left-4"
21
+ },
22
+ "top-center": {
23
+ viewport: "left-1/2 -translate-x-1/2"
24
+ },
25
+ "top-right": {
26
+ viewport: "right-4"
27
+ },
28
+ "bottom-left": {
29
+ viewport: "left-4"
30
+ },
31
+ "bottom-center": {
32
+ viewport: "left-1/2 -translate-x-1/2"
33
+ },
34
+ "bottom-right": {
35
+ viewport: "right-4"
36
+ }
37
+ },
38
+ swipeDirection: {
39
+ up: {
40
+ base: "data-[swipe=end]:animate-[toast-slide-up_200ms_ease-out]"
41
+ },
42
+ right: {
43
+ base: "data-[swipe=end]:animate-[toast-slide-right_200ms_ease-out]"
44
+ },
45
+ down: {
46
+ base: "data-[swipe=end]:animate-[toast-slide-down_200ms_ease-out]"
47
+ },
48
+ left: {
49
+ base: "data-[swipe=end]:animate-[toast-slide-left_200ms_ease-out]"
50
+ }
51
+ }
52
+ },
53
+ compoundVariants: [
54
+ {
55
+ position: ["top-left", "top-center", "top-right"],
56
+ class: {
57
+ viewport: "top-4",
58
+ base: "top-0 data-[state=open]:animate-[slide-in-from-top_200ms_ease-in-out]"
59
+ }
60
+ },
61
+ {
62
+ position: ["bottom-left", "bottom-center", "bottom-right"],
63
+ class: {
64
+ viewport: "bottom-4",
65
+ base: "bottom-0 data-[state=open]:animate-[slide-in-from-bottom_200ms_ease-in-out]"
66
+ }
67
+ },
68
+ {
69
+ swipeDirection: ["left", "right"],
70
+ class: {
71
+ base: [
72
+ "data-[swipe=move]:translate-x-[var(--reka-toast-swipe-move-x)]",
73
+ "data-[swipe=end]:translate-x-[var(--reka-toast-swipe-end-x)]",
74
+ "data-[swipe=cancel]:translate-x-0"
75
+ ]
76
+ }
77
+ },
78
+ {
79
+ swipeDirection: ["up", "down"],
80
+ class: {
81
+ base: [
82
+ "data-[swipe=move]:translate-y-[var(--reka-toast-swipe-move-y)]",
83
+ "data-[swipe=end]:translate-y-[var(--reka-toast-swipe-end-y)]",
84
+ "data-[swipe=cancel]:translate-y-0"
85
+ ]
86
+ }
87
+ }
88
+ ]
89
+ });
@@ -0,0 +1,31 @@
1
+ declare const _default: {
2
+ base: undefined;
3
+ slots: {
4
+ content: string;
5
+ arrow: string;
6
+ text: string;
7
+ };
8
+ variants: {
9
+ [key: string]: {
10
+ [key: string]: "" | {
11
+ content?: import("@byyuurin/ui-kit/index").ClassValue;
12
+ arrow?: import("@byyuurin/ui-kit/index").ClassValue;
13
+ text?: import("@byyuurin/ui-kit/index").ClassValue;
14
+ } | null;
15
+ };
16
+ };
17
+ compoundVariants: import("@byyuurin/ui-kit/index").CVCompoundVariants<{
18
+ [key: string]: {
19
+ [key: string]: "" | {
20
+ content?: import("@byyuurin/ui-kit/index").ClassValue;
21
+ arrow?: import("@byyuurin/ui-kit/index").ClassValue;
22
+ text?: import("@byyuurin/ui-kit/index").ClassValue;
23
+ } | null;
24
+ };
25
+ }, {
26
+ content: string;
27
+ arrow: string;
28
+ text: string;
29
+ }, undefined>;
30
+ };
31
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { ct } from "@byyuurin/ui-kit";
2
+ export default ct({
3
+ slots: {
4
+ content: "flex items-center gap-1 bg-ui-c1 color-ui-base shadow-sm rounded-ui-base ring ring-ui-base/10 h-6 px-2 py-1 text-xs select-none data-[state=delayed-open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in]",
5
+ arrow: "fill-ui-c1 stroke-ui-cb/10",
6
+ text: "truncate"
7
+ }
8
+ });
@@ -0,0 +1,18 @@
1
+ export type * from '../components/Accordion.vue';
2
+ export type * from '../components/App.vue';
3
+ export type * from '../components/App.vue';
4
+ export type * from '../components/Button.vue';
5
+ export type * from '../components/Card.vue';
6
+ export type * from '../components/Checkbox.vue';
7
+ export type * from '../components/Drawer.vue';
8
+ export type * from '../components/Input.vue';
9
+ export type * from '../components/Link.vue';
10
+ export type * from '../components/Modal.vue';
11
+ export type * from '../components/Popover.vue';
12
+ export type * from '../components/RadioGroup.vue';
13
+ export type * from '../components/Select.vue';
14
+ export type * from '../components/Switch.vue';
15
+ export type * from '../components/Tabs.vue';
16
+ export type * from '../components/Toast.vue';
17
+ export type * from '../components/Toaster.vue';
18
+ export type * from '../components/Tooltip.vue';
File without changes
@@ -0,0 +1,7 @@
1
+ import type * as _components from '../components';
2
+ import type * as theme from '../theme';
3
+ import type { PartialTheme } from '../types';
4
+ export * from './components';
5
+ export * from './utils';
6
+ export type ThemeExtension = PartialTheme<typeof theme>;
7
+ export type ComponentName = keyof typeof _components;
@@ -0,0 +1,2 @@
1
+ export * from "./components.mjs";
2
+ export * from "./utils.mjs";
@@ -0,0 +1,29 @@
1
+ import type { ClassValue, CVReturnType, VariantProps } from '@byyuurin/ui-kit';
2
+ export type HintString<T extends string> = T & (string & {});
3
+ export type MaybeArray<T> = T | T[];
4
+ export type MaybeArrayOfArray<T> = T[] | T[][];
5
+ export type MaybeArrayOfArrayItem<T> = T extends Array<infer V1> ? T extends Array<infer V2> ? V2 : V1 : never;
6
+ export type PartialTheme<T> = {
7
+ [P in keyof T as T[P] extends undefined ? never : P]?: T[P] extends Array<infer V> ? V extends string ? string : V[] : T[P] extends object ? PartialTheme<T[P]> : T[P] extends string ? string : T[P];
8
+ };
9
+ export type DynamicSlots<T extends {
10
+ slot?: string;
11
+ }, SlotProps, Slot = T['slot']> = Record<string, SlotProps> & (Slot extends string ? Record<Slot, SlotProps> : Record<string, never>);
12
+ export interface ComponentAttrs<T> {
13
+ class?: MaybeArray<string | Record<string, boolean>>;
14
+ ui?: T extends {
15
+ slots: infer S;
16
+ } ? {
17
+ [Slot in keyof S]?: string;
18
+ } : never;
19
+ }
20
+ export interface StylerBaseProps {
21
+ class?: ClassValue;
22
+ }
23
+ export type StylerReturnType<T> = T extends CVReturnType<infer V, infer S, infer B> ? ReturnType<CVReturnType<V, S, B>> : never;
24
+ export type Styler<T> = T extends CVReturnType<infer V, any, any> ? [keyof V] extends string[] ? (props: Required<VariantProps<T>> & StylerBaseProps) => StylerReturnType<T> : (props?: StylerBaseProps) => StylerReturnType<T> : never;
25
+ export interface SelectModelValueEmits<T, V, M extends boolean = false, DV = T> {
26
+ (event: 'update:modelValue', payload: SelectModelValue<T, V, M, DV>): void;
27
+ }
28
+ export type SelectModelValue<T, V, M extends boolean = false, DV = T> = (T extends Record<string, any> ? V extends keyof T ? T[V] : DV : T) extends infer U ? M extends true ? U[] : U : never;
29
+ export type SelectOptionKey<T> = T extends Record<string, any> ? keyof T : string;
File without changes
@@ -0,0 +1,37 @@
1
+ import type { Theme } from '@unocss/preset-mini';
2
+ export interface PresetOptions {
3
+ /** @default "0rem" */
4
+ radius?: string;
5
+ /** @default "[radius]" */
6
+ radiusButton?: string;
7
+ /** @default "[radius]" */
8
+ radiusBox?: string;
9
+ /** @default "[radius]" */
10
+ radiusTabs?: string;
11
+ /**
12
+ * Base content color
13
+ * @default "#1f2937"
14
+ */
15
+ cb?: string;
16
+ /**
17
+ * Base color 1
18
+ * @default "#ffffff"
19
+ */
20
+ c1?: string;
21
+ /**
22
+ * Base color 2
23
+ * @default "#f2f2f2"
24
+ */
25
+ c2?: string;
26
+ /**
27
+ * Base color 3
28
+ * @default "#e5e6e6"
29
+ */
30
+ c3?: string;
31
+ }
32
+ export declare const cssVarsPrefix = "ui";
33
+ export declare const cssVarsBase: string[];
34
+ export declare const cssVarsDynamic: string[];
35
+ export declare const cssVarsAll: string[];
36
+ declare const _default: import("@unocss/core").PresetFactory<Theme, PresetOptions>;
37
+ export default _default;
@@ -0,0 +1,164 @@
1
+ import { definePreset } from "@unocss/core";
2
+ import { parseColor, parseCssColor } from "@unocss/preset-mini/utils";
3
+ export const cssVarsPrefix = "ui";
4
+ export const cssVarsBase = ["cb", "c1", "c2", "c3"];
5
+ export const cssVarsDynamic = ["fill", "content"];
6
+ export const cssVarsAll = [...cssVarsBase, ...cssVarsDynamic];
7
+ export default definePreset((options = {}) => {
8
+ const theme = {
9
+ colors: {
10
+ [cssVarsPrefix]: {
11
+ cb: cssColor(cssVar("cb")),
12
+ c: {
13
+ 1: cssColor(cssVar("c1")),
14
+ 2: cssColor(cssVar("c2")),
15
+ 3: cssColor(cssVar("c3"))
16
+ },
17
+ fill: cssColor(cssVar("fill", cssVar("cb"))),
18
+ content: cssColor(cssVar("content", cssVar("cb")))
19
+ }
20
+ },
21
+ backgroundColor: {
22
+ [cssVarsPrefix]: {
23
+ base: cssColor(cssVar("fill", cssVar("c1")))
24
+ }
25
+ },
26
+ textColor: {
27
+ [cssVarsPrefix]: {
28
+ base: cssColor(cssVar("content", cssVar("cb")))
29
+ }
30
+ },
31
+ borderColor: {
32
+ [cssVarsPrefix]: {
33
+ base: cssColor(cssVar("fill", cssVar("cb")))
34
+ }
35
+ },
36
+ borderRadius: {
37
+ [`${cssVarsPrefix}-base`]: cssVar("radius"),
38
+ [`${cssVarsPrefix}-button`]: cssVar("radius-button", cssVar("radius")),
39
+ [`${cssVarsPrefix}-box`]: cssVar("radius-box", cssVar("radius")),
40
+ [`${cssVarsPrefix}-tabs`]: cssVar("radius-tabs", cssVar("radius"))
41
+ },
42
+ ringWidth: {
43
+ DEFAULT: "1px"
44
+ },
45
+ shadowColor: {
46
+ [cssVarsPrefix]: {
47
+ base: cssColor(cssVar("fill", cssVar("cb")))
48
+ }
49
+ },
50
+ animation: {
51
+ keyframes: {
52
+ "fade-in": "{from {opacity: 0;}to {opacity: 1;}}",
53
+ "fade-out": "{from {opacity: 1;}to {opacity: 0;}}",
54
+ "scale-in": "{from {opacity: 0;scale: 0.95;}to {opacity: 1;scale: 1;}}",
55
+ "scale-out": "{from {opacity: 1;scale: 1;}to {opacity: 0;scale: 0.95;}}",
56
+ "slide-in-from-top": "{from {transform: translateY(-100%);}to {transform: translateY(0);}}",
57
+ "slide-out-to-top": "{from {transform: translateY(0);}to {transform: translateY(-100%);}}",
58
+ "slide-in-from-right": "{from {transform: translateX(100%);}to {transform: translateX(0);}}",
59
+ "slide-out-to-right": "{from {transform: translateX(0);}to {transform: translateX(100%);}}",
60
+ "slide-in-from-bottom": "{from {transform: translateY(100%);}to {transform: translateY(0);}}",
61
+ "slide-out-to-bottom": "{from {transform: translateY(0);}to {transform: translateY(100%);}}",
62
+ "slide-in-from-left": "{from {transform: translateX(-100%);}to {transform: translateX(0);}}",
63
+ "slide-out-to-left": "{from {transform: translateX(0);}to {transform: translateX(-100%);}}",
64
+ "slide-in-from-top-and-fade": "{from {opacity: 0;transform: translateY(-4px);}to {opacity: 1;transform: translateY(0);}}",
65
+ "slide-out-to-top-and-fade": "{from {opacity: 1;transform: translateY(0);}to {opacity: 0;transform: translateY(-4px);}}",
66
+ "slide-in-from-right-and-fade": "{from {opacity: 0;transform: translateX(4px);}to {opacity: 1;transform: translateX(0);}}",
67
+ "slide-out-to-right-and-fade": "{from {opacity: 1;transform: translateX(0);}to {opacity: 0;transform: translateX(4px);}}",
68
+ "slide-in-from-bottom-and-fade": "{from {opacity: 0;transform: translateY(4px);}to {opacity: 1;transform: translateY(0);}}",
69
+ "slide-out-to-bottom-and-fade": "{from {opacity: 1;transform: translateY(0);}to {opacity: 0;transform: translateY(4px);}}",
70
+ "slide-in-from-left-and-fade": "{from {opacity: 0;transform: translateX(-4px);}to {opacity: 1;transform: translateX(0);}}",
71
+ "slide-out-to-left-and-fade": "{from {opacity: 1;transform: translateX(0);}to {opacity: 0;transform: translateX(-4px);}}"
72
+ }
73
+ }
74
+ };
75
+ const resolveRuleValue = (data) => {
76
+ if (data?.color && data.cssColor?.components) {
77
+ let value = data.cssColor.components.join(" ");
78
+ if (!/var\s*\((.+)\)(.*)/.test(data.color))
79
+ value += ` /* ${data.color} */`;
80
+ return value;
81
+ }
82
+ return null;
83
+ };
84
+ return {
85
+ name: "unocss-preset-ui",
86
+ theme,
87
+ rules: [
88
+ [
89
+ new RegExp(`^${cssVarsPrefix}-([^/]+)$`),
90
+ ([_, color], ctx) => {
91
+ const data = parseColor(color, ctx.theme);
92
+ const value = resolveRuleValue(data);
93
+ if (value)
94
+ return Object.fromEntries(cssVarsDynamic.map((prop) => [`--${cssVarsPrefix}-${prop}`, value]));
95
+ },
96
+ { autocomplete: `${cssVarsPrefix}-$colors` }
97
+ ],
98
+ [
99
+ new RegExp(`^${cssVarsPrefix}-(?:(${cssVarsAll.join("|")})-)([^/]+)$`),
100
+ ([_, prop, color], ctx) => {
101
+ const data = parseColor(color, ctx.theme);
102
+ const value = resolveRuleValue(data);
103
+ if (value)
104
+ return { [`--${cssVarsPrefix}-${prop}`]: value };
105
+ },
106
+ { autocomplete: `${cssVarsPrefix}-(${cssVarsAll.join("|")})-$colors` }
107
+ ],
108
+ // overrides
109
+ [/^rotate-(\d+)$/, ([_, d]) => ({ rotate: `${d}deg` })]
110
+ ],
111
+ preflights: [
112
+ { getCSS: () => createRootCSS(mergeOptions(options)) }
113
+ ],
114
+ safelist: Object.keys(theme.animation.keyframes).map((v) => `keyframes-${v}`)
115
+ };
116
+ });
117
+ function mergeOptions(options) {
118
+ const defaults = {
119
+ radius: "0rem",
120
+ radiusButton: "",
121
+ radiusBox: "",
122
+ radiusTabs: "",
123
+ cb: "#1f2937",
124
+ c1: "#ffffff",
125
+ c2: "#f2f2f2",
126
+ c3: "#e5e6e6"
127
+ };
128
+ return {
129
+ ...defaults,
130
+ ...options
131
+ };
132
+ }
133
+ function cssVar(name, ...defaultValue) {
134
+ return `var(${[`--${cssVarsPrefix}-${name}`, ...defaultValue].join(",")})`;
135
+ }
136
+ function cssColor(...rgb) {
137
+ return `rgb(${rgb.join(" ")})`;
138
+ }
139
+ function createRootCSS(kv) {
140
+ const kebabCase = (input) => input.replace(/([A-Z][^A-Z]*)/g, "-$1").replace(/^-/, "").toLowerCase();
141
+ const join = (input) => input.map((item) => item.endsWith(";") ? item : `${item};`).join("");
142
+ const css = [
143
+ // initial
144
+ `:root{${join(Object.entries(kv).filter(([_, v]) => Boolean(v)).map(([k, v]) => {
145
+ const name = kebabCase(k);
146
+ const content = parseCssColor(v)?.components.join(" ") ?? v;
147
+ return `--${cssVarsPrefix}-${name}:${content}`;
148
+ }))}}`,
149
+ // reset
150
+ `:root{${join([
151
+ `color:${cssColor(cssVar("cb"))}`
152
+ ])}}`,
153
+ `*,::before,::after{${join([
154
+ `--un-default-border-color:color-mix(in srgb,${cssColor(cssVar("cb"))} 10%,transparent)`,
155
+ `accent-color:${cssColor(cssVar("fill", cssVar("cb")))}`,
156
+ `scrollbar-color:color-mix(in srgb,${cssColor(cssVar("cb"))} 25%,transparent) transparent`
157
+ ])}}`,
158
+ `*::selection{${join([
159
+ `color:${cssColor(cssVar("c1"))}`,
160
+ `background-color:${cssColor(cssVar("fill", cssVar("cb")))}`
161
+ ])}}`
162
+ ];
163
+ return css.join("");
164
+ }