@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.
Files changed (123) hide show
  1. package/CHANGELOG.md +65 -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/GidsSectionNotice/GidsSectionNotice.d.ts.map +1 -1
  45. package/dist/components/GidsSectionNotice/GidsSectionNotice.js.map +1 -1
  46. package/dist/components/GidsSegmentedControl/GidsSegmentedControl.d.ts +9 -0
  47. package/dist/components/GidsSegmentedControl/GidsSegmentedControl.d.ts.map +1 -0
  48. package/dist/components/GidsSegmentedControl/GidsSegmentedControl.js +45 -0
  49. package/dist/components/GidsSegmentedControl/GidsSegmentedControl.js.map +1 -0
  50. package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.d.ts +9 -0
  51. package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.d.ts.map +1 -0
  52. package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.js +40 -0
  53. package/dist/components/GidsSegmentedTabItem/GidsSegmentedTabItem.js.map +1 -0
  54. package/dist/components/GidsSnackbar/GidsSnackbar.d.ts +4 -0
  55. package/dist/components/GidsSnackbar/GidsSnackbar.d.ts.map +1 -0
  56. package/dist/components/GidsSnackbar/GidsSnackbar.js +24 -0
  57. package/dist/components/GidsSnackbar/GidsSnackbar.js.map +1 -0
  58. package/dist/components/GidsStatusTag/GidsStatusTag.d.ts +6 -0
  59. package/dist/components/GidsStatusTag/GidsStatusTag.d.ts.map +1 -0
  60. package/dist/components/GidsStatusTag/GidsStatusTag.js +18 -0
  61. package/dist/components/GidsStatusTag/GidsStatusTag.js.map +1 -0
  62. package/dist/components/GidsStepper/GidsStepper.d.ts +8 -0
  63. package/dist/components/GidsStepper/GidsStepper.d.ts.map +1 -0
  64. package/dist/components/GidsStepper/GidsStepper.js +67 -0
  65. package/dist/components/GidsStepper/GidsStepper.js.map +1 -0
  66. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts +6 -0
  67. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.d.ts.map +1 -0
  68. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js +51 -0
  69. package/dist/components/GidsStrengthMeter/GidsStrengthMeter.js.map +1 -0
  70. package/dist/components/GidsTextField/GidsTextField.d.ts +13 -0
  71. package/dist/components/GidsTextField/GidsTextField.d.ts.map +1 -0
  72. package/dist/components/GidsTextField/GidsTextField.js +27 -0
  73. package/dist/components/GidsTextField/GidsTextField.js.map +1 -0
  74. package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts +9 -0
  75. package/dist/components/GidsTopNavigation/GidsTopNavigation.d.ts.map +1 -0
  76. package/dist/components/GidsTopNavigation/GidsTopNavigation.js +61 -0
  77. package/dist/components/GidsTopNavigation/GidsTopNavigation.js.map +1 -0
  78. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts +9 -0
  79. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.d.ts.map +1 -0
  80. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js +73 -0
  81. package/dist/components/_GidsNotificationContainer/GidsNotificationContainer.js.map +1 -0
  82. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts +6 -0
  83. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.d.ts.map +1 -0
  84. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js +26 -0
  85. package/dist/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js.map +1 -0
  86. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts +8 -0
  87. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.d.ts.map +1 -0
  88. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js +37 -0
  89. package/dist/components/_GidsSnackbarContainer/GidsSnackbarContainer.js.map +1 -0
  90. package/dist/index.d.ts +21 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +21 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/utils/domUtils.d.ts +2 -0
  95. package/dist/utils/domUtils.d.ts.map +1 -1
  96. package/dist/utils/domUtils.js +17 -0
  97. package/dist/utils/domUtils.js.map +1 -1
  98. package/package.json +4 -4
  99. package/src/components/GidsDismissButton/GidsDismissButton.ts +45 -0
  100. package/src/components/GidsField/GidsField.ts +55 -0
  101. package/src/components/GidsHeading/GidsHeading.ts +72 -0
  102. package/src/components/GidsInput/GidsInput.ts +64 -0
  103. package/src/components/GidsLink/GidsLink.ts +20 -20
  104. package/src/components/GidsLogo/GidsLogo.ts +60 -0
  105. package/src/components/GidsNotification/GidsNotification.ts +48 -0
  106. package/src/components/GidsOverlayProvider/GidsOverlayProvider.ts +16 -0
  107. package/src/components/GidsPasswordField/GidsPasswordField.ts +77 -0
  108. package/src/components/GidsRequirementsMeter/GidsRequirementsMeter.ts +71 -0
  109. package/src/components/GidsSearchBar/GidsSearchBar.ts +103 -0
  110. package/src/components/GidsSectionNotice/GidsSectionNotice.ts +74 -74
  111. package/src/components/GidsSegmentedControl/GidsSegmentedControl.ts +75 -0
  112. package/src/components/GidsSegmentedTabItem/GidsSegmentedTabItem.ts +75 -0
  113. package/src/components/GidsSnackbar/GidsSnackbar.ts +40 -0
  114. package/src/components/GidsStatusTag/GidsStatusTag.ts +43 -0
  115. package/src/components/GidsStepper/GidsStepper.ts +94 -0
  116. package/src/components/GidsStrengthMeter/GidsStrengthMeter.ts +78 -0
  117. package/src/components/GidsTextField/GidsTextField.ts +59 -0
  118. package/src/components/GidsTopNavigation/GidsTopNavigation.ts +123 -0
  119. package/src/components/_GidsNotificationContainer/GidsNotificationContainer.ts +125 -0
  120. package/src/components/_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.ts +50 -0
  121. package/src/components/_GidsSnackbarContainer/GidsSnackbarContainer.ts +68 -0
  122. package/src/index.ts +21 -0
  123. package/src/utils/domUtils.ts +75 -48
