@ganpatiinfo/gids-web-dom-reference 2.0.2 → 2.0.5
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 +24 -0
- package/dist/components/GidsCheckbox/GidsCheckbox.d.ts +7 -0
- package/dist/components/GidsCheckbox/GidsCheckbox.d.ts.map +1 -0
- package/dist/components/GidsCheckbox/GidsCheckbox.js +38 -0
- package/dist/components/GidsCheckbox/GidsCheckbox.js.map +1 -0
- package/dist/components/GidsCheckboxGroup/GidsCheckboxGroup.d.ts +7 -0
- package/dist/components/GidsCheckboxGroup/GidsCheckboxGroup.d.ts.map +1 -0
- package/dist/components/GidsCheckboxGroup/GidsCheckboxGroup.js +10 -0
- package/dist/components/GidsCheckboxGroup/GidsCheckboxGroup.js.map +1 -0
- package/dist/components/GidsLabel/GidsLabel.d.ts +6 -0
- package/dist/components/GidsLabel/GidsLabel.d.ts.map +1 -0
- package/dist/components/GidsLabel/GidsLabel.js +34 -0
- package/dist/components/GidsLabel/GidsLabel.js.map +1 -0
- package/dist/components/GidsLabel/GidsLabelInfo/GidsLabelInfo.d.ts +8 -0
- package/dist/components/GidsLabel/GidsLabelInfo/GidsLabelInfo.d.ts.map +1 -0
- package/dist/components/GidsLabel/GidsLabelInfo/GidsLabelInfo.js +24 -0
- package/dist/components/GidsLabel/GidsLabelInfo/GidsLabelInfo.js.map +1 -0
- package/dist/components/GidsLink/GidsLink.d.ts +10 -0
- package/dist/components/GidsLink/GidsLink.d.ts.map +1 -0
- package/dist/components/GidsLink/GidsLink.js +16 -0
- package/dist/components/GidsLink/GidsLink.js.map +1 -0
- package/dist/components/GidsRadio/GidsRadio.d.ts +8 -0
- package/dist/components/GidsRadio/GidsRadio.d.ts.map +1 -0
- package/dist/components/GidsRadio/GidsRadio.js +36 -0
- package/dist/components/GidsRadio/GidsRadio.js.map +1 -0
- package/dist/components/GidsRadioGroup/GidsRadioGroup.d.ts +5 -0
- package/dist/components/GidsRadioGroup/GidsRadioGroup.d.ts.map +1 -0
- package/dist/components/GidsRadioGroup/GidsRadioGroup.js +8 -0
- package/dist/components/GidsRadioGroup/GidsRadioGroup.js.map +1 -0
- package/dist/components/GidsSwitch/GidsSwitch.d.ts +8 -0
- package/dist/components/GidsSwitch/GidsSwitch.d.ts.map +1 -0
- package/dist/components/GidsSwitch/GidsSwitch.js +36 -0
- package/dist/components/GidsSwitch/GidsSwitch.js.map +1 -0
- package/dist/components/GidsSwitchGroup/GidsSwitchGroup.d.ts +5 -0
- package/dist/components/GidsSwitchGroup/GidsSwitchGroup.d.ts.map +1 -0
- package/dist/components/GidsSwitchGroup/GidsSwitchGroup.js +8 -0
- package/dist/components/GidsSwitchGroup/GidsSwitchGroup.js.map +1 -0
- package/dist/components/_GidsCheckboxControl/GidsCheckboxControl.d.ts +7 -0
- package/dist/components/_GidsCheckboxControl/GidsCheckboxControl.d.ts.map +1 -0
- package/dist/components/_GidsCheckboxControl/GidsCheckboxControl.js +44 -0
- package/dist/components/_GidsCheckboxControl/GidsCheckboxControl.js.map +1 -0
- package/dist/components/_GidsRadioControl/GidsRadioControl.d.ts +7 -0
- package/dist/components/_GidsRadioControl/GidsRadioControl.d.ts.map +1 -0
- package/dist/components/_GidsRadioControl/GidsRadioControl.js +31 -0
- package/dist/components/_GidsRadioControl/GidsRadioControl.js.map +1 -0
- package/dist/components/_GidsSwitchControl/GidsSwitchControl.d.ts +7 -0
- package/dist/components/_GidsSwitchControl/GidsSwitchControl.d.ts.map +1 -0
- package/dist/components/_GidsSwitchControl/GidsSwitchControl.js +45 -0
- package/dist/components/_GidsSwitchControl/GidsSwitchControl.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/GidsCheckbox/GidsCheckbox.ts +76 -0
- package/src/components/GidsCheckboxGroup/GidsCheckboxGroup.ts +21 -0
- package/src/components/GidsLabel/GidsLabel.ts +58 -0
- package/src/components/GidsLabel/GidsLabelInfo/GidsLabelInfo.ts +44 -0
- package/src/components/GidsLink/GidsLink.ts +37 -0
- package/src/components/GidsRadio/GidsRadio.ts +70 -0
- package/src/components/GidsRadioGroup/GidsRadioGroup.ts +14 -0
- package/src/components/GidsSwitch/GidsSwitch.ts +70 -0
- package/src/components/GidsSwitchGroup/GidsSwitchGroup.ts +14 -0
- package/src/components/_GidsCheckboxControl/GidsCheckboxControl.ts +80 -0
- package/src/components/_GidsRadioControl/GidsRadioControl.ts +58 -0
- package/src/components/_GidsSwitchControl/GidsSwitchControl.ts +78 -0
- package/src/index.ts +14 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Referenced to DOM components
|
|
3
3
|
*/
|
|
4
|
+
export * from './components/GidsButton/GidsButton';
|
|
4
5
|
export * from './components/GidsDivider/GidsDivider';
|
|
5
6
|
export * from './components/GidsDisplayTag/GidsDisplayTag';
|
|
7
|
+
export * from './components/GidsIcon/GidsIcon';
|
|
8
|
+
export * from './components/GidsLabel/GidsLabelInfo/GidsLabelInfo';
|
|
9
|
+
export * from './components/GidsLabel/GidsLabel';
|
|
10
|
+
export * from './components/GidsLink/GidsLink';
|
|
6
11
|
export * from './components/_GidsSpinnerControl/GidsSpinnerControl';
|
|
7
12
|
export * from './components/GidsSpinner/GidsSpinner';
|
|
8
|
-
export * from './components/GidsIcon/GidsIcon';
|
|
9
|
-
export * from './components/GidsButton/GidsButton';
|
|
10
13
|
export * from './components/GidsToggleButton/GidsToggleButton';
|
|
14
|
+
export * from './components/_GidsCheckboxControl/GidsCheckboxControl';
|
|
15
|
+
export * from './components/_GidsRadioControl/GidsRadioControl';
|
|
16
|
+
export * from './components/_GidsSwitchControl/GidsSwitchControl';
|
|
17
|
+
export * from './components/GidsCheckbox/GidsCheckbox';
|
|
18
|
+
export * from './components/GidsRadio/GidsRadio';
|
|
19
|
+
export * from './components/GidsSwitch/GidsSwitch';
|
|
20
|
+
export * from './components/GidsCheckboxGroup/GidsCheckboxGroup';
|
|
21
|
+
export * from './components/GidsRadioGroup/GidsRadioGroup';
|
|
22
|
+
export * from './components/GidsSwitchGroup/GidsSwitchGroup';
|
|
11
23
|
/**
|
|
12
24
|
* Utilities
|
|
13
25
|
*/
|
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;AAC3D,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oDAAoD,CAAC;AACnE,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kDAAkD,CAAC;AACjE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAE7D;;GAEG;AACH,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Referenced to DOM components
|
|
3
3
|
*/
|
|
4
|
+
export * from './components/GidsButton/GidsButton';
|
|
4
5
|
export * from './components/GidsDivider/GidsDivider';
|
|
5
6
|
export * from './components/GidsDisplayTag/GidsDisplayTag';
|
|
7
|
+
export * from './components/GidsIcon/GidsIcon';
|
|
8
|
+
export * from './components/GidsLabel/GidsLabelInfo/GidsLabelInfo';
|
|
9
|
+
export * from './components/GidsLabel/GidsLabel';
|
|
10
|
+
export * from './components/GidsLink/GidsLink';
|
|
6
11
|
export * from './components/_GidsSpinnerControl/GidsSpinnerControl';
|
|
7
12
|
export * from './components/GidsSpinner/GidsSpinner';
|
|
8
|
-
export * from './components/GidsIcon/GidsIcon';
|
|
9
|
-
export * from './components/GidsButton/GidsButton';
|
|
10
13
|
export * from './components/GidsToggleButton/GidsToggleButton';
|
|
14
|
+
export * from './components/_GidsCheckboxControl/GidsCheckboxControl';
|
|
15
|
+
export * from './components/_GidsRadioControl/GidsRadioControl';
|
|
16
|
+
export * from './components/_GidsSwitchControl/GidsSwitchControl';
|
|
17
|
+
export * from './components/GidsCheckbox/GidsCheckbox';
|
|
18
|
+
export * from './components/GidsRadio/GidsRadio';
|
|
19
|
+
export * from './components/GidsSwitch/GidsSwitch';
|
|
20
|
+
export * from './components/GidsCheckboxGroup/GidsCheckboxGroup';
|
|
21
|
+
export * from './components/GidsRadioGroup/GidsRadioGroup';
|
|
22
|
+
export * from './components/GidsSwitchGroup/GidsSwitchGroup';
|
|
11
23
|
/**
|
|
12
24
|
* Utilities
|
|
13
25
|
*/
|
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;AAC3D,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oDAAoD,CAAC;AACnE,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kDAAkD,CAAC;AACjE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAE7D;;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": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
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": "2.0.
|
|
28
|
-
"@ganpatiinfo/gids-web-shared": "2.0.
|
|
27
|
+
"@ganpatiinfo/gids-core-shared": "2.0.5",
|
|
28
|
+
"@ganpatiinfo/gids-web-shared": "2.0.5"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@ganpatiinfo/gids-web-theme-interface": "2.0.
|
|
31
|
+
"@ganpatiinfo/gids-web-theme-interface": "2.0.5",
|
|
32
32
|
"@jest/globals": "29.7.0",
|
|
33
33
|
"@types/jasmine": "5.1.7",
|
|
34
34
|
"expect": "29.7.0"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassValue,
|
|
3
|
+
generateId,
|
|
4
|
+
type GidsCheckboxWebProps,
|
|
5
|
+
GidsCheckboxWebUtils,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
import { GidsCheckboxControlDom } from '../_GidsCheckboxControl/GidsCheckboxControl';
|
|
8
|
+
import { GidsLabelDom } from '../GidsLabel/GidsLabel';
|
|
9
|
+
|
|
10
|
+
const { getGidsCheckboxClassNames } = GidsCheckboxWebUtils;
|
|
11
|
+
|
|
12
|
+
export interface GidsCheckboxDomProps
|
|
13
|
+
extends GidsCheckboxWebProps<
|
|
14
|
+
Element | Element[] | string | string[],
|
|
15
|
+
Element
|
|
16
|
+
> {
|
|
17
|
+
onChange?: (this: HTMLInputElement, event: Event) => void;
|
|
18
|
+
className?: ClassValue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const GidsCheckboxDom = ({
|
|
22
|
+
// Label props
|
|
23
|
+
children,
|
|
24
|
+
fieldRequirement,
|
|
25
|
+
fieldRequirementOptionalText,
|
|
26
|
+
fieldRequirementRequiredText,
|
|
27
|
+
info,
|
|
28
|
+
labelId,
|
|
29
|
+
|
|
30
|
+
// Checkbox props
|
|
31
|
+
checked,
|
|
32
|
+
defaultChecked,
|
|
33
|
+
disabled,
|
|
34
|
+
indeterminate,
|
|
35
|
+
required,
|
|
36
|
+
inputId,
|
|
37
|
+
name,
|
|
38
|
+
value,
|
|
39
|
+
onChange,
|
|
40
|
+
|
|
41
|
+
// CheckboxWithLabel props
|
|
42
|
+
className,
|
|
43
|
+
}: GidsCheckboxDomProps): HTMLDivElement => {
|
|
44
|
+
const checkboxWithLabel = document.createElement('div');
|
|
45
|
+
checkboxWithLabel.className = getGidsCheckboxClassNames(className);
|
|
46
|
+
|
|
47
|
+
const realInputId = inputId ?? generateId();
|
|
48
|
+
|
|
49
|
+
checkboxWithLabel.appendChild(
|
|
50
|
+
GidsCheckboxControlDom({
|
|
51
|
+
checked,
|
|
52
|
+
defaultChecked,
|
|
53
|
+
disabled,
|
|
54
|
+
indeterminate,
|
|
55
|
+
inputId: realInputId,
|
|
56
|
+
name,
|
|
57
|
+
value,
|
|
58
|
+
required,
|
|
59
|
+
onChange,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
checkboxWithLabel.appendChild(
|
|
63
|
+
GidsLabelDom({
|
|
64
|
+
children,
|
|
65
|
+
disabled,
|
|
66
|
+
fieldRequirement,
|
|
67
|
+
fieldRequirementOptionalText,
|
|
68
|
+
fieldRequirementRequiredText,
|
|
69
|
+
htmlFor: realInputId,
|
|
70
|
+
info,
|
|
71
|
+
labelId,
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return checkboxWithLabel;
|
|
76
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type GidsCheckboxGroupCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { GidsCheckboxGroupWebUtils } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { appendAsChildren, type DomChildren } from '../../utils/domUtils';
|
|
4
|
+
|
|
5
|
+
const { getGidsCheckboxGroupClassNames } = GidsCheckboxGroupWebUtils;
|
|
6
|
+
|
|
7
|
+
export interface GidsCheckboxGroupDomProps
|
|
8
|
+
extends GidsCheckboxGroupCommonProps<DomChildren> {
|
|
9
|
+
extraClasses?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const GidsCheckboxGroupDom = ({
|
|
13
|
+
children,
|
|
14
|
+
extraClasses,
|
|
15
|
+
}: GidsCheckboxGroupDomProps): HTMLDivElement => {
|
|
16
|
+
const checkboxGroup = document.createElement('div');
|
|
17
|
+
checkboxGroup.className = getGidsCheckboxGroupClassNames(extraClasses);
|
|
18
|
+
appendAsChildren(checkboxGroup, children);
|
|
19
|
+
|
|
20
|
+
return checkboxGroup;
|
|
21
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GidsLabelWebUtils,
|
|
3
|
+
type GidsLabelWebProps,
|
|
4
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
5
|
+
import {
|
|
6
|
+
appendAsChildren,
|
|
7
|
+
type DomChildren,
|
|
8
|
+
type DomNodeOrString,
|
|
9
|
+
} from '../../utils/domUtils';
|
|
10
|
+
import { GidsLabelCommonUtils } from '@ganpatiinfo/gids-core-shared';
|
|
11
|
+
|
|
12
|
+
const { getIndicatorText } = GidsLabelCommonUtils;
|
|
13
|
+
const { getGidsLabelClassNames } = GidsLabelWebUtils;
|
|
14
|
+
|
|
15
|
+
export interface GidsLabelDomProps
|
|
16
|
+
extends GidsLabelWebProps<DomChildren, DomNodeOrString> {}
|
|
17
|
+
|
|
18
|
+
export const GidsLabelDom = ({
|
|
19
|
+
children,
|
|
20
|
+
disabled,
|
|
21
|
+
fieldRequirement,
|
|
22
|
+
fieldRequirementOptionalText,
|
|
23
|
+
fieldRequirementRequiredText,
|
|
24
|
+
info,
|
|
25
|
+
htmlFor,
|
|
26
|
+
labelId,
|
|
27
|
+
}: GidsLabelDomProps): HTMLDivElement => {
|
|
28
|
+
const container = document.createElement('div');
|
|
29
|
+
container.className = getGidsLabelClassNames({ disabled });
|
|
30
|
+
|
|
31
|
+
const label = document.createElement('label');
|
|
32
|
+
if (htmlFor !== undefined) {
|
|
33
|
+
label.setAttribute('for', htmlFor);
|
|
34
|
+
}
|
|
35
|
+
if (labelId !== undefined) {
|
|
36
|
+
label.id = labelId;
|
|
37
|
+
}
|
|
38
|
+
appendAsChildren(label, children);
|
|
39
|
+
|
|
40
|
+
const indicatorText = getIndicatorText({
|
|
41
|
+
fieldRequirement,
|
|
42
|
+
fieldRequirementOptionalText,
|
|
43
|
+
fieldRequirementRequiredText,
|
|
44
|
+
});
|
|
45
|
+
if (indicatorText !== undefined) {
|
|
46
|
+
const fieldRequirementSpan = document.createElement('span');
|
|
47
|
+
fieldRequirementSpan.className = 'gids-label__field-requirement';
|
|
48
|
+
fieldRequirementSpan.textContent = indicatorText;
|
|
49
|
+
label.appendChild(fieldRequirementSpan);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
container.appendChild(label);
|
|
53
|
+
if (info) {
|
|
54
|
+
container.append(info);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return container;
|
|
58
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type GidsLabelInfoCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { type ClassValue } from '@ganpatiinfo/gids-web-shared';
|
|
3
|
+
import { GidsLabelInfoWebUtils } from '@ganpatiinfo/gids-web-shared';
|
|
4
|
+
import { toggleAttribute } from '../../../utils/domUtils';
|
|
5
|
+
import { GidsLabelInfoCommonUtils } from '@ganpatiinfo/gids-core-shared';
|
|
6
|
+
import { GidsIconDom } from '../../GidsIcon/GidsIcon';
|
|
7
|
+
|
|
8
|
+
const { getGidsLabelInfoClassNames } = GidsLabelInfoWebUtils;
|
|
9
|
+
const { getLabelInfoAltText } = GidsLabelInfoCommonUtils;
|
|
10
|
+
|
|
11
|
+
export interface GidsLabelInfoDomProps extends GidsLabelInfoCommonProps {
|
|
12
|
+
onClick?: (event: MouseEvent) => void;
|
|
13
|
+
className?: ClassValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const GidsLabelInfoDom = ({
|
|
17
|
+
disabled,
|
|
18
|
+
alt,
|
|
19
|
+
onClick,
|
|
20
|
+
className,
|
|
21
|
+
}: GidsLabelInfoDomProps): HTMLButtonElement => {
|
|
22
|
+
const labelInfo = document.createElement('button');
|
|
23
|
+
labelInfo.className = getGidsLabelInfoClassNames(className);
|
|
24
|
+
labelInfo.setAttribute('type', 'button');
|
|
25
|
+
|
|
26
|
+
if (onClick) {
|
|
27
|
+
labelInfo.addEventListener('click', onClick);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (disabled) {
|
|
31
|
+
toggleAttribute(labelInfo, 'disabled', true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const labelSpan = document.createElement('span');
|
|
35
|
+
labelSpan.className = 'gids-visually-hidden';
|
|
36
|
+
labelSpan.textContent = getLabelInfoAltText({ alt });
|
|
37
|
+
|
|
38
|
+
labelInfo.appendChild(labelSpan);
|
|
39
|
+
labelInfo.appendChild(
|
|
40
|
+
GidsIconDom({ name: 'information', size: 'sm', alt: '' }),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return labelInfo;
|
|
44
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type GidsLinkCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { appendAsChildren, type DomChildren } from '../../utils/domUtils';
|
|
3
|
+
import {
|
|
4
|
+
type ClassValue,
|
|
5
|
+
GidsLinkWebUtils,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
|
|
8
|
+
const { getGidsLinkClassNames } = GidsLinkWebUtils;
|
|
9
|
+
|
|
10
|
+
export interface GidsLinkDomProps extends GidsLinkCommonProps<DomChildren> {
|
|
11
|
+
extraClasses?: ClassValue;
|
|
12
|
+
href?: string;
|
|
13
|
+
onClick?: (this: HTMLInputElement, event: Event) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const GidsLinkDom = ({
|
|
17
|
+
children,
|
|
18
|
+
size,
|
|
19
|
+
extraClasses,
|
|
20
|
+
href,
|
|
21
|
+
onClick,
|
|
22
|
+
}: GidsLinkDomProps): HTMLAnchorElement => {
|
|
23
|
+
const linkElement = document.createElement('a');
|
|
24
|
+
linkElement.className = getGidsLinkClassNames({ size }, extraClasses);
|
|
25
|
+
|
|
26
|
+
appendAsChildren(linkElement, children);
|
|
27
|
+
|
|
28
|
+
if (href) {
|
|
29
|
+
linkElement.setAttribute('href', href);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (onClick) {
|
|
33
|
+
linkElement.addEventListener('click', onClick);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return linkElement;
|
|
37
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassValue,
|
|
3
|
+
generateId,
|
|
4
|
+
type GidsRadioWebProps,
|
|
5
|
+
GidsRadioWebUtils,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
import { GidsRadioControlDom } from '../_GidsRadioControl/GidsRadioControl';
|
|
8
|
+
import { GidsLabelDom } from '../GidsLabel/GidsLabel';
|
|
9
|
+
import { type DomChildren, type DomNodeOrString } from '../../utils/domUtils';
|
|
10
|
+
|
|
11
|
+
const { getGidsRadioClassNames } = GidsRadioWebUtils;
|
|
12
|
+
|
|
13
|
+
export interface GidsRadioDomProps
|
|
14
|
+
extends GidsRadioWebProps<DomChildren, DomNodeOrString> {
|
|
15
|
+
onChange?: (this: HTMLInputElement, event: Event) => void;
|
|
16
|
+
className?: ClassValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const GidsRadioDom = ({
|
|
20
|
+
// Label props
|
|
21
|
+
children,
|
|
22
|
+
fieldRequirement,
|
|
23
|
+
fieldRequirementOptionalText,
|
|
24
|
+
fieldRequirementRequiredText,
|
|
25
|
+
info,
|
|
26
|
+
labelId,
|
|
27
|
+
|
|
28
|
+
// Radio props
|
|
29
|
+
checked,
|
|
30
|
+
defaultChecked,
|
|
31
|
+
disabled,
|
|
32
|
+
inputId,
|
|
33
|
+
name,
|
|
34
|
+
value,
|
|
35
|
+
onChange,
|
|
36
|
+
|
|
37
|
+
// RadioWithLabel props
|
|
38
|
+
className,
|
|
39
|
+
}: GidsRadioDomProps): HTMLDivElement => {
|
|
40
|
+
const radioWithLabel = document.createElement('div');
|
|
41
|
+
radioWithLabel.className = getGidsRadioClassNames(className);
|
|
42
|
+
|
|
43
|
+
const realInputId = inputId ?? generateId();
|
|
44
|
+
|
|
45
|
+
radioWithLabel.appendChild(
|
|
46
|
+
GidsRadioControlDom({
|
|
47
|
+
checked,
|
|
48
|
+
defaultChecked,
|
|
49
|
+
disabled,
|
|
50
|
+
inputId: realInputId,
|
|
51
|
+
name,
|
|
52
|
+
value,
|
|
53
|
+
onChange,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
radioWithLabel.appendChild(
|
|
57
|
+
GidsLabelDom({
|
|
58
|
+
children,
|
|
59
|
+
disabled,
|
|
60
|
+
fieldRequirement,
|
|
61
|
+
fieldRequirementOptionalText,
|
|
62
|
+
fieldRequirementRequiredText,
|
|
63
|
+
htmlFor: realInputId,
|
|
64
|
+
info,
|
|
65
|
+
labelId,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return radioWithLabel;
|
|
70
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type GidsRadioGroupCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { appendAsChildren, type DomChildren } from '../../utils/domUtils';
|
|
3
|
+
|
|
4
|
+
export type GidsRadioGroupDomProps = GidsRadioGroupCommonProps<DomChildren>;
|
|
5
|
+
|
|
6
|
+
export const GidsRadioGroupDom = ({
|
|
7
|
+
children,
|
|
8
|
+
}: GidsRadioGroupDomProps): HTMLDivElement => {
|
|
9
|
+
const radioGroup = document.createElement('div');
|
|
10
|
+
radioGroup.className = 'gids-radio-group';
|
|
11
|
+
appendAsChildren(radioGroup, children);
|
|
12
|
+
|
|
13
|
+
return radioGroup;
|
|
14
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassValue,
|
|
3
|
+
generateId,
|
|
4
|
+
type GidsSwitchWebProps,
|
|
5
|
+
GidsSwitchWebUtils,
|
|
6
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
7
|
+
import { GidsSwitchControlDom } from '../_GidsSwitchControl/GidsSwitchControl';
|
|
8
|
+
import { GidsLabelDom } from '../GidsLabel/GidsLabel';
|
|
9
|
+
import { type DomChildren, type DomNodeOrString } from '../../utils/domUtils';
|
|
10
|
+
|
|
11
|
+
const { getGidsSwitchClassNames } = GidsSwitchWebUtils;
|
|
12
|
+
|
|
13
|
+
export interface GidsSwitchDomProps
|
|
14
|
+
extends GidsSwitchWebProps<DomChildren, DomNodeOrString> {
|
|
15
|
+
onChange?: (this: HTMLInputElement, event: Event) => void;
|
|
16
|
+
className?: ClassValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const GidsSwitchDom = ({
|
|
20
|
+
// Label props
|
|
21
|
+
children,
|
|
22
|
+
fieldRequirement,
|
|
23
|
+
fieldRequirementOptionalText,
|
|
24
|
+
fieldRequirementRequiredText,
|
|
25
|
+
info,
|
|
26
|
+
labelId,
|
|
27
|
+
|
|
28
|
+
// Switch props
|
|
29
|
+
checked,
|
|
30
|
+
defaultChecked,
|
|
31
|
+
disabled,
|
|
32
|
+
inputId,
|
|
33
|
+
name,
|
|
34
|
+
value,
|
|
35
|
+
onChange,
|
|
36
|
+
|
|
37
|
+
// SwitchWithLabel props
|
|
38
|
+
className,
|
|
39
|
+
}: GidsSwitchDomProps): HTMLDivElement => {
|
|
40
|
+
const switchElement = document.createElement('div');
|
|
41
|
+
switchElement.className = getGidsSwitchClassNames(className);
|
|
42
|
+
|
|
43
|
+
const realInputId = inputId ?? generateId();
|
|
44
|
+
|
|
45
|
+
switchElement.appendChild(
|
|
46
|
+
GidsSwitchControlDom({
|
|
47
|
+
checked,
|
|
48
|
+
defaultChecked,
|
|
49
|
+
disabled,
|
|
50
|
+
inputId: realInputId,
|
|
51
|
+
name,
|
|
52
|
+
value,
|
|
53
|
+
onChange,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
switchElement.appendChild(
|
|
57
|
+
GidsLabelDom({
|
|
58
|
+
children,
|
|
59
|
+
disabled,
|
|
60
|
+
fieldRequirement,
|
|
61
|
+
fieldRequirementOptionalText,
|
|
62
|
+
fieldRequirementRequiredText,
|
|
63
|
+
htmlFor: realInputId,
|
|
64
|
+
info,
|
|
65
|
+
labelId,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return switchElement;
|
|
70
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type GidsSwitchGroupCommonProps } from '@ganpatiinfo/gids-core-shared';
|
|
2
|
+
import { appendAsChildren, type DomChildren } from '../../utils/domUtils';
|
|
3
|
+
|
|
4
|
+
export type GidsSwitchGroupDomProps = GidsSwitchGroupCommonProps<DomChildren>;
|
|
5
|
+
|
|
6
|
+
export const GidsSwitchGroupDom = ({
|
|
7
|
+
children,
|
|
8
|
+
}: GidsSwitchGroupDomProps): HTMLDivElement => {
|
|
9
|
+
const switchGroup = document.createElement('div');
|
|
10
|
+
switchGroup.className = 'gids-switch-group';
|
|
11
|
+
appendAsChildren(switchGroup, children);
|
|
12
|
+
|
|
13
|
+
return switchGroup;
|
|
14
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassValue,
|
|
3
|
+
type GidsCheckboxControlWebProps,
|
|
4
|
+
GidsCheckboxControlWebUtils,
|
|
5
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
6
|
+
import { applyStatefulInputProps, toggleAttribute } from '../../utils/domUtils';
|
|
7
|
+
import { GidsIconDom } from '../GidsIcon/GidsIcon';
|
|
8
|
+
|
|
9
|
+
const { getGidsCheckboxControlClassNames } = GidsCheckboxControlWebUtils;
|
|
10
|
+
|
|
11
|
+
export interface GidsCheckboxControlDomProps
|
|
12
|
+
extends GidsCheckboxControlWebProps {
|
|
13
|
+
onChange?: (this: HTMLInputElement, event: Event) => void;
|
|
14
|
+
className?: ClassValue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const GidsCheckboxControlDom = ({
|
|
18
|
+
checked,
|
|
19
|
+
defaultChecked,
|
|
20
|
+
disabled,
|
|
21
|
+
inputId,
|
|
22
|
+
indeterminate,
|
|
23
|
+
name,
|
|
24
|
+
value,
|
|
25
|
+
required,
|
|
26
|
+
onChange,
|
|
27
|
+
className,
|
|
28
|
+
}: GidsCheckboxControlDomProps): HTMLSpanElement => {
|
|
29
|
+
const checkboxControlWrapper = document.createElement('span');
|
|
30
|
+
checkboxControlWrapper.className =
|
|
31
|
+
getGidsCheckboxControlClassNames(className);
|
|
32
|
+
|
|
33
|
+
const checkboxInput = document.createElement('input');
|
|
34
|
+
checkboxInput.className = 'gids-checkbox-control__input';
|
|
35
|
+
checkboxInput.setAttribute('type', 'checkbox');
|
|
36
|
+
|
|
37
|
+
toggleAttribute(checkboxInput, 'disabled', disabled ?? false);
|
|
38
|
+
toggleAttribute(checkboxInput, 'required', required ?? false);
|
|
39
|
+
|
|
40
|
+
applyStatefulInputProps(checkboxInput, {
|
|
41
|
+
checked,
|
|
42
|
+
defaultChecked,
|
|
43
|
+
value,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
checkboxInput.indeterminate = indeterminate ?? false;
|
|
47
|
+
|
|
48
|
+
if (inputId) {
|
|
49
|
+
checkboxInput.setAttribute('id', inputId);
|
|
50
|
+
}
|
|
51
|
+
if (name) {
|
|
52
|
+
checkboxInput.setAttribute('name', name);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (onChange) {
|
|
56
|
+
checkboxInput.addEventListener('change', onChange);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
checkboxControlWrapper.appendChild(checkboxInput);
|
|
60
|
+
|
|
61
|
+
checkboxControlWrapper.appendChild(
|
|
62
|
+
GidsIconDom({
|
|
63
|
+
size: 'sm',
|
|
64
|
+
name: 'checkmark',
|
|
65
|
+
alt: '',
|
|
66
|
+
className: 'gids-checkbox-control__check',
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
checkboxControlWrapper.appendChild(
|
|
71
|
+
GidsIconDom({
|
|
72
|
+
size: 'sm',
|
|
73
|
+
name: 'minus',
|
|
74
|
+
alt: '',
|
|
75
|
+
className: 'gids-checkbox-control__minus',
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return checkboxControlWrapper;
|
|
80
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassValue,
|
|
3
|
+
type GidsRadioControlWebProps,
|
|
4
|
+
GidsRadioControlWebUtils,
|
|
5
|
+
} from '@ganpatiinfo/gids-web-shared';
|
|
6
|
+
import { applyStatefulInputProps, toggleAttribute } from '../../utils/domUtils';
|
|
7
|
+
|
|
8
|
+
const { getGidsRadioControlClassNames } = GidsRadioControlWebUtils;
|
|
9
|
+
|
|
10
|
+
export interface GidsRadioControlDomProps extends GidsRadioControlWebProps {
|
|
11
|
+
onChange?: (this: HTMLInputElement, event: Event) => void;
|
|
12
|
+
className?: ClassValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const GidsRadioControlDom = ({
|
|
16
|
+
checked,
|
|
17
|
+
defaultChecked,
|
|
18
|
+
disabled,
|
|
19
|
+
inputId,
|
|
20
|
+
name,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
className,
|
|
24
|
+
}: GidsRadioControlDomProps): HTMLSpanElement => {
|
|
25
|
+
const checkedDot = document.createElement('span');
|
|
26
|
+
checkedDot.className = 'gids-radio-control__check';
|
|
27
|
+
|
|
28
|
+
const radioControlWrapper = document.createElement('span');
|
|
29
|
+
radioControlWrapper.className = getGidsRadioControlClassNames(className);
|
|
30
|
+
|
|
31
|
+
const radioControlInput = document.createElement('input');
|
|
32
|
+
radioControlInput.className = 'gids-radio-control__input';
|
|
33
|
+
radioControlInput.setAttribute('type', 'radio');
|
|
34
|
+
|
|
35
|
+
toggleAttribute(radioControlInput, 'disabled', disabled ?? false);
|
|
36
|
+
|
|
37
|
+
applyStatefulInputProps(radioControlInput, {
|
|
38
|
+
checked,
|
|
39
|
+
defaultChecked,
|
|
40
|
+
value,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (inputId) {
|
|
44
|
+
radioControlInput.setAttribute('id', inputId);
|
|
45
|
+
}
|
|
46
|
+
if (name) {
|
|
47
|
+
radioControlInput.setAttribute('name', name);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (onChange) {
|
|
51
|
+
radioControlInput.addEventListener('click', onChange);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
radioControlWrapper.appendChild(radioControlInput);
|
|
55
|
+
radioControlWrapper.appendChild(checkedDot);
|
|
56
|
+
|
|
57
|
+
return radioControlWrapper;
|
|
58
|
+
};
|