@byyuurin/ui 0.0.7 → 0.0.9

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 (151) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +8 -7
  3. package/dist/module.mjs.map +1 -1
  4. package/dist/runtime/app/injections.d.ts +11 -0
  5. package/dist/runtime/app/injections.js +26 -0
  6. package/dist/runtime/components/Accordion.vue +28 -26
  7. package/dist/runtime/components/Alert.vue +27 -23
  8. package/dist/runtime/components/App.vue +21 -26
  9. package/dist/runtime/components/Avatar.vue +70 -0
  10. package/dist/runtime/components/AvatarGroup.vue +87 -0
  11. package/dist/runtime/components/Badge.vue +17 -15
  12. package/dist/runtime/components/Breadcrumb.vue +108 -0
  13. package/dist/runtime/components/Button.vue +15 -16
  14. package/dist/runtime/components/ButtonGroup.vue +14 -15
  15. package/dist/runtime/components/Calendar.vue +176 -0
  16. package/dist/runtime/components/Card.vue +9 -7
  17. package/dist/runtime/components/Carousel.vue +22 -22
  18. package/dist/runtime/components/Checkbox.vue +15 -14
  19. package/dist/runtime/components/Chip.vue +23 -21
  20. package/dist/runtime/components/Collapsible.vue +5 -8
  21. package/dist/runtime/components/Drawer.vue +91 -49
  22. package/dist/runtime/components/Input.vue +33 -36
  23. package/dist/runtime/components/InputNumber.vue +9 -10
  24. package/dist/runtime/components/Kbd.vue +47 -0
  25. package/dist/runtime/components/Link.vue +15 -12
  26. package/dist/runtime/components/LinkBase.vue +1 -1
  27. package/dist/runtime/components/Modal.vue +31 -19
  28. package/dist/runtime/components/OverlayProvider.vue +29 -0
  29. package/dist/runtime/components/Pagination.vue +60 -53
  30. package/dist/runtime/components/PinInput.vue +9 -12
  31. package/dist/runtime/components/Popover.vue +9 -12
  32. package/dist/runtime/components/Progress.vue +162 -0
  33. package/dist/runtime/components/RadioGroup.vue +38 -35
  34. package/dist/runtime/components/ScrollArea.vue +2 -6
  35. package/dist/runtime/components/Select.vue +48 -51
  36. package/dist/runtime/components/Separator.vue +2 -6
  37. package/dist/runtime/components/Skeleton.vue +30 -0
  38. package/dist/runtime/components/Slider.vue +8 -11
  39. package/dist/runtime/components/Switch.vue +17 -17
  40. package/dist/runtime/components/Table.vue +21 -16
  41. package/dist/runtime/components/Tabs.vue +24 -23
  42. package/dist/runtime/components/Textarea.vue +13 -16
  43. package/dist/runtime/components/Toast.vue +21 -24
  44. package/dist/runtime/components/{Toaster.vue → ToastProvider.vue} +22 -20
  45. package/dist/runtime/components/Tooltip.vue +9 -12
  46. package/dist/runtime/composables/useAvatarGroup.d.ts +4 -0
  47. package/dist/runtime/composables/useAvatarGroup.js +8 -0
  48. package/dist/runtime/composables/useButtonGroup.d.ts +4 -12
  49. package/dist/runtime/composables/useButtonGroup.js +1 -6
  50. package/dist/runtime/composables/useComponentIcons.d.ts +9 -9
  51. package/dist/runtime/composables/useComponentIcons.js +11 -11
  52. package/dist/runtime/composables/useKbd.d.ts +35 -0
  53. package/dist/runtime/composables/useKbd.js +49 -0
  54. package/dist/runtime/composables/useLocale.d.ts +8 -0
  55. package/dist/runtime/composables/useLocale.js +22 -0
  56. package/dist/runtime/composables/useOverlay.d.ts +29 -0
  57. package/dist/runtime/composables/useOverlay.js +69 -0
  58. package/dist/runtime/composables/useTheme.d.ts +6 -6
  59. package/dist/runtime/composables/useTheme.js +11 -15
  60. package/dist/runtime/composables/useToast.d.ts +4 -20
  61. package/dist/runtime/composables/useToast.js +6 -5
  62. package/dist/runtime/index.d.ts +9 -2
  63. package/dist/runtime/index.js +9 -2
  64. package/dist/runtime/locale/en.d.ts +2 -0
  65. package/dist/runtime/locale/en.js +34 -0
  66. package/dist/runtime/locale/index.d.ts +2 -0
  67. package/dist/runtime/locale/index.js +2 -0
  68. package/dist/runtime/locale/zh-tw.d.ts +2 -0
  69. package/dist/runtime/locale/zh-tw.js +34 -0
  70. package/dist/runtime/theme/accordion.d.ts +6 -6
  71. package/dist/runtime/theme/accordion.js +5 -5
  72. package/dist/runtime/theme/alert.js +3 -3
  73. package/dist/runtime/theme/app.d.ts +6 -6
  74. package/dist/runtime/theme/app.js +7 -7
  75. package/dist/runtime/theme/avatar-group.d.ts +52 -0
  76. package/dist/runtime/theme/avatar-group.js +32 -0
  77. package/dist/runtime/theme/avatar.d.ts +56 -0
  78. package/dist/runtime/theme/avatar.js +34 -0
  79. package/dist/runtime/theme/breadcrumb.d.ts +67 -0
  80. package/dist/runtime/theme/breadcrumb.js +44 -0
  81. package/dist/runtime/theme/button.d.ts +8 -8
  82. package/dist/runtime/theme/button.js +22 -22
  83. package/dist/runtime/theme/calendar.d.ts +56 -0
  84. package/dist/runtime/theme/calendar.js +69 -0
  85. package/dist/runtime/theme/card.js +6 -6
  86. package/dist/runtime/theme/carousel.js +1 -1
  87. package/dist/runtime/theme/checkbox.js +5 -5
  88. package/dist/runtime/theme/chip.d.ts +4 -4
  89. package/dist/runtime/theme/chip.js +5 -5
  90. package/dist/runtime/theme/drawer.d.ts +24 -21
  91. package/dist/runtime/theme/drawer.js +47 -20
  92. package/dist/runtime/theme/index.d.ts +8 -1
  93. package/dist/runtime/theme/index.js +8 -1
  94. package/dist/runtime/theme/input-number.d.ts +6 -0
  95. package/dist/runtime/theme/input-number.js +6 -3
  96. package/dist/runtime/theme/input.d.ts +12 -12
  97. package/dist/runtime/theme/input.js +26 -26
  98. package/dist/runtime/theme/kbd.d.ts +39 -0
  99. package/dist/runtime/theme/kbd.js +26 -0
  100. package/dist/runtime/theme/link.d.ts +1 -1
  101. package/dist/runtime/theme/link.js +3 -3
  102. package/dist/runtime/theme/modal.js +5 -5
  103. package/dist/runtime/theme/pagination.d.ts +27 -3
  104. package/dist/runtime/theme/pagination.js +6 -2
  105. package/dist/runtime/theme/pinInput.js +13 -13
  106. package/dist/runtime/theme/popover.js +1 -1
  107. package/dist/runtime/theme/progress.d.ts +122 -0
  108. package/dist/runtime/theme/progress.js +95 -0
  109. package/dist/runtime/theme/radio-group.d.ts +2 -2
  110. package/dist/runtime/theme/radio-group.js +7 -7
  111. package/dist/runtime/theme/select.d.ts +18 -18
  112. package/dist/runtime/theme/select.js +34 -34
  113. package/dist/runtime/theme/separator.js +1 -1
  114. package/dist/runtime/theme/skeleton.d.ts +8 -0
  115. package/dist/runtime/theme/skeleton.js +7 -0
  116. package/dist/runtime/theme/slider.js +1 -1
  117. package/dist/runtime/theme/switch.js +6 -6
  118. package/dist/runtime/theme/table.js +7 -7
  119. package/dist/runtime/theme/tabs.d.ts +2 -2
  120. package/dist/runtime/theme/tabs.js +11 -11
  121. package/dist/runtime/theme/textarea.js +13 -13
  122. package/dist/runtime/theme/toast.js +6 -6
  123. package/dist/runtime/theme/tooltip.js +1 -1
  124. package/dist/runtime/types/components.d.ts +9 -1
  125. package/dist/runtime/types/index.d.ts +1 -0
  126. package/dist/runtime/types/index.js +1 -0
  127. package/dist/runtime/types/locale.d.ts +29 -0
  128. package/dist/runtime/types/locale.js +0 -0
  129. package/dist/runtime/types/utils.d.ts +5 -3
  130. package/dist/runtime/utils/index.d.ts +6 -1
  131. package/dist/runtime/utils/index.js +6 -4
  132. package/dist/runtime/utils/link.d.ts +1 -1
  133. package/dist/runtime/utils/translator.d.ts +18 -0
  134. package/dist/runtime/utils/translator.js +8 -0
  135. package/dist/shared/ui.1a1f119c.mjs +5 -0
  136. package/dist/shared/ui.1a1f119c.mjs.map +1 -0
  137. package/dist/unocss.mjs +19 -14
  138. package/dist/unocss.mjs.map +1 -1
  139. package/dist/unplugin.mjs +3 -12
  140. package/dist/unplugin.mjs.map +1 -1
  141. package/dist/vite.mjs +1 -1
  142. package/package.json +30 -19
  143. package/dist/runtime/components/ModalProvider.vue +0 -10
  144. package/dist/runtime/composables/useModal.d.ts +0 -15
  145. package/dist/runtime/composables/useModal.js +0 -52
  146. package/dist/shared/ui.d1728164.mjs +0 -4
  147. package/dist/shared/ui.d1728164.mjs.map +0 -1
  148. /package/dist/runtime/theme/{toaster.d.ts → toast-provider.d.ts} +0 -0
  149. /package/dist/runtime/theme/{toaster.js → toast-provider.js} +0 -0
  150. /package/dist/runtime/{composables/defineInjection.d.ts → utils/vue.d.ts} +0 -0
  151. /package/dist/runtime/{composables/defineInjection.js → utils/vue.js} +0 -0
