no-frills-ui 0.0.14-alpha.4 → 0.0.14-alpha.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/dist/index.js +1335 -493
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.js +11 -29
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.js +7 -7
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts.map +1 -1
- package/lib-esm/components/Button/ActionButton.js +12 -11
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts.map +1 -1
- package/lib-esm/components/Button/Button.js +14 -13
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts.map +1 -1
- package/lib-esm/components/Button/IconButton.js +15 -14
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts.map +1 -1
- package/lib-esm/components/Button/LinkButton.js +7 -6
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts.map +1 -1
- package/lib-esm/components/Button/RaisedButton.js +15 -14
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts.map +1 -1
- package/lib-esm/components/Card/Card.js +4 -4
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.js +8 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.js +20 -20
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.js +4 -1
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +26 -1
- package/lib-esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib-esm/components/Dialog/Dialog.js +84 -1
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.js +8 -8
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +76 -1
- package/lib-esm/components/Drawer/Drawer.d.ts.map +1 -1
- package/lib-esm/components/Drawer/Drawer.js +158 -24
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts.map +1 -1
- package/lib-esm/components/Groups/Group.js +10 -8
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.d.ts.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.js +3 -3
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts.map +1 -1
- package/lib-esm/components/Input/Checkbox.js +63 -58
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +8 -0
- package/lib-esm/components/Input/Dropdown.d.ts.map +1 -1
- package/lib-esm/components/Input/Dropdown.js +54 -31
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts.map +1 -1
- package/lib-esm/components/Input/Input.js +27 -21
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts.map +1 -1
- package/lib-esm/components/Input/Radio.js +58 -42
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts.map +1 -1
- package/lib-esm/components/Input/RadioButton.js +12 -12
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts.map +1 -1
- package/lib-esm/components/Input/Select.js +27 -21
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts.map +1 -1
- package/lib-esm/components/Input/TextArea.js +27 -21
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts.map +1 -1
- package/lib-esm/components/Input/Toggle.js +17 -14
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +13 -1
- package/lib-esm/components/Menu/Menu.d.ts.map +1 -1
- package/lib-esm/components/Menu/Menu.js +98 -3
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +6 -3
- package/lib-esm/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib-esm/components/Menu/MenuItem.js +10 -10
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +70 -1
- package/lib-esm/components/Modal/Modal.d.ts.map +1 -1
- package/lib-esm/components/Modal/Modal.js +145 -11
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +3 -1
- package/lib-esm/components/Notification/Notification.d.ts.map +1 -1
- package/lib-esm/components/Notification/Notification.js +4 -2
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +11 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.js +43 -8
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +4 -0
- package/lib-esm/components/Notification/style.d.ts.map +1 -1
- package/lib-esm/components/Notification/style.js +30 -15
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Notification/types.d.ts +2 -0
- package/lib-esm/components/Notification/types.d.ts.map +1 -1
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts.map +1 -1
- package/lib-esm/components/Popover/Popover.js +17 -2
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +3 -0
- package/lib-esm/components/Spinner/Spinner.d.ts.map +1 -1
- package/lib-esm/components/Spinner/Spinner.js +19 -4
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts.map +1 -1
- package/lib-esm/components/Stepper/Stepper.js +29 -10
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib-esm/components/Tabs/Tabs.js +45 -12
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +25 -4
- package/lib-esm/components/Toast/Toast.d.ts.map +1 -1
- package/lib-esm/components/Toast/Toast.js +114 -18
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib-esm/components/Tooltip/Tooltip.js +16 -5
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts.map +1 -1
- package/lib-esm/shared/LayerManager.js +63 -1
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +58 -27
- package/lib-esm/shared/constants.d.ts.map +1 -1
- package/lib-esm/shared/constants.js +88 -25
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.d.ts.map +1 -1
- package/lib-esm/shared/styles.js +5 -3
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AA8GnC,KAAK,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,GAC9D,SAAS,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEpD,iBAAwB,QAAQ,CAAC,KAAK,EAAE,aAAa,oDAwBpD;kBAxBuB,QAAQ;;QA2B5B,0BAA0B;;QAE1B,6CAA6C;;;;;;;;eA7BzB,QAAQ"}
|
|
@@ -2,103 +2,108 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
|
-
import
|
|
5
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
6
6
|
const Label = styled.label `
|
|
7
7
|
margin: 5px 0;
|
|
8
8
|
position: relative;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
cursor: pointer;
|
|
9
12
|
`;
|
|
10
|
-
const
|
|
11
|
-
|
|
13
|
+
const StyledCheckmark = styled.span `
|
|
14
|
+
width: 16px;
|
|
15
|
+
height: 16px;
|
|
16
|
+
border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};
|
|
17
|
+
display: inline-block;
|
|
18
|
+
border-radius: 3px;
|
|
19
|
+
margin-right: 5px;
|
|
20
|
+
background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};
|
|
21
|
+
transition: all 0.3s ease;
|
|
12
22
|
position: relative;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
&::before {
|
|
16
|
-
content: '';
|
|
17
|
-
width: 16px;
|
|
18
|
-
height: 16px;
|
|
19
|
-
border: 1px solid var(--border-color, ${constants.BORDER_COLOR});
|
|
20
|
-
display: inline-block;
|
|
21
|
-
border-radius: 3px;
|
|
22
|
-
vertical-align: bottom;
|
|
23
|
-
margin: 0 5px;
|
|
24
|
-
text-align: center;
|
|
25
|
-
line-height: 16px;
|
|
26
|
-
background-color: var(--background, ${constants.BACKGROUND});
|
|
27
|
-
transition: background-color 0.3s ease;
|
|
28
|
-
}
|
|
23
|
+
flex-shrink: 0;
|
|
29
24
|
|
|
30
25
|
&::after {
|
|
31
26
|
content: '';
|
|
32
27
|
width: 3px;
|
|
33
28
|
height: 10px;
|
|
34
|
-
border-right: 2px solid
|
|
35
|
-
border-bottom: 2px solid
|
|
36
|
-
transform: translate(-16px, 1px);
|
|
37
|
-
opacity: 0;
|
|
38
|
-
transition: transform 0.3s ease;
|
|
29
|
+
border-right: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};
|
|
30
|
+
border-bottom: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};
|
|
39
31
|
position: absolute;
|
|
32
|
+
top: 1px;
|
|
33
|
+
left: 6px;
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: rotate(45deg) scale(0);
|
|
36
|
+
transition: all 0.2s ease;
|
|
40
37
|
}
|
|
38
|
+
`;
|
|
39
|
+
const HiddenInput = styled.input `
|
|
40
|
+
opacity: 0;
|
|
41
|
+
width: 0;
|
|
42
|
+
height: 0;
|
|
43
|
+
position: absolute;
|
|
44
|
+
margin: 0;
|
|
41
45
|
|
|
42
46
|
/** checked */
|
|
43
|
-
&:checked
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
border-color: var(--primary, ${constants.PRIMARY});
|
|
47
|
-
color: #fff;
|
|
47
|
+
&:checked + ${StyledCheckmark} {
|
|
48
|
+
background-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
49
|
+
border-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
&:checked::after {
|
|
52
|
+
&:checked + ${StyledCheckmark}::after {
|
|
51
53
|
opacity: 1;
|
|
52
|
-
transform:
|
|
54
|
+
transform: rotate(45deg) scale(1);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/** indeterminate */
|
|
56
|
-
&:indeterminate
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
border-color: var(--primary, ${constants});
|
|
60
|
-
color: #fff;
|
|
58
|
+
&:indeterminate + ${StyledCheckmark} {
|
|
59
|
+
background-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
60
|
+
border-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
&:indeterminate::after {
|
|
64
|
-
width: 0;
|
|
63
|
+
&:indeterminate + ${StyledCheckmark}::after {
|
|
65
64
|
opacity: 1;
|
|
66
|
-
|
|
65
|
+
height: 0;
|
|
66
|
+
width: 8px;
|
|
67
|
+
border-right: none;
|
|
68
|
+
border-bottom: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};
|
|
69
|
+
transform: rotate(0deg) scale(1);
|
|
70
|
+
top: 7px;
|
|
71
|
+
left: 4px;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
/** active and focus */
|
|
70
|
-
&:enabled:active
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
box-shadow: 0 0 0 3px var(--primary, ${constants.PRIMARY_LIGHT});
|
|
75
|
+
&:enabled:active + ${StyledCheckmark}, &:focus + ${StyledCheckmark} {
|
|
76
|
+
border-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
77
|
+
box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
&:enabled:active
|
|
77
|
-
&:focus
|
|
78
|
-
color:
|
|
80
|
+
&:enabled:active ~ span,
|
|
81
|
+
&:focus ~ span {
|
|
82
|
+
color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
/** hover */
|
|
82
|
-
&:enabled:hover
|
|
83
|
-
border-color:
|
|
86
|
+
&:enabled:hover + ${StyledCheckmark} {
|
|
87
|
+
border-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
&:enabled:hover
|
|
87
|
-
color:
|
|
90
|
+
&:enabled:hover ~ span {
|
|
91
|
+
color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/** disabled */
|
|
91
|
-
&:disabled
|
|
92
|
-
border-color:
|
|
95
|
+
&:disabled + ${StyledCheckmark} {
|
|
96
|
+
border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};
|
|
97
|
+
cursor: not-allowed;
|
|
93
98
|
}
|
|
94
99
|
|
|
95
|
-
&:disabled
|
|
96
|
-
color:
|
|
100
|
+
&:disabled ~ span {
|
|
101
|
+
color: ${getThemeValue(THEME_NAME.DISABLED)};
|
|
102
|
+
cursor: not-allowed;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
&:checked:disabled
|
|
100
|
-
|
|
101
|
-
background-color: #aaa;
|
|
105
|
+
&:checked:disabled + ${StyledCheckmark}, &:indeterminate:disabled + ${StyledCheckmark} {
|
|
106
|
+
background-color: ${getThemeValue(THEME_NAME.DISABLED)};
|
|
102
107
|
}
|
|
103
108
|
`;
|
|
104
109
|
export default function Checkbox(props) {
|
|
@@ -109,7 +114,7 @@ export default function Checkbox(props) {
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
}, [props.indeterminate]);
|
|
112
|
-
return (_jsxs(Label, { children: [_jsx(
|
|
117
|
+
return (_jsxs(Label, { children: [_jsx(HiddenInput, Object.assign({}, props, { ref: ref, type: "checkbox", "aria-checked": props.indeterminate ? 'mixed' : props.checked })), _jsx(StyledCheckmark, {}), _jsx("span", { children: props.label })] }));
|
|
113
118
|
}
|
|
114
119
|
Checkbox.propTypes = {
|
|
115
120
|
/** Label for the field */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;CAMzB,CAAC;AAEF,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAA;;;wBAGX,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC;;;;wBAItC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC;;;;;;;;;kCAS1B,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC;mCACzC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC;;;;;;;;CAQ5E,CAAC;AAEF,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;kBAQd,eAAe;4BACL,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;wBACrC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;;;kBAGvC,eAAe;;;;;;wBAMT,eAAe;4BACX,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;wBACrC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;;;wBAGjC,eAAe;;;;;mCAKJ,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC;;;;;;;yBAOp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CAAC,YAAY,GAAG;IACpB,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE,EAAE;CACZ,CAAC","sourcesContent":["import React, { useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Label = styled.label`\n margin: 5px 0;\n position: relative;\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n`;\n\nconst StyledCheckmark = styled.span`\n width: 16px;\n height: 16px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n border-radius: 3px;\n margin-right: 5px;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: all 0.3s ease;\n position: relative;\n flex-shrink: 0;\n\n &::after {\n content: '';\n width: 3px;\n height: 10px;\n border-right: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n border-bottom: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n position: absolute;\n top: 1px;\n left: 6px;\n opacity: 0;\n transform: rotate(45deg) scale(0);\n transition: all 0.2s ease;\n }\n`;\n\nconst HiddenInput = styled.input`\n opacity: 0;\n width: 0;\n height: 0;\n position: absolute;\n margin: 0;\n\n /** checked */\n &:checked + ${StyledCheckmark} {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:checked + ${StyledCheckmark}::after {\n opacity: 1;\n transform: rotate(45deg) scale(1);\n }\n\n /** indeterminate */\n &:indeterminate + ${StyledCheckmark} {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:indeterminate + ${StyledCheckmark}::after {\n opacity: 1;\n height: 0;\n width: 8px;\n border-right: none;\n border-bottom: 2px solid ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n transform: rotate(0deg) scale(1);\n top: 7px;\n left: 4px;\n }\n\n /** active and focus */\n &:enabled:active + ${StyledCheckmark}, &:focus + ${StyledCheckmark} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:active ~ span,\n &:focus ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** hover */\n &:enabled:hover + ${StyledCheckmark} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:enabled:hover ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** disabled */\n &:disabled + ${StyledCheckmark} {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n cursor: not-allowed;\n }\n\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n cursor: not-allowed;\n }\n\n &:checked:disabled + ${StyledCheckmark}, &:indeterminate:disabled + ${StyledCheckmark} {\n background-color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n`;\n\ntype CheckboxProps = Omit<React.HTMLProps<HTMLInputElement>, 'as'> &\n PropTypes.InferProps<typeof Checkbox.propTypes>;\n\nexport default function Checkbox(props: CheckboxProps) {\n const ref = useCallback(\n (node: unknown) => {\n if (node !== null) {\n if (props.indeterminate) {\n (node as HTMLInputElement).indeterminate = true;\n }\n }\n },\n [props.indeterminate],\n );\n\n return (\n <Label>\n <HiddenInput\n {...props}\n ref={ref}\n type=\"checkbox\"\n aria-checked={props.indeterminate ? 'mixed' : props.checked}\n />\n <StyledCheckmark />\n <span>{props.label}</span>\n </Label>\n );\n}\n\nCheckbox.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n /** If the field is in indeterminate state */\n indeterminate: PropTypes.bool,\n};\n\nCheckbox.defaultProps = {\n indeterminate: false,\n label: '',\n};\n"]}
|
|
@@ -15,6 +15,14 @@ type DropdownProps<T> = {
|
|
|
15
15
|
/** Disables the field */
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
} & React.PropsWithChildren<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Dropdown component that allows selection from a list of options.
|
|
20
|
+
* Supports single and multi-select modes.
|
|
21
|
+
*
|
|
22
|
+
* @template T - The type of the value(s) in the dropdown.
|
|
23
|
+
* @param {DropdownProps<T>} props - The properties for the Dropdown component.
|
|
24
|
+
* @returns {JSX.Element} The rendered Dropdown component.
|
|
25
|
+
*/
|
|
18
26
|
declare function Dropdown<T extends object>(props: DropdownProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
27
|
declare namespace Dropdown {
|
|
20
28
|
var defaultProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,KAAK,aAAa,CAAC,CAAC,IAAI;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAChB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC;IAChC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AASrC,iBAAwB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,KAAK,aAAa,CAAC,CAAC,IAAI;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAChB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC;IAChC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AASrC;;;;;;;GAOG;AACH,iBAAwB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,oDA2GzE;kBA3GuB,QAAQ;;;;;eAAR,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
import { ExpandMore } from '../../icons';
|
|
5
5
|
import { Menu } from '../Menu';
|
|
@@ -11,54 +11,77 @@ const ArrowContainer = styled.span `
|
|
|
11
11
|
top: 16px;
|
|
12
12
|
pointer-events: none;
|
|
13
13
|
`;
|
|
14
|
+
/**
|
|
15
|
+
* Dropdown component that allows selection from a list of options.
|
|
16
|
+
* Supports single and multi-select modes.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of the value(s) in the dropdown.
|
|
19
|
+
* @param {DropdownProps<T>} props - The properties for the Dropdown component.
|
|
20
|
+
* @returns {JSX.Element} The rendered Dropdown component.
|
|
21
|
+
*/
|
|
14
22
|
export default function Dropdown(props) {
|
|
15
23
|
const { multiSelect, onChange } = props;
|
|
16
24
|
const [open, setOpen] = useState(false);
|
|
17
25
|
const [value, setValue] = useState(props.value);
|
|
26
|
+
const id = React.useId();
|
|
27
|
+
const menuId = `${id}-menu`;
|
|
28
|
+
const menuRef = React.useRef(null);
|
|
29
|
+
const triggerRef = React.useRef(null);
|
|
30
|
+
// Focus menu when opened
|
|
18
31
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
if (open) {
|
|
33
|
+
// Wait for Popover to fully open and focus itself first
|
|
34
|
+
// Then move focus to the first menu item
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
var _a;
|
|
37
|
+
const firstItem = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[role="option"]');
|
|
38
|
+
if (firstItem) {
|
|
39
|
+
firstItem.focus();
|
|
27
40
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const prev = (_a = currentBtn === null || currentBtn === void 0 ? void 0 : currentBtn.previousElementSibling) === null || _a === void 0 ? void 0 : _a.closest('button');
|
|
32
|
-
prev === null || prev === void 0 ? void 0 : prev.focus();
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const next = (_b = currentBtn === null || currentBtn === void 0 ? void 0 : currentBtn.nextElementSibling) === null || _b === void 0 ? void 0 : _b.closest('button');
|
|
36
|
-
next === null || next === void 0 ? void 0 : next.focus();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
document.addEventListener('keydown', focusHandler);
|
|
43
|
-
return () => {
|
|
44
|
-
document.removeEventListener('keydown', focusHandler);
|
|
45
|
-
};
|
|
41
|
+
}, 100); // Wait after Popover has set initial focus
|
|
42
|
+
return () => clearTimeout(timer);
|
|
43
|
+
}
|
|
46
44
|
}, [open]);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Handles keydown events on the input trigger.
|
|
47
|
+
* Opens the menu on 'Enter', 'Space', 'ArrowDown', or 'ArrowUp'.
|
|
48
|
+
*
|
|
49
|
+
* @param {React.KeyboardEvent<HTMLInputElement>} e - The keyboard event.
|
|
50
|
+
*/
|
|
51
|
+
const onKeyDown = (e) => {
|
|
52
|
+
if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(e.key)) {
|
|
53
|
+
e.preventDefault();
|
|
50
54
|
setOpen(true);
|
|
51
55
|
}
|
|
52
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Handles changes to the dropdown value.
|
|
59
|
+
* Updates local state and calls the external onChange handler.
|
|
60
|
+
* Closes the dropdown if not in multi-select mode.
|
|
61
|
+
*
|
|
62
|
+
* @param {T | T[]} val - The new value(s).
|
|
63
|
+
*/
|
|
53
64
|
const changeHandler = (val) => {
|
|
65
|
+
var _a;
|
|
54
66
|
setValue(val);
|
|
55
67
|
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
56
68
|
// Close dropdown after selection if not multiSelect
|
|
57
69
|
if (!multiSelect) {
|
|
58
70
|
setOpen(false);
|
|
71
|
+
(_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
59
72
|
}
|
|
60
73
|
};
|
|
61
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Toggles the dropdown open state on click.
|
|
76
|
+
*/
|
|
77
|
+
const clickHandler = () => setOpen(true);
|
|
78
|
+
const TriggerElement = React.forwardRef((passedProps, ref) => (_jsxs(_Fragment, { children: [_jsx(Input, Object.assign({}, passedProps, { ref: ref, type: "text", value: value && String(value), label: props.label, errorText: props.errorText, onClick: clickHandler, onKeyDown: onKeyDown, required: props.required, disabled: props.disabled, readOnly: true, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": menuId })), _jsx(ArrowContainer, { "aria-hidden": "true", children: _jsx(ExpandMore, {}) })] })));
|
|
79
|
+
TriggerElement.displayName = 'DropdownTrigger';
|
|
80
|
+
return (_jsx(Popover, { position: POPOVER_POSITION.BOTTOM_LEFT, open: open, element: TriggerElement, onClose: () => {
|
|
81
|
+
var _a;
|
|
82
|
+
setOpen(false);
|
|
83
|
+
(_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
84
|
+
}, children: _jsx(Menu, { ref: menuRef, id: menuId, value: value, multiSelect: multiSelect, onChange: changeHandler, children: props.children }) }));
|
|
62
85
|
}
|
|
63
86
|
Dropdown.defaultProps = {
|
|
64
87
|
multiSelect: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/components/Input/Dropdown.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/components/Input/Dropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,MAAM,SAAS,CAAC;AAmB5B,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;CAKjC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAmB,KAAuB;IACtE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,MAAM,CAAC,IAAI,EAAE,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,YAED,KAAC,IAAI,IACD,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,aAAa,YAEtB,KAAK,CAAC,QAAQ,GACZ,GACD,CACb,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,YAAY,GAAG;IACpB,WAAW,EAAE,KAAK;CACrB,CAAC","sourcesContent":["import React, { useEffect, useState } from 'react';\nimport styled from '@emotion/styled';\nimport { ExpandMore } from '../../icons';\nimport { Menu } from '../Menu';\nimport { Popover, POPOVER_POSITION } from '../Popover';\nimport Input from './Input';\n\ntype DropdownProps<T> = {\n /** Value of the control */\n value?: T | T[];\n /** If multiple elements can be selected */\n multiSelect: boolean;\n /** Change handler */\n onChange?: (v: T | T[]) => void;\n /** Label of the control */\n label?: string;\n /** Error message */\n errorText?: string;\n /** Makes field required */\n required?: boolean;\n /** Disables the field */\n disabled?: boolean;\n} & React.PropsWithChildren<unknown>;\n\nconst ArrowContainer = styled.span`\n position: absolute;\n right: 12px;\n top: 16px;\n pointer-events: none;\n`;\n\n/**\n * Dropdown component that allows selection from a list of options.\n * Supports single and multi-select modes.\n *\n * @template T - The type of the value(s) in the dropdown.\n * @param {DropdownProps<T>} props - The properties for the Dropdown component.\n * @returns {JSX.Element} The rendered Dropdown component.\n */\nexport default function Dropdown<T extends object>(props: DropdownProps<T>) {\n const { multiSelect, onChange } = props;\n const [open, setOpen] = useState(false);\n const [value, setValue] = useState(props.value);\n const id = React.useId();\n const menuId = `${id}-menu`;\n const menuRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n // Focus menu when opened\n useEffect(() => {\n if (open) {\n // Wait for Popover to fully open and focus itself first\n // Then move focus to the first menu item\n const timer = setTimeout(() => {\n const firstItem = menuRef.current?.querySelector('[role=\"option\"]') as HTMLElement;\n if (firstItem) {\n firstItem.focus();\n }\n }, 100); // Wait after Popover has set initial focus\n return () => clearTimeout(timer);\n }\n }, [open]);\n\n /**\n * Handles keydown events on the input trigger.\n * Opens the menu on 'Enter', 'Space', 'ArrowDown', or 'ArrowUp'.\n *\n * @param {React.KeyboardEvent<HTMLInputElement>} e - The keyboard event.\n */\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(e.key)) {\n e.preventDefault();\n setOpen(true);\n }\n };\n\n /**\n * Handles changes to the dropdown value.\n * Updates local state and calls the external onChange handler.\n * Closes the dropdown if not in multi-select mode.\n *\n * @param {T | T[]} val - The new value(s).\n */\n const changeHandler = (val: T | T[]) => {\n setValue(val);\n onChange?.(val);\n\n // Close dropdown after selection if not multiSelect\n if (!multiSelect) {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n\n /**\n * Toggles the dropdown open state on click.\n */\n const clickHandler = () => setOpen(true);\n\n const TriggerElement = React.forwardRef<HTMLInputElement>((passedProps, ref) => (\n <>\n <Input\n {...passedProps}\n ref={ref}\n type=\"text\"\n value={value && String(value)}\n label={props.label}\n errorText={props.errorText}\n onClick={clickHandler}\n onKeyDown={onKeyDown}\n required={props.required}\n disabled={props.disabled}\n readOnly\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={menuId}\n />\n <ArrowContainer aria-hidden=\"true\">\n <ExpandMore />\n </ArrowContainer>\n </>\n ));\n TriggerElement.displayName = 'DropdownTrigger';\n\n return (\n <Popover\n position={POPOVER_POSITION.BOTTOM_LEFT}\n open={open}\n element={TriggerElement}\n onClose={() => {\n setOpen(false);\n triggerRef.current?.focus();\n }}\n >\n <Menu\n ref={menuRef}\n id={menuId}\n value={value}\n multiSelect={multiSelect}\n onChange={changeHandler}\n >\n {props.children}\n </Menu>\n </Popover>\n );\n}\n\nDropdown.defaultProps = {\n multiSelect: false,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAK1D,KAAK,UAAU,GAAG,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,GAAG;IAC1D,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA4HF,QAAA,MAAM,KAAK,iGA4CT,CAAC;AAIH,eAAe,KAAK,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useState, useEffect, useId } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
|
-
import
|
|
5
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
6
6
|
const Label = styled.label `
|
|
7
7
|
display: inline-flex;
|
|
8
8
|
flex-direction: column;
|
|
@@ -17,46 +17,46 @@ const TextField = styled.input `
|
|
|
17
17
|
min-height: 30px;
|
|
18
18
|
width: 250px;
|
|
19
19
|
border-radius: 3px;
|
|
20
|
-
border: 1px solid
|
|
20
|
+
border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};
|
|
21
21
|
display: inline-block;
|
|
22
|
-
background-color:
|
|
22
|
+
background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};
|
|
23
23
|
|
|
24
24
|
/** Focused */
|
|
25
25
|
&:focus,
|
|
26
26
|
&:active {
|
|
27
|
-
border-color:
|
|
28
|
-
box-shadow: 0 0 0 4px
|
|
27
|
+
border-color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
28
|
+
box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
&:focus + span,
|
|
32
32
|
&:active + span {
|
|
33
|
-
color:
|
|
33
|
+
color: ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** Disabled */
|
|
37
37
|
&:disabled {
|
|
38
|
-
border-color:
|
|
39
|
-
background-color:
|
|
38
|
+
border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};
|
|
39
|
+
background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
&:disabled + span {
|
|
43
|
-
color:
|
|
43
|
+
color: ${getThemeValue(THEME_NAME.DISABLED)};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** Invalid */
|
|
47
47
|
&:focus:invalid {
|
|
48
|
-
border-color:
|
|
49
|
-
box-shadow: 0 0 0 4px
|
|
48
|
+
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
49
|
+
box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
${(props) => props.touched
|
|
53
53
|
? `
|
|
54
54
|
&:invalid {
|
|
55
|
-
border-color:
|
|
55
|
+
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
&:invalid + span {
|
|
59
|
-
color:
|
|
59
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
60
60
|
}
|
|
61
61
|
`
|
|
62
62
|
: ''}
|
|
@@ -64,10 +64,10 @@ const TextField = styled.input `
|
|
|
64
64
|
/** Error */
|
|
65
65
|
${(props) => props.errorText
|
|
66
66
|
? `
|
|
67
|
-
border-color:
|
|
67
|
+
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
68
68
|
|
|
69
69
|
& + span {
|
|
70
|
-
color:
|
|
70
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
71
71
|
}
|
|
72
72
|
`
|
|
73
73
|
: ''}
|
|
@@ -76,7 +76,7 @@ const TextField = styled.input `
|
|
|
76
76
|
&:required + span:after {
|
|
77
77
|
content: '*';
|
|
78
78
|
margin-left: 2px;
|
|
79
|
-
color:
|
|
79
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/** Label Animation */
|
|
@@ -94,7 +94,7 @@ const TextField = styled.input `
|
|
|
94
94
|
? `
|
|
95
95
|
& + span {
|
|
96
96
|
top: -8px;
|
|
97
|
-
background:
|
|
97
|
+
background: ${getThemeValue(THEME_NAME.BACKGROUND)};
|
|
98
98
|
font-size: 12px;
|
|
99
99
|
line-height: 14px;
|
|
100
100
|
}
|
|
@@ -103,13 +103,13 @@ const TextField = styled.input `
|
|
|
103
103
|
|
|
104
104
|
&:focus + span, &:placeholder-shown + span {
|
|
105
105
|
top: -8px;
|
|
106
|
-
background:
|
|
106
|
+
background: ${getThemeValue(THEME_NAME.BACKGROUND)};
|
|
107
107
|
font-size: 12px;
|
|
108
108
|
line-height: 14px;
|
|
109
109
|
}
|
|
110
110
|
`;
|
|
111
111
|
const ErrorContainer = styled.div `
|
|
112
|
-
color:
|
|
112
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
113
113
|
padding-top: 3px;
|
|
114
114
|
font-size: 12px;
|
|
115
115
|
line-height: 14px;
|
|
@@ -118,6 +118,12 @@ const ErrorContainer = styled.div `
|
|
|
118
118
|
const Input = React.forwardRef((props, ref) => {
|
|
119
119
|
const [touched, setTouched] = useState(false);
|
|
120
120
|
const [value, setValue] = useState(props.value || '');
|
|
121
|
+
const errorId = useId();
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (props.value !== undefined) {
|
|
124
|
+
setValue(props.value);
|
|
125
|
+
}
|
|
126
|
+
}, [props.value]);
|
|
121
127
|
const handleFocus = (e) => {
|
|
122
128
|
setTouched(true);
|
|
123
129
|
if (props.onFocus) {
|
|
@@ -133,7 +139,7 @@ const Input = React.forwardRef((props, ref) => {
|
|
|
133
139
|
setValue(e.target.value);
|
|
134
140
|
}
|
|
135
141
|
};
|
|
136
|
-
return (_jsxs(Label, { children: [_jsx(TextField, Object.assign({}, props, { ref: ref, value: value, onChange: onChangeHandler, onFocus: handleFocus, touched: touched })), _jsx("span", { children: props.label }), props.errorText && _jsx(ErrorContainer, { children: props.errorText })] }));
|
|
142
|
+
return (_jsxs(Label, { children: [_jsx(TextField, Object.assign({}, props, { ref: ref, value: value, onChange: onChangeHandler, onFocus: handleFocus, touched: touched, "aria-invalid": !!props.errorText, "aria-required": props.required, "aria-describedby": props.errorText ? errorId : undefined })), _jsx("span", { children: props.label }), props.errorText && _jsx(ErrorContainer, { id: errorId, children: props.errorText })] }));
|
|
137
143
|
});
|
|
138
144
|
Input.displayName = 'Input';
|
|
139
145
|
export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAanE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;CAKzB,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAoB;;;;;;;;wBAQ1B,aAAa,CAAC,UA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AAC,CAAC,KAAK,CAAC,SAAS,mBAChB,KAAK,CAAC,QAAQ,sBACX,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,IACzD,EACF,yBAAO,KAAK,CAAC,KAAK,GAAQ,EACzB,KAAK,CAAC,SAAS,IAAI,KAAC,cAAc,IAAC,EAAE,EAAE,OAAO,YAAG,KAAK,CAAC,SAAS,GAAkB,IAC/E,CACX,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,eAAe,KAAK,CAAC;AAErB,KAAK,CAAC,SAAS,GAAG;IACd,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC,MAAM;IACvB,6CAA6C;IAC7C,SAAS,EAAE,SAAS,CAAC,MAAM;CAC9B,CAAC","sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype InputProps = React.AllHTMLAttributes<HTMLInputElement> & {\n /** Label for the field */\n label?: string;\n /** Error message for the field */\n errorText?: string;\n};\n\ntype InputInternalProps = InputProps & {\n touched: boolean;\n};\n\nconst Label = styled.label`\n display: inline-flex;\n flex-direction: column;\n position: relative;\n margin: 10px 5px;\n`;\n\nconst TextField = styled.input<InputInternalProps>`\n outline: none;\n color: inherit;\n padding: 0 8px;\n line-height: 30px;\n min-height: 30px;\n width: 250px;\n border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n\n /** Focused */\n &:focus,\n &:active {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus + span,\n &:active + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:disabled {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:disabled + span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:focus:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n &:invalid + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n &:required + span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n /** Label Animation */\n & + span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n ${(props) =>\n props.value !== ''\n ? `\n & + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n\n &:focus + span, &:placeholder-shown + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\nconst Input = React.forwardRef<HTMLInputElement, Omit<InputProps, 'as'>>((props, ref) => {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n\n useEffect(() => {\n if (props.value !== undefined) {\n setValue(props.value);\n }\n }, [props.value]);\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (props.onChange) {\n setValue(e.target.value);\n props.onChange(e);\n } else {\n setValue(e.target.value);\n }\n };\n\n return (\n <Label>\n <TextField\n {...props}\n ref={ref}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n aria-invalid={!!props.errorText}\n aria-required={props.required}\n aria-describedby={props.errorText ? errorId : undefined}\n />\n <span>{props.label}</span>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n );\n});\n\nInput.displayName = 'Input';\n\nexport default Input;\n\nInput.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n /** Error text to be shown below the field */\n errorText: PropTypes.string,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AA4FnC,iBAAS,KAAK,CACV,KAAK,EAAE,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,GAAG,OAAO,KAAK,CAAC,SAAS,CAAC,oDASlG;kBAVQ,KAAK;;QAaV,0BAA0B;;;;AAI9B,eAAe,KAAK,CAAC"}
|