@byyuurin/ui 0.0.2 → 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 +76 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/nuxt.d.mts +13 -0
- package/dist/nuxt.d.ts +6 -3
- package/dist/nuxt.mjs +6 -3
- package/dist/resolver.d.mts +13 -0
- package/dist/resolver.d.ts +6 -3
- package/dist/resolver.mjs +5 -2
- package/dist/{components → runtime/components}/Accordion.vue +19 -3
- package/dist/{components → runtime/components}/App.vue +5 -1
- package/dist/{components → runtime/components}/Button.vue +92 -94
- package/dist/{components → runtime/components}/Checkbox.vue +101 -104
- package/dist/{components → runtime/components}/Input.vue +5 -1
- package/dist/{components → runtime/components}/ModalProvider.vue +1 -1
- package/dist/{components → runtime/components}/RadioGroup.vue +174 -180
- package/dist/runtime/components/ScrollArea.vue +72 -0
- package/dist/{components → runtime/components}/Select.vue +262 -258
- package/dist/{components → runtime/components}/Switch.vue +98 -99
- package/dist/{components → runtime/components}/Tabs.vue +117 -117
- package/dist/runtime/components/Textarea.vue +173 -0
- package/dist/{components → runtime/components}/Toast.vue +1 -1
- package/dist/{components → runtime/components}/Toaster.vue +35 -1
- package/dist/{components → runtime/components}/index.d.ts +2 -0
- package/dist/{components → 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/{composables → runtime/composables}/index.d.ts +1 -0
- package/dist/{composables → runtime/composables}/index.mjs +1 -0
- package/dist/{composables → runtime/composables}/useModal.d.ts +1 -1
- package/dist/{composables → runtime/composables}/useModal.mjs +3 -2
- package/dist/{composables → runtime/composables}/useTheme.d.ts +3 -2
- package/dist/runtime/composables/useTheme.mjs +26 -0
- package/dist/{composables → runtime/composables}/useToast.d.ts +1 -1
- package/dist/{theme → runtime/theme}/button.d.ts +0 -8
- package/dist/{theme → runtime/theme}/button.mjs +1 -9
- package/dist/{theme → runtime/theme}/checkbox.d.ts +0 -12
- package/dist/{theme → runtime/theme}/checkbox.mjs +4 -9
- package/dist/{theme → runtime/theme}/index.d.ts +2 -0
- package/dist/{theme → runtime/theme}/index.mjs +2 -0
- package/dist/{theme → runtime/theme}/radioGroup.d.ts +0 -24
- package/dist/{theme → 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/{theme → runtime/theme}/switch.d.ts +0 -12
- package/dist/{theme → runtime/theme}/switch.mjs +2 -8
- package/dist/{theme → runtime/theme}/tabs.d.ts +32 -11
- package/dist/{theme → 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/{theme → runtime/theme}/toast.mjs +1 -1
- package/dist/{types → runtime/types}/components.d.ts +2 -0
- package/dist/{types → runtime/types}/index.d.ts +1 -1
- package/dist/{utils → runtime/utils}/index.d.ts +3 -12
- package/dist/{utils → runtime/utils}/index.mjs +3 -12
- package/dist/{internal → runtime/utils}/styler.d.ts +0 -1
- package/dist/runtime/utils/styler.mjs +10 -0
- package/dist/{internal/constants.mjs → shared/ui.Cmq14xN9.mjs} +6 -2
- package/dist/unocss-preset.d.mts +57 -0
- package/dist/unocss-preset.d.ts +29 -9
- package/dist/unocss-preset.mjs +164 -110
- package/package.json +18 -12
- package/dist/composables/useTheme.mjs +0 -18
- package/dist/internal/constants.d.ts +0 -3
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.mjs +0 -4
- package/dist/internal/styler.mjs +0 -236
- package/dist/utils/unocss.d.ts +0 -3
- package/dist/utils/unocss.mjs +0 -50
- /package/dist/{components → runtime/components}/Card.vue +0 -0
- /package/dist/{components → runtime/components}/Drawer.vue +0 -0
- /package/dist/{components → runtime/components}/Link.vue +0 -0
- /package/dist/{components → runtime/components}/Modal.vue +0 -0
- /package/dist/{components → runtime/components}/Popover.vue +0 -0
- /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.mjs +0 -0
- /package/dist/{composables → runtime/composables}/useToast.mjs +0 -0
- /package/dist/{theme → runtime/theme}/accordion.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/accordion.mjs +0 -0
- /package/dist/{theme → runtime/theme}/app.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/app.mjs +0 -0
- /package/dist/{theme → runtime/theme}/card.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/card.mjs +0 -0
- /package/dist/{theme → runtime/theme}/drawer.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/drawer.mjs +0 -0
- /package/dist/{theme → runtime/theme}/input.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/input.mjs +0 -0
- /package/dist/{theme → runtime/theme}/link.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/link.mjs +0 -0
- /package/dist/{theme → runtime/theme}/modal.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/modal.mjs +0 -0
- /package/dist/{theme → runtime/theme}/popover.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/popover.mjs +0 -0
- /package/dist/{theme → runtime/theme}/select.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/select.mjs +0 -0
- /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toaster.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toaster.mjs +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.mjs +0 -0
- /package/dist/{types → runtime/types}/components.mjs +0 -0
- /package/dist/{types → runtime/types}/index.mjs +0 -0
- /package/dist/{types → runtime/types}/utils.d.ts +0 -0
- /package/dist/{types → runtime/types}/utils.mjs +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.mjs +0 -0
- /package/dist/{internal → runtime/utils}/link.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/link.mjs +0 -0
package/dist/unocss-preset.mjs
CHANGED
|
@@ -1,113 +1,122 @@
|
|
|
1
|
-
import { definePreset } from
|
|
2
|
-
import { parseColor, parseCssColor } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
}
|
|
1
|
+
import { definePreset, mergeConfigs } from '@unocss/core';
|
|
2
|
+
import { parseColor, parseCssColor } from '@unocss/preset-mini/utils';
|
|
3
|
+
import { presetUno } from '@unocss/preset-uno';
|
|
4
|
+
|
|
5
|
+
const cssVarsPrefix = "ui";
|
|
6
|
+
const cssVarsBase = ["cb", "c1", "c2", "c3"];
|
|
7
|
+
const cssVarsDynamic = ["fill", "content"];
|
|
8
|
+
const cssVarsAll = [...cssVarsBase, ...cssVarsDynamic];
|
|
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]));
|
|
30
18
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
}
|
|
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 };
|
|
49
28
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
|
|
44
|
+
const theme = {
|
|
45
|
+
colors: {
|
|
46
|
+
[cssVarsPrefix]: {
|
|
47
|
+
cb: cssColor(cssVar("cb")),
|
|
48
|
+
c: {
|
|
49
|
+
1: cssColor(cssVar("c1")),
|
|
50
|
+
2: cssColor(cssVar("c2")),
|
|
51
|
+
3: cssColor(cssVar("c3"))
|
|
52
|
+
},
|
|
53
|
+
fill: cssColor(cssVar("fill", cssVar("cb"))),
|
|
54
|
+
content: cssColor(cssVar("content", cssVar("cb")))
|
|
73
55
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!/var\s*\((.+)\)(.*)/.test(data.color))
|
|
79
|
-
value += ` /* ${data.color} */`;
|
|
80
|
-
return value;
|
|
56
|
+
},
|
|
57
|
+
backgroundColor: {
|
|
58
|
+
[cssVarsPrefix]: {
|
|
59
|
+
base: cssColor(cssVar("fill", cssVar("c1")))
|
|
81
60
|
}
|
|
82
|
-
|
|
83
|
-
|
|
61
|
+
},
|
|
62
|
+
textColor: {
|
|
63
|
+
[cssVarsPrefix]: {
|
|
64
|
+
base: cssColor(cssVar("content", cssVar("cb")))
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
borderColor: {
|
|
68
|
+
[cssVarsPrefix]: {
|
|
69
|
+
base: cssColor(cssVar("fill", cssVar("cb")))
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
borderRadius: {
|
|
73
|
+
...Object.fromEntries(["base", "box", "button", "checkbox", "radio", "switch", "tabs"].map((name) => [`${cssVarsPrefix}-${name}`, name === "base" ? cssVar("radius") : cssVar(`radius-${name}`, cssVar("radius"))]))
|
|
74
|
+
},
|
|
75
|
+
ringWidth: {
|
|
76
|
+
DEFAULT: "1px"
|
|
77
|
+
},
|
|
78
|
+
shadowColor: {
|
|
79
|
+
[cssVarsPrefix]: {
|
|
80
|
+
base: cssColor(cssVar("fill", cssVar("cb")))
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
animation: {
|
|
84
|
+
keyframes: {
|
|
85
|
+
"fade-in": "{from {opacity: 0;}to {opacity: 1;}}",
|
|
86
|
+
"fade-out": "{from {opacity: 1;}to {opacity: 0;}}",
|
|
87
|
+
"scale-in": "{from {opacity: 0;scale: 0.95;}to {opacity: 1;scale: 1;}}",
|
|
88
|
+
"scale-out": "{from {opacity: 1;scale: 1;}to {opacity: 0;scale: 0.95;}}",
|
|
89
|
+
"slide-in-from-top": "{from {transform: translateY(-100%);}to {transform: translateY(0);}}",
|
|
90
|
+
"slide-out-to-top": "{from {transform: translateY(0);}to {transform: translateY(-100%);}}",
|
|
91
|
+
"slide-in-from-right": "{from {transform: translateX(100%);}to {transform: translateX(0);}}",
|
|
92
|
+
"slide-out-to-right": "{from {transform: translateX(0);}to {transform: translateX(100%);}}",
|
|
93
|
+
"slide-in-from-bottom": "{from {transform: translateY(100%);}to {transform: translateY(0);}}",
|
|
94
|
+
"slide-out-to-bottom": "{from {transform: translateY(0);}to {transform: translateY(100%);}}",
|
|
95
|
+
"slide-in-from-left": "{from {transform: translateX(-100%);}to {transform: translateX(0);}}",
|
|
96
|
+
"slide-out-to-left": "{from {transform: translateX(0);}to {transform: translateX(-100%);}}",
|
|
97
|
+
"slide-in-from-top-and-fade": "{from {opacity: 0;transform: translateY(-4px);}to {opacity: 1;transform: translateY(0);}}",
|
|
98
|
+
"slide-out-to-top-and-fade": "{from {opacity: 1;transform: translateY(0);}to {opacity: 0;transform: translateY(-4px);}}",
|
|
99
|
+
"slide-in-from-right-and-fade": "{from {opacity: 0;transform: translateX(4px);}to {opacity: 1;transform: translateX(0);}}",
|
|
100
|
+
"slide-out-to-right-and-fade": "{from {opacity: 1;transform: translateX(0);}to {opacity: 0;transform: translateX(4px);}}",
|
|
101
|
+
"slide-in-from-bottom-and-fade": "{from {opacity: 0;transform: translateY(4px);}to {opacity: 1;transform: translateY(0);}}",
|
|
102
|
+
"slide-out-to-bottom-and-fade": "{from {opacity: 1;transform: translateY(0);}to {opacity: 0;transform: translateY(4px);}}",
|
|
103
|
+
"slide-in-from-left-and-fade": "{from {opacity: 0;transform: translateX(-4px);}to {opacity: 1;transform: translateX(0);}}",
|
|
104
|
+
"slide-out-to-left-and-fade": "{from {opacity: 1;transform: translateX(0);}to {opacity: 0;transform: translateX(-4px);}}"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function cssVar(name, ...defaultValue) {
|
|
109
|
+
return `var(${[`--${cssVarsPrefix}-${name}`, ...defaultValue].join(",")})`;
|
|
110
|
+
}
|
|
111
|
+
function cssColor(...rgb) {
|
|
112
|
+
return `rgb(${rgb.join(" ")})`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const preset = definePreset((options = {}) => {
|
|
84
116
|
return {
|
|
85
117
|
name: "unocss-preset-ui",
|
|
86
118
|
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
|
-
],
|
|
119
|
+
rules,
|
|
111
120
|
preflights: [
|
|
112
121
|
{ getCSS: () => createRootCSS(mergeOptions(options)) }
|
|
113
122
|
],
|
|
@@ -117,8 +126,11 @@ export default definePreset((options = {}) => {
|
|
|
117
126
|
function mergeOptions(options) {
|
|
118
127
|
const defaults = {
|
|
119
128
|
radius: "0rem",
|
|
120
|
-
radiusButton: "",
|
|
121
129
|
radiusBox: "",
|
|
130
|
+
radiusButton: "",
|
|
131
|
+
radiusCheckbox: "",
|
|
132
|
+
radiusRadio: "",
|
|
133
|
+
radiusSwitch: "",
|
|
122
134
|
radiusTabs: "",
|
|
123
135
|
cb: "#1f2937",
|
|
124
136
|
c1: "#ffffff",
|
|
@@ -130,12 +142,6 @@ function mergeOptions(options) {
|
|
|
130
142
|
...options
|
|
131
143
|
};
|
|
132
144
|
}
|
|
133
|
-
function cssVar(name, ...defaultValue) {
|
|
134
|
-
return `var(${[`--${cssVarsPrefix}-${name}`, ...defaultValue].join(",")})`;
|
|
135
|
-
}
|
|
136
|
-
function cssColor(...rgb) {
|
|
137
|
-
return `rgb(${rgb.join(" ")})`;
|
|
138
|
-
}
|
|
139
145
|
function createRootCSS(kv) {
|
|
140
146
|
const kebabCase = (input) => input.replace(/([A-Z][^A-Z]*)/g, "-$1").replace(/^-/, "").toLowerCase();
|
|
141
147
|
const join = (input) => input.map((item) => item.endsWith(";") ? item : `${item};`).join("");
|
|
@@ -162,3 +168,51 @@ function createRootCSS(kv) {
|
|
|
162
168
|
];
|
|
163
169
|
return css.join("");
|
|
164
170
|
}
|
|
171
|
+
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byyuurin/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Yuurin <byyuurin@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -16,24 +16,29 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
|
-
"
|
|
19
|
+
"default": "./dist/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./index": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
20
24
|
},
|
|
21
25
|
"./resolver": {
|
|
22
26
|
"types": "./dist/resolver.d.ts",
|
|
23
|
-
"
|
|
27
|
+
"default": "./dist/resolver.mjs"
|
|
24
28
|
},
|
|
25
29
|
"./nuxt": {
|
|
26
30
|
"types": "./dist/nuxt.d.ts",
|
|
27
|
-
"
|
|
31
|
+
"default": "./dist/nuxt.mjs"
|
|
28
32
|
},
|
|
29
33
|
"./unocss-preset": {
|
|
30
34
|
"types": "./dist/unocss-preset.d.ts",
|
|
31
|
-
"
|
|
32
|
-
}
|
|
35
|
+
"default": "./dist/unocss-preset.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./*": "./dist/*"
|
|
33
38
|
},
|
|
34
|
-
"main": "
|
|
35
|
-
"module": "
|
|
36
|
-
"types": "
|
|
39
|
+
"main": "dist/index.mjs",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
37
42
|
"typesVersions": {
|
|
38
43
|
"*": {
|
|
39
44
|
"*": [
|
|
@@ -43,6 +48,7 @@
|
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"files": [
|
|
51
|
+
"*.d.ts",
|
|
46
52
|
"dist"
|
|
47
53
|
],
|
|
48
54
|
"peerDependencies": {
|
|
@@ -56,7 +62,7 @@
|
|
|
56
62
|
}
|
|
57
63
|
},
|
|
58
64
|
"dependencies": {
|
|
59
|
-
"@byyuurin/ui-kit": "^0.3.
|
|
65
|
+
"@byyuurin/ui-kit": "^0.3.5",
|
|
60
66
|
"@nuxt/kit": "^3.15.4",
|
|
61
67
|
"@unocss/core": "^65.4.3",
|
|
62
68
|
"@unocss/preset-mini": "^65.4.3",
|
|
@@ -72,7 +78,7 @@
|
|
|
72
78
|
"@antfu/ni": "^23.3.1",
|
|
73
79
|
"@byyuurin/eslint-config": "^1.7.0",
|
|
74
80
|
"@nuxt/schema": "^3.15.4",
|
|
75
|
-
"@types/node": "^22.13.
|
|
81
|
+
"@types/node": "^22.13.1",
|
|
76
82
|
"bumpp": "^10.0.1",
|
|
77
83
|
"eslint": "^9.19.0",
|
|
78
84
|
"eslint-plugin-format": "1.0.1",
|
|
@@ -82,7 +88,7 @@
|
|
|
82
88
|
"typescript": "^5.7.3",
|
|
83
89
|
"unbuild": "^3.3.1",
|
|
84
90
|
"unplugin-vue-components": "^28.0.0",
|
|
85
|
-
"vitest": "^3.0.
|
|
91
|
+
"vitest": "^3.0.5",
|
|
86
92
|
"vue": "^3.5.13",
|
|
87
93
|
"vue-tsc": "^2.2.0"
|
|
88
94
|
},
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createSharedComposable } from "@vueuse/core";
|
|
2
|
-
import { computed, toValue } from "vue";
|
|
3
|
-
import { createMergeRules, extendTheme, prepareStyler } from "../internal/index.mjs";
|
|
4
|
-
import * as theme from "../theme/index.mjs";
|
|
5
|
-
import { createInjection } from "../utils/index.mjs";
|
|
6
|
-
export const {
|
|
7
|
-
provide: provideThemeExtension,
|
|
8
|
-
inject: injectThemeExtension
|
|
9
|
-
} = createInjection("ui.themeExtension", {});
|
|
10
|
-
export const mergeRules = createMergeRules();
|
|
11
|
-
export const useTheme = createSharedComposable(() => {
|
|
12
|
-
const _theme = injectThemeExtension();
|
|
13
|
-
const { createStyler } = prepareStyler(mergeRules);
|
|
14
|
-
return {
|
|
15
|
-
theme: computed(() => extendTheme(toValue(_theme), theme)),
|
|
16
|
-
createStyler
|
|
17
|
-
};
|
|
18
|
-
});
|
package/dist/internal/index.d.ts
DELETED
package/dist/internal/index.mjs
DELETED
package/dist/internal/styler.mjs
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { cv } from "@byyuurin/ui-kit";
|
|
2
|
-
import { mergeConfigs, toArray } from "@unocss/core";
|
|
3
|
-
import { h, isCSSMathFn, parseColor, splitShorthand } from "@unocss/preset-mini/utils";
|
|
4
|
-
import { presetUno } from "@unocss/preset-uno";
|
|
5
|
-
import presetUI, { cssVarsAll, cssVarsPrefix } from "../unocss-preset.mjs";
|
|
6
|
-
const theme = mergeConfigs([
|
|
7
|
-
presetUno(),
|
|
8
|
-
presetUI()
|
|
9
|
-
]).theme;
|
|
10
|
-
export function createMergeRules() {
|
|
11
|
-
const GlobalKeywordsRE = /^inherit|initial|revert|revert-layer|unset$/;
|
|
12
|
-
return [
|
|
13
|
-
// _rules/align
|
|
14
|
-
[/^(?:vertical|align|v)-([-\w]+%?)$/, ([type]) => {
|
|
15
|
-
const valid = [
|
|
16
|
-
GlobalKeywordsRE,
|
|
17
|
-
/^(mid(?:dle)?|base(?:line)?|btm|bottom|top|start|bottom|end|text-(?:top|bottom)|sub|super)$/
|
|
18
|
-
].some((r) => r.test(type));
|
|
19
|
-
return valid ? "vertical-align" : null;
|
|
20
|
-
}],
|
|
21
|
-
[/^text-?(?:align-?)?(.+)$/, ([type]) => {
|
|
22
|
-
const valid = [
|
|
23
|
-
GlobalKeywordsRE,
|
|
24
|
-
/^center|left|right|justify|start|end$/
|
|
25
|
-
].some((r) => r.test(type));
|
|
26
|
-
return valid ? "text-align" : null;
|
|
27
|
-
}],
|
|
28
|
-
// _rules/behaviors
|
|
29
|
-
// _rules/border
|
|
30
|
-
[/^(?:border-|b-)(.+)$/, ([type]) => {
|
|
31
|
-
let result = "border";
|
|
32
|
-
[
|
|
33
|
-
/^([xyrltbse]|block|inline|[bi][se])(?:-(.+))?$/
|
|
34
|
-
].some((r) => {
|
|
35
|
-
const matched = type.match(r);
|
|
36
|
-
if (matched) {
|
|
37
|
-
const [_, type2, color = ""] = matched;
|
|
38
|
-
const parsed2 = parseColor(color, theme);
|
|
39
|
-
result = parsed2?.color ? `border-${type2}-color` : `border-${type2}`;
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
});
|
|
44
|
-
const parsed = parseColor(type, theme);
|
|
45
|
-
return parsed?.color ? "border-color" : result;
|
|
46
|
-
}],
|
|
47
|
-
[/^(?:border-|b-)?(?:rounded|rd)(.+)$/, ([type]) => {
|
|
48
|
-
let result = "border-radius";
|
|
49
|
-
[
|
|
50
|
-
/^([xyrltbse]|block|inline|[bi][se])(?:-(.+))?$/
|
|
51
|
-
].some((r) => {
|
|
52
|
-
const matched = type.match(r);
|
|
53
|
-
if (matched) {
|
|
54
|
-
result = `border-radius-${matched[1]}`;
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
});
|
|
59
|
-
return result;
|
|
60
|
-
}],
|
|
61
|
-
// _rules/color
|
|
62
|
-
[/^op(?:acity)?-?(.+)$/, () => `opacity`],
|
|
63
|
-
[/^bg-(.+)$/, ([type]) => {
|
|
64
|
-
if (/^\[url\(.+\)\]$/.test(type))
|
|
65
|
-
return "image";
|
|
66
|
-
if (/^\[image:.+\]$/.test(type))
|
|
67
|
-
return "image";
|
|
68
|
-
if (/^\[(?:linear|conic|radial)-gradient\(.+\)\]$/.test(type))
|
|
69
|
-
return "image";
|
|
70
|
-
if (/^\[(?:length|size):.+\]$/.test(type))
|
|
71
|
-
return "size";
|
|
72
|
-
if (/^\[position:.+\]$/.test(type))
|
|
73
|
-
return "position";
|
|
74
|
-
if (/^op(?:acity)?-?(.+)$/.test(type))
|
|
75
|
-
return "opacity";
|
|
76
|
-
const parsed = parseColor(type, theme);
|
|
77
|
-
return parsed?.color ? "color" : null;
|
|
78
|
-
}, { scope: "bg" }],
|
|
79
|
-
// _rules/container
|
|
80
|
-
[/^@container(?:\/(\w+))?(?:-(normal))?$/, () => "container"],
|
|
81
|
-
// _rules/decoration
|
|
82
|
-
// _rules/default
|
|
83
|
-
// _rules/flex
|
|
84
|
-
// [/^$/, () => ''],
|
|
85
|
-
// _rules/gap
|
|
86
|
-
[
|
|
87
|
-
/^(?:flex-|grid-)?(?:gap-?()|gap-([xy]-?|col-?|row-?))(.+)$/,
|
|
88
|
-
([direction]) => {
|
|
89
|
-
if (direction === "y" || direction === "row")
|
|
90
|
-
return "gap-row";
|
|
91
|
-
if (direction === "x" || direction === "col")
|
|
92
|
-
return "gap-column";
|
|
93
|
-
return "gap";
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
// _rules/grid
|
|
97
|
-
// _rules/layout
|
|
98
|
-
// _rules/position
|
|
99
|
-
[/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, () => "position"],
|
|
100
|
-
[/^(?:position-|pos-)([-\w]+)$/, ([type]) => GlobalKeywordsRE.test(type) ? "position" : null],
|
|
101
|
-
[/^(?:position-|pos-)?(static)$/, () => "position"],
|
|
102
|
-
// _rules/question-mark
|
|
103
|
-
// _rules/ring
|
|
104
|
-
// _rules/shadow
|
|
105
|
-
// _rules/size
|
|
106
|
-
// _rules/spacing
|
|
107
|
-
[/^p-?([xy])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
|
|
108
|
-
[/^p-?([rltbse])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
|
|
109
|
-
[/^p-(block|inline)(?:-(.+))?$/, ([type]) => `padding-${type}`],
|
|
110
|
-
[/^p-?([bi][se])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
|
|
111
|
-
// [/^pa?()-?(.+)$/, () => 'padding'],
|
|
112
|
-
// [/^p-?xy()()$/, () => 'padding'],
|
|
113
|
-
[/^m-?([xy])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
|
|
114
|
-
[/^m-?([rltbse])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
|
|
115
|
-
[/^m-(block|inline)(?:-(.+))?$/, ([type]) => `margin-${type}`],
|
|
116
|
-
[/^m-?([bi][se])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
|
|
117
|
-
// [/^ma?()-?(.+)$/, () => 'margin'],
|
|
118
|
-
// [/^m-?xy()()$/, () => 'margin'],
|
|
119
|
-
// _rules/static
|
|
120
|
-
[
|
|
121
|
-
/^(?:display-(.+)|inline|block|inline-block|contents|flow-root|list-item|hidden)$/,
|
|
122
|
-
([type]) => {
|
|
123
|
-
if (!type || GlobalKeywordsRE.test(type))
|
|
124
|
-
return "display";
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
/^(?:visible|invisible|backface-(.+))$/,
|
|
130
|
-
([type]) => {
|
|
131
|
-
if (!type || GlobalKeywordsRE.test(type) || /^(?:visible|hidden)$/.test(type))
|
|
132
|
-
return "visibility";
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
],
|
|
136
|
-
[/^content-(.+)$/, () => "content"],
|
|
137
|
-
// _rules/svg
|
|
138
|
-
// _rules/transform
|
|
139
|
-
[
|
|
140
|
-
/^(?:transform-)?(origin|perspect(?:ive)?(?:-origin)?|(?:translate|rotate|skew|scale)(?:-[xyz])?)-(.+)$/,
|
|
141
|
-
([type]) => type
|
|
142
|
-
],
|
|
143
|
-
[
|
|
144
|
-
/^(?:transform-)?preserve-(?:3d|flat)$/,
|
|
145
|
-
() => "preserve"
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
/^(?:transform)(?:-(.+))?$/,
|
|
149
|
-
([type]) => {
|
|
150
|
-
if (!type || type === "none" || GlobalKeywordsRE.test(type))
|
|
151
|
-
return "transform";
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
// _rules/transition
|
|
156
|
-
[/^(?:transition-)?(?:(duration|delay|ease|property)-)(.+)$/, ([type]) => type],
|
|
157
|
-
[/^transition(?:-(.+))$/, ([type]) => {
|
|
158
|
-
if (!type || type === "none" || GlobalKeywordsRE.test(type))
|
|
159
|
-
return "transition";
|
|
160
|
-
if (/^discrete|normal$/.test(type))
|
|
161
|
-
return "transition-behavior";
|
|
162
|
-
return null;
|
|
163
|
-
}],
|
|
164
|
-
// _rules/typography
|
|
165
|
-
[
|
|
166
|
-
/^text-(.+)$/,
|
|
167
|
-
([s = "base"]) => {
|
|
168
|
-
const returnValue = "font-size";
|
|
169
|
-
const split = splitShorthand(s, "length");
|
|
170
|
-
if (!split)
|
|
171
|
-
return null;
|
|
172
|
-
const [size] = split;
|
|
173
|
-
const sizePairs = toArray(theme.fontSize?.[size]);
|
|
174
|
-
if (sizePairs?.[0])
|
|
175
|
-
return returnValue;
|
|
176
|
-
const fontSize = h.bracketOfLength.rem(size);
|
|
177
|
-
if (fontSize)
|
|
178
|
-
return returnValue;
|
|
179
|
-
return h.bracketOfLength.rem(s) ? returnValue : null;
|
|
180
|
-
}
|
|
181
|
-
],
|
|
182
|
-
[
|
|
183
|
-
/^(?:text|font)-size-(.+)$/,
|
|
184
|
-
([s]) => {
|
|
185
|
-
const themed = toArray(theme.fontSize?.[s]);
|
|
186
|
-
const size = themed?.[0] ?? h.bracket.cssvar.global.rem(s);
|
|
187
|
-
return size == null ? null : "font-size";
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
[
|
|
191
|
-
/^text-(?:color-)?(.+)$/,
|
|
192
|
-
([colorOrSize]) => {
|
|
193
|
-
if (isCSSMathFn(h.bracket(colorOrSize)))
|
|
194
|
-
return "font-size";
|
|
195
|
-
const parsed = parseColor(colorOrSize, theme);
|
|
196
|
-
return parsed?.color ? "color" : null;
|
|
197
|
-
}
|
|
198
|
-
],
|
|
199
|
-
[
|
|
200
|
-
/^(?:color|c)-(.+)$/,
|
|
201
|
-
([color]) => {
|
|
202
|
-
const parsed = parseColor(color, theme);
|
|
203
|
-
return parsed?.color ? "color" : null;
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
// _rules/variables
|
|
207
|
-
[
|
|
208
|
-
/^\[(.*)\]$/,
|
|
209
|
-
([body]) => {
|
|
210
|
-
if (!body.includes(":"))
|
|
211
|
-
return null;
|
|
212
|
-
const [prop] = body.split(":");
|
|
213
|
-
return prop;
|
|
214
|
-
},
|
|
215
|
-
{ scope: "variables" }
|
|
216
|
-
],
|
|
217
|
-
// others
|
|
218
|
-
[
|
|
219
|
-
new RegExp(`^${cssVarsPrefix}-((?:${cssVarsAll.join("|")})-)?(.+)$`),
|
|
220
|
-
([type = "base", color]) => {
|
|
221
|
-
const parsed = parseColor(color, theme);
|
|
222
|
-
return parsed?.color ? type : null;
|
|
223
|
-
},
|
|
224
|
-
{ scope: cssVarsPrefix }
|
|
225
|
-
]
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
export function prepareStyler(rules = []) {
|
|
229
|
-
const createVariants = cv(rules);
|
|
230
|
-
function createStyler(theme2) {
|
|
231
|
-
const ui = createVariants(theme2);
|
|
232
|
-
const styler = (props) => ui(props);
|
|
233
|
-
return styler;
|
|
234
|
-
}
|
|
235
|
-
return { createStyler };
|
|
236
|
-
}
|
package/dist/utils/unocss.d.ts
DELETED