@byyuurin/ui 0.0.1 → 0.0.3

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 (136) hide show
  1. package/README.md +75 -5
  2. package/dist/index.cjs +38 -0
  3. package/dist/index.d.ts +3 -3
  4. package/dist/index.mjs +3 -3
  5. package/dist/nuxt.d.mts +13 -0
  6. package/dist/nuxt.d.ts +6 -3
  7. package/dist/nuxt.mjs +6 -3
  8. package/dist/resolver.d.mts +13 -0
  9. package/dist/resolver.d.ts +6 -3
  10. package/dist/resolver.mjs +5 -2
  11. package/dist/{components → runtime/components}/Accordion.vue +19 -3
  12. package/dist/{components → runtime/components}/Button.vue +93 -94
  13. package/dist/{components → runtime/components}/Checkbox.vue +104 -104
  14. package/dist/{components → runtime/components}/RadioGroup.vue +180 -180
  15. package/dist/{components → runtime/components}/Select.vue +262 -258
  16. package/dist/{components → runtime/components}/Switch.vue +99 -99
  17. package/dist/{components → runtime/components}/Tabs.vue +117 -117
  18. package/dist/{components → runtime/components}/Toaster.vue +35 -1
  19. package/dist/runtime/components/index.cjs +132 -0
  20. package/dist/runtime/composables/index.cjs +33 -0
  21. package/dist/runtime/composables/useComponentIcons.cjs +30 -0
  22. package/dist/runtime/composables/useModal.cjs +55 -0
  23. package/dist/runtime/composables/useTheme.cjs +30 -0
  24. package/dist/{composables → runtime/composables}/useTheme.d.ts +0 -1
  25. package/dist/{composables → runtime/composables}/useTheme.mjs +3 -3
  26. package/dist/runtime/composables/useToast.cjs +51 -0
  27. package/dist/{composables → runtime/composables}/useToast.d.ts +1 -1
  28. package/dist/runtime/theme/accordion.cjs +27 -0
  29. package/dist/runtime/theme/app.cjs +15 -0
  30. package/dist/runtime/theme/button.cjs +127 -0
  31. package/dist/runtime/theme/card.cjs +17 -0
  32. package/dist/runtime/theme/checkbox.cjs +56 -0
  33. package/dist/runtime/theme/drawer.cjs +73 -0
  34. package/dist/runtime/theme/index.cjs +125 -0
  35. package/dist/runtime/theme/input.cjs +115 -0
  36. package/dist/runtime/theme/link.cjs +23 -0
  37. package/dist/runtime/theme/modal.cjs +55 -0
  38. package/dist/runtime/theme/popover.cjs +13 -0
  39. package/dist/runtime/theme/radioGroup.cjs +73 -0
  40. package/dist/runtime/theme/select.cjs +128 -0
  41. package/dist/runtime/theme/switch.cjs +73 -0
  42. package/dist/runtime/theme/tabs.cjs +105 -0
  43. package/dist/runtime/theme/toast.cjs +33 -0
  44. package/dist/runtime/theme/toaster.cjs +72 -0
  45. package/dist/runtime/theme/tooltip.cjs +14 -0
  46. package/dist/runtime/types/components.cjs +1 -0
  47. package/dist/runtime/types/index.cjs +27 -0
  48. package/dist/{types → runtime/types}/index.d.ts +1 -1
  49. package/dist/runtime/types/utils.cjs +1 -0
  50. package/dist/runtime/utils/extend-theme.cjs +24 -0
  51. package/dist/runtime/utils/index.cjs +119 -0
  52. package/dist/{utils → runtime/utils}/index.d.ts +3 -1
  53. package/dist/{utils → runtime/utils}/index.mjs +3 -1
  54. package/dist/runtime/utils/link.cjs +10 -0
  55. package/dist/runtime/utils/styler.cjs +18 -0
  56. package/dist/{internal → runtime/utils}/styler.d.ts +0 -1
  57. package/dist/runtime/utils/styler.mjs +10 -0
  58. package/dist/{internal/constants.mjs → shared/ui.CPXA9QoM.mjs} +4 -2
  59. package/dist/unocss-preset.d.mts +49 -0
  60. package/dist/unocss-preset.d.ts +20 -8
  61. package/dist/unocss-preset.mjs +428 -78
  62. package/package.json +16 -10
  63. package/dist/internal/constants.d.ts +0 -3
  64. package/dist/internal/extend-theme.test.d.ts +0 -1
  65. package/dist/internal/extend-theme.test.mjs +0 -45
  66. package/dist/internal/index.d.ts +0 -4
  67. package/dist/internal/index.mjs +0 -4
  68. package/dist/internal/styler.mjs +0 -235
  69. package/dist/internal/styler.test.d.ts +0 -1
  70. package/dist/internal/styler.test.mjs +0 -10
  71. package/dist/utils/unocss.d.ts +0 -3
  72. package/dist/utils/unocss.mjs +0 -50
  73. /package/dist/{components → runtime/components}/App.vue +0 -0
  74. /package/dist/{components → runtime/components}/Card.vue +0 -0
  75. /package/dist/{components → runtime/components}/Drawer.vue +0 -0
  76. /package/dist/{components → runtime/components}/Input.vue +0 -0
  77. /package/dist/{components → runtime/components}/Link.vue +0 -0
  78. /package/dist/{components → runtime/components}/Modal.vue +0 -0
  79. /package/dist/{components → runtime/components}/ModalProvider.vue +0 -0
  80. /package/dist/{components → runtime/components}/Popover.vue +0 -0
  81. /package/dist/{components → runtime/components}/Toast.vue +0 -0
  82. /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
  83. /package/dist/{components → runtime/components}/index.d.ts +0 -0
  84. /package/dist/{components → runtime/components}/index.mjs +0 -0
  85. /package/dist/{composables → runtime/composables}/index.d.ts +0 -0
  86. /package/dist/{composables → runtime/composables}/index.mjs +0 -0
  87. /package/dist/{composables → runtime/composables}/useComponentIcons.d.ts +0 -0
  88. /package/dist/{composables → runtime/composables}/useComponentIcons.mjs +0 -0
  89. /package/dist/{composables → runtime/composables}/useModal.d.ts +0 -0
  90. /package/dist/{composables → runtime/composables}/useModal.mjs +0 -0
  91. /package/dist/{composables → runtime/composables}/useToast.mjs +0 -0
  92. /package/dist/{theme → runtime/theme}/accordion.d.ts +0 -0
  93. /package/dist/{theme → runtime/theme}/accordion.mjs +0 -0
  94. /package/dist/{theme → runtime/theme}/app.d.ts +0 -0
  95. /package/dist/{theme → runtime/theme}/app.mjs +0 -0
  96. /package/dist/{theme → runtime/theme}/button.d.ts +0 -0
  97. /package/dist/{theme → runtime/theme}/button.mjs +0 -0
  98. /package/dist/{theme → runtime/theme}/card.d.ts +0 -0
  99. /package/dist/{theme → runtime/theme}/card.mjs +0 -0
  100. /package/dist/{theme → runtime/theme}/checkbox.d.ts +0 -0
  101. /package/dist/{theme → runtime/theme}/checkbox.mjs +0 -0
  102. /package/dist/{theme → runtime/theme}/drawer.d.ts +0 -0
  103. /package/dist/{theme → runtime/theme}/drawer.mjs +0 -0
  104. /package/dist/{theme → runtime/theme}/index.d.ts +0 -0
  105. /package/dist/{theme → runtime/theme}/index.mjs +0 -0
  106. /package/dist/{theme → runtime/theme}/input.d.ts +0 -0
  107. /package/dist/{theme → runtime/theme}/input.mjs +0 -0
  108. /package/dist/{theme → runtime/theme}/link.d.ts +0 -0
  109. /package/dist/{theme → runtime/theme}/link.mjs +0 -0
  110. /package/dist/{theme → runtime/theme}/modal.d.ts +0 -0
  111. /package/dist/{theme → runtime/theme}/modal.mjs +0 -0
  112. /package/dist/{theme → runtime/theme}/popover.d.ts +0 -0
  113. /package/dist/{theme → runtime/theme}/popover.mjs +0 -0
  114. /package/dist/{theme → runtime/theme}/radioGroup.d.ts +0 -0
  115. /package/dist/{theme → runtime/theme}/radioGroup.mjs +0 -0
  116. /package/dist/{theme → runtime/theme}/select.d.ts +0 -0
  117. /package/dist/{theme → runtime/theme}/select.mjs +0 -0
  118. /package/dist/{theme → runtime/theme}/switch.d.ts +0 -0
  119. /package/dist/{theme → runtime/theme}/switch.mjs +0 -0
  120. /package/dist/{theme → runtime/theme}/tabs.d.ts +0 -0
  121. /package/dist/{theme → runtime/theme}/tabs.mjs +0 -0
  122. /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
  123. /package/dist/{theme → runtime/theme}/toast.mjs +0 -0
  124. /package/dist/{theme → runtime/theme}/toaster.d.ts +0 -0
  125. /package/dist/{theme → runtime/theme}/toaster.mjs +0 -0
  126. /package/dist/{theme → runtime/theme}/tooltip.d.ts +0 -0
  127. /package/dist/{theme → runtime/theme}/tooltip.mjs +0 -0
  128. /package/dist/{types → runtime/types}/components.d.ts +0 -0
  129. /package/dist/{types → runtime/types}/components.mjs +0 -0
  130. /package/dist/{types → runtime/types}/index.mjs +0 -0
  131. /package/dist/{types → runtime/types}/utils.d.ts +0 -0
  132. /package/dist/{types → runtime/types}/utils.mjs +0 -0
  133. /package/dist/{internal → runtime/utils}/extend-theme.d.ts +0 -0
  134. /package/dist/{internal → runtime/utils}/extend-theme.mjs +0 -0
  135. /package/dist/{internal → runtime/utils}/link.d.ts +0 -0
  136. /package/dist/{internal → runtime/utils}/link.mjs +0 -0