@@ -0,0 +1,60 @@
1
+ import {
2
+ type ClassValue,
3
+ type GidsLogoWebProps,
4
+ GidsLogoWebUtils,
5
+ } from '@ganpatiinfo/gids-web-shared';
6
+ import clsx from 'clsx';
7
+
8
+ const { getGidsLogoClassNames } = GidsLogoWebUtils;
9
+
10
+ export interface GidsLogoDomProps
11
+ extends
12
+ GidsLogoWebProps<string, string>,
13
+ Omit<Partial<HTMLAnchorElement>, 'href' | 'class'> {
14
+ extraClasses?: ClassValue;
15
+ imgClasses?: ClassValue;
16
+ imgProps?: Omit<
17
+ Partial<HTMLImageElement>,
18
+ 'src' | 'alt' | 'class' | 'height'
19
+ >;
20
+ }
21
+
22
+ export const GidsLogoDom = ({
23
+ src,
24
+ href,
25
+ alt,
26
+ clickable,
27
+ extraClasses,
28
+ imgClasses,
29
+ imgProps,
30
+ imgHeight = '100',
31
+ ...restProps
32
+ }: GidsLogoDomProps): HTMLAnchorElement => {
33
+ const linkElement = document.createElement('a');
34
+ linkElement.className = getGidsLogoClassNames(extraClasses);
35
+ if (restProps) {
36
+ Object.assign(linkElement, restProps);
37
+ }
38
+
39
+ if (clickable && href && href !== '') {
40
+ linkElement.setAttribute('href', href);
41
+ }
42
+
43
+ if (src && src !== '') {
44
+ const imgElement = document.createElement('img');
45
+ imgElement.className = clsx(
46
+ `gids-logo__img gids-logo__img-height-${imgHeight}`,
47
+ imgClasses,
48
+ );
49
+ imgElement.setAttribute('src', src);
50
+ imgElement.setAttribute('alt', alt ? alt : 'logo');
51
+
52
+ if (imgProps) {
53
+ Object.assign(imgElement, imgProps);
54
+ }
55
+
56
+ linkElement.appendChild(imgElement);
57
+ }
58
+
59
+ return linkElement;
60
+ };
@@ -0,0 +1,48 @@
1
+ import { type GidsNotificationWebProps } from '@ganpatiinfo/gids-web-shared';
2
+
3
+ export type GidsNotificationDomProps = GidsNotificationWebProps;
4
+
5
+ export const GidsNotificationDom = ({
6
+ notificationTitle,
7
+ message,
8
+ pronunciation,
9
+ appearance = 'default',
10
+ show,
11
+ onQueueNotification,
12
+ buttonLabel,
13
+ onButtonClick,
14
+ position = 'bottom-center',
15
+ timerInMs,
16
+ }: GidsNotificationDomProps): HTMLElement => {
17
+ const notification = document.createElement('gids-notification');
18
+
19
+ if (notificationTitle) {
20
+ notification.setAttribute('notification-title', notificationTitle);
21
+ }
22
+ if (message) {
23
+ notification.setAttribute('message', message);
24
+ }
25
+ if (pronunciation) {
26
+ notification.setAttribute('pronunciation', pronunciation);
27
+ }
28
+ if (appearance) {
29
+ notification.setAttribute('appearance', appearance);
30
+ }
31
+ notification.setAttribute('position', position);
32
+ notification.setAttribute('timer-in-ms', timerInMs ? `${timerInMs}` : '0');
33
+
34
+ notification.toggleAttribute('show', show ? show : false);
35
+
36
+ if (onQueueNotification) {
37
+ notification.addEventListener('queueNotification', onQueueNotification);
38
+ }
39
+ if (buttonLabel) {
40
+ notification.setAttribute('button-label', buttonLabel);
41
+ }
42
+ if (onButtonClick) {
43
+ // @ts-expect-error Expected
44
+ notification.onButtonClick = onButtonClick;
45
+ }
46
+
47
+ return notification;
48
+ };
@@ -0,0 +1,16 @@
1
+ import { GidsOverlayProviderCommonProps } from '@ganpatiinfo/gids-core-shared';
2
+ import { appendAsChildren, DomChildren } from '../../utils/domUtils.js';
3
+
4
+ export interface GidsOverlayProviderDomProps extends GidsOverlayProviderCommonProps<DomChildren> {
5
+ extraClasses?: string;
6
+ }
7
+
8
+ export const GidsOverlayProviderDom = ({
9
+ children,
10
+ }: GidsOverlayProviderDomProps): HTMLElement => {
11
+ const overlayProvider = document.createElement('gids-overlay-provider');
12
+
13
+ appendAsChildren(overlayProvider, children);
14
+
15
+ return overlayProvider;
16
+ };
@@ -0,0 +1,77 @@
1
+ import { type GidsPasswordFieldWebProps } from '@ganpatiinfo/gids-web-shared';
2
+ import { assignToSlot } from '../../utils/domUtils.js';
3
+ import { type HtmlInputAttributes } from '../GidsInput/GidsInput.js';
4
+
5
+ export interface GidsPasswordFieldDomProps extends GidsPasswordFieldWebProps<
6
+ Element,
7
+ HtmlInputAttributes
8
+ > {
9
+ info?: Element;
10
+ className?: string;
11
+ onGidsPasswordFieldClear?: (event: CustomEvent<void>) => void;
12
+ onGidsPasswordFieldRevealPassword?: (
13
+ event: CustomEvent<{ passwordRevealed: boolean }>,
14
+ ) => void;
15
+ onChange?: (event: Event) => void;
16
+ onInput?: (event: InputEvent) => void;
17
+ onFocus?: (event: FocusEvent) => void;
18
+ onBlur?: (event: FocusEvent) => void;
19
+ }
20
+
21
+ export const GidsPasswordFieldDom = (
22
+ props: GidsPasswordFieldDomProps,
23
+ ): HTMLElement => {
24
+ const {
25
+ info,
26
+ leadingIcon,
27
+ onGidsPasswordFieldClear,
28
+ onGidsPasswordFieldRevealPassword,
29
+ onChange,
30
+ onInput,
31
+ onFocus,
32
+ onBlur,
33
+ ...restProps
34
+ } = props;
35
+
36
+ const passwordFieldComponent = document.createElement('gids-password-field');
37
+ Object.assign(passwordFieldComponent, restProps);
38
+ passwordFieldComponent.setAttribute('type', 'password');
39
+
40
+ assignToSlot(passwordFieldComponent, 'info', info);
41
+ assignToSlot(passwordFieldComponent, 'leadingIcon', leadingIcon);
42
+
43
+ if (onChange) {
44
+ passwordFieldComponent.addEventListener('change', onChange);
45
+ }
46
+ if (onInput) {
47
+ passwordFieldComponent.addEventListener(
48
+ 'input',
49
+ onInput as (e: Event) => void,
50
+ );
51
+ }
52
+ if (onFocus) {
53
+ passwordFieldComponent.addEventListener('focus', onFocus);
54
+ }
55
+ if (onBlur) {
56
+ passwordFieldComponent.addEventListener('blur', onBlur);
57
+ }
58
+ if (onGidsPasswordFieldClear) {
59
+ // @ts-expect-error This is a custom event so ts complaining
60
+ passwordFieldComponent.addEventListener(
61
+ 'gidsPasswordFieldClear',
62
+ onGidsPasswordFieldClear,
63
+ );
64
+ }
65
+ if (onGidsPasswordFieldRevealPassword) {
66
+ // @ts-expect-error This is a custom event so ts complaining
67
+ passwordFieldComponent.addEventListener(
68
+ 'gidsPasswordFieldRevealPassword',
69
+ (event: CustomEvent) => {
70
+ // Stencil data is always nested inside 'detail'
71
+ onGidsPasswordFieldRevealPassword(event.detail);
72
+ },
73
+ );
74
+ }
75
+
76
+ return passwordFieldComponent;
77
+ };
@@ -0,0 +1,71 @@
1
+ import {
2
+ type GidsRequirementsMeterCommonProps,
3
+ GidsRequirementsMeterCommonUtils,
4
+ GidsRequirementsProps,
5
+ } from '@ganpatiinfo/gids-core-shared';
6
+ import { GidsRequirementsMeterWebUtils } from '@ganpatiinfo/gids-web-shared';
7
+ import { GidsRequirementsMeterLabelDom } from '../_GidsRequirementsMeterLabel/GidsRequirementsMeterLabel.js';
8
+ import { minLengthRuleCanBeApplied } from '@ganpatiinfo/gids-core-shared/dist/components/GidsRequirementsMeter/GidsRequirementsMeterCommonUtils.js';
9
+
10
+ const { getGidsRequirementsMeterClassNames } = GidsRequirementsMeterWebUtils;
11
+ const { checkRequirementRuleSatisfied } = GidsRequirementsMeterCommonUtils;
12
+
13
+ export interface GidsRequirementsMeterDomProps extends GidsRequirementsMeterCommonProps {
14
+ extraClasses?: string;
15
+ }
16
+
17
+ export const GidsRequirementsMeterDom = (
18
+ props: GidsRequirementsMeterDomProps,
19
+ ): HTMLDivElement => {
20
+ const { text, textMinLength, requirements = [], extraClasses } = props;
21
+
22
+ const requirementsMeter = document.createElement('div');
23
+ requirementsMeter.className =
24
+ getGidsRequirementsMeterClassNames(extraClasses);
25
+
26
+ const renderRequirements = (
27
+ isSatisfied: boolean,
28
+ requirement: GidsRequirementsProps,
29
+ ) => {
30
+ if (isSatisfied) {
31
+ requirementsMeter.append(
32
+ GidsRequirementsMeterLabelDom({
33
+ label: requirement.requirementText,
34
+ status: 'success',
35
+ }),
36
+ );
37
+ } else {
38
+ requirementsMeter.append(
39
+ GidsRequirementsMeterLabelDom({
40
+ label: requirement.requirementText,
41
+ status: 'error',
42
+ }),
43
+ );
44
+ }
45
+ };
46
+
47
+ requirements.map((requirement) => {
48
+ if (requirement?.requirementText && requirement?.requirementRule) {
49
+ const isSatisfied = checkRequirementRuleSatisfied({
50
+ rule: requirement.requirementRule,
51
+ textMinLength,
52
+ text,
53
+ });
54
+
55
+ if (requirement.requirementRule == 'include-min-length') {
56
+ if (
57
+ minLengthRuleCanBeApplied({
58
+ requirementRule: requirement.requirementRule,
59
+ textMinLength,
60
+ })
61
+ ) {
62
+ renderRequirements(isSatisfied, requirement);
63
+ }
64
+ } else {
65
+ renderRequirements(isSatisfied, requirement);
66
+ }
67
+ }
68
+ });
69
+
70
+ return requirementsMeter;
71
+ };
@@ -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
+ };
@@ -1,12 +1,12 @@
1
1
  import {
2
- GidsSectionNoticeCommonUtils,
3
- type GidsSectionNoticeCommonProps,
2
+ GidsSectionNoticeCommonUtils,
3
+ type GidsSectionNoticeCommonProps,
4
4
  } from '@ganpatiinfo/gids-core-shared';
