@byyuurin/ui 0.0.8 → 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 (111) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +4 -3
  3. package/dist/module.mjs.map +1 -1
  4. package/dist/runtime/app/injections.d.ts +2 -7
  5. package/dist/runtime/app/injections.js +0 -5
  6. package/dist/runtime/components/Accordion.vue +10 -8
  7. package/dist/runtime/components/Alert.vue +5 -8
  8. package/dist/runtime/components/App.vue +14 -19
  9. package/dist/runtime/components/Avatar.vue +5 -8
  10. package/dist/runtime/components/AvatarGroup.vue +2 -5
  11. package/dist/runtime/components/Badge.vue +2 -5
  12. package/dist/runtime/components/Breadcrumb.vue +11 -8
  13. package/dist/runtime/components/Button.vue +2 -3
  14. package/dist/runtime/components/ButtonGroup.vue +2 -5
  15. package/dist/runtime/components/Calendar.vue +176 -0
  16. package/dist/runtime/components/Card.vue +2 -5
  17. package/dist/runtime/components/Carousel.vue +6 -13
  18. package/dist/runtime/components/Checkbox.vue +2 -5
  19. package/dist/runtime/components/Chip.vue +6 -9
  20. package/dist/runtime/components/Collapsible.vue +2 -5
  21. package/dist/runtime/components/Drawer.vue +80 -37
  22. package/dist/runtime/components/Input.vue +10 -13
  23. package/dist/runtime/components/InputNumber.vue +2 -5
  24. package/dist/runtime/components/Kbd.vue +2 -6
  25. package/dist/runtime/components/Link.vue +8 -5
  26. package/dist/runtime/components/Modal.vue +20 -11
  27. package/dist/runtime/components/OverlayProvider.vue +29 -0
  28. package/dist/runtime/components/Pagination.vue +34 -27
  29. package/dist/runtime/components/PinInput.vue +2 -5
  30. package/dist/runtime/components/Popover.vue +2 -5
  31. package/dist/runtime/components/Progress.vue +2 -5
  32. package/dist/runtime/components/RadioGroup.vue +6 -7
  33. package/dist/runtime/components/ScrollArea.vue +2 -6
  34. package/dist/runtime/components/Select.vue +10 -13
  35. package/dist/runtime/components/Separator.vue +2 -6
  36. package/dist/runtime/components/Skeleton.vue +2 -5
  37. package/dist/runtime/components/Slider.vue +2 -5
  38. package/dist/runtime/components/Switch.vue +6 -5
  39. package/dist/runtime/components/Table.vue +2 -5
  40. package/dist/runtime/components/Tabs.vue +2 -5
  41. package/dist/runtime/components/Textarea.vue +2 -5
  42. package/dist/runtime/components/Toast.vue +7 -11
  43. package/dist/runtime/components/{Toaster.vue → ToastProvider.vue} +18 -16
  44. package/dist/runtime/components/Tooltip.vue +2 -5
  45. package/dist/runtime/composables/useKbd.d.ts +1 -1
  46. package/dist/runtime/composables/useOverlay.d.ts +29 -0
  47. package/dist/runtime/composables/useOverlay.js +69 -0
  48. package/dist/runtime/composables/useTheme.d.ts +6 -2
  49. package/dist/runtime/composables/useTheme.js +9 -3
  50. package/dist/runtime/composables/useToast.d.ts +4 -20
  51. package/dist/runtime/composables/useToast.js +6 -5
  52. package/dist/runtime/index.d.ts +3 -2
  53. package/dist/runtime/index.js +3 -2
  54. package/dist/runtime/locale/en.js +6 -0
  55. package/dist/runtime/locale/zh-tw.js +6 -0
  56. package/dist/runtime/theme/accordion.js +3 -3
  57. package/dist/runtime/theme/alert.js +3 -3
  58. package/dist/runtime/theme/avatar.js +2 -2
  59. package/dist/runtime/theme/breadcrumb.js +5 -5
  60. package/dist/runtime/theme/button.js +13 -13
  61. package/dist/runtime/theme/calendar.d.ts +56 -0
  62. package/dist/runtime/theme/calendar.js +69 -0
  63. package/dist/runtime/theme/card.js +6 -6
  64. package/dist/runtime/theme/carousel.js +1 -1
  65. package/dist/runtime/theme/checkbox.js +5 -5
  66. package/dist/runtime/theme/chip.js +3 -3
  67. package/dist/runtime/theme/drawer.d.ts +24 -21
  68. package/dist/runtime/theme/drawer.js +46 -19
  69. package/dist/runtime/theme/index.d.ts +2 -1
  70. package/dist/runtime/theme/index.js +2 -1
  71. package/dist/runtime/theme/input-number.js +1 -1
  72. package/dist/runtime/theme/input.js +14 -14
  73. package/dist/runtime/theme/kbd.d.ts +2 -2
  74. package/dist/runtime/theme/kbd.js +1 -1
  75. package/dist/runtime/theme/link.d.ts +1 -1
  76. package/dist/runtime/theme/link.js +3 -3
  77. package/dist/runtime/theme/modal.js +4 -4
  78. package/dist/runtime/theme/pagination.d.ts +27 -3
  79. package/dist/runtime/theme/pagination.js +6 -2
  80. package/dist/runtime/theme/pinInput.js +13 -13
  81. package/dist/runtime/theme/progress.js +4 -4
  82. package/dist/runtime/theme/radio-group.d.ts +2 -2
  83. package/dist/runtime/theme/radio-group.js +7 -7
  84. package/dist/runtime/theme/select.js +20 -20
  85. package/dist/runtime/theme/separator.js +1 -1
  86. package/dist/runtime/theme/skeleton.d.ts +1 -1
  87. package/dist/runtime/theme/skeleton.js +1 -1
  88. package/dist/runtime/theme/slider.js +1 -1
  89. package/dist/runtime/theme/switch.js +5 -5
  90. package/dist/runtime/theme/table.js +7 -7
  91. package/dist/runtime/theme/tabs.js +10 -10
  92. package/dist/runtime/theme/textarea.js +13 -13
  93. package/dist/runtime/theme/toast.js +5 -5
  94. package/dist/runtime/theme/tooltip.js +1 -1
  95. package/dist/runtime/types/components.d.ts +3 -1
  96. package/dist/runtime/types/locale.d.ts +6 -0
  97. package/dist/runtime/types/utils.d.ts +4 -2
  98. package/dist/shared/ui.1a1f119c.mjs +5 -0
  99. package/dist/shared/ui.1a1f119c.mjs.map +1 -0
  100. package/dist/unocss.mjs +19 -14
  101. package/dist/unocss.mjs.map +1 -1
  102. package/dist/unplugin.mjs +1 -1
  103. package/dist/vite.mjs +1 -1
  104. package/package.json +9 -9
  105. package/dist/runtime/components/ModalProvider.vue +0 -11
  106. package/dist/runtime/composables/useModal.d.ts +0 -10
  107. package/dist/runtime/composables/useModal.js +0 -47
  108. package/dist/shared/ui.ba24b380.mjs +0 -4
  109. package/dist/shared/ui.ba24b380.mjs.map +0 -1
  110. /package/dist/runtime/theme/{toaster.d.ts → toast-provider.d.ts} +0 -0
  111. /package/dist/runtime/theme/{toaster.js → toast-provider.js} +0 -0
