jp-composter 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 (194) hide show
  1. package/dist/index.d.mts +997 -0
  2. package/dist/index.d.ts +997 -0
  3. package/dist/index.js +36837 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +36778 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +66 -0
  8. package/src/SliceUI/IconMoon.tsx +33 -0
  9. package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
  10. package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
  11. package/src/SliceUI/assets/Anatomycheck.svg +15 -0
  12. package/src/SliceUI/assets/Anatomyinput.svg +32 -0
  13. package/src/SliceUI/assets/Checkbox.jpg +0 -0
  14. package/src/SliceUI/assets/Diagram copy.svg +15 -0
  15. package/src/SliceUI/assets/Diagram.jpg +0 -0
  16. package/src/SliceUI/assets/Diagram.svg +15 -0
  17. package/src/SliceUI/assets/Frame 5 copy.png +0 -0
  18. package/src/SliceUI/assets/Frame 5.png +0 -0
  19. package/src/SliceUI/assets/Frame 65.png +0 -0
  20. package/src/SliceUI/assets/Frame_65.png +0 -0
  21. package/src/SliceUI/assets/Icon copy.svg +3 -0
  22. package/src/SliceUI/assets/Icon.svg +3 -0
  23. package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
  24. package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
  25. package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
  26. package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
  27. package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
  28. package/src/SliceUI/assets/Icon_Plug.svg +38 -0
  29. package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
  30. package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
  31. package/src/SliceUI/assets/Layer_1.png +0 -0
  32. package/src/SliceUI/assets/accessibility.png +0 -0
  33. package/src/SliceUI/assets/accessibility.svg +1 -0
  34. package/src/SliceUI/assets/addon-library.png +0 -0
  35. package/src/SliceUI/assets/assets.png +0 -0
  36. package/src/SliceUI/assets/avif-test-image.avif +0 -0
  37. package/src/SliceUI/assets/bridging.svg +13 -0
  38. package/src/SliceUI/assets/consistent.svg +11 -0
  39. package/src/SliceUI/assets/context.png +0 -0
  40. package/src/SliceUI/assets/discord.svg +1 -0
  41. package/src/SliceUI/assets/docs.png +0 -0
  42. package/src/SliceUI/assets/figma-plugin.png +0 -0
  43. package/src/SliceUI/assets/github.svg +1 -0
  44. package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
  45. package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
  46. package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
  47. package/src/SliceUI/assets/resources/Diagram.svg +15 -0
  48. package/src/SliceUI/assets/resources/Frame 5.png +0 -0
  49. package/src/SliceUI/assets/resources/Frame 65.png +0 -0
  50. package/src/SliceUI/assets/resources/Icon.svg +3 -0
  51. package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
  52. package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
  53. package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
  54. package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
  55. package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
  56. package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
  57. package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
  58. package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
  59. package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
  60. package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
  61. package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
  62. package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
  63. package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
  64. package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
  65. package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
  66. package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
  67. package/src/SliceUI/assets/share.png +0 -0
  68. package/src/SliceUI/assets/styling.png +0 -0
  69. package/src/SliceUI/assets/testing.png +0 -0
  70. package/src/SliceUI/assets/theming.png +0 -0
  71. package/src/SliceUI/assets/tutorials.svg +1 -0
  72. package/src/SliceUI/assets/youtube.svg +1 -0
  73. package/src/SliceUI/automation/helper.ts +29 -0
  74. package/src/SliceUI/avatar/Avatar.tsx +237 -0
  75. package/src/SliceUI/avatar/Token.ts +116 -0
  76. package/src/SliceUI/avatar/Type.ts +36 -0
  77. package/src/SliceUI/avatar/helper.ts +53 -0
  78. package/src/SliceUI/badge/Badge.tsx +308 -0
  79. package/src/SliceUI/badge/Token.ts +202 -0
  80. package/src/SliceUI/badge/Type.ts +46 -0
  81. package/src/SliceUI/badge/helper.ts +39 -0
  82. package/src/SliceUI/button/Button.tsx +243 -0
  83. package/src/SliceUI/button/Token.ts +138 -0
  84. package/src/SliceUI/button/Type.ts +34 -0
  85. package/src/SliceUI/button/helper.ts +125 -0
  86. package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
  87. package/src/SliceUI/checkbox/Token.ts +128 -0
  88. package/src/SliceUI/checkbox/Type.ts +35 -0
  89. package/src/SliceUI/chip/Chip.tsx +290 -0
  90. package/src/SliceUI/chip/Token.ts +151 -0
  91. package/src/SliceUI/chip/Type.ts +43 -0
  92. package/src/SliceUI/chip/helper.ts +40 -0
  93. package/src/SliceUI/colors/Pallete.ts +151 -0
  94. package/src/SliceUI/colors/Token.ts +110 -0
  95. package/src/SliceUI/colors/Type.ts +56 -0
  96. package/src/SliceUI/contextProvider/context.tsx +108 -0
  97. package/src/SliceUI/divider/Divider.tsx +109 -0
  98. package/src/SliceUI/divider/Token.ts +18 -0
  99. package/src/SliceUI/divider/Type.ts +26 -0
  100. package/src/SliceUI/icon/CustomIcon.ts +4 -0
  101. package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
  102. package/src/SliceUI/icon/Icon.tsx +38 -0
  103. package/src/SliceUI/icon/Token.ts +14 -0
  104. package/src/SliceUI/icon/Type.ts +13 -0
  105. package/src/SliceUI/icon/selection.json +1 -0
  106. package/src/SliceUI/input/Input.tsx +573 -0
  107. package/src/SliceUI/input/ToDo.md +99 -0
  108. package/src/SliceUI/input/Token.ts +372 -0
  109. package/src/SliceUI/input/Type.ts +109 -0
  110. package/src/SliceUI/input/components/InputPortal.tsx +211 -0
  111. package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
  112. package/src/SliceUI/input/components/SelectChip.tsx +185 -0
  113. package/src/SliceUI/input/components/SelectList.tsx +173 -0
  114. package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
  115. package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
  116. package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
  117. package/src/SliceUI/input/hooks/useInputState.ts +41 -0
  118. package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
  119. package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
  120. package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
  121. package/src/SliceUI/input/utils/inputUtils.ts +120 -0
  122. package/src/SliceUI/input/utils/selectUtils.ts +85 -0
  123. package/src/SliceUI/input/utils/styleUtils.ts +50 -0
  124. package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
  125. package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
  126. package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
  127. package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
  128. package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
  129. package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
  130. package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
  131. package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
  132. package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
  133. package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
  134. package/src/SliceUI/input/variants/TextInput.tsx +68 -0
  135. package/src/SliceUI/layout/Box.tsx +38 -0
  136. package/src/SliceUI/layout/Center.tsx +38 -0
  137. package/src/SliceUI/layout/Divider.tsx +37 -0
  138. package/src/SliceUI/layout/Grid.tsx +75 -0
  139. package/src/SliceUI/layout/PageContainer.tsx +60 -0
  140. package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
  141. package/src/SliceUI/layout/Spacer.tsx +54 -0
  142. package/src/SliceUI/layout/Stack.tsx +97 -0
  143. package/src/SliceUI/layout/StickyHeader.tsx +71 -0
  144. package/src/SliceUI/radio/RadioButton.tsx +130 -0
  145. package/src/SliceUI/radio/Token.ts +197 -0
  146. package/src/SliceUI/radio/Type.ts +35 -0
  147. package/src/SliceUI/react-native.config.js +3 -0
  148. package/src/SliceUI/responsive/Type.ts +7 -0
  149. package/src/SliceUI/responsive/helper.ts +53 -0
  150. package/src/SliceUI/switch/Switch.tsx +119 -0
  151. package/src/SliceUI/switch/Token.ts +205 -0
  152. package/src/SliceUI/switch/Type.ts +26 -0
  153. package/src/SliceUI/tab/TabItem.tsx +204 -0
  154. package/src/SliceUI/tab/Tabs.tsx +110 -0
  155. package/src/SliceUI/tab/Token.ts +282 -0
  156. package/src/SliceUI/tab/Type.ts +66 -0
  157. package/src/SliceUI/tab/helper.ts +53 -0
  158. package/src/SliceUI/table/Table.tsx +388 -0
  159. package/src/SliceUI/table/TableCell.tsx +158 -0
  160. package/src/SliceUI/table/TableFooter.tsx +353 -0
  161. package/src/SliceUI/table/TableHeader.tsx +247 -0
  162. package/src/SliceUI/table/TableRow.tsx +218 -0
  163. package/src/SliceUI/table/Token.ts +252 -0
  164. package/src/SliceUI/table/Type.ts +213 -0
  165. package/src/SliceUI/table/helper.ts +376 -0
  166. package/src/SliceUI/table/index.ts +53 -0
  167. package/src/SliceUI/theme/dummyColors.tsx +7 -0
  168. package/src/SliceUI/theme/theme.ts +107 -0
  169. package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
  170. package/src/SliceUI/typography/FoundationToken.ts +48 -0
  171. package/src/SliceUI/typography/Token.ts +228 -0
  172. package/src/SliceUI/typography/Type.ts +20 -0
  173. package/src/SliceUI/typography/Typography.tsx +99 -0
  174. package/src/SliceUI/values/BorderRadius.ts +17 -0
  175. package/src/SliceUI/values/BorderWidth.ts +7 -0
  176. package/src/SliceUI/values/Dimension.ts +35 -0
  177. package/src/SliceUI/values/IconSizes.ts +13 -0
  178. package/src/SliceUI/values/Spacing.ts +22 -0
  179. package/src/declarations.d.ts +8 -0
  180. package/src/index.tsx +119 -0
  181. package/src/stories/Colors.mdx +1418 -0
  182. package/src/stories/Dimensions.mdx +60 -0
  183. package/src/stories/GetStarted.mdx +90 -0
  184. package/src/stories/Introduction.mdx +136 -0
  185. package/src/stories/Shape.mdx +126 -0
  186. package/src/stories/Spacing.mdx +104 -0
  187. package/src/stories/Typography.mdx +454 -0
  188. package/src/stories/Utils.mdx +277 -0
  189. package/src/stories/story-components/AddIcon.js +13 -0
  190. package/src/stories/story-components/RectangleWithBox.jsx +51 -0
  191. package/src/stories/story-components/RoundedRectangle.jsx +18 -0
  192. package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
  193. package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
  194. package/src/stories/story-components/svgPaths.js +126 -0
