@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,103 @@
1
+ import {
2
+ type GidsSearchBarWebProps,
3
+ GidsSearchBarWebUtils,
4
+ } from '@ganpatiinfo/gids-web-shared';
5
+ import { type HtmlInputAttributes } from '../GidsInput/GidsInput.js';
6
+ import {
7
+ GidsTextFieldDom,
8
+ GidsTextFieldDomProps,
9
+ } from '../GidsTextField/GidsTextField.js';
10
+ import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
11
+ import { GidsSearchBarCommonUtils } from '@ganpatiinfo/gids-core-shared';
12
+
13
+ const { getSearchBarValue } = GidsSearchBarCommonUtils;
14
+ const { getSearchBarType, getSearchBarClassNames } = GidsSearchBarWebUtils;
15
+
16
+ export interface GidsSearchBarDomProps
17
+ extends
18
+ GidsSearchBarWebProps<Element, HtmlInputAttributes>,
19
+ Pick<
20
+ GidsTextFieldDomProps,
21
+ 'className' | 'onChange' | 'onInput' | 'onFocus' | 'onBlur'
22
+ > {
23
+ wrapperClass?: string;
24
+ onGidsSearchBarClear?: (event: CustomEvent<void>) => void;
25
+ }
26
+
27
+ export const GidsSearchBarDom = (
28
+ props: GidsSearchBarDomProps,
29
+ ): HTMLDivElement => {
30
+ const {
31
+ wrapperClass,
32
+ leadingIcon,
33
+ onGidsSearchBarClear,
34
+ onChange,
35
+ onInput,
36
+ onFocus,
37
+ onBlur,
38
+ type = 'default',
39
+ value = '',
40
+ inputProps,
41
+ ...restProps
42
+ } = props;
43
+
44
+ const newValue = getSearchBarValue(value);
45
+ const textFieldType = getSearchBarType(type);
46
+
47
+ // 2. Render your initial DOM exactly once
48
+ const searchBar = document.createElement('div');
49
+ searchBar.className = getSearchBarClassNames(wrapperClass);
50
+
51
+ const updatedLeadingIcon = leadingIcon
52
+ ? leadingIcon
53
+ : GidsIconDom({
54
+ name: 'search',
55
+ appearance: 'regular',
56
+ size: 'md',
57
+ });
58
+
59
+ const gidsSearchBarClear = (event: CustomEvent<void>) => {
60
+ onGidsSearchBarClear?.(event);
61
+ };
62
+
63
+ const gidsOnChange = (event: Event) => {
64
+ if (onChange) {
65
+ onChange(event);
66
+ }
67
+ };
68
+
69
+ const gidsOnInput = (event: InputEvent) => {
70
+ if (onInput) {
71
+ onInput(event);
72
+ }
73
+ };
74
+
75
+ const textFieldProps: GidsTextFieldDomProps = {
76
+ ...restProps,
77
+ leadingAccessory: undefined,
78
+ showClearButton: true,
79
+ leadingIcon: updatedLeadingIcon,
80
+ onGidsTextFieldClear: gidsSearchBarClear,
81
+ onChange: gidsOnChange,
82
+ onInput: gidsOnInput,
83
+ onFocus,
84
+ onBlur,
85
+ type: textFieldType,
86
+ label: undefined,
87
+ value: newValue,
88
+ inputProps: {
89
+ ...inputProps,
90
+ placeholder:
91
+ inputProps?.placeholder && inputProps.placeholder !== ''
92
+ ? inputProps.placeholder
93
+ : 'Search',
94
+ },
95
+ };
96
+
97
+ // 3. Create the text field once
98
+ const textField = GidsTextFieldDom(textFieldProps);
99
+
100
+ searchBar.append(textField);
101
+
102
+ return searchBar;
103
+ };
@@ -0,0 +1,40 @@
1
+ import { type GidsSnackbarWebProps } from '@ganpatiinfo/gids-web-shared';
2
+
3
+ export type GidsSnackbarDomProps = GidsSnackbarWebProps;
4
+
5
+ export const GidsSnackbarDom = ({
6
+ message,
7
+ appearance = 'default',
8
+ show,
9
+ onQueueSnackbar,
10
+ buttonLabel,
11
+ onButtonClick,
12
+ position = 'bottom-center',
13
+ timerInMs,
14
+ }: GidsSnackbarDomProps): HTMLElement => {
15
+ const snackbar = document.createElement('gids-snackbar');
16
+
17
+ if (message) {
18
+ snackbar.setAttribute('message', message);
19
+ }
20
+ if (appearance) {
21
+ snackbar.setAttribute('appearance', appearance);
22
+ }
23
+ snackbar.setAttribute('position', position);
24
+ snackbar.setAttribute('timer-in-ms', timerInMs ? `${timerInMs}` : '0');
25
+
26
+ snackbar.toggleAttribute('show', show ? show : false);
27
+
28
+ if (onQueueSnackbar) {
29
+ snackbar.addEventListener('queueSnackbar', onQueueSnackbar);
30
+ }
31
+ if (buttonLabel) {
32
+ snackbar.setAttribute('button-label', buttonLabel);
33
+ }
34
+ if (onButtonClick) {
35
+ // @ts-expect-error Expected
36
+ snackbar.onButtonClick = onButtonClick;
37
+ }
38
+
39
+ return snackbar;
40
+ };
@@ -0,0 +1,43 @@
1
+ import { type GidsStatusTagCommonProps } from '@ganpatiinfo/gids-core-shared';
2
+ import { GidsStatusTagWebUtils } from '@ganpatiinfo/gids-web-shared';
3
+ import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
4
+ import { type IconName } from '@ganpatiinfo/gids-web-theme-interface';
5
+
6
+ const { getGidsStatusTagClassNames, getStatusTagText, getStatusTagIconName } =
7
+ GidsStatusTagWebUtils;
8
+
9
+ export interface GidsStatusTagDomProps extends GidsStatusTagCommonProps {
10
+ extraClasses?: string;
11
+ }
12
+
13
+ export const GidsStatusTagDom = (
14
+ props: GidsStatusTagDomProps,
15
+ ): HTMLDivElement => {
16
+ const {
17
+ type = 'new',
18
+ appearance = 'subtlest',
19
+ size = 'sm',
20
+ extraClasses,
21
+ } = props;
22
+
23
+ const statusTag = document.createElement('div');
24
+ statusTag.className = getGidsStatusTagClassNames(
25
+ { appearance, size, type },
26
+ extraClasses,
27
+ );
28
+
29
+ const statusTagIconName = getStatusTagIconName<IconName>(type);
30
+ statusTag.append(
31
+ GidsIconDom({
32
+ name: statusTagIconName,
33
+ appearance: 'filled',
34
+ }),
35
+ );
36
+
37
+ const label = document.createElement('label');
38
+ label.textContent = getStatusTagText(type) ?? '';
39
+
40
+ statusTag.appendChild(label);
41
+
42
+ return statusTag;
43
+ };
@@ -0,0 +1,94 @@
1
+ import {
2
+ GidsStepperCommonUtils,
3
+ type StepClickProps,
4
+ type GidsStepperCommonProps,
5
+ } from '@ganpatiinfo/gids-core-shared';
6
+ import { GidsStepperWebUtils } from '@ganpatiinfo/gids-web-shared';
7
+ import { GidsButtonDom } from '../GidsButton/GidsButton.js';
8
+ import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
9
+
10
+ const { isStepperMinusDisabled } = GidsStepperCommonUtils;
11
+ const { getGidsStepperClassNames } = GidsStepperWebUtils;
12
+
13
+ export interface GidsStepperDomProps extends GidsStepperCommonProps {
14
+ extraClasses?: string;
15
+ onClickMinus?: (params: StepClickProps) => void;
16
+ onClickPlus?: (params: StepClickProps) => void;
17
+ }
18
+
19
+ export const GidsStepperDom = ({
20
+ disabled,
21
+ extraClasses,
22
+ onClickMinus,
23
+ onClickPlus,
24
+ }: GidsStepperDomProps): HTMLDivElement => {
25
+ // 1. Maintain internal state within the closure
26
+ let currentValue = 0;
27
+
28
+ const stepper = document.createElement('div');
29
+ stepper.className = getGidsStepperClassNames(extraClasses);
30
+
31
+ // 2. Create the display label
32
+ const label = document.createElement('label');
33
+ label.className = `gids-stepper__label ${disabled ? 'gids-stepper__label-disabled' : ''}`;
34
+
35
+ // Helper to update the text content
36
+ const updateLabel = () => {
37
+ label.textContent = `${currentValue}`;
38
+ };
39
+ updateLabel();
40
+
41
+ // 3. Create the buttons
42
+ const minusButton = GidsButtonDom({
43
+ leadingIcon: GidsIconDom({
44
+ name: 'minus',
45
+ size: 'md',
46
+ appearance: 'regular',
47
+ }),
48
+ disabled: disabled || isStepperMinusDisabled({ stepText: currentValue }),
49
+ size: 'sm',
50
+ width: 'intrinsic',
51
+ appearance: 'default',
52
+ onClick: () => {
53
+ if (disabled) return;
54
+ currentValue -= 1;
55
+ updateLabel();
56
+
57
+ // Re-evaluate the disabled state of the minus button dynamically
58
+ const isMinusDisabled =
59
+ disabled || isStepperMinusDisabled({ stepText: currentValue });
60
+ minusButton.toggleAttribute('disabled', isMinusDisabled);
61
+
62
+ onClickMinus?.({ stepText: currentValue });
63
+ },
64
+ });
65
+
66
+ const plusButton = GidsButtonDom({
67
+ leadingIcon: GidsIconDom({
68
+ name: 'plus',
69
+ size: 'md',
70
+ appearance: 'regular',
71
+ }),
72
+ disabled: disabled,
73
+ size: 'sm',
74
+ width: 'intrinsic',
75
+ appearance: 'default',
76
+ onClick: () => {
77
+ if (disabled) return;
78
+ currentValue += 1;
79
+ updateLabel();
80
+
81
+ // Ensure the minus button is un-disabled if it was previously locked
82
+ const isMinusDisabled =
83
+ disabled || isStepperMinusDisabled({ stepText: currentValue });
84
+ minusButton.toggleAttribute('disabled', isMinusDisabled);
85
+
86
+ onClickPlus?.({ stepText: currentValue });
87
+ },
88
+ });
89
+
90
+ // 4. Assemble the DOM
91
+ stepper.append(minusButton, label, plusButton);
92
+
93
+ return stepper;
94
+ };
@@ -0,0 +1,78 @@
1
+ import {
2
+ type GidsStrengthMeterCommonProps,
3
+ GidsStrengthMeterCommonUtils,
4
+ } from '@ganpatiinfo/gids-core-shared';
5
+ import { GidsStrengthMeterWebUtils } from '@ganpatiinfo/gids-web-shared';
6
+ import { appendAsChildren } from '../../utils/domUtils.js';
7
+ import { minLengthRuleCanBeApplied } from '@ganpatiinfo/gids-core-shared/dist/components/GidsRequirementsMeter/GidsRequirementsMeterCommonUtils.js';
8
+
9
+ const { getGidsStrengthMeterClassNames } = GidsStrengthMeterWebUtils;
10
+ const { getStrengthMeterScore, getColorModifierByScore } =
11
+ GidsStrengthMeterCommonUtils;
12
+
13
+ export interface GidsStrengthMeterDomProps extends GidsStrengthMeterCommonProps {
14
+ extraClasses?: string;
15
+ }
16
+
17
+ export const GidsStrengthMeterDom = ({
18
+ text,
19
+ textMinLength,
20
+ meterRules = [
21
+ '1-uppercase',
22
+ '1-lowercase',
23
+ '1-digit',
24
+ '1-special-character',
25
+ 'include-min-length',
26
+ ],
27
+ extraClasses,
28
+ }: GidsStrengthMeterDomProps): HTMLDivElement => {
29
+ const strengthContainer = document.createElement('div');
30
+ strengthContainer.className = getGidsStrengthMeterClassNames(extraClasses);
31
+
32
+ const textScore = getStrengthMeterScore({
33
+ text,
34
+ textMinLength,
35
+ meterRules,
36
+ });
37
+
38
+ const maxScore = meterRules.length;
39
+ const colorModifier = getColorModifierByScore({ textScore, maxScore });
40
+
41
+ const renderStrengthLine = (
42
+ strengthLine: HTMLDivElement,
43
+ isActive: boolean,
44
+ index: number,
45
+ ) => {
46
+ // Class construction using the dynamic color modifier for active segments
47
+ strengthLine.className = [
48
+ `gids-strength-meter__strength-${index}`,
49
+ isActive ? 'is-active' : '',
50
+ isActive ? colorModifier : '',
51
+ ]
52
+ .filter(Boolean)
53
+ .join(' ');
54
+ };
55
+
56
+ for (let i = 1; i <= maxScore; i++) {
57
+ const strengthLine = document.createElement('div');
58
+
59
+ const isActive = i <= textScore;
60
+
61
+ if (meterRules[i - 1] === 'include-min-length') {
62
+ if (
63
+ minLengthRuleCanBeApplied({
64
+ requirementRule: 'include-min-length',
65
+ textMinLength,
66
+ })
67
+ ) {
68
+ renderStrengthLine(strengthLine, isActive, i);
69
+ }
70
+ } else {
71
+ renderStrengthLine(strengthLine, isActive, i);
72
+ }
73
+
74
+ appendAsChildren(strengthContainer, strengthLine);
75
+ }
76
+
77
+ return strengthContainer;
78
+ };
@@ -0,0 +1,59 @@
1
+ import { type GidsTextFieldWebProps } from '@ganpatiinfo/gids-web-shared';
2
+ import { assignToSlot } from '../../utils/domUtils.js';
3
+ import { type HtmlInputAttributes } from '../GidsInput/GidsInput.js';
4
+
5
+ export interface GidsTextFieldDomProps extends GidsTextFieldWebProps<
6
+ Element,
7
+ HtmlInputAttributes
8
+ > {
9
+ info?: Element;
10
+ className?: string;
11
+ onGidsTextFieldClear?: (event: CustomEvent<void>) => void;
12
+ onChange?: (event: Event) => void;
13
+ onInput?: (event: InputEvent) => void;
14
+ onFocus?: (event: FocusEvent) => void;
15
+ onBlur?: (event: FocusEvent) => void;
16
+ }
17
+
18
+ export const GidsTextFieldDom = (props: GidsTextFieldDomProps): HTMLElement => {
19
+ const {
20
+ info,
21
+ leadingIcon,
22
+ trailingIcon,
23
+ onGidsTextFieldClear,
24
+ onChange,
25
+ onInput,
26
+ onFocus,
27
+ onBlur,
28
+ ...restProps
29
+ } = props;
30
+
31
+ const textFieldComponent = document.createElement('gids-text-field');
32
+ Object.assign(textFieldComponent, restProps);
33
+
34
+ assignToSlot(textFieldComponent, 'info', info);
35
+ assignToSlot(textFieldComponent, 'leadingIcon', leadingIcon);
36
+ assignToSlot(textFieldComponent, 'trailingIcon', trailingIcon);
37
+
38
+ if (onChange) {
39
+ textFieldComponent.addEventListener('change', onChange);
40
+ }
41
+ if (onInput) {
42
+ textFieldComponent.addEventListener('input', onInput as (e: Event) => void);
43
+ }
44
+ if (onFocus) {
45
+ textFieldComponent.addEventListener('focus', onFocus);
46
+ }
47
+ if (onBlur) {
48
+ textFieldComponent.addEventListener('blur', onBlur);
49
+ }
50
+ if (onGidsTextFieldClear) {
51
+ // @ts-expect-error This is a custom event so ts complaining
52
+ textFieldComponent.addEventListener(
53
+ 'gidsTextFieldClear',
54
+ onGidsTextFieldClear,
55
+ );
56
+ }
57
+
58
+ return textFieldComponent;
59
+ };
@@ -0,0 +1,123 @@
1
+ import {
2
+ type GidsTopNavigationWebProps,
3
+ GidsTopNavigationWebUtils,
4
+ } from '@ganpatiinfo/gids-web-shared';
5
+ import {
6
+ appendAsChildren,
7
+ DomChildren,
8
+ DomNodeOrString,
9
+ } from '../../utils/domUtils.js';
10
+ import {
11
+ GidsSearchBarDom,
12
+ GidsSearchBarDomProps,
13
+ } from '../GidsSearchBar/GidsSearchBar.js';
14
+ import {
15
+ GidsSegmentedControlDom,
16
+ GidsSegmentedControlDomProps,
17
+ } from '../GidsSegmentedControl/GidsSegmentedControl.js';
18
+ import { GidsLogoDom } from '../GidsLogo/GidsLogo.js';
19
+
20
+ const { getGidsTopNavigationClassNames } = GidsTopNavigationWebUtils;
21
+
22
+ export interface GidsTopNavigationDomProps
23
+ extends
24
+ GidsTopNavigationWebProps<
25
+ DomChildren,
26
+ DomChildren,
27
+ DomChildren,
28
+ DomNodeOrString,
29
+ string,
30
+ string,
31
+ string
32
+ >,
33
+ Pick<GidsSearchBarDomProps, 'onBlur' | 'onChange' | 'onFocus' | 'onInput'>,
34
+ Pick<GidsSegmentedControlDomProps, 'onPress'> {
35
+ extraClasses?: string;
36
+ }
37
+
38
+ export const GidsTopNavigationDom = (
39
+ props: GidsTopNavigationDomProps,
40
+ ): HTMLElement => {
41
+ const {
42
+ isDefaultLeftContentRender = true,
43
+ isDefaultMiddleContentRender = true,
44
+ isDefaultRightContentRender = true,
45
+ leftContent,
46
+ middleContent,
47
+ rightContent,
48
+ src,
49
+ imgHeight = '100',
50
+ href,
51
+ clickable,
52
+ onPress,
53
+ width,
54
+ tabItems = [],
55
+ extraClasses,
56
+ ...rest
57
+ } = props;
58
+
59
+ const topNavigation = document.createElement('nav');
60
+ topNavigation.className = getGidsTopNavigationClassNames(extraClasses);
61
+
62
+ const leftContentContainer = document.createElement('div');
63
+ leftContentContainer.className = 'gids-top-navigation__left-content';
64
+
65
+ if (leftContent || isDefaultLeftContentRender) {
66
+ if (leftContent) {
67
+ appendAsChildren(leftContentContainer, leftContent);
68
+ }
69
+ if (isDefaultLeftContentRender) {
70
+ leftContentContainer.append(
71
+ GidsLogoDom({
72
+ src: src,
73
+ imgHeight: imgHeight,
74
+ alt: 'logo-img',
75
+ href: href && href !== '' ? href : '/',
76
+ clickable,
77
+ }),
78
+ );
79
+ }
80
+ topNavigation.appendChild(leftContentContainer);
81
+ }
82
+
83
+ const middleContentContainer = document.createElement('div');
84
+ middleContentContainer.className = 'gids-top-navigation__middle-content';
85
+
86
+ if (middleContent || isDefaultMiddleContentRender) {
87
+ if (middleContent) {
88
+ appendAsChildren(middleContentContainer, middleContent);
89
+ }
90
+ if (isDefaultMiddleContentRender) {
91
+ middleContentContainer.append(
92
+ GidsSearchBarDom({
93
+ type: 'default',
94
+ appearance: 'default',
95
+ status: 'default',
96
+ ...rest,
97
+ }),
98
+ );
99
+ }
100
+ topNavigation.appendChild(middleContentContainer);
101
+ }
102
+
103
+ const rightContentContainer = document.createElement('div');
104
+ rightContentContainer.className = 'gids-top-navigation__right-content';
105
+
106
+ if (rightContent || isDefaultRightContentRender) {
107
+ if (rightContent) {
108
+ appendAsChildren(rightContentContainer, rightContent);
109
+ }
110
+ if (isDefaultRightContentRender) {
111
+ rightContentContainer.append(
112
+ GidsSegmentedControlDom({
113
+ width: width ? width : 'intrinsic',
114
+ tabItems: tabItems,
115
+ onPress,
116
+ }),
117
+ );
118
+ }
119
+ topNavigation.appendChild(rightContentContainer);
120
+ }
121
+
122
+ return topNavigation;
123
+ };
@@ -0,0 +1,125 @@
1
+ import { GidsNotificationContainerCommonProps } from '@ganpatiinfo/gids-core-shared';
2
+ import {
3
+ ClassValue,
4
+ GidsNotificationContainerWebUtils,
5
+ } from '@ganpatiinfo/gids-web-shared';
6
+ import { type DomNodeOrString } from '../../utils/domUtils.js';
7
+ import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
8
+ import { IconName } from '@ganpatiinfo/gids-web-theme-interface';
9
+ import { GidsButtonDom } from '../GidsButton/GidsButton.js';
10
+
11
+ const {
12
+ getGidsNotificationContainerClassNames,
13
+ getNotificationContainerIconNames,
14
+ } = GidsNotificationContainerWebUtils;
15
+
16
+ export interface GidsNotificationContainerDomProps extends GidsNotificationContainerCommonProps<
17
+ DomNodeOrString,
18
+ DomNodeOrString
19
+ > {
20
+ extraClasses?: ClassValue;
21
+ onCloseNotificationClick?: (this: HTMLButtonElement, event: Event) => void;
22
+ }
23
+
24
+ export const GidsNotificationContainerDom = (
25
+ props: GidsNotificationContainerDomProps,
26
+ ): HTMLDivElement => {
27
+ const {
28
+ notificationTitle,
29
+ children,
30
+ button,
31
+ appearance = 'default',
32
+ pronunciation = 'standard',
33
+ onCloseNotificationClick,
34
+ extraClasses,
35
+ } = props;
36
+
37
+ const notificationContainer = document.createElement('div');
38
+ notificationContainer.className = getGidsNotificationContainerClassNames(
39
+ { appearance },
40
+ extraClasses,
41
+ );
42
+
43
+ const iconWrapper = document.createElement('div');
44
+ iconWrapper.className = 'gids-notification-container__leading-icon-wrapper';
45
+ const iconName = getNotificationContainerIconNames<IconName>(appearance);
46
+ if (appearance !== 'default' && iconName) {
47
+ iconWrapper.appendChild(
48
+ GidsIconDom({
49
+ size: 'md',
50
+ name: iconName,
51
+ alt: '',
52
+ appearance: 'filled',
53
+ }),
54
+ );
55
+ notificationContainer.appendChild(iconWrapper);
56
+ }
57
+
58
+ const notificationContentWrapper = document.createElement('div');
59
+ notificationContentWrapper.className =
60
+ 'gids-notification-container__content-wrapper';
61
+
62
+ const notificationTopContent = document.createElement('div');
63
+ notificationTopContent.className = 'gids-notification-container__top-content';
64
+
65
+ const notificationTextContent = document.createElement('div');
66
+ notificationTextContent.className =
67
+ 'gids-notification-container__text-content';
68
+
69
+ if (notificationTitle && notificationTitle !== '') {
70
+ const notificationTitleEl = document.createElement('span');
71
+ notificationTitleEl.className = 'gids-notification-container__title';
72
+ notificationTitleEl.textContent = notificationTitle;
73
+
74
+ notificationTextContent.appendChild(notificationTitleEl);
75
+ }
76
+
77
+ if (children) {
78
+ if (typeof children === 'string') {
79
+ const textEl = document.createElement('p');
80
+ textEl.textContent = children;
81
+
82
+ notificationTextContent.appendChild(textEl);
83
+ } else {
84
+ notificationTextContent.appendChild(children);
85
+ }
86
+ }
87
+
88
+ notificationTopContent.appendChild(notificationTextContent);
89
+
90
+ const crossBtnWrapper = document.createElement('div');
91
+ crossBtnWrapper.className = 'gids-notification-container__cross-btn-wrapper';
92
+
93
+ if (pronunciation === 'standard') {
94
+ crossBtnWrapper.appendChild(
95
+ GidsButtonDom({
96
+ appearance: 'subtle',
97
+ size: 'sm',
98
+ width: 'intrinsic',
99
+ leadingIcon: GidsIconDom({
100
+ name: 'cross',
101
+ size: 'md',
102
+ appearance: 'regular',
103
+ }),
104
+ onClick: onCloseNotificationClick,
105
+ }),
106
+ );
107
+ notificationTopContent.appendChild(crossBtnWrapper);
108
+ }
109
+
110
+ notificationContentWrapper.appendChild(notificationTopContent);
111
+
112
+ if (button) {
113
+ const notificationBottomContent = document.createElement('div');
114
+ notificationBottomContent.className =
115
+ 'gids-notification-container__bottom-content';
116
+
117
+ notificationBottomContent.append(button);
118
+
119
+ notificationContentWrapper.appendChild(notificationBottomContent);
120
+ }
121
+
122
+ notificationContainer.appendChild(notificationContentWrapper);
123
+
124
+ return notificationContainer;
125
+ };