@ganpatiinfo/gids-web-dom-reference 13.0.0 → 14.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.
- package/CHANGELOG.md +67 -0
- package/dist/components/GidsCrossTable/GidsCrossTable.d.ts +18 -0
- package/dist/components/GidsCrossTable/GidsCrossTable.d.ts.map +1 -0
- package/dist/components/GidsCrossTable/GidsCrossTable.js +141 -0
- package/dist/components/GidsCrossTable/GidsCrossTable.js.map +1 -0
- package/dist/components/GidsCrossTableBody/GidsCrossTableBody.d.ts +13 -0
- package/dist/components/GidsCrossTableBody/GidsCrossTableBody.d.ts.map +1 -0
- package/dist/components/GidsCrossTableBody/GidsCrossTableBody.js +79 -0
- package/dist/components/GidsCrossTableBody/GidsCrossTableBody.js.map +1 -0
- package/dist/components/GidsCrossTableRow/GidsCrossTableRow.d.ts +13 -0
- package/dist/components/GidsCrossTableRow/GidsCrossTableRow.d.ts.map +1 -0
- package/dist/components/GidsCrossTableRow/GidsCrossTableRow.js +128 -0
- package/dist/components/GidsCrossTableRow/GidsCrossTableRow.js.map +1 -0
- package/dist/components/GidsDialog/GidsDialog.d.ts +13 -0
- package/dist/components/GidsDialog/GidsDialog.d.ts.map +1 -0
- package/dist/components/GidsDialog/GidsDialog.js +102 -0
- package/dist/components/GidsDialog/GidsDialog.js.map +1 -0
- package/dist/components/GidsHeaderNavigation/GidsHeaderNavigation.d.ts +8 -0
- package/dist/components/GidsHeaderNavigation/GidsHeaderNavigation.d.ts.map +1 -0
- package/dist/components/GidsHeaderNavigation/GidsHeaderNavigation.js +29 -0
- package/dist/components/GidsHeaderNavigation/GidsHeaderNavigation.js.map +1 -0
- package/dist/components/GidsHeaderNavigationItem/GidsHeaderNavigationItem.d.ts +8 -0
- package/dist/components/GidsHeaderNavigationItem/GidsHeaderNavigationItem.d.ts.map +1 -0
- package/dist/components/GidsHeaderNavigationItem/GidsHeaderNavigationItem.js +57 -0
- package/dist/components/GidsHeaderNavigationItem/GidsHeaderNavigationItem.js.map +1 -0
- package/dist/components/GidsMatrixTable/GidsMatrixTable.d.ts +20 -0
- package/dist/components/GidsMatrixTable/GidsMatrixTable.d.ts.map +1 -1
- package/dist/components/GidsMatrixTable/GidsMatrixTable.js +5 -0
- package/dist/components/GidsMatrixTable/GidsMatrixTable.js.map +1 -1
- package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.d.ts +20 -0
- package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.d.ts.map +1 -1
- package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.js +5 -0
- package/dist/components/GidsMatrixTableBody/GidsMatrixTableBody.js.map +1 -1
- package/dist/components/GidsMenu/GidsMenu.d.ts +1 -1
- package/dist/components/GidsMenu/GidsMenu.d.ts.map +1 -1
- package/dist/components/GidsMenu/GidsMenu.js +10 -1
- package/dist/components/GidsMenu/GidsMenu.js.map +1 -1
- package/dist/components/GidsProfile/GidsProfile.d.ts +8 -0
- package/dist/components/GidsProfile/GidsProfile.d.ts.map +1 -0
- package/dist/components/GidsProfile/GidsProfile.js +58 -0
- package/dist/components/GidsProfile/GidsProfile.js.map +1 -0
- package/dist/components/GidsProfileMenu/GidsProfileMenu.d.ts +7 -0
- package/dist/components/GidsProfileMenu/GidsProfileMenu.d.ts.map +1 -0
- package/dist/components/GidsProfileMenu/GidsProfileMenu.js +25 -0
- package/dist/components/GidsProfileMenu/GidsProfileMenu.js.map +1 -0
- package/dist/components/GidsProfileMenuHeader/GidsProfileMenuHeader.d.ts +7 -0
- package/dist/components/GidsProfileMenuHeader/GidsProfileMenuHeader.d.ts.map +1 -0
- package/dist/components/GidsProfileMenuHeader/GidsProfileMenuHeader.js +24 -0
- package/dist/components/GidsProfileMenuHeader/GidsProfileMenuHeader.js.map +1 -0
- package/dist/components/GidsSkeleton/GidsSkeleton.d.ts +8 -0
- package/dist/components/GidsSkeleton/GidsSkeleton.d.ts.map +1 -0
- package/dist/components/GidsSkeleton/GidsSkeleton.js +16 -0
- package/dist/components/GidsSkeleton/GidsSkeleton.js.map +1 -0
- package/dist/components/GidsTable/GidsTable.d.ts +1 -1
- package/dist/components/GidsTable/GidsTable.d.ts.map +1 -1
- package/dist/components/GidsTable/GidsTable.js +27 -2
- package/dist/components/GidsTable/GidsTable.js.map +1 -1
- package/dist/components/GidsTableFooter/GidsTableFooter.d.ts +2 -2
- package/dist/components/GidsTableFooter/GidsTableFooter.d.ts.map +1 -1
- package/dist/components/GidsTableFooter/GidsTableFooter.js +2 -24
- package/dist/components/GidsTableFooter/GidsTableFooter.js.map +1 -1
- package/dist/components/GidsTableFooterControl/GidsTableFooterControl.d.ts +1 -1
- package/dist/components/GidsTableFooterControl/GidsTableFooterControl.d.ts.map +1 -1
- package/dist/components/GidsTableFooterControl/GidsTableFooterControl.js +5 -3
- package/dist/components/GidsTableFooterControl/GidsTableFooterControl.js.map +1 -1
- package/dist/components/GidsTableHeader/GidsTableHeader.d.ts +1 -1
- package/dist/components/GidsTableHeader/GidsTableHeader.d.ts.map +1 -1
- package/dist/components/GidsTableHeader/GidsTableHeader.js +1 -3
- package/dist/components/GidsTableHeader/GidsTableHeader.js.map +1 -1
- package/dist/components/GidsTableRow/GidsTableRow.d.ts +1 -1
- package/dist/components/GidsTableRow/GidsTableRow.d.ts.map +1 -1
- package/dist/components/GidsTableRow/GidsTableRow.js +3 -3
- package/dist/components/GidsTableRow/GidsTableRow.js.map +1 -1
- package/dist/components/GidsTransferList/GidsTransferList.d.ts +8 -0
- package/dist/components/GidsTransferList/GidsTransferList.d.ts.map +1 -0
- package/dist/components/GidsTransferList/GidsTransferList.js +25 -0
- package/dist/components/GidsTransferList/GidsTransferList.js.map +1 -0
- package/dist/components/_GidsDialogControl/GidsDialogControl.d.ts +10 -0
- package/dist/components/_GidsDialogControl/GidsDialogControl.d.ts.map +1 -0
- package/dist/components/_GidsDialogControl/GidsDialogControl.js +133 -0
- package/dist/components/_GidsDialogControl/GidsDialogControl.js.map +1 -0
- package/dist/index.d.ts +120 -108
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +120 -108
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/GidsCrossTable/GidsCrossTable.ts +259 -0
- package/src/components/GidsCrossTableBody/GidsCrossTableBody.ts +171 -0
- package/src/components/GidsCrossTableRow/GidsCrossTableRow.ts +230 -0
- package/src/components/GidsDialog/GidsDialog.ts +161 -0
- package/src/components/GidsHeaderNavigation/GidsHeaderNavigation.ts +75 -0
- package/src/components/GidsHeaderNavigationItem/GidsHeaderNavigationItem.ts +103 -0
- package/src/components/GidsMatrixTable/GidsMatrixTable.ts +20 -0
- package/src/components/GidsMatrixTableBody/GidsMatrixTableBody.ts +21 -0
- package/src/components/GidsMenu/GidsMenu.ts +15 -0
- package/src/components/GidsProfile/GidsProfile.ts +120 -0
- package/src/components/GidsProfileMenu/GidsProfileMenu.ts +60 -0
- package/src/components/GidsProfileMenuHeader/GidsProfileMenuHeader.ts +66 -0
- package/src/components/GidsSkeleton/GidsSkeleton.ts +40 -0
- package/src/components/GidsTable/GidsTable.ts +41 -4
- package/src/components/GidsTableFooter/GidsTableFooter.ts +1 -39
- package/src/components/GidsTableFooterControl/GidsTableFooterControl.ts +9 -2
- package/src/components/GidsTableHeader/GidsTableHeader.ts +0 -4
- package/src/components/GidsTableRow/GidsTableRow.ts +2 -4
- package/src/components/GidsTransferList/GidsTransferList.ts +58 -0
- package/src/components/_GidsDialogControl/GidsDialogControl.ts +198 -0
- package/src/index.ts +120 -108
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GidsCrossTableActionEvent,
|
|
3
|
+
GidsCrossTableToolbarSettings,
|
|
4
|
+
GidsInputStatus,
|
|
5
|
+
} from '@ganpatiinfo/gids-core-shared';
|
|
6
|
+
import { appendAsChildren, DomChildren } from '../../utils/domUtils';
|
|
7
|
+
import { HtmlInputAttributes } from '../GidsInput/GidsInput';
|
|
8
|
+
import {
|
|
9
|
+
GidsTableToolbarDom,
|
|
10
|
+
GidsTableToolbarDomProps,
|
|
11
|
+
} from '../GidsTableToolbar/GidsTableToolbar';
|
|
12
|
+
import {
|
|
13
|
+
GidsCrossTableWebProps,
|
|
14
|
+
GidsCrossTableWebUtils,
|
|
15
|
+
GidsTableEntryTypographyStyle,
|
|
16
|
+
isValidChildren,
|
|
17
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
18
|
+
import {
|
|
19
|
+
IconAppearance,
|
|
20
|
+
IconName,
|
|
21
|
+
} from '@ganpatiinfo/gids-web-theme-interface';
|
|
22
|
+
import {
|
|
23
|
+
GidsTableHeaderActionBaseEvent,
|
|
24
|
+
GidsTableHeaderDom,
|
|
25
|
+
} from '../GidsTableHeader/GidsTableHeader';
|
|
26
|
+
import {
|
|
27
|
+
GidsCrossTableBodyActionBaseEvent,
|
|
28
|
+
GidsCrossTableBodyDom,
|
|
29
|
+
} from '../GidsCrossTableBody/GidsCrossTableBody';
|
|
30
|
+
import { GidsTableFooterDom } from '../GidsTableFooter/GidsTableFooter';
|
|
31
|
+
import { GidsTableFooterControlDom } from '../GidsTableFooterControl/GidsTableFooterControl';
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
getGidsCrossTableClassNames,
|
|
35
|
+
getCustomisedCrossTableHeaderEntries,
|
|
36
|
+
getCustomisedCrossTableFooterEntries,
|
|
37
|
+
getCrossTableBodyBorder,
|
|
38
|
+
} = GidsCrossTableWebUtils;
|
|
39
|
+
|
|
40
|
+
export type GidsCrossTableToolbarBaseSettings = GidsCrossTableToolbarSettings<
|
|
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 GidsCrossTableBaseWebProps = Omit<
|
|
53
|
+
GidsCrossTableWebProps<
|
|
54
|
+
DomChildren,
|
|
55
|
+
GidsTableEntryTypographyStyle,
|
|
56
|
+
IconName,
|
|
57
|
+
IconAppearance,
|
|
58
|
+
DomChildren,
|
|
59
|
+
Event,
|
|
60
|
+
Element,
|
|
61
|
+
HtmlInputAttributes
|
|
62
|
+
>,
|
|
63
|
+
'toolbarSettings'
|
|
64
|
+
> & {
|
|
65
|
+
toolbarSettings?: GidsCrossTableToolbarBaseSettings;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type GidsCrossTableActionBaseEvent = GidsCrossTableActionEvent<
|
|
69
|
+
Event,
|
|
70
|
+
GidsTableEntryTypographyStyle,
|
|
71
|
+
IconName,
|
|
72
|
+
IconAppearance
|
|
73
|
+
>;
|
|
74
|
+
|
|
75
|
+
export interface GidsCrossTableDomProps extends GidsCrossTableBaseWebProps {
|
|
76
|
+
extraClasses?: string;
|
|
77
|
+
onCrossTableAction?: (event: GidsCrossTableActionBaseEvent) => void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const GidsCrossTableDom = ({
|
|
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
|
+
crossHeaderSettings,
|
|
96
|
+
onCrossTableAction,
|
|
97
|
+
footerItems = [],
|
|
98
|
+
footerSettings,
|
|
99
|
+
isFooterVisible = false,
|
|
100
|
+
isFooterControlVisible = false,
|
|
101
|
+
footerControlSettings,
|
|
102
|
+
footerControl,
|
|
103
|
+
extraClasses,
|
|
104
|
+
}: GidsCrossTableDomProps): HTMLDivElement => {
|
|
105
|
+
/*
|
|
106
|
+
* Cross Table Root
|
|
107
|
+
*/
|
|
108
|
+
const crossTableDiv = document.createElement('div');
|
|
109
|
+
crossTableDiv.className = getGidsCrossTableClassNames(
|
|
110
|
+
{ tableBorders, tableBorderRadius },
|
|
111
|
+
extraClasses,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* Toolbar
|
|
116
|
+
*/
|
|
117
|
+
if (isValidChildren<DomChildren>(toolbar)) {
|
|
118
|
+
appendAsChildren(crossTableDiv, toolbar);
|
|
119
|
+
} else if (isToolbarVisible) {
|
|
120
|
+
const tableToolbar = GidsTableToolbarDom({
|
|
121
|
+
...toolbarSettings,
|
|
122
|
+
children: toolbarChildren as Element,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
crossTableDiv.append(tableToolbar);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Scroll Container
|
|
130
|
+
*/
|
|
131
|
+
const tableScrollContainer = document.createElement('div');
|
|
132
|
+
tableScrollContainer.className = [
|
|
133
|
+
'gids-cross-table__scroll-container',
|
|
134
|
+
horizontalScroll
|
|
135
|
+
? 'gids-cross-table__scroll-container--horizontal-scroll'
|
|
136
|
+
: '',
|
|
137
|
+
]
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.join(' ');
|
|
140
|
+
|
|
141
|
+
if (tableBodyMaxHeight) {
|
|
142
|
+
tableScrollContainer.style.maxHeight = `${tableBodyMaxHeight}px`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* Cross Table
|
|
147
|
+
*/
|
|
148
|
+
const crossTable = document.createElement('table');
|
|
149
|
+
crossTable.className = 'gids-cross-table__main-table';
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Horizontal scroll is enabled:
|
|
153
|
+
*
|
|
154
|
+
* The table is allowed to become wider than the viewport.
|
|
155
|
+
*
|
|
156
|
+
* Horizontal scroll is disabled:
|
|
157
|
+
*
|
|
158
|
+
* The table stays 100% wide and cells wrap exactly like GidsTable.
|
|
159
|
+
*/
|
|
160
|
+
if (horizontalScroll) {
|
|
161
|
+
crossTable.classList.add('gids-cross-table__main-table--horizontal-scroll');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
* Custom Children
|
|
166
|
+
*/
|
|
167
|
+
if (isValidChildren(children)) {
|
|
168
|
+
appendAsChildren(crossTable, children);
|
|
169
|
+
} else {
|
|
170
|
+
function onActionBtnClick(
|
|
171
|
+
event: GidsTableHeaderActionBaseEvent | GidsCrossTableBodyActionBaseEvent,
|
|
172
|
+
) {
|
|
173
|
+
if (onCrossTableAction) {
|
|
174
|
+
onCrossTableAction({
|
|
175
|
+
...event,
|
|
176
|
+
details: {
|
|
177
|
+
...event.details,
|
|
178
|
+
columnIndex: event?.details?.entryIndex,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
* Header
|
|
186
|
+
*/
|
|
187
|
+
if (isHeaderVisible && headerItems && headerItems.length > 0) {
|
|
188
|
+
const crossTableHeader = GidsTableHeaderDom({
|
|
189
|
+
...headerSettings,
|
|
190
|
+
headerItems: getCustomisedCrossTableHeaderEntries({
|
|
191
|
+
headerItems: [{}, ...headerItems],
|
|
192
|
+
tableBorders,
|
|
193
|
+
}),
|
|
194
|
+
onHeaderAction: onActionBtnClick,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
crossTable.append(crossTableHeader);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/*
|
|
201
|
+
* Body
|
|
202
|
+
*/
|
|
203
|
+
if (bodyContent && bodyContent.length > 0) {
|
|
204
|
+
crossTable.append(
|
|
205
|
+
GidsCrossTableBodyDom({
|
|
206
|
+
bodyBorder: getCrossTableBodyBorder({
|
|
207
|
+
tableBorders,
|
|
208
|
+
}),
|
|
209
|
+
bodyContent,
|
|
210
|
+
bodySettings,
|
|
211
|
+
crossHeaderSettings,
|
|
212
|
+
onCrossTableBodyAction: onActionBtnClick,
|
|
213
|
+
}),
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/*
|
|
218
|
+
* Footer
|
|
219
|
+
*/
|
|
220
|
+
if (isFooterVisible && footerItems && footerItems.length > 0) {
|
|
221
|
+
const crossTableFooter = GidsTableFooterDom({
|
|
222
|
+
...footerSettings,
|
|
223
|
+
footerItems: getCustomisedCrossTableFooterEntries({
|
|
224
|
+
footerItems: [{}, ...footerItems],
|
|
225
|
+
tableBorders,
|
|
226
|
+
}),
|
|
227
|
+
onFooterAction: onActionBtnClick,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
crossTable.append(crossTableFooter);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/*
|
|
235
|
+
* Put cross table inside scroll container
|
|
236
|
+
*/
|
|
237
|
+
tableScrollContainer.appendChild(crossTable);
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
* Put scroll container inside Cross Table div
|
|
241
|
+
*/
|
|
242
|
+
crossTableDiv.appendChild(tableScrollContainer);
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Footer Control
|
|
246
|
+
*/
|
|
247
|
+
if (isFooterControlVisible || isValidChildren(footerControl)) {
|
|
248
|
+
crossTableDiv.append(
|
|
249
|
+
GidsTableFooterControlDom({
|
|
250
|
+
...footerControlSettings,
|
|
251
|
+
tableViewControllerSettings:
|
|
252
|
+
footerControlSettings?.tableViewControllerSettings,
|
|
253
|
+
children: footerControl,
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return crossTableDiv;
|
|
259
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { GidsCrossTableBodyActionEvent } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import {
|
|
3
|
+
GidsCrossTableBodyWebProps,
|
|
4
|
+
GidsCrossTableBodyWebUtils,
|
|
5
|
+
GidsTableEntryTypographyStyle,
|
|
6
|
+
isValidChildren,
|
|
7
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
8
|
+
import {
|
|
9
|
+
IconAppearance,
|
|
10
|
+
IconName,
|
|
11
|
+
} from '@ganpatiinfo/gids-web-theme-interface';
|
|
12
|
+
import { appendAsChildren, DomChildren } from '../../utils/domUtils';
|
|
13
|
+
import {
|
|
14
|
+
GidsCrossTableRowActionBaseEvent,
|
|
15
|
+
GidsCrossTableRowDom,
|
|
16
|
+
} from '../GidsCrossTableRow/GidsCrossTableRow';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
getGidsCrossTableBodyClassNames,
|
|
20
|
+
getConstructedCrossTableBodyContent,
|
|
21
|
+
getCrossTableBodyRowEntryBackgroundColor,
|
|
22
|
+
getCrossTableBodyRowEntryContentColor,
|
|
23
|
+
getCrossTableBodyRowEntryActionsBackgroundColor,
|
|
24
|
+
getCrossTableBodyRowEntryActionsContentColor,
|
|
25
|
+
} = GidsCrossTableBodyWebUtils;
|
|
26
|
+
|
|
27
|
+
type GidsCrossTableBodyBaseWebProps = GidsCrossTableBodyWebProps<
|
|
28
|
+
GidsTableEntryTypographyStyle,
|
|
29
|
+
IconName,
|
|
30
|
+
IconAppearance,
|
|
31
|
+
DomChildren
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export type GidsCrossTableBodyActionBaseEvent = GidsCrossTableBodyActionEvent<
|
|
35
|
+
Event,
|
|
36
|
+
GidsTableEntryTypographyStyle,
|
|
37
|
+
IconName,
|
|
38
|
+
IconAppearance
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export interface GidsCrossTableBodyDomProps extends GidsCrossTableBodyBaseWebProps {
|
|
42
|
+
extraClasses?: string;
|
|
43
|
+
onCrossTableBodyAction?: (event: GidsCrossTableBodyActionBaseEvent) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const GidsCrossTableBodyDom = ({
|
|
47
|
+
bodySettings,
|
|
48
|
+
bodyContent = [],
|
|
49
|
+
bodyBorder = 'none',
|
|
50
|
+
crossHeaderSettings,
|
|
51
|
+
children,
|
|
52
|
+
onCrossTableBodyAction,
|
|
53
|
+
extraClasses,
|
|
54
|
+
}: GidsCrossTableBodyDomProps): HTMLElement => {
|
|
55
|
+
const crossTableBody = document.createElement('tbody');
|
|
56
|
+
|
|
57
|
+
crossTableBody.className = getGidsCrossTableBodyClassNames(extraClasses);
|
|
58
|
+
|
|
59
|
+
if (isValidChildren<DomChildren>(children)) {
|
|
60
|
+
appendAsChildren(crossTableBody, children);
|
|
61
|
+
|
|
62
|
+
return crossTableBody;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (bodyContent && bodyContent.length > 0) {
|
|
66
|
+
const constructedCrossTableBodyContent =
|
|
67
|
+
getConstructedCrossTableBodyContent({
|
|
68
|
+
bodyContent,
|
|
69
|
+
bodyBorder,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
function onCrossTableRowActionBtnClick({
|
|
73
|
+
event,
|
|
74
|
+
rowIndex,
|
|
75
|
+
}: {
|
|
76
|
+
event: GidsCrossTableRowActionBaseEvent;
|
|
77
|
+
rowIndex: number;
|
|
78
|
+
}) {
|
|
79
|
+
if (onCrossTableBodyAction) {
|
|
80
|
+
onCrossTableBodyAction({
|
|
81
|
+
...event,
|
|
82
|
+
details: {
|
|
83
|
+
...event.details,
|
|
84
|
+
rowIndex,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
constructedCrossTableBodyContent.forEach(
|
|
91
|
+
(constructedCrossTableBody, indexI) => {
|
|
92
|
+
const constructedBodyRowItems =
|
|
93
|
+
constructedCrossTableBody?.rowItems ?? [];
|
|
94
|
+
|
|
95
|
+
const rowBgColor = getCrossTableBodyRowEntryBackgroundColor<
|
|
96
|
+
GidsTableEntryTypographyStyle,
|
|
97
|
+
IconName,
|
|
98
|
+
IconAppearance
|
|
99
|
+
>({
|
|
100
|
+
bodySettings,
|
|
101
|
+
rowIndex: indexI,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const rowContentColor = getCrossTableBodyRowEntryContentColor<
|
|
105
|
+
GidsTableEntryTypographyStyle,
|
|
106
|
+
IconName,
|
|
107
|
+
IconAppearance
|
|
108
|
+
>({
|
|
109
|
+
bodySettings,
|
|
110
|
+
rowIndex: indexI,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const rowActionsBgColor =
|
|
114
|
+
getCrossTableBodyRowEntryActionsBackgroundColor<
|
|
115
|
+
GidsTableEntryTypographyStyle,
|
|
116
|
+
IconName,
|
|
117
|
+
IconAppearance
|
|
118
|
+
>({
|
|
119
|
+
bodySettings,
|
|
120
|
+
rowIndex: indexI,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const rowActionsContentColor =
|
|
124
|
+
getCrossTableBodyRowEntryActionsContentColor<
|
|
125
|
+
GidsTableEntryTypographyStyle,
|
|
126
|
+
IconName,
|
|
127
|
+
IconAppearance
|
|
128
|
+
>({
|
|
129
|
+
bodySettings,
|
|
130
|
+
rowIndex: indexI,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
crossTableBody.append(
|
|
134
|
+
GidsCrossTableRowDom({
|
|
135
|
+
...bodySettings,
|
|
136
|
+
|
|
137
|
+
rows: constructedBodyRowItems,
|
|
138
|
+
/*
|
|
139
|
+
* Cross Header
|
|
140
|
+
*
|
|
141
|
+
* sideHeaderItem = actual content
|
|
142
|
+
* for this specific row.
|
|
143
|
+
*/
|
|
144
|
+
crossHeaderItem: constructedCrossTableBody?.crossHeaderItem,
|
|
145
|
+
/*
|
|
146
|
+
* Cross Header Settings
|
|
147
|
+
*
|
|
148
|
+
* Shared configuration/style for
|
|
149
|
+
* all side-header cells.
|
|
150
|
+
*/
|
|
151
|
+
crossHeaderSettings,
|
|
152
|
+
/*
|
|
153
|
+
* Body row styling
|
|
154
|
+
*/
|
|
155
|
+
backgroundColor: rowBgColor,
|
|
156
|
+
contentColor: rowContentColor,
|
|
157
|
+
actionsBackgroundColor: rowActionsBgColor,
|
|
158
|
+
actionsContentColor: rowActionsContentColor,
|
|
159
|
+
onCrossTableRowAction: (event: GidsCrossTableRowActionBaseEvent) =>
|
|
160
|
+
onCrossTableRowActionBtnClick({
|
|
161
|
+
event,
|
|
162
|
+
rowIndex: indexI,
|
|
163
|
+
}),
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return crossTableBody;
|
|
171
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GidsCrossTableRowWebProps,
|
|
3
|
+
GidsTableEntryTypographyStyle,
|
|
4
|
+
GidsCrossTableRowWebUtils,
|
|
5
|
+
isValidChildren,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
import {
|
|
8
|
+
IconAppearance,
|
|
9
|
+
IconName,
|
|
10
|
+
} from '@ganpatiinfo/gids-web-theme-interface';
|
|
11
|
+
import { DomChildren, appendAsChildren } from '../../utils/domUtils';
|
|
12
|
+
import {
|
|
13
|
+
GidsTableEntryActionBaseEvent,
|
|
14
|
+
GidsTableEntryDom,
|
|
15
|
+
} from '../GidsTableEntry/GidsTableEntry';
|
|
16
|
+
import { GidsCrossTableRowActionEvent } from '@ganpatiinfo/gids-core-shared';
|
|
17
|
+
|
|
18
|
+
const { getGidsCrossTableRowClassNames } = GidsCrossTableRowWebUtils;
|
|
19
|
+
|
|
20
|
+
type GidsCrossTableRowBaseWebProps = GidsCrossTableRowWebProps<
|
|
21
|
+
GidsTableEntryTypographyStyle,
|
|
22
|
+
IconName,
|
|
23
|
+
IconAppearance,
|
|
24
|
+
DomChildren
|
|
25
|
+
>;
|
|
26
|
+
export type GidsCrossTableRowActionBaseEvent = GidsCrossTableRowActionEvent<
|
|
27
|
+
Event,
|
|
28
|
+
GidsTableEntryTypographyStyle,
|
|
29
|
+
IconName,
|
|
30
|
+
IconAppearance
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export interface GidsCrossTableRowDomProps extends GidsCrossTableRowBaseWebProps {
|
|
34
|
+
extraClasses?: string;
|
|
35
|
+
onCrossTableRowAction?: (event: GidsCrossTableRowActionBaseEvent) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const GidsCrossTableRowDom = ({
|
|
39
|
+
rows = [],
|
|
40
|
+
crossHeaderItem,
|
|
41
|
+
crossHeaderSettings,
|
|
42
|
+
onCrossTableRowAction,
|
|
43
|
+
textAlignment = 'center',
|
|
44
|
+
appearance = 'none',
|
|
45
|
+
labelTypography = 'label-medium',
|
|
46
|
+
entryAlignment = 'center',
|
|
47
|
+
colorSwatchLabelColor = 'default',
|
|
48
|
+
colorSwatchLabelPosition = 'left',
|
|
49
|
+
colorSwatchLabelTypography = 'label-medium',
|
|
50
|
+
colorSwatchSize = 'sm',
|
|
51
|
+
colorSwatchShape = 'oval',
|
|
52
|
+
colorSwatchShadow = 'shadow-overlay',
|
|
53
|
+
colorSwatchBorderRadius = 'none',
|
|
54
|
+
colorSwatchApplyBorders = true,
|
|
55
|
+
colorSwatchBorderWidth = 'thick',
|
|
56
|
+
progressBarSize = 'sm',
|
|
57
|
+
progressBarEndCap = true,
|
|
58
|
+
avatarSize = 'sm',
|
|
59
|
+
avatarGroupAppearance,
|
|
60
|
+
avatarGroupLayout,
|
|
61
|
+
statusTagAppearance = 'subtle',
|
|
62
|
+
statusTagSize = 'sm',
|
|
63
|
+
progressBarContainerMinWidth = 200,
|
|
64
|
+
displayTagsOrientation = 'horizontal',
|
|
65
|
+
statusTagsOrientation = 'horizontal',
|
|
66
|
+
progressBarsOrientation = 'horizontal',
|
|
67
|
+
colorSwatchesOrientation = 'horizontal',
|
|
68
|
+
badgesOrientation = 'horizontal',
|
|
69
|
+
actionsBackgroundColor,
|
|
70
|
+
actionsContentColor,
|
|
71
|
+
backgroundColor,
|
|
72
|
+
contentColor,
|
|
73
|
+
children,
|
|
74
|
+
extraClasses,
|
|
75
|
+
}: GidsCrossTableRowDomProps): HTMLTableRowElement => {
|
|
76
|
+
const crossTableRow = document.createElement('tr');
|
|
77
|
+
crossTableRow.className = getGidsCrossTableRowClassNames(extraClasses);
|
|
78
|
+
|
|
79
|
+
if (isValidChildren<DomChildren>(children)) {
|
|
80
|
+
appendAsChildren(crossTableRow, children);
|
|
81
|
+
|
|
82
|
+
return crossTableRow;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function onEntryActionBtnClick({
|
|
86
|
+
event,
|
|
87
|
+
entryIndex,
|
|
88
|
+
}: {
|
|
89
|
+
event: GidsTableEntryActionBaseEvent;
|
|
90
|
+
entryIndex: number;
|
|
91
|
+
}) {
|
|
92
|
+
if (onCrossTableRowAction) {
|
|
93
|
+
onCrossTableRowAction({
|
|
94
|
+
...event,
|
|
95
|
+
details: {
|
|
96
|
+
...event.details,
|
|
97
|
+
entryIndex,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Cross Header
|
|
105
|
+
*
|
|
106
|
+
* IMPORTANT:
|
|
107
|
+
* Cross header settings are completely independent
|
|
108
|
+
* from the body row settings.
|
|
109
|
+
*/
|
|
110
|
+
if (crossHeaderItem && Object.keys(crossHeaderItem).length > 0) {
|
|
111
|
+
crossTableRow.append(
|
|
112
|
+
GidsTableEntryDom({
|
|
113
|
+
...crossHeaderItem,
|
|
114
|
+
...crossHeaderSettings,
|
|
115
|
+
label: crossHeaderItem?.label,
|
|
116
|
+
entryType: 'header',
|
|
117
|
+
/*
|
|
118
|
+
* Cross header uses its own settings first.
|
|
119
|
+
*/
|
|
120
|
+
leadingActions: crossHeaderItem?.leadingActions ?? [],
|
|
121
|
+
trailingActions: crossHeaderItem?.trailingActions ?? [],
|
|
122
|
+
entryAlignment: crossHeaderSettings?.entryAlignment ?? 'center',
|
|
123
|
+
colorSwatchLabelColor:
|
|
124
|
+
crossHeaderSettings?.colorSwatchLabelColor ?? 'default',
|
|
125
|
+
colorSwatchLabelPosition:
|
|
126
|
+
crossHeaderSettings?.colorSwatchLabelPosition ?? 'left',
|
|
127
|
+
colorSwatchLabelTypography:
|
|
128
|
+
crossHeaderSettings?.colorSwatchLabelTypography ?? 'label-medium',
|
|
129
|
+
colorSwatchSize: crossHeaderSettings?.colorSwatchSize ?? 'sm',
|
|
130
|
+
colorSwatchShape: crossHeaderSettings?.colorSwatchShape ?? 'oval',
|
|
131
|
+
colorSwatchShadow:
|
|
132
|
+
crossHeaderSettings?.colorSwatchShadow ?? 'shadow-overlay',
|
|
133
|
+
colorSwatchBorderRadius:
|
|
134
|
+
crossHeaderSettings?.colorSwatchBorderRadius ?? 'none',
|
|
135
|
+
colorSwatchApplyBorders:
|
|
136
|
+
crossHeaderSettings?.colorSwatchApplyBorders ?? true,
|
|
137
|
+
colorSwatchBorderWidth:
|
|
138
|
+
crossHeaderSettings?.colorSwatchBorderWidth ?? 'thick',
|
|
139
|
+
progressBarSize: crossHeaderSettings?.progressBarSize ?? 'sm',
|
|
140
|
+
progressBarEndCap: crossHeaderSettings?.progressBarEndCap ?? true,
|
|
141
|
+
avatarSize: crossHeaderSettings?.avatarSize ?? 'sm',
|
|
142
|
+
avatarGroupAppearance:
|
|
143
|
+
crossHeaderSettings?.avatarGroupAppearance ?? 'spread',
|
|
144
|
+
avatarGroupLayout: crossHeaderSettings?.avatarGroupLayout ?? 'wrap',
|
|
145
|
+
statusTagAppearance:
|
|
146
|
+
crossHeaderSettings?.statusTagAppearance ?? 'subtle',
|
|
147
|
+
statusTagSize: crossHeaderSettings?.statusTagSize ?? 'sm',
|
|
148
|
+
progressBarContainerMinWidth:
|
|
149
|
+
crossHeaderSettings?.progressBarContainerMinWidth ?? 200,
|
|
150
|
+
displayTagsOrientation:
|
|
151
|
+
crossHeaderSettings?.displayTagsOrientation ?? 'horizontal',
|
|
152
|
+
statusTagsOrientation:
|
|
153
|
+
crossHeaderSettings?.statusTagsOrientation ?? 'horizontal',
|
|
154
|
+
progressBarsOrientation:
|
|
155
|
+
crossHeaderSettings?.progressBarsOrientation ?? 'horizontal',
|
|
156
|
+
colorSwatchesOrientation:
|
|
157
|
+
crossHeaderSettings?.colorSwatchesOrientation ?? 'horizontal',
|
|
158
|
+
badgesOrientation:
|
|
159
|
+
crossHeaderSettings?.badgesOrientation ?? 'horizontal',
|
|
160
|
+
textAlignment: crossHeaderSettings?.textAlignment ?? 'center',
|
|
161
|
+
labelTypography: crossHeaderSettings?.labelTypography ?? 'label-medium',
|
|
162
|
+
appearance: crossHeaderSettings?.appearance ?? 'none',
|
|
163
|
+
/*
|
|
164
|
+
* Most importantly, colors come from crossHeaderSettings,
|
|
165
|
+
* never from the body row.
|
|
166
|
+
*/
|
|
167
|
+
onEntryAction: (event: GidsTableEntryActionBaseEvent) =>
|
|
168
|
+
onEntryActionBtnClick({
|
|
169
|
+
event,
|
|
170
|
+
entryIndex: -1,
|
|
171
|
+
}),
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* Body Cells
|
|
178
|
+
*
|
|
179
|
+
* These continue using the normal row settings.
|
|
180
|
+
*/
|
|
181
|
+
if (rows && rows.length > 0) {
|
|
182
|
+
rows.forEach((row, index) => {
|
|
183
|
+
crossTableRow.append(
|
|
184
|
+
GidsTableEntryDom({
|
|
185
|
+
...row,
|
|
186
|
+
entryType: 'body',
|
|
187
|
+
leadingActions: row?.leadingActions ?? [],
|
|
188
|
+
trailingActions: row?.trailingActions ?? [],
|
|
189
|
+
entryAlignment,
|
|
190
|
+
colorSwatchLabelColor,
|
|
191
|
+
colorSwatchLabelPosition,
|
|
192
|
+
colorSwatchLabelTypography,
|
|
193
|
+
colorSwatchSize,
|
|
194
|
+
colorSwatchShape,
|
|
195
|
+
colorSwatchShadow,
|
|
196
|
+
colorSwatchBorderRadius,
|
|
197
|
+
colorSwatchApplyBorders,
|
|
198
|
+
colorSwatchBorderWidth,
|
|
199
|
+
progressBarSize,
|
|
200
|
+
progressBarEndCap,
|
|
201
|
+
avatarSize,
|
|
202
|
+
avatarGroupAppearance,
|
|
203
|
+
avatarGroupLayout,
|
|
204
|
+
statusTagAppearance,
|
|
205
|
+
statusTagSize,
|
|
206
|
+
progressBarContainerMinWidth,
|
|
207
|
+
displayTagsOrientation,
|
|
208
|
+
statusTagsOrientation,
|
|
209
|
+
progressBarsOrientation,
|
|
210
|
+
colorSwatchesOrientation,
|
|
211
|
+
badgesOrientation,
|
|
212
|
+
textAlignment,
|
|
213
|
+
labelTypography,
|
|
214
|
+
appearance,
|
|
215
|
+
backgroundColor,
|
|
216
|
+
contentColor,
|
|
217
|
+
actionsBackgroundColor,
|
|
218
|
+
actionsContentColor,
|
|
219
|
+
onEntryAction: (event: GidsTableEntryActionBaseEvent) =>
|
|
220
|
+
onEntryActionBtnClick({
|
|
221
|
+
event,
|
|
222
|
+
entryIndex: index,
|
|
223
|
+
}),
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return crossTableRow;
|
|
230
|
+
};
|