no-frills-ui 0.0.14-alpha.8 → 0.0.14-rc.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/README.md +3 -3
- package/dist/index.js +847 -718
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +9 -13
- package/lib-esm/components/Accordion/Accordion.js +13 -11
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
- package/lib-esm/components/Accordion/AccordionStep.js +34 -29
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.d.ts +13 -16
- package/lib-esm/components/Badge/Badge.js +10 -20
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts +9 -5
- package/lib-esm/components/Button/ActionButton.js +18 -3
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +9 -5
- package/lib-esm/components/Button/Button.js +17 -5
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts +9 -5
- package/lib-esm/components/Button/IconButton.js +18 -3
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts +9 -5
- package/lib-esm/components/Button/LinkButton.js +18 -3
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
- package/lib-esm/components/Button/RaisedButton.js +18 -3
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts +4 -6
- package/lib-esm/components/Card/Card.js +16 -3
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +2 -2
- package/lib-esm/components/Chip/Chip.js +14 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -39
- package/lib-esm/components/ChipInput/ChipInput.js +37 -37
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +4 -11
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
- package/lib-esm/components/Dialog/ConfirmDialog.js +4 -12
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +8 -14
- package/lib-esm/components/Dialog/Dialog.js +11 -9
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
- package/lib-esm/components/Dialog/PromptDialog.js +10 -18
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +37 -59
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +23 -26
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +2 -2
- package/lib-esm/components/DragAndDrop/DragItem.js +40 -38
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +3 -3
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +24 -31
- package/lib-esm/components/Drawer/Drawer.js +49 -45
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts +6 -8
- package/lib-esm/components/Groups/Group.js +12 -10
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +30 -26
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +8 -18
- package/lib-esm/components/Input/Dropdown.js +42 -17
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +8 -3
- package/lib-esm/components/Input/Input.js +20 -19
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +4 -8
- package/lib-esm/components/Input/Radio.js +16 -13
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +4 -8
- package/lib-esm/components/Input/RadioButton.js +15 -12
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts +6 -13
- package/lib-esm/components/Input/Select.js +21 -18
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts +6 -13
- package/lib-esm/components/Input/TextArea.js +29 -24
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +4 -9
- package/lib-esm/components/Input/Toggle.js +12 -10
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +4 -14
- package/lib-esm/components/Menu/Menu.js +24 -16
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +4 -4
- package/lib-esm/components/Menu/MenuContext.js +1 -0
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +10 -4
- package/lib-esm/components/Menu/MenuItem.js +19 -5
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +17 -23
- package/lib-esm/components/Modal/Modal.js +37 -34
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +39 -34
- package/lib-esm/components/Notification/Notification.js +16 -39
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +4 -4
- package/lib-esm/components/Notification/NotificationManager.js +18 -14
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/index.d.ts +1 -0
- package/lib-esm/components/Notification/style.d.ts +2 -3
- package/lib-esm/components/Notification/style.js +11 -11
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +42 -44
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -15
- package/lib-esm/components/Spinner/Spinner.js +12 -13
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Step.d.ts +15 -12
- package/lib-esm/components/Stepper/Step.js +10 -8
- package/lib-esm/components/Stepper/Step.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
- package/lib-esm/components/Stepper/Stepper.js +25 -23
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tab.d.ts +10 -16
- package/lib-esm/components/Tabs/Tab.js +0 -8
- package/lib-esm/components/Tabs/Tab.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
- package/lib-esm/components/Tabs/Tabs.js +39 -31
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +7 -7
- package/lib-esm/components/Toast/Toast.js +13 -12
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
- package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
- package/lib-esm/components/Tooltip/Tooltip.js +11 -21
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/icons/CheckCircle.js +2 -2
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.js +2 -2
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/Info.js +2 -2
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.js +2 -2
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/index.js +43 -0
- package/lib-esm/shared/LayerManager.d.ts +5 -4
- package/lib-esm/shared/LayerManager.js +111 -111
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.js +9 -9
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +66 -31
- package/lib-esm/components/index.js +0 -43
- /package/lib-esm/{components/index.js.map → index.js.map} +0 -0
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
6
5
|
|
|
7
6
|
const Input = /*#__PURE__*/ styled("input", {
|
|
8
|
-
target: "
|
|
7
|
+
target: "e1yp0s5y0",
|
|
9
8
|
label: "Input"
|
|
10
9
|
})("appearance:none;margin:0;width:0;& + span{color:", getThemeValue(THEME_NAME.PRIMARY), ";padding:6px 12px;border:none;border:1px solid ", getThemeValue(THEME_NAME.PRIMARY), ";cursor:pointer;margin-right:-1px;line-height:18px;}&:enabled:focus + span{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:hover + span{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}&:enabled:checked + span{background-color:", getThemeValue(THEME_NAME.PRIMARY), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}&:disabled + span{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled:checked + span{background-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}");
|
|
11
10
|
const Label = /*#__PURE__*/ styled("label", {
|
|
12
|
-
target: "
|
|
11
|
+
target: "e1yp0s5y1",
|
|
13
12
|
label: "Label"
|
|
14
13
|
})("display:inline-flex;&:focus-within{z-index:1;}");
|
|
15
14
|
const RadioGroup = /*#__PURE__*/ styled("div", {
|
|
16
|
-
target: "
|
|
15
|
+
target: "e1yp0s5y2",
|
|
17
16
|
label: "RadioGroup"
|
|
18
17
|
})("display:inline-flex;align-items:center;border-radius:3px;margin:5px 0;& ", Label, ":first-child > span{border-radius:3px 0 0 3px;}& ", Label, ":last-child > span{border-radius:0 3px 3px 0;}");
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* RadioButton Component
|
|
20
|
+
* @param props - Component props
|
|
21
|
+
* @param ref - Ref forwarded to the underlying HTMLInputElement
|
|
22
|
+
*/ function RadioButtonComponent(props, ref) {
|
|
23
|
+
const { label, ...rest } = props;
|
|
20
24
|
return /*#__PURE__*/ jsxs(Label, {
|
|
21
25
|
children: [
|
|
22
26
|
/*#__PURE__*/ jsx(Input, {
|
|
23
|
-
...
|
|
24
|
-
type: "radio"
|
|
27
|
+
...rest,
|
|
28
|
+
type: "radio",
|
|
29
|
+
ref: ref
|
|
25
30
|
}),
|
|
26
31
|
/*#__PURE__*/ jsx("span", {
|
|
27
|
-
children:
|
|
32
|
+
children: label
|
|
28
33
|
})
|
|
29
34
|
]
|
|
30
35
|
});
|
|
31
36
|
}
|
|
32
|
-
RadioButton
|
|
33
|
-
/** Label for the field */ label: PropTypes.string
|
|
34
|
-
};
|
|
37
|
+
const RadioButton = /*#__PURE__*/ React.forwardRef(RadioButtonComponent);
|
|
35
38
|
|
|
36
39
|
export { RadioGroup, RadioButton as default };
|
|
37
40
|
//# sourceMappingURL=RadioButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.js","sources":["../../../src/components/Input/RadioButton.tsx"],"sourcesContent":["import React from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../../../src/components/Input/RadioButton.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Input = styled.input`\n appearance: none;\n margin: 0;\n width: 0;\n\n & + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n padding: 6px 12px;\n border: none;\n border: 1px solid ${getThemeValue(THEME_NAME.PRIMARY)};\n cursor: pointer;\n margin-right: -1px;\n line-height: 18px;\n }\n\n &:enabled:focus + span {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:hover + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:enabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n\n &:focus-within {\n z-index: 1;\n }\n`;\n\nexport const RadioGroup = styled.div`\n display: inline-flex;\n align-items: center;\n border-radius: 3px;\n margin: 5px 0;\n\n & ${Label}:first-child > span {\n border-radius: 3px 0 0 3px;\n }\n\n & ${Label}:last-child > span {\n border-radius: 0 3px 3px 0;\n }\n`;\n\ntype RadioButtonProps = {\n /** Label for the field */\n label?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * RadioButton Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLInputElement\n */\nfunction RadioButtonComponent(props: RadioButtonProps, ref: React.Ref<HTMLInputElement>) {\n const { label, ...rest } = props;\n return (\n <Label>\n <Input {...rest} type=\"radio\" ref={ref} />\n <span>{label}</span>\n </Label>\n );\n}\n\nconst RadioButton = React.forwardRef(RadioButtonComponent);\nexport default RadioButton;\n"],"names":["Input","styled","getThemeValue","THEME_NAME","PRIMARY","PRIMARY_LIGHT","TEXT_COLOR_LIGHT","BORDER_LIGHT_COLOR","DISABLED_BORDER","Label","RadioGroup","RadioButtonComponent","props","ref","label","rest","_jsxs","_jsx","type","span","RadioButton","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,KAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;AAMGC,CAAAA,CAAAA,CAAAA,kDAAAA,EAAAA,aAAAA,CAAcC,WAAWC,OAAO,CAAA,EAAA,iDAAA,EAGrBF,cAAcC,UAAAA,CAAWC,OAAO,uGAO5BF,aAAAA,CAAcC,UAAAA,CAAWE,aAAa,CAAA,EAAA,4CAAA,EAI1CH,cAAcC,UAAAA,CAAWE,aAAa,cACjDH,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,8CAAA,EAI9BJ,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,cAC3CF,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,uCAAA,EAI9BJ,aAAAA,CAAcC,WAAWI,kBAAkB,CAAA,EAAA,SAAA,EACtDL,cAAcC,UAAAA,CAAWK,eAAe,oDAI7BN,aAAAA,CAAcC,UAAAA,CAAWK,eAAe,CAAA,EAAA,SAAA,EACnDN,aAAAA,CAAcC,WAAWG,gBAAgB,CAAA,EAAA,IAAA,CAAA;AAI1D,MAAMG,KAAAA,iBAAQR,MAAAA,CAAAA,OAAAA,EAAAA;;;;MAQDS,UAAAA,iBAAaT,MAAAA,CAAAA,KAAAA,EAAAA;;;AAMlBQ,CAAAA,CAAAA,CAAAA,0EAAAA,EAAAA,KAAAA,EAAAA,mDAAAA,EAIAA,KAAAA,EAAAA,gDAAAA;AAUR;;;;AAIC,IACD,SAASE,oBAAAA,CAAqBC,KAAuB,EAAEC,GAAgC,EAAA;AACnF,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGH,KAAAA;AAC3B,IAAA,qBACII,IAAA,CAACP,KAAAA,EAAAA;;0BACGQ,GAAA,CAACjB,KAAAA,EAAAA;AAAO,gBAAA,GAAGe,IAAI;gBAAEG,IAAAA,EAAK,OAAA;gBAAQL,GAAAA,EAAKA;;0BACnCI,GAAA,CAACE,MAAAA,EAAAA;AAAML,gBAAAA,QAAAA,EAAAA;;;;AAGnB;AAEA,MAAMM,WAAAA,iBAAcC,KAAAA,CAAMC,UAAU,CAACX,oBAAAA;;;;"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var propTypes: {
|
|
9
|
-
/** Label for the field */
|
|
10
|
-
label: PropTypes.Requireable<string>;
|
|
11
|
-
/** Error text to be shown below the field */
|
|
12
|
-
errorText: PropTypes.Requireable<string>;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
2
|
+
declare const Select: React.ForwardRefExoticComponent<{
|
|
3
|
+
/** Label for the field */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Error text to be shown below the field */
|
|
6
|
+
errorText?: string;
|
|
7
|
+
} & React.InputHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
15
8
|
export default Select;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { useState, useId, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useState, useId, useRef, useEffect } from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import ExpandMore from '../../icons/ExpandMore.js';
|
|
6
5
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
7
6
|
|
|
8
|
-
const Label = /*#__PURE__*/ styled("label", {
|
|
9
|
-
target: "
|
|
7
|
+
const Label$3 = /*#__PURE__*/ styled("label", {
|
|
8
|
+
target: "e13b7jm0",
|
|
10
9
|
label: "Label"
|
|
11
10
|
})("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;pointer-events:none;max-width:268px;& svg{fill:currentColor;}");
|
|
12
11
|
const SelectField = /*#__PURE__*/ styled("select", {
|
|
13
|
-
target: "
|
|
12
|
+
target: "e13b7jm1",
|
|
14
13
|
label: "SelectField"
|
|
15
14
|
})("border:none;color:inherit;padding:0 8px;line-height:30px;min-height:32px;width:268px;border-radius:3px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";display:inline-block;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";pointer-events:auto;appearance:none;&:focus,&:active{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:focus ~ span,&:active ~ span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED), ";}&:focus:invalid{border-color:", getThemeValue(THEME_NAME.ERROR), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}", (props)=>props.touched ? `
|
|
16
15
|
&:invalid {
|
|
@@ -34,21 +33,27 @@ const SelectField = /*#__PURE__*/ styled("select", {
|
|
|
34
33
|
line-height: 14px;
|
|
35
34
|
}
|
|
36
35
|
` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
|
|
37
|
-
const ErrorContainer = /*#__PURE__*/ styled("div", {
|
|
38
|
-
target: "
|
|
36
|
+
const ErrorContainer$1 = /*#__PURE__*/ styled("div", {
|
|
37
|
+
target: "e13b7jm2",
|
|
39
38
|
label: "ErrorContainer"
|
|
40
39
|
})("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
|
|
41
|
-
const ArrowContainer = /*#__PURE__*/ styled("span", {
|
|
42
|
-
target: "
|
|
40
|
+
const ArrowContainer$1 = /*#__PURE__*/ styled("span", {
|
|
41
|
+
target: "e13b7jm3",
|
|
43
42
|
label: "ArrowContainer"
|
|
44
43
|
})("position:absolute;right:8px;top:8px;");
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Select Component
|
|
46
|
+
* @param props - Component props
|
|
47
|
+
* @param ref - Ref forwarded to the underlying HTMLSelectElement
|
|
48
|
+
*/ function SelectComponent(props, ref) {
|
|
46
49
|
const [touched, setTouched] = useState(false);
|
|
47
50
|
const [value, setValue] = useState(props.value || '');
|
|
48
51
|
const errorId = useId();
|
|
52
|
+
const prevValueRef = useRef(undefined);
|
|
49
53
|
useEffect(()=>{
|
|
50
|
-
if (props.value !== undefined) {
|
|
54
|
+
if (props.value !== undefined && props.value !== prevValueRef.current) {
|
|
51
55
|
setValue(props.value);
|
|
56
|
+
prevValueRef.current = props.value;
|
|
52
57
|
}
|
|
53
58
|
}, [
|
|
54
59
|
props.value
|
|
@@ -67,10 +72,11 @@ function Select(props) {
|
|
|
67
72
|
setValue(e.target.value);
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
|
-
return /*#__PURE__*/ jsxs(Label, {
|
|
75
|
+
return /*#__PURE__*/ jsxs(Label$3, {
|
|
71
76
|
children: [
|
|
72
77
|
/*#__PURE__*/ jsxs(SelectField, {
|
|
73
78
|
...props,
|
|
79
|
+
ref: ref,
|
|
74
80
|
multiple: false,
|
|
75
81
|
value: value,
|
|
76
82
|
onChange: onChangeHandler,
|
|
@@ -87,21 +93,18 @@ function Select(props) {
|
|
|
87
93
|
/*#__PURE__*/ jsx("span", {
|
|
88
94
|
children: props.label
|
|
89
95
|
}),
|
|
90
|
-
/*#__PURE__*/ jsx(ArrowContainer, {
|
|
96
|
+
/*#__PURE__*/ jsx(ArrowContainer$1, {
|
|
91
97
|
"aria-hidden": "true",
|
|
92
98
|
children: /*#__PURE__*/ jsx(ExpandMore, {})
|
|
93
99
|
}),
|
|
94
|
-
props.errorText && /*#__PURE__*/ jsx(ErrorContainer, {
|
|
100
|
+
props.errorText && /*#__PURE__*/ jsx(ErrorContainer$1, {
|
|
95
101
|
id: errorId,
|
|
96
102
|
children: props.errorText
|
|
97
103
|
})
|
|
98
104
|
]
|
|
99
105
|
});
|
|
100
106
|
}
|
|
101
|
-
Select
|
|
102
|
-
/** Label for the field */ label: PropTypes.string,
|
|
103
|
-
/** Error text to be shown below the field */ errorText: PropTypes.string
|
|
104
|
-
};
|
|
107
|
+
const Select = /*#__PURE__*/ React.forwardRef(SelectComponent);
|
|
105
108
|
|
|
106
109
|
export { Select as default };
|
|
107
110
|
//# sourceMappingURL=Select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/components/Input/Select.tsx"],"sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/components/Input/Select.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef } from 'react';\nimport styled from '@emotion/styled';\nimport ExpandMore from '../../icons/ExpandMore';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype SelectProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLSelectElement>;\n\ntype SelectInternalProps = SelectProps & {\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 pointer-events: none;\n max-width: 268px;\n\n & svg {\n fill: currentColor;\n }\n`;\n\nconst SelectField = styled.select<SelectInternalProps>`\n border: none;\n color: inherit;\n padding: 0 8px;\n line-height: 30px;\n min-height: 32px;\n width: 268px;\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 pointer-events: auto;\n appearance: none;\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 ArrowContainer = styled.span`\n position: absolute;\n right: 8px;\n top: 8px;\n`;\n\n/**\n * Select Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLSelectElement\n */\nfunction SelectComponent(props: SelectProps, ref: React.Ref<HTMLSelectElement>) {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n\n useEffect(() => {\n if (props.value !== undefined && props.value !== prevValueRef.current) {\n setValue(props.value);\n prevValueRef.current = props.value as string;\n }\n }, [props.value]);\n\n const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLSelectElement>) => {\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 <SelectField\n {...props}\n ref={ref}\n multiple={false}\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 <option />\n {props.children}\n </SelectField>\n <span>{props.label}</span>\n <ArrowContainer aria-hidden=\"true\">\n <ExpandMore />\n </ArrowContainer>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst Select = React.forwardRef(SelectComponent);\nexport default Select;\n"],"names":["Label","styled","SelectField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","ArrowContainer","SelectComponent","ref","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","useEffect","current","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","multiple","aria-invalid","aria-required","required","aria-describedby","_jsx","option","children","span","label","aria-hidden","ExpandMore","id","Select","React","forwardRef"],"mappings":";;;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAad,MAAMC,WAAAA,iBAAcD,MAAAA,CAAAA,QAAAA,EAAAA;;;+HAQIE,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,qEAAA,EAOnCH,cAAcC,UAAAA,CAAWG,OAAO,6BACxBJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,yCAAA,EAKrDL,aAAAA,CAAcC,WAAWG,OAAO,CAAA,EAAA,4BAAA,EAKzBJ,cAAcC,UAAAA,CAAWK,eAAe,yBACpCN,aAAAA,CAAcC,UAAAA,CAAWM,mBAAmB,CAAA,EAAA,4BAAA,EAIvDP,aAAAA,CAAcC,WAAWO,QAAQ,CAAA,EAAA,iCAAA,EAK1BR,cAAcC,UAAAA,CAAWQ,KAAK,6BACtBT,aAAAA,CAAcC,UAAAA,CAAWS,WAAW,CAAA,EAAA,IAAA,EAG9D,CAACC,QACCA,KAAAA,CAAMC,OAAO,GACP;;sBAEQ,EAAEZ,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;;;eAIzC,EAAET,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;AAE7C,IAAA,CAAC,GACS,EAAA,EAAA,YAAA,EAGR,CAACE,QACCA,KAAAA,CAA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;;;0BAEXF,GAAA,CAACG,MAAAA,EAAAA;AAAMjC,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMkC;;0BACbJ,GAAA,CAACzB,gBAAAA,EAAAA;gBAAe8B,aAAAA,EAAY,MAAA;AACxB,gBAAA,QAAA,gBAAAL,GAAA,CAACM,UAAAA,EAAAA,EAAAA;;YAEJpC,KAAAA,CAAME,SAAS,kBAAI4B,GAAA,CAAC1B,gBAAAA,EAAAA;gBAAeiC,EAAAA,EAAI1B,OAAAA;AAAUX,gBAAAA,QAAAA,EAAAA,KAAAA,CAAME;;;;AAGpE;AAEA,MAAMoC,MAAAA,iBAASC,KAAAA,CAAMC,UAAU,CAAClC,eAAAA;;;;"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var propTypes: {
|
|
9
|
-
/** Label for the field */
|
|
10
|
-
label: PropTypes.Requireable<string>;
|
|
11
|
-
/** Error text to be shown below the field */
|
|
12
|
-
errorText: PropTypes.Requireable<string>;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
2
|
+
declare const TextArea: React.ForwardRefExoticComponent<{
|
|
3
|
+
/** Label for the field */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Error text to be shown below the field */
|
|
6
|
+
errorText?: string;
|
|
7
|
+
} & React.InputHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
15
8
|
export default TextArea;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { useState, useId, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useState, useId, useRef, useEffect } from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
6
5
|
|
|
7
|
-
const Label = /*#__PURE__*/ styled("label", {
|
|
8
|
-
target: "
|
|
6
|
+
const Label$4 = /*#__PURE__*/ styled("label", {
|
|
7
|
+
target: "e1j32tnv0",
|
|
9
8
|
label: "Label"
|
|
10
9
|
})("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;");
|
|
11
10
|
const TextField = /*#__PURE__*/ styled("textarea", {
|
|
12
|
-
target: "
|
|
11
|
+
target: "e1j32tnv1",
|
|
13
12
|
label: "TextField"
|
|
14
13
|
})("border:none;color:inherit;padding:8px;min-height:150px;min-width:250px;border-radius:3px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";display:inline-block;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";&:focus,&:active{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:focus + span,&:active + span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:disabled + span{color:", getThemeValue(THEME_NAME.DISABLED), ";}&:focus:invalid{border-color:", getThemeValue(THEME_NAME.ERROR), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}", (props)=>props.touched ? `
|
|
15
14
|
&:invalid {
|
|
@@ -33,20 +32,27 @@ const TextField = /*#__PURE__*/ styled("textarea", {
|
|
|
33
32
|
line-height: 14px;
|
|
34
33
|
}
|
|
35
34
|
` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
|
|
36
|
-
const ErrorContainer = /*#__PURE__*/ styled("div", {
|
|
37
|
-
target: "
|
|
35
|
+
const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
|
|
36
|
+
target: "e1j32tnv2",
|
|
38
37
|
label: "ErrorContainer"
|
|
39
38
|
})("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* TextArea Component
|
|
41
|
+
* @param props - Component props
|
|
42
|
+
* @param ref - Ref forwarded to the underlying HTMLTextAreaElement
|
|
43
|
+
*/ function TextAreaComponent(props, ref) {
|
|
44
|
+
const { label, errorText, value: propsValue, required, ...rest } = props;
|
|
41
45
|
const [touched, setTouched] = useState(false);
|
|
42
|
-
const [value, setValue] = useState(
|
|
46
|
+
const [value, setValue] = useState(propsValue || '');
|
|
43
47
|
const errorId = useId();
|
|
48
|
+
const prevValueRef = useRef(undefined);
|
|
44
49
|
useEffect(()=>{
|
|
45
|
-
if (
|
|
46
|
-
setValue(
|
|
50
|
+
if (propsValue !== undefined && propsValue !== prevValueRef.current) {
|
|
51
|
+
setValue(propsValue);
|
|
52
|
+
prevValueRef.current = propsValue;
|
|
47
53
|
}
|
|
48
54
|
}, [
|
|
49
|
-
|
|
55
|
+
propsValue
|
|
50
56
|
]);
|
|
51
57
|
const handleFocus = (e)=>{
|
|
52
58
|
setTouched(true);
|
|
@@ -62,32 +68,31 @@ function TextArea(props) {
|
|
|
62
68
|
setValue(e.target.value);
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
|
-
return /*#__PURE__*/ jsxs(Label, {
|
|
71
|
+
return /*#__PURE__*/ jsxs(Label$4, {
|
|
66
72
|
children: [
|
|
67
73
|
/*#__PURE__*/ jsx(TextField, {
|
|
68
|
-
...
|
|
74
|
+
...rest,
|
|
75
|
+
ref: ref,
|
|
69
76
|
value: value,
|
|
70
77
|
onChange: onChangeHandler,
|
|
71
78
|
onFocus: handleFocus,
|
|
72
79
|
touched: touched,
|
|
73
|
-
|
|
74
|
-
"aria-
|
|
75
|
-
"aria-
|
|
80
|
+
required: required,
|
|
81
|
+
"aria-invalid": !!errorText,
|
|
82
|
+
"aria-required": required,
|
|
83
|
+
"aria-describedby": errorText ? errorId : undefined
|
|
76
84
|
}),
|
|
77
85
|
/*#__PURE__*/ jsx("span", {
|
|
78
|
-
children:
|
|
86
|
+
children: label
|
|
79
87
|
}),
|
|
80
|
-
|
|
88
|
+
errorText && /*#__PURE__*/ jsx(ErrorContainer$2, {
|
|
81
89
|
id: errorId,
|
|
82
|
-
children:
|
|
90
|
+
children: errorText
|
|
83
91
|
})
|
|
84
92
|
]
|
|
85
93
|
});
|
|
86
94
|
}
|
|
87
|
-
TextArea
|
|
88
|
-
/** Label for the field */ label: PropTypes.string,
|
|
89
|
-
/** Error text to be shown below the field */ errorText: PropTypes.string
|
|
90
|
-
};
|
|
95
|
+
const TextArea = /*#__PURE__*/ React.forwardRef(TextAreaComponent);
|
|
91
96
|
|
|
92
97
|
export { TextArea as default };
|
|
93
98
|
//# sourceMappingURL=TextArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","sources":["../../../src/components/Input/TextArea.tsx"],"sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"TextArea.js","sources":["../../../src/components/Input/TextArea.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype TextAreaProps = {\n /** Label for the field */\n label: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLTextAreaElement>;\n\ntype TextAreaInternalProps = {\n touched: boolean;\n errorText?: string;\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.textarea<TextAreaInternalProps>`\n border: none;\n color: inherit;\n padding: 8px;\n min-height: 150px;\n min-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\n/**\n * TextArea Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLTextAreaElement\n */\nfunction TextAreaComponent(props: TextAreaProps, ref: React.Ref<HTMLTextAreaElement>) {\n const { label, errorText, value: propsValue, required, ...rest } = props;\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(propsValue || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n\n useEffect(() => {\n if (propsValue !== undefined && propsValue !== prevValueRef.current) {\n setValue(propsValue);\n prevValueRef.current = propsValue as string;\n }\n }, [propsValue]);\n\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\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 {...rest}\n ref={ref}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n required={required}\n aria-invalid={!!errorText}\n aria-required={required}\n aria-describedby={errorText ? errorId : undefined}\n />\n <span>{label}</span>\n {errorText && <ErrorContainer id={errorId}>{errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst TextArea = React.forwardRef(TextAreaComponent);\nexport default TextArea;\n"],"names":["Label","styled","TextField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","TextAreaComponent","ref","label","propsValue","required","rest","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","useEffect","current","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","_jsx","aria-invalid","aria-required","aria-describedby","span","id","TextArea","React","forwardRef"],"mappings":";;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAA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MAAME,kBAAkB,CAACF,CAAAA,GAAAA;QACrB,IAAItB,KAAAA,CAAMyB,QAAQ,EAAE;YAChBZ,QAAAA,CAASS,CAAAA,CAAEI,MAAM,CAACvB,KAAK,CAAA;AACvBH,YAAAA,KAAAA,CAAMyB,QAAQ,CAACH,CAAAA,CAAAA;QACnB,CAAA,MAAO;YACHT,QAAAA,CAASS,CAAAA,CAAEI,MAAM,CAACvB,KAAK,CAAA;AAC3B,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,qBACIwB,IAAA,CAACzC,OAAAA,EAAAA;;0BACG0C,GAAA,CAACxC,SAAAA,EAAAA;AACI,gBAAA,GAAGsB,IAAI;gBACRJ,GAAAA,EAAKA,GAAAA;gBACLH,KAAAA,EAAOA,KAAAA;gBACPsB,QAAAA,EAAUD,eAAAA;gBACVD,OAAAA,EAASF,WAAAA;gBACTpB,OAAAA,EAASA,OAAAA;gBACTQ,QAAAA,EAAUA,QAAAA;AACVoB,gBAAAA,cAAAA,EAAc,CAAC,CAAC3B,SAAAA;gBAChB4B,eAAAA,EAAerB,QAAAA;AACfsB,gBAAAA,kBAAAA,EAAkB7B,YAAYY,OAAAA,GAAUI;;0BAE5CU,GAAA,CAACI,MAAAA,EAAAA;AAAMzB,gBAAAA,QAAAA,EAAAA;;AACNL,YAAAA,SAAAA,kBAAa0B,GAAA,CAACxB,gBAAAA,EAAAA;gBAAe6B,EAAAA,EAAInB,OAAAA;AAAUZ,gBAAAA,QAAAA,EAAAA;;;;AAGxD;AAEA,MAAMgC,QAAAA,iBAAWC,KAAAA,CAAMC,UAAU,CAAC/B,iBAAAA;;;;"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var propTypes: {
|
|
7
|
-
/** Label for the field */
|
|
8
|
-
label: PropTypes.Requireable<string>;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
2
|
+
declare const Toggle: React.ForwardRefExoticComponent<{
|
|
3
|
+
/** Label for the field */
|
|
4
|
+
label?: string;
|
|
5
|
+
} & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
|
|
11
6
|
export default Toggle;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
6
5
|
|
|
7
6
|
const Switch = /*#__PURE__*/ styled("label", {
|
|
8
|
-
target: "
|
|
7
|
+
target: "e185uavx0",
|
|
9
8
|
label: "Switch"
|
|
10
9
|
})("position:relative;display:inline-flex;margin:5px 0;");
|
|
11
|
-
const Input = /*#__PURE__*/ styled("input", {
|
|
12
|
-
target: "
|
|
10
|
+
const Input$1 = /*#__PURE__*/ styled("input", {
|
|
11
|
+
target: "e185uavx1",
|
|
13
12
|
label: "Input"
|
|
14
13
|
})("position:absolute;width:0;height:0;appearance:none;margin:0;& + span{position:relative;cursor:pointer;width:30px;height:18px;background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";transition:0.4s;border-radius:10px;padding:0 3px;margin:0 10px 0 5px;}& + span:before{position:absolute;content:'';height:14px;width:14px;left:1px;top:1px;border:1px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";border-radius:50%;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";transition:0.4s;}&:checked + span{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:checked + span:before{transform:translateX(18px);border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:focus + span:before{box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:hover ~ span{cursor:pointer;color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled + span{background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";cursor:not-allowed;}&:disabled + span:before{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}");
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Toggle Component
|
|
16
|
+
* @param props - Component props
|
|
17
|
+
* @param ref - Ref forwarded to the underlying HTMLInputElement
|
|
18
|
+
*/ function ToggleComponent(props, ref) {
|
|
16
19
|
return /*#__PURE__*/ jsxs(Switch, {
|
|
17
20
|
children: [
|
|
18
|
-
/*#__PURE__*/ jsx(Input, {
|
|
21
|
+
/*#__PURE__*/ jsx(Input$1, {
|
|
19
22
|
...props,
|
|
23
|
+
ref: ref,
|
|
20
24
|
type: "checkbox",
|
|
21
25
|
role: "switch",
|
|
22
26
|
"aria-checked": props.checked
|
|
@@ -28,9 +32,7 @@ function Toggle(props) {
|
|
|
28
32
|
]
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
|
-
Toggle
|
|
32
|
-
/** Label for the field */ label: PropTypes.string
|
|
33
|
-
};
|
|
35
|
+
const Toggle = /*#__PURE__*/ React.forwardRef(ToggleComponent);
|
|
34
36
|
|
|
35
37
|
export { Toggle as default };
|
|
36
38
|
//# sourceMappingURL=Toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.js","sources":["../../../src/components/Input/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"Toggle.js","sources":["../../../src/components/Input/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Switch = styled.label`\n position: relative;\n display: inline-flex;\n margin: 5px 0;\n`;\n\nconst Input = styled.input`\n position: absolute;\n width: 0;\n height: 0;\n appearance: none;\n margin: 0;\n\n & + span {\n position: relative;\n cursor: pointer;\n width: 30px;\n height: 18px;\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n transition: 0.4s;\n border-radius: 10px;\n padding: 0 3px;\n margin: 0 10px 0 5px;\n }\n & + span:before {\n position: absolute;\n content: '';\n height: 14px;\n width: 14px;\n left: 1px;\n top: 1px;\n border: 1px solid ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n border-radius: 50%;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: 0.4s;\n }\n\n /* checked */\n &:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:checked + span:before {\n transform: translateX(18px);\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* focus */\n &:enabled:focus + span:before {\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* hover */\n &:enabled:hover ~ span {\n cursor: pointer;\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* disabled */\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n cursor: not-allowed;\n }\n\n &:disabled + span:before {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n`;\n\ntype ToggleProps = {\n /** Label for the field */\n label?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * Toggle Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLInputElement\n */\nfunction ToggleComponent(props: ToggleProps, ref: React.Ref<HTMLInputElement>) {\n return (\n <Switch>\n <Input\n {...props}\n ref={ref}\n type=\"checkbox\"\n role=\"switch\"\n aria-checked={props.checked}\n />\n <span></span>\n <span>{props.label}</span>\n </Switch>\n );\n}\n\nconst Toggle = React.forwardRef(ToggleComponent);\nexport default Toggle;\n"],"names":["Switch","styled","Input","getThemeValue","THEME_NAME","LIGHT_GREY","DISABLED_BORDER","BACKGROUND","PRIMARY_LIGHT","PRIMARY","BORDER_LIGHT_COLOR","ToggleComponent","props","ref","_jsxs","_jsx","type","role","aria-checked","checked","span","label","Toggle","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,MAAAA,iBAASC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAMf,MAAMC,OAAAA,iBAAQD,MAAAA,CAAAA,OAAAA,EAAAA;;;qJAYcE,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,+KAAA,EAanCF,aAAAA,CAAcC,WAAWE,eAAe,CAAA,EAAA,sCAAA,EAExCH,cAAcC,UAAAA,CAAWG,UAAU,2DAMnCJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,oEAAA,EAK1CL,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,uDAAA,EAKxBN,cAAcC,UAAAA,CAAWI,aAAa,qBAC9CL,aAAAA,CAAcC,UAAAA,CAAWK,OAAO,CAAA,EAAA,gDAAA,EAMvCN,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,4BAAA,EAKhCN,cAAcC,UAAAA,CAAWE,eAAe,4CAI7BH,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,iEAAA,EAKnCF,aAAAA,CAAcC,WAAWM,kBAAkB,CAAA,EAAA,gBAAA,EAC/CP,aAAAA,CAAcC,UAAAA,CAAWE,eAAe,CAAA,EAAA,IAAA,CAAA;AAShE;;;;AAIC,IACD,SAASK,eAAAA,CAAgBC,KAAkB,EAAEC,GAAgC,EAAA;AACzE,IAAA,qBACIC,IAAA,CAACd,MAAAA,EAAAA;;0BACGe,GAAA,CAACb,OAAAA,EAAAA;AACI,gBAAA,GAAGU,KAAK;gBACTC,GAAAA,EAAKA,GAAAA;gBACLG,IAAAA,EAAK,UAAA;gBACLC,IAAAA,EAAK,QAAA;AACLC,gBAAAA,cAAAA,EAAcN,MAAMO;;0BAExBJ,GAAA,CAACK,MAAAA,EAAAA,EAAAA,CAAAA;0BACDL,GAAA,CAACK,MAAAA,EAAAA;AAAMR,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMS;;;;AAGzB;AAEA,MAAMC,MAAAA,iBAASC,KAAAA,CAAMC,UAAU,CAACb,eAAAA;;;;"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Props for the Menu component.
|
|
4
4
|
* @template T - The type of value(s) in the menu.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
type MenuProps<T> = {
|
|
7
7
|
/** Multiple Menu Items can be selected */
|
|
8
8
|
multiSelect?: boolean;
|
|
9
9
|
/** Value(s) selected */
|
|
10
10
|
value?: T | T[];
|
|
11
11
|
/** Callback when the selected value changes */
|
|
12
12
|
onChange?: (value: T | T[]) => void;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Menu component that allows selection of items from a list.
|
|
18
|
-
* Supports single and multi-select modes and keyboard navigation.
|
|
19
|
-
*
|
|
20
|
-
* @template T - The type of value(s) in the menu.
|
|
21
|
-
* @param {MenuProps<T> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>} props - The menu properties.
|
|
22
|
-
* @param {ForwardedRef<HTMLDivElement>} ref - The ref forwarded to the menu container.
|
|
23
|
-
*/
|
|
24
|
-
declare const Menu: React.ForwardRefExoticComponent<MenuProps<object> & Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>;
|
|
14
|
+
declare const Menu: <T>(props: MenuProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement;
|
|
25
15
|
export default Menu;
|
|
@@ -5,7 +5,7 @@ import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
|
5
5
|
import MenuContext from './MenuContext.js';
|
|
6
6
|
|
|
7
7
|
const MenuContainer = /*#__PURE__*/ styled("div", {
|
|
8
|
-
target: "
|
|
8
|
+
target: "e1qc23xy0",
|
|
9
9
|
label: "MenuContainer"
|
|
10
10
|
})("flex:1;display:flex;flex-direction:column;& div:last-child{border-bottom:none;}&:focus-within{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}");
|
|
11
11
|
/**
|
|
@@ -13,11 +13,17 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
|
|
|
13
13
|
* Supports single and multi-select modes and keyboard navigation.
|
|
14
14
|
*
|
|
15
15
|
* @template T - The type of value(s) in the menu.
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
* @param props - The menu properties.
|
|
17
|
+
* @param ref - The ref forwarded to the menu container.
|
|
18
|
+
*/ /**
|
|
19
|
+
* Menu Component
|
|
20
|
+
* @template T - The type of value(s) in the menu.
|
|
21
|
+
* @param props - Component props
|
|
22
|
+
* @param ref - Ref forwarded to the underlying HTMLDivElement
|
|
23
|
+
*/ function MenuInner(props, ref) {
|
|
24
|
+
const { multiSelect = false, onChange, value: propValue, children, ...rest } = props;
|
|
25
|
+
// State holds either a single T or an array of T when multiSelect
|
|
26
|
+
const [value, setValue] = useState(propValue);
|
|
21
27
|
/**
|
|
22
28
|
* Updates the selected value(s).
|
|
23
29
|
* Handles both single and multi-select logic.
|
|
@@ -35,6 +41,10 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
|
|
|
35
41
|
val
|
|
36
42
|
];
|
|
37
43
|
}
|
|
44
|
+
} else {
|
|
45
|
+
newVal = [
|
|
46
|
+
val
|
|
47
|
+
];
|
|
38
48
|
}
|
|
39
49
|
} else {
|
|
40
50
|
newVal = val;
|
|
@@ -100,10 +110,11 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
|
|
|
100
110
|
firstItem?.focus();
|
|
101
111
|
}
|
|
102
112
|
};
|
|
103
|
-
return
|
|
113
|
+
return(// @ts-expect-error Generic context typing
|
|
114
|
+
/*#__PURE__*/ jsx(MenuContext.Provider, {
|
|
104
115
|
value: {
|
|
105
|
-
value,
|
|
106
|
-
multiSelect,
|
|
116
|
+
value: value,
|
|
117
|
+
multiSelect: !!multiSelect,
|
|
107
118
|
updateValue
|
|
108
119
|
},
|
|
109
120
|
children: /*#__PURE__*/ jsx(MenuContainer, {
|
|
@@ -114,14 +125,11 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
|
|
|
114
125
|
tabIndex: 0,
|
|
115
126
|
onKeyDown: handleKeyDown,
|
|
116
127
|
onFocus: focusHandler,
|
|
117
|
-
children:
|
|
128
|
+
children: children
|
|
118
129
|
})
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
Menu
|
|
122
|
-
Menu.defaultProps = {
|
|
123
|
-
multiSelect: false
|
|
124
|
-
};
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
const Menu = /*#__PURE__*/ React.forwardRef(MenuInner);
|
|
125
133
|
|
|
126
134
|
export { Menu as default };
|
|
127
135
|
//# sourceMappingURL=Menu.js.map
|