@ganpatiinfo/gids-web-dom-reference 12.0.0 → 14.0.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 (172) hide show
  1. package/CHANGELOG.md +131 -2
  2. package/dist/components/GidsAdvancedTooltip/GidsAdvancedTooltip.d.ts +8 -0
  3. package/dist/components/GidsAdvancedTooltip/GidsAdvancedTooltip.d.ts.map +1 -0
  4. package/dist/components/GidsAdvancedTooltip/GidsAdvancedTooltip.js +14 -0
  5. package/dist/components/GidsAdvancedTooltip/GidsAdvancedTooltip.js.map +1 -0
  6. package/dist/components/GidsBasicTableBody/GidsBasicTableBody.d.ts +26 -3
  7. package/dist/components/GidsBasicTableBody/GidsBasicTableBody.d.ts.map +1 -1
  8. package/dist/components/GidsBasicTableBody/GidsBasicTableBody.js +22 -3
  9. package/dist/components/GidsBasicTableBody/GidsBasicTableBody.js.map +1 -1
  10. package/dist/components/GidsBasicTableHead/GidsBasicTableHead.d.ts +15 -0
  11. package/dist/components/GidsBasicTableHead/GidsBasicTableHead.d.ts.map +1 -1
  12. package/dist/components/GidsBasicTableHead/GidsBasicTableHead.js +5 -0
  13. package/dist/components/GidsBasicTableHead/GidsBasicTableHead.js.map +1 -1
  14. package/dist/components/GidsBasicTableHeader/GidsBasicTableHeader.d.ts +26 -3
  15. package/dist/components/GidsBasicTableHeader/GidsBasicTableHeader.d.ts.map +1 -1
  16. package/dist/components/GidsBasicTableHeader/GidsBasicTableHeader.js +9 -1
  17. package/dist/components/GidsBasicTableHeader/GidsBasicTableHeader.js.map +1 -1
  18. package/dist/components/GidsBasicTableRow/GidsBasicTableRow.d.ts +22 -3
  19. package/dist/components/GidsBasicTableRow/GidsBasicTableRow.d.ts.map +1 -1
  20. package/dist/components/GidsBasicTableRow/GidsBasicTableRow.js +27 -6
  21. package/dist/components/GidsBasicTableRow/GidsBasicTableRow.js.map +1 -1
  22. package/dist/components/GidsBsTable/GidsBsTable.d.ts +26 -3
  23. package/dist/components/GidsBsTable/GidsBsTable.d.ts.map +1 -1
  24. package/dist/components/GidsBsTable/GidsBsTable.js +36 -14
  25. package/dist/components/GidsBsTable/GidsBsTable.js.map +1 -1
  26. package/dist/components/GidsChartLegendItem/GidsChartLegendItem.d.ts +1 -1
  27. package/dist/components/GidsChartLegendItem/GidsChartLegendItem.d.ts.map +1 -1
  28. package/dist/components/GidsChartLegendItem/GidsChartLegendItem.js +2 -1
  29. package/dist/components/GidsChartLegendItem/GidsChartLegendItem.js.map +1 -1
  30. package/dist/components/GidsColorSwatch/GidsColorSwatch.d.ts +8 -0
  31. package/dist/components/GidsColorSwatch/GidsColorSwatch.d.ts.map +1 -0
  32. package/dist/components/GidsColorSwatch/GidsColorSwatch.js +62 -0
  33. package/dist/components/GidsColorSwatch/GidsColorSwatch.js.map +1 -0
  34. package/dist/components/GidsCrossTable/GidsCrossTable.d.ts +18 -0
  35. package/dist/components/GidsCrossTable/GidsCrossTable.d.ts.map +1 -0
  36. package/dist/components/GidsCrossTable/GidsCrossTable.js +141 -0
  37. package/dist/components/GidsCrossTable/GidsCrossTable.js.map +1 -0
  38. package/dist/components/GidsCrossTableBody/GidsCrossTableBody.d.ts +13 -0
  39. package/dist/components/GidsCrossTableBody/GidsCrossTableBody.d.ts.map +1 -0
  40. package/dist/components/GidsCrossTableBody/GidsCrossTableBody.js +79 -0
  41. package/dist/components/GidsCrossTableBody/GidsCrossTableBody.js.map +1 -0
  42. package/dist/components/GidsCrossTableRow/GidsCrossTableRow.d.ts +13 -0
  43. package/dist/components/GidsCrossTableRow/GidsCrossTableRow.d.ts.map +1 -0
  44. package/dist/components/GidsCrossTableRow/GidsCrossTableRow.js +128 -0
  45. package/dist/components/GidsCrossTableRow/GidsCrossTableRow.js.map +1 -0
  46. package/dist/components/GidsDialog/GidsDialog.d.ts +13 -0
  47. package/dist/components/GidsDialog/GidsDialog.d.ts.map +1 -0
  48. package/dist/components/GidsDialog/GidsDialog.js +102 -0
  49. package/dist/components/GidsDialog/GidsDialog.js.map +1 -0
  50. package/dist/components/GidsMatrixTable/GidsMatrixTable.d.ts +32 -0
  51. package/dist/components/GidsMatrixTable/GidsMatrixTable.d.ts.map +1 -0
  52. package/dist/components/GidsMatrixTable/GidsMatrixTable.js +75 -0
  53. package/dist/components/GidsMatrixTable/GidsMatrixTable.js.map +1 -0
  54. package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.d.ts +32 -0
  55. package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.d.ts.map +1 -0
  56. package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.js +75 -0
  57. package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.js.map +1 -0
  58. package/dist/components/GidsMdTable/GidsMdTable.d.ts +11 -2
  59. package/dist/components/GidsMdTable/GidsMdTable.d.ts.map +1 -1
  60. package/dist/components/GidsMdTable/GidsMdTable.js +3 -0
  61. package/dist/components/GidsMdTable/GidsMdTable.js.map +1 -1
  62. package/dist/components/GidsMenu/GidsMenu.d.ts +1 -1
  63. package/dist/components/GidsMenu/GidsMenu.d.ts.map +1 -1
  64. package/dist/components/GidsMenu/GidsMenu.js +10 -1
  65. package/dist/components/GidsMenu/GidsMenu.js.map +1 -1
  66. package/dist/components/GidsPagination/GidsPagination.d.ts +10 -0
  67. package/dist/components/GidsPagination/GidsPagination.d.ts.map +1 -1
  68. package/dist/components/GidsPagination/GidsPagination.js +5 -0
  69. package/dist/components/GidsPagination/GidsPagination.js.map +1 -1
  70. package/dist/components/GidsPaginator/GidsPaginator.d.ts +8 -0
  71. package/dist/components/GidsPaginator/GidsPaginator.d.ts.map +1 -0
  72. package/dist/components/GidsPaginator/GidsPaginator.js +154 -0
  73. package/dist/components/GidsPaginator/GidsPaginator.js.map +1 -0
  74. package/dist/components/GidsPaginatorItem/GidsPaginatorItem.d.ts +9 -0
  75. package/dist/components/GidsPaginatorItem/GidsPaginatorItem.d.ts.map +1 -0
  76. package/dist/components/GidsPaginatorItem/GidsPaginatorItem.js +33 -0
  77. package/dist/components/GidsPaginatorItem/GidsPaginatorItem.js.map +1 -0
  78. package/dist/components/GidsSkeleton/GidsSkeleton.d.ts +8 -0
  79. package/dist/components/GidsSkeleton/GidsSkeleton.d.ts.map +1 -0
  80. package/dist/components/GidsSkeleton/GidsSkeleton.js +16 -0
  81. package/dist/components/GidsSkeleton/GidsSkeleton.js.map +1 -0
  82. package/dist/components/GidsTable/GidsTable.d.ts +18 -0
  83. package/dist/components/GidsTable/GidsTable.d.ts.map +1 -0
  84. package/dist/components/GidsTable/GidsTable.js +121 -0
  85. package/dist/components/GidsTable/GidsTable.js.map +1 -0
  86. package/dist/components/GidsTableBody/GidsTableBody.d.ts +13 -0
  87. package/dist/components/GidsTableBody/GidsTableBody.d.ts.map +1 -0
  88. package/dist/components/GidsTableBody/GidsTableBody.js +61 -0
  89. package/dist/components/GidsTableBody/GidsTableBody.js.map +1 -0
  90. package/dist/components/GidsTableCell/GidsTableCell.d.ts +28 -0
  91. package/dist/components/GidsTableCell/GidsTableCell.d.ts.map +1 -0
  92. package/dist/components/GidsTableCell/GidsTableCell.js +146 -0
  93. package/dist/components/GidsTableCell/GidsTableCell.js.map +1 -0
  94. package/dist/components/GidsTableEntry/GidsTableEntry.d.ts +13 -0
  95. package/dist/components/GidsTableEntry/GidsTableEntry.d.ts.map +1 -0
  96. package/dist/components/GidsTableEntry/GidsTableEntry.js +305 -0
  97. package/dist/components/GidsTableEntry/GidsTableEntry.js.map +1 -0
  98. package/dist/components/GidsTableFooter/GidsTableFooter.d.ts +13 -0
  99. package/dist/components/GidsTableFooter/GidsTableFooter.d.ts.map +1 -0
  100. package/dist/components/GidsTableFooter/GidsTableFooter.js +53 -0
  101. package/dist/components/GidsTableFooter/GidsTableFooter.js.map +1 -0
  102. package/dist/components/GidsTableFooterControl/GidsTableFooterControl.d.ts +11 -0
  103. package/dist/components/GidsTableFooterControl/GidsTableFooterControl.d.ts.map +1 -0
  104. package/dist/components/GidsTableFooterControl/GidsTableFooterControl.js +99 -0
  105. package/dist/components/GidsTableFooterControl/GidsTableFooterControl.js.map +1 -0
  106. package/dist/components/GidsTableHeader/GidsTableHeader.d.ts +13 -0
  107. package/dist/components/GidsTableHeader/GidsTableHeader.d.ts.map +1 -0
  108. package/dist/components/GidsTableHeader/GidsTableHeader.js +49 -0
  109. package/dist/components/GidsTableHeader/GidsTableHeader.js.map +1 -0
  110. package/dist/components/GidsTableRow/GidsTableRow.d.ts +13 -0
  111. package/dist/components/GidsTableRow/GidsTableRow.d.ts.map +1 -0
  112. package/dist/components/GidsTableRow/GidsTableRow.js +71 -0
  113. package/dist/components/GidsTableRow/GidsTableRow.js.map +1 -0
  114. package/dist/components/GidsTableToolbar/GidsTableToolbar.d.ts +11 -0
  115. package/dist/components/GidsTableToolbar/GidsTableToolbar.d.ts.map +1 -0
  116. package/dist/components/GidsTableToolbar/GidsTableToolbar.js +92 -0
  117. package/dist/components/GidsTableToolbar/GidsTableToolbar.js.map +1 -0
  118. package/dist/components/GidsTransferList/GidsTransferList.d.ts +8 -0
  119. package/dist/components/GidsTransferList/GidsTransferList.d.ts.map +1 -0
  120. package/dist/components/GidsTransferList/GidsTransferList.js +25 -0
  121. package/dist/components/GidsTransferList/GidsTransferList.js.map +1 -0
  122. package/dist/components/_GidsDialogControl/GidsDialogControl.d.ts +10 -0
  123. package/dist/components/_GidsDialogControl/GidsDialogControl.d.ts.map +1 -0
  124. package/dist/components/_GidsDialogControl/GidsDialogControl.js +133 -0
  125. package/dist/components/_GidsDialogControl/GidsDialogControl.js.map +1 -0
  126. package/dist/components/_GidsPaginationItem/GidsPaginationItem.d.ts +10 -0
  127. package/dist/components/_GidsPaginationItem/GidsPaginationItem.d.ts.map +1 -1
  128. package/dist/components/_GidsPaginationItem/GidsPaginationItem.js +5 -0
  129. package/dist/components/_GidsPaginationItem/GidsPaginationItem.js.map +1 -1
  130. package/dist/index.d.ts +118 -97
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +118 -97
  133. package/dist/index.js.map +1 -1
  134. package/package.json +4 -4
  135. package/src/components/GidsAdvancedTooltip/GidsAdvancedTooltip.ts +42 -0
  136. package/src/components/GidsBasicTableBody/GidsBasicTableBody.ts +66 -5
  137. package/src/components/GidsBasicTableHead/GidsBasicTableHead.ts +15 -0
  138. package/src/components/GidsBasicTableHeader/GidsBasicTableHeader.ts +45 -5
  139. package/src/components/GidsBasicTableRow/GidsBasicTableRow.ts +65 -7
  140. package/src/components/GidsBsTable/GidsBsTable.ts +81 -19
  141. package/src/components/GidsChartLegendItem/GidsChartLegendItem.ts +2 -0
  142. package/src/components/GidsColorSwatch/GidsColorSwatch.ts +107 -0
  143. package/src/components/GidsCrossTable/GidsCrossTable.ts +259 -0
  144. package/src/components/GidsCrossTableBody/GidsCrossTableBody.ts +171 -0
  145. package/src/components/GidsCrossTableRow/GidsCrossTableRow.ts +230 -0
  146. package/src/components/GidsDialog/GidsDialog.ts +161 -0
  147. package/src/components/GidsMatrixTable/GidsMatrixTable.ts +187 -0
  148. package/src/components/GidsMatrixTableBody/GidsMatrixTableBody.ts +185 -0
  149. package/src/components/GidsMdTable/GidsMdTable.ts +14 -2
  150. package/src/components/GidsMenu/GidsMenu.ts +15 -0
  151. package/src/components/GidsPagination/GidsPagination.ts +14 -2
  152. package/src/components/GidsPaginator/GidsPaginator.ts +241 -0
  153. package/src/components/GidsPaginatorItem/GidsPaginatorItem.ts +72 -0
  154. package/src/components/GidsSkeleton/GidsSkeleton.ts +40 -0
  155. package/src/components/GidsTable/GidsTable.ts +240 -0
  156. package/src/components/GidsTableBody/GidsTableBody.ts +137 -0
  157. package/src/components/GidsTableCell/GidsTableCell.ts +276 -0
  158. package/src/components/GidsTableEntry/GidsTableEntry.ts +515 -0
  159. package/src/components/GidsTableFooter/GidsTableFooter.ts +119 -0
  160. package/src/components/GidsTableFooterControl/GidsTableFooterControl.ts +166 -0
  161. package/src/components/GidsTableHeader/GidsTableHeader.ts +112 -0
  162. package/src/components/GidsTableRow/GidsTableRow.ts +152 -0
  163. package/src/components/GidsTableToolbar/GidsTableToolbar.ts +180 -0
  164. package/src/components/GidsTransferList/GidsTransferList.ts +58 -0
  165. package/src/components/_GidsDialogControl/GidsDialogControl.ts +198 -0
  166. package/src/components/_GidsPaginationItem/GidsPaginationItem.ts +14 -2
  167. package/src/index.ts +118 -97
  168. package/dist/components/GidsBasicTableCell/GidsBasicTableCell.d.ts +0 -9
  169. package/dist/components/GidsBasicTableCell/GidsBasicTableCell.d.ts.map +0 -1
  170. package/dist/components/GidsBasicTableCell/GidsBasicTableCell.js +0 -48
  171. package/dist/components/GidsBasicTableCell/GidsBasicTableCell.js.map +0 -1
  172. package/src/components/GidsBasicTableCell/GidsBasicTableCell.ts +0 -99