@@ -124,27 +124,24 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen'
124
124
  const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as SelectContentProps)
125
125
  const arrowProps = toRef(() => props.arrow as SelectArrowProps)
126
126
 
127
- const { theme, createStyler } = useTheme()
127
+ const { theme, generateStyle } = useTheme()
128
128
 
129
129
  const { size, orientation } = useButtonGroup(props)
130
130
  const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(props, {
131
131
  trailingIcon: theme.value.app.icons.chevronDown,
132
132
  })))
133
133
 
134
+ const style = computed(() => generateStyle('select', {
135
+ ...props,
136
+ size: size.value,
137
+ groupOrientation: orientation.value,
138
+ leading: isLeading.value,
139
+ trailing: isTrailing.value,
140
+ }))
141
+
134
142
  const groups = computed(() => props.options?.length ? (Array.isArray(props.options[0]) ? props.options : [props.options]) as SelectOption[][] : [])
135
143
  const items = computed(() => groups.value.flat() as T[])
136
144
 
137
- const style = computed(() => {
138
- const styler = createStyler(theme.value.select)
139
- return styler({
140
- ...props,
141
- size: size.value,
142
- groupOrientation: orientation.value,
143
- leading: isLeading.value,
144
- trailing: isTrailing.value,
145
- })
146
- })
147
-
148
145
  function typedItem(item: SelectOption) {
149
146
  return item as unknown as T
150
147
  }
