v-uixy 1.5.0 → 1.7.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 (26) hide show
  1. package/package.json +1 -1
  2. package/templates/components/Alert/Alert.component.vue +53 -11
  3. package/templates/components/Alert/Alert.types.ts +2 -0
  4. package/templates/components/Alert/AlertItem.component.vue +21 -2
  5. package/templates/components/Button/Button.styles.ts +4 -4
  6. package/templates/components/Checkbox/Checkbox.component.vue +19 -5
  7. package/templates/components/Checkbox/Checkbox.styles.ts +10 -0
  8. package/templates/components/Checkbox/Checkbox.types.ts +1 -0
  9. package/templates/components/DatePicker/DatePicker.component.vue +23 -3
  10. package/templates/components/DatePicker/DatePicker.types.ts +0 -1
  11. package/templates/components/DateRangePicker/DateRangePicker.component.vue +29 -4
  12. package/templates/components/DateRangePicker/DateRangePicker.types.ts +0 -1
  13. package/templates/components/FileUpload/FileUpload.component.vue +23 -13
  14. package/templates/components/Input/Input.component.vue +23 -13
  15. package/templates/components/Input/Input.types.ts +0 -1
  16. package/templates/components/Popover/Popover.component.vue +1 -1
  17. package/templates/components/Select/Select.component.vue +23 -14
  18. package/templates/components/Select/Select.types.ts +0 -1
  19. package/templates/components/Table/Table.component.vue +507 -0
  20. package/templates/components/Table/Table.styles.ts +140 -0
  21. package/templates/components/Table/Table.types.ts +98 -0
  22. package/templates/components/Table/index.ts +39 -0
  23. package/templates/components/Textarea/Textarea.component.vue +20 -14
  24. package/templates/components/Textarea/Textarea.types.ts +0 -1
  25. package/templates/components.json +6 -0
  26. package/templates/composables/usePosition.ts +6 -4