@@ -0,0 +1,240 @@
1
+ import {
2
+ GidsTableEntryTypographyStyle,
3
+ GidsTableWebProps,
4
+ GidsTableWebUtils,
5
+ isValidChildren,
6
+ } from '@ganpatiinfo/gids-web-shared';
7
+ import { appendAsChildren, DomChildren } from '../../utils/domUtils';
8
+ import { HtmlInputAttributes } from '../GidsInput/GidsInput';
9
+ import {
10
+ IconAppearance,
11
+ IconName,
12
+ } from '@ganpatiinfo/gids-web-theme-interface';
13
+ import {
14
+ GidsInputStatus,
15
+ GidsTableActionEvent,
16
+ GidsTableToolbarSettings,
17
+ } from '@ganpatiinfo/gids-core-shared';
18
+ import {
19
+ GidsTableToolbarDom,
20
+ GidsTableToolbarDomProps,
21
+ } from '../GidsTableToolbar/GidsTableToolbar';
22
+ import {
23
+ GidsTableHeaderActionBaseEvent,
24
+ GidsTableHeaderDom,
25
+ } from '../GidsTableHeader/GidsTableHeader';
26
+ import {
27
+ GidsTableBodyActionBaseEvent,
28
+ GidsTableBodyDom,
29
+ } from '../GidsTableBody/GidsTableBody';
30
+ import { GidsTableFooterDom } from '../GidsTableFooter/GidsTableFooter';
31
+ import { GidsTableFooterControlDom } from '../GidsTableFooterControl/GidsTableFooterControl';
32
+
33
+ const {
34
+ getGidsTableClassNames,
35
+ getCustomisedTableHeaderEntries,
36
+ getCustomisedTableFooterEntries,
37
+ getTableBodyBorder,
38
+ } = GidsTableWebUtils;
39
+
40
+ export type GidsTableToolbarBaseSettings = GidsTableToolbarSettings<
41
+ DomChildren,
42
+ Event,
43
+ Element,
44
+ HtmlInputAttributes,
45
+ GidsInputStatus
46
+ > &
47
+ Pick<
48
+ GidsTableToolbarDomProps,
49
+ 'onChange' | 'onInput' | 'onFocus' | 'onBlur' | 'onGidsSearchBarClear'
50
+ >;
51
+
52
+ type GidsTableBaseWebProps = Omit<
53
+ GidsTableWebProps<
54
+ DomChildren,
55
+ GidsTableEntryTypographyStyle,
56
+ IconName,
57
+ IconAppearance,
58
+ DomChildren,
59
+ Event,
60
+ Element,
61
+ HtmlInputAttributes
62
+ >,
63
+ 'toolbarSettings'
64
+ > & {
65
+ toolbarSettings?: GidsTableToolbarBaseSettings;
66
+ };
67
+
68
+ type GidsTableActionBaseEvent = GidsTableActionEvent<
69
+ Event,
70
+ GidsTableEntryTypographyStyle,
71
+ IconName,
72
+ IconAppearance
73
+ >;
74
+
75
+ export interface GidsTableDomProps extends GidsTableBaseWebProps {
76
+ extraClasses?: string;
77
+ onTableAction?: (event: GidsTableActionBaseEvent) => void;
78
+ }
79
+
80
+ export const GidsTableDom = ({
81
+ toolbar,
82
+ toolbarChildren,
83
+ children,
84
+ headerItems = [],
85
+ bodyContent = [],
86
+ isHeaderVisible,
87
+ isToolbarVisible,
88
+ bodySettings,
89
+ toolbarSettings,
90
+ headerSettings,
91
+ tableBorders,
92
+ tableBorderRadius,
93
+ tableBodyMaxHeight = 200,
94
+ horizontalScroll = false,
95
+ onTableAction,
96
+ footerItems = [],
97
+ footerSettings,
98
+ isFooterVisible = false,
99
+ isFooterControlVisible = false,
100
+ footerControlSettings,
101
+ footerControl,
102
+ extraClasses,
103
+ }: GidsTableDomProps): HTMLDivElement => {
104
+ const tableDiv = document.createElement('div');
105
+
106
+ tableDiv.className = getGidsTableClassNames(
107
+ { tableBorders, tableBorderRadius },
108
+ extraClasses,
109
+ );
110
+
111
+ /*
112
+ * Toolbar
113
+ */
114
+ if (isValidChildren(toolbar)) {
115
+ appendAsChildren(tableDiv, toolbar);
116
+ } else if (isToolbarVisible) {
117
+ tableDiv.append(
118
+ GidsTableToolbarDom({
119
+ ...toolbarSettings,
120
+ children: toolbarChildren as Element,
121
+ }),
122
+ );
123
+ }
124
+
125
+ /*
126
+ * Scroll container
127
+ */
128
+ const tableScrollContainer = document.createElement('div');
129
+ tableScrollContainer.className = [
130
+ 'gids-table__scroll-container',
131
+ horizontalScroll ? 'gids-table__scroll-container--horizontal-scroll' : '',
132
+ ]
133
+ .filter(Boolean)
134
+ .join(' ');
135
+
136
+ if (tableBodyMaxHeight) {
137
+ tableScrollContainer.style.maxHeight = `${tableBodyMaxHeight}px`;
138
+ }
139
+
140
+ /*
141
+ * Table
142
+ */
143
+ const table = document.createElement('table');
144
+ table.className = 'gids-table--main-table';
145
+
146
+ /*
147
+ * Custom children
148
+ */
149
+ if (isValidChildren(children)) {
150
+ appendAsChildren(table, children);
151
+ } else {
152
+ function onActionBtnClick(
153
+ event: GidsTableHeaderActionBaseEvent | GidsTableBodyActionBaseEvent,
154
+ ) {
155
+ if (onTableAction) {
156
+ onTableAction({
157
+ ...event,
158
+ details: {
159
+ ...event.details,
160
+ columnIndex: event?.details?.entryIndex,
161
+ },
162
+ });
163
+ }
164
+ }
165
+
166
+ /*
167
+ * Header
168
+ */
169
+ if (isHeaderVisible && headerItems && headerItems.length > 0) {
170
+ table.append(
171
+ GidsTableHeaderDom({
172
+ ...headerSettings,
173
+ headerItems: getCustomisedTableHeaderEntries({
174
+ headerItems,
175
+ tableBorders,
176
+ }),
177
+ onHeaderAction: onActionBtnClick,
178
+ }),
179
+ );
180
+ }
181
+
182
+ /*
183
+ * Body
184
+ */
185
+ if (bodyContent && bodyContent.length > 0) {
186
+ table.append(
187
+ GidsTableBodyDom({
188
+ bodyBorder: getTableBodyBorder({
189
+ tableBorders,
190
+ }),
191
+ bodyContent,
192
+ bodySettings,
193
+ onBodyAction: onActionBtnClick,
194
+ }),
195
+ );
196
+ }
197
+
198
+ /**
199
+ * Footer
200
+ */
201
+ if (isFooterVisible && footerItems && footerItems.length > 0) {
202
+ table.append(
203
+ GidsTableFooterDom({
204
+ ...footerSettings,
205
+ footerItems: getCustomisedTableFooterEntries({
206
+ footerItems,
207
+ tableBorders,
208
+ }),
209
+ onFooterAction: onActionBtnClick,
210
+ }),
211
+ );
212
+ }
213
+ }
214
+
215
+ /*
216
+ * Final DOM:
217
+ *
218
+ * tableDiv
219
+ * └── scrollContainer
220
+ * └── table
221
+ */
222
+ tableScrollContainer.appendChild(table);
223
+ tableDiv.appendChild(tableScrollContainer);
224
+
225
+ /*
226
+ * Table Footer Control
227
+ */
228
+ if (isFooterControlVisible || isValidChildren(footerControl)) {
229
+ tableDiv.append(
230
+ GidsTableFooterControlDom({
231
+ ...footerControlSettings,
232
+ tableViewControllerSettings:
233
+ footerControlSettings?.tableViewControllerSettings,
234
+ children: footerControl,
235
+ }),
236
+ );
237
+ }
238
+
239
+ return tableDiv;
240
+ };
@@ -0,0 +1,137 @@
1
+ import {
2
+ GidsTableBodyWebProps,
3
+ GidsTableBodyWebUtils,
4
+ GidsTableEntryTypographyStyle,
5
+ isValidChildren,
6
+ } from '@ganpatiinfo/gids-web-shared';
7
+ import {
8
+ GidsTableRowActionBaseEvent,
9
+ GidsTableRowDom,
10
+ } from '../GidsTableRow/GidsTableRow';
11
+ import {
12
+ IconAppearance,
13
+ IconName,
14
+ } from '@ganpatiinfo/gids-web-theme-interface';
15
+ import { GidsTableBodyActionEvent } from '@ganpatiinfo/gids-core-shared';
16
+ import { appendAsChildren, DomChildren } from '../../utils/domUtils';
17
+
18
+ const {
19
+ getGidsTableBodyClassNames,
20
+ getConstructedTableBodyContent,
21
+ getTableBodyRowEntryBackgroundColor,
22
+ getTableBodyRowEntryContentColor,
23
+ getTableBodyRowEntryActionsBackgroundColor,
24
+ getTableBodyRowEntryActionsContentColor,
25
+ } = GidsTableBodyWebUtils;
26
+
27
+ type GidsTableBodyBaseWebProps = GidsTableBodyWebProps<
28
+ GidsTableEntryTypographyStyle,
29
+ IconName,
30
+ IconAppearance,
31
+ DomChildren
32
+ >;
33
+ export type GidsTableBodyActionBaseEvent = GidsTableBodyActionEvent<
34
+ Event,
35
+ GidsTableEntryTypographyStyle,
36
+ IconName,
37
+ IconAppearance
38
+ >;
39
+
40
+ export interface GidsTableBodyDomProps extends GidsTableBodyBaseWebProps {
41
+ extraClasses?: string;
42
+ onBodyAction?: (event: GidsTableBodyActionBaseEvent) => void;
43
+ }
44
+
45
+ export const GidsTableBodyDom = ({
46
+ bodySettings,
47
+ bodyContent = [],
48
+ bodyBorder = 'none',
49
+ children,
50
+ onBodyAction,
51
+ extraClasses,
52
+ }: GidsTableBodyDomProps): HTMLElement => {
53
+ const tableBody = document.createElement('tbody');
54
+ tableBody.className = getGidsTableBodyClassNames(extraClasses);
55
+
56
+ if (isValidChildren(children)) {
57
+ appendAsChildren(tableBody, children);
58
+ } else {
59
+ if (bodyContent && bodyContent.length > 0) {
60
+ const constructedTableBodyContent = getConstructedTableBodyContent({
61
+ bodyContent,
62
+ bodyBorder,
63
+ });
64
+
65
+ function onRowActionBtnClick({
66
+ event,
67
+ rowIndex,
68
+ }: {
69
+ event: GidsTableRowActionBaseEvent;
70
+ rowIndex: number;
71
+ }) {
72
+ if (onBodyAction) {
73
+ onBodyAction({
74
+ ...event,
75
+ details: {
76
+ ...event.details,
77
+ rowIndex,
78
+ },
79
+ });
80
+ }
81
+ }
82
+
83
+ constructedTableBodyContent.forEach((constructedBody, indexI) => {
84
+ const constructedBodyRowItems = constructedBody?.rowItems ?? [];
85
+
86
+ const rowBgColor = getTableBodyRowEntryBackgroundColor<
87
+ GidsTableEntryTypographyStyle,
88
+ IconName,
89
+ IconAppearance
90
+ >({
91
+ bodySettings,
92
+ rowIndex: indexI,
93
+ });
94
+ const rowContentColor = getTableBodyRowEntryContentColor<
95
+ GidsTableEntryTypographyStyle,
96
+ IconName,
97
+ IconAppearance
98
+ >({
99
+ bodySettings,
100
+ rowIndex: indexI,
101
+ });
102
+ const rowActionsBgColor = getTableBodyRowEntryActionsBackgroundColor<
103
+ GidsTableEntryTypographyStyle,
104
+ IconName,
105
+ IconAppearance
106
+ >({
107
+ bodySettings,
108
+ rowIndex: indexI,
109
+ });
110
+ const rowActionsContentColor = getTableBodyRowEntryActionsContentColor<
111
+ GidsTableEntryTypographyStyle,
112
+ IconName,
113
+ IconAppearance
114
+ >({
115
+ bodySettings,
116
+ rowIndex: indexI,
117
+ });
118
+
119
+ tableBody.append(
120
+ GidsTableRowDom({
121
+ ...bodySettings,
122
+ actionsBackgroundColor: rowActionsBgColor,
123
+ actionsContentColor: rowActionsContentColor,
124
+ backgroundColor: rowBgColor,
125
+ contentColor: rowContentColor,
126
+ rowType: 'body',
127
+ rows: constructedBodyRowItems,
128
+ onRowAction: (event: GidsTableRowActionBaseEvent) =>
129
+ onRowActionBtnClick({ event, rowIndex: indexI }),
130
+ }),
131
+ );
132
+ });
133
+ }
134
+ }
135
+
136
+ return tableBody;
137
+ };
@@ -0,0 +1,276 @@
1
+ import {
2
+ GidsTableCellTypographyStyle,
3
+ GidsTableCellWebProps,
4
+ GidsTableCellWebUtils,
5
+ } from '@ganpatiinfo/gids-web-shared';
6
+ import { appendAsChildren } from '../../utils/domUtils';
7
+ import {
8
+ IconAppearance,
9
+ IconName,
10
+ } from '@ganpatiinfo/gids-web-theme-interface';
11
+ import { GidsDisplayTagDom } from '../GidsDisplayTag/GidsDisplayTag';
12
+ import { GidsIconDom } from '../GidsIcon/GidsIcon';
13
+ import {
14
+ GetTableCellButtonIconNeedType,
15
+ GidsTableCellActionButtonEvent,
16
+ GidsTableCellActionButtonSharedTypes,
17
+ GidsTableCellCommonUtils,
18
+ GidsTableCellActionButtonPosition,
19
+ } from '@ganpatiinfo/gids-core-shared';
20
+ import { GidsButtonDom } from '../GidsButton/GidsButton';
21
+
22
+ const { getGidsTableCellClassNames, getGidsTableCellLabelTypographyClass } =
23
+ GidsTableCellWebUtils;
24
+ const { isTableCellActionButtonVisible, getTableCellBtnIcon } =
25
+ GidsTableCellCommonUtils;
26
+
27
+ /**
28
+ * @deprecated
29
+ * Use `GidsTableEntry` and its props and functions
30
+ */
31
+ type GidsTableCellBaseWebProps = GidsTableCellWebProps<
32
+ GidsTableCellTypographyStyle,
33
+ IconName,
34
+ IconAppearance
35
+ >;
36
+
37
+ /**
38
+ * @deprecated
39
+ * Use `GidsTableEntry` and its props and functions
40
+ */
41
+ export type GidsTableCellActionButtonBaseEvent = GidsTableCellActionButtonEvent<
42
+ Event,
43
+ GidsTableCellTypographyStyle,
44
+ IconName,
45
+ IconAppearance
46
+ >;
47
+
48
+ /**
49
+ * @deprecated
50
+ * Use `GidsTableEntry` and its props and functions
51
+ */
52
+ export interface GidsTableCellDomProps extends GidsTableCellBaseWebProps {
53
+ extraClasses?: string;
54
+ onClickCellActionBtn?: (event: GidsTableCellActionButtonBaseEvent) => void;
55
+ }
56
+
57
+ /**
58
+ * @deprecated
59
+ * Use `GidsTableEntry` and its props and functions
60
+ */
61
+ export const GidsTableCellDom = ({
62
+ id,
63
+ uniqueKey,
64
+ extraData,
65
+ label,
66
+ cellDataType = 'text',
67
+ displayTags = [],
68
+ width = 'full',
69
+ borderSides = [],
70
+ borderRadiusSides = [],
71
+ appearance = 'none',
72
+ textAlignment = 'center',
73
+ labelTypography = 'label-medium',
74
+ isHeaderCell = false,
75
+ cellPrimaryActionButtons = [],
76
+ cellSecondaryActionButtons = [],
77
+ onClickCellActionBtn,
78
+ extraClasses,
79
+ }: GidsTableCellDomProps): HTMLElement => {
80
+ const cellTag = isHeaderCell ? 'th' : 'td';
81
+ const tableCell = document.createElement(cellTag);
82
+ tableCell.className = getGidsTableCellClassNames(
83
+ { borderSides, borderRadiusSides, appearance, textAlignment, width },
84
+ extraClasses,
85
+ );
86
+
87
+ if (id) {
88
+ tableCell.setAttribute('id', id);
89
+ }
90
+
91
+ if (uniqueKey) {
92
+ tableCell.setAttribute('unique-key', uniqueKey);
93
+ }
94
+
95
+ if (extraData) {
96
+ tableCell.setAttribute('extra-data', JSON.stringify(extraData));
97
+ }
98
+
99
+ function makeCellActionBtnIcon({
100
+ cellActionBtn,
101
+ neededIconType = 'leading',
102
+ }: {
103
+ cellActionBtn?: GidsTableCellActionButtonSharedTypes<
104
+ IconName,
105
+ IconAppearance
106
+ >;
107
+ neededIconType?: GetTableCellButtonIconNeedType;
108
+ }) {
109
+ const tableCellBtnIcon = getTableCellBtnIcon<IconName, IconAppearance>({
110
+ cellActionButton: cellActionBtn,
111
+ neededIconType,
112
+ });
113
+
114
+ return tableCellBtnIcon?.cellIconName &&
115
+ tableCellBtnIcon.cellIconName.toString() !== ''
116
+ ? GidsIconDom({
117
+ name: tableCellBtnIcon.cellIconName,
118
+ size: tableCellBtnIcon.cellIconSize,
119
+ appearance: tableCellBtnIcon.cellIconAppearance,
120
+ })
121
+ : undefined;
122
+ }
123
+
124
+ function onActionBtnClick({
125
+ event,
126
+ actionBtnIndex,
127
+ actionBtnPosition,
128
+ }: {
129
+ event: Event;
130
+ actionBtnIndex: number;
131
+ actionBtnPosition: GidsTableCellActionButtonPosition;
132
+ }) {
133
+ if (onClickCellActionBtn) {
134
+ onClickCellActionBtn({
135
+ originalEvent: event,
136
+ details: {
137
+ appearance,
138
+ cellDataType,
139
+ displayTags,
140
+ label,
141
+ id,
142
+ extraData,
143
+ isHeaderCell,
144
+ uniqueKey,
145
+ actionBtnNumber: `action-btn-${actionBtnIndex + 1}`,
146
+ actionBtnIndex: actionBtnIndex,
147
+ actionBtnPosition: actionBtnPosition ?? 'secondary',
148
+ },
149
+ });
150
+ }
151
+ }
152
+
153
+ function makeCellActionButton({
154
+ cellActionBtn,
155
+ actionBtnIndex,
156
+ actionBtnPosition,
157
+ }: {
158
+ cellActionBtn?: GidsTableCellActionButtonSharedTypes<
159
+ IconName,
160
+ IconAppearance
161
+ >;
162
+ actionBtnIndex: number;
163
+ actionBtnPosition: GidsTableCellActionButtonPosition;
164
+ }) {
165
+ return GidsButtonDom({
166
+ as: 'button',
167
+ appearance: cellActionBtn?.appearance ?? 'default',
168
+ size: cellActionBtn?.size ?? 'md',
169
+ disabled: cellActionBtn?.disabled,
170
+ destructive: cellActionBtn?.destructive,
171
+ positive: cellActionBtn?.positive,
172
+ loading: cellActionBtn?.loading,
173
+ width: cellActionBtn?.width ?? 'intrinsic',
174
+ children: cellActionBtn?.buttonLabel ?? '',
175
+ type: 'button',
176
+ leadingIcon: makeCellActionBtnIcon({
177
+ cellActionBtn,
178
+ neededIconType: 'leading',
179
+ }),
180
+ trailingIcon: makeCellActionBtnIcon({
181
+ cellActionBtn,
182
+ neededIconType: 'trailing',
183
+ }),
184
+ onClick: (event: Event) =>
185
+ onActionBtnClick({ event, actionBtnIndex, actionBtnPosition }),
186
+ });
187
+ }
188
+
189
+ if (cellPrimaryActionButtons && cellPrimaryActionButtons.length > 0) {
190
+ const cellPrimaryActionBtnContainer = document.createElement('div');
191
+ cellPrimaryActionBtnContainer.className =
192
+ 'gids-table-cell__primary-action-btn-container';
193
+
194
+ Array.from({ length: cellPrimaryActionButtons.length }, (_, indexI) => {
195
+ const cellPrimaryActionBtnIndex =
196
+ cellPrimaryActionButtons.length - indexI - 1;
197
+ const cellPrimaryActionBtn =
198
+ cellPrimaryActionButtons[cellPrimaryActionBtnIndex];
199
+ const cellActionBtnVisible = isTableCellActionButtonVisible<
200
+ IconName,
201
+ IconAppearance
202
+ >(cellPrimaryActionBtn);
203
+ if (cellActionBtnVisible) {
204
+ cellPrimaryActionBtnContainer.append(
205
+ makeCellActionButton({
206
+ cellActionBtn: cellPrimaryActionBtn,
207
+ actionBtnIndex: cellPrimaryActionBtnIndex,
208
+ actionBtnPosition: 'primary',
209
+ }),
210
+ );
211
+ }
212
+ });
213
+
214
+ tableCell.appendChild(cellPrimaryActionBtnContainer);
215
+ }
216
+
217
+ if (cellDataType === 'text' && label && label !== '') {
218
+ const labelSpan = document.createElement('span');
219
+ labelSpan.textContent = label;
220
+ labelSpan.className = `${getGidsTableCellLabelTypographyClass(labelTypography)}`;
221
+
222
+ appendAsChildren(tableCell, labelSpan);
223
+ }
224
+
225
+ if (cellDataType === 'display-tag' && displayTags && displayTags.length > 0) {
226
+ const displayTagsContainer = document.createElement('div');
227
+ displayTagsContainer.className = 'gids-table-cell__display-tags-container';
228
+
229
+ displayTags.forEach((displayTag) => {
230
+ displayTagsContainer.append(
231
+ GidsDisplayTagDom({
232
+ label: displayTag?.label ?? '',
233
+ appearance: displayTag?.displayTagAppearance ?? 'subtle',
234
+ size: displayTag?.displayTagSize ?? 'xs',
235
+ icon: displayTag?.displayTagIcon
236
+ ? GidsIconDom({
237
+ name: displayTag.displayTagIcon,
238
+ size: displayTag?.displayTagSize ?? 'xs',
239
+ appearance: displayTag?.displayTagIconAppearance ?? 'regular',
240
+ })
241
+ : undefined,
242
+ color: displayTag?.displayTagColor ?? 'accent-5',
243
+ }),
244
+ );
245
+ });
246
+
247
+ appendAsChildren(tableCell, displayTagsContainer);
248
+ }
249
+
250
+ if (cellSecondaryActionButtons && cellSecondaryActionButtons.length > 0) {
251
+ const cellSecondaryActionBtnContainer = document.createElement('div');
252
+ cellSecondaryActionBtnContainer.className =
253
+ 'gids-table-cell__secondary-action-btn-container';
254
+
255
+ Array.from({ length: cellSecondaryActionButtons.length }, (_, indexJ) => {
256
+ const cellSecondaryActionBtn = cellSecondaryActionButtons[indexJ];
257
+ const cellActionBtnVisible = isTableCellActionButtonVisible<
258
+ IconName,
259
+ IconAppearance
260
+ >(cellSecondaryActionBtn);
261
+ if (cellActionBtnVisible) {
262
+ cellSecondaryActionBtnContainer.append(
263
+ makeCellActionButton({
264
+ cellActionBtn: cellSecondaryActionBtn,
265
+ actionBtnIndex: indexJ,
266
+ actionBtnPosition: 'secondary',
267
+ }),
268
+ );
269
+ }
270
+ });
271
+
272
+ tableCell.appendChild(cellSecondaryActionBtnContainer);
273
+ }
274
+
275
+ return tableCell;
276
+ };