@byyuurin/ui 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +32 -0
  3. package/dist/components/Accordion.vue +104 -0
  4. package/dist/components/App.vue +57 -0
  5. package/dist/components/Button.vue +94 -0
  6. package/dist/components/Card.vue +76 -0
  7. package/dist/components/Checkbox.vue +104 -0
  8. package/dist/components/Drawer.vue +133 -0
  9. package/dist/components/Input.vue +169 -0
  10. package/dist/components/Link.vue +117 -0
  11. package/dist/components/Modal.vue +145 -0
  12. package/dist/components/ModalProvider.vue +10 -0
  13. package/dist/components/Popover.vue +97 -0
  14. package/dist/components/RadioGroup.vue +180 -0
  15. package/dist/components/Select.vue +258 -0
  16. package/dist/components/Switch.vue +99 -0
  17. package/dist/components/Tabs.vue +117 -0
  18. package/dist/components/Toast.vue +126 -0
  19. package/dist/components/Toaster.vue +143 -0
  20. package/dist/components/Tooltip.vue +71 -0
  21. package/dist/components/index.d.ts +18 -0
  22. package/dist/components/index.mjs +18 -0
  23. package/dist/composables/index.d.ts +4 -0
  24. package/dist/composables/index.mjs +4 -0
  25. package/dist/composables/useComponentIcons.d.ts +26 -0
  26. package/dist/composables/useComponentIcons.mjs +24 -0
  27. package/dist/composables/useModal.d.ts +15 -0
  28. package/dist/composables/useModal.mjs +51 -0
  29. package/dist/composables/useTheme.d.ts +8 -0
  30. package/dist/composables/useTheme.mjs +18 -0
  31. package/dist/composables/useToast.d.ts +24 -0
  32. package/dist/composables/useToast.mjs +48 -0
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.mjs +3 -0
  35. package/dist/internal/constants.d.ts +3 -0
  36. package/dist/internal/constants.mjs +21 -0
  37. package/dist/internal/extend-theme.d.ts +9 -0
  38. package/dist/internal/extend-theme.mjs +16 -0
  39. package/dist/internal/extend-theme.test.d.ts +1 -0
  40. package/dist/internal/extend-theme.test.mjs +45 -0
  41. package/dist/internal/index.d.ts +4 -0
  42. package/dist/internal/index.mjs +4 -0
  43. package/dist/internal/link.d.ts +15 -0
  44. package/dist/internal/link.mjs +4 -0
  45. package/dist/internal/styler.d.ts +5 -0
  46. package/dist/internal/styler.mjs +236 -0
  47. package/dist/internal/styler.test.d.ts +1 -0
  48. package/dist/internal/styler.test.mjs +10 -0
  49. package/dist/nuxt.d.ts +10 -0
  50. package/dist/nuxt.mjs +28 -0
  51. package/dist/resolver.d.ts +10 -0
  52. package/dist/resolver.mjs +18 -0
  53. package/dist/theme/accordion.d.ts +39 -0
  54. package/dist/theme/accordion.mjs +25 -0
  55. package/dist/theme/app.d.ts +10 -0
  56. package/dist/theme/app.mjs +9 -0
  57. package/dist/theme/button.d.ts +184 -0
  58. package/dist/theme/button.mjs +140 -0
  59. package/dist/theme/card.d.ts +43 -0
  60. package/dist/theme/card.mjs +11 -0
  61. package/dist/theme/checkbox.d.ts +97 -0
  62. package/dist/theme/checkbox.mjs +53 -0
  63. package/dist/theme/drawer.d.ts +72 -0
  64. package/dist/theme/drawer.mjs +72 -0
  65. package/dist/theme/index.d.ts +17 -0
  66. package/dist/theme/index.mjs +17 -0
  67. package/dist/theme/input.d.ts +159 -0
  68. package/dist/theme/input.mjs +133 -0
  69. package/dist/theme/link.d.ts +31 -0
  70. package/dist/theme/link.mjs +23 -0
  71. package/dist/theme/modal.d.ts +50 -0
  72. package/dist/theme/modal.mjs +54 -0
  73. package/dist/theme/popover.d.ts +27 -0
  74. package/dist/theme/popover.mjs +10 -0
  75. package/dist/theme/radioGroup.d.ts +131 -0
  76. package/dist/theme/radioGroup.mjs +67 -0
  77. package/dist/theme/select.d.ts +177 -0
  78. package/dist/theme/select.mjs +154 -0
  79. package/dist/theme/switch.d.ts +131 -0
  80. package/dist/theme/switch.mjs +78 -0
  81. package/dist/theme/tabs.d.ts +101 -0
  82. package/dist/theme/tabs.mjs +117 -0
  83. package/dist/theme/toast.d.ts +51 -0
  84. package/dist/theme/toast.mjs +27 -0
  85. package/dist/theme/toaster.d.ts +73 -0
  86. package/dist/theme/toaster.mjs +89 -0
  87. package/dist/theme/tooltip.d.ts +31 -0
  88. package/dist/theme/tooltip.mjs +8 -0
  89. package/dist/types/components.d.ts +18 -0
  90. package/dist/types/components.mjs +0 -0
  91. package/dist/types/index.d.ts +7 -0
  92. package/dist/types/index.mjs +2 -0
  93. package/dist/types/utils.d.ts +29 -0
  94. package/dist/types/utils.mjs +0 -0
  95. package/dist/unocss-preset.d.ts +37 -0
  96. package/dist/unocss-preset.mjs +164 -0
  97. package/dist/utils/index.d.ts +18 -0
  98. package/dist/utils/index.mjs +70 -0
  99. package/dist/utils/unocss.d.ts +3 -0
  100. package/dist/utils/unocss.mjs +50 -0
  101. package/package.json +103 -0
