@byyuurin/ui 0.0.10 → 0.1.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 (289) hide show
  1. package/README.md +170 -58
  2. package/dist/module.d.mts +4 -13
  3. package/dist/module.json +4 -4
  4. package/dist/module.mjs +54 -20
  5. package/dist/runtime/components/Accordion.vue +48 -72
  6. package/dist/runtime/components/Accordion.vue.d.ts +74 -0
  7. package/dist/runtime/components/Alert.vue +65 -83
  8. package/dist/runtime/components/Alert.vue.d.ts +71 -0
  9. package/dist/runtime/components/App.vue +28 -42
  10. package/dist/runtime/components/App.vue.d.ts +26 -0
  11. package/dist/runtime/components/Avatar.vue +82 -58
  12. package/dist/runtime/components/Avatar.vue.d.ts +39 -0
  13. package/dist/runtime/components/AvatarGroup.vue +43 -70
  14. package/dist/runtime/components/AvatarGroup.vue.d.ts +30 -0
  15. package/dist/runtime/components/Badge.vue +70 -64
  16. package/dist/runtime/components/Badge.vue.d.ts +45 -0
  17. package/dist/runtime/components/Breadcrumb.vue +56 -76
  18. package/dist/runtime/components/Breadcrumb.vue.d.ts +79 -0
  19. package/dist/runtime/components/Button.vue +150 -78
  20. package/dist/runtime/components/Button.vue.d.ts +45 -0
  21. package/dist/runtime/components/Calendar.vue +99 -125
  22. package/dist/runtime/components/Calendar.vue.d.ts +102 -0
  23. package/dist/runtime/components/Card.vue +33 -46
  24. package/dist/runtime/components/Card.vue.d.ts +34 -0
  25. package/dist/runtime/components/Carousel.vue +164 -237
  26. package/dist/runtime/components/Carousel.vue.d.ts +125 -0
  27. package/dist/runtime/components/Checkbox.vue +86 -88
  28. package/dist/runtime/components/Checkbox.vue.d.ts +63 -0
  29. package/dist/runtime/components/Chip.vue +44 -58
  30. package/dist/runtime/components/Chip.vue.d.ts +48 -0
  31. package/dist/runtime/components/Collapsible.vue +29 -33
  32. package/dist/runtime/components/Collapsible.vue.d.ts +34 -0
  33. package/dist/runtime/components/Drawer.vue +110 -150
  34. package/dist/runtime/components/Drawer.vue.d.ts +103 -0
  35. package/dist/runtime/components/DropdownMenu.vue +49 -120
  36. package/dist/runtime/components/DropdownMenu.vue.d.ts +140 -0
  37. package/dist/runtime/components/DropdownMenuContent.vue +177 -143
  38. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +51 -0
  39. package/dist/runtime/components/FieldGroup.vue +33 -0
  40. package/dist/runtime/components/FieldGroup.vue.d.ts +33 -0
  41. package/dist/runtime/components/Form.vue +245 -275
  42. package/dist/runtime/components/Form.vue.d.ts +103 -0
  43. package/dist/runtime/components/FormField.vue +108 -0
  44. package/dist/runtime/components/FormField.vue.d.ts +63 -0
  45. package/dist/runtime/components/Icon.vue +20 -0
  46. package/dist/runtime/components/Icon.vue.d.ts +9 -0
  47. package/dist/runtime/components/Input.vue +125 -156
  48. package/dist/runtime/components/Input.vue.d.ts +76 -0
  49. package/dist/runtime/components/InputNumber.vue +103 -130
  50. package/dist/runtime/components/InputNumber.vue.d.ts +191 -0
  51. package/dist/runtime/components/Kbd.vue +24 -39
  52. package/dist/runtime/components/Kbd.vue.d.ts +34 -0
  53. package/dist/runtime/components/Link.vue +105 -337
  54. package/dist/runtime/components/Link.vue.d.ts +95 -0
  55. package/dist/runtime/components/LinkBase.vue +31 -71
  56. package/dist/runtime/components/LinkBase.vue.d.ts +33 -0
  57. package/dist/runtime/components/Modal.vue +82 -103
  58. package/dist/runtime/components/Modal.vue.d.ts +96 -0
  59. package/dist/runtime/components/NavigationMenu.vue +336 -0
  60. package/dist/runtime/components/NavigationMenu.vue.d.ts +181 -0
  61. package/dist/runtime/components/OverlayProvider.vue +12 -16
  62. package/dist/runtime/components/OverlayProvider.vue.d.ts +3 -0
  63. package/dist/runtime/components/Pagination.vue +65 -139
  64. package/dist/runtime/components/Pagination.vue.d.ts +116 -0
  65. package/dist/runtime/components/PinInput.vue +78 -73
  66. package/dist/runtime/components/PinInput.vue.d.ts +54 -0
  67. package/dist/runtime/components/Popover.vue +60 -75
  68. package/dist/runtime/components/Popover.vue.d.ts +70 -0
  69. package/dist/runtime/components/Progress.vue +79 -126
  70. package/dist/runtime/components/Progress.vue.d.ts +63 -0
  71. package/dist/runtime/components/RadioGroup.vue +109 -140
  72. package/dist/runtime/components/RadioGroup.vue.d.ts +96 -0
  73. package/dist/runtime/components/ScrollArea.vue +50 -48
  74. package/dist/runtime/components/ScrollArea.vue.d.ts +21 -0
  75. package/dist/runtime/components/Select.vue +221 -221
  76. package/dist/runtime/components/Select.vue.d.ts +260 -0
  77. package/dist/runtime/components/Separator.vue +55 -47
  78. package/dist/runtime/components/Separator.vue.d.ts +48 -0
  79. package/dist/runtime/components/Skeleton.vue +25 -22
  80. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  81. package/dist/runtime/components/Slider.vue +73 -77
  82. package/dist/runtime/components/Slider.vue.d.ts +52 -0
  83. package/dist/runtime/components/Switch.vue +66 -77
  84. package/dist/runtime/components/Switch.vue.d.ts +58 -0
  85. package/dist/runtime/components/Table.vue +357 -215
  86. package/dist/runtime/components/Table.vue.d.ts +234 -0
  87. package/dist/runtime/components/Tabs.vue +90 -88
  88. package/dist/runtime/components/Tabs.vue.d.ts +97 -0
  89. package/dist/runtime/components/Textarea.vue +147 -146
  90. package/dist/runtime/components/Textarea.vue.d.ts +76 -0
  91. package/dist/runtime/components/Toast.vue +108 -90
  92. package/dist/runtime/components/Toast.vue.d.ts +152 -0
  93. package/dist/runtime/components/ToastProvider.vue +82 -109
  94. package/dist/runtime/components/ToastProvider.vue.d.ts +51 -0
  95. package/dist/runtime/components/Tooltip.vue +54 -53
  96. package/dist/runtime/components/Tooltip.vue.d.ts +53 -0
  97. package/dist/runtime/composables/defineShortcuts.d.ts +16 -0
  98. package/dist/runtime/composables/defineShortcuts.js +129 -0
  99. package/dist/runtime/composables/useAvatarGroup.d.ts +8 -3
  100. package/dist/runtime/composables/useAvatarGroup.js +10 -3
  101. package/dist/runtime/composables/useComponentIcons.d.ts +9 -6
  102. package/dist/runtime/composables/useComponentIcons.js +4 -4
  103. package/dist/runtime/composables/useFieldGroup.d.ts +8 -0
  104. package/dist/runtime/composables/useFieldGroup.js +14 -0
  105. package/dist/runtime/composables/useFormField.d.ts +62 -0
  106. package/dist/runtime/composables/useFormField.js +99 -0
  107. package/dist/runtime/composables/useKbd.d.ts +3 -2
  108. package/dist/runtime/composables/useKbd.js +3 -2
  109. package/dist/runtime/composables/useLocale.d.ts +68 -5
  110. package/dist/runtime/composables/useLocale.js +11 -11
  111. package/dist/runtime/composables/useOverlay.d.ts +51 -15
  112. package/dist/runtime/composables/useOverlay.js +44 -30
  113. package/dist/runtime/composables/usePortal.d.ts +6 -0
  114. package/dist/runtime/composables/usePortal.js +17 -0
  115. package/dist/runtime/composables/useToast.d.ts +12 -5
  116. package/dist/runtime/composables/useToast.js +12 -7
  117. package/dist/runtime/locale/en.d.ts +30 -1
  118. package/dist/runtime/locale/en.js +2 -1
  119. package/dist/runtime/locale/index.d.ts +2 -2
  120. package/dist/runtime/locale/index.js +1 -1
  121. package/dist/runtime/locale/zh_tw.d.ts +31 -0
  122. package/dist/runtime/locale/{zh-tw.js → zh_tw.js} +2 -1
  123. package/dist/runtime/plugins/colors.d.ts +2 -0
  124. package/dist/runtime/plugins/colors.js +50 -0
  125. package/dist/runtime/types/app.config.d.ts +6 -0
  126. package/dist/runtime/types/form.d.ts +58 -17
  127. package/dist/runtime/types/form.js +11 -0
  128. package/dist/runtime/types/index.d.ts +51 -8
  129. package/dist/runtime/types/index.js +45 -2
  130. package/dist/runtime/types/input.d.ts +8 -0
  131. package/dist/runtime/types/locale.d.ts +5 -0
  132. package/dist/runtime/types/style.d.ts +33 -0
  133. package/dist/runtime/types/style.js +0 -0
  134. package/dist/runtime/types/unocss.d.ts +4 -0
  135. package/dist/runtime/types/utils.d.ts +38 -37
  136. package/dist/runtime/utils/form.d.ts +5 -1
  137. package/dist/runtime/utils/form.js +49 -0
  138. package/dist/runtime/utils/index.d.ts +10 -13
  139. package/dist/runtime/utils/index.js +41 -48
  140. package/dist/runtime/utils/link.d.ts +5 -6
  141. package/dist/runtime/utils/link.js +16 -2
  142. package/dist/runtime/utils/locale.d.ts +5 -0
  143. package/dist/runtime/utils/locale.js +10 -0
  144. package/dist/runtime/utils/style.d.ts +94 -0
  145. package/dist/runtime/utils/style.js +37 -0
  146. package/dist/runtime/vue/components/Icon.vue +15 -0
  147. package/dist/runtime/vue/components/Icon.vue.d.ts +7 -0
  148. package/dist/runtime/vue/components/Link.vue +163 -0
  149. package/dist/runtime/vue/components/Link.vue.d.ts +95 -0
  150. package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
  151. package/dist/runtime/vue/composables/useAppConfig.js +4 -0
  152. package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
  153. package/dist/runtime/vue/plugins/color-mode.js +6 -0
  154. package/dist/runtime/vue/plugins/head.d.ts +4 -0
  155. package/dist/runtime/vue/plugins/head.js +9 -0
  156. package/dist/runtime/vue/stubs.d.ts +16 -1
  157. package/dist/runtime/vue/stubs.js +32 -1
  158. package/dist/setup.d.mts +13 -0
  159. package/dist/setup.mjs +12 -0
  160. package/dist/shared/ui.CzIlLITK.mjs +51 -0
  161. package/dist/shared/ui.DSyJHSTk.mjs +3787 -0
  162. package/dist/shared/ui.DpbffTXs.d.mts +84 -0
  163. package/dist/shared/ui.IulR-OYx.d.mts +64 -0
  164. package/dist/types.d.mts +3 -1
  165. package/dist/unocss.d.mts +12 -52
  166. package/dist/unocss.mjs +144 -253
  167. package/dist/unplugin.d.mts +13 -26
  168. package/dist/unplugin.mjs +193 -18
  169. package/dist/vite.d.mts +10 -1
  170. package/dist/vite.mjs +12 -3
  171. package/package.json +156 -87
  172. package/vue-plugin.d.ts +5 -0
  173. package/dist/module.cjs +0 -5
  174. package/dist/module.d.ts +0 -13
  175. package/dist/module.mjs.map +0 -1
  176. package/dist/runtime/app/injections.d.ts +0 -9307
  177. package/dist/runtime/app/injections.js +0 -61
  178. package/dist/runtime/components/ButtonGroup.vue +0 -46
  179. package/dist/runtime/components/FormItem.vue +0 -129
  180. package/dist/runtime/composables/useButtonGroup.d.ts +0 -5
  181. package/dist/runtime/composables/useButtonGroup.js +0 -9
  182. package/dist/runtime/composables/useFormItem.d.ts +0 -27
  183. package/dist/runtime/composables/useFormItem.js +0 -64
  184. package/dist/runtime/composables/useTheme.d.ts +0 -9
  185. package/dist/runtime/composables/useTheme.js +0 -23
  186. package/dist/runtime/index.d.ts +0 -44
  187. package/dist/runtime/index.js +0 -44
  188. package/dist/runtime/locale/zh-tw.d.ts +0 -2
  189. package/dist/runtime/theme/accordion.d.ts +0 -56
  190. package/dist/runtime/theme/accordion.js +0 -28
  191. package/dist/runtime/theme/alert.d.ts +0 -125
  192. package/dist/runtime/theme/alert.js +0 -47
  193. package/dist/runtime/theme/app.d.ts +0 -19
  194. package/dist/runtime/theme/app.js +0 -19
  195. package/dist/runtime/theme/avatar-group.d.ts +0 -52
  196. package/dist/runtime/theme/avatar-group.js +0 -32
  197. package/dist/runtime/theme/avatar.d.ts +0 -56
  198. package/dist/runtime/theme/avatar.js +0 -34
  199. package/dist/runtime/theme/badge.d.ts +0 -82
  200. package/dist/runtime/theme/badge.js +0 -92
  201. package/dist/runtime/theme/breadcrumb.d.ts +0 -67
  202. package/dist/runtime/theme/breadcrumb.js +0 -44
  203. package/dist/runtime/theme/button-group.d.ts +0 -66
  204. package/dist/runtime/theme/button-group.js +0 -42
  205. package/dist/runtime/theme/button.d.ts +0 -190
  206. package/dist/runtime/theme/button.js +0 -164
  207. package/dist/runtime/theme/calendar.d.ts +0 -56
  208. package/dist/runtime/theme/calendar.js +0 -69
  209. package/dist/runtime/theme/card.d.ts +0 -62
  210. package/dist/runtime/theme/card.js +0 -37
  211. package/dist/runtime/theme/carousel.d.ts +0 -113
  212. package/dist/runtime/theme/carousel.js +0 -43
  213. package/dist/runtime/theme/checkbox.d.ts +0 -88
  214. package/dist/runtime/theme/checkbox.js +0 -54
  215. package/dist/runtime/theme/chip.d.ts +0 -67
  216. package/dist/runtime/theme/chip.js +0 -66
  217. package/dist/runtime/theme/collapsible.d.ts +0 -38
  218. package/dist/runtime/theme/collapsible.js +0 -10
  219. package/dist/runtime/theme/drawer.d.ts +0 -148
  220. package/dist/runtime/theme/drawer.js +0 -113
  221. package/dist/runtime/theme/dropdown-menu.d.ts +0 -71
  222. package/dist/runtime/theme/dropdown-menu.js +0 -83
  223. package/dist/runtime/theme/form-item.d.ts +0 -76
  224. package/dist/runtime/theme/form-item.js +0 -34
  225. package/dist/runtime/theme/form.d.ts +0 -8
  226. package/dist/runtime/theme/form.js +0 -7
  227. package/dist/runtime/theme/index.d.ts +0 -41
  228. package/dist/runtime/theme/index.js +0 -41
  229. package/dist/runtime/theme/input-number.d.ts +0 -121
  230. package/dist/runtime/theme/input-number.js +0 -95
  231. package/dist/runtime/theme/input.d.ts +0 -178
  232. package/dist/runtime/theme/input.js +0 -151
  233. package/dist/runtime/theme/kbd.d.ts +0 -39
  234. package/dist/runtime/theme/kbd.js +0 -26
  235. package/dist/runtime/theme/link.d.ts +0 -44
  236. package/dist/runtime/theme/link.js +0 -26
  237. package/dist/runtime/theme/modal.d.ts +0 -48
  238. package/dist/runtime/theme/modal.js +0 -55
  239. package/dist/runtime/theme/pagination.d.ts +0 -80
  240. package/dist/runtime/theme/pagination.js +0 -17
  241. package/dist/runtime/theme/pinInput.d.ts +0 -100
  242. package/dist/runtime/theme/pinInput.js +0 -111
  243. package/dist/runtime/theme/popover.d.ts +0 -38
  244. package/dist/runtime/theme/popover.js +0 -13
  245. package/dist/runtime/theme/progress.d.ts +0 -186
  246. package/dist/runtime/theme/progress.js +0 -95
  247. package/dist/runtime/theme/radio-group.d.ts +0 -110
  248. package/dist/runtime/theme/radio-group.js +0 -61
  249. package/dist/runtime/theme/scroll-area.d.ts +0 -73
  250. package/dist/runtime/theme/scroll-area.js +0 -33
  251. package/dist/runtime/theme/select.d.ts +0 -192
  252. package/dist/runtime/theme/select.js +0 -173
  253. package/dist/runtime/theme/separator.d.ts +0 -80
  254. package/dist/runtime/theme/separator.js +0 -53
  255. package/dist/runtime/theme/skeleton.d.ts +0 -8
  256. package/dist/runtime/theme/skeleton.js +0 -7
  257. package/dist/runtime/theme/slider.d.ts +0 -76
  258. package/dist/runtime/theme/slider.js +0 -52
  259. package/dist/runtime/theme/switch.d.ts +0 -122
  260. package/dist/runtime/theme/switch.js +0 -78
  261. package/dist/runtime/theme/table.d.ts +0 -92
  262. package/dist/runtime/theme/table.js +0 -36
  263. package/dist/runtime/theme/tabs.d.ts +0 -135
  264. package/dist/runtime/theme/tabs.js +0 -146
  265. package/dist/runtime/theme/textarea.d.ts +0 -96
  266. package/dist/runtime/theme/textarea.js +0 -116
  267. package/dist/runtime/theme/toast-provider.d.ts +0 -122
  268. package/dist/runtime/theme/toast-provider.js +0 -97
  269. package/dist/runtime/theme/toast.d.ts +0 -89
  270. package/dist/runtime/theme/toast.js +0 -35
  271. package/dist/runtime/theme/tooltip.d.ts +0 -44
  272. package/dist/runtime/theme/tooltip.js +0 -11
  273. package/dist/runtime/types/components.d.ts +0 -42
  274. package/dist/runtime/utils/extend-theme.d.ts +0 -9
  275. package/dist/runtime/utils/extend-theme.js +0 -27
  276. package/dist/runtime/utils/styler.d.ts +0 -4
  277. package/dist/runtime/utils/styler.js +0 -10
  278. package/dist/runtime/utils/translator.d.ts +0 -18
  279. package/dist/runtime/utils/translator.js +0 -8
  280. package/dist/shared/ui.3e7fad19.mjs +0 -5
  281. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  282. package/dist/types.d.ts +0 -1
  283. package/dist/unocss.d.ts +0 -52
  284. package/dist/unocss.mjs.map +0 -1
  285. package/dist/unplugin.d.ts +0 -26
  286. package/dist/unplugin.mjs.map +0 -1
  287. package/dist/vite.d.ts +0 -9
  288. package/dist/vite.mjs.map +0 -1
  289. /package/dist/runtime/types/{components.js → input.js} +0 -0
