@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
package/dist/module.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@byyuurin/ui",
3
+ "version": "0.0.9",
3
4
  "configKey": "ui",
4
5
  "compatibility": {
5
6
  "nuxt": ">=3.13.1"
6
7
  },
7
- "version": "0.0.8",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { defineNuxtModule, useLogger, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
- import { n as name } from './shared/ui.ba24b380.mjs';
1
+ import { defineNuxtModule, useLogger, createResolver, hasNuxtModule, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
+ import { n as name, v as version } from './shared/ui.1a1f119c.mjs';
3
3
 
4
4
  const module = defineNuxtModule({
5
5
  meta: {
6
6
  name: name,
7
+ version: version,
7
8
  configKey: "ui",
8
9
  compatibility: {
9
10
  nuxt: ">=3.13.1"
@@ -15,7 +16,7 @@ const module = defineNuxtModule({
15
16
  setup(options, nuxt) {
16
17
  const logger = useLogger(name);
17
18
  const { resolve } = createResolver(import.meta.url);
18
- if (!nuxt.options.modules.includes("@unocss/nuxt")) {
19
+ if (!hasNuxtModule("@unocss/nuxt")) {
19
20
  logger.error(`\`${name}\` requires the \`@unocss/nuxt\` module to be installed.`);
20
21
  return;
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","sources":["../src/module.ts"],"sourcesContent":["import { addComponentsDir, addImportsDir, createResolver, defineNuxtModule, useLogger } from '@nuxt/kit'\nimport { packageName } from './shared'\n\nexport interface ModuleOptions {\n /**\n * prefix for components used in templates\n *\n * @default \"U\"\n */\n prefix?: string\n}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: packageName,\n configKey: 'ui',\n compatibility: {\n nuxt: '>=3.13.1',\n },\n },\n defaults: {\n prefix: 'U',\n },\n setup(options, nuxt) {\n const logger = useLogger(packageName)\n const { resolve } = createResolver(import.meta.url)\n\n // Make sure the UnoCSS Nuxt module is installed\n if (!nuxt.options.modules.includes('@unocss/nuxt')) {\n logger.error(`\\`${packageName}\\` requires the \\`@unocss/nuxt\\` module to be installed.`)\n return\n }\n\n nuxt.options.vite.optimizeDeps ??= {}\n nuxt.options.vite.optimizeDeps.include ??= []\n nuxt.options.vite.optimizeDeps.include.push(`${packageName}/unocss`)\n\n nuxt.options.alias['#ui'] = resolve('./runtime')\n\n addComponentsDir({\n path: resolve('./runtime/components'),\n prefix: options.prefix,\n pathPrefix: false,\n })\n\n addImportsDir(resolve('./runtime/composables'))\n },\n})\n"],"names":["packageName"],"mappings":";;;AAYA,eAAe,gBAAgC,CAAA;AAAA,EAC7C,IAAM,EAAA;AAAA,IACJ,IAAM,EAAAA,IAAA;AAAA,IACN,SAAW,EAAA,IAAA;AAAA,IACX,aAAe,EAAA;AAAA,MACb,IAAM,EAAA,UAAA;AAAA,KACR;AAAA,GACF;AAAA,EACA,QAAU,EAAA;AAAA,IACR,MAAQ,EAAA,GAAA;AAAA,GACV;AAAA,EACA,KAAA,CAAM,SAAS,IAAM,EAAA;AACnB,IAAM,MAAA,MAAA,GAAS,UAAUA,IAAW,CAAA,CAAA;AACpC,IAAA,MAAM,EAAE,OAAA,EAAY,GAAA,cAAA,CAAe,YAAY,GAAG,CAAA,CAAA;AAGlD,IAAA,IAAI,CAAC,IAAK,CAAA,OAAA,CAAQ,OAAQ,CAAA,QAAA,CAAS,cAAc,CAAG,EAAA;AAClD,MAAO,MAAA,CAAA,KAAA,CAAM,CAAK,EAAA,EAAAA,IAAW,CAA0D,wDAAA,CAAA,CAAA,CAAA;AACvF,MAAA,OAAA;AAAA,KACF;AAEA,IAAK,IAAA,CAAA,OAAA,CAAQ,IAAK,CAAA,YAAA,KAAiB,EAAC,CAAA;AACpC,IAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,CAAK,YAAa,CAAA,OAAA,KAAY,EAAC,CAAA;AAC5C,IAAA,IAAA,CAAK,QAAQ,IAAK,CAAA,YAAA,CAAa,QAAQ,IAAK,CAAA,CAAA,EAAGA,IAAW,CAAS,OAAA,CAAA,CAAA,CAAA;AAEnE,IAAA,IAAA,CAAK,OAAQ,CAAA,KAAA,CAAM,KAAK,CAAA,GAAI,QAAQ,WAAW,CAAA,CAAA;AAE/C,IAAiB,gBAAA,CAAA;AAAA,MACf,IAAA,EAAM,QAAQ,sBAAsB,CAAA;AAAA,MACpC,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,UAAY,EAAA,KAAA;AAAA,KACb,CAAA,CAAA;AAED,IAAc,aAAA,CAAA,OAAA,CAAQ,uBAAuB,CAAC,CAAA,CAAA;AAAA,GAChD;AACF,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"module.mjs","sources":["../src/module.ts"],"sourcesContent":["import { addComponentsDir, addImportsDir, createResolver, defineNuxtModule, hasNuxtModule, useLogger } from '@nuxt/kit'\nimport { packageName, packageVersion } from './shared'\n\nexport interface ModuleOptions {\n /**\n * prefix for components used in templates\n *\n * @default \"U\"\n */\n prefix?: string\n}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: packageName,\n version: packageVersion,\n configKey: 'ui',\n compatibility: {\n nuxt: '>=3.13.1',\n },\n },\n defaults: {\n prefix: 'U',\n },\n setup(options, nuxt) {\n const logger = useLogger(packageName)\n const { resolve } = createResolver(import.meta.url)\n\n // Make sure the UnoCSS Nuxt module is installed\n if (!hasNuxtModule('@unocss/nuxt')) {\n logger.error(`\\`${packageName}\\` requires the \\`@unocss/nuxt\\` module to be installed.`)\n return\n }\n\n nuxt.options.vite.optimizeDeps ??= {}\n nuxt.options.vite.optimizeDeps.include ??= []\n nuxt.options.vite.optimizeDeps.include.push(`${packageName}/unocss`)\n\n nuxt.options.alias['#ui'] = resolve('./runtime')\n\n addComponentsDir({\n path: resolve('./runtime/components'),\n prefix: options.prefix,\n pathPrefix: false,\n })\n\n addImportsDir(resolve('./runtime/composables'))\n },\n})\n"],"names":["packageName","packageVersion"],"mappings":";;;AAYA,eAAe,gBAAgC,CAAA;AAAA,EAC7C,IAAM,EAAA;AAAA,IACJ,IAAM,EAAAA,IAAA;AAAA,IACN,OAAS,EAAAC,OAAA;AAAA,IACT,SAAW,EAAA,IAAA;AAAA,IACX,aAAe,EAAA;AAAA,MACb,IAAM,EAAA,UAAA;AAAA,KACR;AAAA,GACF;AAAA,EACA,QAAU,EAAA;AAAA,IACR,MAAQ,EAAA,GAAA;AAAA,GACV;AAAA,EACA,KAAA,CAAM,SAAS,IAAM,EAAA;AACnB,IAAM,MAAA,MAAA,GAAS,UAAUD,IAAW,CAAA,CAAA;AACpC,IAAA,MAAM,EAAE,OAAA,EAAY,GAAA,cAAA,CAAe,YAAY,GAAG,CAAA,CAAA;AAGlD,IAAI,IAAA,CAAC,aAAc,CAAA,cAAc,CAAG,EAAA;AAClC,MAAO,MAAA,CAAA,KAAA,CAAM,CAAK,EAAA,EAAAA,IAAW,CAA0D,wDAAA,CAAA,CAAA,CAAA;AACvF,MAAA,OAAA;AAAA,KACF;AAEA,IAAK,IAAA,CAAA,OAAA,CAAQ,IAAK,CAAA,YAAA,KAAiB,EAAC,CAAA;AACpC,IAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,CAAK,YAAa,CAAA,OAAA,KAAY,EAAC,CAAA;AAC5C,IAAA,IAAA,CAAK,QAAQ,IAAK,CAAA,YAAA,CAAa,QAAQ,IAAK,CAAA,CAAA,EAAGA,IAAW,CAAS,OAAA,CAAA,CAAA,CAAA;AAEnE,IAAA,IAAA,CAAK,OAAQ,CAAA,KAAA,CAAM,KAAK,CAAA,GAAI,QAAQ,WAAW,CAAA,CAAA;AAE/C,IAAiB,gBAAA,CAAA;AAAA,MACf,IAAA,EAAM,QAAQ,sBAAsB,CAAA;AAAA,MACpC,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,UAAY,EAAA,KAAA;AAAA,KACb,CAAA,CAAA;AAED,IAAc,aAAA,CAAA,OAAA,CAAQ,uBAAuB,CAAC,CAAA,CAAA;AAAA,GAChD;AACF,CAAC,CAAA;;;;"}
@@ -1,16 +1,11 @@
1
1
  import type { UserConfig } from '@unocss/core';
2
- import type { Component, ComputedRef, MaybeRefOrGetter, ShallowRef } from 'vue';
3
- import type { AvatarGroupProps, ButtonGroupProps, Messages, ModalProps } from '../types/index.js';
2
+ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
3
+ import type { AvatarGroupProps, ButtonGroupProps, Messages } from '../types/index.js';
4
4
  import type { Locale } from '../utils/index.js';
5
5
  export type AvatarGroupProvideValue = Pick<AvatarGroupProps, 'size'>;
6
6
  export declare const InjectionKeyAvatarGroup: import("vue").InjectionKey<ComputedRef<AvatarGroupProvideValue>>, injectAvatarGroup: () => ComputedRef<AvatarGroupProvideValue> | undefined, provideAvatarGroup: (value: ComputedRef<AvatarGroupProvideValue>) => void;
7
7
  export type ButtonGroupProvideValue = Pick<ButtonGroupProps, 'size' | 'orientation'>;
8
8
  export declare const InjectionKeyButtonGroup: import("vue").InjectionKey<ComputedRef<ButtonGroupProvideValue>>, injectButtonGroup: () => ComputedRef<ButtonGroupProvideValue> | undefined, provideButtonGroup: (value: ComputedRef<ButtonGroupProvideValue>) => void;
9
9
  export declare const InjectionKeyLocaleContext: import("vue").InjectionKey<MaybeRefOrGetter<Locale<Messages> | undefined>>, injectLocaleContext: () => MaybeRefOrGetter<Locale<Messages> | undefined>, provideLocaleContext: (value: MaybeRefOrGetter<Locale<Messages> | undefined>) => void;
10
- export interface ModalStateProvideValue {
11
- component: Component | string;
12
- props: ModalProps;
13
- }
14
- export declare const InjectionKeyModalState: import("vue").InjectionKey<ShallowRef<ModalStateProvideValue>>, injectModalState: () => ShallowRef<ModalStateProvideValue> | undefined, provideModalState: (value: ShallowRef<ModalStateProvideValue>) => void;
15
10
  export declare const InjectionKeyThemeExtension: import("vue").InjectionKey<MaybeRefOrGetter<import("..").PartialTheme<typeof import("../theme")>>>, provideThemeExtension: (value: MaybeRefOrGetter<import("..").PartialTheme<typeof import("../theme")>>) => void, injectThemeExtension: () => MaybeRefOrGetter<import("..").PartialTheme<typeof import("../theme")>>;
16
11
  export declare const InjectionKeyUnoConfig: import("vue").InjectionKey<MaybeRefOrGetter<UserConfig<object>>>, provideUnoConfig: (value: MaybeRefOrGetter<UserConfig<object>>) => void, injectUnoConfig: () => MaybeRefOrGetter<UserConfig<object>>;
@@ -14,11 +14,6 @@ export const {
14
14
  inject: injectLocaleContext,
15
15
  provide: provideLocaleContext
16
16
  } = defineInjection("ui.locale-context");
17
- export const {
18
- InjectionKey: InjectionKeyModalState,
19
- inject: injectModalState,
20
- provide: provideModalState
21
- } = defineInjection("ui.modal");
22
17
  export const {
23
18
  InjectionKey: InjectionKeyThemeExtension,
24
19
  provide: provideThemeExtension,
@@ -1,12 +1,17 @@
1
1
  <script lang="ts">
2
2
  import type { AccordionRootEmits, AccordionRootProps } from 'reka-ui'
3
3
  import type { accordion } from '../theme'
4
- import type { ComponentAttrs, DynamicSlots } from '../types'
4
+ import type { ComponentAttrs } from '../types'
5
5
 
6
6
  export interface AccordionEmits extends AccordionRootEmits {}
7
7
 
8
8
  type SlotProps<T> = (props: { item: T, index: number, open: boolean }) => any
9
9
 
10
+ type DynamicSlots<T extends { slot?: string }, SlotProps, Slot = T['slot']> =
11
+ Slot extends string
12
+ ? Record<Slot | `${Slot}-body`, SlotProps>
13
+ : Record<string, never>
14
+
10
15
  export type AccordionSlots<T extends { slot?: string }> = {
11
16
  default?: SlotProps<T>
12
17
  leading?: SlotProps<T>
@@ -55,11 +60,8 @@ const emit = defineEmits<AccordionEmits>()
55
60
  const slots = defineSlots<AccordionSlots<T>>()
56
61
  const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'collapsible', 'defaultValue', 'disabled', 'modelValue', 'type', 'unmountOnHide'), emit)
57
62
 
58
- const { theme, createStyler } = useTheme()
59
- const style = computed(() => {
60
- const styler = createStyler(theme.value.accordion)
61
- return styler(props)
62
- })
63
+ const { theme, generateStyle } = useTheme()
64
+ const style = computed(() => generateStyle('accordion', props))
63
65
  </script>
64
66
 
65
67
  <template>
@@ -89,12 +91,12 @@ const style = computed(() => {
89
91
  </AccordionHeader>
90
92
 
91
93
  <AccordionContent
92
- v-if="item.content || slots.content || (item.slot && slots[item.slot]) || slots.body || (slots[`${item.slot}-body`])"
94
+ v-if="item.content || slots.content || (item.slot && slots[item.slot]) || slots.body || (item.slot && slots[`${item.slot}-body`])"
93
95
  :class="style.content({ class: props.ui?.content })"
94
96
  >
95
97
  <slot :name="item.slot || 'content'" v-bind="{ item, index, open }">
96
98
  <div :class="style.body({ class: props.ui?.body })">
97
- <slot :name="item.slot ? item.slot : 'body'" v-bind="{ item, index, open }">
99
+ <slot :name="item.slot ? `${item.slot}-body` : 'body'" v-bind="{ item, index, open }">
98
100
  {{ item.content }}
99
101
  </slot>
100
102
  </div>
@@ -64,14 +64,11 @@ const emit = defineEmits<AlertEmits>()
64
64
  const slots = defineSlots<AlertSlots>()
65
65
 
66
66
  const { t } = useLocale()
67
- const { theme, createStyler } = useTheme()
68
- const style = computed(() => {
69
- const styler = createStyler(theme.value.alert)
70
- return styler({
71
- ...props,
72
- title: !!props.title || !!slots.title,
73
- })
74
- })
67
+ const { theme, generateStyle } = useTheme()
68
+ const style = computed(() => generateStyle('alert', {
69
+ ...props,
70
+ title: !!props.title || !!slots.title,
71
+ }))
75
72
  </script>
76
73
 
77
74
  <template>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { UserConfig } from '@unocss/core'
3
3
  import type { ConfigProviderProps, TooltipProviderProps } from 'reka-ui'
4
- import type { Messages, ThemeExtension, ToasterProps } from '../types'
4
+ import type { Messages, ThemeExtension, ToastProviderProps } from '../types'
5
5
  import type { Locale } from '../utils'
6
6
 
7
7
  export interface AppSlots {
@@ -11,7 +11,7 @@ export interface AppSlots {
11
11
  export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir' | 'locale'> {
12
12
  unoConfig?: UserConfig
13
13
  ui?: ThemeExtension
14
- toaster?: ToasterProps
14
+ toaster?: ToastProviderProps
15
15
  tooltip?: TooltipProviderProps
16
16
  locale?: Locale<Messages>
17
17
  }
@@ -20,11 +20,10 @@ export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir' | 'l
20
20
  <script setup lang="ts">
21
21
  import { reactivePick } from '@vueuse/core'
22
22
  import { ConfigProvider, TooltipProvider, useForwardProps } from 'reka-ui'
23
- import { shallowRef, toRef, useId } from 'vue'
24
- import type { ModalStateProvideValue } from '../app/injections'
25
- import { provideLocaleContext, provideModalState, provideThemeExtension, provideUnoConfig } from '../app/injections'
26
- import ModalProvider from './ModalProvider.vue'
27
- import Toaster from './Toaster.vue'
23
+ import { toRef, useId } from 'vue'
24
+ import { provideLocaleContext, provideThemeExtension, provideUnoConfig } from '../app/injections'
25
+ import OverlayProvider from './OverlayProvider.vue'
26
+ import ToastProvider from './ToastProvider.vue'
28
27
 
29
28
  const props = withDefaults(defineProps<AppProps>(), {
30
29
  unoConfig: () => ({}),
@@ -35,27 +34,23 @@ defineSlots<AppSlots>()
35
34
 
36
35
  const configProviderProps = useForwardProps(reactivePick(props, 'scrollBody'))
37
36
  const tooltipProps = toRef(() => props.tooltip)
38
- const toasterProps = toRef(() => props.toaster)
37
+ const toastProviderProps = toRef(() => props.toaster)
39
38
 
40
- const modalState = shallowRef<ModalStateProvideValue>({
41
- component: 'div',
42
- props: {},
43
- })
44
-
45
- provideModalState(modalState)
46
39
  provideUnoConfig(() => props.unoConfig)
47
40
  provideThemeExtension(() => props.ui)
48
- provideLocaleContext(() => props.locale)
41
+
42
+ const locale = toRef(() => props.locale)
43
+ provideLocaleContext(locale)
49
44
  </script>
50
45
 
51
46
  <template>
52
- <ConfigProvider :use-id="useId" v-bind="configProviderProps">
47
+ <ConfigProvider :use-id="useId" :dir="locale?.dir" :locale="locale?.code" v-bind="configProviderProps">
53
48
  <TooltipProvider v-bind="tooltipProps">
54
- <Toaster v-if="props.toaster !== null" v-bind="toasterProps">
49
+ <ToastProvider v-if="props.toaster !== null" v-bind="toastProviderProps">
55
50
  <slot></slot>
56
- </Toaster>
51
+ </ToastProvider>
57
52
  <slot v-else></slot>
58
53
  </TooltipProvider>
59
- <ModalProvider />
54
+ <OverlayProvider />
60
55
  </ConfigProvider>
61
56
  </template>
@@ -40,14 +40,11 @@ const props = withDefaults(defineProps<AvatarProps>(), {
40
40
  const { size } = useAvatarGroup(props)
41
41
  const fallback = computed(() => props.text || (props.alt || '').split(' ').map((word) => word.charAt(0)).join('').slice(0, 2))
42
42
 
43
- const { theme, createStyler } = useTheme()
44
- const style = computed(() => {
45
- const styler = createStyler(theme.value.avatar)
46
- return styler({
47
- ...props,
48
- size: size.value,
49
- })
50
- })
43
+ const { generateStyle } = useTheme()
44
+ const style = computed(() => generateStyle('avatar', {
45
+ ...props,
46
+ size: size.value,
47
+ }))
51
48
 
52
49
  const error = shallowRef(false)
53
50
 
@@ -73,11 +73,8 @@ const hiddenCount = computed(() => {
73
73
  return children.value.length - visibleAvatars.value.length
74
74
  })
75
75
 
76
- const { theme, createStyler } = useTheme()
77
- const style = computed(() => {
78
- const styler = createStyler(theme.value.avatarGroup)
79
- return styler(props)
80
- })
76
+ const { generateStyle } = useTheme()
77
+ const style = computed(() => generateStyle('avatarGroup', props))
81
78
 
82
79
  provideAvatarGroup(computed(() => props))
83
80
  </script>
@@ -50,11 +50,8 @@ defineSlots<BadgeSlots>()
50
50
 
51
51
  const show = defineModel<boolean>('show', { default: true })
52
52
 
53
- const { theme, createStyler } = useTheme()
54
- const style = computed(() => {
55
- const styler = createStyler(theme.value.badge)
56
- return styler(props)
57
- })
53
+ const { generateStyle } = useTheme()
54
+ const style = computed(() => generateStyle('badge', props))
58
55
  </script>
59
56
 
60
57
  <template>
@@ -1,10 +1,15 @@
1
1
  <script lang="ts">
2
2
  import type { PrimitiveProps } from 'reka-ui'
3
3
  import type { breadcrumb } from '../theme'
4
- import type { ComponentAttrs, DynamicSlots, LinkProps } from '../types'
4
+ import type { ComponentAttrs, LinkProps } from '../types'
5
5
 
6
6
  type SlotProps<T> = (props: { item: T, index: number, active?: boolean }) => any
7
7
 
8
+ type DynamicSlots<T extends { slot?: string }, SlotProps, Slot = T['slot']> =
9
+ Slot extends string
10
+ ? Record<Slot | `${Slot}-${'leading' | 'label' | 'trailing'}`, SlotProps>
11
+ : Record<string, never>
12
+
8
13
  export type BreadcrumbSlots<T extends { slot?: string }> = {
9
14
  'item'?: SlotProps<T>
10
15
  'item-leading'?: SlotProps<T>
@@ -25,7 +30,6 @@ export interface BreadcrumbProps<T> extends ComponentAttrs<typeof breadcrumb> {
25
30
  * @default "nav"
26
31
  */
27
32
  as?: PrimitiveProps['as']
28
- dir?: 'rtl' | 'ltr'
29
33
  items?: T[]
30
34
  /**
31
35
  * The icon to use as a separator.
@@ -43,6 +47,7 @@ export interface BreadcrumbProps<T> extends ComponentAttrs<typeof breadcrumb> {
43
47
  <script setup lang="ts" generic="T extends BreadcrumbItem">
44
48
  import { Primitive } from 'reka-ui'
45
49
  import { computed } from 'vue'
50
+ import { useLocale } from '../composables/useLocale'
46
51
  import { useTheme } from '../composables/useTheme'
47
52
  import { get, pickLinkProps } from '../utils'
48
53
  import Link from './Link.vue'
@@ -55,14 +60,12 @@ const props = withDefaults(defineProps<BreadcrumbProps<T>>(), {
55
60
 
56
61
  const slots = defineSlots<BreadcrumbSlots<T>>()
57
62
 
58
- const { theme, createStyler } = useTheme()
63
+ const { dir } = useLocale()
64
+ const { theme, generateStyle } = useTheme()
59
65
 
60
- const separatorIcon = computed(() => props.separatorIcon || (props.dir === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
66
+ const separatorIcon = computed(() => props.separatorIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
61
67
 
62
- const style = computed(() => {
63
- const styler = createStyler(theme.value.breadcrumb)
64
- return styler(props)
65
- })
68
+ const style = computed(() => generateStyle('breadcrumb', props))
66
69
  </script>
67
70
 
68
71
  <template>
@@ -46,11 +46,10 @@ const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponen
46
46
 
47
47
  const linkProps = useForwardProps(pickLinkProps(props))
48
48
 
49
- const { theme, createStyler } = useTheme()
49
+ const { generateStyle } = useTheme()
50
50
 
51
51
  const style = computed(() => {
52
- const styler = createStyler(theme.value.button)
53
- return styler({
52
+ return generateStyle('button', {
54
53
  ...props,
55
54
  size: size.value,
56
55
  groupOrientation: orientation.value,
@@ -35,11 +35,8 @@ defineSlots<ButtonGroupSlots>()
35
35
 
36
36
  provideButtonGroup(computed(() => props))
37
37
 
38
- const { theme, createStyler } = useTheme()
39
- const style = computed(() => {
40
- const styler = createStyler(theme.value.buttonGroup)
41
- return styler(props)
42
- })
38
+ const { generateStyle } = useTheme()
39
+ const style = computed(() => generateStyle('buttonGroup', props))
43
40
  </script>
44
41
 
45
42
  <template>
@@ -0,0 +1,176 @@
1
+ <script lang="ts">
2
+ import type { VariantProps } from '@byyuurin/ui-kit'
3
+ import type { DateValue } from '@internationalized/date'
4
+ import type { CalendarCellTriggerProps, CalendarRootEmits, CalendarRootProps, DateRange, RangeCalendarRootEmits } from 'reka-ui'
5
+ import type { calendar } from '../theme'
6
+ import type { ComponentAttrs } from '../types'
7
+
8
+ export interface CalendarEmits<R extends boolean, M extends boolean> extends Omit<CalendarRootEmits & RangeCalendarRootEmits, 'update:modelValue'> {
9
+ 'update:modelValue': [date: CalendarModelValue<R, M>]
10
+ }
11
+
12
+ export interface CalendarSlots {
13
+ 'heading'?: (props: { value: string }) => any
14
+ 'day'?: (props: Pick<CalendarCellTriggerProps, 'day'>) => any
15
+ 'week-day'?: (props: { day: string }) => any
16
+ }
17
+
18
+ type CalendarVariants = VariantProps<typeof calendar>
19
+
20
+ type CalendarModelValue<R extends boolean = false, M extends boolean = false> = R extends true
21
+ ? DateRange
22
+ : M extends true ? DateValue[] : DateValue
23
+
24
+ export interface CalendarProps<R extends boolean, M extends boolean> extends ComponentAttrs<typeof calendar>, Omit<CalendarRootProps, 'modelValue' | 'defaultValue' | 'dir' | 'locale' | 'calendarLabel' | 'multiple'> {
25
+ /**
26
+ * The icon to use for the next year control.
27
+ * @default app.icons.chevronDoubleRight
28
+ */
29
+ nextYearIcon?: string
30
+ /**
31
+ * The icon to use for the next month control.
32
+ * @default app.icons.chevronRight
33
+ */
34
+ nextMonthIcon?: string
35
+ /**
36
+ * The icon to use for the previous year control.
37
+ * @default app.icons.chevronDoubleLeft
38
+ */
39
+ prevYearIcon?: string
40
+ /**
41
+ * The icon to use for the previous month control.
42
+ * @default app.icons.chevronLeft
43
+ */
44
+ prevMonthIcon?: string
45
+ /**
46
+ * @default "md"
47
+ */
48
+ size?: CalendarVariants['size']
49
+ /** Whether or not a range of dates can be selected */
50
+ range?: R & boolean
51
+ /** Whether or not multiple dates can be selected */
52
+ multiple?: M & boolean
53
+ /** Show month controls */
54
+ monthControls?: boolean
55
+ /** Show year controls */
56
+ yearControls?: boolean
57
+ defaultValue?: CalendarModelValue<R, M>
58
+ modelValue?: CalendarModelValue<R, M>
59
+ }
60
+ </script>
61
+
62
+ <script setup lang="ts" generic="R extends boolean = false, M extends boolean = false">
63
+ import { reactiveOmit } from '@vueuse/core'
64
+ import { useForwardPropsEmits } from 'reka-ui'
65
+ import { Calendar as BaseCalendar, RangeCalendar } from 'reka-ui/namespaced'
66
+ import { computed } from 'vue'
67
+ import { useLocale } from '../composables/useLocale'
68
+ import { useTheme } from '../composables/useTheme'
69
+ import Button from './Button.vue'
70
+
71
+ const props = withDefaults(defineProps<CalendarProps<R, M>>(), {
72
+ fixedWeeks: true,
73
+ monthControls: true,
74
+ yearControls: true,
75
+ })
76
+ const emit = defineEmits<CalendarEmits<R, M>>()
77
+ defineSlots<CalendarSlots>()
78
+
79
+ const rootProps = useForwardPropsEmits(reactiveOmit(props, 'range', 'modelValue', 'defaultValue', 'size', 'monthControls', 'yearControls', 'class', 'ui'), emit)
80
+
81
+ const { code: locale, dir, t } = useLocale()
82
+ const { theme, generateStyle } = useTheme()
83
+
84
+ const nextYearIcon = computed(() => props.nextYearIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronDoubleLeft : theme.value.app.icons.chevronDoubleRight))
85
+ const nextMonthIcon = computed(() => props.nextMonthIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
86
+ const prevYearIcon = computed(() => props.prevYearIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronDoubleRight : theme.value.app.icons.chevronDoubleLeft))
87
+ const prevMonthIcon = computed(() => props.prevMonthIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronRight : theme.value.app.icons.chevronLeft))
88
+
89
+ function paginateYear(date: DateValue, sign: -1 | 1) {
90
+ if (sign === -1)
91
+ return date.subtract({ years: 1 })
92
+
93
+ return date.add({ years: 1 })
94
+ }
95
+
96
+ const Calendar = computed(() => props.range ? RangeCalendar : BaseCalendar)
97
+
98
+ const style = computed(() => generateStyle('calendar', props))
99
+ </script>
100
+
101
+ <template>
102
+ <Calendar.Root
103
+ v-slot="{ weekDays, grid }"
104
+ v-bind="rootProps"
105
+ :model-value="props.modelValue"
106
+ :default-value="props.defaultValue"
107
+ :locale="locale"
108
+ :dir="dir"
109
+ :class="style.root({ class: [props.class, props.ui?.root] })"
110
+ >
111
+ <Calendar.Header :class="style.header({ class: props.ui?.header })">
112
+ <Calendar.Prev v-if="props.yearControls" :prev-page="date => paginateYear(date, -1)" :aria-label="t('calendar.prevYear')" as-child>
113
+ <Button :icon="prevYearIcon" :size="props.size" variant="ghost" />
114
+ </Calendar.Prev>
115
+ <Calendar.Prev v-if="props.monthControls" :aria-label="t('calendar.prevMonth')" as-child>
116
+ <Button :icon="prevMonthIcon" :size="props.size" variant="ghost" />
117
+ </Calendar.Prev>
118
+
119
+ <Calendar.Heading v-slot="{ headingValue }" :class="style.heading({ class: props.ui?.heading })">
120
+ <slot name="heading" :value="headingValue">
121
+ {{ headingValue }}
122
+ </slot>
123
+ </Calendar.Heading>
124
+ <Calendar.Next v-if="props.monthControls" :aria-label="t('calendar.nextMonth')" as-child>
125
+ <Button :icon="nextMonthIcon" :size="props.size" variant="ghost" />
126
+ </Calendar.Next>
127
+ <Calendar.Next v-if="props.yearControls" :next-page="(date) => paginateYear(date, 1)" :aria-label="t('calendar.nextYear')" as-child>
128
+ <Button :icon="nextYearIcon" :size="props.size" variant="ghost" />
129
+ </Calendar.Next>
130
+ </Calendar.Header>
131
+ <div :class="style.body({ class: props.ui?.body })">
132
+ <Calendar.Grid
133
+ v-for="month in grid"
134
+ :key="month.value.toString()"
135
+ :class="style.grid({ class: props.ui?.grid })"
136
+ >
137
+ <Calendar.GridHead>
138
+ <Calendar.GridRow :class="style.gridWeekDaysRow({ class: props.ui?.gridWeekDaysRow })">
139
+ <Calendar.HeadCell v-for="day in weekDays" :key="day" :class="style.headCell({ class: props.ui?.headCell })">
140
+ <slot name="week-day" :day="day">
141
+ {{ day }}
142
+ </slot>
143
+ </Calendar.HeadCell>
144
+ </Calendar.GridRow>
145
+ </Calendar.GridHead>
146
+ <Calendar.GridBody :class="style.gridBody({ class: props.ui?.gridBody })">
147
+ <Calendar.GridRow
148
+ v-for="(weekDates, index) in month.rows"
149
+ :key="`weekDates-${index}`"
150
+ :class="style.gridRow({ class: props.ui?.gridRow })"
151
+ >
152
+ <Calendar.Cell
153
+ v-for="weekDate in weekDates"
154
+ :key="weekDate.toString()"
155
+ :date="weekDate"
156
+ :class="style.cell({ class: props.ui?.cell })"
157
+ >
158
+ <Calendar.CellTrigger
159
+ v-slot="{ disabled, unavailable }"
160
+ :day="weekDate"
161
+ :month="month.value"
162
+ as-child
163
+ >
164
+ <div :class="style.cellTrigger({ class: props.ui?.cellTrigger, disabled: disabled || unavailable })">
165
+ <slot name="day" :day="weekDate">
166
+ {{ weekDate.day }}
167
+ </slot>
168
+ </div>
169
+ </Calendar.CellTrigger>
170
+ </Calendar.Cell>
171
+ </Calendar.GridRow>
172
+ </Calendar.GridBody>
173
+ </Calendar.Grid>
174
+ </div>
175
+ </Calendar.Root>
176
+ </template>
@@ -35,11 +35,8 @@ import { useTheme } from '../composables/useTheme'
35
35
  const props = withDefaults(defineProps<CardProps>(), {})
36
36
  const slots = defineSlots<CardSlots>()
37
37
 
38
- const { theme, createStyler } = useTheme()
39
- const style = computed(() => {
40
- const styler = createStyler(theme.value.card)
41
- return styler(props)
42
- })
38
+ const { generateStyle } = useTheme()
39
+ const style = computed(() => generateStyle('card', props))
43
40
  </script>
44
41
 
45
42
  <template>
@@ -55,7 +55,6 @@ export interface CarouselProps<T> extends ComponentAttrs<typeof carousel>, Omit<
55
55
  dots?: boolean
56
56
  orientation?: CarouselVariants['orientation']
57
57
  items?: T[]
58
- dir?: 'rtl' | 'ltr'
59
58
  /**
60
59
  * Enable Autoplay plugin
61
60
  * @link https://www.embla-carousel.com/plugins/autoplay/
@@ -103,8 +102,6 @@ const props = withDefaults(defineProps<CarouselProps<T>>(), {
103
102
  arrows: false,
104
103
  dots: false,
105
104
 
106
- dir: 'ltr',
107
-
108
105
  // Embla Options
109
106
  active: true,
110
107
  align: 'center',
@@ -135,21 +132,18 @@ defineSlots<CarouselSlots<T>>()
135
132
 
136
133
  const rootProps = useForwardProps(reactivePick(props, 'active', 'align', 'breakpoints', 'containScroll', 'dragFree', 'dragThreshold', 'duration', 'inViewThreshold', 'loop', 'skipSnaps', 'slidesToScroll', 'startIndex', 'watchDrag', 'watchResize', 'watchSlides', 'watchFocus'))
137
134
 
138
- const { t } = useLocale()
139
- const { theme, createStyler } = useTheme()
140
- const style = computed(() => {
141
- const styler = createStyler(theme.value.carousel)
142
- return styler(props)
143
- })
135
+ const { t, dir } = useLocale()
136
+ const { theme, generateStyle } = useTheme()
137
+ const style = computed(() => generateStyle('carousel', props))
144
138
 
145
- const prevIcon = computed(() => props.prevIcon || (props.dir === 'rtl' ? theme.value.app.icons.chevronRight : theme.value.app.icons.chevronLeft))
146
- const nextIcon = computed(() => props.nextIcon || (props.dir === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
139
+ const prevIcon = computed(() => props.prevIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronRight : theme.value.app.icons.chevronLeft))
140
+ const nextIcon = computed(() => props.nextIcon || (dir.value === 'rtl' ? theme.value.app.icons.chevronLeft : theme.value.app.icons.chevronRight))
147
141
 
148
142
  const options = computed<EmblaOptionsType>(() => ({
149
143
  ...(props.fade ? { align: 'center', containScroll: false } : {}),
150
144
  ...rootProps.value,
151
145
  axis: props.orientation === 'horizontal' ? 'x' : 'y',
152
- direction: props.dir === 'rtl' ? 'rtl' : 'ltr',
146
+ direction: dir.value === 'rtl' ? 'rtl' : 'ltr',
153
147
  }))
154
148
 
155
149
  const plugins = computedAsync<EmblaPluginType[]>(async () => {
@@ -261,7 +255,6 @@ defineExpose({
261
255
  role="region"
262
256
  aria-roledescription="carousel"
263
257
  tabindex="0"
264
- :dir="props.dir"
265
258
  :class="style.root({ class: [props.class, props.ui?.root] })"
266
259
  @keydown="onKeyDown"
267
260
  >
@@ -55,11 +55,8 @@ const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defa
55
55
 
56
56
  const id = props.id ?? useId()
57
57
 
58
- const { theme, createStyler } = useTheme()
59
- const style = computed(() => {
60
- const styler = createStyler(theme.value.checkbox)
61
- return styler(props)
62
- })
58
+ const { theme, generateStyle } = useTheme()
59
+ const style = computed(() => generateStyle('checkbox', props))
63
60
 
64
61
  function onUpdate(value: any) {
65
62
  // @ts-expect-error - 'target' does not exist in type 'EventInit'
@@ -41,15 +41,12 @@ const slots = defineSlots<ChipSlots>()
41
41
  const { size, orientation } = useButtonGroup(props)
42
42
  const { isLeading, leadingIconName, isTrailing, trailingIconName } = useComponentIcons(props)
43
43
 
44
- const { theme, createStyler } = useTheme()
45
- const style = computed(() => {
46
- const styler = createStyler(theme.value.chip)
47
- return styler({
48
- ...props,
49
- size: size.value,
50
- groupOrientation: orientation.value,
51
- })
52
- })
44
+ const { generateStyle } = useTheme()
45
+ const style = computed(() => generateStyle('chip', {
46
+ ...props,
47
+ size: size.value,
48
+ groupOrientation: orientation.value,
49
+ }))
53
50
  </script>
54
51
 
55
52
  <template>
@@ -28,11 +28,8 @@ const slots = defineSlots<CollapsibleSlots>()
28
28
 
29
29
  const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen', 'open', 'disabled', 'unmountOnHide'), emit)
30
30
 
31
- const { theme, createStyler } = useTheme()
32
- const style = computed(() => {
33
- const styler = createStyler(theme.value.collapsible)
34
- return styler(props)
35
- })
31
+ const { generateStyle } = useTheme()
32
+ const style = computed(() => generateStyle('collapsible', props))
36
33
  </script>
37
34
 
38
35
  <template>