5
5
  import { GidsSectionNoticeWebUtils } from '@ganpatiinfo/gids-web-shared';
6
6
  import {
7
- appendAsChildren,
8
- type DomChildren,
9
- type DomNodeOrString,
7
+ appendAsChildren,
8
+ type DomChildren,
9
+ type DomNodeOrString,
10
10
  } from '../../utils/domUtils.js';
11
11
  import { type IconName } from '@ganpatiinfo/gids-web-theme-interface';
12
12
  import { GidsIconDom } from '../GidsIcon/GidsIcon.js';
@@ -17,89 +17,89 @@ const { getGidsSectionNoticeClassNames } = GidsSectionNoticeWebUtils;
17
17
  const { getSectionNoticeIconName } = GidsSectionNoticeCommonUtils;
18
18
 
19
19
  export interface GidsSectionNoticeDomProps
20
- extends GidsSectionNoticeCommonProps<DomNodeOrString, DomChildren> {
21
- onClickDismiss?: (event: MouseEvent) => void;
20
+ extends GidsSectionNoticeCommonProps<DomNodeOrString, DomChildren> {
21
+ onClickDismiss?: (event: MouseEvent) => void;
22
22
  }
23
23
 
24
24
  export const GidsSectionNoticeDom = ({
25
- appearance = 'information',
26
- title,
27
- supportingText,
28
- children,
29
- dismissible = true,
30
- onClickDismiss,
25
+ appearance = 'information',
26
+ title,
27
+ supportingText,
28
+ children,
29
+ dismissible = true,
30
+ onClickDismiss,
31
31
  }: GidsSectionNoticeDomProps): HTMLDivElement => {
32
- const sectionNotice = document.createElement('div');
33
- sectionNotice.className = getGidsSectionNoticeClassNames({ appearance });
32
+ const sectionNotice = document.createElement('div');
33
+ sectionNotice.className = getGidsSectionNoticeClassNames({ appearance });
34
34
 
35
- const innerContainer = document.createElement('div');
36
- innerContainer.className = 'gids-section-notice__inner-container';
35
+ const innerContainer = document.createElement('div');
36
+ innerContainer.className = 'gids-section-notice__inner-container';
37
37
 
38
- const leadingIconContainer = document.createElement('div');
39
- leadingIconContainer.className =
40
- 'gids-section-notice__leading-icon-container';
38
+ const leadingIconContainer = document.createElement('div');
39
+ leadingIconContainer.className =
40
+ 'gids-section-notice__leading-icon-container';
41
41
 
42
- const leadingIconName = getSectionNoticeIconName({ appearance }) as IconName;
42
+ const leadingIconName = getSectionNoticeIconName({ appearance }) as IconName;
43
43
 
44
- const leadingIcon = GidsIconDom({
45
- size: 'md',
46
- appearance: 'filled',
47
- name: leadingIconName,
48
- alt: '',
49
- className: `gids-section-notice__${appearance}-icon`,
50
- });
51
- leadingIconContainer.appendChild(leadingIcon);
52
- innerContainer.appendChild(leadingIconContainer);
44
+ const leadingIcon = GidsIconDom({
45
+ size: 'md',
46
+ appearance: 'filled',
47
+ name: leadingIconName,
48
+ alt: '',
49
+ className: `gids-section-notice__${appearance}-icon`,
50
+ });
51
+ leadingIconContainer.appendChild(leadingIcon);
52
+ innerContainer.appendChild(leadingIconContainer);
53
53
 
54
- const contentContainer = document.createElement('div');
55
- contentContainer.className = 'gids-section-notice__content-container';
54
+ const contentContainer = document.createElement('div');
55
+ contentContainer.className = 'gids-section-notice__content-container';
56
56
 
57
- const titleElement = document.createElement('div');
58
- titleElement.className = 'gids-section-notice__title';
59
- appendAsChildren(titleElement, title);
60
- contentContainer.appendChild(titleElement);
57
+ const titleElement = document.createElement('div');
58
+ titleElement.className = 'gids-section-notice__title';
59
+ appendAsChildren(titleElement, title);
60
+ contentContainer.appendChild(titleElement);
61
61
 
62
- if (supportingText) {
63
- const supportingTextElement = document.createElement('div');
64
- supportingTextElement.className = 'gids-section-notice__supporting-text';
65
- appendAsChildren(supportingTextElement, supportingText);
66
- contentContainer.appendChild(supportingTextElement);
67
- }
62
+ if (supportingText) {
63
+ const supportingTextElement = document.createElement('div');
64
+ supportingTextElement.className = 'gids-section-notice__supporting-text';
65
+ appendAsChildren(supportingTextElement, supportingText);
66
+ contentContainer.appendChild(supportingTextElement);
67
+ }
68
68
 
69
- if (children) {
70
- contentContainer.appendChild(
71
- GidsButtonGroupDom({
72
- layout: 'wrap',
73
- children: children,
74
- }),
75
- );
76
- }
69
+ if (children) {
70
+ contentContainer.appendChild(
71
+ GidsButtonGroupDom({
72
+ layout: 'wrap',
73
+ children: children,
74
+ }),
75
+ );
76
+ }
77
77
 
78
- innerContainer.appendChild(contentContainer);
78
+ innerContainer.appendChild(contentContainer);
79
79
 
80
- if (dismissible && onClickDismiss) {
81
- const leadingIcon = GidsIconDom({
82
- size: 'sm',
83
- appearance: 'filled',
84
- name: 'cross',
85
- alt: '',
86
- });
87
- const crossButton = GidsButtonDom({
88
- as: 'button',
89
- type: 'button',
90
- appearance: 'subtle',
91
- size: 'sm',
92
- width: 'intrinsic',
93
- leadingIcon: leadingIcon,
94
- });
95
- crossButton.addEventListener('click', onClickDismiss);
96
- const crossBtnContainer = document.createElement('div');
97
- crossBtnContainer.className = 'gids-section-notice__cross-button-container';
98
- crossBtnContainer.appendChild(crossButton);
99
- innerContainer.appendChild(crossBtnContainer);
100
- }
80
+ if (dismissible && onClickDismiss) {
81
+ const leadingIcon = GidsIconDom({
82
+ size: 'sm',
83
+ appearance: 'filled',
84
+ name: 'cross',
85
+ alt: '',
86
+ });
87
+ const crossButton = GidsButtonDom({
88
+ as: 'button',
89
+ type: 'button',
90
+ appearance: 'subtle',
91
+ size: 'sm',
92
+ width: 'intrinsic',
93
+ leadingIcon: leadingIcon,
94
+ });
95
+ crossButton.addEventListener('click', onClickDismiss);
96
+ const crossBtnContainer = document.createElement('div');
97
+ crossBtnContainer.className = 'gids-section-notice__cross-button-container';
98
+ crossBtnContainer.appendChild(crossButton);
99
+ innerContainer.appendChild(crossBtnContainer);
100
+ }
101
101
 
102
- sectionNotice.appendChild(innerContainer);
102
+ sectionNotice.appendChild(innerContainer);
103
103
 
104
- return sectionNotice;
104
+ return sectionNotice;
105
105
  };
@@ -0,0 +1,75 @@
1
+ import {
2
+ GidsSegmentedTabItemPressedReturnedProps,
3
+ type GidsSegmentedControlCommonProps,
4
+ } from '@ganpatiinfo/gids-core-shared';
5
+ import {
6
+ type ClassValue,
7
+ GidsSegmentedControlWebUtils,
8
+ } from '@ganpatiinfo/gids-web-shared';
9
+ import { type DomNodeOrString } from '../../utils/domUtils.js';
10
+ import { GidsSegmentedTabItemDom } from '../GidsSegmentedTabItem/GidsSegmentedTabItem.js';
11
+
12
+ const { getGidsSegmentedControlClassNames } = GidsSegmentedControlWebUtils;
13
+
14
+ export interface GidsSegmentedControlDomProps extends GidsSegmentedControlCommonProps<
15
+ DomNodeOrString,
16
+ string
17
+ > {
18
+ onPress?: (props: GidsSegmentedTabItemPressedReturnedProps) => void;
19
+ className?: ClassValue;
20
+ }
21
+
22
+ export const GidsSegmentedControlDom = ({
23
+ width = 'intrinsic',
24
+ tabItems,
25
+ onPress,
26
+ className,
27
+ }: GidsSegmentedControlDomProps): HTMLDivElement => {
28
+ const segmentedControl = document.createElement('div');
29
+ segmentedControl.className = getGidsSegmentedControlClassNames(
30
+ { width },
31
+ className,
32
+ );
33
+
34
+ if (tabItems && tabItems.length > 0) {
35
+ // This function renders (or re-renders) the tabs
36
+ const renderTabs = (selectedIndex?: number) => {
37
+ // Clear existing tabs
38
+ segmentedControl.innerHTML = '';
39
+
40
+ if (tabItems && tabItems.length > 0) {
41
+ tabItems.forEach((tabItem, index) => {
42
+ // Determine if this tab is selected
43
+ // Priority: 1. The newly clicked index, 2. The initial tabItem.selected state
44
+
45
+ let isSelected = false;
46
+ if (selectedIndex !== undefined && selectedIndex !== null) {
47
+ isSelected = index === selectedIndex;
48
+ } else {
49
+ isSelected = index === 0 ? true : false;
50
+ }
51
+
52
+ const tabElement = GidsSegmentedTabItemDom({
53
+ ...tabItem,
54
+ index,
55
+ selected: isSelected,
56
+ width: width,
57
+ onPress: (returnedProps) => {
58
+ // Re-render all tabs with the new selection
59
+ renderTabs(returnedProps.selectedIndex);
60
+ // Notify external listeners
61
+ if (onPress) onPress(returnedProps);
62
+ },
63
+ });
64
+
65
+ segmentedControl.appendChild(tabElement);
66
+ });
67
+ }
68
+ };
69
+
70
+ // Initial render
71
+ renderTabs();
72
+ }
73
+
74
+ return segmentedControl;
75
+ };