@byyuurin/ui 0.0.10 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/README.md +170 -58
  2. package/dist/module.d.mts +4 -13
  3. package/dist/module.json +4 -4
  4. package/dist/module.mjs +54 -20
  5. package/dist/runtime/components/Accordion.vue +48 -72
  6. package/dist/runtime/components/Accordion.vue.d.ts +74 -0
  7. package/dist/runtime/components/Alert.vue +65 -83
  8. package/dist/runtime/components/Alert.vue.d.ts +71 -0
  9. package/dist/runtime/components/App.vue +28 -42
  10. package/dist/runtime/components/App.vue.d.ts +26 -0
  11. package/dist/runtime/components/Avatar.vue +82 -58
  12. package/dist/runtime/components/Avatar.vue.d.ts +39 -0
  13. package/dist/runtime/components/AvatarGroup.vue +43 -70
  14. package/dist/runtime/components/AvatarGroup.vue.d.ts +30 -0
  15. package/dist/runtime/components/Badge.vue +70 -64
  16. package/dist/runtime/components/Badge.vue.d.ts +45 -0
  17. package/dist/runtime/components/Breadcrumb.vue +56 -76
  18. package/dist/runtime/components/Breadcrumb.vue.d.ts +79 -0
  19. package/dist/runtime/components/Button.vue +150 -78
  20. package/dist/runtime/components/Button.vue.d.ts +45 -0
  21. package/dist/runtime/components/Calendar.vue +99 -125
  22. package/dist/runtime/components/Calendar.vue.d.ts +102 -0
  23. package/dist/runtime/components/Card.vue +33 -46
  24. package/dist/runtime/components/Card.vue.d.ts +34 -0
  25. package/dist/runtime/components/Carousel.vue +164 -237
  26. package/dist/runtime/components/Carousel.vue.d.ts +125 -0
  27. package/dist/runtime/components/Checkbox.vue +86 -88
  28. package/dist/runtime/components/Checkbox.vue.d.ts +63 -0
  29. package/dist/runtime/components/Chip.vue +44 -58
  30. package/dist/runtime/components/Chip.vue.d.ts +48 -0
  31. package/dist/runtime/components/Collapsible.vue +29 -33
  32. package/dist/runtime/components/Collapsible.vue.d.ts +34 -0
  33. package/dist/runtime/components/Drawer.vue +110 -150
  34. package/dist/runtime/components/Drawer.vue.d.ts +103 -0
  35. package/dist/runtime/components/DropdownMenu.vue +49 -120
  36. package/dist/runtime/components/DropdownMenu.vue.d.ts +140 -0
  37. package/dist/runtime/components/DropdownMenuContent.vue +177 -143
  38. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +51 -0
  39. package/dist/runtime/components/FieldGroup.vue +33 -0
  40. package/dist/runtime/components/FieldGroup.vue.d.ts +33 -0
  41. package/dist/runtime/components/Form.vue +245 -275
  42. package/dist/runtime/components/Form.vue.d.ts +103 -0
  43. package/dist/runtime/components/FormField.vue +108 -0
  44. package/dist/runtime/components/FormField.vue.d.ts +63 -0
  45. package/dist/runtime/components/Icon.vue +20 -0
  46. package/dist/runtime/components/Icon.vue.d.ts +9 -0
  47. package/dist/runtime/components/Input.vue +125 -156
  48. package/dist/runtime/components/Input.vue.d.ts +76 -0
  49. package/dist/runtime/components/InputNumber.vue +103 -130
  50. package/dist/runtime/components/InputNumber.vue.d.ts +191 -0
  51. package/dist/runtime/components/Kbd.vue +24 -39
  52. package/dist/runtime/components/Kbd.vue.d.ts +34 -0
  53. package/dist/runtime/components/Link.vue +105 -337
  54. package/dist/runtime/components/Link.vue.d.ts +95 -0
  55. package/dist/runtime/components/LinkBase.vue +31 -71
  56. package/dist/runtime/components/LinkBase.vue.d.ts +33 -0
  57. package/dist/runtime/components/Modal.vue +82 -103
  58. package/dist/runtime/components/Modal.vue.d.ts +96 -0
  59. package/dist/runtime/components/NavigationMenu.vue +336 -0
  60. package/dist/runtime/components/NavigationMenu.vue.d.ts +181 -0
  61. package/dist/runtime/components/OverlayProvider.vue +12 -16
  62. package/dist/runtime/components/OverlayProvider.vue.d.ts +3 -0
  63. package/dist/runtime/components/Pagination.vue +65 -139
  64. package/dist/runtime/components/Pagination.vue.d.ts +116 -0
  65. package/dist/runtime/components/PinInput.vue +78 -73
  66. package/dist/runtime/components/PinInput.vue.d.ts +54 -0
  67. package/dist/runtime/components/Popover.vue +60 -75
  68. package/dist/runtime/components/Popover.vue.d.ts +70 -0
  69. package/dist/runtime/components/Progress.vue +79 -126
  70. package/dist/runtime/components/Progress.vue.d.ts +63 -0
  71. package/dist/runtime/components/RadioGroup.vue +109 -140
  72. package/dist/runtime/components/RadioGroup.vue.d.ts +96 -0
  73. package/dist/runtime/components/ScrollArea.vue +50 -48
  74. package/dist/runtime/components/ScrollArea.vue.d.ts +21 -0
  75. package/dist/runtime/components/Select.vue +221 -221
  76. package/dist/runtime/components/Select.vue.d.ts +260 -0
  77. package/dist/runtime/components/Separator.vue +55 -47
  78. package/dist/runtime/components/Separator.vue.d.ts +48 -0
  79. package/dist/runtime/components/Skeleton.vue +25 -22
  80. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  81. package/dist/runtime/components/Slider.vue +73 -77
  82. package/dist/runtime/components/Slider.vue.d.ts +52 -0
  83. package/dist/runtime/components/Switch.vue +66 -77
  84. package/dist/runtime/components/Switch.vue.d.ts +58 -0
  85. package/dist/runtime/components/Table.vue +357 -215
  86. package/dist/runtime/components/Table.vue.d.ts +234 -0
  87. package/dist/runtime/components/Tabs.vue +90 -88
  88. package/dist/runtime/components/Tabs.vue.d.ts +97 -0
  89. package/dist/runtime/components/Textarea.vue +147 -146
  90. package/dist/runtime/components/Textarea.vue.d.ts +76 -0
  91. package/dist/runtime/components/Toast.vue +108 -90
  92. package/dist/runtime/components/Toast.vue.d.ts +152 -0
  93. package/dist/runtime/components/ToastProvider.vue +82 -109
  94. package/dist/runtime/components/ToastProvider.vue.d.ts +51 -0
  95. package/dist/runtime/components/Tooltip.vue +54 -53
  96. package/dist/runtime/components/Tooltip.vue.d.ts +53 -0
  97. package/dist/runtime/composables/defineShortcuts.d.ts +16 -0
  98. package/dist/runtime/composables/defineShortcuts.js +129 -0
  99. package/dist/runtime/composables/useAvatarGroup.d.ts +8 -3
  100. package/dist/runtime/composables/useAvatarGroup.js +10 -3
  101. package/dist/runtime/composables/useComponentIcons.d.ts +9 -6
  102. package/dist/runtime/composables/useComponentIcons.js +4 -4
  103. package/dist/runtime/composables/useFieldGroup.d.ts +8 -0
  104. package/dist/runtime/composables/useFieldGroup.js +14 -0
  105. package/dist/runtime/composables/useFormField.d.ts +62 -0
  106. package/dist/runtime/composables/useFormField.js +99 -0
  107. package/dist/runtime/composables/useKbd.d.ts +3 -2
  108. package/dist/runtime/composables/useKbd.js +3 -2
  109. package/dist/runtime/composables/useLocale.d.ts +68 -5
  110. package/dist/runtime/composables/useLocale.js +11 -11
  111. package/dist/runtime/composables/useOverlay.d.ts +51 -15
  112. package/dist/runtime/composables/useOverlay.js +44 -30
  113. package/dist/runtime/composables/usePortal.d.ts +6 -0
  114. package/dist/runtime/composables/usePortal.js +17 -0
  115. package/dist/runtime/composables/useToast.d.ts +12 -5
  116. package/dist/runtime/composables/useToast.js +12 -7
  117. package/dist/runtime/locale/en.d.ts +30 -1
  118. package/dist/runtime/locale/en.js +2 -1
  119. package/dist/runtime/locale/index.d.ts +2 -2
  120. package/dist/runtime/locale/index.js +1 -1
  121. package/dist/runtime/locale/zh_tw.d.ts +31 -0
  122. package/dist/runtime/locale/{zh-tw.js → zh_tw.js} +2 -1
  123. package/dist/runtime/plugins/colors.d.ts +2 -0
  124. package/dist/runtime/plugins/colors.js +50 -0
  125. package/dist/runtime/types/app.config.d.ts +6 -0
  126. package/dist/runtime/types/form.d.ts +58 -17
  127. package/dist/runtime/types/form.js +11 -0
  128. package/dist/runtime/types/index.d.ts +51 -8
  129. package/dist/runtime/types/index.js +45 -2
  130. package/dist/runtime/types/input.d.ts +8 -0
  131. package/dist/runtime/types/locale.d.ts +5 -0
  132. package/dist/runtime/types/style.d.ts +33 -0
  133. package/dist/runtime/types/style.js +0 -0
  134. package/dist/runtime/types/unocss.d.ts +4 -0
  135. package/dist/runtime/types/utils.d.ts +38 -37
  136. package/dist/runtime/utils/form.d.ts +5 -1
  137. package/dist/runtime/utils/form.js +49 -0
  138. package/dist/runtime/utils/index.d.ts +10 -13
  139. package/dist/runtime/utils/index.js +41 -48
  140. package/dist/runtime/utils/link.d.ts +5 -6
  141. package/dist/runtime/utils/link.js +16 -2
  142. package/dist/runtime/utils/locale.d.ts +5 -0
  143. package/dist/runtime/utils/locale.js +10 -0
  144. package/dist/runtime/utils/style.d.ts +94 -0
  145. package/dist/runtime/utils/style.js +37 -0
  146. package/dist/runtime/vue/components/Icon.vue +15 -0
  147. package/dist/runtime/vue/components/Icon.vue.d.ts +7 -0
  148. package/dist/runtime/vue/components/Link.vue +163 -0
  149. package/dist/runtime/vue/components/Link.vue.d.ts +95 -0
  150. package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
  151. package/dist/runtime/vue/composables/useAppConfig.js +4 -0
  152. package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
  153. package/dist/runtime/vue/plugins/color-mode.js +6 -0
  154. package/dist/runtime/vue/plugins/head.d.ts +4 -0
  155. package/dist/runtime/vue/plugins/head.js +9 -0
  156. package/dist/runtime/vue/stubs.d.ts +16 -1
  157. package/dist/runtime/vue/stubs.js +32 -1
  158. package/dist/setup.d.mts +13 -0
  159. package/dist/setup.mjs +12 -0
  160. package/dist/shared/ui.CzIlLITK.mjs +51 -0
  161. package/dist/shared/ui.DSyJHSTk.mjs +3787 -0
  162. package/dist/shared/ui.DpbffTXs.d.mts +84 -0
  163. package/dist/shared/ui.IulR-OYx.d.mts +64 -0
  164. package/dist/types.d.mts +3 -1
  165. package/dist/unocss.d.mts +12 -52
  166. package/dist/unocss.mjs +144 -253
  167. package/dist/unplugin.d.mts +13 -26
  168. package/dist/unplugin.mjs +193 -18
  169. package/dist/vite.d.mts +10 -1
  170. package/dist/vite.mjs +12 -3
  171. package/package.json +156 -87
  172. package/vue-plugin.d.ts +5 -0
  173. package/dist/module.cjs +0 -5
  174. package/dist/module.d.ts +0 -13
  175. package/dist/module.mjs.map +0 -1
  176. package/dist/runtime/app/injections.d.ts +0 -9307
  177. package/dist/runtime/app/injections.js +0 -61
  178. package/dist/runtime/components/ButtonGroup.vue +0 -46
  179. package/dist/runtime/components/FormItem.vue +0 -129
  180. package/dist/runtime/composables/useButtonGroup.d.ts +0 -5
  181. package/dist/runtime/composables/useButtonGroup.js +0 -9
  182. package/dist/runtime/composables/useFormItem.d.ts +0 -27
  183. package/dist/runtime/composables/useFormItem.js +0 -64
  184. package/dist/runtime/composables/useTheme.d.ts +0 -9
  185. package/dist/runtime/composables/useTheme.js +0 -23
  186. package/dist/runtime/index.d.ts +0 -44
  187. package/dist/runtime/index.js +0 -44
  188. package/dist/runtime/locale/zh-tw.d.ts +0 -2
  189. package/dist/runtime/theme/accordion.d.ts +0 -56
  190. package/dist/runtime/theme/accordion.js +0 -28
  191. package/dist/runtime/theme/alert.d.ts +0 -125
  192. package/dist/runtime/theme/alert.js +0 -47
  193. package/dist/runtime/theme/app.d.ts +0 -19
  194. package/dist/runtime/theme/app.js +0 -19
  195. package/dist/runtime/theme/avatar-group.d.ts +0 -52
  196. package/dist/runtime/theme/avatar-group.js +0 -32
  197. package/dist/runtime/theme/avatar.d.ts +0 -56
  198. package/dist/runtime/theme/avatar.js +0 -34
  199. package/dist/runtime/theme/badge.d.ts +0 -82
  200. package/dist/runtime/theme/badge.js +0 -92
  201. package/dist/runtime/theme/breadcrumb.d.ts +0 -67
  202. package/dist/runtime/theme/breadcrumb.js +0 -44
  203. package/dist/runtime/theme/button-group.d.ts +0 -66
  204. package/dist/runtime/theme/button-group.js +0 -42
  205. package/dist/runtime/theme/button.d.ts +0 -190
  206. package/dist/runtime/theme/button.js +0 -164
  207. package/dist/runtime/theme/calendar.d.ts +0 -56
  208. package/dist/runtime/theme/calendar.js +0 -69
  209. package/dist/runtime/theme/card.d.ts +0 -62
  210. package/dist/runtime/theme/card.js +0 -37
  211. package/dist/runtime/theme/carousel.d.ts +0 -113
  212. package/dist/runtime/theme/carousel.js +0 -43
  213. package/dist/runtime/theme/checkbox.d.ts +0 -88
  214. package/dist/runtime/theme/checkbox.js +0 -54
  215. package/dist/runtime/theme/chip.d.ts +0 -67
  216. package/dist/runtime/theme/chip.js +0 -66
  217. package/dist/runtime/theme/collapsible.d.ts +0 -38
  218. package/dist/runtime/theme/collapsible.js +0 -10
  219. package/dist/runtime/theme/drawer.d.ts +0 -148
  220. package/dist/runtime/theme/drawer.js +0 -113
  221. package/dist/runtime/theme/dropdown-menu.d.ts +0 -71
  222. package/dist/runtime/theme/dropdown-menu.js +0 -83
  223. package/dist/runtime/theme/form-item.d.ts +0 -76
  224. package/dist/runtime/theme/form-item.js +0 -34
  225. package/dist/runtime/theme/form.d.ts +0 -8
  226. package/dist/runtime/theme/form.js +0 -7
  227. package/dist/runtime/theme/index.d.ts +0 -41
  228. package/dist/runtime/theme/index.js +0 -41
  229. package/dist/runtime/theme/input-number.d.ts +0 -121
  230. package/dist/runtime/theme/input-number.js +0 -95
  231. package/dist/runtime/theme/input.d.ts +0 -178
  232. package/dist/runtime/theme/input.js +0 -151
  233. package/dist/runtime/theme/kbd.d.ts +0 -39
  234. package/dist/runtime/theme/kbd.js +0 -26
  235. package/dist/runtime/theme/link.d.ts +0 -44
  236. package/dist/runtime/theme/link.js +0 -26
  237. package/dist/runtime/theme/modal.d.ts +0 -48
  238. package/dist/runtime/theme/modal.js +0 -55
  239. package/dist/runtime/theme/pagination.d.ts +0 -80
  240. package/dist/runtime/theme/pagination.js +0 -17
  241. package/dist/runtime/theme/pinInput.d.ts +0 -100
  242. package/dist/runtime/theme/pinInput.js +0 -111
  243. package/dist/runtime/theme/popover.d.ts +0 -38
  244. package/dist/runtime/theme/popover.js +0 -13
  245. package/dist/runtime/theme/progress.d.ts +0 -186
  246. package/dist/runtime/theme/progress.js +0 -95
  247. package/dist/runtime/theme/radio-group.d.ts +0 -110
  248. package/dist/runtime/theme/radio-group.js +0 -61
  249. package/dist/runtime/theme/scroll-area.d.ts +0 -73
  250. package/dist/runtime/theme/scroll-area.js +0 -33
  251. package/dist/runtime/theme/select.d.ts +0 -192
  252. package/dist/runtime/theme/select.js +0 -173
  253. package/dist/runtime/theme/separator.d.ts +0 -80
  254. package/dist/runtime/theme/separator.js +0 -53
  255. package/dist/runtime/theme/skeleton.d.ts +0 -8
  256. package/dist/runtime/theme/skeleton.js +0 -7
  257. package/dist/runtime/theme/slider.d.ts +0 -76
  258. package/dist/runtime/theme/slider.js +0 -52
  259. package/dist/runtime/theme/switch.d.ts +0 -122
  260. package/dist/runtime/theme/switch.js +0 -78
  261. package/dist/runtime/theme/table.d.ts +0 -92
  262. package/dist/runtime/theme/table.js +0 -36
  263. package/dist/runtime/theme/tabs.d.ts +0 -135
  264. package/dist/runtime/theme/tabs.js +0 -146
  265. package/dist/runtime/theme/textarea.d.ts +0 -96
  266. package/dist/runtime/theme/textarea.js +0 -116
  267. package/dist/runtime/theme/toast-provider.d.ts +0 -122
  268. package/dist/runtime/theme/toast-provider.js +0 -97
  269. package/dist/runtime/theme/toast.d.ts +0 -89
  270. package/dist/runtime/theme/toast.js +0 -35
  271. package/dist/runtime/theme/tooltip.d.ts +0 -44
  272. package/dist/runtime/theme/tooltip.js +0 -11
  273. package/dist/runtime/types/components.d.ts +0 -42
  274. package/dist/runtime/utils/extend-theme.d.ts +0 -9
  275. package/dist/runtime/utils/extend-theme.js +0 -27
  276. package/dist/runtime/utils/styler.d.ts +0 -4
  277. package/dist/runtime/utils/styler.js +0 -10
  278. package/dist/runtime/utils/translator.d.ts +0 -18
  279. package/dist/runtime/utils/translator.js +0 -8
  280. package/dist/shared/ui.3e7fad19.mjs +0 -5
  281. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  282. package/dist/types.d.ts +0 -1
  283. package/dist/unocss.d.ts +0 -52
  284. package/dist/unocss.mjs.map +0 -1
  285. package/dist/unplugin.d.ts +0 -26
  286. package/dist/unplugin.mjs.map +0 -1
  287. package/dist/vite.d.ts +0 -9
  288. package/dist/vite.mjs.map +0 -1
  289. /package/dist/runtime/types/{components.js → input.js} +0 -0
