@ganpatiinfo/gids-web-dom-reference 3.1.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/components/GidsDismissButton/GidsDismissButton.d.ts +8 -0
  3. package/dist/components/GidsDismissButton/GidsDismissButton.d.ts.map +1 -0
  4. package/dist/components/GidsDismissButton/GidsDismissButton.js +20 -0
  5. package/dist/components/GidsDismissButton/GidsDismissButton.js.map +1 -0
  6. package/dist/components/GidsField/GidsField.d.ts +7 -0
  7. package/dist/components/GidsField/GidsField.d.ts.map +1 -0
  8. package/dist/components/GidsField/GidsField.js +27 -0
  9. package/dist/components/GidsField/GidsField.js.map +1 -0
  10. package/dist/components/GidsHeading/GidsHeading.d.ts +7 -0
  11. package/dist/components/GidsHeading/GidsHeading.d.ts.map +1 -0
  12. package/dist/components/GidsHeading/GidsHeading.js +45 -0
  13. package/dist/components/GidsHeading/GidsHeading.js.map +1 -0
  14. package/dist/components/GidsInput/GidsInput.d.ts +18 -0
  15. package/dist/components/GidsInput/GidsInput.d.ts.map +1 -0
  16. package/dist/components/GidsInput/GidsInput.js +28 -0
  17. package/dist/components/GidsInput/GidsInput.js.map +1 -0
  18. package/dist/components/GidsLink/GidsLink.d.ts.map +1 -1
  19. package/dist/components/GidsLink/GidsLink.js.map +1 -1
  20. package/dist/components/GidsLogo/GidsLogo.d.ts +8 -0
  21. package/dist/components/GidsLogo/GidsLogo.d.ts.map +1 -0
  22. package/dist/components/GidsLogo/GidsLogo.js +25 -0
  23. package/dist/components/GidsLogo/GidsLogo.js.map +1 -0
  24. package/dist/components/GidsNotification/GidsNotification.d.ts +4 -0
  25. package/dist/components/GidsNotification/GidsNotification.d.ts.map +1 -0
  26. package/dist/components/GidsNotification/GidsNotification.js +30 -0
  27. package/dist/components/GidsNotification/GidsNotification.js.map +1 -0
  28. package/dist/components/GidsOverlayProvider/GidsOverlayProvider.d.ts +7 -0
  29. package/dist/components/GidsOverlayProvider/GidsOverlayProvider.d.ts.map +1 -0
  30. package/dist/components/GidsOverlayProvider/GidsOverlayProvider.js +7 -0
  31. package/dist/components/GidsOverlayProvider/GidsOverlayProvider.js.map +1 -0
  32. package/dist/components/GidsPasswordField/GidsPasswordField.d.ts +16 -0
  33. package/dist/components/GidsPasswordField/GidsPasswordField.d.ts.map +1 -0
  34. package/dist/components/GidsPasswordField/GidsPasswordField.js +34 -0
  35. package/dist/components/GidsPasswordField/GidsPasswordField.js.map +1 -0
  36. package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.d.ts +6 -0
  37. package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.d.ts.map +1 -0
  38. package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.js +48 -0
  39. package/dist/components/GidsRequirementsMeter/GidsRequirementsMeter.js.map +1 -0
  40. package/dist/components/GidsSearchBar/GidsSearchBar.d.ts +9 -0
  41. package/dist/components/GidsSearchBar/GidsSearchBar.d.ts.map +1 -0
  42. package/dist/components/GidsSearchBar/GidsSearchBar.js +59 -0
  43. package/dist/components/GidsSearchBar/GidsSearchBar.js.map +1 -0
  44. package/dist/components/GidsSnackbar/GidsSnackbar.d.ts +4 -0
  45. package/dist/components/GidsSnackbar/GidsSnackbar.d.ts.map +1 -0
  46. package/dist/components/GidsSnackbar/GidsSnackbar.js +24 -0
  47. package/dist/components/GidsSnackbar/GidsSnackbar.js.map +1 -0
  48. package/dist/components/GidsStatusTag/GidsStatusTag.d.ts +6 -0
  49. package/dist/components/GidsStatusTag/GidsStatusTag.d.ts.map +1 -0
  50. package/dist/components/GidsStatusTag/GidsStatusTag.js +18 -0
  51. package/dist/components/GidsStatusTag/GidsStatusTag.js.map +1 -0
  52. package/dist/components/GidsStepper/GidsStepper.d.ts +8 -0
  53. package/dist/components/GidsStepper/GidsStepper.d.ts.map +1 -0
  54. package/dist/components/GidsStepper/GidsStepper.js +67 -0
  55. package/dist/components/GidsStepper/GidsStepper.js.map +1 -0
  56. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts +6 -0
  57. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts.map +1 -0
  58. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js +51 -0
  59. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js.map +1 -0
  60. package/dist/components/GidsTextField/GidsTextField.d.ts +13 -0
  61. package/dist/components/GidsTextField/GidsTextField.d.ts.map +1 -0
  62. package/dist/components/GidsTextField/GidsTextField.js +27 -0
  63. package/dist/components/GidsTextField/GidsTextField.js.map +1 -0
  64. package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts +9 -0
  65. package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts.map +1 -0
  66. package/dist/components/GidsTopNavigation/GidsTopNavigation.js +61 -0
  67. package/dist/components/GidsTopNavigation/GidsTopNavigation.js.map +1 -0
  68. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts +9 -0
  69. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts.map +1 -0
  70. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js +73 -0
  71. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js.map +1 -0
  72. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts +6 -0
  73. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts.map +1 -0
  74. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js +26 -0
  75. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js.map +1 -0
  76. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts +8 -0
  77. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts.map +1 -0
  78. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js +37 -0
  79. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js.map +1 -0
  80. package/dist/index.d.ts +19 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +19 -0
  83. package/dist/index.js.map +1 -1
  84. package/dist/utils/domUtils.d.ts +2 -0
  85. package/dist/utils/domUtils.d.ts.map +1 -1
  86. package/dist/utils/domUtils.js +17 -0
  87. package/dist/utils/domUtils.js.map +1 -1
  88. package/package.json +3 -3
  89. package/src/components/GidsDismissButton/GidsDismissButton.ts +45 -0
  90. package/src/components/GidsField/GidsField.ts +55 -0
  91. package/src/components/GidsHeading/GidsHeading.ts +72 -0
  92. package/src/components/GidsInput/GidsInput.ts +64 -0
  93. package/src/components/GidsLink/GidsLink.ts +20 -20
  94. package/src/components/GidsLogo/GidsLogo.ts +60 -0
  95. package/src/components/GidsNotification/GidsNotification.ts +48 -0
  96. package/src/components/GidsOverlayProvider/GidsOverlayProvider.ts +16 -0
  97. package/src/components/GidsPasswordField/GidsPasswordField.ts +77 -0
  98. package/src/components/GidsRequirementsMeter/GidsRequirementsMeter.ts +71 -0
  99. package/src/components/GidsSearchBar/GidsSearchBar.ts +103 -0
  100. package/src/components/GidsSnackbar/GidsSnackbar.ts +40 -0
  101. package/src/components/GidsStatusTag/GidsStatusTag.ts +43 -0
  102. package/src/components/GidsStepper/GidsStepper.ts +94 -0
  103. package/src/components/GidsStrengthMeter/GidsStrengthMeter.ts +78 -0
  104. package/src/components/GidsTextField/GidsTextField.ts +59 -0
  105. package/src/components/GidsTopNavigation/GidsTopNavigation.ts +123 -0
  106. package/src/components/_GidsNotificationContainer/GidsNotificationContainer.ts +125 -0
  107. package/src/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.ts +50 -0
  108. package/src/components/_GidsSnackbarContainer/GidsSnackbarContainer.ts +68 -0
  109. package/src/index.ts +19 -0
  110. package/src/utils/domUtils.ts +75 -48
