no-frills-ui 0.0.14-alpha.0 → 0.0.14-alpha.10
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 +63 -24
- package/dist/index.js +3550 -4336
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +11 -16
- package/lib-esm/components/Accordion/Accordion.js +25 -29
- 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 +111 -109
- 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 +31 -51
- 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 -38
- 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 +18 -40
- 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 -42
- 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 -32
- 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 -46
- 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 +18 -13
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +8 -3
- package/lib-esm/components/Chip/Chip.js +44 -42
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +31 -0
- package/lib-esm/components/ChipInput/ChipInput.js +198 -0
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -0
- package/lib-esm/components/ChipInput/index.d.ts +1 -0
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +44 -28
- 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 +49 -33
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +40 -18
- package/lib-esm/components/Dialog/Dialog.js +125 -70
- 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 +78 -49
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +43 -14
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +128 -19
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +41 -0
- package/lib-esm/components/DragAndDrop/DragItem.js +253 -36
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +25 -3
- package/lib-esm/components/DragAndDrop/types.js +9 -6
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +86 -22
- package/lib-esm/components/Drawer/Drawer.js +176 -97
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Drawer/index.d.ts +1 -1
- package/lib-esm/components/Groups/Group.d.ts +5 -8
- package/lib-esm/components/Groups/Group.js +34 -79
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.js +8 -17
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +51 -118
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +11 -12
- package/lib-esm/components/Input/Dropdown.js +133 -52
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +3 -3
- package/lib-esm/components/Input/Input.js +61 -109
- 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 +35 -79
- 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 +34 -71
- 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 +75 -122
- 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 +64 -108
- 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 +31 -80
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +8 -6
- package/lib-esm/components/Menu/Menu.js +116 -31
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +11 -5
- package/lib-esm/components/Menu/MenuContext.js +6 -2
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +7 -4
- package/lib-esm/components/Menu/MenuItem.js +46 -47
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +75 -16
- package/lib-esm/components/Modal/Modal.js +150 -51
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +46 -39
- package/lib-esm/components/Notification/Notification.js +80 -87
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +19 -5
- package/lib-esm/components/Notification/NotificationManager.js +177 -79
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +6 -3
- package/lib-esm/components/Notification/style.js +64 -140
- 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.js +9 -10
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +159 -126
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -12
- package/lib-esm/components/Spinner/Spinner.js +22 -27
- 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 +18 -25
- 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 +104 -102
- 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 +9 -15
- 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 +97 -55
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +34 -7
- package/lib-esm/components/Toast/Toast.js +200 -109
- 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 +52 -67
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/components/index.d.ts +1 -0
- package/lib-esm/components/index.js +43 -20
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/icons/CheckCircle.d.ts +1 -1
- package/lib-esm/icons/CheckCircle.js +22 -4
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/Close.d.ts +1 -1
- package/lib-esm/icons/Close.js +22 -4
- package/lib-esm/icons/Close.js.map +1 -1
- package/lib-esm/icons/DragIndicator.d.ts +1 -1
- package/lib-esm/icons/DragIndicator.js +22 -4
- package/lib-esm/icons/DragIndicator.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.d.ts +1 -1
- package/lib-esm/icons/ErrorOutline.js +16 -4
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/ExpandMore.d.ts +1 -1
- package/lib-esm/icons/ExpandMore.js +22 -4
- package/lib-esm/icons/ExpandMore.js.map +1 -1
- package/lib-esm/icons/FiberManualRecord.d.ts +1 -1
- package/lib-esm/icons/FiberManualRecord.js +24 -4
- package/lib-esm/icons/FiberManualRecord.js.map +1 -1
- package/lib-esm/icons/Info.d.ts +1 -1
- package/lib-esm/icons/Info.js +22 -4
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.d.ts +1 -1
- package/lib-esm/icons/ReportProblem.js +22 -4
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts +34 -4
- package/lib-esm/shared/LayerManager.js +248 -114
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +58 -27
- package/lib-esm/shared/constants.js +62 -26
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.js +21 -24
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +130 -72
- package/lib-esm/components/Accordion/index.js +0 -3
- package/lib-esm/components/Accordion/index.js.map +0 -1
- package/lib-esm/components/Badge/index.js +0 -2
- package/lib-esm/components/Badge/index.js.map +0 -1
- package/lib-esm/components/Button/index.js +0 -6
- package/lib-esm/components/Button/index.js.map +0 -1
- package/lib-esm/components/Card/index.js +0 -3
- package/lib-esm/components/Card/index.js.map +0 -1
- package/lib-esm/components/Chip/index.js +0 -2
- package/lib-esm/components/Chip/index.js.map +0 -1
- package/lib-esm/components/Dialog/index.js +0 -5
- package/lib-esm/components/Dialog/index.js.map +0 -1
- package/lib-esm/components/DragAndDrop/index.js +0 -3
- package/lib-esm/components/DragAndDrop/index.js.map +0 -1
- package/lib-esm/components/Drawer/index.js +0 -2
- package/lib-esm/components/Drawer/index.js.map +0 -1
- package/lib-esm/components/Groups/index.js +0 -3
- package/lib-esm/components/Groups/index.js.map +0 -1
- package/lib-esm/components/Input/index.js +0 -9
- package/lib-esm/components/Input/index.js.map +0 -1
- package/lib-esm/components/Menu/index.js +0 -3
- package/lib-esm/components/Menu/index.js.map +0 -1
- package/lib-esm/components/Modal/index.js +0 -2
- package/lib-esm/components/Modal/index.js.map +0 -1
- package/lib-esm/components/Notification/index.js +0 -3
- package/lib-esm/components/Notification/index.js.map +0 -1
- package/lib-esm/components/Popover/index.js +0 -2
- package/lib-esm/components/Popover/index.js.map +0 -1
- package/lib-esm/components/Spinner/index.js +0 -2
- package/lib-esm/components/Spinner/index.js.map +0 -1
- package/lib-esm/components/Stepper/index.js +0 -4
- package/lib-esm/components/Stepper/index.js.map +0 -1
- package/lib-esm/components/Tabs/index.js +0 -3
- package/lib-esm/components/Tabs/index.js.map +0 -1
- package/lib-esm/components/Toast/ToastStory.js +0 -35
- package/lib-esm/components/Toast/ToastStory.js.map +0 -1
- package/lib-esm/components/Toast/index.js +0 -2
- package/lib-esm/components/Toast/index.js.map +0 -1
- package/lib-esm/components/Tooltip/index.js +0 -2
- package/lib-esm/components/Tooltip/index.js.map +0 -1
- package/lib-esm/icons/index.js +0 -9
- package/lib-esm/icons/index.js.map +0 -1
- package/lib-esm/index.js +0 -2
- package/lib-esm/index.js.map +0 -1
|
@@ -1,66 +1,147 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
import Input from './Input.js';
|
|
5
|
+
import Popover, { POPOVER_POSITION } from '../Popover/Popover.js';
|
|
6
|
+
import Menu from '../Menu/Menu.js';
|
|
7
|
+
import ExpandMore from '../../icons/ExpandMore.js';
|
|
8
|
+
|
|
9
|
+
const ArrowContainer = /*#__PURE__*/ styled("span", {
|
|
10
|
+
target: "eqzh0a30",
|
|
11
|
+
label: "ArrowContainer"
|
|
12
|
+
})("position:absolute;right:12px;top:16px;pointer-events:none;");
|
|
13
|
+
/**
|
|
14
|
+
* Dropdown component that allows selection from a list of options.
|
|
15
|
+
* Supports single and multi-select modes.
|
|
16
|
+
*
|
|
17
|
+
* @template T - The type of the value(s) in the dropdown.
|
|
18
|
+
* @param props - The properties for the Dropdown component.
|
|
19
|
+
* @returns The rendered Dropdown component.
|
|
20
|
+
*/ function DropdownComponent(props, outerRef) {
|
|
21
|
+
const { multiSelect = false, onChange, children, value: propValue, label, errorText, required, disabled, ...rest } = props;
|
|
16
22
|
const [open, setOpen] = useState(false);
|
|
17
|
-
const [value, setValue] = useState(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
prev === null || prev === void 0 ? void 0 : prev.focus();
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const next = (_b = currentBtn === null || currentBtn === void 0 ? void 0 : currentBtn.nextElementSibling) === null || _b === void 0 ? void 0 : _b.closest('button');
|
|
35
|
-
next === null || next === void 0 ? void 0 : next.focus();
|
|
23
|
+
const [value, setValue] = useState(propValue);
|
|
24
|
+
const id = React.useId();
|
|
25
|
+
const menuId = `${id}-menu`;
|
|
26
|
+
const menuRef = React.useRef(null);
|
|
27
|
+
const triggerRef = React.useRef(null);
|
|
28
|
+
// Focus menu when opened
|
|
29
|
+
useEffect(()=>{
|
|
30
|
+
if (open) {
|
|
31
|
+
// Wait for Popover to fully open and focus itself first
|
|
32
|
+
// Then move focus to the first menu item
|
|
33
|
+
const timer = setTimeout(()=>{
|
|
34
|
+
const firstItem = menuRef.current?.querySelector('[role="option"]');
|
|
35
|
+
if (firstItem) {
|
|
36
|
+
firstItem.focus();
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
-
return
|
|
38
|
+
}, 100); // Wait after Popover has set initial focus
|
|
39
|
+
return ()=>clearTimeout(timer);
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
41
|
+
}, [
|
|
42
|
+
open
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* Handles keydown events on the input trigger.
|
|
46
|
+
* Opens the menu on 'Enter', 'Space', 'ArrowDown', or 'ArrowUp'.
|
|
47
|
+
*
|
|
48
|
+
* @param {React.KeyboardEvent<HTMLInputElement>} e - The keyboard event.
|
|
49
|
+
*/ const onKeyDown = (e)=>{
|
|
50
|
+
if ([
|
|
51
|
+
'ArrowDown',
|
|
52
|
+
'ArrowUp',
|
|
53
|
+
'Enter',
|
|
54
|
+
' '
|
|
55
|
+
].includes(e.key)) {
|
|
56
|
+
e.preventDefault();
|
|
50
57
|
setOpen(true);
|
|
51
58
|
}
|
|
52
59
|
};
|
|
53
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Handles changes to the dropdown value.
|
|
62
|
+
* Updates local state and calls the external onChange handler.
|
|
63
|
+
* Closes the dropdown if not in multi-select mode.
|
|
64
|
+
*
|
|
65
|
+
* @param {T | T[]} val - The new value(s).
|
|
66
|
+
*/ const changeHandler = (val)=>{
|
|
54
67
|
setValue(val);
|
|
55
|
-
onChange
|
|
68
|
+
onChange?.(val);
|
|
56
69
|
// Close dropdown after selection if not multiSelect
|
|
57
70
|
if (!multiSelect) {
|
|
58
71
|
setOpen(false);
|
|
72
|
+
triggerRef.current?.focus();
|
|
59
73
|
}
|
|
60
74
|
};
|
|
61
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Toggles the dropdown open state on click.
|
|
77
|
+
*/ const clickHandler = ()=>setOpen(true);
|
|
78
|
+
const TriggerElement = /*#__PURE__*/ React.forwardRef((passedProps, ref)=>{
|
|
79
|
+
// Helper to assign both internal triggerRef and external forwarded ref
|
|
80
|
+
const assignRefs = (node)=>{
|
|
81
|
+
triggerRef.current = node;
|
|
82
|
+
if (!outerRef) return;
|
|
83
|
+
if (typeof outerRef === 'function') {
|
|
84
|
+
outerRef(node);
|
|
85
|
+
} else {
|
|
86
|
+
outerRef.current = node;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Combine the ref passed by parent with our assignRefs so both are updated
|
|
90
|
+
const combinedRef = (node)=>{
|
|
91
|
+
assignRefs(node);
|
|
92
|
+
if (typeof ref === 'function') {
|
|
93
|
+
ref(node);
|
|
94
|
+
} else if (ref) {
|
|
95
|
+
ref.current = node;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
99
|
+
children: [
|
|
100
|
+
/*#__PURE__*/ jsx(Input, {
|
|
101
|
+
...rest,
|
|
102
|
+
...passedProps,
|
|
103
|
+
ref: combinedRef,
|
|
104
|
+
type: "text",
|
|
105
|
+
value: value && String(value),
|
|
106
|
+
label: label,
|
|
107
|
+
errorText: errorText,
|
|
108
|
+
onClick: clickHandler,
|
|
109
|
+
onKeyDown: onKeyDown,
|
|
110
|
+
required: required,
|
|
111
|
+
disabled: disabled,
|
|
112
|
+
readOnly: true,
|
|
113
|
+
role: "combobox",
|
|
114
|
+
"aria-haspopup": "listbox",
|
|
115
|
+
"aria-expanded": open,
|
|
116
|
+
"aria-controls": menuId
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ jsx(ArrowContainer, {
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
children: /*#__PURE__*/ jsx(ExpandMore, {})
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
TriggerElement.displayName = 'DropdownTrigger';
|
|
126
|
+
return /*#__PURE__*/ jsx(Popover, {
|
|
127
|
+
position: POPOVER_POSITION.BOTTOM_LEFT,
|
|
128
|
+
open: open,
|
|
129
|
+
element: TriggerElement,
|
|
130
|
+
onClose: ()=>{
|
|
131
|
+
setOpen(false);
|
|
132
|
+
triggerRef.current?.focus();
|
|
133
|
+
},
|
|
134
|
+
children: /*#__PURE__*/ jsx(Menu, {
|
|
135
|
+
ref: menuRef,
|
|
136
|
+
id: menuId,
|
|
137
|
+
value: value,
|
|
138
|
+
multiSelect: multiSelect,
|
|
139
|
+
onChange: changeHandler,
|
|
140
|
+
children: children
|
|
141
|
+
})
|
|
142
|
+
});
|
|
62
143
|
}
|
|
63
|
-
Dropdown
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=Dropdown.js.map
|
|
144
|
+
const Dropdown = /*#__PURE__*/ React.forwardRef(DropdownComponent);
|
|
145
|
+
|
|
146
|
+
export { Dropdown as default };
|
|
147
|
+
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/components/Input/Dropdown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CAAC;QACnB,CAAC;IACL,CAAC,CAAA;IAED,OAAO,CACH,KAAC,OAAO,IACJ,QAAQ,EAAE,gBAAgB,CAAC,WAAW,EACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EAAE,CAAC,CACX,8BACA,KAAC,KAAK,IACF,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,EACF,KAAC,cAAc,cAAC,KAAC,UAAU,KAAG,GAAiB,IAC5C,CACN,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,YAE7B,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,YAChE,KAAK,CAAC,QAAQ,GACZ,GACD,CACb,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,YAAY,GAAG;IACpB,WAAW,EAAE,KAAK;CACrB,CAAA"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Input/Dropdown.tsx"],"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> = React.PropsWithChildren<{\n /** Value of the control */\n value?: T | T[];\n /**\n * If multiple elements can be selected\n * @default false\n */\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}> &\n React.InputHTMLAttributes<HTMLInputElement>;\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 props - The properties for the Dropdown component.\n * @returns The rendered Dropdown component.\n */\nfunction DropdownComponent<T extends object>(\n props: DropdownProps<T>,\n outerRef: React.Ref<HTMLInputElement>,\n) {\n const {\n multiSelect = false,\n onChange,\n children,\n value: propValue,\n label,\n errorText,\n required,\n disabled,\n ...rest\n } = props;\n const [open, setOpen] = useState(false);\n const [value, setValue] = useState<T | T[] | undefined>(propValue);\n const id = React.useId();\n const menuId = `${id}-menu`;\n const menuRef = React.useRef<HTMLDivElement | null>(null);\n const triggerRef = React.useRef<HTMLInputElement | null>(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 // Helper to assign both internal triggerRef and external forwarded ref\n const assignRefs = (node: HTMLInputElement | null) => {\n triggerRef.current = node;\n\n if (!outerRef) return;\n if (typeof outerRef === 'function') {\n outerRef(node);\n } else {\n (outerRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n };\n\n // Combine the ref passed by parent with our assignRefs so both are updated\n const combinedRef: React.Ref<HTMLInputElement> = (node) => {\n assignRefs(node);\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n };\n\n return (\n <>\n <Input\n {...rest}\n {...passedProps}\n ref={combinedRef}\n type=\"text\"\n value={value && String(value)}\n label={label}\n errorText={errorText}\n onClick={clickHandler}\n onKeyDown={onKeyDown}\n required={required}\n disabled={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 });\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 {children}\n </Menu>\n </Popover>\n );\n}\n\nconst Dropdown = React.forwardRef(DropdownComponent);\nexport default Dropdown;\n"],"names":["ArrowContainer","styled","DropdownComponent","props","outerRef","multiSelect","onChange","children","value","propValue","label","errorText","required","disabled","rest","open","setOpen","useState","setValue","id","React","useId","menuId","menuRef","useRef","triggerRef","useEffect","timer","setTimeout","firstItem","current","querySelector","focus","clearTimeout","onKeyDown","e","includes","key","preventDefault","changeHandler","val","clickHandler","TriggerElement","forwardRef","passedProps","ref","assignRefs","node","combinedRef","_jsxs","_Fragment","_jsx","Input","type","String","onClick","readOnly","role","aria-haspopup","aria-expanded","aria-controls","aria-hidden","ExpandMore","displayName","Popover","position","POPOVER_POSITION","BOTTOM_LEFT","element","onClose","Menu","Dropdown"],"mappings":";;;;;;;;AA4BA,MAAMA,cAAAA,iBAAiBC,MAAAA,CAAAA,MAAAA,EAAAA;;;;AAOvB;;;;;;;AAOC,IACD,SAASC,iBAAAA,CACLC,KAAuB,EACvBC,QAAqC,EAAA;IAErC,MAAM,EACFC,cAAc,KAAK,EACnBC,QAAQ,EACRC,QAAQ,EACRC,KAAAA,EAAOC,SAAS,EAChBC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACR,GAAGC,IAAAA,EACN,GAAGX,KAAAA;AACJ,IAAA,MAAM,CAACY,IAAAA,EAAMC,OAAAA,CAAQ,GAAGC,QAAAA,CAAS,KAAA,CAAA;AACjC,IAAA,MAAM,CAACT,KAAAA,EAAOU,QAAAA,CAAS,GAAGD,QAAAA,CAA8BR,SAAAA,CAAAA;IACxD,MAAMU,EAAAA,GAAKC,MAAMC,KAAK,EAAA;AACtB,IAAA,MAAMC,MAAAA,GAAS,CAAA,EAAGH,EAAAA,CAAG,KAAK,CAAC;IAC3B,MAAMI,OAAAA,GAAUH,KAAAA,CAAMI,MAAM,CAAwB,IAAA,CAAA;IACpD,MAAMC,UAAAA,GAAaL,KAAAA,CAAMI,MAAM,CAA0B,IAAA,CAAA;;IAGzDE,SAAAA,CAAU,IAAA;AACN,QAAA,IAAIX,IAAAA,EAAM;;;AAGN,YAAA,MAAMY,QAAQC,UAAAA,CAAW,IAAA;AACrB,gBAAA,MAAMC,SAAAA,GAAYN,OAAAA,CAAQO,OAAO,EAAEC,aAAAA,CAAc,iBAAA,CAAA;AACjD,gBAAA,IAAIF,SAAAA,EAAW;AACXA,oBAAAA,SAAAA,CAAUG,KAAK,EAAA;AACnB,gBAAA;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,KAAA,CAAA;AACRS,YAAAA,UAAAA,CAAWK,OAAO,EAAEE,KAAAA,EAAAA;AACxB,QAAA,CAAA;AAEA,QAAA,QAAA,gBAAAmB,GAAA,CAACmB,IAAAA,EAAAA;YACGzB,GAAAA,EAAKtB,OAAAA;YACLJ,EAAAA,EAAIG,MAAAA;YACJd,KAAAA,EAAOA,KAAAA;YACPH,WAAAA,EAAaA,WAAAA;YACbC,QAAAA,EAAUiC,aAAAA;AAEThC,YAAAA,QAAAA,EAAAA;;;AAIjB;AAEA,MAAMgE,QAAAA,iBAAWnD,KAAAA,CAAMuB,UAAU,CAACzC,iBAAAA;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type InputProps =
|
|
2
|
+
type InputProps = {
|
|
3
3
|
/** Label for the field */
|
|
4
4
|
label?: string;
|
|
5
|
-
/** Error
|
|
5
|
+
/** Error text to be shown below the field */
|
|
6
6
|
errorText?: string;
|
|
7
|
-
}
|
|
7
|
+
} & React.AllHTMLAttributes<HTMLInputElement>;
|
|
8
8
|
declare const Input: React.ForwardRefExoticComponent<Omit<InputProps, "as"> & React.RefAttributes<HTMLInputElement>>;
|
|
9
9
|
export default Input;
|
|
@@ -1,138 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import React, { useState, useId, useEffect } from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
|
-
import
|
|
6
|
-
const Label = styled.label `
|
|
7
|
-
display: inline-flex;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
flex: 1;
|
|
10
|
-
position: relative;
|
|
11
|
-
margin: 10px 5px;
|
|
12
|
-
`;
|
|
13
|
-
const TextField = styled.input `
|
|
14
|
-
border: none;
|
|
15
|
-
color: inherit;
|
|
16
|
-
padding: 0 8px;
|
|
17
|
-
line-height: 30px;
|
|
18
|
-
min-height: 30px;
|
|
19
|
-
width: 250px;
|
|
20
|
-
border-radius: 3px;
|
|
21
|
-
border: 1px solid var(--border-color, ${constants.BORDER_COLOR});
|
|
22
|
-
display: inline-block;
|
|
23
|
-
background-color: var(--background, ${constants.BACKGROUND});
|
|
4
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
24
5
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Disabled */
|
|
36
|
-
&:disabled {
|
|
37
|
-
border-color: var(--disabled-border, ${constants.DISABLED_BORDER});
|
|
38
|
-
background-color: var(--disabled-background, ${constants.DISABLED_BACKGROUND});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&:disabled + span {
|
|
42
|
-
color: #777;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Invalid */
|
|
46
|
-
&:focus:invalid {
|
|
47
|
-
border-color: var(--error, ${constants.ERROR});
|
|
48
|
-
box-shadow: 0 0 0 4px var(--error-light, ${constants.ERROR_LIGHT});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
${props => props.touched ? `
|
|
6
|
+
const Label$5 = /*#__PURE__*/ styled("label", {
|
|
7
|
+
target: "e13ukqtd0",
|
|
8
|
+
label: "Label"
|
|
9
|
+
})("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;");
|
|
10
|
+
const TextField$1 = /*#__PURE__*/ styled("input", {
|
|
11
|
+
target: "e13ukqtd1",
|
|
12
|
+
label: "TextField"
|
|
13
|
+
})("outline:none;color:inherit;padding:0 8px;line-height:30px;min-height:30px;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), ";padding:0 8px;}&: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 ? `
|
|
52
14
|
&:invalid {
|
|
53
|
-
border-color:
|
|
15
|
+
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
54
16
|
}
|
|
55
17
|
|
|
56
18
|
&:invalid + span {
|
|
57
|
-
color:
|
|
19
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
58
20
|
}
|
|
59
|
-
` : ''
|
|
60
|
-
|
|
61
|
-
/** Error */
|
|
62
|
-
${props => props.errorText ? `
|
|
63
|
-
border-color: var(--error, ${constants.ERROR});
|
|
21
|
+
` : '', " \n ", (props)=>props.errorText ? `
|
|
22
|
+
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
64
23
|
|
|
65
24
|
& + span {
|
|
66
|
-
color:
|
|
25
|
+
color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
67
26
|
}
|
|
68
|
-
` : ''}
|
|
69
|
-
|
|
70
|
-
/** Required */
|
|
71
|
-
&:required + span:after {
|
|
72
|
-
content: '*';
|
|
73
|
-
margin-left: 2px;
|
|
74
|
-
color: var(--error, ${constants.ERROR});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Label Animation */
|
|
27
|
+
` : '', " \n &:required + span:after{content:'*';margin-left:2px;color:", getThemeValue(THEME_NAME.ERROR), ";}& + span{position:absolute;padding:0 5px;top:0px;left:4px;font-size:14px;line-height:32px;transition:all 300ms ease;}", (props)=>props.value !== '' ? `
|
|
78
28
|
& + span {
|
|
79
|
-
position: absolute;
|
|
80
|
-
padding: 0 5px;
|
|
81
|
-
top: 0px;
|
|
82
|
-
left: 4px;
|
|
83
|
-
font-size: 14px;
|
|
84
|
-
line-height: 32px;
|
|
85
|
-
transition: all 300ms ease;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
${props => props.value !== '' ? `
|
|
89
|
-
& + span {
|
|
90
|
-
top: -8px;
|
|
91
|
-
background: var(--background, ${constants.BACKGROUND});
|
|
92
|
-
font-size: 12px;
|
|
93
|
-
line-height: 14px;
|
|
94
|
-
}
|
|
95
|
-
` : ''}
|
|
96
|
-
|
|
97
|
-
&:focus + span, &:placeholder-shown + span {
|
|
98
29
|
top: -8px;
|
|
99
|
-
background:
|
|
30
|
+
background: ${getThemeValue(THEME_NAME.BACKGROUND)};
|
|
100
31
|
font-size: 12px;
|
|
101
32
|
line-height: 14px;
|
|
102
33
|
}
|
|
103
|
-
|
|
104
|
-
const ErrorContainer = styled
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
margin-left: 3px;
|
|
110
|
-
`;
|
|
111
|
-
const Input = React.forwardRef((props, ref) => {
|
|
34
|
+
` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
|
|
35
|
+
const ErrorContainer$3 = /*#__PURE__*/ styled("div", {
|
|
36
|
+
target: "e13ukqtd2",
|
|
37
|
+
label: "ErrorContainer"
|
|
38
|
+
})("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
|
|
39
|
+
const Input$2 = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
112
40
|
const [touched, setTouched] = useState(false);
|
|
113
41
|
const [value, setValue] = useState(props.value || '');
|
|
114
|
-
const
|
|
42
|
+
const errorId = useId();
|
|
43
|
+
useEffect(()=>{
|
|
44
|
+
if (props.value !== undefined) {
|
|
45
|
+
setValue(props.value);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
props.value
|
|
49
|
+
]);
|
|
50
|
+
const handleFocus = (e)=>{
|
|
115
51
|
setTouched(true);
|
|
116
52
|
if (props.onFocus) {
|
|
117
53
|
props.onFocus(e);
|
|
118
54
|
}
|
|
119
55
|
};
|
|
120
|
-
const onChangeHandler = (e)
|
|
56
|
+
const onChangeHandler = (e)=>{
|
|
121
57
|
if (props.onChange) {
|
|
122
58
|
setValue(e.target.value);
|
|
123
59
|
props.onChange(e);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
60
|
+
} else {
|
|
126
61
|
setValue(e.target.value);
|
|
127
62
|
}
|
|
128
63
|
};
|
|
129
|
-
return (
|
|
64
|
+
return /*#__PURE__*/ jsxs(Label$5, {
|
|
65
|
+
children: [
|
|
66
|
+
/*#__PURE__*/ jsx(TextField$1, {
|
|
67
|
+
...props,
|
|
68
|
+
ref: ref,
|
|
69
|
+
value: value,
|
|
70
|
+
onChange: onChangeHandler,
|
|
71
|
+
onFocus: handleFocus,
|
|
72
|
+
touched: touched,
|
|
73
|
+
"aria-invalid": !!props.errorText,
|
|
74
|
+
"aria-required": props.required,
|
|
75
|
+
"aria-describedby": props.errorText ? errorId : undefined
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsx("span", {
|
|
78
|
+
children: props.label
|
|
79
|
+
}),
|
|
80
|
+
props.errorText && /*#__PURE__*/ jsx(ErrorContainer$3, {
|
|
81
|
+
id: errorId,
|
|
82
|
+
children: props.errorText
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
});
|
|
130
86
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/** Error text to be shown below the field */
|
|
136
|
-
errorText: PropTypes.string,
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=Input.js.map
|
|
87
|
+
Input$2.displayName = 'Input';
|
|
88
|
+
|
|
89
|
+
export { Input$2 as default };
|
|
90
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype InputProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.AllHTMLAttributes<HTMLInputElement>;\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 padding: 0 8px;\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';\nexport default Input;\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","Input","React","forwardRef","ref","setTouched","useState","setValue","errorId","useId","useEffect","undefined","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","_jsx","aria-invalid","aria-required","required","aria-describedby","span","label","id","displayName"],"mappings":";;;;;AAeA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAOd,MAAMC,WAAAA,iBAAYD,MAAAA,CAAAA,OAAAA,EAAAA;;;gIAQME,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,iCAAA,EAKnCH,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,0CAAA,EAKvDP,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,CA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;AAGpE,CAAA;AAEAG,OAAAA,CAAM0B,WAAW,GAAG,OAAA;;;;"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Label for the field */
|
|
7
|
-
label: PropTypes.Requireable<string>;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
2
|
+
declare const Radio: React.ForwardRefExoticComponent<{
|
|
3
|
+
/** Label for the field */
|
|
4
|
+
label?: string;
|
|
5
|
+
} & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
|
|
10
6
|
export default Radio;
|
|
@@ -1,81 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
&:enabled:focus::before {
|
|
34
|
-
border: 1px solid var(--primary, ${constants.PRIMARY});
|
|
35
|
-
box-shadow: 0 0 0 3px var(--primary, ${constants.PRIMARY_LIGHT});
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:enabled:checked:focus::before {
|
|
40
|
-
border: 1px solid var(--primary, ${constants.PRIMARY});
|
|
41
|
-
box-shadow: 0 0 0 3px var(--primary, ${constants.PRIMARY_LIGHT}),
|
|
42
|
-
inset 0 0 0 3px var(--background, ${constants.BACKGROUND});
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* hover */
|
|
47
|
-
&:enabled:hover::before {
|
|
48
|
-
border: 1px solid var(--primary, ${constants.PRIMARY});
|
|
49
|
-
cursor: pointer;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&:enabled:hover + span {
|
|
53
|
-
color: var(--primary, ${constants.PRIMARY});
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* disabled */
|
|
58
|
-
&:disabled::before {
|
|
59
|
-
border: 1px solid var(--disabled-border, ${constants.DISABLED_BORDER});
|
|
60
|
-
background-color: var(--light-grey, ${constants.LIGHT_GREY});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&:disabled:checked::before {
|
|
64
|
-
border: 1px solid var(--disabled-border, ${constants.DISABLED_BORDER});
|
|
65
|
-
background-color: var(--disabled-border, ${constants.DISABLED_BORDER});
|
|
66
|
-
box-shadow: inset 0 0 0 3px var(--background, ${constants.BACKGROUND});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&:disabled + span {
|
|
70
|
-
color: var(--disabled-border, ${constants.DISABLED_BORDER});
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
function Radio(props) {
|
|
74
|
-
return (_jsxs(Label, { children: [_jsx(Input, Object.assign({}, props, { type: 'radio' })), _jsx("span", { children: props.label })] }));
|
|
4
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
|
+
|
|
6
|
+
const Label$1 = /*#__PURE__*/ styled("label", {
|
|
7
|
+
target: "e10nk2o50",
|
|
8
|
+
label: "Label"
|
|
9
|
+
})("display:inline-flex;align-items:center;margin:5px 0;cursor:pointer;position:relative;");
|
|
10
|
+
const StyledRadio = /*#__PURE__*/ styled("span", {
|
|
11
|
+
target: "e10nk2o51",
|
|
12
|
+
label: "StyledRadio"
|
|
13
|
+
})("width:16px;height:16px;margin-right:5px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";border-radius:50%;display:block;transition:background-color 0.3s ease;position:relative;flex-shrink:0;&::after{content:'';width:100%;height:100%;border-radius:50%;position:absolute;top:0;left:0;box-shadow:inset 0 0 0 3px ", getThemeValue(THEME_NAME.BACKGROUND), ";opacity:0;transition:opacity 0.2s ease;}");
|
|
14
|
+
const HiddenInput = /*#__PURE__*/ styled("input", {
|
|
15
|
+
target: "e10nk2o52",
|
|
16
|
+
label: "HiddenInput"
|
|
17
|
+
})("opacity:0;width:0;height:0;position:absolute;margin:0;&:checked + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";background-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:checked + ", StyledRadio, "::after{opacity:1;}&:enabled:focus + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:checked:focus + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:hover + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:hover ~ span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";cursor:not-allowed;}&:disabled:checked + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";cursor:not-allowed;}");
|
|
18
|
+
function RadioComponent(props, ref) {
|
|
19
|
+
const { label, ...rest } = props;
|
|
20
|
+
return /*#__PURE__*/ jsxs(Label$1, {
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ jsx(HiddenInput, {
|
|
23
|
+
...rest,
|
|
24
|
+
ref: ref,
|
|
25
|
+
type: "radio"
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsx(StyledRadio, {}),
|
|
28
|
+
/*#__PURE__*/ jsx("span", {
|
|
29
|
+
children: label
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
75
33
|
}
|
|
76
|
-
Radio
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
export default Radio;
|
|
81
|
-
//# sourceMappingURL=Radio.js.map
|
|
34
|
+
const Radio = /*#__PURE__*/ React.forwardRef(RadioComponent);
|
|
35
|
+
|
|
36
|
+
export { Radio as default };
|
|
37
|
+
//# sourceMappingURL=Radio.js.map
|