@@ -162,7 +159,7 @@ function displayValue(value?: MaybeArray<AcceptableValue>): string | undefined {
162
159
  return value.map((v) => displayValue(v)).filter(Boolean).join(', ')
163
160
 
164
161
  const item = items.value.find((item) => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
165
- return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
162
+ return (item != null) && (typeof item === 'object' ? get(item, props.labelKey as string) : item.toString())
166
163
  }
167
164
 
168
165
  function onUpdate(value: any) {
@@ -37,12 +37,8 @@ const slots = defineSlots<SeparatorSlots>()
37
37
 
38
38
  const rootProps = useForwardProps(reactivePick(props, 'as', 'decorative', 'orientation'))
39
39
 
40
- const { theme, createStyler } = useTheme()
41
-
42
- const style = computed(() => {
43
- const styler = createStyler(theme.value.separator)
44
- return styler(props)
45
- })
40
+ const { generateStyle } = useTheme()
41
+ const style = computed(() => generateStyle('separator', props))
46
42
  </script>
47
43
 
48
44
  <template>
@@ -19,11 +19,8 @@ import { useTheme } from '../composables/useTheme'
19
19
 
20
20
  const props = withDefaults(defineProps<SkeletonProps>(), {})
21
21
 
22
- const { theme, createStyler } = useTheme()
23
- const styler = computed(() => {
24
- const styler = createStyler(theme.value.skeleton)
25
- return styler(props)
26
- })
22
+ const { generateStyle } = useTheme()
23
+ const styler = computed(() => generateStyle('skeleton', props))
27
24
  </script>
28
25
 
29
26
  <template>
@@ -63,11 +63,8 @@ const sliderValue = computed({
63
63
 
64
64
  const thumbsCount = computed(() => sliderValue.value?.length ?? 1)
65
65
 
66
- const { theme, createStyler } = useTheme()
67
- const style = computed(() => {
68
- const styler = createStyler(theme.value.slider)
69
- return styler(props)
70
- })
66
+ const { generateStyle } = useTheme()
67
+ const style = computed(() => generateStyle('slider', props))
71
68
 
72
69
  function onChange(value: any) {
73
70
  // @ts-expect-error - 'target' does not exist in type 'EventInit'
@@ -47,11 +47,12 @@ const modelValue = defineModel<boolean>({ default: undefined })
47
47
  const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
48
48
  const id = useId()
49
49
 
50
- const { theme, createStyler } = useTheme()
51
- const style = computed(() => {
52
- const styler = createStyler(theme.value.switch)
53
- return styler({ ...props, checked: false, unchecked: false })
54
- })
50
+ const { theme, generateStyle } = useTheme()
51
+ const style = computed(() => generateStyle('switch', {
52
+ ...props,
53
+ checked: false,
54
+ unchecked: false,
55
+ }))
55
56
 
56
57
  function onUpdate(value: any) {
57
58
  // @ts-expect-error - 'target' does not exist in type 'EventInit'
@@ -229,11 +229,8 @@ function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
229
229
  }
230
230
 
231
231
  const { t } = useLocale()
232
- const { theme, createStyler } = useTheme()
233
- const style = computed(() => {
234
- const styler = createStyler(theme.value.table)
235
- return styler(props)
236
- })
232
+ const { generateStyle } = useTheme()
233
+ const style = computed(() => generateStyle('table', props))
237
234
 
238
235
  defineExpose({
239
236
  tableApi,
@@ -73,11 +73,8 @@ const slots = defineSlots<TabsSlots<T>>()
73
73
 
74
74
  const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emit)
75
75
 
76
- const { theme, createStyler } = useTheme()
77
- const style = computed(() => {
78
- const styler = createStyler(theme.value.tabs)
79
- return styler(props)
80
- })
76
+ const { generateStyle } = useTheme()
77
+ const style = computed(() => generateStyle('tabs', props))
81
78
  </script>
82
79
 
83
80
  <template>
@@ -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)
@@ -61,14 +61,11 @@ const el = ref<InstanceType<typeof ToastRoot>>()
61
61
  const { height } = useElementBounding(() => el.value?.$el.getBoundingClientRect ? el.value.$el : undefined)
62
62
 
63
63
  const { t } = useLocale()
64
- const { theme, createStyler } = useTheme()
65
- const style = computed(() => {
66
- const styler = createStyler(theme.value.toast)
67
- return styler({
68
- ...props,
69
- title: !!(props.title || slots.title),
70
- })
71
- })
64
+ const { theme, generateStyle } = useTheme()
65
+ const style = computed(() => generateStyle('toast', {
66
+ ...props,
67
+ title: !!(props.title || slots.title),
68
+ }))
72
69
 
73
70
  defineExpose({
74
71
  height,
@@ -108,7 +105,7 @@ defineExpose({
108
105
  </div>
109
106
  </div>
110
107
 
111
- <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 })">
112
109
  <template v-if="props.orientation === 'horizontal'">
113
110
  <slot name="actions">
114
111
  <ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
@@ -117,10 +114,9 @@ defineExpose({
117
114
  </slot>
118
115
  </template>
119
116
 
120
- <ToastClose as-child>
117
+ <ToastClose v-if="props.close || slots.close" as-child>
121
118
  <slot name="close" :ui="ui">
122
119
  <Button
123
- v-if="props.close"
124
120
  :icon="props.closeIcon || theme.app.icons.close"
125
121
  size="sm"
126
122
  variant="link"
@@ -1,16 +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
+
7
+ export interface ToastState extends Omit<ToastProps, 'defaultOpen'> {
8
+ id: string | number
9
+ onClick?: (toast: ToastState) => void
10
+ }
6
11
 
7
12
  export interface ToasterSlots {
8
13
  default?: (props?: {}) => any
9
14
  }
10
15
 
11
- type ToasterVariants = VariantProps<typeof toaster>
16
+ type ToasterVariants = VariantProps<typeof toastProvider>
12
17
 
13
- export interface ToasterProps extends ComponentAttrs<typeof toaster>, Omit<ToastProviderProps, 'swipeDirection'> {
18
+ export interface ToastProviderProps extends ComponentAttrs<typeof toastProvider>, Omit<RekaToastProviderProps, 'swipeDirection'> {
14
19
  /** @default "bottom-right" */
15
20
  position?: ToasterVariants['position']
16
21
  /**
@@ -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)
@@ -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>
@@ -29,7 +29,7 @@ export declare const kbdKeysMap: {
29
29
  export type KbdKey = keyof typeof kbdKeysMap;
30
30
  export type KbdKeySpecific = keyof KbdKeysSpecificMap;
31
31
  export declare const useKbd: () => {
32
- macOS: import("vue").ComputedRef<any>;
32
+ macOS: import("vue").ComputedRef<false | "" | RegExpMatchArray | null | undefined>;
33
33
  getKbdKey: (value?: KbdKey | (string & {})) => string | undefined;
34
34
  };
35
35
  export {};
@@ -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,5 +1,9 @@
1
- import * as theme from '../theme/index.js';
1
+ import * as uiTheme from '../theme/index.js';
2
+ import type { StylerProps, StylerReturnType, StylerTheme } from '../types/index.js';
3
+ type UITheme = typeof uiTheme;
2
4
  export declare const useTheme: () => {
3
- theme: import("vue").ComputedRef<typeof theme>;
5
+ theme: import("vue").ComputedRef<typeof uiTheme>;
4
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]>>;
5
8
  };
9
+ export {};
@@ -2,15 +2,21 @@ import { transformUnoRules } from "@byyuurin/ui/unocss";
2
2
  import { createSharedComposable } from "@vueuse/core";
3
3
  import { computed, toValue } from "vue";
4
4
  import { injectThemeExtension, injectUnoConfig } from "../app/injections.js";
5
- import * as theme from "../theme/index.js";
5
+ import * as uiTheme from "../theme/index.js";
6
6
  import { extendTheme, prepareStyler } from "../utils/index.js";
7
7
  export const useTheme = createSharedComposable(() => {
8
8
  const themeExtension = injectThemeExtension();
9
9
  const unoConfig = injectUnoConfig();
10
10
  const mergeRules = transformUnoRules(toValue(unoConfig));
11
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
+ }
12
17
  return {
13
- theme: computed(() => extendTheme(toValue(themeExtension), theme)),
14
- createStyler
18
+ theme,
19
+ createStyler,
20
+ generateStyle
15
21
  };
16
22
  });
@@ -1,24 +1,8 @@
1
- import type { ToastProps } from '../types/index.js';
2
- export interface Toast extends Omit<ToastProps, 'defaultOpen'> {
3
- id: string | number;
4
- onClick?: (toast: Toast) => void;
5
- }
1
+ import type { ToastState } from '../types/index.js';
6
2
  export declare const useToast: () => {
7
- toasts: import("vue").Ref<{
8
- [x: string]: any;
9
- [x: number]: any;
10
- [x: symbol]: ToastProps;
11
- id: string | number;
12
- onClick?: ((toast: Toast) => void) | undefined;
13
- }[], Toast[] | {
14
- [x: string]: any;
15
- [x: number]: any;
16
- [x: symbol]: ToastProps;
17
- id: string | number;
18
- onClick?: ((toast: Toast) => void) | undefined;
19
- }[]>;
20
- add: (toast: Partial<Toast>) => Toast;
21
- update: (id: string | number, toast: Partial<Omit<Toast, "id">>) => void;
3
+ toasts: import("vue").Ref<ToastState[], ToastState[]>;
4
+ add: (toast: Partial<ToastState>) => ToastState;
5
+ update: (id: string | number, toast: Partial<Omit<ToastState, "id">>) => void;
22
6
  remove: (id: string | number) => void;
23
7
  clear: () => void;
24
8
  };
@@ -1,11 +1,12 @@
1
1
  import { createSharedComposable } from "@vueuse/core";
2
2
  import { nextTick, ref } from "vue";
3
+ import { useState } from "#imports";
3
4
  export const useToast = createSharedComposable(() => {
4
- const toasts = ref([]);
5
+ const toasts = useState("toasts", () => []);
5
6
  const running = ref(false);
6
7
  const maxToasts = 5;
7
8
  const queue = [];
8
- const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
9
+ const generateId = () => `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
9
10
  async function processQueue() {
10
11
  if (running.value || queue.length === 0)
11
12
  return;
@@ -28,7 +29,7 @@ export const useToast = createSharedComposable(() => {
28
29
  return body;
29
30
  }
30
31
  function update(id, toast) {
31
- const index = toasts.value.findIndex((t) => t.id === id);
32
+ const index = toasts.value.findIndex((toast2) => toast2.id === id);
32
33
  if (index === -1)
33
34
  return;
34
35
  toasts.value[index] = {
@@ -37,7 +38,7 @@ export const useToast = createSharedComposable(() => {
37
38
  };
38
39
  }
39
40
  function remove(id) {
40
- const index = toasts.value.findIndex((t) => t.id === id);
41
+ const index = toasts.value.findIndex((toast) => toast.id === id);
41
42
  if (index === -1)
42
43
  return;
43
44
  toasts.value[index] = {
@@ -45,7 +46,7 @@ export const useToast = createSharedComposable(() => {
45
46
  open: false
46
47
  };
47
48
  setTimeout(() => {
48
- toasts.value = toasts.value.filter((t) => t.id !== id);
49
+ toasts.value = toasts.value.filter((toast) => toast.id !== id);
49
50
  }, 200);
50
51
  }
51
52
  function clear() {
@@ -7,6 +7,7 @@ export { default as Badge } from './components/Badge.vue.js';
7
7
  export { default as Breadcrumb } from './components/Breadcrumb.vue.js';
8
8
  export { default as Button } from './components/Button.vue.js';
9
9
  export { default as ButtonGroup } from './components/ButtonGroup.vue.js';
10
+ export { default as Calendar } from './components/Calendar.vue.js';
10
11
  export { default as Card } from './components/Card.vue.js';
11
12
  export { default as Carousel } from './components/Carousel.vue.js';
12
13
  export { default as Checkbox } from './components/Checkbox.vue.js';
@@ -19,7 +20,7 @@ export { default as Kbd } from './components/Kbd.vue.js';
19
20
  export { default as Link } from './components/Link.vue.js';
20
21
  export { default as LinkBase } from './components/LinkBase.vue.js';
21
22
  export { default as Modal } from './components/Modal.vue.js';
22
- export { default as ModalProvider } from './components/ModalProvider.vue.js';
23
+ export { default as OverlayProvider } from './components/OverlayProvider.vue.js';
23
24
  export { default as Pagination } from './components/Pagination.vue.js';
24
25
  export { default as PinInput } from './components/PinInput.vue.js';
25
26
  export { default as Popover } from './components/Popover.vue.js';
@@ -35,6 +36,6 @@ export { default as Table } from './components/Table.vue.js';
35
36
  export { default as Tabs } from './components/Tabs.vue.js';
36
37
  export { default as Textarea } from './components/Textarea.vue.js';
37
38
  export { default as Toast } from './components/Toast.vue.js';
38
- export { default as Toaster } from './components/Toaster.vue.js';
39
+ export { default as ToastProvider } from './components/ToastProvider.vue.js';
39
40
  export { default as Tooltip } from './components/Tooltip.vue.js';
40
41
  export * from './types/index.js';
@@ -7,6 +7,7 @@ export { default as Badge } from "./components/Badge.vue";
7
7
  export { default as Breadcrumb } from "./components/Breadcrumb.vue";
8
8
  export { default as Button } from "./components/Button.vue";
9
9
  export { default as ButtonGroup } from "./components/ButtonGroup.vue";
10
+ export { default as Calendar } from "./components/Calendar.vue";
10
11
  export { default as Card } from "./components/Card.vue";
11
12
  export { default as Carousel } from "./components/Carousel.vue";
12
13
  export { default as Checkbox } from "./components/Checkbox.vue";
@@ -19,7 +20,7 @@ export { default as Kbd } from "./components/Kbd.vue";
19
20
  export { default as Link } from "./components/Link.vue";
20
21
  export { default as LinkBase } from "./components/LinkBase.vue";
21
22
  export { default as Modal } from "./components/Modal.vue";
22
- export { default as ModalProvider } from "./components/ModalProvider.vue";
23
+ export { default as OverlayProvider } from "./components/OverlayProvider.vue";
23
24
  export { default as Pagination } from "./components/Pagination.vue";
24
25
  export { default as PinInput } from "./components/PinInput.vue";
25
26
  export { default as Popover } from "./components/Popover.vue";
@@ -35,6 +36,6 @@ export { default as Table } from "./components/Table.vue";
35
36
  export { default as Tabs } from "./components/Tabs.vue";
36
37
  export { default as Textarea } from "./components/Textarea.vue";
37
38
  export { default as Toast } from "./components/Toast.vue";
38
- export { default as Toaster } from "./components/Toaster.vue";
39
+ export { default as ToastProvider } from "./components/ToastProvider.vue";
39
40
  export { default as Tooltip } from "./components/Tooltip.vue";
40
41
  export * from "./types/index.js";
@@ -6,6 +6,12 @@ export default defineLocale({
6
6
  alert: {
7
7
  close: "Close"
8
8
  },
9
+ calendar: {
10
+ prevYear: "Previous year",
11
+ nextYear: "Next year",
12
+ prevMonth: "Previous month",
13
+ nextMonth: "Next month"
14
+ },
9
15
  carousel: {
10
16
  prev: "Prev",
11
17
  next: "Next",
@@ -6,6 +6,12 @@ export default defineLocale({
6
6
  alert: {
7
7
  close: "\u95DC\u9589"
8
8
  },
9
+ calendar: {
10
+ prevYear: "\u53BB\u5E74",
11
+ nextYear: "\u660E\u5E74",
12
+ prevMonth: "\u4E0A\u500B\u6708",
13
+ nextMonth: "\u4E0B\u500B\u6708"
14
+ },
9
15
  carousel: {
10
16
  prev: "\u4E0A\u4E00\u9801",
11
17
  next: "\u4E0B\u4E00\u9801",
@@ -3,16 +3,16 @@ export default ct(
3
3
  /* @unocss-include */
4
4
  {
5
5
  slots: {
6
- root: "w-full color-ui-cb",
6
+ root: "w-full color-ui-base",
7
7
  item: "border-b last:border-b-0",
8
8
  header: "flex",
9
- trigger: "group flex-1 flex items-center gap-2 font-medium text-sm py-4 outline-none focus-visible:outline-ui-cb/80 min-w-0",
9
+ trigger: "group flex-1 flex items-center gap-2 font-medium text-sm py-4 outline-none focus-visible:outline-ui-base/80 min-w-0",
10
10
  content: [
11
11
  "overflow-hidden focus:outline-none",
12
12
  "data-[state=open]:animate-[accordion-down_200ms_ease-out]",
13
13
  "data-[state=closed]:animate-[accordion-up_200ms_ease-out]"
14
14
  ],
15
- body: "text-sm pb-4 color-ui-cb/80",
15
+ body: "text-sm pb-4 color-ui-base/80",
16
16
  leadingIcon: "shrink-0 size-5",
17
17
  trailingIcon: "shrink-0 size-5 ms-auto group-data-[state=open]:rotate-180 transition-all duration-200",
18
18
  label: "text-start break-words"
@@ -18,13 +18,13 @@ export default ct(
18
18
  close: "ui-base-inverted"
19
19
  },
20
20
  "outline": {
21
- root: "color-ui-content bg-ui-cx ring ring-inset ring-ui-fill/30"
21
+ root: "color-ui-fill bg-ui-base ring ring-inset ring-ui-fill/30"
22
22
  },
23
23
  "soft": {
24
- root: "color-ui-content bg-soft-ui-fill/10"
24
+ root: "color-ui-fill bg-soft-ui-fill/10"
25
25
  },
26
26
  "soft-outline": {
27
- root: "color-ui-content bg-soft-ui-fill/10 ring ring-inset ring-ui-fill/30"
27
+ root: "color-ui-fill bg-soft-ui-fill/10 ring ring-inset ring-ui-fill/30"
28
28
  }
29
29
  },
30
30
  orientation: {
@@ -5,8 +5,8 @@ export default ct(
5
5
  slots: {
6
6
  root: "inline-flex items-center justify-center shrink-0 select-none overflow-hidden rounded-full align-middle bg-soft-ui-cb/10",
7
7
  image: "size-full rounded-inherit object-cover",
8
- fallback: "leading-none color-ui-cb/60 truncate",
9
- icon: "size-3/4 color-ui-cb/60 shrink-0"
8
+ fallback: "leading-none color-ui-base/60 truncate",
9
+ icon: "size-3/4 color-ui-base/60 shrink-0"
10
10
  },
11
11
  variants: {
12
12
  size: {