@@ -1,235 +0,0 @@
1
- import { cv } from "@byyuurin/ui-kit";
2
- import { h, isCSSMathFn, parseColor, splitShorthand } from "@unocss/preset-mini/utils";
3
- import { mergeConfigs, presetUno, toArray } from "unocss";
4
- import presetUI, { cssVarsAll, cssVarsPrefix } from "../unocss-preset.mjs";
5
- const theme = mergeConfigs([
6
- presetUno(),
7
- presetUI()
8
- ]).theme;
9
- export function createMergeRules() {
10
- const GlobalKeywordsRE = /^inherit|initial|revert|revert-layer|unset$/;
11
- return [
12
- // _rules/align
13
- [/^(?:vertical|align|v)-([-\w]+%?)$/, ([type]) => {
14
- const valid = [
15
- GlobalKeywordsRE,
16
- /^(mid(?:dle)?|base(?:line)?|btm|bottom|top|start|bottom|end|text-(?:top|bottom)|sub|super)$/
17
- ].some((r) => r.test(type));
18
- return valid ? "vertical-align" : null;
19
- }],
20
- [/^text-?(?:align-?)?(.+)$/, ([type]) => {
21
- const valid = [
22
- GlobalKeywordsRE,
23
- /^center|left|right|justify|start|end$/
24
- ].some((r) => r.test(type));
25
- return valid ? "text-align" : null;
26
- }],
27
- // _rules/behaviors
28
- // _rules/border
29
- [/^(?:border-|b-)(.+)$/, ([type]) => {
30
- let result = "border";
31
- [
32
- /^([xyrltbse]|block|inline|[bi][se])(?:-(.+))?$/
33
- ].some((r) => {
34
- const matched = type.match(r);
35
- if (matched) {
36
- const [_, type2, color = ""] = matched;
37
- const parsed2 = parseColor(color, theme);
38
- result = parsed2?.color ? `border-${type2}-color` : `border-${type2}`;
39
- return true;
40
- }
41
- return false;
42
- });
43
- const parsed = parseColor(type, theme);
44
- return parsed?.color ? "border-color" : result;
45
- }],
46
- [/^(?:border-|b-)?(?:rounded|rd)(.+)$/, ([type]) => {
47
- let result = "border-radius";
48
- [
49
- /^([xyrltbse]|block|inline|[bi][se])(?:-(.+))?$/
50
- ].some((r) => {
51
- const matched = type.match(r);
52
- if (matched) {
53
- result = `border-radius-${matched[1]}`;
54
- return true;
55
- }
56
- return false;
57
- });
58
- return result;
59
- }],
60
- // _rules/color
61
- [/^op(?:acity)?-?(.+)$/, () => `opacity`],
62
- [/^bg-(.+)$/, ([type]) => {
63
- if (/^\[url\(.+\)\]$/.test(type))
64
- return "image";
65
- if (/^\[image:.+\]$/.test(type))
66
- return "image";
67
- if (/^\[(?:linear|conic|radial)-gradient\(.+\)\]$/.test(type))
68
- return "image";
69
- if (/^\[(?:length|size):.+\]$/.test(type))
70
- return "size";
71
- if (/^\[position:.+\]$/.test(type))
72
- return "position";
73
- if (/^op(?:acity)?-?(.+)$/.test(type))
74
- return "opacity";
75
- const parsed = parseColor(type, theme);
76
- return parsed?.color ? "color" : null;
77
- }, { scope: "bg" }],
78
- // _rules/container
79
- [/^@container(?:\/(\w+))?(?:-(normal))?$/, () => "container"],
80
- // _rules/decoration
81
- // _rules/default
82
- // _rules/flex
83
- // [/^$/, () => ''],
84
- // _rules/gap
85
- [
86
- /^(?:flex-|grid-)?(?:gap-?()|gap-([xy]-?|col-?|row-?))(.+)$/,
87
- ([direction]) => {
88
- if (direction === "y" || direction === "row")
89
- return "gap-row";
90
- if (direction === "x" || direction === "col")
91
- return "gap-column";
92
- return "gap";
93
- }
94
- ],
95
- // _rules/grid
96
- // _rules/layout
97
- // _rules/position
98
- [/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, () => "position"],
99
- [/^(?:position-|pos-)([-\w]+)$/, ([type]) => GlobalKeywordsRE.test(type) ? "position" : null],
100
- [/^(?:position-|pos-)?(static)$/, () => "position"],
101
- // _rules/question-mark
102
- // _rules/ring
103
- // _rules/shadow
104
- // _rules/size
105
- // _rules/spacing
106
- [/^p-?([xy])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
107
- [/^p-?([rltbse])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
108
- [/^p-(block|inline)(?:-(.+))?$/, ([type]) => `padding-${type}`],
109
- [/^p-?([bi][se])(?:-?(.+))?$/, ([type]) => `padding-${type}`],
110
- // [/^pa?()-?(.+)$/, () => 'padding'],
111
- // [/^p-?xy()()$/, () => 'padding'],
112
- [/^m-?([xy])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
113
- [/^m-?([rltbse])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
114
- [/^m-(block|inline)(?:-(.+))?$/, ([type]) => `margin-${type}`],
115
- [/^m-?([bi][se])(?:-?(.+))?$/, ([type]) => `margin-${type}`],
116
- // [/^ma?()-?(.+)$/, () => 'margin'],
117
- // [/^m-?xy()()$/, () => 'margin'],
118
- // _rules/static
119
- [
120
- /^(?:display-(.+)|inline|block|inline-block|contents|flow-root|list-item|hidden)$/,
121
- ([type]) => {
122
- if (!type || GlobalKeywordsRE.test(type))
123
- return "display";
124
- return null;
125
- }
126
- ],
127
- [
128
- /^(?:visible|invisible|backface-(.+))$/,
129
- ([type]) => {
130
- if (!type || GlobalKeywordsRE.test(type) || /^(?:visible|hidden)$/.test(type))
131
- return "visibility";
132
- return null;
133
- }
134
- ],
135
- [/^content-(.+)$/, () => "content"],
136
- // _rules/svg
137
- // _rules/transform
138
- [
139
- /^(?:transform-)?(origin|perspect(?:ive)?(?:-origin)?|(?:translate|rotate|skew|scale)(?:-[xyz])?)-(.+)$/,
140
- ([type]) => type
141
- ],
142
- [
143
- /^(?:transform-)?preserve-(?:3d|flat)$/,
144
- () => "preserve"
145
- ],
146
- [
147
- /^(?:transform)(?:-(.+))?$/,
148
- ([type]) => {
149
- if (!type || type === "none" || GlobalKeywordsRE.test(type))
150
- return "transform";
151
- return null;
152
- }
153
- ],
154
- // _rules/transition
155
- [/^(?:transition-)?(?:(duration|delay|ease|property)-)(.+)$/, ([type]) => type],
156
- [/^transition(?:-(.+))$/, ([type]) => {
157
- if (!type || type === "none" || GlobalKeywordsRE.test(type))
158
- return "transition";
159
- if (/^discrete|normal$/.test(type))
160
- return "transition-behavior";
161
- return null;
162
- }],
163
- // _rules/typography
164
- [
165
- /^text-(.+)$/,
166
- ([s = "base"]) => {
167
- const returnValue = "font-size";
168
- const split = splitShorthand(s, "length");
169
- if (!split)
170
- return null;
171
- const [size] = split;
172
- const sizePairs = toArray(theme.fontSize?.[size]);
173
- if (sizePairs?.[0])
174
- return returnValue;
175
- const fontSize = h.bracketOfLength.rem(size);
176
- if (fontSize)
177
- return returnValue;
178
- return h.bracketOfLength.rem(s) ? returnValue : null;
179
- }
180
- ],
181
- [
182
- /^(?:text|font)-size-(.+)$/,
183
- ([s]) => {
184
- const themed = toArray(theme.fontSize?.[s]);
185
- const size = themed?.[0] ?? h.bracket.cssvar.global.rem(s);
186
- return size == null ? null : "font-size";
187
- }
188
- ],
189
- [
190
- /^text-(?:color-)?(.+)$/,
191
- ([colorOrSize]) => {
192
- if (isCSSMathFn(h.bracket(colorOrSize)))
193
- return "font-size";
194
- const parsed = parseColor(colorOrSize, theme);
195
- return parsed?.color ? "color" : null;
196
- }
197
- ],
198
- [
199
- /^(?:color|c)-(.+)$/,
200
- ([color]) => {
201
- const parsed = parseColor(color, theme);
202
- return parsed?.color ? "color" : null;
203
- }
204
- ],
205
- // _rules/variables
206
- [
207
- /^\[(.*)\]$/,
208
- ([body]) => {
209
- if (!body.includes(":"))
210
- return null;
211
- const [prop] = body.split(":");
212
- return prop;
213
- },
214
- { scope: "variables" }
215
- ],
216
- // others
217
- [
218
- new RegExp(`^${cssVarsPrefix}-((?:${cssVarsAll.join("|")})-)?(.+)$`),
219
- ([type = "base", color]) => {
220
- const parsed = parseColor(color, theme);
221
- return parsed?.color ? type : null;
222
- },
223
- { scope: cssVarsPrefix }
224
- ]
225
- ];
226
- }
227
- export function prepareStyler(rules = []) {
228
- const createVariants = cv(rules);
229
- function createStyler(theme2) {
230
- const ui = createVariants(theme2);
231
- const styler = (props) => ui(props);
232
- return styler;
233
- }
234
- return { createStyler };
235
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { cr } from "@byyuurin/ui-kit";
2
- import { describe, expect, it } from "vitest";
3
- import { mergeRules } from "../composables/useTheme.mjs";
4
- describe("check style merge", () => {
5
- const merge = cr(mergeRules, { debug: true });
6
- it("should...", () => {
7
- const result = merge("grid gap-10 grid-cols-10 scale-1 translate-y-full");
8
- expect(result).toMatchInlineSnapshot(`"grid gap grid-cols-10 scale translate-y"`);
9
- });
10
- });
@@ -1,3 +0,0 @@
1
- import type { CRRule } from '@byyuurin/ui-kit';
2
- import type { ConfigBase } from 'unocss';
3
- export declare function transformUnoRules<Theme extends object = object>(config?: ConfigBase<Theme>): CRRule[];
@@ -1,50 +0,0 @@
1
- export function transformUnoRules(config = {}) {
2
- const { rules = [], theme = {} } = config;
3
- const mergeRules = [];
4
- const wrap = (value, skip = false) => skip ? value : `[${value}]`;
5
- const resolveCSSEntries = (entries, skipWrap = false) => () => wrap(
6
- entries.flatMap((value) => Object.keys(value)).join(","),
7
- skipWrap
8
- );
9
- const resolveCSSObject = (object, skipWrap = false) => () => {
10
- if (JSON.stringify(object) === "{}")
11
- return null;
12
- return wrap(
13
- Object.keys(object).join(","),
14
- skipWrap
15
- );
16
- };
17
- for (const rule of rules) {
18
- const [maybeString, maybeResult] = rule;
19
- const ruleRE = typeof maybeString === "string" ? new RegExp(`^${maybeString}$`) : maybeString;
20
- if (Array.isArray(maybeResult)) {
21
- mergeRules.push([ruleRE, resolveCSSEntries(maybeResult)]);
22
- continue;
23
- }
24
- if (typeof maybeResult === "object") {
25
- mergeRules.push([ruleRE, resolveCSSObject(maybeResult)]);
26
- continue;
27
- }
28
- const matcher = (matches, ctx) => {
29
- try {
30
- const result = maybeResult([ctx.input, ...matches], {
31
- theme,
32
- // @ts-expect-error pass
33
- generator: { config: {} }
34
- });
35
- if (typeof result === "function")
36
- return null;
37
- if (Array.isArray(result)) {
38
- return wrap(result.map((item) => Array.isArray(item) ? item[0] : resolveCSSObject(item, false)).join(","));
39
- }
40
- if (typeof result === "object")
41
- return resolveCSSObject(result)();
42
- } catch (e) {
43
- console.warn(`[Fail Rule]`, ruleRE, e.message);
44
- }
45
- return null;
46
- };
47
- mergeRules.push([ruleRE, matcher]);
48
- }
49
- return mergeRules;
50
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes