@foris/avocado-suite 0.24.1 → 0.26.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 (25) hide show
  1. package/dist/avocado-suite.es.js +5589 -5081
  2. package/dist/avocado-suite.umd.js +87 -87
  3. package/dist/components/accordion/Accordion.d.ts +3 -1
  4. package/dist/components/pager/Pager.d.ts +34 -19
  5. package/dist/components/table/Table.d.ts +3 -0
  6. package/dist/components/table/components/table-action-item/TableActionItem.d.ts +10 -0
  7. package/dist/components/table/components/table-action-item/index.d.ts +2 -0
  8. package/dist/components/table/components/table-desktop/TableDesktop.d.ts +3 -0
  9. package/dist/components/table/components/table-desktop/index.d.ts +2 -0
  10. package/dist/components/table/components/table-desktop-head/TableDesktopHead.d.ts +11 -0
  11. package/dist/components/table/components/table-desktop-head/index.d.ts +2 -0
  12. package/dist/components/table/components/table-desktop-row/TableDesktopRow.d.ts +15 -0
  13. package/dist/components/table/components/table-desktop-row/index.d.ts +2 -0
  14. package/dist/components/table/components/table-mobile/TableMobile.d.ts +3 -0
  15. package/dist/components/table/components/table-mobile/index.d.ts +2 -0
  16. package/dist/components/table/components/table-mobile-row/TableMobileRow.d.ts +13 -0
  17. package/dist/components/table/components/table-mobile-row/index.d.ts +2 -0
  18. package/dist/components/table/components/table-select-actions/TableSelectActions.d.ts +10 -0
  19. package/dist/components/table/components/table-select-actions/index.d.ts +2 -0
  20. package/dist/components/table/index.d.ts +2 -0
  21. package/dist/hooks/useIsMobile.d.ts +9 -0
  22. package/dist/index.d.ts +3 -1
  23. package/dist/style.css +1 -1
  24. package/dist/types/table.types.d.ts +179 -0
  25. package/package.json +2 -2
@@ -0,0 +1,179 @@
1
+ import { IconTypes } from '../../../avocado-icons';
2
+ import { ReactNode } from 'react';
3
+ export type OrderDirection = 'asc' | 'desc';
4
+ /**
5
+ * Represents the sorting configuration for a table.
6
+ */
7
+ export interface TableSort {
8
+ column: string | null;
9
+ direction: OrderDirection | null;
10
+ }
11
+ /**
12
+ * Options for configuring the styles and class names of table columns in a desktop view.
13
+ */
14
+ export interface TableDesktopColumnOptions {
15
+ headCellStyles?: React.CSSProperties;
16
+ headCellClassName?: string;
17
+ bodyCellClassName?: string;
18
+ bodyCellStyles?: React.CSSProperties;
19
+ }
20
+ /**
21
+ * Represents a column in a table.
22
+ */
23
+ export interface TableColumn {
24
+ /**
25
+ * Unique key for the column.
26
+ * Usually used for sorting or actions that required an unique key.
27
+ */
28
+ key: string;
29
+ /**
30
+ * Header text for the column.
31
+ */
32
+ header: string;
33
+ /**
34
+ * Indicates if the column is sortable.
35
+ * @default false
36
+ */
37
+ isSortable?: boolean;
38
+ /**
39
+ * Accessor for the column data.
40
+ */
41
+ accesor?: string;
42
+ /**
43
+ * Options specific to desktop view for the column.
44
+ */
45
+ desktopOptions?: TableDesktopColumnOptions;
46
+ /**
47
+ * Function to render the cell content.
48
+ * @param data - The data to be rendered in the cell.
49
+ * @returns The rendered cell content.
50
+ */
51
+ renderCell?: (data: unknown) => ReactNode;
52
+ /**
53
+ * Callback function when the header is clicked for sorting.
54
+ * @param newSort - The new sort state.
55
+ */
56
+ onHeaderSortClick?: (newSort: TableSort) => void;
57
+ }
58
+ /**
59
+ * Represents an action that can be performed on a table row, typically displayed as an icon or button.
60
+ */
61
+ export interface TableRightAction {
62
+ /**
63
+ * The icon to be displayed for the action.
64
+ */
65
+ icon?: (row: unknown) => IconTypes;
66
+ /**
67
+ * Indicates if the action should be disabled (This only applies to icon actions).
68
+ */
69
+ isDisabled?: (row: unknown) => boolean;
70
+ /**
71
+ * The content to be displayed for the action, which can be a React node.
72
+ * would be displayed only if icon is not provided.
73
+ */
74
+ renderContent?: (row: unknown, isRowDisabled: boolean) => ReactNode;
75
+ /**
76
+ * The function to be called when the action is clicked.
77
+ * This function is only for the icon variant, if the onClick is not provided, the icon will not be clickable.
78
+ * @param row - The data of the row on which the action is performed.
79
+ */
80
+ onClick?: (row: unknown) => void;
81
+ /**
82
+ * A function to determine whether the action should be rendered for a given row.
83
+ * @param row - The data of the row to check.
84
+ * @returns A boolean indicating whether the action should be rendered.
85
+ */
86
+ shouldRender?: (row: unknown) => boolean;
87
+ }
88
+ export type TableVariant = 'regular' | 'relaxed' | 'condensed';
89
+ export type TableSelectType = 'checkbox' | 'radio';
90
+ /**
91
+ * Options for configuring the behavior and appearance of a table row.
92
+ * available options could be: 'checkbox' | 'radio'
93
+ */
94
+ export interface TableRowOptions {
95
+ /**
96
+ * The type of selection mechanism to use for the table row.
97
+ */
98
+ selectorType?: TableSelectType;
99
+ /**
100
+ * Optional indicator to enable text adaptability by allowing max 3 lines per row.
101
+ */
102
+ isTextAdaptable?: boolean;
103
+ /**
104
+ * A function to determine if a row should be disabled.
105
+ *
106
+ * @param row - The data of the row to check.
107
+ * @returns `true` if the row should be disabled, otherwise `false`.
108
+ */
109
+ isDisabled?: (row: unknown) => boolean;
110
+ /**
111
+ * A function to determine if a row is selected.
112
+ *
113
+ * @param row - The data of the row to check.
114
+ * @returns `true` if the row is selected, otherwise `false`.
115
+ */
116
+ isSelected?: (row: unknown) => boolean;
117
+ /**
118
+ * Indicates if all rows are selected.
119
+ */
120
+ isAllSelected?: boolean;
121
+ /**
122
+ * Callback function triggered when a row is selected or deselected.
123
+ *
124
+ * @param isSelected - `true` if the row is selected, otherwise `false`.
125
+ * @param data - The data of the row that was selected or deselected.
126
+ */
127
+ onRowSelect?: (isSelected: boolean, data: unknown) => void;
128
+ /**
129
+ * Callback function triggered when all rows are selected or deselected.
130
+ *
131
+ * @param isSelected - `true` if all rows are selected, otherwise `false`.
132
+ */
133
+ onSelectAll?: (isSelected: boolean) => void;
134
+ /**
135
+ * Function to render custom content for a row.
136
+ *
137
+ * @param data - The data of the row for which to render custom content.
138
+ * @returns A React node representing the custom content.
139
+ */
140
+ renderCustomContent?: (data?: unknown) => React.ReactNode;
141
+ }
142
+ /**
143
+ * Interface representing the properties for a table component.
144
+ */
145
+ export interface TableProps {
146
+ /**
147
+ * The data to be displayed in the table.
148
+ */
149
+ data: unknown[];
150
+ /**
151
+ * The columns configuration for the table.
152
+ */
153
+ columns: TableColumn[];
154
+ /**
155
+ * Optional configuration for row-specific options.
156
+ */
157
+ rowOptions?: TableRowOptions;
158
+ /**
159
+ * Optional initial sorting configuration for the table.
160
+ */
161
+ initialSort?: TableSort;
162
+ /**
163
+ * Optional actions to be displayed on the right side of the table.
164
+ */
165
+ rightActions?: TableRightAction[];
166
+ /**
167
+ * Optional variant for the table when displayed on desktop.
168
+ */
169
+ desktopVariant?: TableVariant;
170
+ /**
171
+ * Indicates if the table should not have responsive behavior.
172
+ */
173
+ notResponsive?: boolean;
174
+ /**
175
+ * Optional callback function to handle sort changes.
176
+ * @param newSort - The new sorting configuration.
177
+ */
178
+ onSortChange?: (newSort: TableSort) => void;
179
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foris/avocado-suite",
3
- "version": "0.24.1",
3
+ "version": "0.26.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  "react-select-async-paginate": "0.7.3",
26
26
  "react-toastify": "9.0.3",
27
27
  "zustand": "4.5.4",
28
- "@foris/avocado-core": "0.8.0",
28
+ "@foris/avocado-core": "0.9.0",
29
29
  "@foris/avocado-icons": "1.9.1"
30
30
  },
31
31
  "devDependencies": {