@byyuurin/ui 0.0.3 → 0.0.4
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 +4 -2
- package/dist/nuxt.mjs +1 -1
- package/dist/resolver.mjs +1 -1
- package/dist/runtime/components/App.vue +5 -1
- package/dist/runtime/components/Button.vue +0 -1
- package/dist/runtime/components/Checkbox.vue +2 -5
- package/dist/runtime/components/Input.vue +5 -1
- package/dist/runtime/components/ModalProvider.vue +1 -1
- package/dist/runtime/components/RadioGroup.vue +1 -7
- package/dist/runtime/components/ScrollArea.vue +72 -0
- package/dist/runtime/components/Switch.vue +0 -1
- package/dist/runtime/components/Tabs.vue +5 -5
- package/dist/runtime/components/Textarea.vue +173 -0
- package/dist/runtime/components/Toast.vue +1 -1
- package/dist/runtime/components/index.d.ts +2 -0
- package/dist/runtime/components/index.mjs +2 -0
- package/dist/runtime/composables/defineInjection.d.ts +11 -0
- package/dist/runtime/composables/defineInjection.mjs +9 -0
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.mjs +1 -0
- package/dist/runtime/composables/useModal.d.ts +1 -1
- package/dist/runtime/composables/useModal.mjs +3 -2
- package/dist/runtime/composables/useTheme.d.ts +3 -1
- package/dist/runtime/composables/useTheme.mjs +14 -6
- package/dist/runtime/theme/button.d.ts +0 -8
- package/dist/runtime/theme/button.mjs +1 -9
- package/dist/runtime/theme/checkbox.d.ts +0 -12
- package/dist/runtime/theme/checkbox.mjs +4 -9
- package/dist/runtime/theme/index.d.ts +2 -0
- package/dist/runtime/theme/index.mjs +2 -0
- package/dist/runtime/theme/radioGroup.d.ts +0 -24
- package/dist/runtime/theme/radioGroup.mjs +8 -20
- package/dist/runtime/theme/scrollArea.d.ts +51 -0
- package/dist/runtime/theme/scrollArea.mjs +30 -0
- package/dist/runtime/theme/switch.d.ts +0 -12
- package/dist/runtime/theme/switch.mjs +2 -8
- package/dist/runtime/theme/tabs.d.ts +32 -11
- package/dist/runtime/theme/tabs.mjs +19 -12
- package/dist/runtime/theme/textarea.d.ts +90 -0
- package/dist/runtime/theme/textarea.mjs +100 -0
- package/dist/runtime/theme/toast.mjs +1 -1
- package/dist/runtime/types/components.d.ts +2 -0
- package/dist/runtime/utils/index.d.ts +0 -11
- package/dist/runtime/utils/index.mjs +0 -11
- package/dist/shared/{ui.CPXA9QoM.mjs → ui.Cmq14xN9.mjs} +2 -0
- package/dist/unocss-preset.d.mts +15 -7
- package/dist/unocss-preset.d.ts +15 -7
- package/dist/unocss-preset.mjs +90 -386
- package/package.json +6 -5
- package/dist/index.cjs +0 -38
- package/dist/runtime/components/index.cjs +0 -132
- package/dist/runtime/composables/index.cjs +0 -33
- package/dist/runtime/composables/useComponentIcons.cjs +0 -30
- package/dist/runtime/composables/useModal.cjs +0 -55
- package/dist/runtime/composables/useTheme.cjs +0 -30
- package/dist/runtime/composables/useToast.cjs +0 -51
- package/dist/runtime/theme/accordion.cjs +0 -27
- package/dist/runtime/theme/app.cjs +0 -15
- package/dist/runtime/theme/button.cjs +0 -127
- package/dist/runtime/theme/card.cjs +0 -17
- package/dist/runtime/theme/checkbox.cjs +0 -56
- package/dist/runtime/theme/drawer.cjs +0 -73
- package/dist/runtime/theme/index.cjs +0 -125
- package/dist/runtime/theme/input.cjs +0 -115
- package/dist/runtime/theme/link.cjs +0 -23
- package/dist/runtime/theme/modal.cjs +0 -55
- package/dist/runtime/theme/popover.cjs +0 -13
- package/dist/runtime/theme/radioGroup.cjs +0 -73
- package/dist/runtime/theme/select.cjs +0 -128
- package/dist/runtime/theme/switch.cjs +0 -73
- package/dist/runtime/theme/tabs.cjs +0 -105
- package/dist/runtime/theme/toast.cjs +0 -33
- package/dist/runtime/theme/toaster.cjs +0 -72
- package/dist/runtime/theme/tooltip.cjs +0 -14
- package/dist/runtime/types/components.cjs +0 -1
- package/dist/runtime/types/index.cjs +0 -27
- package/dist/runtime/types/utils.cjs +0 -1
- package/dist/runtime/utils/extend-theme.cjs +0 -24
- package/dist/runtime/utils/index.cjs +0 -119
- package/dist/runtime/utils/link.cjs +0 -10
- package/dist/runtime/utils/styler.cjs +0 -18
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import type { InjectionKey } from 'vue';
|
|
2
1
|
export * from './extend-theme';
|
|
3
2
|
export * from './link';
|
|
4
3
|
export * from './styler';
|
|
5
|
-
export declare function createInjection<T>(name: string): {
|
|
6
|
-
injectionKey: InjectionKey<T>;
|
|
7
|
-
provide: (value: T) => void;
|
|
8
|
-
inject: () => T | undefined;
|
|
9
|
-
};
|
|
10
|
-
export declare function createInjection<T>(name: string, defaultValue: T): {
|
|
11
|
-
injectionKey: InjectionKey<T>;
|
|
12
|
-
provide: (value: T) => void;
|
|
13
|
-
inject: () => T;
|
|
14
|
-
};
|
|
15
4
|
export declare function pick<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Pick<Data, Keys>;
|
|
16
5
|
export declare function omit<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Omit<Data, Keys>;
|
|
17
6
|
export declare function get(object: Record<string, any> | undefined, path: (string | number)[] | string, defaultValue?: any): any;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { isEqual } from "ohash";
|
|
2
|
-
import { inject as vueInject, provide as vueProvide } from "vue";
|
|
3
2
|
export * from "./extend-theme.mjs";
|
|
4
3
|
export * from "./link.mjs";
|
|
5
4
|
export * from "./styler.mjs";
|
|
6
|
-
export function createInjection(name, defaultValue) {
|
|
7
|
-
const injectionKey = Symbol(name);
|
|
8
|
-
const provide = (value) => vueProvide(injectionKey, value);
|
|
9
|
-
const inject = () => vueInject(injectionKey, defaultValue);
|
|
10
|
-
return {
|
|
11
|
-
injectionKey,
|
|
12
|
-
provide,
|
|
13
|
-
inject
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
5
|
export function pick(data, keys) {
|
|
17
6
|
const result = {};
|
|
18
7
|
for (const key of keys)
|
package/dist/unocss-preset.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as unocss from 'unocss';
|
|
1
2
|
import { CRRule } from '@byyuurin/ui-kit';
|
|
2
|
-
import
|
|
3
|
-
import * as _unocss_preset_mini from '@unocss/preset-mini';
|
|
3
|
+
import { UserConfig, Rule } from '@unocss/core';
|
|
4
4
|
import { Theme } from '@unocss/preset-mini';
|
|
5
5
|
|
|
6
6
|
declare const cssVarsPrefix = "ui";
|
|
@@ -8,15 +8,19 @@ declare const cssVarsBase: string[];
|
|
|
8
8
|
declare const cssVarsDynamic: string[];
|
|
9
9
|
declare const cssVarsAll: string[];
|
|
10
10
|
|
|
11
|
-
declare function createMergeRules(): CRRule[];
|
|
12
|
-
|
|
13
11
|
interface PresetOptions {
|
|
14
12
|
/** @default "0rem" */
|
|
15
13
|
radius?: string;
|
|
16
14
|
/** @default "[radius]" */
|
|
15
|
+
radiusBox?: string;
|
|
16
|
+
/** @default "[radius]" */
|
|
17
17
|
radiusButton?: string;
|
|
18
18
|
/** @default "[radius]" */
|
|
19
|
-
|
|
19
|
+
radiusCheckbox?: string;
|
|
20
|
+
/** @default "[radius]" */
|
|
21
|
+
radiusRadio?: string;
|
|
22
|
+
/** @default "[radius]" */
|
|
23
|
+
radiusSwitch?: string;
|
|
20
24
|
/** @default "[radius]" */
|
|
21
25
|
radiusTabs?: string;
|
|
22
26
|
/**
|
|
@@ -40,10 +44,14 @@ interface PresetOptions {
|
|
|
40
44
|
*/
|
|
41
45
|
c3?: string;
|
|
42
46
|
}
|
|
43
|
-
declare const preset:
|
|
47
|
+
declare const preset: unocss.PresetFactory<object, PresetOptions>;
|
|
48
|
+
|
|
49
|
+
declare function transformUnoRules(userConfig?: UserConfig): CRRule[];
|
|
50
|
+
|
|
51
|
+
declare const rules: Rule[];
|
|
44
52
|
|
|
45
53
|
declare const theme: Theme;
|
|
46
54
|
declare function cssVar(name: string, ...defaultValue: string[]): string;
|
|
47
55
|
declare function cssColor(...rgb: (string | number)[]): string;
|
|
48
56
|
|
|
49
|
-
export { type PresetOptions,
|
|
57
|
+
export { type PresetOptions, cssColor, cssVar, cssVarsAll, cssVarsBase, cssVarsDynamic, cssVarsPrefix, preset as default, preset, rules, theme, transformUnoRules };
|
package/dist/unocss-preset.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as unocss from 'unocss';
|
|
1
2
|
import { CRRule } from '@byyuurin/ui-kit';
|
|
2
|
-
import
|
|
3
|
-
import * as _unocss_preset_mini from '@unocss/preset-mini';
|
|
3
|
+
import { UserConfig, Rule } from '@unocss/core';
|
|
4
4
|
import { Theme } from '@unocss/preset-mini';
|
|
5
5
|
|
|
6
6
|
declare const cssVarsPrefix = "ui";
|
|
@@ -8,15 +8,19 @@ declare const cssVarsBase: string[];
|
|
|
8
8
|
declare const cssVarsDynamic: string[];
|
|
9
9
|
declare const cssVarsAll: string[];
|
|
10
10
|
|
|
11
|
-
declare function createMergeRules(): CRRule[];
|
|
12
|
-
|
|
13
11
|
interface PresetOptions {
|
|
14
12
|
/** @default "0rem" */
|
|
15
13
|
radius?: string;
|
|
16
14
|
/** @default "[radius]" */
|
|
15
|
+
radiusBox?: string;
|
|
16
|
+
/** @default "[radius]" */
|
|
17
17
|
radiusButton?: string;
|
|
18
18
|
/** @default "[radius]" */
|
|
19
|
-
|
|
19
|
+
radiusCheckbox?: string;
|
|
20
|
+
/** @default "[radius]" */
|
|
21
|
+
radiusRadio?: string;
|
|
22
|
+
/** @default "[radius]" */
|
|
23
|
+
radiusSwitch?: string;
|
|
20
24
|
/** @default "[radius]" */
|
|
21
25
|
radiusTabs?: string;
|
|
22
26
|
/**
|
|
@@ -40,10 +44,14 @@ interface PresetOptions {
|
|
|
40
44
|
*/
|
|
41
45
|
c3?: string;
|
|
42
46
|
}
|
|
43
|
-
declare const preset:
|
|
47
|
+
declare const preset: unocss.PresetFactory<object, PresetOptions>;
|
|
48
|
+
|
|
49
|
+
declare function transformUnoRules(userConfig?: UserConfig): CRRule[];
|
|
50
|
+
|
|
51
|
+
declare const rules: Rule[];
|
|
44
52
|
|
|
45
53
|
declare const theme: Theme;
|
|
46
54
|
declare function cssVar(name: string, ...defaultValue: string[]): string;
|
|
47
55
|
declare function cssColor(...rgb: (string | number)[]): string;
|
|
48
56
|
|
|
49
|
-
export { type PresetOptions,
|
|
57
|
+
export { type PresetOptions, cssColor, cssVar, cssVarsAll, cssVarsBase, cssVarsDynamic, cssVarsPrefix, preset as default, preset, rules, theme, transformUnoRules };
|
package/dist/unocss-preset.mjs
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { definePreset, mergeConfigs } from '@unocss/core';
|
|
2
|
+
import { parseColor, parseCssColor } from '@unocss/preset-mini/utils';
|
|
3
|
+
import { presetUno } from '@unocss/preset-uno';
|
|
4
4
|
|
|
5
5
|
const cssVarsPrefix = "ui";
|
|
6
6
|
const cssVarsBase = ["cb", "c1", "c2", "c3"];
|
|
7
7
|
const cssVarsDynamic = ["fill", "content"];
|
|
8
8
|
const cssVarsAll = [...cssVarsBase, ...cssVarsDynamic];
|
|
9
9
|
|
|
10
|
+
const rules = [
|
|
11
|
+
[
|
|
12
|
+
new RegExp(`^${cssVarsPrefix}-([^/]+)$`),
|
|
13
|
+
([_, color], ctx) => {
|
|
14
|
+
const data = parseColor(color, ctx.theme);
|
|
15
|
+
const value = resolveRuleValue(data);
|
|
16
|
+
if (value)
|
|
17
|
+
return Object.fromEntries(cssVarsDynamic.map((prop) => [`--${cssVarsPrefix}-${prop}`, value]));
|
|
18
|
+
},
|
|
19
|
+
{ autocomplete: `${cssVarsPrefix}-$colors` }
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
new RegExp(`^${cssVarsPrefix}-(?:(${cssVarsAll.join("|")})-)([^/]+)$`),
|
|
23
|
+
([_, prop, color], ctx) => {
|
|
24
|
+
const data = parseColor(color, ctx.theme);
|
|
25
|
+
const value = resolveRuleValue(data);
|
|
26
|
+
if (value)
|
|
27
|
+
return { [`--${cssVarsPrefix}-${prop}`]: value };
|
|
28
|
+
},
|
|
29
|
+
{ autocomplete: `${cssVarsPrefix}-(${cssVarsAll.join("|")})-$colors` }
|
|
30
|
+
],
|
|
31
|
+
// overrides
|
|
32
|
+
[/^rotate-(\d+)$/, ([_, d]) => ({ rotate: `${d}deg` })]
|
|
33
|
+
];
|
|
34
|
+
function resolveRuleValue(data) {
|
|
35
|
+
if (data?.color && data.cssColor?.components) {
|
|
36
|
+
let value = data.cssColor.components.join(" ");
|
|
37
|
+
if (!/var\s*\((.+)\)(.*)/.test(data.color))
|
|
38
|
+
value += ` /* ${data.color} */`;
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
10
44
|
const theme = {
|
|
11
45
|
colors: {
|
|
12
46
|
[cssVarsPrefix]: {
|
|
@@ -36,10 +70,7 @@ const theme = {
|
|
|
36
70
|
}
|
|
37
71
|
},
|
|
38
72
|
borderRadius: {
|
|
39
|
-
[`${cssVarsPrefix}
|
|
40
|
-
[`${cssVarsPrefix}-button`]: cssVar("radius-button", cssVar("radius")),
|
|
41
|
-
[`${cssVarsPrefix}-box`]: cssVar("radius-box", cssVar("radius")),
|
|
42
|
-
[`${cssVarsPrefix}-tabs`]: cssVar("radius-tabs", cssVar("radius"))
|
|
73
|
+
...Object.fromEntries(["base", "box", "button", "checkbox", "radio", "switch", "tabs"].map((name) => [`${cssVarsPrefix}-${name}`, name === "base" ? cssVar("radius") : cssVar(`radius-${name}`, cssVar("radius"))]))
|
|
43
74
|
},
|
|
44
75
|
ringWidth: {
|
|
45
76
|
DEFAULT: "1px"
|
|
@@ -81,387 +112,11 @@ function cssColor(...rgb) {
|
|
|
81
112
|
return `rgb(${rgb.join(" ")})`;
|
|
82
113
|
}
|
|
83
114
|
|
|
84
|
-
function createMergeRules() {
|
|
85
|
-
const theme$2 = mergeDeep(theme$1, theme);
|
|
86
|
-
const directionSpacing = (type, direction = "", size = "") => {
|
|
87
|
-
if (directionSize(type)(["", direction, size], { theme: theme$2 }))
|
|
88
|
-
return directionMap[direction]?.map((v) => `${type}${v}`).join(",");
|
|
89
|
-
return null;
|
|
90
|
-
};
|
|
91
|
-
return [
|
|
92
|
-
// _rules/align
|
|
93
|
-
[
|
|
94
|
-
/^(?:vertical|align|v)-([-\w]+%?)$/,
|
|
95
|
-
() => "vertical-align"
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
|
-
/^(?:text-align|text)-(.+)$/,
|
|
99
|
-
([value]) => ["center", "left", "right", "justify", "start", "end"].includes(value) ? "text-align" : null
|
|
100
|
-
],
|
|
101
|
-
// _rules/behaviors
|
|
102
|
-
[
|
|
103
|
-
/^outline-(?:width-|size-)?(.+)$/,
|
|
104
|
-
([value]) => {
|
|
105
|
-
if (theme$2.lineWidth && value in theme$2.lineWidth)
|
|
106
|
-
return "outline-width";
|
|
107
|
-
if (h.bracket.cssvar.global.px(value))
|
|
108
|
-
return "outline-width";
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
/^outline-(?:color-)?(.+)$/,
|
|
114
|
-
([value]) => {
|
|
115
|
-
if (isCSSMathFn(h.bracket(value)))
|
|
116
|
-
return null;
|
|
117
|
-
const parsed = parseColor(value, theme$2);
|
|
118
|
-
return parsed?.color ? "outline-color" : null;
|
|
119
|
-
}
|
|
120
|
-
],
|
|
121
|
-
[
|
|
122
|
-
/^outline-offset-(.+)$/,
|
|
123
|
-
([value]) => {
|
|
124
|
-
if (theme$2.lineWidth && value in theme$2.lineWidth)
|
|
125
|
-
return "outline-offset";
|
|
126
|
-
if (h.bracket.cssvar.global.px(value))
|
|
127
|
-
return "outline-offset";
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
[
|
|
132
|
-
/^outline(?:-(.+))$/,
|
|
133
|
-
([value]) => {
|
|
134
|
-
if (!value)
|
|
135
|
-
return "outline-style";
|
|
136
|
-
if (["auto", "dashed", "dotted", "double", "hidden", "solid", "groove", "ridge", "inset", "outset", ...globalKeywords].includes(value))
|
|
137
|
-
return "outline-style";
|
|
138
|
-
if (value === "none")
|
|
139
|
-
return "outline,outline-offset";
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
// _rules/border
|
|
144
|
-
[/^(?:border|b)(?:-(.+))?$/, ([value]) => {
|
|
145
|
-
if (!value)
|
|
146
|
-
return "border-width";
|
|
147
|
-
const borderStyles = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none", "groove", "ridge", "inset", "outset", ...globalKeywords]);
|
|
148
|
-
if (borderStyles.has(value))
|
|
149
|
-
return "border-style";
|
|
150
|
-
const matched = value && value.match(/^([xyrltbse]|block|inline|[bi][se])?(?:-(.+))?$/);
|
|
151
|
-
if (matched) {
|
|
152
|
-
const [_, d = "", value2 = "1"] = matched;
|
|
153
|
-
const parsed = parseColor(value2, theme$2);
|
|
154
|
-
const size = !!(theme$2.lineWidth && value2 in theme$2.lineWidth || h.bracket.cssvar.global.px(value2));
|
|
155
|
-
const base = directionMap[d]?.map((v) => `border${v}`) ?? null;
|
|
156
|
-
if (!base)
|
|
157
|
-
return `null`;
|
|
158
|
-
if (borderStyles.has(value2))
|
|
159
|
-
return base.map((v) => `${v}-style`).join(",");
|
|
160
|
-
if (size)
|
|
161
|
-
return base.map((v) => `${v}-width`).join(",");
|
|
162
|
-
if (parsed?.color)
|
|
163
|
-
return base.map((v) => `${v}-color`).join(",");
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
}],
|
|
167
|
-
[/^(?:border-|b-)?(?:rounded|rd)(.+)$/, ([type]) => {
|
|
168
|
-
let result = "border-radius";
|
|
169
|
-
[
|
|
170
|
-
/^([xyrltbse]|block|inline|[bi][se])(?:-(.+))?$/
|
|
171
|
-
].some((r) => {
|
|
172
|
-
const matched = type.match(r);
|
|
173
|
-
if (matched) {
|
|
174
|
-
result = `border-radius-${matched[1]}`;
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
178
|
-
});
|
|
179
|
-
return result;
|
|
180
|
-
}],
|
|
181
|
-
// _rules/color
|
|
182
|
-
[/^op(?:acity)?-?(.+)$/, () => `opacity`],
|
|
183
|
-
[/^bg-(.+)$/, ([type]) => {
|
|
184
|
-
if (/^\[url\(.+\)\]$/.test(type))
|
|
185
|
-
return "image";
|
|
186
|
-
if (/^\[image:.+\]$/.test(type))
|
|
187
|
-
return "image";
|
|
188
|
-
if (/^\[(?:linear|conic|radial)-gradient\(.+\)\]$/.test(type))
|
|
189
|
-
return "image";
|
|
190
|
-
if (/^\[(?:length|size):.+\]$/.test(type))
|
|
191
|
-
return "size";
|
|
192
|
-
if (/^\[position:.+\]$/.test(type))
|
|
193
|
-
return "position";
|
|
194
|
-
if (/^op(?:acity)?-?(.+)$/.test(type))
|
|
195
|
-
return "opacity";
|
|
196
|
-
const parsed = parseColor(type, theme$2);
|
|
197
|
-
return parsed?.color ? "background-color" : null;
|
|
198
|
-
}],
|
|
199
|
-
// _rules/container
|
|
200
|
-
[/^@container(?:\/(\w+))?(?:-(normal))?$/, () => "container"],
|
|
201
|
-
// _rules/decoration
|
|
202
|
-
// _rules/default
|
|
203
|
-
// _rules/flex
|
|
204
|
-
// _rules/gap
|
|
205
|
-
[
|
|
206
|
-
/^(?:flex-|grid-)?(?:gap-?()|gap-([xy]-?|col-?|row-?))(.+)$/,
|
|
207
|
-
([direction]) => {
|
|
208
|
-
if (direction === "y" || direction === "row")
|
|
209
|
-
return "row-gap";
|
|
210
|
-
if (direction === "x" || direction === "col")
|
|
211
|
-
return "column-gap";
|
|
212
|
-
return "gap";
|
|
213
|
-
}
|
|
214
|
-
],
|
|
215
|
-
// _rules/grid
|
|
216
|
-
// _rules/layout
|
|
217
|
-
// _rules/position
|
|
218
|
-
[/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, () => "position"],
|
|
219
|
-
[/^(?:position-|pos-)([-\w]+)$/, ([value]) => globalKeywords.includes(value) ? "position" : null],
|
|
220
|
-
[/^(?:position-|pos-)?(static)$/, () => "position"],
|
|
221
|
-
// _rules/question-mark
|
|
222
|
-
// _rules/ring
|
|
223
|
-
// _rules/shadow
|
|
224
|
-
// _rules/size
|
|
225
|
-
[
|
|
226
|
-
/^size-(min-|max-)?(.+)$/,
|
|
227
|
-
([m, s]) => {
|
|
228
|
-
return getSizeValue(m, "w", theme$2, s) ? [getSizePropName(m, "w"), getSizePropName(m, "h")].join(",") : null;
|
|
229
|
-
}
|
|
230
|
-
],
|
|
231
|
-
[
|
|
232
|
-
/^(?:size-)?(min-|max-)?([wh])-?(.+)$/,
|
|
233
|
-
([m, w, s]) => {
|
|
234
|
-
return getSizeValue(m, w, theme$2, s) ? getSizePropName(m, w) : null;
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
[
|
|
238
|
-
/^(?:size-)?(min-|max-)?(block|inline)-(.+)$/,
|
|
239
|
-
([m, w, s]) => {
|
|
240
|
-
return getSizeValue(m, w, theme$2, s) ? getSizePropName(m, w) : null;
|
|
241
|
-
}
|
|
242
|
-
],
|
|
243
|
-
[
|
|
244
|
-
/^(?:size-)?(min-|max-)?(h)-screen-(.+)$/,
|
|
245
|
-
([m, h2, p]) => getSizeBreakpointValue(theme$2, p, "verticalBreakpoints") ? getSizePropName(m, h2) : null
|
|
246
|
-
],
|
|
247
|
-
[
|
|
248
|
-
/^(?:size-)?(min-|max-)?(w)-screen-(.+)$/,
|
|
249
|
-
([m, w, p]) => getSizeBreakpointValue(theme$2, p) ? getSizePropName(m, w) : null
|
|
250
|
-
],
|
|
251
|
-
[
|
|
252
|
-
/^(?:size-)?aspect-(?:ratio-)?(?:\d+\/\d+|square|video)$/,
|
|
253
|
-
() => "aspect-ratio"
|
|
254
|
-
],
|
|
255
|
-
// _rules/spacing
|
|
256
|
-
[
|
|
257
|
-
/^p-?([xyrltbse])?(?:-?(.+))?$/,
|
|
258
|
-
([direction, size]) => directionSpacing("padding", direction, size)
|
|
259
|
-
],
|
|
260
|
-
[
|
|
261
|
-
/^p-(block|inline)(?:-(.+))?$/,
|
|
262
|
-
([direction, size]) => directionSpacing("padding", direction, size)
|
|
263
|
-
],
|
|
264
|
-
[
|
|
265
|
-
/^p-?([bi][se])(?:-?(.+))?$/,
|
|
266
|
-
([direction, size]) => directionSpacing("padding", direction, size)
|
|
267
|
-
],
|
|
268
|
-
[
|
|
269
|
-
/^m-?([xyrltbse])?(?:-?(.+))?$/,
|
|
270
|
-
([direction, size]) => directionSpacing("margin", direction, size)
|
|
271
|
-
],
|
|
272
|
-
[
|
|
273
|
-
/^m-(block|inline)(?:-(.+))?$/,
|
|
274
|
-
([direction, size]) => directionSpacing("margin", direction, size)
|
|
275
|
-
],
|
|
276
|
-
[
|
|
277
|
-
/^m-?([bi][se])(?:-?(.+))?$/,
|
|
278
|
-
([direction, size]) => directionSpacing("margin", direction, size)
|
|
279
|
-
],
|
|
280
|
-
// _rules/static
|
|
281
|
-
[
|
|
282
|
-
/^(?:display-(.+)|inline|block|inline-block|contents|flow-root|list-item|hidden)$/,
|
|
283
|
-
([value]) => {
|
|
284
|
-
if (!value || globalKeywords.includes(value))
|
|
285
|
-
return "display";
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
],
|
|
289
|
-
[
|
|
290
|
-
/^(?:visible|invisible|backface-(.+))$/,
|
|
291
|
-
([value]) => value ? "backface-visibility" : "visibility"
|
|
292
|
-
],
|
|
293
|
-
[/^content-(.+)$/, () => "content"],
|
|
294
|
-
// _rules/svg
|
|
295
|
-
// _rules/transform
|
|
296
|
-
[
|
|
297
|
-
/^(?:transform-)?(origin|perspect(?:ive)?(?:-origin)?|(?:translate|rotate|skew|scale)(?:-[xyz])?)-(.+)$/,
|
|
298
|
-
([type]) => type
|
|
299
|
-
],
|
|
300
|
-
[
|
|
301
|
-
/^(?:transform-)?preserve-(?:3d|flat)$/,
|
|
302
|
-
() => "transform-style"
|
|
303
|
-
],
|
|
304
|
-
[
|
|
305
|
-
/^(?:transform)(?:-(.+))?$/,
|
|
306
|
-
([value]) => {
|
|
307
|
-
if (!value || value === "none" || globalKeywords.includes(value))
|
|
308
|
-
return "transform";
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
],
|
|
312
|
-
// _rules/transition
|
|
313
|
-
[
|
|
314
|
-
/^(?:transition-)?(?:(duration|delay|ease|property)-)(.+)$/,
|
|
315
|
-
([value]) => {
|
|
316
|
-
const mapping = {
|
|
317
|
-
duration: "transition-duration",
|
|
318
|
-
delay: "transition-delay",
|
|
319
|
-
ease: "transition-timing-function",
|
|
320
|
-
property: "transition-property"
|
|
321
|
-
};
|
|
322
|
-
return mapping[value];
|
|
323
|
-
}
|
|
324
|
-
],
|
|
325
|
-
[
|
|
326
|
-
/^transition(?:-(.+))$/,
|
|
327
|
-
([value]) => {
|
|
328
|
-
if (!value)
|
|
329
|
-
return "transition-property,transition-timing-function,transition-duration";
|
|
330
|
-
if (value === "none" || globalKeywords.includes(value))
|
|
331
|
-
return "transition";
|
|
332
|
-
if (/^discrete|normal$/.test(value))
|
|
333
|
-
return "transition-behavior";
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
],
|
|
337
|
-
// _rules/typography
|
|
338
|
-
[
|
|
339
|
-
/^text-(.+)$/,
|
|
340
|
-
([s = "base"]) => {
|
|
341
|
-
const returnValue = "font-size";
|
|
342
|
-
const split = splitShorthand(s, "length");
|
|
343
|
-
if (!split)
|
|
344
|
-
return null;
|
|
345
|
-
const [size] = split;
|
|
346
|
-
const sizePairs = toArray(theme$2.fontSize?.[size]);
|
|
347
|
-
if (sizePairs?.[0])
|
|
348
|
-
return returnValue;
|
|
349
|
-
const fontSize = h.bracketOfLength.rem(size);
|
|
350
|
-
if (fontSize)
|
|
351
|
-
return returnValue;
|
|
352
|
-
return h.bracketOfLength.rem(s) ? returnValue : null;
|
|
353
|
-
}
|
|
354
|
-
],
|
|
355
|
-
[
|
|
356
|
-
/^(?:text|font)-size-(.+)$/,
|
|
357
|
-
([s]) => {
|
|
358
|
-
const themed = toArray(theme$2.fontSize?.[s]);
|
|
359
|
-
const size = themed?.[0] ?? h.bracket.cssvar.global.rem(s);
|
|
360
|
-
return size == null ? null : "font-size";
|
|
361
|
-
}
|
|
362
|
-
],
|
|
363
|
-
[
|
|
364
|
-
/^text-(?:color-)?(.+)$/,
|
|
365
|
-
([colorOrSize]) => {
|
|
366
|
-
if (isCSSMathFn(h.bracket(colorOrSize)))
|
|
367
|
-
return "font-size";
|
|
368
|
-
const parsed = parseColor(colorOrSize, theme$2);
|
|
369
|
-
return parsed?.color ? "color" : null;
|
|
370
|
-
}
|
|
371
|
-
],
|
|
372
|
-
[
|
|
373
|
-
/^(?:color|c)-(.+)$/,
|
|
374
|
-
([color]) => {
|
|
375
|
-
const parsed = parseColor(color, theme$2);
|
|
376
|
-
return parsed?.color ? "color" : null;
|
|
377
|
-
}
|
|
378
|
-
],
|
|
379
|
-
// _rules/variables
|
|
380
|
-
[
|
|
381
|
-
/^\[(.*)\]$/,
|
|
382
|
-
([body]) => {
|
|
383
|
-
if (!body.includes(":"))
|
|
384
|
-
return null;
|
|
385
|
-
return body.split(":")[0];
|
|
386
|
-
}
|
|
387
|
-
],
|
|
388
|
-
// others
|
|
389
|
-
[
|
|
390
|
-
new RegExp(`^${cssVarsPrefix}-((?:${cssVarsAll.join("|")})-)?(.+)$`),
|
|
391
|
-
([prop, color]) => {
|
|
392
|
-
const parsed = parseColor(color, theme$2);
|
|
393
|
-
if (!parsed?.color)
|
|
394
|
-
return null;
|
|
395
|
-
return prop ? `--ui-${prop}` : "--ui-fill,--ui-content";
|
|
396
|
-
}
|
|
397
|
-
]
|
|
398
|
-
];
|
|
399
|
-
}
|
|
400
|
-
function getSizePropName(minmax, hw) {
|
|
401
|
-
const sizeMapping = {
|
|
402
|
-
h: "height",
|
|
403
|
-
w: "width",
|
|
404
|
-
inline: "inline-size",
|
|
405
|
-
block: "block-size"
|
|
406
|
-
};
|
|
407
|
-
return `${minmax || ""}${sizeMapping[hw]}`;
|
|
408
|
-
}
|
|
409
|
-
function getSizeValue(minmax, hw, theme, prop) {
|
|
410
|
-
const str = getSizePropName(minmax, hw).replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
411
|
-
const v = theme[str]?.[prop];
|
|
412
|
-
if (v != null)
|
|
413
|
-
return v;
|
|
414
|
-
switch (prop) {
|
|
415
|
-
case "fit":
|
|
416
|
-
case "max":
|
|
417
|
-
case "min":
|
|
418
|
-
return `${prop}-content`;
|
|
419
|
-
}
|
|
420
|
-
return h.bracket.cssvar.global.auto.fraction.rem(prop);
|
|
421
|
-
}
|
|
422
|
-
function getSizeBreakpointValue(theme, point, key = "breakpoints") {
|
|
423
|
-
const bp = resolveBreakpoints({ theme }, key);
|
|
424
|
-
if (bp)
|
|
425
|
-
return bp.find((i) => i.point === point)?.size;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
115
|
const preset = definePreset((options = {}) => {
|
|
429
|
-
const resolveRuleValue = (data) => {
|
|
430
|
-
if (data?.color && data.cssColor?.components) {
|
|
431
|
-
let value = data.cssColor.components.join(" ");
|
|
432
|
-
if (!/var\s*\((.+)\)(.*)/.test(data.color))
|
|
433
|
-
value += ` /* ${data.color} */`;
|
|
434
|
-
return value;
|
|
435
|
-
}
|
|
436
|
-
return null;
|
|
437
|
-
};
|
|
438
116
|
return {
|
|
439
117
|
name: "unocss-preset-ui",
|
|
440
118
|
theme,
|
|
441
|
-
rules
|
|
442
|
-
[
|
|
443
|
-
new RegExp(`^${cssVarsPrefix}-([^/]+)$`),
|
|
444
|
-
([_, color], ctx) => {
|
|
445
|
-
const data = parseColor(color, ctx.theme);
|
|
446
|
-
const value = resolveRuleValue(data);
|
|
447
|
-
if (value)
|
|
448
|
-
return Object.fromEntries(cssVarsDynamic.map((prop) => [`--${cssVarsPrefix}-${prop}`, value]));
|
|
449
|
-
},
|
|
450
|
-
{ autocomplete: `${cssVarsPrefix}-$colors` }
|
|
451
|
-
],
|
|
452
|
-
[
|
|
453
|
-
new RegExp(`^${cssVarsPrefix}-(?:(${cssVarsAll.join("|")})-)([^/]+)$`),
|
|
454
|
-
([_, prop, color], ctx) => {
|
|
455
|
-
const data = parseColor(color, ctx.theme);
|
|
456
|
-
const value = resolveRuleValue(data);
|
|
457
|
-
if (value)
|
|
458
|
-
return { [`--${cssVarsPrefix}-${prop}`]: value };
|
|
459
|
-
},
|
|
460
|
-
{ autocomplete: `${cssVarsPrefix}-(${cssVarsAll.join("|")})-$colors` }
|
|
461
|
-
],
|
|
462
|
-
// overrides
|
|
463
|
-
[/^rotate-(\d+)$/, ([_, d]) => ({ rotate: `${d}deg` })]
|
|
464
|
-
],
|
|
119
|
+
rules,
|
|
465
120
|
preflights: [
|
|
466
121
|
{ getCSS: () => createRootCSS(mergeOptions(options)) }
|
|
467
122
|
],
|
|
@@ -471,8 +126,11 @@ const preset = definePreset((options = {}) => {
|
|
|
471
126
|
function mergeOptions(options) {
|
|
472
127
|
const defaults = {
|
|
473
128
|
radius: "0rem",
|
|
474
|
-
radiusButton: "",
|
|
475
129
|
radiusBox: "",
|
|
130
|
+
radiusButton: "",
|
|
131
|
+
radiusCheckbox: "",
|
|
132
|
+
radiusRadio: "",
|
|
133
|
+
radiusSwitch: "",
|
|
476
134
|
radiusTabs: "",
|
|
477
135
|
cb: "#1f2937",
|
|
478
136
|
c1: "#ffffff",
|
|
@@ -511,4 +169,50 @@ function createRootCSS(kv) {
|
|
|
511
169
|
return css.join("");
|
|
512
170
|
}
|
|
513
171
|
|
|
514
|
-
|
|
172
|
+
const baseUnoConfig = mergeConfigs([
|
|
173
|
+
presetUno(),
|
|
174
|
+
preset()
|
|
175
|
+
]);
|
|
176
|
+
function transformUnoRules(userConfig = {}) {
|
|
177
|
+
const { rules = [], theme = {} } = mergeConfigs([baseUnoConfig, userConfig]);
|
|
178
|
+
const mergeRules = [];
|
|
179
|
+
const resolveCSSEntries = (entries) => () => entries.flatMap((value) => Object.keys(value)).join(",");
|
|
180
|
+
const resolveCSSObject = (object) => () => {
|
|
181
|
+
if (JSON.stringify(object) === "{}")
|
|
182
|
+
return null;
|
|
183
|
+
return Object.keys(object).join(",");
|
|
184
|
+
};
|
|
185
|
+
for (const rule of rules) {
|
|
186
|
+
const [maybeString, maybeResult] = rule;
|
|
187
|
+
const ruleRE = typeof maybeString === "string" ? new RegExp(`^${maybeString}$`) : maybeString;
|
|
188
|
+
if (Array.isArray(maybeResult)) {
|
|
189
|
+
mergeRules.push([ruleRE, resolveCSSEntries(maybeResult)]);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (typeof maybeResult === "object") {
|
|
193
|
+
mergeRules.push([ruleRE, resolveCSSObject(maybeResult)]);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const matcher = (matches) => {
|
|
197
|
+
try {
|
|
198
|
+
const result = maybeResult(["", ...matches], {
|
|
199
|
+
theme,
|
|
200
|
+
// @ts-expect-error pass
|
|
201
|
+
generator: { config: {} }
|
|
202
|
+
});
|
|
203
|
+
if (Array.isArray(result)) {
|
|
204
|
+
return result.filter((i) => typeof i === "object").map((i) => Array.isArray(i) ? i[0] : Object.keys(i).join(",")).join(",");
|
|
205
|
+
}
|
|
206
|
+
if (typeof result === "object")
|
|
207
|
+
return resolveCSSObject(result)();
|
|
208
|
+
} catch (e) {
|
|
209
|
+
console.warn(`[Fail Rule]`, ruleRE, e.message);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
};
|
|
213
|
+
mergeRules.push([ruleRE, matcher]);
|
|
214
|
+
}
|
|
215
|
+
return mergeRules;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { cssColor, cssVar, cssVarsAll, cssVarsBase, cssVarsDynamic, cssVarsPrefix, preset as default, preset, rules, theme, transformUnoRules };
|