@@ -0,0 +1,234 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { Cell, Header, RowData, TableMeta } from '@tanstack/table-core';
3
+ import type { CellContext, ColumnDef, ColumnFiltersOptions, ColumnFiltersState, ColumnOrderState, ColumnPinningOptions, ColumnPinningState, ColumnSizingInfoState, ColumnSizingOptions, ColumnSizingState, CoreOptions, ExpandedOptions, ExpandedState, FacetedOptions, GlobalFilterOptions, GroupingOptions, GroupingState, HeaderContext, PaginationOptions, PaginationState, Row, RowPinningOptions, RowPinningState, RowSelectionOptions, RowSelectionState, SortingOptions, SortingState, VisibilityOptions, VisibilityState } from '@tanstack/vue-table';
4
+ import type { VirtualizerOptions } from '@tanstack/vue-virtual';
5
+ import type { PrimitiveProps } from 'reka-ui';
6
+ import type { WatchOptions } from 'vue';
7
+ import theme from '#build/ui/table';
8
+ import type { ComponentBaseProps, ComponentUIProps } from '../types';
9
+ import type { MaybeNull, StaticSlot } from '../types/utils';
10
+ declare module '@tanstack/table-core' {
11
+ interface ColumnMeta<TData extends RowData, TValue> {
12
+ class?: {
13
+ th?: string | ((cell: Header<TData, TValue>) => string);
14
+ td?: string | ((cell: Cell<TData, TValue>) => string);
15
+ };
16
+ style?: {
17
+ th?: string | Record<string, string> | ((cell: Header<TData, TValue>) => string | Record<string, string>);
18
+ td?: string | Record<string, string> | ((cell: Cell<TData, TValue>) => string | Record<string, string>);
19
+ };
20
+ colspan?: {
21
+ td?: string | ((cell: Cell<TData, TValue>) => string);
22
+ };
23
+ rowspan?: {
24
+ td?: string | ((cell: Cell<TData, TValue>) => string);
25
+ };
26
+ }
27
+ interface TableMeta<TData> {
28
+ class?: {
29
+ tr?: string | ((row: Row<TData>) => string);
30
+ };
31
+ style?: {
32
+ tr?: string | Record<string, string> | ((row: Row<TData>) => string | Record<string, string>);
33
+ };
34
+ }
35
+ }
36
+ export type TableRow<T> = Row<T>;
37
+ export type TableData = RowData;
38
+ export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D>;
39
+ export interface TableOptions<T extends TableData = TableData> extends Omit<CoreOptions<T>, 'data' | 'columns' | 'getCoreRowModel' | 'state' | 'onStateChange' | 'renderFallbackValue'> {
40
+ state?: CoreOptions<T>['state'];
41
+ onStateChange?: CoreOptions<T>['onStateChange'];
42
+ renderFallbackValue?: CoreOptions<T>['renderFallbackValue'];
43
+ }
44
+ type ThemeVariants = VariantProps<typeof theme>;
45
+ export interface TableProps<T extends TableData = TableData> extends ComponentBaseProps, TableOptions<T> {
46
+ /**
47
+ * The element or component this component should render as.
48
+ * @default "div"
49
+ */
50
+ as?: PrimitiveProps['as'];
51
+ data?: T[];
52
+ columns?: TableColumn<T>[];
53
+ caption?: string;
54
+ meta?: TableMeta<T>;
55
+ /**
56
+ * Enable virtualization for large datasets.
57
+ *
58
+ * Note: when enabled, the divider between rows and sticky properties are not supported.
59
+ * @default false
60
+ */
61
+ virtualize?: boolean | (Partial<Omit<VirtualizerOptions<Element, Element>, 'getScrollElement' | 'count' | 'estimateSize' | 'overscan'>> & {
62
+ /**
63
+ * Number of items rendered outside the visible area
64
+ * @default 12
65
+ */
66
+ overscan?: number;
67
+ /**
68
+ * Estimated size (in px) of each item
69
+ * @default 65
70
+ */
71
+ estimateSize?: number;
72
+ });
73
+ /**
74
+ * The text to display when the table is empty.
75
+ * @default t('table.noData')
76
+ */
77
+ empty?: string;
78
+ /**
79
+ * Whether the table should have a sticky header or footer. True for both, 'header' for header only, 'footer' for footer only.
80
+ *
81
+ * Note: this prop is not supported when `virtualize` is true.
82
+ * @default false
83
+ */
84
+ sticky?: boolean | 'header' | 'footer';
85
+ /** Whether the table should be in loading state. */
86
+ loading?: boolean;
87
+ /** @default "primary" */
88
+ loadingColor?: ThemeVariants['loadingColor'];
89
+ /** @default "carousel" */
90
+ loadingAnimation?: ThemeVariants['loadingAnimation'];
91
+ globalFilter?: string;
92
+ columnFilters?: ColumnFiltersState;
93
+ columnOrder?: ColumnOrderState;
94
+ columnVisibility?: VisibilityState;
95
+ columnPinning?: ColumnPinningState;
96
+ columnSizing?: ColumnSizingState;
97
+ columnSizingInfo?: ColumnSizingInfoState;
98
+ rowSelection?: RowSelectionState;
99
+ rowPinning?: RowPinningState;
100
+ sorting?: SortingState;
101
+ grouping?: GroupingState;
102
+ expanded?: ExpandedState;
103
+ pagination?: PaginationState;
104
+ /**
105
+ * Use the `watchOptions` prop to customize reactivity (for ex: disable deep watching for changes in your data or limiting the max traversal depth). This can improve performance by reducing unnecessary re-renders, but it should be used with caution as it may lead to unexpected behavior if not managed properly.
106
+ * @see [API](https://vuejs.org/api/options-state.html#watch)
107
+ * @see [Guide](https://vuejs.org/guide/essentials/watchers.html)
108
+ * @default { deep: true }
109
+ */
110
+ watchOptions?: WatchOptions;
111
+ /**
112
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/global-filtering#table-options)
113
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
114
+ */
115
+ globalFilterOptions?: Omit<GlobalFilterOptions<T>, 'onGlobalFilterChange'>;
116
+ /**
117
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/column-filtering#table-options)
118
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
119
+ */
120
+ columnFiltersOptions?: Omit<ColumnFiltersOptions<T>, 'getFilteredRowModel' | 'onColumnFiltersChange'>;
121
+ /**
122
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/column-pinning#table-options)
123
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/column-pinning)
124
+ */
125
+ columnPinningOptions?: Omit<ColumnPinningOptions, 'onColumnPinningChange'>;
126
+ /**
127
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/column-sizing#table-options)
128
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
129
+ */
130
+ columnSizingOptions?: Omit<ColumnSizingOptions, 'onColumnSizingChange' | 'onColumnSizingInfoChange'>;
131
+ /**
132
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/column-visibility#table-options)
133
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
134
+ */
135
+ visibilityOptions?: Omit<VisibilityOptions, 'onColumnVisibilityChange'>;
136
+ /**
137
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/sorting#table-options)
138
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
139
+ */
140
+ sortingOptions?: Omit<SortingOptions<T>, 'getSortedRowModel' | 'onSortingChange'>;
141
+ /**
142
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/grouping#table-options)
143
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
144
+ */
145
+ groupingOptions?: Omit<GroupingOptions, 'onGroupingChange'>;
146
+ /**
147
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/expanding#table-options)
148
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/expanding)
149
+ */
150
+ expandedOptions?: Omit<ExpandedOptions<T>, 'getExpandedRowModel' | 'onExpandedChange'>;
151
+ /**
152
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/row-selection#table-options)
153
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
154
+ */
155
+ rowSelectionOptions?: Omit<RowSelectionOptions<T>, 'onRowSelectionChange'>;
156
+ /**
157
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/row-pinning#table-options)
158
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
159
+ */
160
+ rowPinningOptions?: Omit<RowPinningOptions<T>, 'onRowPinningChange'>;
161
+ /**
162
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/pagination#table-options)
163
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
164
+ */
165
+ paginationOptions?: Omit<PaginationOptions, 'onPaginationChange'>;
166
+ /**
167
+ * @see [API](https://tanstack.com/table/v8/docs/api/features/column-faceting#table-options)
168
+ * @see [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
169
+ */
170
+ facetedOptions?: FacetedOptions<T>;
171
+ onSelect?: (e: Event, row: TableRow<T>) => void;
172
+ onHover?: (e: Event, row: MaybeNull<TableRow<T>>) => void;
173
+ onContextmenu?: ((e: Event, row: TableRow<T>) => void) | Array<((e: Event, row: TableRow<T>) => void)>;
174
+ ui?: ComponentUIProps<typeof theme>;
175
+ }
176
+ type DynamicHeaderSlots<T, K = keyof T> = Record<string, (props: HeaderContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-header`, (props: HeaderContext<T, unknown>) => any>;
177
+ type DynamicFooterSlots<T, K = keyof T> = Record<string, (props: HeaderContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-footer`, (props: HeaderContext<T, unknown>) => any>;
178
+ type DynamicCellSlots<T, K = keyof T> = Record<string, (props: CellContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-cell`, (props: CellContext<T, unknown>) => any>;
179
+ export type TableSlots<T> = {
180
+ 'expanded': StaticSlot<{
181
+ row: Row<T>;
182
+ }>;
183
+ 'empty': StaticSlot;
184
+ 'loading': StaticSlot;
185
+ 'caption': StaticSlot;
186
+ 'body-top': StaticSlot;
187
+ 'body-bottom': StaticSlot;
188
+ } & DynamicHeaderSlots<T> & DynamicFooterSlots<T> & DynamicCellSlots<T>;
189
+ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
190
+ props: __VLS_PrettifyLocal<(TableProps<T> & {
191
+ globalFilter?: string;
192
+ columnFilters?: ColumnFiltersState;
193
+ columnOrder?: ColumnOrderState;
194
+ columnVisibility?: VisibilityState;
195
+ columnPinning?: ColumnPinningState;
196
+ columnSizing?: ColumnSizingState;
197
+ columnSizingInfo?: ColumnSizingInfoState;
198
+ rowSelection?: RowSelectionState;
199
+ rowPinning?: RowPinningState;
200
+ sorting?: SortingState;
201
+ grouping?: GroupingState;
202
+ expanded?: ExpandedState;
203
+ pagination?: PaginationState;
204
+ }) & {
205
+ "onUpdate:globalFilter"?: ((value: string) => any) | undefined;
206
+ "onUpdate:columnFilters"?: ((value: ColumnFiltersState) => any) | undefined;
207
+ "onUpdate:columnOrder"?: ((value: ColumnOrderState) => any) | undefined;
208
+ "onUpdate:columnVisibility"?: ((value: VisibilityState) => any) | undefined;
209
+ "onUpdate:columnPinning"?: ((value: ColumnPinningState) => any) | undefined;
210
+ "onUpdate:columnSizing"?: ((value: ColumnSizingState) => any) | undefined;
211
+ "onUpdate:columnSizingInfo"?: ((value: ColumnSizingInfoState) => any) | undefined;
212
+ "onUpdate:rowSelection"?: ((value: RowSelectionState) => any) | undefined;
213
+ "onUpdate:rowPinning"?: ((value: RowPinningState) => any) | undefined;
214
+ "onUpdate:sorting"?: ((value: SortingState) => any) | undefined;
215
+ "onUpdate:grouping"?: ((value: GroupingState) => any) | undefined;
216
+ "onUpdate:expanded"?: ((value: ExpandedState) => any) | undefined;
217
+ "onUpdate:pagination"?: ((value: PaginationState) => any) | undefined;
218
+ }> & import("vue").PublicProps;
219
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
220
+ readonly $el: any;
221
+ tableRef: import("vue").ShallowRef<MaybeNull<HTMLTableElement>, MaybeNull<HTMLTableElement>>;
222
+ tableApi: import("@tanstack/table-core").Table<T>;
223
+ }>) => void;
224
+ attrs: any;
225
+ slots: TableSlots<T>;
226
+ emit: ((evt: "update:globalFilter", value: string) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState) => void) & ((evt: "update:columnOrder", value: ColumnOrderState) => void) & ((evt: "update:columnVisibility", value: VisibilityState) => void) & ((evt: "update:columnPinning", value: ColumnPinningState) => void) & ((evt: "update:columnSizing", value: ColumnSizingState) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState) => void) & ((evt: "update:rowSelection", value: RowSelectionState) => void) & ((evt: "update:rowPinning", value: RowPinningState) => void) & ((evt: "update:sorting", value: SortingState) => void) & ((evt: "update:grouping", value: GroupingState) => void) & ((evt: "update:expanded", value: ExpandedState) => void) & ((evt: "update:pagination", value: PaginationState) => void);
227
+ }>) => import("vue").VNode & {
228
+ __ctx?: Awaited<typeof __VLS_setup>;
229
+ };
230
+ declare const _default: typeof __VLS_export;
231
+ export default _default;
232
+ type __VLS_PrettifyLocal<T> = {
233
+ [K in keyof T as K]: T[K];
234
+ } & {};
@@ -1,115 +1,117 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { TabsRootEmits, TabsRootProps } from 'reka-ui'
4
- import type { tabs } from '../theme'
5
- import type { ComponentAttrs, DynamicSlots } from '../types'
6
-
7
- export interface TabsEmits extends TabsRootEmits<string | number> {}
8
-
9
- export interface TabsItem {
10
- label?: string
11
- icon?: string
12
- slot?: string
13
- content?: string
14
- /** A unique value for the tab item. Defaults to the index. */
15
- value?: string | number
16
- disabled?: boolean
17
- [key: string]: any
18
- }
19
-
20
- type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
21
-
22
- export type TabsSlots<T extends TabsItem = TabsItem> = {
23
- leading?: SlotProps<T>
24
- default?: SlotProps<T>
25
- trailing?: SlotProps<T>
26
- content?: SlotProps<T>
27
- } & DynamicSlots<T, undefined, SlotProps<T>>
28
-
29
- type TabsVariants = VariantProps<typeof tabs>
30
-
31
- export interface TabsProps<T extends TabsItem = TabsItem> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
32
- /**
33
- * The element or component this component should render as.
34
- * @default "div"
35
- */
36
- as?: TabsRootProps<string | number>['as']
37
- items?: T[]
38
- variant?: TabsVariants['variant']
39
- orientation?: TabsVariants['orientation']
40
- size?: TabsVariants['size']
41
- /** @default true */
42
- evenly?: boolean
43
- /**
44
- * The content of the tabs, can be disabled to prevent rendering the content.
45
- * @default true
46
- */
47
- content?: boolean
48
- /**
49
- * The key used to get the label from the item.
50
- * @default "label"
51
- */
52
- labelKey?: string
53
- }
1
+ <script>
2
+ import theme from "#build/ui/tabs";
54
3
  </script>
55
4
 
56
- <script lang="ts" setup generic="T extends TabsItem">
57
- import { reactivePick } from '@vueuse/core'
58
- import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from 'reka-ui'
59
- import { computed } from 'vue'
60
- import { useTheme } from '../composables/useTheme'
61
- import { get } from '../utils'
62
-
63
- const props = withDefaults(defineProps<TabsProps<T>>(), {
64
- defaultValue: '0',
65
- variant: 'solid',
66
- orientation: 'horizontal',
67
- evenly: true,
68
- content: true,
69
- labelKey: 'label',
70
- })
71
-
72
- const emit = defineEmits<TabsEmits>()
73
- const slots = defineSlots<TabsSlots<T>>()
74
-
75
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emit)
76
-
77
- const { generateStyle } = useTheme()
78
- const style = computed(() => generateStyle('tabs', props))
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from "reka-ui";
8
+ import { computed, ref } from "vue";
9
+ import { useAppConfig } from "#imports";
10
+ import { get } from "../utils";
11
+ import { cv, merge } from "../utils/style";
12
+ import Avatar from "./Avatar.vue";
13
+ import Badge from "./Badge.vue";
14
+ import Icon from "./Icon.vue";
15
+ const props = defineProps({
16
+ as: { type: null, required: false },
17
+ items: { type: Array, required: false },
18
+ variant: { type: null, required: false },
19
+ orientation: { type: null, required: false, default: "horizontal" },
20
+ color: { type: null, required: false },
21
+ size: { type: null, required: false },
22
+ content: { type: Boolean, required: false, default: true },
23
+ labelKey: { type: null, required: false, default: "label" },
24
+ ui: { type: null, required: false },
25
+ class: { type: [Object, String, Number, Boolean, null, Array], required: false, skipCheck: true },
26
+ defaultValue: { type: [String, Number], required: false, default: "0" },
27
+ modelValue: { type: [String, Number], required: false },
28
+ activationMode: { type: String, required: false },
29
+ unmountOnHide: { type: Boolean, required: false, default: true }
30
+ });
31
+ const emit = defineEmits(["update:modelValue"]);
32
+ const slots = defineSlots();
33
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "unmountOnHide"), emit);
34
+ const appConfig = useAppConfig();
35
+ const ui = computed(() => {
36
+ const styler = cv(merge(theme, appConfig.ui.tabs));
37
+ return styler(props);
38
+ });
39
+ const triggersRef = ref([]);
40
+ defineExpose({
41
+ triggersRef
42
+ });
79
43
  </script>
80
44
 
81
45
  <template>
82
- <TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
83
- <TabsList :class="style.list({ class: props.ui?.list })">
84
- <TabsIndicator :class="style.indicator({ class: props.ui?.indicator })" />
46
+ <TabsRoot
47
+ v-bind="rootProps"
48
+ :model-value="props.modelValue"
49
+ :default-value="props.defaultValue"
50
+ :orientation="props.orientation"
51
+ :activation-mode="props.activationMode"
52
+ :class="ui.root({ class: [props.ui?.root, props.class] })"
53
+ data-part="root"
54
+ >
55
+ <TabsList :class="ui.list({ class: props.ui?.list })" data-part="list">
56
+ <TabsIndicator :class="ui.indicator({ class: props.ui?.indicator })" data-part="indicator" />
57
+
58
+ <slot name="list-leading">
59
+ </slot>
85
60
 
86
61
  <TabsTrigger
87
62
  v-for="(item, index) of items"
63
+ :ref="(el) => triggersRef[index] = el"
88
64
  :key="index"
89
- :value="item.value || String(index)"
65
+ :value="item.value ?? String(index)"
90
66
  :disabled="item.disabled"
91
- :class="style.trigger({ class: props.ui?.trigger })"
67
+ :class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger] })"
68
+ data-part="trigger"
92
69
  >
93
- <slot name="leading" :item="item" :index="index">
94
- <span v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></span>
70
+ <slot name="leading" :item="item" :index="index" :ui="ui">
71
+ <Icon
72
+ v-if="item.icon"
73
+ :name="item.icon"
74
+ :class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item.ui?.leadingIcon] })"
75
+ data-part="leading-icon"
76
+ />
77
+ <Avatar
78
+ v-else-if="item.avatar"
79
+ :size="item.ui?.leadingAvatarSize || props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
80
+ v-bind="item.avatar"
81
+ :class="ui.leadingAvatar({ class: [props.ui?.leadingAvatar, item.ui?.leadingAvatar] })"
82
+ data-part="leading-avatar"
83
+ />
95
84
  </slot>
96
85
 
97
- <span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
86
+ <span v-if="get(item, props.labelKey) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })" data-part="label">
98
87
  <slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
99
88
  </span>
100
89
 
101
- <slot name="trailing" :item="item" :index="index"></slot>
90
+ <slot name="trailing" :item="item" :index="index" :ui="ui">
91
+ <Badge
92
+ v-if="item.badge !== void 0"
93
+ color="neutral"
94
+ variant="outline"
95
+ :size="item.ui?.trailingBadgeSize || props.ui?.trailingBadgeSize || ui.trailingBadgeSize()"
96
+ v-bind="typeof item.badge === 'string' || typeof item.badge === 'number' ? { label: item.badge } : item.badge"
97
+ :class="ui.trailingBadge({ class: [props.ui?.trailingBadge, item.ui?.trailingBadge] })"
98
+ data-part="trailing-badge"
99
+ />
100
+ </slot>
102
101
  </TabsTrigger>
102
+
103
+ <slot name="list-trailing"></slot>
103
104
  </TabsList>
104
105
 
105
106
  <template v-if="props.content">
106
107
  <TabsContent
107
108
  v-for="(item, index) of items"
108
109
  :key="index"
109
- :value="item.value || String(index)"
110
- :class="style.content({ class: props.ui?.content })"
110
+ :value="item.value ?? String(index)"
111
+ :class="ui.content({ class: [props.ui?.content, item.ui?.content] })"
112
+ data-part="content"
111
113
  >
112
- <slot :name="((item.slot || 'content') as keyof TabsSlots<T>)" :item="(item as Extract<T, { slot: string }>)" :index="index">
114
+ <slot :name="item.slot || 'content'" :item="item" :index="index" :ui="ui">
113
115
  {{ item.content }}
114
116
  </slot>
115
117
  </TabsContent>
@@ -0,0 +1,97 @@
1
+ import type { ComponentPublicInstance } from 'vue';
2
+ import type { VariantProps } from '@byyuurin/ui-kit';
3
+ import type { TabsRootEmits, TabsRootProps } from 'reka-ui';
4
+ import theme from '#build/ui/tabs';
5
+ import type { AvatarProps, BadgeProps, ComponentBaseProps, ComponentStyler, ComponentUIProps, IconProps } from '../types';
6
+ import type { DynamicSlots, GetItemKeys, StaticSlot } from '../types/utils';
7
+ export interface TabsItem {
8
+ label?: string;
9
+ icon?: IconProps['name'];
10
+ avatar?: AvatarProps;
11
+ /** Display a badge on the item. */
12
+ badge?: string | number | BadgeProps;
13
+ slot?: string;
14
+ content?: string;
15
+ /** A unique value for the tab item. Defaults to the index. */
16
+ value?: string | number;
17
+ disabled?: boolean;
18
+ ui?: Pick<ComponentUIProps<typeof theme>, 'trigger' | 'leadingIcon' | 'leadingAvatar' | 'leadingAvatarSize' | 'label' | 'trailingBadge' | 'trailingBadgeSize' | 'content'>;
19
+ [key: string]: any;
20
+ }
21
+ type ThemeVariants = VariantProps<typeof theme>;
22
+ export interface TabsProps<T extends TabsItem = TabsItem> extends ComponentBaseProps, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
23
+ /**
24
+ * The element or component this component should render as.
25
+ * @default "div"
26
+ */
27
+ as?: TabsRootProps<string | number>['as'];
28
+ items?: T[];
29
+ /** @default "pill" */
30
+ variant?: ThemeVariants['variant'];
31
+ /**
32
+ * The orientation of the tabs.
33
+ * @default "horizontal"
34
+ */
35
+ orientation?: ThemeVariants['orientation'];
36
+ /** @default "primary" */
37
+ color?: ThemeVariants['color'];
38
+ /** @default "md" */
39
+ size?: ThemeVariants['size'];
40
+ /**
41
+ * The content of the tabs, can be disabled to prevent rendering the content.
42
+ * @default true
43
+ */
44
+ content?: boolean;
45
+ /**
46
+ * The key used to get the label from the item.
47
+ * @default "label"
48
+ */
49
+ labelKey?: GetItemKeys<T>;
50
+ ui?: ComponentUIProps<typeof theme>;
51
+ }
52
+ export interface TabsEmits extends TabsRootEmits<string | number> {
53
+ }
54
+ export type TabsSlots<T extends TabsItem = TabsItem> = {
55
+ 'leading': StaticSlot<{
56
+ item: T;
57
+ index: number;
58
+ ui: ComponentStyler<typeof theme>;
59
+ }>;
60
+ 'default': StaticSlot<{
61
+ item: T;
62
+ index: number;
63
+ }>;
64
+ 'trailing': StaticSlot<{
65
+ item: T;
66
+ index: number;
67
+ ui: ComponentStyler<typeof theme>;
68
+ }>;
69
+ 'content': StaticSlot<{
70
+ item: T;
71
+ index: number;
72
+ ui: ComponentStyler<typeof theme>;
73
+ }>;
74
+ 'list-leading': StaticSlot;
75
+ 'list-trailing': StaticSlot;
76
+ } & DynamicSlots<T, undefined, {
77
+ index: number;
78
+ ui: ComponentStyler<typeof theme>;
79
+ }>;
80
+ declare const __VLS_export: <T extends TabsItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
81
+ props: __VLS_PrettifyLocal<TabsProps<T> & {
82
+ "onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
83
+ }> & import("vue").PublicProps;
84
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
85
+ triggersRef: import("vue").Ref<ComponentPublicInstance[], ComponentPublicInstance[]>;
86
+ }>) => void;
87
+ attrs: any;
88
+ slots: TabsSlots<T>;
89
+ emit: (evt: "update:modelValue", payload: string | number) => void;
90
+ }>) => import("vue").VNode & {
91
+ __ctx?: Awaited<typeof __VLS_setup>;
92
+ };
93
+ declare const _default: typeof __VLS_export;
94
+ export default _default;
95
+ type __VLS_PrettifyLocal<T> = {
96
+ [K in keyof T as K]: T[K];
97
+ } & {};