@ganpatiinfo/gids-web-dom-reference 3.0.0 → 3.1.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 +13 -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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- 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/index.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ganpatiinfo/gids-web-dom-reference
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- - Segmented Control and Segmented Tab Item components are ready
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @ganpatiinfo/gids-web-theme-interface@3.1.0
|
|
13
|
+
- @ganpatiinfo/gids-core-shared@3.1.0
|
|
14
|
+
- @ganpatiinfo/gids-web-shared@3.1.0
|
|
15
|
+
|
|
3
16
|
## 3.0.0
|
|
4
17
|
|
|
5
18
|
### Major Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GidsSectionNotice.d.ts","sourceRoot":"","sources":["../../../src/components/GidsSectionNotice/GidsSectionNotice.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GidsSectionNotice.d.ts","sourceRoot":"","sources":["../../../src/components/GidsSectionNotice/GidsSectionNotice.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AASjC,MAAM,WAAW,yBACf,SAAQ,4BAA4B,CAAC,eAAe,EAAE,WAAW,CAAC;IAClE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,oBAAoB,GAAI,+EAOlC,yBAAyB,KAAG,cA0E9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GidsSectionNotice.js","sourceRoot":"","sources":["../../../src/components/GidsSectionNotice/GidsSectionNotice.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GidsSectionNotice.js","sourceRoot":"","sources":["../../../src/components/GidsSectionNotice/GidsSectionNotice.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,GAE7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACL,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC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CAAC,WAAW,CAAC,CAAC;QAC3C,cAAc,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,aAAa,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAE1C,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GidsSegmentedTabItemPressedReturnedProps, type GidsSegmentedControlCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { type ClassValue } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { type DomNodeOrString } from '../../utils/domUtils.js';
|
|
4
|
+
export interface GidsSegmentedControlDomProps extends GidsSegmentedControlCommonProps<DomNodeOrString, string> {
|
|
5
|
+
onPress?: (props: GidsSegmentedTabItemPressedReturnedProps) => void;
|
|
6
|
+
className?: ClassValue;
|
|
7
|
+
}
|
|
8
|
+
export declare const GidsSegmentedControlDom: ({ width, tabItems, onPress, className, }: GidsSegmentedControlDomProps) => HTMLDivElement;
|
|
9
|
+
//# sourceMappingURL=GidsSegmentedControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/GidsSegmentedControl/GidsSegmentedControl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wCAAwC,EACxC,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,UAAU,EAEhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK/D,MAAM,WAAW,4BAA6B,SAAQ,+BAA+B,CACnF,eAAe,EACf,MAAM,CACP;IACC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,wCAAwC,KAAK,IAAI,CAAC;IACpE,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,GAAI,0CAKrC,4BAA4B,KAAG,cAgDjC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GidsSegmentedControlWebUtils, } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import { GidsSegmentedTabItemDom } from '../GidsSegmentedTabItem/GidsSegmentedTabItem.js';
|
|
3
|
+
const { getGidsSegmentedControlClassNames } = GidsSegmentedControlWebUtils;
|
|
4
|
+
export const GidsSegmentedControlDom = ({ width = 'intrinsic', tabItems, onPress, className, }) => {
|
|
5
|
+
const segmentedControl = document.createElement('div');
|
|
6
|
+
segmentedControl.className = getGidsSegmentedControlClassNames({ width }, className);
|
|
7
|
+
if (tabItems && tabItems.length > 0) {
|
|
8
|
+
// This function renders (or re-renders) the tabs
|
|
9
|
+
const renderTabs = (selectedIndex) => {
|
|
10
|
+
// Clear existing tabs
|
|
11
|
+
segmentedControl.innerHTML = '';
|
|
12
|
+
if (tabItems && tabItems.length > 0) {
|
|
13
|
+
tabItems.forEach((tabItem, index) => {
|
|
14
|
+
// Determine if this tab is selected
|
|
15
|
+
// Priority: 1. The newly clicked index, 2. The initial tabItem.selected state
|
|
16
|
+
let isSelected = false;
|
|
17
|
+
if (selectedIndex !== undefined && selectedIndex !== null) {
|
|
18
|
+
isSelected = index === selectedIndex;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
isSelected = index === 0 ? true : false;
|
|
22
|
+
}
|
|
23
|
+
const tabElement = GidsSegmentedTabItemDom({
|
|
24
|
+
...tabItem,
|
|
25
|
+
index,
|
|
26
|
+
selected: isSelected,
|
|
27
|
+
width: width,
|
|
28
|
+
onPress: (returnedProps) => {
|
|
29
|
+
// Re-render all tabs with the new selection
|
|
30
|
+
renderTabs(returnedProps.selectedIndex);
|
|
31
|
+
// Notify external listeners
|
|
32
|
+
if (onPress)
|
|
33
|
+
onPress(returnedProps);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
segmentedControl.appendChild(tabElement);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
// Initial render
|
|
41
|
+
renderTabs();
|
|
42
|
+
}
|
|
43
|
+
return segmentedControl;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=GidsSegmentedControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSegmentedControl.js","sourceRoot":"","sources":["../../../src/components/GidsSegmentedControl/GidsSegmentedControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAE1F,MAAM,EAAE,iCAAiC,EAAE,GAAG,4BAA4B,CAAC;AAU3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,KAAK,GAAG,WAAW,EACnB,QAAQ,EACR,OAAO,EACP,SAAS,GACoB,EAAkB,EAAE;IACjD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,gBAAgB,CAAC,SAAS,GAAG,iCAAiC,CAC5D,EAAE,KAAK,EAAE,EACT,SAAS,CACV,CAAC;IAEF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,iDAAiD;QACjD,MAAM,UAAU,GAAG,CAAC,aAAsB,EAAE,EAAE;YAC5C,sBAAsB;YACtB,gBAAgB,CAAC,SAAS,GAAG,EAAE,CAAC;YAEhC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;oBAClC,oCAAoC;oBACpC,8EAA8E;oBAE9E,IAAI,UAAU,GAAG,KAAK,CAAC;oBACvB,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;wBAC1D,UAAU,GAAG,KAAK,KAAK,aAAa,CAAC;oBACvC,CAAC;yBAAM,CAAC;wBACN,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;oBAC1C,CAAC;oBAED,MAAM,UAAU,GAAG,uBAAuB,CAAC;wBACzC,GAAG,OAAO;wBACV,KAAK;wBACL,QAAQ,EAAE,UAAU;wBACpB,KAAK,EAAE,KAAK;wBACZ,OAAO,EAAE,CAAC,aAAa,EAAE,EAAE;4BACzB,4CAA4C;4BAC5C,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;4BACxC,4BAA4B;4BAC5B,IAAI,OAAO;gCAAE,OAAO,CAAC,aAAa,CAAC,CAAC;wBACtC,CAAC;qBACF,CAAC,CAAC;oBAEH,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;gBAC3C,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,iBAAiB;QACjB,UAAU,EAAE,CAAC;IACf,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type GidsSegmentedTabItemPressedReturnedProps, type GidsSegmentedTabItemCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { type ClassValue } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { type DomNodeOrString } from '../../utils/domUtils.js';
|
|
4
|
+
export interface GidsSegmentedTabItemDomProps extends GidsSegmentedTabItemCommonProps<DomNodeOrString, string> {
|
|
5
|
+
onPress?: (props: GidsSegmentedTabItemPressedReturnedProps) => void;
|
|
6
|
+
className?: ClassValue;
|
|
7
|
+
}
|
|
8
|
+
export declare const GidsSegmentedTabItemDom: ({ index, label, selected, badge, badgeAccessibleText, badgeAppearance, onPress, className, width, }: GidsSegmentedTabItemDomProps) => HTMLButtonElement;
|
|
9
|
+
//# sourceMappingURL=GidsSegmentedTabItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSegmentedTabItem.d.ts","sourceRoot":"","sources":["../../../src/components/GidsSegmentedTabItem/GidsSegmentedTabItem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wCAAwC,EAC7C,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,UAAU,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK/D,MAAM,WAAW,4BAA6B,SAAQ,+BAA+B,CACnF,eAAe,EACf,MAAM,CACP;IACC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,wCAAwC,KAAK,IAAI,CAAC;IACpE,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,GAAI,qGAUrC,4BAA4B,KAAG,iBA0CjC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GidsSegmentedTabItemWebUtils, } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { GidsBadgeDom } from '../GidsBadge/GidsBadge.js';
|
|
4
|
+
const { getGidsSegmentedTabItemClassNames } = GidsSegmentedTabItemWebUtils;
|
|
5
|
+
export const GidsSegmentedTabItemDom = ({ index, label, selected = false, badge = false, badgeAccessibleText, badgeAppearance = 'information', onPress, className, width = 'intrinsic', }) => {
|
|
6
|
+
const segmentedTabItem = document.createElement('button');
|
|
7
|
+
segmentedTabItem.className = getGidsSegmentedTabItemClassNames({ selected, width }, className);
|
|
8
|
+
segmentedTabItem.setAttribute('data-gids-segmented-item', 'true');
|
|
9
|
+
segmentedTabItem.setAttribute('aria-selected', selected.toString());
|
|
10
|
+
segmentedTabItem.addEventListener('click', () => {
|
|
11
|
+
if (onPress) {
|
|
12
|
+
onPress({
|
|
13
|
+
selectedIndex: index,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
if (label && label !== '') {
|
|
18
|
+
if (typeof label === 'string') {
|
|
19
|
+
const labelElement = document.createElement('label');
|
|
20
|
+
labelElement.className = clsx('gids-segmented-tab-item__label', {
|
|
21
|
+
'gids-segmented-tab-item__selected-label': selected,
|
|
22
|
+
});
|
|
23
|
+
labelElement.textContent = label;
|
|
24
|
+
segmentedTabItem.appendChild(labelElement);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
segmentedTabItem.appendChild(label);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (badge) {
|
|
31
|
+
segmentedTabItem.appendChild(GidsBadgeDom({
|
|
32
|
+
accessibleText: badgeAccessibleText,
|
|
33
|
+
appearance: badgeAppearance,
|
|
34
|
+
outline: false,
|
|
35
|
+
type: 'dot',
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
return segmentedTabItem;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=GidsSegmentedTabItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSegmentedTabItem.js","sourceRoot":"","sources":["../../../src/components/GidsSegmentedTabItem/GidsSegmentedTabItem.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,EAAE,iCAAiC,EAAE,GAAG,4BAA4B,CAAC;AAU3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,KAAK,EACL,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,KAAK,EACb,mBAAmB,EACnB,eAAe,GAAG,aAAa,EAC/B,OAAO,EACP,SAAS,EACT,KAAK,GAAG,WAAW,GACU,EAAqB,EAAE;IACpD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAA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aseCard.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';
|
|
41
43
|
/**
|
|
42
44
|
* Utilities
|
|
43
45
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,uDAAuD,CAAC;AACtE,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wDAAwD,CAAC;AACvE,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAClE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qDAAqD,CAAC;AACpE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iDAAiD,CAAC;AAChE,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qEAAqE,CAAC;AACpF,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iDAAiD,CAAC;AAChE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,qDAAqD,CAAC;AACpE,cAAc,uDAAuD,CAAC;AACtE,cAAc,iCAAiC,CAAC;AAChD,cAA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E,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,2DAA2D,CAAC;AAE1E;;GAEG;AACH,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,8 @@ 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';
|
|
41
43
|
/**
|
|
42
44
|
* Utilities
|
|
43
45
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,uDAAuD,CAAC;AACtE,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wDAAwD,CAAC;AACvE,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAClE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qDAAqD,CAAC;AACpE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iDAAiD,CAAC;AAChE,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qEAAqE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C,CAAC;AAChD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uDAAuD,CAAC;AACtE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAClD,cAAc,wDAAwD,CAAC;AACvE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,2DAA2D,CAAC;AAE1E;;GAEG;AACH,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ganpatiinfo/gids-web-dom-reference",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "DOM for components reference implementations",
|
|
6
6
|
"homepage": "https://ganpatiinfosystem.vercel.app/",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"directory": "packages/private/web-dom-reference"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ganpatiinfo/gids-core-shared": "3.
|
|
28
|
-
"@ganpatiinfo/gids-web-shared": "3.
|
|
27
|
+
"@ganpatiinfo/gids-core-shared": "3.1.0",
|
|
28
|
+
"@ganpatiinfo/gids-web-shared": "3.1.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@ganpatiinfo/gids-web-theme-interface": "3.
|
|
31
|
+
"@ganpatiinfo/gids-web-theme-interface": "3.1.0",
|
|
32
32
|
"@jest/globals": "^30.2.0",
|
|
33
33
|
"@types/jasmine": "^5.1.15",
|
|
34
34
|
"expect": "^30.2.0"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
21
|
-
|
|
20
|
+
extends GidsSectionNoticeCommonProps<DomNodeOrString, DomChildren> {
|
|
21
|
+
onClickDismiss?: (event: MouseEvent) => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const GidsSectionNoticeDom = ({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
appearance = 'information',
|
|
26
|
+
title,
|
|
27
|
+
supportingText,
|
|
28
|
+
children,
|
|
29
|
+
dismissible = true,
|
|
30
|
+
onClickDismiss,
|
|
31
31
|
}: GidsSectionNoticeDomProps): HTMLDivElement => {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const sectionNotice = document.createElement('div');
|
|
33
|
+
sectionNotice.className = getGidsSectionNoticeClassNames({ appearance });
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const innerContainer = document.createElement('div');
|
|
36
|
+
innerContainer.className = 'gids-section-notice__inner-container';
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const leadingIconContainer = document.createElement('div');
|
|
39
|
+
leadingIconContainer.className =
|
|
40
|
+
'gids-section-notice__leading-icon-container';
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const leadingIconName = getSectionNoticeIconName({ appearance }) as IconName;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
54
|
+
const contentContainer = document.createElement('div');
|
|
55
|
+
contentContainer.className = 'gids-section-notice__content-container';
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const titleElement = document.createElement('div');
|
|
58
|
+
titleElement.className = 'gids-section-notice__title';
|
|
59
|
+
appendAsChildren(titleElement, title);
|
|
60
|
+
contentContainer.appendChild(titleElement);
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
if (children) {
|
|
70
|
+
contentContainer.appendChild(
|
|
71
|
+
GidsButtonGroupDom({
|
|
72
|
+
layout: 'wrap',
|
|
73
|
+
children: children,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
innerContainer.appendChild(contentContainer);
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
102
|
+
sectionNotice.appendChild(innerContainer);
|
|
103
103
|
|
|
104
|
-
|
|
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
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GidsSegmentedTabItemPressedReturnedProps,
|
|
3
|
+
type GidsSegmentedTabItemCommonProps,
|
|
4
|
+
} from '@ganpatiinfo/gids-core-shared';
|
|
5
|
+
import {
|
|
6
|
+
type ClassValue,
|
|
7
|
+
GidsSegmentedTabItemWebUtils,
|
|
8
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { type DomNodeOrString } from '../../utils/domUtils.js';
|
|
11
|
+
import { GidsBadgeDom } from '../GidsBadge/GidsBadge.js';
|
|
12
|
+
|
|
13
|
+
const { getGidsSegmentedTabItemClassNames } = GidsSegmentedTabItemWebUtils;
|
|
14
|
+
|
|
15
|
+
export interface GidsSegmentedTabItemDomProps extends GidsSegmentedTabItemCommonProps<
|
|
16
|
+
DomNodeOrString,
|
|
17
|
+
string
|
|
18
|
+
> {
|
|
19
|
+
onPress?: (props: GidsSegmentedTabItemPressedReturnedProps) => void;
|
|
20
|
+
className?: ClassValue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const GidsSegmentedTabItemDom = ({
|
|
24
|
+
index,
|
|
25
|
+
label,
|
|
26
|
+
selected = false,
|
|
27
|
+
badge = false,
|
|
28
|
+
badgeAccessibleText,
|
|
29
|
+
badgeAppearance = 'information',
|
|
30
|
+
onPress,
|
|
31
|
+
className,
|
|
32
|
+
width = 'intrinsic',
|
|
33
|
+
}: GidsSegmentedTabItemDomProps): HTMLButtonElement => {
|
|
34
|
+
const segmentedTabItem = document.createElement('button');
|
|
35
|
+
segmentedTabItem.className = getGidsSegmentedTabItemClassNames(
|
|
36
|
+
{ selected, width },
|
|
37
|
+
className,
|
|
38
|
+
);
|
|
39
|
+
segmentedTabItem.setAttribute('data-gids-segmented-item', 'true');
|
|
40
|
+
segmentedTabItem.setAttribute('aria-selected', selected.toString());
|
|
41
|
+
|
|
42
|
+
segmentedTabItem.addEventListener('click', () => {
|
|
43
|
+
if (onPress) {
|
|
44
|
+
onPress({
|
|
45
|
+
selectedIndex: index,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (label && label !== '') {
|
|
51
|
+
if (typeof label === 'string') {
|
|
52
|
+
const labelElement = document.createElement('label');
|
|
53
|
+
labelElement.className = clsx('gids-segmented-tab-item__label', {
|
|
54
|
+
'gids-segmented-tab-item__selected-label': selected,
|
|
55
|
+
});
|
|
56
|
+
labelElement.textContent = label;
|
|
57
|
+
segmentedTabItem.appendChild(labelElement);
|
|
58
|
+
} else {
|
|
59
|
+
segmentedTabItem.appendChild(label);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (badge) {
|
|
64
|
+
segmentedTabItem.appendChild(
|
|
65
|
+
GidsBadgeDom({
|
|
66
|
+
accessibleText: badgeAccessibleText,
|
|
67
|
+
appearance: badgeAppearance,
|
|
68
|
+
outline: false,
|
|
69
|
+
type: 'dot',
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return segmentedTabItem;
|
|
75
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -38,6 +38,8 @@ 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';
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* Utilities
|