@byyuurin/ui 0.0.2 → 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 (132) 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 +15 -10
  63. package/dist/internal/constants.d.ts +0 -3
  64. package/dist/internal/index.d.ts +0 -4
  65. package/dist/internal/index.mjs +0 -4
  66. package/dist/internal/styler.mjs +0 -236
  67. package/dist/utils/unocss.d.ts +0 -3
  68. package/dist/utils/unocss.mjs +0 -50
  69. /package/dist/{components → runtime/components}/App.vue +0 -0
  70. /package/dist/{components → runtime/components}/Card.vue +0 -0
  71. /package/dist/{components → runtime/components}/Drawer.vue +0 -0
  72. /package/dist/{components → runtime/components}/Input.vue +0 -0
  73. /package/dist/{components → runtime/components}/Link.vue +0 -0
  74. /package/dist/{components → runtime/components}/Modal.vue +0 -0
  75. /package/dist/{components → runtime/components}/ModalProvider.vue +0 -0
  76. /package/dist/{components → runtime/components}/Popover.vue +0 -0
  77. /package/dist/{components → runtime/components}/Toast.vue +0 -0
  78. /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
  79. /package/dist/{components → runtime/components}/index.d.ts +0 -0
  80. /package/dist/{components → runtime/components}/index.mjs +0 -0
  81. /package/dist/{composables → runtime/composables}/index.d.ts +0 -0
  82. /package/dist/{composables → runtime/composables}/index.mjs +0 -0
  83. /package/dist/{composables → runtime/composables}/useComponentIcons.d.ts +0 -0
  84. /package/dist/{composables → runtime/composables}/useComponentIcons.mjs +0 -0
  85. /package/dist/{composables → runtime/composables}/useModal.d.ts +0 -0
  86. /package/dist/{composables → runtime/composables}/useModal.mjs +0 -0
  87. /package/dist/{composables → runtime/composables}/useToast.mjs +0 -0
  88. /package/dist/{theme → runtime/theme}/accordion.d.ts +0 -0
  89. /package/dist/{theme → runtime/theme}/accordion.mjs +0 -0
  90. /package/dist/{theme → runtime/theme}/app.d.ts +0 -0
  91. /package/dist/{theme → runtime/theme}/app.mjs +0 -0
  92. /package/dist/{theme → runtime/theme}/button.d.ts +0 -0
  93. /package/dist/{theme → runtime/theme}/button.mjs +0 -0
  94. /package/dist/{theme → runtime/theme}/card.d.ts +0 -0
  95. /package/dist/{theme → runtime/theme}/card.mjs +0 -0
  96. /package/dist/{theme → runtime/theme}/checkbox.d.ts +0 -0
  97. /package/dist/{theme → runtime/theme}/checkbox.mjs +0 -0
  98. /package/dist/{theme → runtime/theme}/drawer.d.ts +0 -0
  99. /package/dist/{theme → runtime/theme}/drawer.mjs +0 -0
  100. /package/dist/{theme → runtime/theme}/index.d.ts +0 -0
  101. /package/dist/{theme → runtime/theme}/index.mjs +0 -0
  102. /package/dist/{theme → runtime/theme}/input.d.ts +0 -0
  103. /package/dist/{theme → runtime/theme}/input.mjs +0 -0
  104. /package/dist/{theme → runtime/theme}/link.d.ts +0 -0
  105. /package/dist/{theme → runtime/theme}/link.mjs +0 -0
  106. /package/dist/{theme → runtime/theme}/modal.d.ts +0 -0
  107. /package/dist/{theme → runtime/theme}/modal.mjs +0 -0
  108. /package/dist/{theme → runtime/theme}/popover.d.ts +0 -0
  109. /package/dist/{theme → runtime/theme}/popover.mjs +0 -0
  110. /package/dist/{theme → runtime/theme}/radioGroup.d.ts +0 -0
  111. /package/dist/{theme → runtime/theme}/radioGroup.mjs +0 -0
  112. /package/dist/{theme → runtime/theme}/select.d.ts +0 -0
  113. /package/dist/{theme → runtime/theme}/select.mjs +0 -0
  114. /package/dist/{theme → runtime/theme}/switch.d.ts +0 -0
  115. /package/dist/{theme → runtime/theme}/switch.mjs +0 -0
  116. /package/dist/{theme → runtime/theme}/tabs.d.ts +0 -0
  117. /package/dist/{theme → runtime/theme}/tabs.mjs +0 -0
  118. /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
  119. /package/dist/{theme → runtime/theme}/toast.mjs +0 -0
  120. /package/dist/{theme → runtime/theme}/toaster.d.ts +0 -0
  121. /package/dist/{theme → runtime/theme}/toaster.mjs +0 -0
  122. /package/dist/{theme → runtime/theme}/tooltip.d.ts +0 -0
  123. /package/dist/{theme → runtime/theme}/tooltip.mjs +0 -0
  124. /package/dist/{types → runtime/types}/components.d.ts +0 -0
  125. /package/dist/{types → runtime/types}/components.mjs +0 -0
  126. /package/dist/{types → runtime/types}/index.mjs +0 -0
  127. /package/dist/{types → runtime/types}/utils.d.ts +0 -0
  128. /package/dist/{types → runtime/types}/utils.mjs +0 -0
  129. /package/dist/{internal → runtime/utils}/extend-theme.d.ts +0 -0
  130. /package/dist/{internal → runtime/utils}/extend-theme.mjs +0 -0
  131. /package/dist/{internal → runtime/utils}/link.d.ts +0 -0
  132. /package/dist/{internal → runtime/utils}/link.mjs +0 -0
@@ -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
- }
@@ -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