@ganpatiinfo/gids-web-dom-reference 13.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.
- package/CHANGELOG.md +47 -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/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/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 +115 -108
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +115 -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/GidsMatrixTable/GidsMatrixTable.ts +20 -0
- package/src/components/GidsMatrixTableBody/GidsMatrixTableBody.ts +21 -0
- package/src/components/GidsMenu/GidsMenu.ts +15 -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 +115 -108
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GidsSkeletonWebProps,
|
|
3
|
+
GidsSkeletonWebUtils,
|
|
4
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
5
|
+
|
|
6
|
+
const { getGidsSkeletonClassNames } = GidsSkeletonWebUtils;
|
|
7
|
+
|
|
8
|
+
type GidsSkeletonBaseWebProps = GidsSkeletonWebProps;
|
|
9
|
+
|
|
10
|
+
type GidsSkeletonElement = HTMLElement & GidsSkeletonBaseWebProps;
|
|
11
|
+
|
|
12
|
+
export interface GidsSkeletonDomProps extends GidsSkeletonBaseWebProps {
|
|
13
|
+
extraClasses?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const GidsSkeletonDom = ({
|
|
17
|
+
variant = 'text',
|
|
18
|
+
animation = 'none',
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
extraClasses,
|
|
22
|
+
}: GidsSkeletonDomProps): HTMLElement => {
|
|
23
|
+
const skeleton = document.createElement(
|
|
24
|
+
'gids-skeleton',
|
|
25
|
+
) as GidsSkeletonElement;
|
|
26
|
+
|
|
27
|
+
skeleton.variant = variant;
|
|
28
|
+
skeleton.animation = animation;
|
|
29
|
+
|
|
30
|
+
if (width) {
|
|
31
|
+
skeleton.width = width;
|
|
32
|
+
}
|
|
33
|
+
if (height) {
|
|
34
|
+
skeleton.height = height;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
skeleton.className = getGidsSkeletonClassNames(extraClasses);
|
|
38
|
+
|
|
39
|
+
return skeleton;
|
|
40
|
+
};
|
|
@@ -27,10 +27,13 @@ import {
|
|
|
27
27
|
GidsTableBodyActionBaseEvent,
|
|
28
28
|
GidsTableBodyDom,
|
|
29
29
|
} from '../GidsTableBody/GidsTableBody';
|
|
30
|
+
import { GidsTableFooterDom } from '../GidsTableFooter/GidsTableFooter';
|
|
31
|
+
import { GidsTableFooterControlDom } from '../GidsTableFooterControl/GidsTableFooterControl';
|
|
30
32
|
|
|
31
33
|
const {
|
|
32
34
|
getGidsTableClassNames,
|
|
33
35
|
getCustomisedTableHeaderEntries,
|
|
36
|
+
getCustomisedTableFooterEntries,
|
|
34
37
|
getTableBodyBorder,
|
|
35
38
|
} = GidsTableWebUtils;
|
|
36
39
|
|
|
@@ -78,8 +81,8 @@ export const GidsTableDom = ({
|
|
|
78
81
|
toolbar,
|
|
79
82
|
toolbarChildren,
|
|
80
83
|
children,
|
|
81
|
-
headerItems,
|
|
82
|
-
bodyContent,
|
|
84
|
+
headerItems = [],
|
|
85
|
+
bodyContent = [],
|
|
83
86
|
isHeaderVisible,
|
|
84
87
|
isToolbarVisible,
|
|
85
88
|
bodySettings,
|
|
@@ -90,6 +93,12 @@ export const GidsTableDom = ({
|
|
|
90
93
|
tableBodyMaxHeight = 200,
|
|
91
94
|
horizontalScroll = false,
|
|
92
95
|
onTableAction,
|
|
96
|
+
footerItems = [],
|
|
97
|
+
footerSettings,
|
|
98
|
+
isFooterVisible = false,
|
|
99
|
+
isFooterControlVisible = false,
|
|
100
|
+
footerControlSettings,
|
|
101
|
+
footerControl,
|
|
93
102
|
extraClasses,
|
|
94
103
|
}: GidsTableDomProps): HTMLDivElement => {
|
|
95
104
|
const tableDiv = document.createElement('div');
|
|
@@ -117,7 +126,6 @@ export const GidsTableDom = ({
|
|
|
117
126
|
* Scroll container
|
|
118
127
|
*/
|
|
119
128
|
const tableScrollContainer = document.createElement('div');
|
|
120
|
-
|
|
121
129
|
tableScrollContainer.className = [
|
|
122
130
|
'gids-table__scroll-container',
|
|
123
131
|
horizontalScroll ? 'gids-table__scroll-container--horizontal-scroll' : '',
|
|
@@ -133,7 +141,6 @@ export const GidsTableDom = ({
|
|
|
133
141
|
* Table
|
|
134
142
|
*/
|
|
135
143
|
const table = document.createElement('table');
|
|
136
|
-
|
|
137
144
|
table.className = 'gids-table--main-table';
|
|
138
145
|
|
|
139
146
|
/*
|
|
@@ -187,6 +194,22 @@ export const GidsTableDom = ({
|
|
|
187
194
|
}),
|
|
188
195
|
);
|
|
189
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
|
+
}
|
|
190
213
|
}
|
|
191
214
|
|
|
192
215
|
/*
|
|
@@ -199,5 +222,19 @@ export const GidsTableDom = ({
|
|
|
199
222
|
tableScrollContainer.appendChild(table);
|
|
200
223
|
tableDiv.appendChild(tableScrollContainer);
|
|
201
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
|
+
|
|
202
239
|
return tableDiv;
|
|
203
240
|
};
|
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
import { appendAsChildren, DomChildren } from '../../utils/domUtils';
|
|
12
12
|
import { GidsTableFooterActionEvent } from '@ganpatiinfo/gids-core-shared';
|
|
13
13
|
import { GidsTableRowDom } from '../GidsTableRow/GidsTableRow';
|
|
14
|
-
import { GidsTableFooterControlDom } from '../GidsTableFooterControl/GidsTableFooterControl';
|
|
15
|
-
import { GidsTableEntryDom } from '../GidsTableEntry/GidsTableEntry';
|
|
16
14
|
|
|
17
15
|
const { getGidsTableFooterClassNames } = GidsTableFooterWebUtils;
|
|
18
16
|
|
|
@@ -24,10 +22,7 @@ export type GidsTableFooterBaseWebProps = GidsTableFooterWebProps<
|
|
|
24
22
|
GidsTableEntryTypographyStyle,
|
|
25
23
|
IconName,
|
|
26
24
|
IconAppearance,
|
|
27
|
-
DomChildren
|
|
28
|
-
DomChildren,
|
|
29
|
-
GidsTableFooterNativeInputForwardedDomProps,
|
|
30
|
-
Event
|
|
25
|
+
DomChildren
|
|
31
26
|
>;
|
|
32
27
|
|
|
33
28
|
export type GidsTableFooterActionBaseEvent = GidsTableFooterActionEvent<
|
|
@@ -47,8 +42,6 @@ export const GidsTableFooterDom = ({
|
|
|
47
42
|
appearance = 'none',
|
|
48
43
|
labelTypography = 'label-medium',
|
|
49
44
|
textAlignment = 'center',
|
|
50
|
-
leadingActions = [],
|
|
51
|
-
trailingActions = [],
|
|
52
45
|
entryAlignment = 'center',
|
|
53
46
|
colorSwatchLabelColor = 'default',
|
|
54
47
|
colorSwatchLabelPosition = 'left',
|
|
@@ -74,8 +67,6 @@ export const GidsTableFooterDom = ({
|
|
|
74
67
|
badgesOrientation = 'horizontal',
|
|
75
68
|
|
|
76
69
|
// Footer Props
|
|
77
|
-
footerControlSettings,
|
|
78
|
-
footerControlChildren,
|
|
79
70
|
children,
|
|
80
71
|
footerItems,
|
|
81
72
|
onFooterAction,
|
|
@@ -91,8 +82,6 @@ export const GidsTableFooterDom = ({
|
|
|
91
82
|
const rowContent = GidsTableRowDom({
|
|
92
83
|
rows: footerItems,
|
|
93
84
|
rowType: 'footer',
|
|
94
|
-
leadingActions,
|
|
95
|
-
trailingActions,
|
|
96
85
|
entryAlignment,
|
|
97
86
|
colorSwatchLabelColor,
|
|
98
87
|
colorSwatchLabelPosition,
|
|
@@ -126,32 +115,5 @@ export const GidsTableFooterDom = ({
|
|
|
126
115
|
}
|
|
127
116
|
}
|
|
128
117
|
|
|
129
|
-
const isValidFooterChildren = isValidChildren<DomChildren>(
|
|
130
|
-
footerControlChildren,
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
isValidFooterChildren ||
|
|
135
|
-
(footerControlSettings && Object.keys(footerControlSettings).length > 0)
|
|
136
|
-
) {
|
|
137
|
-
const colSpan = footerItems?.length ?? 1;
|
|
138
|
-
|
|
139
|
-
tableFooter.append(
|
|
140
|
-
GidsTableRowDom({
|
|
141
|
-
appearance,
|
|
142
|
-
rowType: 'footer',
|
|
143
|
-
children: GidsTableEntryDom({
|
|
144
|
-
appearance,
|
|
145
|
-
colSpan,
|
|
146
|
-
entryType: 'footer',
|
|
147
|
-
children: GidsTableFooterControlDom({
|
|
148
|
-
...footerControlSettings,
|
|
149
|
-
children: footerControlChildren,
|
|
150
|
-
}),
|
|
151
|
-
}),
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
118
|
return tableFooter;
|
|
157
119
|
};
|
|
@@ -30,6 +30,7 @@ export interface GidsTableFooterControlDomProps extends GidsTableFooterControlBa
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const GidsTableFooterControlDom = ({
|
|
33
|
+
appearance = 'surface-default',
|
|
33
34
|
children,
|
|
34
35
|
bulkStatus,
|
|
35
36
|
rangeStatus,
|
|
@@ -40,8 +41,14 @@ export const GidsTableFooterControlDom = ({
|
|
|
40
41
|
extraClasses,
|
|
41
42
|
}: GidsTableFooterControlDomProps): HTMLDivElement => {
|
|
42
43
|
const tableFooterControl = document.createElement('div');
|
|
43
|
-
tableFooterControl.className =
|
|
44
|
-
|
|
44
|
+
tableFooterControl.className = getGidsTableFooterControlClassNames(
|
|
45
|
+
{ appearance },
|
|
46
|
+
extraClasses,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (appearance) {
|
|
50
|
+
tableFooterControl.setAttribute('control-appearance', appearance);
|
|
51
|
+
}
|
|
45
52
|
|
|
46
53
|
if (isValidChildren(children)) {
|
|
47
54
|
appendAsChildren(tableFooterControl, children);
|
|
@@ -38,8 +38,6 @@ export const GidsTableHeaderDom = ({
|
|
|
38
38
|
appearance = 'none',
|
|
39
39
|
labelTypography = 'label-medium',
|
|
40
40
|
textAlignment = 'center',
|
|
41
|
-
leadingActions = [],
|
|
42
|
-
trailingActions = [],
|
|
43
41
|
onHeaderAction,
|
|
44
42
|
extraClasses,
|
|
45
43
|
entryAlignment = 'center',
|
|
@@ -77,8 +75,6 @@ export const GidsTableHeaderDom = ({
|
|
|
77
75
|
const rowContent = GidsTableRowDom({
|
|
78
76
|
rows: headerItems,
|
|
79
77
|
rowType: 'header',
|
|
80
|
-
leadingActions,
|
|
81
|
-
trailingActions,
|
|
82
78
|
entryAlignment,
|
|
83
79
|
colorSwatchLabelColor,
|
|
84
80
|
colorSwatchLabelPosition,
|
|
@@ -38,8 +38,6 @@ export interface GidsTableRowDomProps extends GidsTableRowBaseWebProps {
|
|
|
38
38
|
export const GidsTableRowDom = ({
|
|
39
39
|
rows,
|
|
40
40
|
rowType = 'body',
|
|
41
|
-
leadingActions,
|
|
42
|
-
trailingActions,
|
|
43
41
|
onRowAction,
|
|
44
42
|
textAlignment = 'center',
|
|
45
43
|
appearance = 'none',
|
|
@@ -114,8 +112,8 @@ export const GidsTableRowDom = ({
|
|
|
114
112
|
contentColor,
|
|
115
113
|
label: rowLabel,
|
|
116
114
|
entryType: rowType,
|
|
117
|
-
leadingActions,
|
|
118
|
-
trailingActions,
|
|
115
|
+
leadingActions: row?.leadingActions ?? [],
|
|
116
|
+
trailingActions: row?.trailingActions ?? [],
|
|
119
117
|
entryAlignment,
|
|
120
118
|
colorSwatchLabelColor,
|
|
121
119
|
colorSwatchLabelPosition,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GidsTransferListWebProps,
|
|
3
|
+
GidsTransferListWebUtils,
|
|
4
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
5
|
+
|
|
6
|
+
const { getGidsTransferListClassNames } = GidsTransferListWebUtils;
|
|
7
|
+
|
|
8
|
+
type GidsTransferListBaseWebProps = GidsTransferListWebProps<Event>;
|
|
9
|
+
|
|
10
|
+
type GidsTransferListElement = HTMLElement & GidsTransferListBaseWebProps;
|
|
11
|
+
|
|
12
|
+
export interface GidsTransferListDomProps extends GidsTransferListBaseWebProps {
|
|
13
|
+
extraClasses?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const GidsTransferListDom = ({
|
|
17
|
+
leftListHeading = 'Choices',
|
|
18
|
+
rightListHeading = 'Choosen',
|
|
19
|
+
moveAllVisible = false,
|
|
20
|
+
transferListType = 'basic',
|
|
21
|
+
leftListItems = [],
|
|
22
|
+
rightListItems = [],
|
|
23
|
+
onTransferAction,
|
|
24
|
+
onTransferListSelect,
|
|
25
|
+
listsMaxHeight = '200px',
|
|
26
|
+
extraClasses,
|
|
27
|
+
}: GidsTransferListDomProps): HTMLElement => {
|
|
28
|
+
const transferList = document.createElement(
|
|
29
|
+
'gids-transfer-list',
|
|
30
|
+
) as GidsTransferListElement;
|
|
31
|
+
|
|
32
|
+
transferList.transferListType = transferListType;
|
|
33
|
+
|
|
34
|
+
if (transferListType === 'enhanced' && leftListHeading) {
|
|
35
|
+
transferList.leftListHeading = leftListHeading;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (transferListType === 'enhanced' && rightListHeading) {
|
|
39
|
+
transferList.rightListHeading = rightListHeading;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
transferList.moveAllVisible = moveAllVisible;
|
|
43
|
+
transferList.leftListItems = leftListItems;
|
|
44
|
+
transferList.rightListItems = rightListItems;
|
|
45
|
+
transferList.listsMaxHeight = listsMaxHeight;
|
|
46
|
+
|
|
47
|
+
transferList.className = getGidsTransferListClassNames(extraClasses);
|
|
48
|
+
|
|
49
|
+
if (onTransferAction) {
|
|
50
|
+
transferList.onTransferAction = onTransferAction;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (onTransferListSelect) {
|
|
54
|
+
transferList.onTransferListSelect = onTransferListSelect;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return transferList;
|
|
58
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GidsDialogControlWebProps,
|
|
3
|
+
GidsDialogControlWebUtils,
|
|
4
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
5
|
+
import {
|
|
6
|
+
appendAsChildren,
|
|
7
|
+
DomChildren,
|
|
8
|
+
DomNodeOrString,
|
|
9
|
+
} from '../../utils/domUtils';
|
|
10
|
+
import {
|
|
11
|
+
IconAppearance,
|
|
12
|
+
IconName,
|
|
13
|
+
} from '@ganpatiinfo/gids-web-theme-interface';
|
|
14
|
+
import { GidsIconDom } from '../GidsIcon/GidsIcon';
|
|
15
|
+
import { GidsButtonDom } from '../GidsButton/GidsButton';
|
|
16
|
+
|
|
17
|
+
const { getGidsDialogControlClassNames, setupDialogControlDraggable } =
|
|
18
|
+
GidsDialogControlWebUtils;
|
|
19
|
+
|
|
20
|
+
type GidsDialogControlBaseWebProps = GidsDialogControlWebProps<
|
|
21
|
+
DomNodeOrString,
|
|
22
|
+
Event,
|
|
23
|
+
IconName,
|
|
24
|
+
IconAppearance
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export interface GidsDialogControlDomProps extends GidsDialogControlBaseWebProps {
|
|
28
|
+
extraClasses?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const GidsDialogControlDom = ({
|
|
32
|
+
variant = 'alert',
|
|
33
|
+
maxWidth = 'sm',
|
|
34
|
+
scrollMode = 'paper',
|
|
35
|
+
draggable = false,
|
|
36
|
+
headerTitle,
|
|
37
|
+
closeVisible = true,
|
|
38
|
+
children,
|
|
39
|
+
footerActions = [],
|
|
40
|
+
onCloseDialogControl,
|
|
41
|
+
headerDividerVisible = false,
|
|
42
|
+
footerDividerVisible = false,
|
|
43
|
+
onDialogControlFooterAction,
|
|
44
|
+
extraClasses,
|
|
45
|
+
}: GidsDialogControlDomProps): HTMLDialogElement => {
|
|
46
|
+
const dialogControl = document.createElement('dialog');
|
|
47
|
+
dialogControl.className = getGidsDialogControlClassNames(
|
|
48
|
+
{ variant, maxWidth, scrollMode },
|
|
49
|
+
extraClasses,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
dialogControl.setAttribute('dialog-variant', variant);
|
|
53
|
+
dialogControl.setAttribute('max-width', maxWidth);
|
|
54
|
+
dialogControl.setAttribute('scroll-mode', scrollMode);
|
|
55
|
+
|
|
56
|
+
if (headerTitle) {
|
|
57
|
+
dialogControl.setAttribute('header-title', headerTitle);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (draggable) {
|
|
61
|
+
dialogControl.setAttribute('dialog-draggable', 'true');
|
|
62
|
+
} else {
|
|
63
|
+
dialogControl.removeAttribute('dialog-draggable');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (closeVisible) {
|
|
67
|
+
dialogControl.setAttribute('close-visible', 'true');
|
|
68
|
+
} else {
|
|
69
|
+
dialogControl.removeAttribute('close-visible');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Dialog control header
|
|
73
|
+
const header = document.createElement('div');
|
|
74
|
+
header.className = headerDividerVisible
|
|
75
|
+
? 'gids-dialog-control__header gids-dialog-control__header-divider'
|
|
76
|
+
: 'gids-dialog-control__header';
|
|
77
|
+
|
|
78
|
+
if (headerTitle !== undefined) {
|
|
79
|
+
const headerTitleEl = document.createElement('h2');
|
|
80
|
+
headerTitleEl.className = 'gids-dialog-control__title';
|
|
81
|
+
headerTitleEl.textContent = headerTitle;
|
|
82
|
+
header.appendChild(headerTitleEl);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function onDialogControlClose(event: Event) {
|
|
86
|
+
if (onCloseDialogControl) {
|
|
87
|
+
onCloseDialogControl({
|
|
88
|
+
originalEvent: event,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Render structural Close Icon layout button if visible setting rule matches
|
|
94
|
+
if (closeVisible) {
|
|
95
|
+
const closeButton = GidsButtonDom({
|
|
96
|
+
appearance: 'subtle',
|
|
97
|
+
size: 'md',
|
|
98
|
+
width: 'intrinsic',
|
|
99
|
+
leadingIcon: GidsIconDom({ name: 'cross', size: 'md' }),
|
|
100
|
+
onClick: onDialogControlClose,
|
|
101
|
+
});
|
|
102
|
+
header.appendChild(closeButton);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
dialogControl.appendChild(header);
|
|
106
|
+
|
|
107
|
+
// Dialog control body
|
|
108
|
+
if (children) {
|
|
109
|
+
const body = document.createElement('div');
|
|
110
|
+
body.className = 'gids-dialog-control__body';
|
|
111
|
+
appendAsChildren(body, children);
|
|
112
|
+
dialogControl.appendChild(body);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Dialog control footer
|
|
116
|
+
if (footerActions !== undefined && footerActions.length > 0) {
|
|
117
|
+
const footer = document.createElement('div');
|
|
118
|
+
footer.className = footerDividerVisible
|
|
119
|
+
? 'gids-dialog-control__footer gids-dialog-control__footer-divider'
|
|
120
|
+
: 'gids-dialog-control__footer';
|
|
121
|
+
|
|
122
|
+
footerActions.forEach((action, indexI) => {
|
|
123
|
+
const buttonChildren: DomChildren = [];
|
|
124
|
+
|
|
125
|
+
// Append leading decorative graphic nodes safely if defined
|
|
126
|
+
if (action.leadingIconName) {
|
|
127
|
+
buttonChildren.push(
|
|
128
|
+
GidsIconDom({
|
|
129
|
+
name: action.leadingIconName,
|
|
130
|
+
size: action?.leadingIconSize ?? 'md',
|
|
131
|
+
appearance: action?.leadingIconAppearance ?? 'filled',
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Map textual action titles cleanly
|
|
137
|
+
if (action.buttonLabel) {
|
|
138
|
+
const labelSpan = document.createElement('span');
|
|
139
|
+
labelSpan.textContent = action.buttonLabel;
|
|
140
|
+
buttonChildren.push(labelSpan);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Append trailing decorative graphic nodes safely if defined
|
|
144
|
+
if (action.trailingIconName) {
|
|
145
|
+
buttonChildren.push(
|
|
146
|
+
GidsIconDom({
|
|
147
|
+
name: action.trailingIconName,
|
|
148
|
+
size: action.trailingIconSize,
|
|
149
|
+
appearance: action.trailingIconAppearance,
|
|
150
|
+
}),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const actionBtnAppearance = action?.appearance ?? 'default';
|
|
155
|
+
const actionBtnSize = action?.size ?? 'md';
|
|
156
|
+
const actionBtnWidth = action?.width ?? 'intrinsic';
|
|
157
|
+
const isDestructive = action?.destructive ?? false;
|
|
158
|
+
const isDisabled = action?.disabled ?? false;
|
|
159
|
+
const isLoading = action?.loading ?? false;
|
|
160
|
+
const isPositive = action?.positive ?? false;
|
|
161
|
+
|
|
162
|
+
const actionButton = GidsButtonDom({
|
|
163
|
+
appearance: actionBtnAppearance,
|
|
164
|
+
destructive: isDestructive,
|
|
165
|
+
disabled: isDisabled,
|
|
166
|
+
loading: isLoading,
|
|
167
|
+
positive: isPositive,
|
|
168
|
+
size: actionBtnSize,
|
|
169
|
+
width: actionBtnWidth,
|
|
170
|
+
children: buttonChildren,
|
|
171
|
+
onClick: (event: Event) =>
|
|
172
|
+
onDialogControlFooterAction?.({
|
|
173
|
+
originalEvent: event,
|
|
174
|
+
appearance: actionBtnAppearance,
|
|
175
|
+
destructive: isDestructive,
|
|
176
|
+
disabled: isDisabled,
|
|
177
|
+
buttonLabel: action?.buttonLabel,
|
|
178
|
+
positive: isPositive,
|
|
179
|
+
size: actionBtnSize,
|
|
180
|
+
width: actionBtnWidth,
|
|
181
|
+
buttonId: action?.buttonId,
|
|
182
|
+
index: indexI,
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
footer.appendChild(actionButton);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
dialogControl.appendChild(footer);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 5. Initialize Drag Rules Engine (Excludes layout-breaking fullscreen options)
|
|
193
|
+
if (draggable && variant !== 'full-screen') {
|
|
194
|
+
setupDialogControlDraggable(dialogControl, header);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return dialogControl;
|
|
198
|
+
};
|