@ganpatiinfo/gids-web-dom-reference 3.0.0 → 4.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 +65 -0
- package/dist/components/GidsDismissButton/GidsDismissButton.d.ts +8 -0
- package/dist/components/GidsDismissButton/GidsDismissButton.d.ts.map +1 -0
- package/dist/components/GidsDismissButton/GidsDismissButton.js +20 -0
- package/dist/components/GidsDismissButton/GidsDismissButton.js.map +1 -0
- package/dist/components/GidsField/GidsField.d.ts +7 -0
- package/dist/components/GidsField/GidsField.d.ts.map +1 -0
- package/dist/components/GidsField/GidsField.js +27 -0
- package/dist/components/GidsField/GidsField.js.map +1 -0
- package/dist/components/GidsHeading/GidsHeading.d.ts +7 -0
- package/dist/components/GidsHeading/GidsHeading.d.ts.map +1 -0
- package/dist/components/GidsHeading/GidsHeading.js +45 -0
- package/dist/components/GidsHeading/GidsHeading.js.map +1 -0
- package/dist/components/GidsInput/GidsInput.d.ts +18 -0
- package/dist/components/GidsInput/GidsInput.d.ts.map +1 -0
- package/dist/components/GidsInput/GidsInput.js +28 -0
- package/dist/components/GidsInput/GidsInput.js.map +1 -0
- package/dist/components/GidsLink/GidsLink.d.ts.map +1 -1
- package/dist/components/GidsLink/GidsLink.js.map +1 -1
- package/dist/components/GidsLogo/GidsLogo.d.ts +8 -0
- package/dist/components/GidsLogo/GidsLogo.d.ts.map +1 -0
- package/dist/components/GidsLogo/GidsLogo.js +25 -0
- package/dist/components/GidsLogo/GidsLogo.js.map +1 -0
- package/dist/components/GidsNotification/GidsNotification.d.ts +4 -0
- package/dist/components/GidsNotification/GidsNotification.d.ts.map +1 -0
- package/dist/components/GidsNotification/GidsNotification.js +30 -0
- package/dist/components/GidsNotification/GidsNotification.js.map +1 -0
- package/dist/components/GidsOverlayProvider/GidsOverlayProvider.d.ts +7 -0
- package/dist/components/GidsOverlayProvider/GidsOverlayProvider.d.ts.map +1 -0
- package/dist/components/GidsOverlayProvider/GidsOverlayProvider.js +7 -0
- package/dist/components/GidsOverlayProvider/GidsOverlayProvider.js.map +1 -0
- package/dist/components/GidsPasswordField/GidsPasswordField.d.ts +16 -0
- package/dist/components/GidsPasswordField/GidsPasswordField.d.ts.map +1 -0
- package/dist/components/GidsPasswordField/GidsPasswordField.js +34 -0
- package/dist/components/GidsPasswordField/GidsPasswordField.js.map +1 -0
- package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.d.ts +6 -0
- package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.d.ts.map +1 -0
- package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.js +48 -0
- package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.js.map +1 -0
- package/dist/components/GidsSearchBar/GidsSearchBar.d.ts +9 -0
- package/dist/components/GidsSearchBar/GidsSearchBar.d.ts.map +1 -0
- package/dist/components/GidsSearchBar/GidsSearchBar.js +59 -0
- package/dist/components/GidsSearchBar/GidsSearchBar.js.map +1 -0
- package/dist/components/GidsSectionNotice/GidsSectionNotice.d.ts.map +1 -1
- package/dist/components/GidsSectionNotice/GidsSectionNotice.js.map +1 -1
- package/dist/components/GidsSegmentedControl/GidsSegmentedControl.d.ts +9 -0
- package/dist/components/GidsSegmentedControl/GidsSegmentedControl.d.ts.map +1 -0
- package/dist/components/GidsSegmentedControl/GidsSegmentedControl.js +45 -0
- package/dist/components/GidsSegmentedControl/GidsSegmentedControl.js.map +1 -0
- package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.d.ts +9 -0
- package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.d.ts.map +1 -0
- package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.js +40 -0
- package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.js.map +1 -0
- package/dist/components/GidsSnackbar/GidsSnackbar.d.ts +4 -0
- package/dist/components/GidsSnackbar/GidsSnackbar.d.ts.map +1 -0
- package/dist/components/GidsSnackbar/GidsSnackbar.js +24 -0
- package/dist/components/GidsSnackbar/GidsSnackbar.js.map +1 -0
- package/dist/components/GidsStatusTag/GidsStatusTag.d.ts +6 -0
- package/dist/components/GidsStatusTag/GidsStatusTag.d.ts.map +1 -0
- package/dist/components/GidsStatusTag/GidsStatusTag.js +18 -0
- package/dist/components/GidsStatusTag/GidsStatusTag.js.map +1 -0
- package/dist/components/GidsStepper/GidsStepper.d.ts +8 -0
- package/dist/components/GidsStepper/GidsStepper.d.ts.map +1 -0
- package/dist/components/GidsStepper/GidsStepper.js +67 -0
- package/dist/components/GidsStepper/GidsStepper.js.map +1 -0
- package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts +6 -0
- package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts.map +1 -0
- package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js +51 -0
- package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js.map +1 -0
- package/dist/components/GidsTextField/GidsTextField.d.ts +13 -0
- package/dist/components/GidsTextField/GidsTextField.d.ts.map +1 -0
- package/dist/components/GidsTextField/GidsTextField.js +27 -0
- package/dist/components/GidsTextField/GidsTextField.js.map +1 -0
- package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts +9 -0
- package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts.map +1 -0
- package/dist/components/GidsTopNavigation/GidsTopNavigation.js +61 -0
- package/dist/components/GidsTopNavigation/GidsTopNavigation.js.map +1 -0
- package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts +9 -0
- package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts.map +1 -0
- package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js +73 -0
- package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js.map +1 -0
- package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts +6 -0
- package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts.map +1 -0
- package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js +26 -0
- package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js.map +1 -0
- package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts +8 -0
- package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts.map +1 -0
- package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js +37 -0
- package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/domUtils.d.ts +2 -0
- package/dist/utils/domUtils.d.ts.map +1 -1
- package/dist/utils/domUtils.js +17 -0
- package/dist/utils/domUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/components/GidsDismissButton/GidsDismissButton.ts +45 -0
- package/src/components/GidsField/GidsField.ts +55 -0
- package/src/components/GidsHeading/GidsHeading.ts +72 -0
- package/src/components/GidsInput/GidsInput.ts +64 -0
- package/src/components/GidsLink/GidsLink.ts +20 -20
- package/src/components/GidsLogo/GidsLogo.ts +60 -0
- package/src/components/GidsNotification/GidsNotification.ts +48 -0
- package/src/components/GidsOverlayProvider/GidsOverlayProvider.ts +16 -0
- package/src/components/GidsPasswordField/GidsPasswordField.ts +77 -0
- package/src/components/GidsRequirementsMeter/GidsRequirementsMeter.ts +71 -0
- package/src/components/GidsSearchBar/GidsSearchBar.ts +103 -0
- package/src/components/GidsSectionNotice/GidsSectionNotice.ts +74 -74
- package/src/components/GidsSegmentedControl/GidsSegmentedControl.ts +75 -0
- package/src/components/GidsSegmentedTabItem/GidsSegmentedTabItem.ts +75 -0
- package/src/components/GidsSnackbar/GidsSnackbar.ts +40 -0
- package/src/components/GidsStatusTag/GidsStatusTag.ts +43 -0
- package/src/components/GidsStepper/GidsStepper.ts +94 -0
- package/src/components/GidsStrengthMeter/GidsStrengthMeter.ts +78 -0
- package/src/components/GidsTextField/GidsTextField.ts +59 -0
- package/src/components/GidsTopNavigation/GidsTopNavigation.ts +123 -0
- package/src/components/_GidsNotificationContainer/GidsNotificationContainer.ts +125 -0
- package/src/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.ts +50 -0
- package/src/components/_GidsSnackbarContainer/GidsSnackbarContainer.ts +68 -0
- package/src/index.ts +21 -0
- package/src/utils/domUtils.ts +75 -48
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type GidsSnackbarContainerCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import {
|
|
3
|
+
type ClassValue,
|
|
4
|
+
GidsSnackbarContainerWebUtils,
|
|
5
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
6
|
+
import {
|
|
7
|
+
appendAsChildren,
|
|
8
|
+
type DomNodeOrString,
|
|
9
|
+
} from '../../utils/domUtils.js';
|
|
10
|
+
import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
|
|
11
|
+
import { IconName } from '@ganpatiinfo/gids-web-theme-interface';
|
|
12
|
+
|
|
13
|
+
const { getGidsSnackbarContainerClassNames, getSnackbarContainerIconNames } =
|
|
14
|
+
GidsSnackbarContainerWebUtils;
|
|
15
|
+
|
|
16
|
+
export interface GidsSnackbarContainerDomProps extends GidsSnackbarContainerCommonProps<
|
|
17
|
+
DomNodeOrString,
|
|
18
|
+
DomNodeOrString
|
|
19
|
+
> {
|
|
20
|
+
extraClasses?: ClassValue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const GidsSnackbarContainerDom = (
|
|
24
|
+
props: GidsSnackbarContainerDomProps,
|
|
25
|
+
): HTMLDivElement => {
|
|
26
|
+
const { appearance = 'default', children, button, extraClasses } = props;
|
|
27
|
+
|
|
28
|
+
const snackbarContainer = document.createElement('div');
|
|
29
|
+
snackbarContainer.className = getGidsSnackbarContainerClassNames(
|
|
30
|
+
{ appearance },
|
|
31
|
+
extraClasses,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const snackbarContent = document.createElement('div');
|
|
35
|
+
snackbarContent.className = 'gids-snackbar-container__content';
|
|
36
|
+
|
|
37
|
+
const iconName = getSnackbarContainerIconNames<IconName>(appearance);
|
|
38
|
+
if (appearance !== 'default' && iconName) {
|
|
39
|
+
snackbarContent.appendChild(
|
|
40
|
+
GidsIconDom({
|
|
41
|
+
size: 'md',
|
|
42
|
+
name: iconName,
|
|
43
|
+
alt: '',
|
|
44
|
+
appearance: 'filled',
|
|
45
|
+
className: 'gids-snackbar-container__icon',
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (children) {
|
|
51
|
+
if (typeof children === 'string') {
|
|
52
|
+
const textEl = document.createElement('p');
|
|
53
|
+
appendAsChildren(textEl, children);
|
|
54
|
+
|
|
55
|
+
snackbarContent.appendChild(textEl);
|
|
56
|
+
} else {
|
|
57
|
+
snackbarContent.appendChild(children);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
snackbarContainer.appendChild(snackbarContent);
|
|
62
|
+
|
|
63
|
+
if (button) {
|
|
64
|
+
snackbarContainer.append(button);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return snackbarContainer;
|
|
68
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -38,6 +38,27 @@ export * from './components/GidsBaseCard/GidsBaseCard.js';
|
|
|
38
38
|
export * from './components/GidsCard/GidsCard.js';
|
|
39
39
|
export * from './components/_GidsPaginationItem/GidsPaginationItem.js';
|
|
40
40
|
export * from './components/GidsPagination/GidsPagination.js';
|
|
41
|
+
export * from './components/GidsSegmentedTabItem/GidsSegmentedTabItem.js';
|
|
42
|
+
export * from './components/GidsSegmentedControl/GidsSegmentedControl.js';
|
|
43
|
+
export * from './components/GidsLogo/GidsLogo.js';
|
|
44
|
+
export * from './components/GidsDismissButton/GidsDismissButton.js';
|
|
45
|
+
export * from './components/GidsInput/GidsInput.js';
|
|
46
|
+
export * from './components/GidsField/GidsField.js';
|
|
47
|
+
export * from './components/GidsTextField/GidsTextField.js';
|
|
48
|
+
export * from './components/GidsSearchBar/GidsSearchBar.js';
|
|
49
|
+
export * from './components/GidsTopNavigation/GidsTopNavigation.js';
|
|
50
|
+
export * from './components/GidsStrengthMeter/GidsStrengthMeter.js';
|
|
51
|
+
export * from './components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js';
|
|
52
|
+
export * from './components/GidsRequirementsMeter/GidsRequirementsMeter.js';
|
|
53
|
+
export * from './components/GidsStepper/GidsStepper.js';
|
|
54
|
+
export * from './components/GidsStatusTag/GidsStatusTag.js';
|
|
55
|
+
export * from './components/GidsHeading/GidsHeading.js';
|
|
56
|
+
export * from './components/GidsPasswordField/GidsPasswordField.js';
|
|
57
|
+
export * from './components/_GidsSnackbarContainer/GidsSnackbarContainer.js';
|
|
58
|
+
export * from './components/GidsOverlayProvider/GidsOverlayProvider.js';
|
|
59
|
+
export * from './components/GidsSnackbar/GidsSnackbar.js';
|
|
60
|
+
export * from './components/_GidsNotificationContainer/GidsNotificationContainer.js';
|
|
61
|
+
export * from './components/GidsNotification/GidsNotification.js';
|
|
41
62
|
|
|
42
63
|
/**
|
|
43
64
|
* Utilities
|
package/src/utils/domUtils.ts
CHANGED
|
@@ -3,65 +3,92 @@ export type DomNodeOrString = Node | string;
|
|
|
3
3
|
export type DomChildren = DomNodeOrString | DomNodeOrString[];
|
|
4
4
|
|
|
5
5
|
export const toElementArray = <E extends DomNodeOrString = DomNodeOrString>(
|
|
6
|
-
|
|
6
|
+
singleOrArr: E | E[] | undefined,
|
|
7
7
|
): E[] => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (singleOrArr === undefined) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return Array.isArray(singleOrArr) ? singleOrArr : [singleOrArr];
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const appendAsChildren = (
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
parent: Element,
|
|
16
|
+
children: DomChildren | undefined,
|
|
17
17
|
): void => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
toElementArray(children).forEach((child) => {
|
|
19
|
+
parent.append(child);
|
|
20
|
+
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const toggleAttribute = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
element: Element,
|
|
25
|
+
attributeName: string,
|
|
26
|
+
force?: boolean,
|
|
27
27
|
): boolean => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
if (typeof element.toggleAttribute === 'function') {
|
|
29
|
+
return element.toggleAttribute(attributeName, force);
|
|
30
|
+
} else {
|
|
31
|
+
if (element.hasAttribute(attributeName) || !force) {
|
|
32
|
+
element.removeAttribute(attributeName);
|
|
33
|
+
return false;
|
|
34
|
+
} else {
|
|
35
|
+
element.setAttribute(attributeName, '');
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export const applyStatefulInputProps = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
inputElement: HTMLInputElement,
|
|
43
|
+
{
|
|
44
|
+
value,
|
|
45
|
+
defaultValue,
|
|
46
|
+
checked,
|
|
47
|
+
defaultChecked,
|
|
48
|
+
}: {
|
|
49
|
+
value?: string;
|
|
50
|
+
defaultValue?: string;
|
|
51
|
+
checked?: boolean;
|
|
52
|
+
defaultChecked?: boolean;
|
|
53
|
+
},
|
|
54
54
|
): void => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
if (value !== undefined) {
|
|
56
|
+
inputElement.value = value;
|
|
57
|
+
}
|
|
58
|
+
if (defaultValue !== undefined) {
|
|
59
|
+
inputElement.defaultValue = defaultValue;
|
|
60
|
+
}
|
|
61
|
+
if (checked !== undefined) {
|
|
62
|
+
inputElement.checked = checked;
|
|
63
|
+
}
|
|
64
|
+
if (defaultChecked !== undefined) {
|
|
65
|
+
inputElement.defaultChecked = defaultChecked;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const htmlToDomChildren = (
|
|
70
|
+
html: DomChildren | undefined,
|
|
71
|
+
): DomChildren | undefined => {
|
|
72
|
+
if (Array.isArray(html)) {
|
|
73
|
+
return html.flatMap(htmlToDomChildren).filter((x) => x !== undefined);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (typeof html === 'string') {
|
|
77
|
+
const template = document.createElement('template');
|
|
78
|
+
template.innerHTML = html;
|
|
79
|
+
return Array.from(template.content.childNodes);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return html;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const assignToSlot = (
|
|
86
|
+
parent: Element,
|
|
87
|
+
slotName: string,
|
|
88
|
+
element?: Element,
|
|
89
|
+
): void => {
|
|
90
|
+
if (element) {
|
|
91
|
+
element.slot = slotName;
|
|
92
|
+
parent.appendChild(element);
|
|
93
|
+
}
|
|
67
94
|
};
|