@@ -1,43 +1,52 @@
1
1
  import { createSharedComposable } from "@vueuse/core";
2
2
  import { markRaw, reactive, shallowReactive } from "vue";
3
- export const useOverlay = createSharedComposable(() => {
3
+ function _useOverlay() {
4
4
  const overlays = shallowReactive([]);
5
- const generateId = () => `overlay-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
6
- function create(component, options = {}) {
7
- const { props = {}, defaultOpen = false, unmountOnHide = true } = options;
8
- const state = reactive({
9
- id: generateId(),
10
- modelValue: defaultOpen,
11
- component: markRaw(component),
5
+ function create(component, options) {
6
+ const { props = {}, defaultOpen = false, unmountOnHide = true } = options || {};
7
+ const optionsPrivate = reactive({
8
+ id: Symbol(import.meta.dev ? "useOverlay" : ""),
9
+ isOpen: defaultOpen,
12
10
  isMounted: defaultOpen,
11
+ component: markRaw(component),
12
+ originalProps: props,
13
13
  unmountOnHide,
14
- props
14
+ props: { ...props }
15
15
  });
16
- overlays.push(state);
16
+ overlays.push(optionsPrivate);
17
17
  return {
18
- open: (props2) => open(state.id, props2),
19
- close: (value) => close(state.id, value),
20
- patch: (props2) => patch(state.id, props2)
18
+ ...optionsPrivate,
19
+ open: (props2) => open(optionsPrivate.id, props2),
20
+ close: (value) => close(optionsPrivate.id, value),
21
+ patch: (props2) => patch(optionsPrivate.id, props2)
21
22
  };
22
23
  }
23
24
  function open(id, props) {
24
25
  const overlay = getOverlay(id);
25
- if (props)
26
- patch(id, props);
27
- overlay.modelValue = true;
26
+ overlay.props = props ? { ...overlay.originalProps, ...props } : { ...overlay.originalProps };
27
+ overlay.isOpen = true;
28
28
  overlay.isMounted = true;
29
- return new Promise((resolve) => {
30
- overlay.resolve = resolve;
29
+ const result = new Promise((resolve) => {
30
+ overlay.resolvePromise = resolve;
31
+ });
32
+ return Object.assign(result, {
33
+ id,
34
+ isMounted: overlay.isMounted,
35
+ isOpen: overlay.isOpen,
36
+ result
31
37
  });
32
38
  }
33
39
  function close(id, value) {
34
40
  const overlay = getOverlay(id);
35
- overlay.modelValue = false;
36
- if (overlay.resolve) {
37
- overlay.resolve(value);
38
- overlay.resolve = void 0;
41
+ overlay.isOpen = false;
42
+ if (overlay.resolvePromise) {
43
+ overlay.resolvePromise(value);
44
+ overlay.resolvePromise = void 0;
39
45
  }
40
46
  }
47
+ function closeAll() {
48
+ overlays.forEach((overlay) => close(overlay.id));
49
+ }
41
50
  function unmount(id) {
42
51
  const overlay = getOverlay(id);
43
52
  overlay.isMounted = false;
@@ -48,22 +57,27 @@ export const useOverlay = createSharedComposable(() => {
48
57
  }
49
58
  function patch(id, props) {
50
59
  const overlay = getOverlay(id);
51
- Object.entries(props).forEach(([key, value]) => {
52
- overlay.props[key] = value;
53
- });
60
+ overlay.props = { ...overlay.props, ...props };
54
61
  }
55
62
  function getOverlay(id) {
56
- const item = overlays.find((item2) => item2.id === id);
57
- if (!item)
63
+ const overlay = overlays.find((item) => item.id === id);
64
+ if (!overlay)
58
65
  throw new Error("Overlay not found");
59
- return item;
66
+ return overlay;
67
+ }
68
+ function isOpen(id) {
69
+ const overlay = getOverlay(id);
70
+ return overlay.isOpen;
60
71
  }
61
72
  return {
62
73
  overlays,
63
74
  open,
64
75
  close,
76
+ closeAll,
65
77
  create,
66
78
  patch,
67
- unmount
79
+ unmount,
80
+ isOpen
68
81
  };
69
- });
82
+ }
83
+ export const useOverlay = /* @__PURE__ */ createSharedComposable(_useOverlay);
@@ -0,0 +1,6 @@
1
+ import { type Ref } from 'vue';
2
+ export declare const InjectionKeyPortalTarget: import("vue").InjectionKey<Ref<string | boolean | HTMLElement | undefined, string | boolean | HTMLElement | undefined>>, injectPortalTarget: () => Ref<string | boolean | HTMLElement | undefined, string | boolean | HTMLElement | undefined> | undefined, providePortalTarget: (value: Ref<string | boolean | HTMLElement | undefined, string | boolean | HTMLElement | undefined>) => void;
3
+ export declare function usePortal(portal: Ref<boolean | string | HTMLElement | undefined>): import("vue").ComputedRef<{
4
+ to: string | HTMLElement | undefined;
5
+ disabled: boolean;
6
+ }>;
@@ -0,0 +1,17 @@
1
+ import { computed } from "vue";
2
+ import { defineInjection } from "../utils/index.js";
3
+ export const {
4
+ InjectionKey: InjectionKeyPortalTarget,
5
+ inject: injectPortalTarget,
6
+ provide: providePortalTarget
7
+ } = defineInjection("ui.portal-target");
8
+ export function usePortal(portal) {
9
+ const globalPortal = injectPortalTarget();
10
+ const value = computed(() => portal.value === true ? globalPortal?.value : portal.value);
11
+ const disabled = computed(() => typeof value.value === "boolean" ? !value.value : false);
12
+ const to = computed(() => typeof value.value === "boolean" ? "body" : value.value);
13
+ return computed(() => ({
14
+ to: to.value,
15
+ disabled: disabled.value
16
+ }));
17
+ }
@@ -1,8 +1,15 @@
1
- import type { ToastState } from '../types/index.js';
2
- export declare const useToast: () => {
3
- toasts: import("vue").Ref<ToastState[], ToastState[]>;
4
- add: (toast: Partial<ToastState>) => ToastState;
5
- update: (id: string | number, toast: Partial<Omit<ToastState, "id">>) => void;
1
+ import type { Ref } from 'vue';
2
+ import type { ToastEmits, ToastProps } from '../types';
3
+ import type { EmitsToProps } from '../types/utils';
4
+ export declare const InjectionKeyToastMax: import("vue").InjectionKey<Ref<number, number>>, injectToastMax: () => Ref<number, number> | undefined, provideToastMax: (value: Ref<number, number>) => void;
5
+ export interface Toast extends Omit<ToastProps, 'defaultOpen'>, EmitsToProps<ToastEmits> {
6
+ id: string | number;
7
+ onClick?: (toast: Toast) => void;
8
+ }
9
+ export declare function useToast(): {
10
+ toasts: Ref<Toast[], Toast[]>;
11
+ add: (toast: Partial<Toast>) => Toast;
12
+ update: (id: string | number, toast: Partial<Omit<Toast, "id">>) => void;
6
13
  remove: (id: string | number) => void;
7
14
  clear: () => void;
8
15
  };
@@ -1,11 +1,16 @@
1
- import { createSharedComposable } from "@vueuse/core";
2
- import { nextTick, ref } from "vue";
1
+ import { nextTick, shallowRef } from "vue";
3
2
  import { useState } from "#imports";
4
- export const useToast = createSharedComposable(() => {
3
+ import { defineInjection } from "../utils/index.js";
4
+ export const {
5
+ InjectionKey: InjectionKeyToastMax,
6
+ inject: injectToastMax,
7
+ provide: provideToastMax
8
+ } = defineInjection("ui.toast-max");
9
+ export function useToast() {
5
10
  const toasts = useState("toasts", () => []);
6
- const running = ref(false);
7
- const maxToasts = 5;
11
+ const max = injectToastMax();
8
12
  const queue = [];
13
+ const running = shallowRef(false);
9
14
  const generateId = () => `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
10
15
  async function processQueue() {
11
16
  if (running.value || queue.length === 0)
@@ -14,7 +19,7 @@ export const useToast = createSharedComposable(() => {
14
19
  while (queue.length > 0) {
15
20
  const toast = queue.shift();
16
21
  await nextTick();
17
- toasts.value = [...toasts.value, toast].slice(-maxToasts);
22
+ toasts.value = [...toasts.value, toast].slice(-(max?.value ?? 5));
18
23
  }
19
24
  running.value = false;
20
25
  }
@@ -59,4 +64,4 @@ export const useToast = createSharedComposable(() => {
59
64
  remove,
60
65
  clear
61
66
  };
62
- });
67
+ }
@@ -1,2 +1,31 @@
1
- declare const _default: import("../utils").Locale<import("..").Messages>;
1
+ declare const _default: Required<import("@byyuurin/ui-kit").Locale<{
2
+ alert: {
3
+ close: string;
4
+ };
5
+ calendar: {
6
+ prevYear: string;
7
+ nextYear: string;
8
+ prevMonth: string;
9
+ nextMonth: string;
10
+ };
11
+ carousel: {
12
+ dots: string;
13
+ prev: string;
14
+ next: string;
15
+ goto: string;
16
+ };
17
+ inputNumber: {
18
+ increment: string;
19
+ decrement: string;
20
+ };
21
+ modal: {
22
+ close: string;
23
+ };
24
+ table: {
25
+ noData: string;
26
+ };
27
+ toast: {
28
+ close: string;
29
+ };
30
+ }>>;
2
31
  export default _default;
@@ -1,4 +1,4 @@
1
- import { defineLocale } from "../utils/index.js";
1
+ import { defineLocale } from "../utils/locale.js";
2
2
  export default defineLocale({
3
3
  name: "English",
4
4
  code: "en",
@@ -13,6 +13,7 @@ export default defineLocale({
13
13
  nextMonth: "Next month"
14
14
  },
15
15
  carousel: {
16
+ dots: "Choose slide to display",
16
17
  prev: "Prev",
17
18
  next: "Next",
18
19
  goto: "Go to slide {page}"
@@ -1,2 +1,2 @@
1
- export { default as en } from './en.js';
2
- export { default as zhTW } from './zh-tw.js';
1
+ export { default as en } from './en';
2
+ export { default as zh_tw } from './zh_tw';
@@ -1,2 +1,2 @@
1
1
  export { default as en } from "./en.js";
2
- export { default as zhTW } from "./zh-tw.js";
2
+ export { default as zh_tw } from "./zh_tw.js";
@@ -0,0 +1,31 @@
1
+ declare const _default: Required<import("@byyuurin/ui-kit").Locale<{
2
+ alert: {
3
+ close: string;
4
+ };
5
+ calendar: {
6
+ prevYear: string;
7
+ nextYear: string;
8
+ prevMonth: string;
9
+ nextMonth: string;
10
+ };
11
+ carousel: {
12
+ dots: string;
13
+ prev: string;
14
+ next: string;
15
+ goto: string;
16
+ };
17
+ inputNumber: {
18
+ increment: string;
19
+ decrement: string;
20
+ };
21
+ modal: {
22
+ close: string;
23
+ };
24
+ table: {
25
+ noData: string;
26
+ };
27
+ toast: {
28
+ close: string;
29
+ };
30
+ }>>;
31
+ export default _default;
@@ -1,4 +1,4 @@
1
- import { defineLocale } from "../utils/index.js";
1
+ import { defineLocale } from "../utils/locale.js";
2
2
  export default defineLocale({
3
3
  name: "\u7E41\u9AD4\u4E2D\u6587",
4
4
  code: "zh-TW",
@@ -13,6 +13,7 @@ export default defineLocale({
13
13
  nextMonth: "\u4E0B\u500B\u6708"
14
14
  },
15
15
  carousel: {
16
+ dots: "\u9078\u64C7\u8981\u986F\u793A\u7684\u6295\u5F71\u7247",
16
17
  prev: "\u4E0A\u4E00\u9801",
17
18
  next: "\u4E0B\u4E00\u9801",
18
19
  goto: "\u8DF3\u8F49\u5230\u7B2C {page} \u9801"
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,50 @@
1
+ import { colors } from "@unocss/preset-wind4/colors";
2
+ import { computed } from "vue";
3
+ import { defineNuxtPlugin, useAppConfig, useHead, useNuxtApp } from "#imports";
4
+ const themeShades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
5
+ function getColor(color, shade) {
6
+ if (color in colors && typeof colors[color] === "object" && shade in colors[color])
7
+ return colors[color][shade];
8
+ return "";
9
+ }
10
+ function generateShades(key, value) {
11
+ return themeShades.map((shade) => `--ui-color-${key}-${shade}: var(--colors-${value === "neutral" ? "tw-neutral" : value}-${shade}, ${getColor(value, shade)});`).join("\n ");
12
+ }
13
+ function generateColor(key, shade) {
14
+ return `--ui-${key}: var(--ui-color-${key}-${shade});`;
15
+ }
16
+ export default defineNuxtPlugin(() => {
17
+ const appConfig = useAppConfig();
18
+ const nuxtApp = useNuxtApp();
19
+ const root = computed(() => {
20
+ const { neutral, ...colors2 } = appConfig.ui.colors;
21
+ return `:root {
22
+ ${Object.entries(appConfig.ui.colors).map(([key, value]) => generateShades(key, value)).join("\n ")}
23
+ }
24
+ :root,
25
+ .light {
26
+ ${Object.keys(colors2).map((key) => generateColor(key, 500)).join("\n ")}
27
+ }
28
+ .dark {
29
+ ${Object.keys(colors2).map((key) => generateColor(key, 400)).join("\n ")}
30
+ }
31
+ `;
32
+ });
33
+ const headData = {
34
+ style: [{
35
+ innerHTML: () => root.value,
36
+ tagPriority: -2,
37
+ id: "ui-colors"
38
+ }]
39
+ };
40
+ if (import.meta.client && nuxtApp.isHydrating && !nuxtApp.payload.serverRendered) {
41
+ const style = document.createElement("style");
42
+ style.innerHTML = root.value;
43
+ style.dataset.uiColors = "";
44
+ document.head.append(style);
45
+ headData.script = [{
46
+ innerHTML: "document.head.removeChild(document.querySelector('[data-ui-colors]'))"
47
+ }];
48
+ }
49
+ useHead(headData);
50
+ });
@@ -0,0 +1,6 @@
1
+ declare module '#build/app.config' {
2
+ import type { AppConfig } from '@nuxt/schema'
3
+
4
+ const _default: AppConfig
5
+ export default _default
6
+ }
@@ -1,6 +1,31 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- import type { FormExpose } from './components.js';
3
- export type FormSchema<_T> = StandardSchemaV1;
2
+ import type { Struct as SuperstructSchema } from 'superstruct';
3
+ import type { ComputedRef, DeepReadonly, Ref } from 'vue';
4
+ import type { GetObjectField, MaybeNull } from './utils';
5
+ export interface Form<S extends FormSchema> {
6
+ validate: <T extends boolean>(opts?: {
7
+ name?: keyof FormData<S, false> | (keyof FormData<S, false>)[];
8
+ silent?: boolean;
9
+ nested?: boolean;
10
+ transform?: T;
11
+ }) => Promise<FormData<S, T> | false>;
12
+ clear: (path?: keyof FormData<S, false> | string | RegExp) => void;
13
+ errors: Ref<FormError[]>;
14
+ setErrors: (errs: FormError[], name?: keyof FormData<S, false> | string | RegExp) => void;
15
+ getErrors: (name?: keyof FormData<S, false> | string | RegExp) => FormError[];
16
+ submit: () => Promise<void>;
17
+ disabled: ComputedRef<boolean>;
18
+ dirty: ComputedRef<boolean>;
19
+ loading: Ref<boolean>;
20
+ dirtyFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
21
+ touchedFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
22
+ blurredFields: ReadonlySet<DeepReadonly<keyof FormData<S, false>>>;
23
+ }
24
+ export type FormSchema<I extends object = object, O extends object = I> = SuperstructSchema<any, any> | StandardSchemaV1<I, O>;
25
+ export type InferInput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : Schema extends SuperstructSchema<infer I, any> ? I : Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : never;
26
+ export type InferOutput<Schema> = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : Schema extends SuperstructSchema<infer O, any> ? O : never;
27
+ export type FormData<S extends FormSchema, T extends boolean = true> = T extends true ? InferOutput<S> : InferInput<S>;
28
+ export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus';
4
29
  export interface FormError<P extends string = string> {
5
30
  name?: P;
6
31
  message: string;
@@ -8,15 +33,21 @@ export interface FormError<P extends string = string> {
8
33
  export interface FormErrorWithId extends FormError {
9
34
  id?: string;
10
35
  }
11
- export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus';
12
- export type FormEventType = FormInputEvents;
13
36
  export type FormSubmitEvent<T> = SubmitEvent & {
14
37
  data: T;
15
38
  };
16
- export interface FormChildAttachEvent {
39
+ export interface FormValidationError {
40
+ errors: FormErrorWithId[];
41
+ children?: FormErrorWithId[];
42
+ }
43
+ export type FormErrorEvent = SubmitEvent & FormValidationError;
44
+ export type FormEventType = FormInputEvents;
45
+ export interface FormChildAttachEvent<S extends FormSchema> {
17
46
  type: 'attach';
18
47
  formId: string | number;
19
- validate: FormExpose<any>['validate'];
48
+ validate: Form<any>['validate'];
49
+ name?: string;
50
+ api: Form<S>;
20
51
  }
21
52
  export interface FormChildDetachEvent {
22
53
  type: 'detach';
@@ -27,19 +58,29 @@ export interface FormInputEvent<T extends object> {
27
58
  name: keyof T;
28
59
  eager?: boolean;
29
60
  }
30
- export type FormEvent<T extends object> = FormInputEvent<T> | FormChildAttachEvent | FormChildDetachEvent;
31
- export interface FormValidationError {
32
- errors: FormErrorWithId[];
33
- children?: FormValidationError[];
61
+ export type FormEvent<T extends object> = FormInputEvent<T> | FormChildAttachEvent<any> | FormChildDetachEvent;
62
+ export interface FormInjectedOptions {
63
+ disabled?: boolean;
64
+ validateOnInputDelay?: number;
65
+ }
66
+ export interface FormFieldInjectedOptions<T> {
67
+ name?: string;
68
+ size?: GetObjectField<T, 'size'>;
69
+ error?: string | boolean;
70
+ eagerValidation?: boolean;
71
+ validateOnInputDelay?: number;
72
+ errorPattern?: RegExp;
73
+ hint?: string;
74
+ description?: string;
75
+ help?: string;
76
+ ariaId: string;
34
77
  }
35
- export type FormErrorEvent = SubmitEvent & FormValidationError;
36
78
  export interface ValidateReturnSchema<T> {
37
79
  result: T;
38
- errors: FormError[] | null;
80
+ errors: MaybeNull<FormError[]>;
39
81
  }
40
- export interface FormValidateOptions<T extends object> {
41
- name?: keyof T | (keyof T)[];
42
- silent?: boolean;
43
- nested?: boolean;
44
- transform?: boolean;
82
+ export declare class FormValidationException extends Error {
83
+ formId: string | number;
84
+ errors: FormErrorWithId[];
85
+ constructor(formId: string | number, errors: FormErrorWithId[]);
45
86
  }
@@ -0,0 +1,11 @@
1
+ export class FormValidationException extends Error {
2
+ formId;
3
+ errors;
4
+ // eslint-disable-next-line unicorn/custom-error-definition
5
+ constructor(formId, errors) {
6
+ super("Form validation exception");
7
+ this.formId = formId;
8
+ this.errors = errors;
9
+ Object.setPrototypeOf(this, FormValidationException.prototype);
10
+ }
11
+ }
@@ -1,9 +1,52 @@
1
- import type * as theme from '../theme/index.js';
2
- export * from './components.js';
3
- export * from './form.js';
4
- export * from './locale.js';
5
- export * from './utils.js';
6
- type MergeThemes<T> = {
7
- [P in keyof T as T[P] extends undefined ? never : P]?: T[P] extends Array<infer V> ? V extends string ? string : V[] : T[P] extends object ? MergeThemes<T[P]> : T[P] extends string ? string : T[P];
1
+ import type { AppConfig } from '@nuxt/schema';
2
+ import type { AppConfigUI } from '#build/types/ui';
3
+ export * from '../components/Accordion.vue';
4
+ export * from '../components/Alert.vue';
5
+ export * from '../components/App.vue';
6
+ export * from '../components/Avatar.vue';
7
+ export * from '../components/AvatarGroup.vue';
8
+ export * from '../components/Badge.vue';
9
+ export * from '../components/Breadcrumb.vue';
10
+ export * from '../components/Button.vue';
11
+ export * from '../components/Calendar.vue';
12
+ export * from '../components/Card.vue';
13
+ export * from '../components/Carousel.vue';
14
+ export * from '../components/Checkbox.vue';
15
+ export * from '../components/Chip.vue';
16
+ export * from '../components/Collapsible.vue';
17
+ export * from '../components/Drawer.vue';
18
+ export * from '../components/DropdownMenu.vue';
19
+ export * from '../components/FieldGroup.vue';
20
+ export * from '../components/Form.vue';
21
+ export * from '../components/FormField.vue';
22
+ export * from '../components/Icon.vue';
23
+ export * from '../components/Input.vue';
24
+ export * from '../components/InputNumber.vue';
25
+ export * from '../components/Kbd.vue';
26
+ export * from '../components/Link.vue';
27
+ export * from '../components/Modal.vue';
28
+ export * from '../components/NavigationMenu.vue';
29
+ export * from '../components/OverlayProvider.vue';
30
+ export * from '../components/Pagination.vue';
31
+ export * from '../components/PinInput.vue';
32
+ export * from '../components/Popover.vue';
33
+ export * from '../components/Progress.vue';
34
+ export * from '../components/RadioGroup.vue';
35
+ export * from '../components/ScrollArea.vue';
36
+ export * from '../components/Select.vue';
37
+ export * from '../components/Separator.vue';
38
+ export * from '../components/Skeleton.vue';
39
+ export * from '../components/Slider.vue';
40
+ export * from '../components/Switch.vue';
41
+ export * from '../components/Table.vue';
42
+ export * from '../components/Tabs.vue';
43
+ export * from '../components/Textarea.vue';
44
+ export * from '../components/Toast.vue';
45
+ export * from '../components/ToastProvider.vue';
46
+ export * from '../components/Tooltip.vue';
47
+ export * from './form';
48
+ export * from './locale';
49
+ export * from './style';
50
+ export type RuntimeAppConfig = AppConfig & {
51
+ ui: AppConfigUI;
8
52
  };
9
- export type ThemeExtension = MergeThemes<typeof theme>;
@@ -1,4 +1,47 @@
1
- export * from "./components.js";
1
+ export * from "../components/Accordion.vue";
2
+ export * from "../components/Alert.vue";
3
+ export * from "../components/App.vue";
4
+ export * from "../components/Avatar.vue";
5
+ export * from "../components/AvatarGroup.vue";
6
+ export * from "../components/Badge.vue";
7
+ export * from "../components/Breadcrumb.vue";
8
+ export * from "../components/Button.vue";
9
+ export * from "../components/Calendar.vue";
10
+ export * from "../components/Card.vue";
11
+ export * from "../components/Carousel.vue";
12
+ export * from "../components/Checkbox.vue";
13
+ export * from "../components/Chip.vue";
14
+ export * from "../components/Collapsible.vue";
15
+ export * from "../components/Drawer.vue";
16
+ export * from "../components/DropdownMenu.vue";
17
+ export * from "../components/FieldGroup.vue";
18
+ export * from "../components/Form.vue";
19
+ export * from "../components/FormField.vue";
20
+ export * from "../components/Icon.vue";
21
+ export * from "../components/Input.vue";
22
+ export * from "../components/InputNumber.vue";
23
+ export * from "../components/Kbd.vue";
24
+ export * from "../components/Link.vue";
25
+ export * from "../components/Modal.vue";
26
+ export * from "../components/NavigationMenu.vue";
27
+ export * from "../components/OverlayProvider.vue";
28
+ export * from "../components/Pagination.vue";
29
+ export * from "../components/PinInput.vue";
30
+ export * from "../components/Popover.vue";
31
+ export * from "../components/Progress.vue";
32
+ export * from "../components/RadioGroup.vue";
33
+ export * from "../components/ScrollArea.vue";
34
+ export * from "../components/Select.vue";
35
+ export * from "../components/Separator.vue";
36
+ export * from "../components/Skeleton.vue";
37
+ export * from "../components/Slider.vue";
38
+ export * from "../components/Switch.vue";
39
+ export * from "../components/Table.vue";
40
+ export * from "../components/Tabs.vue";
41
+ export * from "../components/Textarea.vue";
42
+ export * from "../components/Toast.vue";
43
+ export * from "../components/ToastProvider.vue";
44
+ export * from "../components/Tooltip.vue";
2
45
  export * from "./form.js";
3
46
  export * from "./locale.js";
4
- export * from "./utils.js";
47
+ export * from "./style.js";
@@ -0,0 +1,8 @@
1
+ export interface ModelModifiers {
2
+ string?: boolean;
3
+ number?: boolean;
4
+ trim?: boolean;
5
+ lazy?: boolean;
6
+ nullable?: boolean;
7
+ optional?: boolean;
8
+ }
@@ -1,3 +1,7 @@
1
+ import type { Locale as DefineLocale, LocaleDirection } from '@byyuurin/ui-kit';
2
+ export type DefineLocaleOptions<M> = DefineLocale<M>;
3
+ export type Locale<M> = Required<DefineLocale<M>>;
4
+ export type Direction = LocaleDirection;
1
5
  export interface Messages {
2
6
  alert: {
3
7
  close: string;
@@ -9,6 +13,7 @@ export interface Messages {
9
13
  nextMonth: string;
10
14
  };
11
15
  carousel: {
16
+ dots: string;
12
17
  prev: string;
13
18
  next: string;
14
19
  goto: string;
@@ -0,0 +1,33 @@
1
+ import type { ClassProp, ClassValue, CVDefaultVariants, CVParts, CVScopeMeta, CVVariants, MaybeArray, StringToBoolean, VariantProps } from '@byyuurin/ui-kit';
2
+ export interface ComponentBaseProps {
3
+ class?: ClassValue;
4
+ }
5
+ export type ComponentStyler<T> = T extends {
6
+ parts: infer P;
7
+ variants: infer V;
8
+ } ? {
9
+ [Part in keyof P]: V extends undefined ? (props: {
10
+ class?: ClassValue;
11
+ }) => string : (props?: VariantProps<T> & {
12
+ class?: ClassValue;
13
+ }) => string;
14
+ } : Record<string, never>;
15
+ export type ComponentUIProps<T> = T extends {
16
+ parts: infer P;
17
+ } ? {
18
+ [Part in keyof P]?: string;
19
+ } : Record<string, never>;
20
+ type UIConfigPartial<T> = {
21
+ [P in keyof T as T[P] extends undefined ? never : P]?: T[P] extends Array<infer V> ? V extends string ? V extends '' ? '' : string : V[] : T[P] extends object ? UIConfigPartial<T[P]> : T[P] extends string ? T[P] extends '' ? '' : string : T[P];
22
+ };
23
+ type PartsName<P extends CVParts, B extends ClassValue> = B extends undefined ? keyof P : keyof P | 'base';
24
+ type PartsClassValue<S extends CVParts, B extends ClassValue> = {
25
+ [K in PartsName<S, B>]?: string;
26
+ };
27
+ type CVCompoundVariants<V extends CVVariants<P>, P extends CVParts, B extends ClassValue> = Array<{
28
+ [K in keyof V]?: MaybeArray<StringToBoolean<keyof V[K]>>;
29
+ } & (P extends undefined ? ClassProp<PartsClassValue<P, B> | string> : ClassProp<PartsClassValue<P, B>>)>;
30
+ export type UIConfig<Themes extends Record<string, any>> = {
31
+ [Component in keyof Themes]?: Themes[Component] extends CVScopeMeta<infer V, any, any, infer B, infer P> ? UIConfigPartial<CVScopeMeta<V, CVCompoundVariants<V, P, B>, CVDefaultVariants<V, P>, B, P>> : never;
32
+ };
33
+ export {};
File without changes