@@ -0,0 +1,98 @@
1
+ export type UixyTableAlign = "left" | "center" | "right";
2
+ export type UixyTableDensity = "compact" | "comfortable";
3
+ export type UixyTableSortDirection = "asc" | "desc";
4
+
5
+ export type UixyTableColumnKey<TRow> =
6
+ | Extract<keyof TRow, string>
7
+ | (string & {});
8
+
9
+ export interface UixyTableColumn<TRow = Record<string, unknown>> {
10
+ key: UixyTableColumnKey<TRow>;
11
+ header: string;
12
+ accessor?: (row: TRow) => unknown;
13
+ sortable?: boolean;
14
+ align?: UixyTableAlign;
15
+ width?: string;
16
+ minWidth?: string;
17
+ }
18
+
19
+ export interface UixyTableSort<TRow = Record<string, unknown>> {
20
+ key: UixyTableColumnKey<TRow>;
21
+ direction: UixyTableSortDirection;
22
+ }
23
+
24
+ export interface UixyTablePagination {
25
+ page: number;
26
+ pageSize: number;
27
+ total: number;
28
+ }
29
+
30
+ export interface UixyTableFilter {
31
+ key: string;
32
+ type: string;
33
+ label?: string;
34
+ active?: boolean;
35
+ [key: string]: unknown;
36
+ }
37
+
38
+ export type UixyTableRowKey<TRow> =
39
+ | UixyTableColumnKey<TRow>
40
+ | ((row: TRow) => string | number);
41
+
42
+ export interface UixyTableProps<TRow = Record<string, unknown>> {
43
+ columns: UixyTableColumn<TRow>[];
44
+ rows: TRow[];
45
+ rowKey?: UixyTableRowKey<TRow>;
46
+ sort?: UixyTableSort<TRow> | null;
47
+ pagination?: UixyTablePagination;
48
+ filters?: UixyTableFilter[];
49
+ selectable?: boolean;
50
+ selectedRowKeys?: Array<string | number>;
51
+ summary?: Partial<Record<UixyTableColumnKey<TRow>, unknown>>;
52
+ loading?: boolean;
53
+ density?: UixyTableDensity;
54
+ stickyHeader?: boolean;
55
+ maxHeight?: string;
56
+ caption?: string;
57
+ emptyText?: string;
58
+ }
59
+
60
+ export interface UixyTableEmits<TRow = Record<string, unknown>> {
61
+ (event: "sortChange", sort: UixyTableSort<TRow> | null): void;
62
+ (event: "pageChange", page: number): void;
63
+ (event: "selectionChange", keys: Array<string | number>): void;
64
+ }
65
+
66
+ export interface UixyTableCellSlotProps<TRow = Record<string, unknown>> {
67
+ row: TRow;
68
+ value: unknown;
69
+ column: UixyTableColumn<TRow>;
70
+ index: number;
71
+ }
72
+
73
+ export interface UixyTableSummarySlotProps<TRow = Record<string, unknown>> {
74
+ column: UixyTableColumn<TRow>;
75
+ value: unknown;
76
+ }
77
+
78
+ export interface UixyTableFilterSlotProps<TRow = Record<string, unknown>> {
79
+ column: UixyTableColumn<TRow>;
80
+ filter?: UixyTableFilter;
81
+ close: () => void;
82
+ }
83
+
84
+ export interface UixyTablePaginationSlotProps {
85
+ pagination: UixyTablePagination;
86
+ pageCount: number;
87
+ goToPage: (page: number) => void;
88
+ }
89
+
90
+ export interface UixyTableSlots<TRow = Record<string, unknown>> {
91
+ empty?: (props: Record<string, never>) => unknown;
92
+ pagination?: (props: UixyTablePaginationSlotProps) => unknown;
93
+ [key: `cell-${string}`]: (props: UixyTableCellSlotProps<TRow>) => unknown;
94
+ [key: `summary-${string}`]: (
95
+ props: UixyTableSummarySlotProps<TRow>,
96
+ ) => unknown;
97
+ [key: `filter-${string}`]: (props: UixyTableFilterSlotProps<TRow>) => unknown;
98
+ }
@@ -0,0 +1,39 @@
1
+ import UixyTable from "./Table.component.vue";
2
+ import {
3
+ type UixyTableProps,
4
+ type UixyTableEmits,
5
+ type UixyTableSlots,
6
+ type UixyTableColumn,
7
+ type UixyTableColumnKey,
8
+ type UixyTableSort,
9
+ type UixyTableSortDirection,
10
+ type UixyTablePagination,
11
+ type UixyTableFilter,
12
+ type UixyTableRowKey,
13
+ type UixyTableAlign,
14
+ type UixyTableDensity,
15
+ type UixyTableCellSlotProps,
16
+ type UixyTableSummarySlotProps,
17
+ type UixyTableFilterSlotProps,
18
+ type UixyTablePaginationSlotProps,
19
+ } from "./Table.types";
20
+
21
+ export {
22
+ UixyTable,
23
+ type UixyTableProps,
24
+ type UixyTableEmits,
25
+ type UixyTableSlots,
26
+ type UixyTableColumn,
27
+ type UixyTableColumnKey,
28
+ type UixyTableSort,
29
+ type UixyTableSortDirection,
30
+ type UixyTablePagination,
31
+ type UixyTableFilter,
32
+ type UixyTableRowKey,
33
+ type UixyTableAlign,
34
+ type UixyTableDensity,
35
+ type UixyTableCellSlotProps,
36
+ type UixyTableSummarySlotProps,
37
+ type UixyTableFilterSlotProps,
38
+ type UixyTablePaginationSlotProps,
39
+ };
@@ -21,23 +21,29 @@
21
21
  {{ props.label }}
22
22
  </label>
23
23
  </div>