@@ -0,0 +1,18 @@
1
+ import type { InjectionKey } from 'vue';
2
+ export * from './unocss';
3
+ export declare function createInjection<T>(name: string): {
4
+ injectionKey: InjectionKey<T>;
5
+ provide: (value: T) => void;
6
+ inject: () => T | undefined;
7
+ };
8
+ export declare function createInjection<T>(name: string, defaultValue: T): {
9
+ injectionKey: InjectionKey<T>;
10
+ provide: (value: T) => void;
11
+ inject: () => T;
12
+ };
13
+ export declare function pick<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Pick<Data, Keys>;
14
+ export declare function omit<Data extends object, Keys extends keyof Data>(data: Data, keys: Keys[]): Omit<Data, Keys>;
15
+ export declare function get(object: Record<string, any> | undefined, path: (string | number)[] | string, defaultValue?: any): any;
16
+ export declare function set(object: Record<string, any>, path: (string | number)[] | string, value: any): void;
17
+ export declare function looseToNumber(value: any): any;
18
+ export declare function compare<T>(value?: T, currentValue?: T, comparator?: string | ((a: T, b: T) => boolean)): boolean;
@@ -0,0 +1,70 @@
1
+ import { isEqual } from "ohash";
2
+ import { inject as vueInject, provide as vueProvide } from "vue";
3
+ export * from "./unocss.mjs";
4
+ export function createInjection(name, defaultValue) {
5
+ const injectionKey = Symbol(name);
6
+ const provide = (value) => vueProvide(injectionKey, value);
7
+ const inject = () => vueInject(injectionKey, defaultValue);
8
+ return {
9
+ injectionKey,
10
+ provide,
11
+ inject
12
+ };
13
+ }
14
+ export function pick(data, keys) {
15
+ const result = {};
16
+ for (const key of keys)
17
+ result[key] = data[key];
18
+ return result;
19
+ }
20
+ export function omit(data, keys) {
21
+ const result = { ...data };
22
+ for (const key of keys)
23
+ delete result[key];
24
+ return result;
25
+ }
26
+ export function get(object, path, defaultValue) {
27
+ if (typeof path === "string") {
28
+ path = path.split(".").map((key) => {
29
+ const numKey = Number(key);
30
+ return Number.isNaN(numKey) ? key : numKey;
31
+ });
32
+ }
33
+ let result = object;
34
+ for (const key of path) {
35
+ if (result === void 0 || result === null)
36
+ return defaultValue;
37
+ result = result[key];
38
+ }
39
+ return result === void 0 ? defaultValue : result;
40
+ }
41
+ export function set(object, path, value) {
42
+ if (typeof path === "string") {
43
+ path = path.split(".").map((key) => {
44
+ const numKey = Number(key);
45
+ return Number.isNaN(numKey) ? key : numKey;
46
+ });
47
+ }
48
+ path.reduce((acc, key, i) => {
49
+ if (acc[key] === void 0)
50
+ acc[key] = {};
51
+ if (i === path.length - 1)
52
+ acc[key] = value;
53
+ return acc[key];
54
+ }, object);
55
+ }
56
+ export function looseToNumber(value) {
57
+ const n = Number.parseFloat(value);
58
+ return Number.isNaN(n) ? value : n;
59
+ }
60
+ export function compare(value, currentValue, comparator) {
61
+ if (value === void 0 || currentValue === void 0)
62
+ return false;
63
+ if (typeof value === "string")
64
+ return value === currentValue;
65
+ if (typeof comparator === "function")
66
+ return comparator(value, currentValue);
67
+ if (typeof comparator === "string")
68
+ return get(value, comparator) === get(currentValue, comparator);
69
+ return isEqual(value, currentValue);
70
+ }
@@ -0,0 +1,3 @@
1
+ import type { CRRule } from '@byyuurin/ui-kit';
2
+ import type { ConfigBase } from '@unocss/core';
3
+ export declare function transformUnoRules<Theme extends object = object>(config?: ConfigBase<Theme>): CRRule[];
@@ -0,0 +1,50 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@byyuurin/ui",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "",
6
+ "author": "Yuurin <byyuurin@gmail.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/byyuurin/ui#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/byyuurin/ui.git"
12
+ },
13
+ "bugs": "https://github.com/byyuurin/ui/issues",
14
+ "keywords": [],
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs"
20
+ },
21
+ "./resolver": {
22
+ "types": "./dist/resolver.d.ts",
23
+ "import": "./dist/resolver.mjs"
24
+ },
25
+ "./nuxt": {
26
+ "types": "./dist/nuxt.d.ts",
27
+ "import": "./dist/nuxt.mjs"
28
+ },
29
+ "./unocss-preset": {
30
+ "types": "./dist/unocss-preset.d.ts",
31
+ "import": "./dist/unocss-preset.mjs"
32
+ }
33
+ },
34
+ "main": "./dist/index.mjs",
35
+ "module": "./dist/index.mjs",
36
+ "types": "./dist/index.d.ts",
37
+ "typesVersions": {
38
+ "*": {
39
+ "*": [
40
+ "./dist/*",
41
+ "./dist/index.d.ts"
42
+ ]
43
+ }
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "peerDependencies": {
49
+ "vue": "^3.5.13"
50
+ },
51
+ "dependencies": {
52
+ "@byyuurin/ui-kit": "^0.3.3",
53
+ "@unocss/core": "^65.4.3",
54
+ "@unocss/preset-mini": "^65.4.3",
55
+ "@unocss/preset-uno": "^65.4.3",
56
+ "@vueuse/core": "^12.5.0",
57
+ "defu": "^6.1.4",
58
+ "nuxt": "^3.15.3",
59
+ "ohash": "^1.1.4",
60
+ "reka-ui": "1.0.0-alpha.8",
61
+ "vaul-vue": "^0.2.0",
62
+ "vue-component-type-helpers": "^2.2.0"
63
+ },
64
+ "devDependencies": {
65
+ "@antfu/ni": "^23.3.0",
66
+ "@byyuurin/eslint-config": "^1.7.0",
67
+ "@nuxt/kit": "^3.15.3",
68
+ "@nuxt/schema": "^3.15.3",
69
+ "@types/node": "^22.12.0",
70
+ "bumpp": "^9.11.1",
71
+ "eslint": "^9.19.0",
72
+ "eslint-plugin-format": "1.0.1",
73
+ "esno": "^4.8.0",
74
+ "lint-staged": "^15.4.3",
75
+ "simple-git-hooks": "^2.11.1",
76
+ "typescript": "^5.7.3",
77
+ "unbuild": "^3.3.1",
78
+ "unplugin-vue-components": "^28.0.0",
79
+ "vitest": "^2.1.8",
80
+ "vue": "^3.5.13",
81
+ "vue-tsc": "^2.2.0"
82
+ },
83
+ "resolutions": {
84
+ "mkdist": "^1.6.0"
85
+ },
86
+ "simple-git-hooks": {
87
+ "pre-commit": "pnpm lint-staged"
88
+ },
89
+ "lint-staged": {
90
+ "*": "eslint --fix"
91
+ },
92
+ "scripts": {
93
+ "build": "unbuild",
94
+ "stub": "unbuild --stub",
95
+ "dev:vue": "pnpm --filter \"./playground/vue\" run dev",
96
+ "dev:nuxt": "pnpm --filter \"./playground/nuxt\" run dev",
97
+ "lint": "eslint .",
98
+ "release": "bumpp && pnpm publish",
99
+ "start": "esno src/index.ts",
100
+ "test": "vitest",
101
+ "typecheck": "tsc --noEmit"
102
+ }
103
+ }