@@ -4,12 +4,22 @@ import type { PrimitiveProps } from 'reka-ui'
4
4
  import type { textarea } from '../theme'
5
5
  import type { ComponentAttrs } from '../types'
6
6
 
7
+ export interface TextareaEmits {
8
+ (e: 'update:modelValue', payload: string): void
9
+ (e: 'blur', event: FocusEvent): void
10
+ (e: 'change', event: Event): void
11
+ }
12
+
13
+ export interface TextareaSlots {
14
+ default?: (props?: {}) => any
15
+ }
16
+
7
17
  type TextareaVariants = VariantProps<typeof textarea>
8
18
 
9
19
  export interface TextareaProps extends ComponentAttrs<typeof textarea> {
10
20
  /**
11
21
  * The element or component this component should render as.
12
- * @defaultValue 'div'
22
+ * @default "div"
13
23
  */
14
24
  as?: PrimitiveProps['as']
15
25
  id?: string
@@ -27,16 +37,6 @@ export interface TextareaProps extends ComponentAttrs<typeof textarea> {
27
37
  maxRows?: number
28
38
  autoResize?: boolean
29
39
  }
30
-
31
- export interface TextareaEmits {
32
- (e: 'update:modelValue', payload: string): void
33
- (e: 'blur', event: FocusEvent): void
34
- (e: 'change', event: Event): void
35
- }
36
-
37
- export interface TextareaSlots {
38
- default?: (props?: {}) => any
39
- }
40
40
  </script>
41
41
 
42
42
  <script setup lang="ts">
@@ -61,11 +61,8 @@ const [modelValue, modelModifiers] = defineModel<string | number>()
61
61
 
62
62
  const textareaRef = ref<HTMLTextAreaElement | null>(null)
63
63
 
64
- const { theme, createStyler } = useTheme()
65
- const style = computed(() => {
66
- const styler = createStyler(theme.value.textarea)
67
- return styler(props)
68
- })
64
+ const { generateStyle } = useTheme()
65
+ const style = computed(() => generateStyle('textarea', props))
69
66
 
70
67
  function autoFocus() {
71
68
  if (props.autofocus)
@@ -4,6 +4,16 @@ import type { PrimitiveProps, ToastRootEmits, ToastRootProps } from 'reka-ui'
4
4
  import type { toast } from '../theme'
5
5
  import type { ButtonProps, ComponentAttrs } from '../types'
6
6
 
7
+ export interface ToastEmits extends ToastRootEmits {}
8
+
9
+ export interface ToastSlots {
10
+ icon?: (props?: {}) => any
11
+ title?: (props?: {}) => any
12
+ description?: (props?: {}) => any
13
+ actions?: (props?: {}) => any
14
+ close?: (props: { ui: any }) => any
15
+ }
16
+
7
17
  type ToastVariants = VariantProps<typeof toast>
8
18
 
9
19
  export interface ToastProps extends ComponentAttrs<typeof toast>, Pick<ToastRootProps, 'defaultOpen' | 'open' | 'type' | 'duration'> {
@@ -27,23 +37,13 @@ export interface ToastProps extends ComponentAttrs<typeof toast>, Pick<ToastRoot
27
37
  /** @default app.icons.close */
28
38
  closeIcon?: string
29
39
  }
30
-
31
- export interface ToastEmits extends ToastRootEmits {}
32
-
33
- export interface ToastSlots {
34
- icon?: (props?: {}) => any
35
- title?: (props?: {}) => any
36
- description?: (props?: {}) => any
37
- actions?: (props?: {}) => any
38
- close?: (props: { ui: any }) => any
39
-
40
- }
41
40
  </script>
42
41
 
43
42
  <script setup lang="ts">
44
43
  import { reactivePick, useElementBounding } from '@vueuse/core'
45
44
  import { ToastAction, ToastClose, ToastDescription, ToastRoot, ToastTitle, useForwardPropsEmits } from 'reka-ui'
46
45
  import { computed, ref } from 'vue'
46
+ import { useLocale } from '../composables/useLocale'
47
47
  import { useTheme } from '../composables/useTheme'
48
48
  import Button from './Button.vue'
49
49
 
@@ -60,14 +60,12 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen',
60
60
  const el = ref<InstanceType<typeof ToastRoot>>()
61
61
  const { height } = useElementBounding(() => el.value?.$el.getBoundingClientRect ? el.value.$el : undefined)
62
62
 
63
- const { theme, createStyler } = useTheme()
64
- const style = computed(() => {
65
- const styler = createStyler(theme.value.toast)
66
- return styler({
67
- ...props,
68
- title: !!(props.title || slots.title),
69
- })
70
- })
63
+ const { t } = useLocale()
64
+ const { theme, generateStyle } = useTheme()
65
+ const style = computed(() => generateStyle('toast', {
66
+ ...props,
67
+ title: !!(props.title || slots.title),
68
+ }))
71
69
 
72
70
  defineExpose({
73
71
  height,
@@ -107,7 +105,7 @@ defineExpose({
107
105
  </div>
108
106
  </div>
109
107
 
110
- <div v-if="(props.orientation === 'horizontal' && actions?.length) || props.close !== null" :class="style.actions({ class: props.ui?.actions })">
108
+ <div v-if="(props.orientation === 'horizontal' && actions?.length) || props.close || slots.close" :class="style.actions({ class: props.ui?.actions })">
111
109
  <template v-if="props.orientation === 'horizontal'">
112
110
  <slot name="actions">
113
111
  <ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
@@ -116,14 +114,13 @@ defineExpose({
116
114
  </slot>
117
115
  </template>
118
116
 
119
- <ToastClose as-child>
117
+ <ToastClose v-if="props.close || slots.close" as-child>
120
118
  <slot name="close" :ui="ui">
121
119
  <Button
122
- v-if="props.close"
123
120
  :icon="props.closeIcon || theme.app.icons.close"
124
- size="md"
121
+ size="sm"
125
122
  variant="link"
126
- aria-label="close"
123
+ :aria-label="t('toast.close')"
127
124
  v-bind="typeof close === 'object' ? close : undefined"
128
125
  :class="style.close({ class: props.ui?.close })"
129
126
  @click.stop
@@ -1,12 +1,21 @@
1
1
  <script lang="ts">
2
2
  import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { ToastProviderProps } from 'reka-ui'
4
- import type { toaster } from '../theme'
5
- import type { ComponentAttrs } from '../types'
3
+ import type { ToastProviderProps as RekaToastProviderProps } from 'reka-ui'
4
+ import type { toastProvider } from '../theme'
5
+ import type { ComponentAttrs, ToastProps } from '../types'
6
6
 
7
- type ToasterVariants = VariantProps<typeof toaster>
7
+ export interface ToastState extends Omit<ToastProps, 'defaultOpen'> {
8
+ id: string | number
9
+ onClick?: (toast: ToastState) => void
10
+ }
11
+
12
+ export interface ToasterSlots {
13
+ default?: (props?: {}) => any
14
+ }
15
+
16
+ type ToasterVariants = VariantProps<typeof toastProvider>
8
17
 
9
- export interface ToasterProps extends ComponentAttrs<typeof toaster>, Omit<ToastProviderProps, 'swipeDirection'> {
18
+ export interface ToastProviderProps extends ComponentAttrs<typeof toastProvider>, Omit<RekaToastProviderProps, 'swipeDirection'> {
10
19
  /** @default "bottom-right" */
11
20
  position?: ToasterVariants['position']
12
21
  /**
@@ -20,10 +29,6 @@ export interface ToasterProps extends ComponentAttrs<typeof toaster>, Omit<Toast
20
29
  */
21
30
  portal?: boolean
22
31
  }
23
-
24
- export interface ToasterSlots {
25
- default?: (props?: {}) => any
26
- }
27
32
  </script>
28
33
 
29
34
  <script setup lang="ts">
@@ -35,7 +40,7 @@ import { useToast } from '../composables/useToast'
35
40
  import { omit } from '../utils'
36
41
  import Toast from './Toast.vue'
37
42
 
38
- const props = withDefaults(defineProps<ToasterProps>(), {
43
+ const props = withDefaults(defineProps<ToastProviderProps>(), {
39
44
  position: 'bottom-right',
40
45
  expand: true,
41
46
  portal: true,
@@ -61,20 +66,17 @@ const swipeDirection = computed(() => {
61
66
  return 'left'
62
67
  }
63
68
 
64
- console.warn(`[Toaster] Unknown position "${props.position}"`)
69
+ console.warn(`[ToastProvider] Unknown position "${props.position}"`)
65
70
 
66
71
  return 'right'
67
72
  })
68
73
 
69
- const { theme, createStyler } = useTheme()
70
- const style = computed(() => {
71
- const styler = createStyler(theme.value.toaster)
72
- return styler({
73
- ...props,
74
- swipeDirection: swipeDirection.value,
75
- clickable: false,
76
- })
77
- })
74
+ const { generateStyle } = useTheme()
75
+ const style = computed(() => generateStyle('toastProvider', {
76
+ ...props,
77
+ swipeDirection: swipeDirection.value,
78
+ clickable: false,
79
+ }))
78
80
 
79
81
  function onUpdateOpen(value: boolean, id: string | number) {
80
82
  if (value)
@@ -3,6 +3,13 @@ import type { TooltipArrowProps, TooltipContentProps, TooltipRootEmits, TooltipR
3
3
  import type { tooltip } from '../theme'
4
4
  import type { ComponentAttrs } from '../types'
5
5
 
6
+ export interface TooltipEmits extends TooltipRootEmits {}
7
+
8
+ export interface TooltipSlots {
9
+ default?: (props: { open: boolean }) => any
10
+ content?: (props: {}) => any
11
+ }
12
+
6
13
  export interface TooltipProps extends ComponentAttrs<typeof tooltip>, TooltipRootProps {
7
14
  text?: string
8
15
  content?: Omit<TooltipContentProps, 'as' | 'asChild'>
@@ -10,13 +17,6 @@ export interface TooltipProps extends ComponentAttrs<typeof tooltip>, TooltipRoo
10
17
  /** @default true */
11
18
  portal?: boolean
12
19
  }
13
-
14
- export interface TooltipEmits extends TooltipRootEmits {}
15
-
16
- export interface TooltipSlots {
17
- default?: (props: { open: boolean }) => any
18
- content?: (props: {}) => any
19
- }
20
20
  </script>
21
21
 
22
22
  <script lang="ts" setup>
@@ -44,11 +44,8 @@ const contentProps = toRef(() => defu(props.content, contentDefaults) as Tooltip
44
44
 
45
45
  const arrowProps = toRef(() => props.arrow as TooltipArrowProps)
46
46
 
47
- const { theme, createStyler } = useTheme()
48
- const style = computed(() => {
49
- const styler = createStyler(theme.value.tooltip)
50
- return styler(props)
51
- })
47
+ const { generateStyle } = useTheme()
48
+ const style = computed(() => generateStyle('tooltip', props))
52
49
  </script>
53
50
 
54
51
  <template>
@@ -0,0 +1,4 @@
1
+ import type { AvatarProps } from '../types/index.js';
2
+ export declare function useAvatarGroup(props?: AvatarProps): {
3
+ size: import("vue").ComputedRef<any>;
4
+ };
@@ -0,0 +1,8 @@
1
+ import { computed } from "vue";
2
+ import { injectAvatarGroup } from "../app/injections.js";
3
+ export function useAvatarGroup(props = {}) {
4
+ const avatarGroup = injectAvatarGroup();
5
+ return {
6
+ size: computed(() => props.size ?? avatarGroup?.value.size)
7
+ };
8
+ }
@@ -1,13 +1,5 @@
1
- import type { ComputedRef } from 'vue';
2
- import type { ButtonGroupProps } from '../components/ButtonGroup.vue.js';
3
- interface ButtonGroupInjectData {
4
- size: ButtonGroupProps['size'];
5
- orientation: ButtonGroupProps['orientation'];
6
- }
7
- export declare const InjectionKeyButtonGroup: import("vue").InjectionKey<ComputedRef<ButtonGroupInjectData>>, injectButtonGroup: () => ComputedRef<ButtonGroupInjectData> | undefined, provideButtonGroup: (value: ComputedRef<ButtonGroupInjectData>) => void;
8
- type UseButtonGroupProps = Pick<ButtonGroupProps, 'size'>;
9
- export declare function useButtonGroup(props?: UseButtonGroupProps): {
10
- size: ComputedRef<any>;
11
- orientation: ComputedRef<any>;
1
+ import type { ButtonProps } from '../types/index.js';
2
+ export declare function useButtonGroup(props?: Pick<ButtonProps, 'size'>): {
3
+ size: import("vue").ComputedRef<any>;
4
+ orientation: import("vue").ComputedRef<any>;
12
5
  };
13
- export {};
@@ -1,10 +1,5 @@
1
1
  import { computed } from "vue";
2
- import { defineInjection } from "./defineInjection.js";
3
- export const {
4
- InjectionKey: InjectionKeyButtonGroup,
5
- inject: injectButtonGroup,
6
- provide: provideButtonGroup
7
- } = defineInjection("ui.buttonGroup");
2
+ import { injectButtonGroup } from "../app/injections.js";
8
3
  export function useButtonGroup(props = {}) {
9
4
  const buttonGroup = injectButtonGroup();
10
5
  return {
@@ -1,15 +1,15 @@
1
1
  import { type MaybeRefOrGetter } from 'vue';
2
2
  export interface UseComponentIconsProps {
3
- /** Display an icon based on the `prefix` and `suffix` props. */
3
+ /** Display an icon based on the `leading` and `trailing` props. */
4
4
  icon?: string;
5
5
  /** When `true`, the icon will be displayed on the left side. */
6
- prefix?: boolean;
6
+ leading?: boolean;
7
7
  /** Display an icon on the left side. */
8
- prefixIcon?: string;
8
+ leadingIcon?: string;
9
9
  /** When `true`, the icon will be displayed on the right side. */
10
- suffix?: boolean;
10
+ trailing?: boolean;
11
11
  /** Display an icon on the right side. */
12
- suffixIcon?: string;
12
+ trailingIcon?: string;
13
13
  /** When `true`, the loading icon will be displayed. */
14
14
  loading?: boolean;
15
15
  /**
@@ -19,8 +19,8 @@ export interface UseComponentIconsProps {
19
19
  loadingIcon?: string;
20
20
  }
21
21
  export declare function useComponentIcons(componentProps: MaybeRefOrGetter<UseComponentIconsProps>): {
22
- isPrefix: import("vue").ComputedRef<boolean>;
23
- isSuffix: import("vue").ComputedRef<boolean>;
24
- prefixIconName: import("vue").ComputedRef<string | undefined>;
25
- suffixIconName: import("vue").ComputedRef<string | undefined>;
22
+ isLeading: import("vue").ComputedRef<boolean>;
23
+ isTrailing: import("vue").ComputedRef<boolean>;
24
+ leadingIconName: import("vue").ComputedRef<string | undefined>;
25
+ trailingIconName: import("vue").ComputedRef<string | undefined>;
26
26
  };
@@ -3,22 +3,22 @@ import { useTheme } from "./useTheme.js";
3
3
  export function useComponentIcons(componentProps) {
4
4
  const { theme } = useTheme();
5
5
  const props = computed(() => toValue(componentProps));
6
- const isPrefix = computed(() => props.value.icon && props.value.prefix || props.value.icon && !props.value.suffix || props.value.loading && !props.value.suffix || !!props.value.prefixIcon);
7
- const isSuffix = computed(() => props.value.icon && props.value.suffix || props.value.loading && props.value.suffix || !!props.value.suffixIcon);
8
- const prefixIconName = computed(() => {
6
+ const isLeading = computed(() => props.value.icon && props.value.leading || props.value.icon && !props.value.trailing || props.value.loading && !props.value.trailing || !!props.value.leadingIcon);
7
+ const isTrailing = computed(() => props.value.icon && props.value.trailing || props.value.loading && props.value.trailing || !!props.value.trailingIcon);
8
+ const leadingIconName = computed(() => {
9
9
  if (props.value.loading)
10
10
  return props.value.loadingIcon || theme.value.app.icons.loading;
11
- return props.value.prefixIcon || props.value.icon;
11
+ return props.value.leadingIcon || props.value.icon;
12
12
  });
13
- const suffixIconName = computed(() => {
14
- if (props.value.loading && !isPrefix.value)
13
+ const trailingIconName = computed(() => {
14
+ if (props.value.loading && !isLeading.value)
15
15
  return props.value.loadingIcon || theme.value.app.icons.loading;
16
- return props.value.suffixIcon || props.value.icon;
16
+ return props.value.trailingIcon || props.value.icon;
17
17
  });
18
18
  return {
19
- isPrefix,
20
- isSuffix,
21
- prefixIconName,
22
- suffixIconName
19
+ isLeading,
20
+ isTrailing,
21
+ leadingIconName,
22
+ trailingIconName
23
23
  };
24
24
  }
@@ -0,0 +1,35 @@
1
+ interface KbdKeysSpecificMap {
2
+ meta: string;
3
+ alt: string;
4
+ ctrl: string;
5
+ }
6
+ export declare const kbdKeysMap: {
7
+ meta: string;
8
+ ctrl: string;
9
+ alt: string;
10
+ win: string;
11
+ command: string;
12
+ shift: string;
13
+ option: string;
14
+ enter: string;
15
+ delete: string;
16
+ backspace: string;
17
+ escape: string;
18
+ tab: string;
19
+ capslock: string;
20
+ arrowup: string;
21
+ arrowright: string;
22
+ arrowdown: string;
23
+ arrowleft: string;
24
+ pageup: string;
25
+ pagedown: string;
26
+ home: string;
27
+ end: string;
28
+ };
29
+ export type KbdKey = keyof typeof kbdKeysMap;
30
+ export type KbdKeySpecific = keyof KbdKeysSpecificMap;
31
+ export declare const useKbd: () => {
32
+ macOS: import("vue").ComputedRef<false | "" | RegExpMatchArray | null | undefined>;
33
+ getKbdKey: (value?: KbdKey | (string & {})) => string | undefined;
34
+ };
35
+ export {};
@@ -0,0 +1,49 @@
1
+ import { createSharedComposable } from "@vueuse/core";
2
+ import { computed, onMounted, reactive } from "vue";
3
+ export const kbdKeysMap = {
4
+ meta: "",
5
+ ctrl: "",
6
+ alt: "",
7
+ win: "\u229E",
8
+ command: "\u2318",
9
+ shift: "\u21E7",
10
+ option: "\u2325",
11
+ enter: "\u21B5",
12
+ delete: "\u2326",
13
+ backspace: "\u232B",
14
+ escape: "\u238B",
15
+ tab: "\u21E5",
16
+ capslock: "\u21EA",
17
+ arrowup: "\u2191",
18
+ arrowright: "\u2192",
19
+ arrowdown: "\u2193",
20
+ arrowleft: "\u2190",
21
+ pageup: "\u21DE",
22
+ pagedown: "\u21DF",
23
+ home: "\u2196",
24
+ end: "\u2198"
25
+ };
26
+ export const useKbd = createSharedComposable(() => {
27
+ const macOS = computed(() => import.meta.client && navigator && navigator.userAgent && navigator.userAgent.match(/Macintosh;/));
28
+ const kbdKeysSpecificMap = reactive({
29
+ meta: " ",
30
+ alt: " ",
31
+ ctrl: " "
32
+ });
33
+ onMounted(() => {
34
+ kbdKeysSpecificMap.meta = macOS.value ? kbdKeysMap.command : kbdKeysMap.win;
35
+ kbdKeysSpecificMap.alt = macOS.value ? kbdKeysMap.option : "alt";
36
+ kbdKeysSpecificMap.ctrl = macOS.value ? "\u2303" : "ctrl";
37
+ });
38
+ function getKbdKey(value) {
39
+ if (!value)
40
+ return;
41
+ if (["meta", "alt", "ctrl"].includes(value))
42
+ return kbdKeysSpecificMap[value];
43
+ return kbdKeysMap[value] || value.toUpperCase();
44
+ }
45
+ return {
46
+ macOS,
47
+ getKbdKey
48
+ };
49
+ });
@@ -0,0 +1,8 @@
1
+ import type { Translator } from '../utils/translator.js';
2
+ export declare const useLocale: () => {
3
+ locale: import("vue").ComputedRef<import("../utils").Locale<import("..").Messages>>;
4
+ lang: import("vue").ComputedRef<string>;
5
+ code: import("vue").ComputedRef<string>;
6
+ dir: import("vue").ComputedRef<import("../utils").Direction>;
7
+ t: Translator<import("..").Messages>;
8
+ };
@@ -0,0 +1,22 @@
1
+ import { createSharedComposable } from "@vueuse/core";
2
+ import { computed, toValue } from "vue";
3
+ import { injectLocaleContext } from "../app/injections.js";
4
+ import localeDefault from "../locale/en.js";
5
+ import { createTranslator } from "../utils/index.js";
6
+ export const useLocale = createSharedComposable(() => {
7
+ const _locale = injectLocaleContext();
8
+ const locale = computed(() => toValue(_locale) ?? localeDefault);
9
+ const lang = computed(() => locale.value.name);
10
+ const code = computed(() => locale.value.code);
11
+ const dir = computed(() => locale.value.dir ?? "ltr");
12
+ const t = (path, options) => {
13
+ return createTranslator(toValue(locale))(path, options);
14
+ };
15
+ return {
16
+ locale,
17
+ lang,
18
+ code,
19
+ dir,
20
+ t
21
+ };
22
+ });
@@ -0,0 +1,29 @@
1
+ import type { Component } from 'vue';
2
+ import type { ComponentProps } from 'vue-component-type-helpers';
3
+ export interface OverlayOptions<ComponentProps = Record<string, any>> {
4
+ defaultOpen?: boolean;
5
+ props?: ComponentProps;
6
+ unmountOnHide?: boolean;
7
+ }
8
+ interface _ComponentState<T extends Component> {
9
+ component?: T;
10
+ id: string | number;
11
+ isMounted: boolean;
12
+ modelValue: boolean;
13
+ resolve?: (value: unknown) => void;
14
+ }
15
+ export type OverlayComponentState = OverlayOptions<Component> & _ComponentState<Component>;
16
+ export interface OverlayComponentInstance<T> {
17
+ open: (props?: ComponentProps<T>) => Promise<any>;
18
+ close: (value?: any) => void;
19
+ patch: (props: Partial<ComponentProps<T>>) => void;
20
+ }
21
+ export declare const useOverlay: () => {
22
+ overlays: import("vue").ShallowReactive<OverlayComponentState[]>;
23
+ open: <T extends Component>(id: OverlayComponentState["id"], props?: ComponentProps<T>) => Promise<any>;
24
+ close: (id: OverlayComponentState["id"], value?: any) => void;
25
+ create: <T extends Component>(component: T, options?: OverlayOptions<ComponentProps<T>>) => OverlayComponentInstance<T>;
26
+ patch: <T extends Component>(id: OverlayComponentState["id"], props: Partial<ComponentProps<T>>) => void;
27
+ unmount: (id: OverlayComponentState["id"]) => void;
28
+ };
29
+ export {};
@@ -0,0 +1,69 @@
1
+ import { createSharedComposable } from "@vueuse/core";
2
+ import { markRaw, reactive, shallowReactive } from "vue";
3
+ export const useOverlay = createSharedComposable(() => {
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),
12
+ isMounted: defaultOpen,
13
+ unmountOnHide,
14
+ props
15
+ });
16
+ overlays.push(state);
17
+ return {
18
+ open: (props2) => open(state.id, props2),
19
+ close: (value) => close(state.id, value),
20
+ patch: (props2) => patch(state.id, props2)
21
+ };
22
+ }
23
+ function open(id, props) {
24
+ const overlay = getOverlay(id);
25
+ if (props)
26
+ patch(id, props);
27
+ overlay.modelValue = true;
28
+ overlay.isMounted = true;
29
+ return new Promise((resolve) => {
30
+ overlay.resolve = resolve;
31
+ });
32
+ }
33
+ function close(id, value) {
34
+ const overlay = getOverlay(id);
35
+ overlay.modelValue = false;
36
+ if (overlay.resolve) {
37
+ overlay.resolve(value);
38
+ overlay.resolve = void 0;
39
+ }
40
+ }
41
+ function unmount(id) {
42
+ const overlay = getOverlay(id);
43
+ overlay.isMounted = false;
44
+ if (overlay.unmountOnHide) {
45
+ const index = overlays.findIndex((item) => item.id === id);
46
+ overlays.splice(index, 1);
47
+ }
48
+ }
49
+ function patch(id, props) {
50
+ const overlay = getOverlay(id);
51
+ Object.entries(props).forEach(([key, value]) => {
52
+ overlay.props[key] = value;
53
+ });
54
+ }
55
+ function getOverlay(id) {
56
+ const item = overlays.find((item2) => item2.id === id);
57
+ if (!item)
58
+ throw new Error("Overlay not found");
59
+ return item;
60
+ }
61
+ return {
62
+ overlays,
63
+ open,
64
+ close,
65
+ create,
66
+ patch,
67
+ unmount
68
+ };
69
+ });
@@ -1,9 +1,9 @@
1
- import type { UserConfig } from '@unocss/core';
2
- import type { MaybeRefOrGetter } from 'vue';
3
- import * as theme from '../theme/index.js';
4
- export declare const InjectionKeyThemeExtension: import("vue").InjectionKey<MaybeRefOrGetter<import("..").PartialTheme<typeof theme>>>, provideThemeExtension: (value: MaybeRefOrGetter<import("..").PartialTheme<typeof theme>>) => void, injectThemeExtension: () => MaybeRefOrGetter<import("..").PartialTheme<typeof theme>>;
5
- export declare const InjectionKeyUnoConfig: import("vue").InjectionKey<UserConfig<object>>, provideUnoConfig: (value: UserConfig<object>) => void, injectUnoConfig: () => UserConfig<object>;
1
+ import * as uiTheme from '../theme/index.js';
2
+ import type { StylerProps, StylerReturnType, StylerTheme } from '../types/index.js';
3
+ type UITheme = typeof uiTheme;
6
4
  export declare const useTheme: () => {
7
- theme: import("vue").ComputedRef<typeof theme>;
5
+ theme: import("vue").ComputedRef<typeof uiTheme>;
8
6
  createStyler: <V extends import("@byyuurin/ui-kit").CVVariants<S, B>, CV extends import("@byyuurin/ui-kit").CVCompoundVariants<V, S, B>, DV extends import("@byyuurin/ui-kit").CVDefaultVariants<V, S>, B extends import("@byyuurin/ui-kit").ClassValue = undefined, S extends import("@byyuurin/ui-kit").CVSlots = undefined>(theme: import("@byyuurin/ui-kit").CVMeta<V, CV, DV, B, S>) => [keyof V] extends string[] ? (props: import("@byyuurin/ui-kit").VariantProps<import("@byyuurin/ui-kit").CVReturnType<V, S, B>> & import("..").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit").CVHandler<V, S, string>; } : (props?: import("..").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit").CVHandler<V, S, string>; };
7
+ generateStyle: <T extends keyof UITheme>(name: T, props?: StylerProps<UITheme[T]>) => StylerReturnType<StylerTheme<UITheme[T]>>;
9
8
  };
9
+ export {};
@@ -1,26 +1,22 @@
1
1
  import { transformUnoRules } from "@byyuurin/ui/unocss";
2
2
  import { createSharedComposable } from "@vueuse/core";
3
3
  import { computed, toValue } from "vue";
4
- import * as theme from "../theme/index.js";
4
+ import { injectThemeExtension, injectUnoConfig } from "../app/injections.js";
5
+ import * as uiTheme from "../theme/index.js";
5
6
  import { extendTheme, prepareStyler } from "../utils/index.js";
6
- import { defineInjection } from "./defineInjection.js";
7
- export const {
8
- InjectionKey: InjectionKeyThemeExtension,
9
- provide: provideThemeExtension,
10
- inject: injectThemeExtension
11
- } = defineInjection("ui.themeExtension", {});
12
- export const {
13
- InjectionKey: InjectionKeyUnoConfig,
14
- provide: provideUnoConfig,
15
- inject: injectUnoConfig
16
- } = defineInjection("ui.unoConfig", {});
17
7
  export const useTheme = createSharedComposable(() => {
18
8
  const themeExtension = injectThemeExtension();
19
9
  const unoConfig = injectUnoConfig();
20
- const mergeRules = transformUnoRules(unoConfig);
10
+ const mergeRules = transformUnoRules(toValue(unoConfig));
21
11
  const { createStyler } = prepareStyler(mergeRules);
12
+ const theme = computed(() => extendTheme(toValue(themeExtension), uiTheme));
13
+ function generateStyle(name, props) {
14
+ const styler = createStyler(theme.value[name]);
15
+ return styler(props);
16
+ }
22
17
  return {
23
- theme: computed(() => extendTheme(toValue(themeExtension), theme)),
24
- createStyler
18
+ theme,
19
+ createStyler,
20
+ generateStyle
25
21
  };
26
22
  });