24
- <div v-if="!props.hideHelper" class="h-4">
25
- <animate-presence mode="wait" :initial="false">
26
- <motion.div
27
- :initial="{ opacity: 0, y: '-4px' }"
28
- :animate="{ opacity: 1, y: 0 }"
29
- :exit="{ opacity: 0, y: '-4px' }"
30
- :transition="{ duration: 0.125 }"
31
- :key="status"
32
- >
33
- <p
24
+ <animate-presence mode="wait" :initial="false">
25
+ <motion.div
26
+ v-if="!!text"
27
+ class="overflow-hidden"
28
+ :initial="{ height: 0 }"
29
+ :animate="{ height: 'auto' }"
30
+ :exit="{ height: 0 }"
31
+ :transition="{ duration: 0.1, ease: 'easeInOut' }"
32
+ >
33
+ <animate-presence mode="wait" :initial="false">
34
+ <motion.p
35
+ :key="status + text"
34
36
  :class="helperStyles({ status, align: props.alignText ?? 'left' })"
37
+ :initial="{ opacity: 0, y: -4 }"
38
+ :animate="{ opacity: 1, y: 0 }"
39
+ :exit="{ opacity: 0, y: 4 }"
40
+ :transition="{ duration: 0.12, ease: 'easeInOut', delay: 0.1 }"
35
41
  >
36
42
  {{ text }}
37
- </p>
38
- </motion.div>
39
- </animate-presence>
40
- </div>
43
+ </motion.p>
44
+ </animate-presence>
45
+ </motion.div>
46
+ </animate-presence>
41
47
  </div>
42
48
  </template>
43
49
 
@@ -10,5 +10,4 @@ export interface UixyTextareaProps {
10
10
  noResize?: boolean;
11
11
  rows?: number;
12
12
  maxLength?: number;
13
- hideHelper?: boolean;
14
13
  }
@@ -198,6 +198,12 @@
198
198
  "packages": ["motion-v"],
199
199
  "composables": []
200
200
  },
201
+ {
202
+ "name": "Table",
203
+ "related-components": ["Card", "Checkbox", "Icon", "Skeleton", "Popover"],
204
+ "packages": [],
205
+ "composables": []
206
+ },
201
207
  {
202
208
  "name": "TableOfContents",
203
209
  "related-components": [],
@@ -6,6 +6,8 @@ interface UsePositionOptions {
6
6
  direction?: Direction;
7
7
  }
8
8
 
9
+ const GAP = 6;
10
+
9
11
  function hasFixedParent(el: HTMLElement | null): boolean {
10
12
  while (el) {
11
13
  const style = window.getComputedStyle(el);
@@ -46,8 +48,8 @@ export function usePosition({ direction = "bottom" }: UsePositionOptions) {
46
48
 
47
49
  const spaceBelow = winH - targetRect.bottom;
48
50
  const spaceAbove = targetRect.top;
49
- const fitsBelow = spaceBelow >= tooltipRect.height + 6;
50
- const fitsAbove = spaceAbove >= tooltipRect.height + 6;
51
+ const fitsBelow = spaceBelow >= tooltipRect.height + GAP;
52
+ const fitsAbove = spaceAbove >= tooltipRect.height + GAP;
51
53
 
52
54
  const effectiveDirection =
53
55
  direction === "top"
@@ -60,8 +62,8 @@ export function usePosition({ direction = "bottom" }: UsePositionOptions) {
60
62
 
61
63
  top =
62
64
  effectiveDirection === "top"
63
- ? targetRect.top - tooltipRect.height - 6 + scrollY
64
- : targetRect.bottom + 6 + scrollY;
65
+ ? targetRect.top - tooltipRect.height - GAP + scrollY
66
+ : targetRect.bottom + GAP + scrollY;
65
67
 
66
68
  let left = targetRect.left + targetRect.width / 2 - tooltipRect.width / 2;
67
69
  const newStyles: Record<string, string | number> = {