@@ -0,0 +1,376 @@
1
+ import type {ExtendedTheme} from '../colors/Type';
2
+ import type {
3
+ TableColumn,
4
+ TableRowData,
5
+ SortDirection,
6
+ TableSortState,
7
+ TablePagination,
8
+ ColumnAlign,
9
+ } from './Type';
10
+ import {TABLE_COLOR_TOKENS} from './Token';
11
+
12
+ /**
13
+ * Get the row key for a given record
14
+ */
15
+ export const getRowKey = <T extends TableRowData>(
16
+ record: T,
17
+ index: number,
18
+ rowKey?: string | ((record: T) => string | number),
19
+ ): string | number => {
20
+ if (typeof rowKey === 'function') {
21
+ return rowKey(record);
22
+ }
23
+ if (typeof rowKey === 'string') {
24
+ return record[rowKey] as string | number;
25
+ }
26
+ return record.key ?? index;
27
+ };
28
+
29
+ /**
30
+ * Sort data based on column configuration
31
+ */
32
+ export const sortData = <T extends TableRowData>(
33
+ data: T[],
34
+ sortState: TableSortState,
35
+ columns: TableColumn<T>[],
36
+ ): T[] => {
37
+ if (!sortState.columnKey || !sortState.order) {
38
+ return data;
39
+ }
40
+
41
+ const column = columns.find(col => col.key === sortState.columnKey);
42
+ if (!column || !column.sortable) {
43
+ return data;
44
+ }
45
+
46
+ const sorted = [...data].sort((a, b) => {
47
+ let aValue = column.dataIndex ? a[column.dataIndex] : a[column.key];
48
+ let bValue = column.dataIndex ? b[column.dataIndex] : b[column.key];
49
+
50
+ // Handle custom sorter function
51
+ if (typeof column.sorter === 'function') {
52
+ return column.sorter(a, b);
53
+ }
54
+
55
+ // Handle null/undefined values
56
+ if (aValue == null && bValue == null) return 0;
57
+ if (aValue == null) return 1;
58
+ if (bValue == null) return -1;
59
+
60
+ // Convert to comparable values
61
+ if (typeof aValue === 'string' && typeof bValue === 'string') {
62
+ aValue = aValue.toLowerCase();
63
+ bValue = bValue.toLowerCase();
64
+ }
65
+
66
+ if (aValue < bValue) return -1;
67
+ if (aValue > bValue) return 1;
68
+ return 0;
69
+ });
70
+
71
+ return sortState.order === 'desc' ? sorted.reverse() : sorted;
72
+ };
73
+
74
+ /**
75
+ * Filter data based on search/filter criteria
76
+ */
77
+ export const filterData = <T extends TableRowData>(
78
+ data: T[],
79
+ searchText?: string,
80
+ columns?: TableColumn<T>[],
81
+ ): T[] => {
82
+ if (!searchText || !columns) {
83
+ return data;
84
+ }
85
+
86
+ const searchLower = searchText.toLowerCase();
87
+
88
+ return data.filter(record => {
89
+ return columns.some(column => {
90
+ const value = column.dataIndex ? record[column.dataIndex] : record[column.key];
91
+ if (value == null) return false;
92
+
93
+ return String(value).toLowerCase().includes(searchLower);
94
+ });
95
+ });
96
+ };
97
+
98
+ /**
99
+ * Paginate data based on pagination settings
100
+ */
101
+ export const paginateData = <T extends TableRowData>(
102
+ data: T[],
103
+ pagination?: TablePagination | false,
104
+ ): {
105
+ paginatedData: T[];
106
+ totalPages: number;
107
+ startIndex: number;
108
+ endIndex: number;
109
+ } => {
110
+ if (!pagination) {
111
+ return {
112
+ paginatedData: data,
113
+ totalPages: 1,
114
+ startIndex: 0,
115
+ endIndex: data.length,
116
+ };
117
+ }
118
+
119
+ const {current = 1, pageSize = 10} = pagination;
120
+ const startIndex = (current - 1) * pageSize;
121
+ const endIndex = Math.min(startIndex + pageSize, data.length);
122
+ const paginatedData = data.slice(startIndex, endIndex);
123
+ const totalPages = Math.ceil(data.length / pageSize);
124
+
125
+ return {
126
+ paginatedData,
127
+ totalPages,
128
+ startIndex,
129
+ endIndex,
130
+ };
131
+ };
132
+
133
+ /**
134
+ * Generate page numbers for pagination
135
+ */
136
+ export const generatePageNumbers = (
137
+ current: number,
138
+ total: number,
139
+ showPages: number = 5,
140
+ ): (number | string)[] => {
141
+ if (total <= showPages) {
142
+ return Array.from({length: total}, (_, i) => i + 1);
143
+ }
144
+
145
+ const pages: (number | string)[] = [];
146
+ const half = Math.floor(showPages / 2);
147
+
148
+ let start = Math.max(1, current - half);
149
+ let end = Math.min(total, start + showPages - 1);
150
+
151
+ if (end - start < showPages - 1) {
152
+ start = Math.max(1, end - showPages + 1);
153
+ }
154
+
155
+ if (start > 1) {
156
+ pages.push(1);
157
+ if (start > 2) {
158
+ pages.push('...');
159
+ }
160
+ }
161
+
162
+ for (let i = start; i <= end; i++) {
163
+ pages.push(i);
164
+ }
165
+
166
+ if (end < total) {
167
+ if (end < total - 1) {
168
+ pages.push('...');
169
+ }
170
+ pages.push(total);
171
+ }
172
+
173
+ return pages;
174
+ };
175
+
176
+ /**
177
+ * Get text alignment style based on column alignment
178
+ */
179
+ export const getTextAlign = (align?: ColumnAlign): 'left' | 'center' | 'right' => {
180
+ return align || 'left';
181
+ };
182
+
183
+ /**
184
+ * Get flex justification based on column alignment
185
+ */
186
+ export const getJustifyContent = (
187
+ align?: ColumnAlign,
188
+ ): 'flex-start' | 'center' | 'flex-end' => {
189
+ switch (align) {
190
+ case 'center':
191
+ return 'center';
192
+ case 'right':
193
+ return 'flex-end';
194
+ default:
195
+ return 'flex-start';
196
+ }
197
+ };
198
+
199
+ /**
200
+ * Get background color for table elements
201
+ */
202
+ export const getTableBackgroundColor = (
203
+ variant: keyof typeof TABLE_COLOR_TOKENS,
204
+ state: 'default' | 'hover' | 'selected' | 'striped',
205
+ theme: ExtendedTheme,
206
+ ): string => {
207
+ const colorTokens = TABLE_COLOR_TOKENS[variant];
208
+
209
+ switch (state) {
210
+ case 'hover':
211
+ return theme.colors[colorTokens.hoverBackground as keyof typeof theme.colors];
212
+ case 'selected':
213
+ return theme.colors[colorTokens.selectedBackground as keyof typeof theme.colors];
214
+ case 'striped':
215
+ return theme.colors[colorTokens.stripedBackground as keyof typeof theme.colors];
216
+ default:
217
+ return theme.colors[colorTokens.background as keyof typeof theme.colors];
218
+ }
219
+ };
220
+
221
+ /**
222
+ * Get border color for table elements
223
+ */
224
+ export const getTableBorderColor = (
225
+ variant: keyof typeof TABLE_COLOR_TOKENS,
226
+ theme: ExtendedTheme,
227
+ ): string => {
228
+ const colorTokens = TABLE_COLOR_TOKENS[variant];
229
+ return theme.colors[colorTokens.border as keyof typeof theme.colors];
230
+ };
231
+
232
+ /**
233
+ * Get text color for table elements
234
+ */
235
+ export const getTableTextColor = (
236
+ variant: keyof typeof TABLE_COLOR_TOKENS,
237
+ isHeader: boolean,
238
+ theme: ExtendedTheme,
239
+ ): string => {
240
+ const colorTokens = TABLE_COLOR_TOKENS[variant];
241
+ const colorKey = isHeader ? colorTokens.headerText : colorTokens.text;
242
+ return theme.colors[colorKey as keyof typeof theme.colors];
243
+ };
244
+
245
+ /**
246
+ * Calculate column widths based on content and constraints
247
+ */
248
+ export const calculateColumnWidths = <T extends TableRowData>(
249
+ columns: TableColumn<T>[],
250
+ containerWidth: number,
251
+ data: T[],
252
+ ): {[key: string]: number} => {
253
+ const widths: {[key: string]: number} = {};
254
+ let totalFixedWidth = 0;
255
+ let flexColumns: TableColumn<T>[] = [];
256
+
257
+ // Calculate fixed widths first
258
+ columns.forEach(column => {
259
+ if (typeof column.width === 'number') {
260
+ widths[column.key] = column.width;
261
+ totalFixedWidth += column.width;
262
+ } else if (typeof column.width === 'string' && column.width.endsWith('%')) {
263
+ const percentage = parseFloat(column.width) / 100;
264
+ widths[column.key] = containerWidth * percentage;
265
+ totalFixedWidth += widths[column.key];
266
+ } else {
267
+ flexColumns.push(column);
268
+ }
269
+ });
270
+
271
+ // Distribute remaining width among flex columns
272
+ const remainingWidth = Math.max(0, containerWidth - totalFixedWidth);
273
+ const flexWidth = remainingWidth / flexColumns.length;
274
+
275
+ flexColumns.forEach(column => {
276
+ let calculatedWidth = flexWidth;
277
+
278
+ if (column.minWidth && calculatedWidth < column.minWidth) {
279
+ calculatedWidth = column.minWidth;
280
+ }
281
+ if (column.maxWidth && calculatedWidth > column.maxWidth) {
282
+ calculatedWidth = column.maxWidth;
283
+ }
284
+
285
+ widths[column.key] = calculatedWidth;
286
+ });
287
+
288
+ return widths;
289
+ };
290
+
291
+ /**
292
+ * Check if all rows are selected
293
+ */
294
+ export const isAllRowsSelected = <T extends TableRowData>(
295
+ data: T[],
296
+ selectedRowKeys: (string | number)[],
297
+ rowKey?: string | ((record: T) => string | number),
298
+ ): boolean => {
299
+ if (data.length === 0) return false;
300
+
301
+ return data.every((record, index) => {
302
+ const key = getRowKey(record, index, rowKey);
303
+ return selectedRowKeys.includes(key);
304
+ });
305
+ };
306
+
307
+ /**
308
+ * Check if some rows are selected (indeterminate state)
309
+ */
310
+ export const isSomeRowsSelected = <T extends TableRowData>(
311
+ data: T[],
312
+ selectedRowKeys: (string | number)[],
313
+ rowKey?: string | ((record: T) => string | number),
314
+ ): boolean => {
315
+ if (data.length === 0 || selectedRowKeys.length === 0) return false;
316
+
317
+ const someSelected = data.some((record, index) => {
318
+ const key = getRowKey(record, index, rowKey);
319
+ return selectedRowKeys.includes(key);
320
+ });
321
+
322
+ const allSelected = isAllRowsSelected(data, selectedRowKeys, rowKey);
323
+
324
+ return someSelected && !allSelected;
325
+ };
326
+
327
+ /**
328
+ * Toggle all rows selection
329
+ */
330
+ export const toggleAllRowsSelection = <T extends TableRowData>(
331
+ data: T[],
332
+ currentSelectedKeys: (string | number)[],
333
+ rowKey?: string | ((record: T) => string | number),
334
+ ): {
335
+ selectedRowKeys: (string | number)[];
336
+ selectedRows: T[];
337
+ } => {
338
+ const allSelected = isAllRowsSelected(data, currentSelectedKeys, rowKey);
339
+
340
+ if (allSelected) {
341
+ // Deselect all
342
+ return {
343
+ selectedRowKeys: [],
344
+ selectedRows: [],
345
+ };
346
+ } else {
347
+ // Select all
348
+ const selectedRowKeys = data.map((record, index) =>
349
+ getRowKey(record, index, rowKey)
350
+ );
351
+ return {
352
+ selectedRowKeys,
353
+ selectedRows: [...data],
354
+ };
355
+ }
356
+ };
357
+
358
+ /**
359
+ * Format display text for pagination
360
+ */
361
+ export const formatPaginationText = (
362
+ current: number,
363
+ pageSize: number,
364
+ total: number,
365
+ ): {
366
+ range: [number, number];
367
+ text: string;
368
+ } => {
369
+ const start = Math.min((current - 1) * pageSize + 1, total);
370
+ const end = Math.min(current * pageSize, total);
371
+
372
+ return {
373
+ range: [start, end],
374
+ text: `Showing ${start}-${end} of ${total} items`,
375
+ };
376
+ };
@@ -0,0 +1,53 @@
1
+ export { default as Table } from './Table';
2
+ export { default as TableCell } from './TableCell';
3
+ export { default as TableHeader } from './TableHeader';
4
+ export { default as TableRow } from './TableRow';
5
+ export { default as TableFooter } from './TableFooter';
6
+
7
+ export type {
8
+ TableProps,
9
+ TableColumn,
10
+ TableRowData,
11
+ TableSelection,
12
+ TablePagination,
13
+ TableCellProps,
14
+ TableHeaderProps,
15
+ TableRowProps,
16
+ TableFooterProps,
17
+ TableSize,
18
+ TableVariant,
19
+ ColumnAlign,
20
+ SortDirection,
21
+ TableSortState,
22
+ TableFilterState,
23
+ TableState,
24
+ TableTheme,
25
+ TableThemeVariant,
26
+ TableThemeSize,
27
+ } from './Type';
28
+
29
+ export {
30
+ TABLE_STYLES,
31
+ TABLE_SPACING,
32
+ TABLE_TYPOGRAPHY,
33
+ TABLE_COLOR_TOKENS,
34
+ TABLE_ANIMATIONS,
35
+ } from './Token';
36
+
37
+ export {
38
+ getRowKey,
39
+ sortData,
40
+ filterData,
41
+ paginateData,
42
+ generatePageNumbers,
43
+ getTextAlign,
44
+ getJustifyContent,
45
+ getTableBackgroundColor,
46
+ getTableBorderColor,
47
+ getTableTextColor,
48
+ calculateColumnWidths,
49
+ isAllRowsSelected,
50
+ isSomeRowsSelected,
51
+ toggleAllRowsSelection,
52
+ formatPaginationText,
53
+ } from './helper';
@@ -0,0 +1,7 @@
1
+ import {LightColorTokens} from '../colors/Token';
2
+
3
+ export const useGetColors = () => {
4
+ return {
5
+ colors: LightColorTokens(),
6
+ };
7
+ };
@@ -0,0 +1,107 @@
1
+ import type {TypographyVariants} from '../typography/Type';
2
+ import type {IconSize} from '../icon/Type';
3
+ import {TYPOGRAPHY_STYLES} from '../typography/Token';
4
+ import {ICON_SIZES} from '../icon/Token';
5
+ import type {
6
+ ButtonIconSizeType,
7
+ ButtonSizeType,
8
+ ButtonTextSizeType,
9
+ } from '../button/Type';
10
+ import {
11
+ BUTTON_ICON_STYLE,
12
+ BUTTON_STYLE,
13
+ BUTTON_TXT_STYLE,
14
+ ROUNDED_BORDER_RADIUS,
15
+ } from '../button/Token';
16
+ import type {ViewStyle} from 'react-native';
17
+ import {inputTheme} from '../input/Token';
18
+ import type {InputThemeSize} from '../input/Type';
19
+ import {
20
+ CHIP_ROUNDED_BORDER_RADIUS,
21
+ CHIP_STYLE,
22
+ CHIP_TXT_STYLE,
23
+ } from '../chip/Token';
24
+ import {
25
+ BADGE_ICON_STYLE,
26
+ BADGE_ROUNDED_BORDER_RADIUS,
27
+ BADGE_STYLE,
28
+ BADGE_TXT_STYLE,
29
+ } from '../badge/Token';
30
+ import {
31
+ AVATAR_IMAGE_STYLE,
32
+ AVATAR_ROUNDED_BORDER_RADIUS,
33
+ AVATAR_STYLE,
34
+ AVATAR_TXT_STYLE,
35
+ } from '../avatar/Token';
36
+ import {
37
+ TAB_ITEM_STYLE,
38
+ TAB_ITEM_TXT_STYLE,
39
+ } from '../tab/Token';
40
+ import {spacing} from '../values/Spacing';
41
+ import {LightColorTokens} from '../colors/Token';
42
+ import {dimensions} from '../values/Dimension';
43
+
44
+ export class SliceTheme {
45
+ isDebugBuildType: boolean = true; // Default value
46
+ automationBaseid: string = 'AK_'; // Default value
47
+ typographyStyles: TypographyVariants = TYPOGRAPHY_STYLES; // Default value
48
+ iconSizes: IconSize = ICON_SIZES; // Default value
49
+ buttonStyles: ButtonSizeType = BUTTON_STYLE; // Default value
50
+ buttonTextStyles: ButtonTextSizeType = BUTTON_TXT_STYLE; // Default value
51
+ buttonIconStyles: ButtonIconSizeType = BUTTON_ICON_STYLE; // Default value
52
+ roundButtonRadius: ViewStyle['borderRadius'] = ROUNDED_BORDER_RADIUS;
53
+ chipStyles: ButtonSizeType = CHIP_STYLE; // Default value
54
+ chipTextStyles: ButtonTextSizeType = CHIP_TXT_STYLE; // Default value
55
+ chipIconStyles: ButtonIconSizeType = BUTTON_ICON_STYLE; // Default value
56
+ chipButtonRadius: ViewStyle['borderRadius'] = CHIP_ROUNDED_BORDER_RADIUS;
57
+ badgeStyles: ButtonSizeType = BADGE_STYLE; // Default value
58
+ badgeTextStyles: ButtonTextSizeType = BADGE_TXT_STYLE; // Default value
59
+ badgeIconStyles: ButtonIconSizeType = BADGE_ICON_STYLE; // Default value
60
+ badgeButtonRadius: ViewStyle['borderRadius'] = BADGE_ROUNDED_BORDER_RADIUS;
61
+ avatarStyles: any = AVATAR_STYLE; // Default value
62
+ avatarTextStyles: any = AVATAR_TXT_STYLE; // Default value
63
+ avatarImageStyles: any = AVATAR_IMAGE_STYLE; // Default value
64
+ avatarButtonRadius: ViewStyle['borderRadius'] = AVATAR_ROUNDED_BORDER_RADIUS;
65
+ tabItemStyles: any = TAB_ITEM_STYLE; // Default value
66
+ tabItemTextStyles: any = TAB_ITEM_TXT_STYLE; // Default value
67
+ inputStyles: InputThemeSize = inputTheme;
68
+ spacing = spacing; // Add spacing to theme
69
+ colors = LightColorTokens(); // Add colors to theme
70
+ dimensions = dimensions; // Add dimensions to theme
71
+
72
+ constructor(params?: Partial<SliceTheme>) {
73
+ if (params) {
74
+ Object.assign(this, params);
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Updates the most deeply nested properties in the theme object.
80
+ * Uses recursion to merge nested structures.
81
+ *
82
+ * @param updates A partial update object to apply changes deeply.
83
+ */
84
+ updateNestedStyles(updates: Partial<SliceTheme>) {
85
+ const mergeDeep = (target: any, source: any) => {
86
+ if (typeof target !== 'object' || target === null) {
87
+ return source; // Replace if not an object
88
+ }
89
+ if (typeof source !== 'object' || source === null) {
90
+ return source;
91
+ }
92
+
93
+ for (const key of Object.keys(source)) {
94
+ if (source[key] instanceof Object) {
95
+ target[key] = mergeDeep(target[key] || {}, source[key]);
96
+ } else {
97
+ target[key] = source[key];
98
+ }
99
+ }
100
+ return target;
101
+ };
102
+
103
+ mergeDeep(this, updates);
104
+ }
105
+ }
106
+
107
+ export const theme = new SliceTheme(); // Instantiates with default values
@@ -0,0 +1,62 @@
1
+ import { foundationTypography } from './FoundationToken';
2
+
3
+ export const baseTypographyToken = {
4
+ display: {
5
+ display1: {
6
+ fontSize: foundationTypography.fontSize.fontSizeThirteenHundred,
7
+ lineHeight: foundationTypography.lineHeight.fontLineHeight1200,
8
+ },
9
+ display2: {
10
+ fontSize: foundationTypography.fontSize.fontSizeTwelveHundred,
11
+ lineHeight: foundationTypography.lineHeight.fontLineHeight1100,
12
+ },
13
+ display3: {
14
+ fontSize: foundationTypography.fontSize.fontSizeElevenHundred,
15
+ lineHeight: foundationTypography.lineHeight.fontLineHeight1000,
16
+ },
17
+ display4: {
18
+ fontSize: foundationTypography.fontSize.fontSizeThousand,
19
+ lineHeight: foundationTypography.lineHeight.fontLineHeight900,
20
+ },
21
+ },
22
+ heading: {
23
+ heading1: {
24
+ fontSize: foundationTypography.fontSize.fontSizeNineHundred,
25
+ lineHeight: foundationTypography.lineHeight.fontLineHeight800,
26
+ },
27
+ heading2: {
28
+ fontSize: foundationTypography.fontSize.fontSizeEightHundred,
29
+ lineHeight: foundationTypography.lineHeight.fontLineHeight700,
30
+ },
31
+ heading3: {
32
+ fontSize: foundationTypography.fontSize.fontSizeSevenHundred,
33
+ lineHeight: foundationTypography.lineHeight.fontLineHeight600,
34
+ },
35
+ heading4: {
36
+ fontSize: foundationTypography.fontSize.fontSizeSixHundred,
37
+ lineHeight: foundationTypography.lineHeight.fontLineHeight500,
38
+ },
39
+ heading5: {
40
+ fontSize: foundationTypography.fontSize.fontSizeFiveHundred,
41
+ lineHeight: foundationTypography.lineHeight.fontLineHeight400,
42
+ },
43
+ },
44
+ body: {
45
+ body1: {
46
+ fontSize: foundationTypography.fontSize.fontSizeFourHundred,
47
+ lineHeight: foundationTypography.lineHeight.fontLineHeight400,
48
+ },
49
+ body2: {
50
+ fontSize: foundationTypography.fontSize.fontSizeThreeHundred,
51
+ lineHeight: foundationTypography.lineHeight.fontLineHeight300,
52
+ },
53
+ body3: {
54
+ fontSize: foundationTypography.fontSize.fontSizeTwoHundred,
55
+ lineHeight: foundationTypography.lineHeight.fontLineHeight200,
56
+ },
57
+ body4: {
58
+ fontSize: foundationTypography.fontSize.fontSizeHundred,
59
+ lineHeight: foundationTypography.lineHeight.fontLineHeight100,
60
+ },
61
+ },
62
+ };
@@ -0,0 +1,48 @@
1
+ import {dimensions} from '../values/Dimension';
2
+
3
+ export const foundationTypography = {
4
+ fontFamily: {
5
+ latoRegular: 'Lato-Regular',
6
+ latoMedium: 'Lato-Medium',
7
+ latoBold: 'Lato-Bold',
8
+ latoHeavy: 'Lato-Heavy',
9
+ latoBlack: 'Lato-Black',
10
+ },
11
+ fontWeight: {
12
+ fontWeightRegular: 400,
13
+ fontWeightMedium: 500,
14
+ fontWeightBold: 700,
15
+ fontWeightHeavy: 800,
16
+ fontWeightBlack: 900,
17
+ },
18
+
19
+ fontSize: {
20
+ fontSizeHundred: dimensions.dimension05,
21
+ fontSizeTwoHundred: dimensions.dimension06,
22
+ fontSizeThreeHundred: dimensions.dimension07,
23
+ fontSizeFourHundred: dimensions.dimension08,
24
+ fontSizeFiveHundred: dimensions.dimension09,
25
+ fontSizeSixHundred: dimensions.dimension10,
26
+ fontSizeSevenHundred: dimensions.dimension12,
27
+ fontSizeEightHundred: dimensions.dimension16,
28
+ fontSizeNineHundred: dimensions.dimension17,
29
+ fontSizeThousand: dimensions.dimension18,
30
+ fontSizeElevenHundred: dimensions.dimension19,
31
+ fontSizeTwelveHundred: dimensions.dimension20,
32
+ fontSizeThirteenHundred: dimensions.dimension21,
33
+ },
34
+ lineHeight: {
35
+ fontLineHeight100: dimensions.dimension07,
36
+ fontLineHeight200: dimensions.dimension09,
37
+ fontLineHeight300: dimensions.dimension10,
38
+ fontLineHeight400: dimensions.dimension12,
39
+ fontLineHeight500: dimensions.dimension14,
40
+ fontLineHeight600: dimensions.dimension16,
41
+ fontLineHeight700: dimensions.dimension17,
42
+ fontLineHeight800: dimensions.dimension18,
43
+ fontLineHeight900: dimensions.dimension19,
44
+ fontLineHeight1000: dimensions.dimension20,
45
+ fontLineHeight1100: dimensions.dimension21,
46
+ fontLineHeight1200: dimensions.dimension22,
47
+ },
48
+ };