@@ -0,0 +1,50 @@
1
+ import {
2
+ GidsRequirementsMeterLabelCommonUtils,
3
+ type GidsRequirementsMeterLabelCommonProps,
4
+ } from '@ganpatiinfo/gids-core-shared';
5
+ import { GidsRequirementsMeterLabelWebUtils } from '@ganpatiinfo/gids-web-shared';
6
+ import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
7
+
8
+ const { getGidsRequirementsMeterLabelClassNames } =
9
+ GidsRequirementsMeterLabelWebUtils;
10
+
11
+ const { getRequirementsMeterLabelLeadingIcon } =
12
+ GidsRequirementsMeterLabelCommonUtils;
13
+
14
+ export interface GidsRequirementsMeterLabelDomProps extends GidsRequirementsMeterLabelCommonProps {
15
+ extraClasses?: string;
16
+ }
17
+
18
+ export const GidsRequirementsMeterLabelDom = ({
19
+ label,
20
+ status = 'default',
21
+ leadingIconVisible = true,
22
+ extraClasses,
23
+ }: GidsRequirementsMeterLabelDomProps): HTMLDivElement => {
24
+ const labelContainer = document.createElement('div');
25
+ labelContainer.className = getGidsRequirementsMeterLabelClassNames(
26
+ { status },
27
+ extraClasses,
28
+ );
29
+
30
+ if (leadingIconVisible && status) {
31
+ const iconName = getRequirementsMeterLabelLeadingIcon(status);
32
+ if (iconName) {
33
+ labelContainer.append(
34
+ GidsIconDom({
35
+ name: iconName,
36
+ size: 'sm',
37
+ appearance: 'filled',
38
+ }),
39
+ );
40
+ }
41
+ }
42
+
43
+ if (label && label !== '') {
44
+ const textEl = document.createElement('span');
45
+ textEl.textContent = label;
46
+ labelContainer.appendChild(textEl);
47
+ }
48
+
49
+ return labelContainer;
50
+ };
@@ -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
@@ -40,6 +40,25 @@ export * from './components/_GidsPaginationItem/GidsPaginationItem.js';
40
40
  export * from './components/GidsPagination/GidsPagination.js';
41
41
  export * from './components/GidsSegmentedTabItem/GidsSegmentedTabItem.js';
42
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';
43
62
 
44
63
  /**
45
64
  * Utilities
@@ -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
- singleOrArr: E | E[] | undefined,
6
+ singleOrArr: E | E[] | undefined,
7
7
  ): E[] => {
8
- if (singleOrArr === undefined) {
9
- return [];
10
- }
11
- return Array.isArray(singleOrArr) ? singleOrArr : [singleOrArr];
8
+ if (singleOrArr === undefined) {
9
+ return [];
10
+ }
11
+ return Array.isArray(singleOrArr) ? singleOrArr : [singleOrArr];
12
12
  };
13
13
 
14
14
  export const appendAsChildren = (
15
- parent: Element,
16
- children: DomChildren | undefined,
15
+ parent: Element,
16
+ children: DomChildren | undefined,
17
17
  ): void => {
18
- toElementArray(children).forEach((child) => {
19
- parent.append(child);
20
- });
18
+ toElementArray(children).forEach((child) => {
19
+ parent.append(child);
20
+ });
21
21
  };
22
22
 
23
23
  export const toggleAttribute = (
24
- element: Element,
25
- attributeName: string,
26
- force?: boolean,
24
+ element: Element,
25
+ attributeName: string,
26
+ force?: boolean,
27
27
  ): boolean => {
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
- }
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
- 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
- },
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
- 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
- }
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
  };