@ganpatiinfo/gids-web-dom-reference 0.0.7 → 2.0.1
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 +15 -0
- package/dist/components/GidsButton/GidsButton.d.ts +9 -0
- package/dist/components/GidsButton/GidsButton.d.ts.map +1 -0
- package/dist/components/GidsButton/GidsButton.js +39 -0
- package/dist/components/GidsButton/GidsButton.js.map +1 -0
- package/dist/components/GidsIcon/GidsIcon.d.ts +7 -0
- package/dist/components/GidsIcon/GidsIcon.d.ts.map +1 -0
- package/dist/components/GidsIcon/GidsIcon.js +27 -0
- package/dist/components/GidsIcon/GidsIcon.js.map +1 -0
- package/dist/components/GidsSpinner/GidsSpinner.d.ts +7 -0
- package/dist/components/GidsSpinner/GidsSpinner.d.ts.map +1 -0
- package/dist/components/GidsSpinner/GidsSpinner.js +33 -0
- package/dist/components/GidsSpinner/GidsSpinner.js.map +1 -0
- package/dist/components/GidsToggleButton/GidsToggleButton.d.ts +13 -0
- package/dist/components/GidsToggleButton/GidsToggleButton.d.ts.map +1 -0
- package/dist/components/GidsToggleButton/GidsToggleButton.js +26 -0
- package/dist/components/GidsToggleButton/GidsToggleButton.js.map +1 -0
- package/dist/components/_GidsSpinnerControl/GidsSpinnerControl.d.ts +7 -0
- package/dist/components/_GidsSpinnerControl/GidsSpinnerControl.d.ts.map +1 -0
- package/dist/components/_GidsSpinnerControl/GidsSpinnerControl.js +31 -0
- package/dist/components/_GidsSpinnerControl/GidsSpinnerControl.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/components/GidsButton/GidsButton.ts +89 -0
- package/src/components/GidsIcon/GidsIcon.ts +54 -0
- package/src/components/GidsSpinner/GidsSpinner.ts +60 -0
- package/src/components/GidsToggleButton/GidsToggleButton.ts +58 -0
- package/src/components/_GidsSpinnerControl/GidsSpinnerControl.ts +60 -0
- package/src/index.ts +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @ganpatiinfo/gids-web-dom-reference
|
|
2
|
+
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4ffaa50: 1st automated publishing of package
|
|
8
|
+
- Updated dependencies [4ffaa50]
|
|
9
|
+
- Updated dependencies [4ffaa50]
|
|
10
|
+
- Updated dependencies [4ffaa50]
|
|
11
|
+
- Updated dependencies [4ffaa50]
|
|
12
|
+
- Updated dependencies [4ffaa50]
|
|
13
|
+
- @ganpatiinfo/gids-core-shared@2.0.1
|
|
14
|
+
- @ganpatiinfo/gids-web-shared@2.0.1
|
|
15
|
+
- @ganpatiinfo/gids-web-theme-interface@2.0.1
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PermittedGidsButtonElements, type GidsButtonWebProps } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import { type DomChildren } from '../../utils/domUtils';
|
|
3
|
+
export interface GidsButtonDomProps<ButtonElement extends PermittedGidsButtonElements> extends GidsButtonWebProps<DomChildren, DomChildren, ButtonElement> {
|
|
4
|
+
type?: 'button' | 'submit' | 'reset';
|
|
5
|
+
href?: string;
|
|
6
|
+
onClick?: (this: HTMLButtonElement, event: Event) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const GidsButtonDom: <ButtonElement extends PermittedGidsButtonElements = "button">({ as, appearance, size, disabled, destructive, loading, width, children, leadingIcon, trailingIcon, type, href, onClick, }: GidsButtonDomProps<ButtonElement>) => ButtonElement extends "button" ? HTMLButtonElement : HTMLAnchorElement;
|
|
9
|
+
//# sourceMappingURL=GidsButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsButton.d.ts","sourceRoot":"","sources":["../../../src/components/GidsButton/GidsButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,2BAA2B,EAC3B,KAAK,kBAAkB,EACvB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI1E,MAAM,WAAW,kBAAkB,CAClC,aAAa,SAAS,2BAA2B,CAChD,SAAQ,kBAAkB,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC;IACpE,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,aAAa,GACzB,aAAa,SAAS,2BAA2B,GAAG,QAAQ,EAC3D,4HAcC,kBAAkB,CAAC,aAAa,CAAC,KAAG,aAAa,SAAS,QAAQ,GAClE,iBAAiB,GACjB,iBAmDF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GidsButtonWebUtils, nonEmpty, } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import { GidsSpinnerControlDom } from '../_GidsSpinnerControl/GidsSpinnerControl';
|
|
3
|
+
import { appendAsChildren } from '../../utils/domUtils';
|
|
4
|
+
const { getGidsButtonClassNames } = GidsButtonWebUtils;
|
|
5
|
+
export const GidsButtonDom = ({ as, appearance, size, disabled, destructive, loading, width, children, leadingIcon, trailingIcon, type, href, onClick, }) => {
|
|
6
|
+
const button = document.createElement(as || 'button');
|
|
7
|
+
button.className = getGidsButtonClassNames({ appearance, size, width, destructive, loading }, !children && nonEmpty(leadingIcon) && !nonEmpty(trailingIcon));
|
|
8
|
+
if (as !== 'a') {
|
|
9
|
+
button.setAttribute('type', type ?? 'button');
|
|
10
|
+
if (disabled) {
|
|
11
|
+
button.setAttribute('disabled', '');
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
button.removeAttribute('disabled');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (as === 'a') {
|
|
18
|
+
if (href) {
|
|
19
|
+
button.setAttribute('href', href);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const content = document.createElement('span');
|
|
23
|
+
content.classList.add('gids-button__content');
|
|
24
|
+
appendAsChildren(content, leadingIcon);
|
|
25
|
+
appendAsChildren(content, children);
|
|
26
|
+
button.appendChild(content);
|
|
27
|
+
appendAsChildren(button, trailingIcon);
|
|
28
|
+
if (loading) {
|
|
29
|
+
button.appendChild(GidsSpinnerControlDom({
|
|
30
|
+
size: size === 'lg' || size === undefined ? 'md' : size,
|
|
31
|
+
indeterminate: true
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
if (onClick && !loading) {
|
|
35
|
+
button.addEventListener('click', onClick);
|
|
36
|
+
}
|
|
37
|
+
return button;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=GidsButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsButton.js","sourceRoot":"","sources":["../../../src/components/GidsButton/GidsButton.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,QAAQ,GAGR,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,sBAAsB,CAAC;AAE1E,MAAM,EAAE,uBAAuB,EAAE,GAAG,kBAAkB,CAAC;AAUvD,MAAM,CAAC,MAAM,aAAa,GAAG,CAE3B,EACD,EAAE,EACF,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,OAAO,GAC4B,EAEf,EAAE;IACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CACpC,EAAE,IAAI,QAAQ,CAC4D,CAAC;IAE5E,MAA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C;IAEE,IAAI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAEJ,OAAO,MAAM,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IconName, type IconAppearance } from '@ganpatiinfo/gids-web-theme-interface';
|
|
2
|
+
import { type GidsIconWebProps } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
export interface GidsIconDomProps extends GidsIconWebProps<IconName, IconAppearance> {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const GidsIconDom: ({ size, name, appearance, alt, titleId, className, }: GidsIconDomProps) => SVGSVGElement;
|
|
7
|
+
//# sourceMappingURL=GidsIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsIcon.d.ts","sourceRoot":"","sources":["../../../src/components/GidsIcon/GidsIcon.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,cAAc,EAEnB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,8BAA8B,CAAC;AAItC,MAAM,WAAW,gBAChB,SAAQ,gBAAgB,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,WAAW,GAAI,sDAOzB,gBAAgB,KAAG,aA2BrB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getIconGlyphUrl, } from '@ganpatiinfo/gids-web-theme-interface';
|
|
2
|
+
import { generateId, getGidsAssetFilePath, GidsIconWebUtils, } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
const { getGidsIconClassNames } = GidsIconWebUtils;
|
|
4
|
+
export const GidsIconDom = ({ size, name, appearance, alt, titleId, className, }) => {
|
|
5
|
+
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
6
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
|
7
|
+
icon.setAttribute('class', getGidsIconClassNames({ size }, className));
|
|
8
|
+
icon.setAttribute('width', '16');
|
|
9
|
+
icon.setAttribute('height', '16');
|
|
10
|
+
icon.setAttribute('role', 'img');
|
|
11
|
+
if (alt === '') {
|
|
12
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const title = document.createElementNS(svgNamespace, 'title');
|
|
16
|
+
title.textContent = alt || name;
|
|
17
|
+
const titleElementId = generateId(titleId);
|
|
18
|
+
title.setAttribute('id', titleElementId);
|
|
19
|
+
icon.insertBefore(title, icon.firstChild);
|
|
20
|
+
icon.setAttribute('aria-labelledby', titleElementId);
|
|
21
|
+
}
|
|
22
|
+
const use = document.createElementNS(svgNamespace, 'use');
|
|
23
|
+
use.setAttribute('href', getIconGlyphUrl(name, appearance, getGidsAssetFilePath));
|
|
24
|
+
icon.appendChild(use);
|
|
25
|
+
return icon;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=GidsIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsIcon.js","sourceRoot":"","sources":["../../../src/components/GidsIcon/GidsIcon.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,eAAe,GACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,UAAU,EACV,oBAAoB,EACpB,gBAAgB,GAEhB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,EAAE,qBAAqB,EAAE,GAAG,gBAAgB,CAAC;AAOnD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC3B,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,SAAS,GACS,EAAiB,EAAE;IACrC,MAAM,YAAY,GAAG,4BAA4B,CAAC;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC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atiinfo/gids-web-shared';
|
|
3
|
+
export interface GidsSpinnerDomProps extends GidsSpinnerCommonProps {
|
|
4
|
+
className?: ClassValue;
|
|
5
|
+
}
|
|
6
|
+
export declare const GidsSpinnerDom: ({ label, supportingText, size, indeterminate, value, max, className, }: GidsSpinnerDomProps) => HTMLSpanElement;
|
|
7
|
+
//# sourceMappingURL=GidsSpinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSpinner.d.ts","sourceRoot":"","sources":["../../../src/components/GidsSpinner/GidsSpinner.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,sBAAsB,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,UAAU,EAEf,MAAM,8BAA8B,CAAC;AAMtC,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IAClE,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,GAAI,wEAQ5B,mBAAmB,KAAG,eAkCxB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GidsSpinnerCommonUtils, } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { GidsSpinnerWebUtils, } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { GidsSpinnerControlDom } from '../_GidsSpinnerControl/GidsSpinnerControl';
|
|
4
|
+
const { getGidsSpinnerClassNames } = GidsSpinnerWebUtils;
|
|
5
|
+
const { getElementVisibility } = GidsSpinnerCommonUtils;
|
|
6
|
+
export const GidsSpinnerDom = ({ label, supportingText, size, indeterminate, value, max, className, }) => {
|
|
7
|
+
const spinner = document.createElement('span');
|
|
8
|
+
const { hasLabel, hasSupportingText } = getElementVisibility({
|
|
9
|
+
label,
|
|
10
|
+
supportingText,
|
|
11
|
+
});
|
|
12
|
+
spinner.className = getGidsSpinnerClassNames({ size }, className);
|
|
13
|
+
spinner.appendChild(GidsSpinnerControlDom({
|
|
14
|
+
size,
|
|
15
|
+
indeterminate,
|
|
16
|
+
value,
|
|
17
|
+
max,
|
|
18
|
+
}));
|
|
19
|
+
if (hasLabel) {
|
|
20
|
+
const spinnerLabel = document.createElement('span');
|
|
21
|
+
spinnerLabel.className = 'gids-spinner__label';
|
|
22
|
+
spinnerLabel.textContent = label || '';
|
|
23
|
+
spinner.appendChild(spinnerLabel);
|
|
24
|
+
}
|
|
25
|
+
if (hasSupportingText) {
|
|
26
|
+
const spinnerSupportingText = document.createElement('span');
|
|
27
|
+
spinnerSupportingText.className = 'gids-spinner__supporting-text';
|
|
28
|
+
spinnerSupportingText.textContent = supportingText || '';
|
|
29
|
+
spinner.appendChild(spinnerSupportingText);
|
|
30
|
+
}
|
|
31
|
+
return spinner;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=GidsSpinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSpinner.js","sourceRoot":"","sources":["../../../src/components/GidsSpinner/GidsSpinner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,sBAAsB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEN,mBAAmB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAElF,MAAM,EAAE,wBAAwB,EAAE,GAAG,mBAAmB,CAAC;AACzD,MAAM,EAAE,oBAAoB,EAAE,GAAG,sBAAsB,CAAC;AAMxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC9B,KAAK,EACL,cAAc,EACd,IAAI,EACJ,aAAa,EACb,KAAK,EACL,GAAG,EACH,SAAS,GACY,EAAmB,EAAE;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,CAAC;QAC5D,KAAK;QACL,cAAc;KACd,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,GAAG,wBAAwB,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;IAElE,OAAO,CAAC,WAAW,CAClB,qBAAqB,CAAC;QACrB,IAAI;QACJ,aAAa;QACb,KAAK;QACL,GAAG;KACH,CAAC,CACF,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACd,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACpD,YAAY,CAAC,SAAS,GAAG,qBAAqB,CAAC;QAC/C,YAAY,CAAC,WAAW,GAAG,KAAK,IAAI,EAAE,CAAC;QACvC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,iBAAiB,EAAE,CAAC;QACvB,MAAM,qBAAqB,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7D,qBAAqB,CAAC,SAAS,GAAG,+BAA+B,CAAC;QAClE,qBAAqB,CAAC,WAAW,GAAG,cAAc,IAAI,EAAE,CAAC;QACzD,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GidsToggleButtonWebProps } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import { type DomChildren } from '../../utils/domUtils';
|
|
3
|
+
export interface GidsToggleButtonDomProps extends GidsToggleButtonWebProps<DomChildren> {
|
|
4
|
+
onClick?: (this: HTMLElement, ev: MouseEvent) => void;
|
|
5
|
+
onSelect?: (this: HTMLElement, ev: CustomEvent<boolean>) => void;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementEventMap {
|
|
9
|
+
select: CustomEvent<boolean>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const GidsToggleButtonDom: ({ appearance, size, width, defaultSelected, disabled, selected, children, onClick, onSelect, }: GidsToggleButtonDomProps) => HTMLElement;
|
|
13
|
+
//# sourceMappingURL=GidsToggleButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsToggleButton.d.ts","sourceRoot":"","sources":["../../../src/components/GidsToggleButton/GidsToggleButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,wBAChB,SAAQ,wBAAwB,CAAC,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,mBAAmB;QAC5B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;KAC7B;CACD;AAED,eAAO,MAAM,mBAAmB,GAAI,gGAUjC,wBAAwB,gBA4B1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { appendAsChildren, toggleAttribute, } from '../../utils/domUtils';
|
|
2
|
+
export const GidsToggleButtonDom = ({ appearance, size, width, defaultSelected, disabled, selected, children, onClick, onSelect, }) => {
|
|
3
|
+
const toggleButton = document.createElement('gids-toggle-button');
|
|
4
|
+
if (appearance !== undefined) {
|
|
5
|
+
toggleButton.setAttribute('appearance', appearance);
|
|
6
|
+
}
|
|
7
|
+
if (size !== undefined) {
|
|
8
|
+
toggleButton.setAttribute('size', size);
|
|
9
|
+
}
|
|
10
|
+
if (width !== undefined) {
|
|
11
|
+
toggleButton.setAttribute('width', width);
|
|
12
|
+
}
|
|
13
|
+
toggleAttribute(toggleButton, 'disabled', !!disabled);
|
|
14
|
+
toggleAttribute(toggleButton, 'default-selected', !!defaultSelected);
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
toggleButton.selected = selected;
|
|
17
|
+
appendAsChildren(toggleButton, children);
|
|
18
|
+
if (onClick) {
|
|
19
|
+
toggleButton.addEventListener('click', onClick);
|
|
20
|
+
}
|
|
21
|
+
if (onSelect) {
|
|
22
|
+
toggleButton.addEventListener('select', onSelect);
|
|
23
|
+
}
|
|
24
|
+
return toggleButton;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=GidsToggleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsToggleButton.js","sourceRoot":"","sources":["../../../src/components/GidsToggleButton/GidsToggleButton.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,eAAe,GAEf,MAAM,sBAAsB,CAAC;AAc9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EACnC,UAAU,EACV,IAAI,EACJ,KAAK,EACL,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,GACkB,EAAE,EAAE;IAC9B,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAClE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,eAAe,CAAC,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,eAAe,CAAC,YAAY,EAAE,kBAAkB,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAErE,mBAAmB;IACnB,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAEjC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAEzC,IAAI,OAAO,EAAE,CAAC;QACb,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACd,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type GidsSpinnerControlCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { type ClassValue } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
export interface GidsSpinnerControlDomProps extends GidsSpinnerControlCommonProps {
|
|
4
|
+
className?: ClassValue;
|
|
5
|
+
}
|
|
6
|
+
export declare const GidsSpinnerControlDom: ({ size, indeterminate, value, max, className, }: GidsSpinnerControlDomProps) => SVGSVGElement;
|
|
7
|
+
//# sourceMappingURL=GidsSpinnerControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GidsSpinnerControl.d.ts","sourceRoot":"","sources":["../../../src/components/_GidsSpinnerControl/GidsSpinnerControl.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,6BAA6B,EAElC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,UAAU,EAEf,MAAM,8BAA8B,CAAC;AAMtC,MAAM,WAAW,0BAChB,SAAQ,6BAA6B;IACrC,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,GAAI,iDAMnC,0BAA0B,KAAG,aAmC/B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GidsSpinnerControlCommonUtils, } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { GidsSpinnerControlWebUtils, } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
const { getGidsSpinnerControlClassNames } = GidsSpinnerControlWebUtils;
|
|
4
|
+
const { calculateStrokeDasharray, thickness, radius, centerPosition, viewBox } = GidsSpinnerControlCommonUtils;
|
|
5
|
+
export const GidsSpinnerControlDom = ({ size, indeterminate, value, max, className, }) => {
|
|
6
|
+
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
7
|
+
const spinnerControlWrapper = document.createElementNS(svgNamespace, 'svg');
|
|
8
|
+
spinnerControlWrapper.setAttribute('class', getGidsSpinnerControlClassNames({ size, indeterminate, value }, className));
|
|
9
|
+
spinnerControlWrapper.setAttribute('viewBox', viewBox);
|
|
10
|
+
const track = document.createElementNS(svgNamespace, 'circle');
|
|
11
|
+
track.classList.add('gids-spinner-control__track');
|
|
12
|
+
track.setAttribute('cx', centerPosition.toString());
|
|
13
|
+
track.setAttribute('cy', centerPosition.toString());
|
|
14
|
+
track.setAttribute('r', radius.toString());
|
|
15
|
+
track.setAttribute('stroke-width', thickness.toString());
|
|
16
|
+
const shape = document.createElementNS(svgNamespace, 'circle');
|
|
17
|
+
shape.classList.add('gids-spinner-control__progress');
|
|
18
|
+
shape.setAttribute('cx', centerPosition.toString());
|
|
19
|
+
shape.setAttribute('cy', centerPosition.toString());
|
|
20
|
+
shape.setAttribute('r', radius.toString());
|
|
21
|
+
shape.setAttribute('stroke-width', thickness.toString());
|
|
22
|
+
if (!indeterminate) {
|
|
23
|
+
const dashArray = calculateStrokeDasharray(value, max ? max : 0);
|
|
24
|
+
shape.style.strokeDasharray = dashArray;
|
|
25
|
+
shape.style.strokeDashoffset = '0';
|
|
26
|
+
}
|
|
27
|
+
spinnerControlWrapper.appendChild(track);
|
|
28
|
+
spinnerControlWrapper.appendChild(shape);
|
|
29
|
+
return spinnerControlWrapper;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=GidsSpinnerControl.js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AK,CAAC,YAAY,CAAC,cAAc,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEzD,MAAM,KAAK,GAAG,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC/D,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IACtD,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3C,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEzD,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjE,KAAK,CAAC,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC;QACxC,KAAK,CAAC,KAAK,CAAC,gBAAgB,GAAG,GAAG,CAAC;IACpC,CAAC;IAED,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzC,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from './components/GidsDivider/GidsDivider';
|
|
5
5
|
export * from './components/GidsDisplayTag/GidsDisplayTag';
|
|
6
|
+
export * from './components/_GidsSpinnerControl/GidsSpinnerControl';
|
|
7
|
+
export * from './components/GidsSpinner/GidsSpinner';
|
|
8
|
+
export * from './components/GidsIcon/GidsIcon';
|
|
9
|
+
export * from './components/GidsButton/GidsButton';
|
|
10
|
+
export * from './components/GidsToggleButton/GidsToggleButton';
|
|
6
11
|
/**
|
|
7
12
|
* Utilities
|
|
8
13
|
*/
|
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,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAE/D;;GAEG;AACH,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from './components/GidsDivider/GidsDivider';
|
|
5
5
|
export * from './components/GidsDisplayTag/GidsDisplayTag';
|
|
6
|
+
export * from './components/_GidsSpinnerControl/GidsSpinnerControl';
|
|
7
|
+
export * from './components/GidsSpinner/GidsSpinner';
|
|
8
|
+
export * from './components/GidsIcon/GidsIcon';
|
|
9
|
+
export * from './components/GidsButton/GidsButton';
|
|
10
|
+
export * from './components/GidsToggleButton/GidsToggleButton';
|
|
6
11
|
/**
|
|
7
12
|
* Utilities
|
|
8
13
|
*/
|
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,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAE/D;;GAEG;AACH,cAAc,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ganpatiinfo/gids-web-dom-reference",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "DOM for components reference implementations",
|
|
6
6
|
"homepage": "https://ganpatiinfosystem.vercel.app/",
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
"directory": "packages/private/web-dom-reference"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ganpatiinfo/gids-core-shared": "
|
|
28
|
-
"@ganpatiinfo/gids-web-shared": "
|
|
27
|
+
"@ganpatiinfo/gids-core-shared": "2.0.1",
|
|
28
|
+
"@ganpatiinfo/gids-web-shared": "2.0.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
+
"@ganpatiinfo/gids-web-theme-interface": "2.0.1",
|
|
31
32
|
"@jest/globals": "29.7.0",
|
|
32
33
|
"@types/jasmine": "5.1.7",
|
|
33
34
|
"expect": "29.7.0"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GidsButtonWebUtils,
|
|
3
|
+
nonEmpty,
|
|
4
|
+
PermittedGidsButtonElements,
|
|
5
|
+
type GidsButtonWebProps,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
import { GidsSpinnerControlDom } from '../_GidsSpinnerControl/GidsSpinnerControl';
|
|
8
|
+
import { appendAsChildren, type DomChildren } from '../../utils/domUtils';
|
|
9
|
+
|
|
10
|
+
const { getGidsButtonClassNames } = GidsButtonWebUtils;
|
|
11
|
+
|
|
12
|
+
export interface GidsButtonDomProps<
|
|
13
|
+
ButtonElement extends PermittedGidsButtonElements,
|
|
14
|
+
> extends GidsButtonWebProps<DomChildren, DomChildren, ButtonElement> {
|
|
15
|
+
type?: 'button' | 'submit' | 'reset';
|
|
16
|
+
href?: string;
|
|
17
|
+
onClick?: (this: HTMLButtonElement, event: Event) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const GidsButtonDom = <
|
|
21
|
+
ButtonElement extends PermittedGidsButtonElements = 'button',
|
|
22
|
+
>({
|
|
23
|
+
as,
|
|
24
|
+
appearance,
|
|
25
|
+
size,
|
|
26
|
+
disabled,
|
|
27
|
+
destructive,
|
|
28
|
+
loading,
|
|
29
|
+
width,
|
|
30
|
+
children,
|
|
31
|
+
leadingIcon,
|
|
32
|
+
trailingIcon,
|
|
33
|
+
type,
|
|
34
|
+
href,
|
|
35
|
+
onClick,
|
|
36
|
+
}: GidsButtonDomProps<ButtonElement>): ButtonElement extends 'button'
|
|
37
|
+
? HTMLButtonElement
|
|
38
|
+
: HTMLAnchorElement => {
|
|
39
|
+
const button = document.createElement(
|
|
40
|
+
as || 'button',
|
|
41
|
+
) as ButtonElement extends 'button' ? HTMLButtonElement : HTMLAnchorElement;
|
|
42
|
+
|
|
43
|
+
button.className = getGidsButtonClassNames(
|
|
44
|
+
{ appearance, size, width, destructive, loading },
|
|
45
|
+
!children && nonEmpty(leadingIcon) && !nonEmpty(trailingIcon),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (as !== 'a') {
|
|
49
|
+
button.setAttribute('type', type ?? 'button');
|
|
50
|
+
|
|
51
|
+
if (disabled) {
|
|
52
|
+
button.setAttribute('disabled', '');
|
|
53
|
+
} else {
|
|
54
|
+
button.removeAttribute('disabled');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (as === 'a') {
|
|
59
|
+
if (href) {
|
|
60
|
+
button.setAttribute('href', href);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const content = document.createElement('span');
|
|
65
|
+
content.classList.add('gids-button__content');
|
|
66
|
+
|
|
67
|
+
appendAsChildren(content, leadingIcon);
|
|
68
|
+
|
|
69
|
+
appendAsChildren(content, children);
|
|
70
|
+
|
|
71
|
+
button.appendChild(content);
|
|
72
|
+
|
|
73
|
+
appendAsChildren(button, trailingIcon);
|
|
74
|
+
|
|
75
|
+
if (loading) {
|
|
76
|
+
button.appendChild(
|
|
77
|
+
GidsSpinnerControlDom({
|
|
78
|
+
size: size === 'lg' || size === undefined ? 'md' : size,
|
|
79
|
+
indeterminate: true
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (onClick && !loading) {
|
|
85
|
+
button.addEventListener('click', onClick)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return button;
|
|
89
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type IconName,
|
|
3
|
+
type IconAppearance,
|
|
4
|
+
getIconGlyphUrl,
|
|
5
|
+
} from '@ganpatiinfo/gids-web-theme-interface';
|
|
6
|
+
import {
|
|
7
|
+
generateId,
|
|
8
|
+
getGidsAssetFilePath,
|
|
9
|
+
GidsIconWebUtils,
|
|
10
|
+
type GidsIconWebProps,
|
|
11
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
12
|
+
|
|
13
|
+
const { getGidsIconClassNames } = GidsIconWebUtils;
|
|
14
|
+
|
|
15
|
+
export interface GidsIconDomProps
|
|
16
|
+
extends GidsIconWebProps<IconName, IconAppearance> {
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const GidsIconDom = ({
|
|
21
|
+
size,
|
|
22
|
+
name,
|
|
23
|
+
appearance,
|
|
24
|
+
alt,
|
|
25
|
+
titleId,
|
|
26
|
+
className,
|
|
27
|
+
}: GidsIconDomProps): SVGSVGElement => {
|
|
28
|
+
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
29
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
|
30
|
+
icon.setAttribute('class', getGidsIconClassNames({ size }, className));
|
|
31
|
+
icon.setAttribute('width', '16');
|
|
32
|
+
icon.setAttribute('height', '16');
|
|
33
|
+
icon.setAttribute('role', 'img');
|
|
34
|
+
|
|
35
|
+
if (alt === '') {
|
|
36
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
37
|
+
} else {
|
|
38
|
+
const title = document.createElementNS(svgNamespace, 'title');
|
|
39
|
+
title.textContent = alt || name;
|
|
40
|
+
const titleElementId = generateId(titleId);
|
|
41
|
+
title.setAttribute('id', titleElementId);
|
|
42
|
+
icon.insertBefore(title, icon.firstChild);
|
|
43
|
+
icon.setAttribute('aria-labelledby', titleElementId);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const use = document.createElementNS(svgNamespace, 'use');
|
|
47
|
+
use.setAttribute(
|
|
48
|
+
'href',
|
|
49
|
+
getIconGlyphUrl(name, appearance, getGidsAssetFilePath),
|
|
50
|
+
);
|
|
51
|
+
icon.appendChild(use);
|
|
52
|
+
|
|
53
|
+
return icon;
|
|
54
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GidsSpinnerCommonProps,
|
|
3
|
+
GidsSpinnerCommonUtils,
|
|
4
|
+
} from '@ganpatiinfo/gids-core-shared';
|
|
5
|
+
import {
|
|
6
|
+
type ClassValue,
|
|
7
|
+
GidsSpinnerWebUtils,
|
|
8
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
9
|
+
import { GidsSpinnerControlDom } from '../_GidsSpinnerControl/GidsSpinnerControl';
|
|
10
|
+
|
|
11
|
+
const { getGidsSpinnerClassNames } = GidsSpinnerWebUtils;
|
|
12
|
+
const { getElementVisibility } = GidsSpinnerCommonUtils;
|
|
13
|
+
|
|
14
|
+
export interface GidsSpinnerDomProps extends GidsSpinnerCommonProps {
|
|
15
|
+
className?: ClassValue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const GidsSpinnerDom = ({
|
|
19
|
+
label,
|
|
20
|
+
supportingText,
|
|
21
|
+
size,
|
|
22
|
+
indeterminate,
|
|
23
|
+
value,
|
|
24
|
+
max,
|
|
25
|
+
className,
|
|
26
|
+
}: GidsSpinnerDomProps): HTMLSpanElement => {
|
|
27
|
+
const spinner = document.createElement('span');
|
|
28
|
+
|
|
29
|
+
const { hasLabel, hasSupportingText } = getElementVisibility({
|
|
30
|
+
label,
|
|
31
|
+
supportingText,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
spinner.className = getGidsSpinnerClassNames({ size }, className);
|
|
35
|
+
|
|
36
|
+
spinner.appendChild(
|
|
37
|
+
GidsSpinnerControlDom({
|
|
38
|
+
size,
|
|
39
|
+
indeterminate,
|
|
40
|
+
value,
|
|
41
|
+
max,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (hasLabel) {
|
|
46
|
+
const spinnerLabel = document.createElement('span');
|
|
47
|
+
spinnerLabel.className = 'gids-spinner__label';
|
|
48
|
+
spinnerLabel.textContent = label || '';
|
|
49
|
+
spinner.appendChild(spinnerLabel);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (hasSupportingText) {
|
|
53
|
+
const spinnerSupportingText = document.createElement('span');
|
|
54
|
+
spinnerSupportingText.className = 'gids-spinner__supporting-text';
|
|
55
|
+
spinnerSupportingText.textContent = supportingText || '';
|
|
56
|
+
spinner.appendChild(spinnerSupportingText);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return spinner;
|
|
60
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type GidsToggleButtonWebProps } from '@ganpatiinfo/gids-web-shared';
|
|
2
|
+
import {
|
|
3
|
+
appendAsChildren,
|
|
4
|
+
toggleAttribute,
|
|
5
|
+
type DomChildren,
|
|
6
|
+
} from '../../utils/domUtils';
|
|
7
|
+
|
|
8
|
+
export interface GidsToggleButtonDomProps
|
|
9
|
+
extends GidsToggleButtonWebProps<DomChildren> {
|
|
10
|
+
onClick?: (this: HTMLElement, ev: MouseEvent) => void;
|
|
11
|
+
onSelect?: (this: HTMLElement, ev: CustomEvent<boolean>) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementEventMap {
|
|
16
|
+
select: CustomEvent<boolean>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const GidsToggleButtonDom = ({
|
|
21
|
+
appearance,
|
|
22
|
+
size,
|
|
23
|
+
width,
|
|
24
|
+
defaultSelected,
|
|
25
|
+
disabled,
|
|
26
|
+
selected,
|
|
27
|
+
children,
|
|
28
|
+
onClick,
|
|
29
|
+
onSelect,
|
|
30
|
+
}: GidsToggleButtonDomProps) => {
|
|
31
|
+
const toggleButton = document.createElement('gids-toggle-button');
|
|
32
|
+
if (appearance !== undefined) {
|
|
33
|
+
toggleButton.setAttribute('appearance', appearance);
|
|
34
|
+
}
|
|
35
|
+
if (size !== undefined) {
|
|
36
|
+
toggleButton.setAttribute('size', size);
|
|
37
|
+
}
|
|
38
|
+
if (width !== undefined) {
|
|
39
|
+
toggleButton.setAttribute('width', width);
|
|
40
|
+
}
|
|
41
|
+
toggleAttribute(toggleButton, 'disabled', !!disabled);
|
|
42
|
+
toggleAttribute(toggleButton, 'default-selected', !!defaultSelected);
|
|
43
|
+
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
toggleButton.selected = selected;
|
|
46
|
+
|
|
47
|
+
appendAsChildren(toggleButton, children);
|
|
48
|
+
|
|
49
|
+
if (onClick) {
|
|
50
|
+
toggleButton.addEventListener('click', onClick);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (onSelect) {
|
|
54
|
+
toggleButton.addEventListener('select', onSelect);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return toggleButton;
|
|
58
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GidsSpinnerControlCommonProps,
|
|
3
|
+
GidsSpinnerControlCommonUtils,
|
|
4
|
+
} from '@ganpatiinfo/gids-core-shared';
|
|
5
|
+
import {
|
|
6
|
+
type ClassValue,
|
|
7
|
+
GidsSpinnerControlWebUtils,
|
|
8
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
9
|
+
|
|
10
|
+
const { getGidsSpinnerControlClassNames } = GidsSpinnerControlWebUtils;
|
|
11
|
+
const { calculateStrokeDasharray, thickness, radius, centerPosition, viewBox } =
|
|
12
|
+
GidsSpinnerControlCommonUtils;
|
|
13
|
+
|
|
14
|
+
export interface GidsSpinnerControlDomProps
|
|
15
|
+
extends GidsSpinnerControlCommonProps {
|
|
16
|
+
className?: ClassValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const GidsSpinnerControlDom = ({
|
|
20
|
+
size,
|
|
21
|
+
indeterminate,
|
|
22
|
+
value,
|
|
23
|
+
max,
|
|
24
|
+
className,
|
|
25
|
+
}: GidsSpinnerControlDomProps): SVGSVGElement => {
|
|
26
|
+
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
27
|
+
const spinnerControlWrapper = document.createElementNS(svgNamespace, 'svg');
|
|
28
|
+
|
|
29
|
+
spinnerControlWrapper.setAttribute(
|
|
30
|
+
'class',
|
|
31
|
+
getGidsSpinnerControlClassNames({ size, indeterminate, value }, className),
|
|
32
|
+
);
|
|
33
|
+
spinnerControlWrapper.setAttribute('viewBox', viewBox);
|
|
34
|
+
|
|
35
|
+
const track = document.createElementNS(svgNamespace, 'circle');
|
|
36
|
+
track.classList.add('gids-spinner-control__track');
|
|
37
|
+
track.setAttribute('cx', centerPosition.toString());
|
|
38
|
+
track.setAttribute('cy', centerPosition.toString());
|
|
39
|
+
track.setAttribute('r', radius.toString());
|
|
40
|
+
track.setAttribute('stroke-width', thickness.toString());
|
|
41
|
+
|
|
42
|
+
const shape = document.createElementNS(svgNamespace, 'circle');
|
|
43
|
+
shape.classList.add('gids-spinner-control__progress');
|
|
44
|
+
shape.setAttribute('cx', centerPosition.toString());
|
|
45
|
+
shape.setAttribute('cy', centerPosition.toString());
|
|
46
|
+
shape.setAttribute('r', radius.toString());
|
|
47
|
+
shape.setAttribute('stroke-width', thickness.toString());
|
|
48
|
+
|
|
49
|
+
if (!indeterminate) {
|
|
50
|
+
const dashArray = calculateStrokeDasharray(value, max ? max : 0);
|
|
51
|
+
|
|
52
|
+
shape.style.strokeDasharray = dashArray;
|
|
53
|
+
shape.style.strokeDashoffset = '0';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
spinnerControlWrapper.appendChild(track);
|
|
57
|
+
spinnerControlWrapper.appendChild(shape);
|
|
58
|
+
|
|
59
|
+
return spinnerControlWrapper;
|
|
60
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from './components/GidsDivider/GidsDivider';
|
|
5
5
|
export * from './components/GidsDisplayTag/GidsDisplayTag';
|
|
6
|
+
export * from './components/_GidsSpinnerControl/GidsSpinnerControl';
|
|
7
|
+
export * from './components/GidsSpinner/GidsSpinner';
|
|
8
|
+
export * from './components/GidsIcon/GidsIcon';
|
|
9
|
+
export * from './components/GidsButton/GidsButton';
|
|
10
|
+
export * from './components/GidsToggleButton/GidsToggleButton';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Utilities
|