@festo-ui/react 9.0.1 → 10.0.0-dev.827
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/Accordion.d.ts +3 -3
- package/dist/components/accordion/Accordion.js +2 -1
- package/dist/components/accordion/accordion-header/AccordionHeader.js +1 -0
- package/dist/components/accordion/accordion-item/AccordionItem.d.ts +1 -1
- package/dist/components/accordion/accordion-item/AccordionItem.js +2 -1
- package/dist/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +1 -0
- package/dist/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +1 -0
- package/dist/components/bottom-sheet/BottomSheet.d.ts +2 -3
- package/dist/components/bottom-sheet/BottomSheet.js +7 -4
- package/dist/components/breadcrumb/Breadcrumb.d.ts +9 -9
- package/dist/components/breadcrumb/Breadcrumb.js +86 -26
- package/dist/components/button/Button.js +1 -0
- package/dist/components/card/Card.d.ts +3 -4
- package/dist/components/card/Card.js +6 -4
- package/dist/components/card/CardBody.d.ts +3 -3
- package/dist/components/card/CardBody.js +6 -4
- package/dist/components/card/CardHeader.d.ts +3 -3
- package/dist/components/card/CardHeader.js +6 -4
- package/dist/components/card/CardNotification.d.ts +2 -3
- package/dist/components/card/CardNotification.js +6 -2
- package/dist/components/chips/chip/Chip.d.ts +4 -5
- package/dist/components/chips/chip/Chip.js +11 -4
- package/dist/components/chips/chip-container/ChipContainer.d.ts +3 -3
- package/dist/components/chips/chip-container/ChipContainer.js +6 -2
- package/dist/components/icon-wrapper/IconWrapper.d.ts +2 -1
- package/dist/components/loading-indicator/LoadingIndicator.d.ts +2 -2
- package/dist/components/loading-indicator/LoadingIndicator.js +1 -0
- package/dist/components/mobile-flyout/MobileFlyout.js +1 -0
- package/dist/components/mobile-flyout/mobile-flyout-item/MobileFlyoutItem.d.ts +1 -0
- package/dist/components/mobile-flyout/mobile-flyout-item/MobileFlyoutItem.js +3 -2
- package/dist/components/mobile-flyout/mobile-flyout-page/MobileFlyoutPage.js +4 -3
- package/dist/components/modals/AlertModal.d.ts +1 -1
- package/dist/components/modals/AlertModal.js +5 -4
- package/dist/components/modals/ConfirmModal.d.ts +1 -1
- package/dist/components/modals/ConfirmModal.js +5 -4
- package/dist/components/modals/CustomModal.js +1 -0
- package/dist/components/modals/Modal.js +1 -0
- package/dist/components/modals/ModalBase.js +1 -0
- package/dist/components/modals/ModalFooter.d.ts +2 -2
- package/dist/components/modals/ModalFooter.js +3 -1
- package/dist/components/modals/Prompt.d.ts +3 -3
- package/dist/components/modals/Prompt.js +9 -6
- package/dist/components/modals/image-gallery/ImageGallery.css +24 -6
- package/dist/components/modals/image-gallery/ImageGallery.d.ts +1 -1
- package/dist/components/modals/image-gallery/ImageGallery.js +1 -0
- package/dist/components/modals/image-gallery/ImageGallerySwiper.js +1 -1
- package/dist/components/modals/image-gallery/internal/ImageGalleryContainer.d.ts +1 -1
- package/dist/components/pagination/Pagination.d.ts +3 -4
- package/dist/components/pagination/Pagination.js +17 -13
- package/dist/components/popovers/legend/Legend.d.ts +6 -4
- package/dist/components/popovers/legend/Legend.js +8 -4
- package/dist/components/popovers/popover/Popover.css +5 -52
- package/dist/components/popovers/popover/Popover.d.ts +12 -14
- package/dist/components/popovers/popover/Popover.js +81 -91
- package/dist/components/popovers/popover-menu/PopoverMenu.d.ts +6 -4
- package/dist/components/popovers/popover-menu/PopoverMenu.js +23 -27
- package/dist/components/popovers/popover-menu/PopoverMenuContext.d.ts +2 -1
- package/dist/components/popovers/popover-menu/PopoverMenuContext.js +1 -1
- package/dist/components/popovers/popover-menu/popover-menu-item/PopoverMenuItem.d.ts +9 -0
- package/dist/components/popovers/popover-menu/popover-menu-item/PopoverMenuItem.js +31 -0
- package/dist/components/popovers/tooltip/Tooltip.d.ts +4 -3
- package/dist/components/popovers/tooltip/Tooltip.js +7 -6
- package/dist/components/progress/Progress.d.ts +2 -3
- package/dist/components/progress/Progress.js +6 -2
- package/dist/components/search-input/ClearButton.d.ts +1 -2
- package/dist/components/search-input/ClearButton.js +5 -4
- package/dist/components/search-input/SearchInput.d.ts +3 -4
- package/dist/components/search-input/SearchInput.js +9 -5
- package/dist/components/snackbar/Snackbar.d.ts +4 -4
- package/dist/components/snackbar/Snackbar.js +11 -7
- package/dist/components/snackbar/SnackbarProvider.d.ts +3 -3
- package/dist/components/snackbar/SnackbarProvider.js +7 -4
- package/dist/components/stepper-horizontal/StepperHorizontal.d.ts +2 -2
- package/dist/components/stepper-horizontal/StepperHorizontal.js +4 -3
- package/dist/components/stepper-horizontal/step-horizontal/StepHorizontal.js +2 -1
- package/dist/components/stepper-vertical/StepperVertical.js +1 -1
- package/dist/components/stepper-vertical/step-vertical/StepVertical.js +1 -0
- package/dist/components/tab/Tabs.js +3 -3
- package/dist/components/tab/tab-pane/TabPane.d.ts +3 -4
- package/dist/components/tab/tab-pane/TabPane.js +6 -2
- package/dist/components/table-header-cell/TableHeaderCell.d.ts +2 -1
- package/dist/components/table-header-cell/TableHeaderCell.js +1 -0
- package/dist/forms/checkbox/Checkbox.d.ts +3 -6
- package/dist/forms/checkbox/Checkbox.js +5 -2
- package/dist/forms/combobox/ComboBox.css +124 -0
- package/dist/forms/combobox/ComboBox.d.ts +27 -0
- package/dist/forms/combobox/ComboBox.js +174 -0
- package/dist/forms/multi-select/MultiSelect.css +13 -0
- package/dist/forms/multi-select/MultiSelect.d.ts +20 -0
- package/dist/forms/multi-select/MultiSelect.js +192 -0
- package/dist/forms/radio/RadioButton.d.ts +4 -4
- package/dist/forms/radio/RadioButton.js +11 -10
- package/dist/forms/radio/RadioGroup.d.ts +4 -4
- package/dist/forms/radio/RadioGroup.js +1 -0
- package/dist/forms/segment/Segment.d.ts +4 -5
- package/dist/forms/segment/Segment.js +10 -9
- package/dist/forms/segment/segment-control/SegmentControl.d.ts +4 -8
- package/dist/forms/segment/segment-control/SegmentControl.js +8 -6
- package/dist/forms/select/Select.d.ts +16 -17
- package/dist/forms/select/Select.js +80 -82
- package/dist/forms/select/internal/SelectButton.d.ts +0 -12
- package/dist/forms/select/internal/SelectButton.js +0 -49
- package/dist/forms/select/internal/SelectButtonContent.d.ts +0 -7
- package/dist/forms/select/internal/SelectButtonContent.js +0 -31
- package/dist/forms/select/internal/SelectOptionsContainer.d.ts +0 -17
- package/dist/forms/select/internal/SelectOptionsContainer.js +0 -103
- package/dist/forms/slider/Slider.d.ts +4 -7
- package/dist/forms/slider/Slider.js +11 -6
- package/dist/forms/switch/Switch.d.ts +4 -6
- package/dist/forms/switch/Switch.js +12 -6
- package/dist/forms/text-area/TextArea.d.ts +6 -15
- package/dist/forms/text-area/TextArea.js +42 -25
- package/dist/forms/text-input/TextInput.css +31 -0
- package/dist/forms/text-input/TextInput.d.ts +6 -17
- package/dist/forms/text-input/TextInput.js +16 -25
- package/dist/forms/time-picker/TimePicker.d.ts +7 -6
- package/dist/forms/time-picker/TimePicker.js +16 -31
- package/dist/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +1 -0
- package/dist/forms/time-picker/time-picker-dropdown/TimePickerInput.js +1 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +4 -3
- package/dist/utils/types.d.ts +0 -6
- package/dist/utils/useControlled.js +4 -4
- package/dist/utils/useForkRef.d.ts +2 -2
- package/dist/utils/useForkRef.js +2 -2
- package/dist/utils/useOnClickOutside.d.ts +1 -1
- package/package.json +17 -28
- package/dist/components/popovers/popover-menu-item/PopoverMenuItem.d.ts +0 -9
- package/dist/components/popovers/popover-menu-item/PopoverMenuItem.js +0 -29
- package/dist/forms/select/Select.css +0 -160
- package/dist/forms/select/internal/HiddenInput.d.ts +0 -8
- package/dist/forms/select/internal/HiddenInput.js +0 -15
- package/dist/forms/select/internal/ListItem.d.ts +0 -18
- package/dist/forms/select/internal/ListItem.js +0 -69
- package/dist/forms/select/internal/SelectCheckbox.d.ts +0 -4
- package/dist/forms/select/internal/SelectCheckbox.js +0 -13
- package/dist/forms/select/internal/SelectLabel.d.ts +0 -7
- package/dist/forms/select/internal/SelectLabel.js +0 -12
- package/dist/forms/select/internal/SelectScrollContainer.d.ts +0 -8
- package/dist/forms/select/internal/SelectScrollContainer.js +0 -15
- package/dist/forms/select/internal/SelectWrapper.d.ts +0 -6
- package/dist/forms/select/internal/SelectWrapper.js +0 -12
- package/dist/forms/select/internal/index.d.ts +0 -6
- package/dist/forms/select/internal/index.js +0 -7
- package/dist/forms/select/internal/utils.d.ts +0 -7
- package/dist/forms/select/internal/utils.js +0 -30
- package/dist/forms/select/select-option/SelectOption.d.ts +0 -14
- package/dist/forms/select/select-option/SelectOption.js +0 -12
- package/dist/forms/select/utils.d.ts +0 -2
- package/dist/forms/select/utils.js +0 -12
|
@@ -1,95 +1,93 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "@headlessui/react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { forwardRef, useMemo } from "react";
|
|
5
5
|
import { useControlled } from "../../utils/useControlled.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function SelectComponent({ defaultValue = '', open, defaultOpen = false, value: controlled, label, options, onChange, required = false, config, disabled, name, id, children, hint, error, onOpenChange, renderLabelContent, ...props }, ref) {
|
|
6
|
+
import { useId } from "../../utils/useId.js";
|
|
7
|
+
function SelectComponent({ defaultValue = '', value: controlled, label, options = [], onChange, disabled, name, id: idProp, hint, error, placeholder, className, ...props }, ref) {
|
|
8
|
+
const id = useId(idProp);
|
|
9
|
+
const labelId = `${id}-label`;
|
|
11
10
|
const [value, setValue] = useControlled({
|
|
12
11
|
controlled,
|
|
13
12
|
default: defaultValue,
|
|
14
13
|
onChange
|
|
15
14
|
});
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setFocused(false);
|
|
28
|
-
buttonEl?.current?.focus();
|
|
29
|
-
};
|
|
30
|
-
const handleOptionChange = (newOption)=>{
|
|
31
|
-
let newValue = newOption.data;
|
|
32
|
-
if (Array.isArray(value)) newValue = value.includes(newValue) ? value.filter((item)=>item !== newValue) : [
|
|
33
|
-
...value,
|
|
34
|
-
newValue
|
|
35
|
-
];
|
|
36
|
-
setValue(newValue);
|
|
37
|
-
if (!multiple) refocusButton();
|
|
38
|
-
};
|
|
39
|
-
const removeChip = (chipLabel)=>{
|
|
40
|
-
const chipOption = usedOptions.find((option)=>option.label === chipLabel);
|
|
41
|
-
if (chipOption) handleOptionChange(chipOption);
|
|
42
|
-
};
|
|
43
|
-
const selectedLabel = multiple ? usedOptions.filter((option)=>value.includes(option.data))?.map((option)=>option.label) : usedOptions.find((option)=>option.data === value)?.label;
|
|
44
|
-
return /*#__PURE__*/ jsxs(SelectWrapper, {
|
|
15
|
+
const selectedOption = useMemo(()=>options.find((option)=>option.data === value && !option.disabled), [
|
|
16
|
+
options,
|
|
17
|
+
value
|
|
18
|
+
]);
|
|
19
|
+
function handleChange(option) {
|
|
20
|
+
if (!option || option.disabled) return;
|
|
21
|
+
setValue(option.data);
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/ jsx(Listbox, {
|
|
24
|
+
value: selectedOption ?? null,
|
|
25
|
+
onChange: handleChange,
|
|
45
26
|
disabled: disabled,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/*#__PURE__*/ jsx(HiddenInput, {
|
|
50
|
-
onChange: handleOptionChange,
|
|
51
|
-
options: usedOptions,
|
|
52
|
-
value: value
|
|
53
|
-
}),
|
|
54
|
-
/*#__PURE__*/ jsx(SelectButton, {
|
|
55
|
-
ref: buttonEl,
|
|
56
|
-
onToggle: ()=>setFocused((prev)=>!prev),
|
|
57
|
-
error: error,
|
|
58
|
-
disabled: disabled,
|
|
59
|
-
focused: focused,
|
|
60
|
-
required: required,
|
|
61
|
-
onChipClick: removeChip,
|
|
62
|
-
label: selectedLabel,
|
|
63
|
-
renderLabelContent: renderLabelContent
|
|
64
|
-
}),
|
|
65
|
-
/*#__PURE__*/ jsx(SelectLabel, {
|
|
66
|
-
hideLabel: config?.hideLabel,
|
|
67
|
-
label: label,
|
|
68
|
-
id: id
|
|
69
|
-
}),
|
|
70
|
-
/*#__PURE__*/ jsx("div", {
|
|
71
|
-
className: "fwe-select-underline"
|
|
72
|
-
}),
|
|
73
|
-
hint && !error && /*#__PURE__*/ jsx("div", {
|
|
74
|
-
className: "fwe-select-description",
|
|
75
|
-
children: hint
|
|
76
|
-
}),
|
|
77
|
-
error && /*#__PURE__*/ jsx("div", {
|
|
78
|
-
className: "fwe-select-invalid",
|
|
79
|
-
children: error
|
|
27
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
28
|
+
className: classnames(className, 'fwe-select-wrapper', {
|
|
29
|
+
'fwe-disabled': disabled
|
|
80
30
|
}),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
31
|
+
ref: ref,
|
|
32
|
+
...props,
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx(ListboxButton, {
|
|
35
|
+
className: classnames('fwe-select', {
|
|
36
|
+
'fwe-invalid': error
|
|
37
|
+
}),
|
|
38
|
+
id: id,
|
|
39
|
+
"aria-labelledby": label ? labelId : void 0,
|
|
40
|
+
disabled: disabled,
|
|
41
|
+
children: selectedOption ? selectedOption.label : placeholder ?? ''
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ jsx("label", {
|
|
44
|
+
className: "fwe-select-label",
|
|
45
|
+
id: labelId,
|
|
46
|
+
htmlFor: id,
|
|
47
|
+
children: label || ''
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ jsx(ListboxOptions, {
|
|
50
|
+
className: "fwe-options-container",
|
|
51
|
+
as: "ul",
|
|
52
|
+
portal: false,
|
|
53
|
+
style: {
|
|
54
|
+
minWidth: 'var(--button-width)'
|
|
55
|
+
},
|
|
56
|
+
anchor: {
|
|
57
|
+
to: 'bottom start',
|
|
58
|
+
gap: 12,
|
|
59
|
+
padding: 8
|
|
60
|
+
},
|
|
61
|
+
children: options.map((option)=>/*#__PURE__*/ jsx(ListboxOption, {
|
|
62
|
+
value: option,
|
|
63
|
+
disabled: option.disabled,
|
|
64
|
+
as: "li",
|
|
65
|
+
className: ({ focus, selected, disabled: isDisabled })=>classnames('fwe-combobox-option', {
|
|
66
|
+
'fwe-selected': selected,
|
|
67
|
+
'fwe-focus': focus,
|
|
68
|
+
'fwe-disabled': isDisabled
|
|
69
|
+
}),
|
|
70
|
+
children: option.label
|
|
71
|
+
}, String(option.data)))
|
|
72
|
+
}),
|
|
73
|
+
name && /*#__PURE__*/ jsx("input", {
|
|
74
|
+
type: "hidden",
|
|
75
|
+
name: name,
|
|
76
|
+
value: String(value ?? ''),
|
|
77
|
+
disabled: disabled
|
|
78
|
+
}),
|
|
79
|
+
hint && !error && /*#__PURE__*/ jsx("div", {
|
|
80
|
+
className: "fwe-select-description",
|
|
81
|
+
children: hint
|
|
82
|
+
}),
|
|
83
|
+
error && /*#__PURE__*/ jsx("div", {
|
|
84
|
+
className: "fwe-select-invalid",
|
|
85
|
+
children: error
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
91
|
const Select = /*#__PURE__*/ forwardRef(SelectComponent);
|
|
92
|
+
Select.displayName = 'Select';
|
|
95
93
|
export { Select };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface SelectButtonProps {
|
|
2
|
-
onToggle: () => void;
|
|
3
|
-
focused?: boolean;
|
|
4
|
-
required: boolean;
|
|
5
|
-
error?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
onChipClick: (label: string) => void;
|
|
8
|
-
label?: string | string[];
|
|
9
|
-
renderLabelContent?: (label?: string | string[]) => JSX.Element;
|
|
10
|
-
}
|
|
11
|
-
export declare const SelectButton: (props: SelectButtonProps & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null;
|
|
12
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
import { SelectButtonContent } from "./SelectButtonContent.js";
|
|
5
|
-
const SelectButton = /*#__PURE__*/ forwardRef(({ onToggle, disabled, label, focused, required, error, onChipClick, renderLabelContent }, ref)=>{
|
|
6
|
-
const empty = void 0 === label && !focused;
|
|
7
|
-
function handleKeyDown(e) {
|
|
8
|
-
if (disabled) return;
|
|
9
|
-
const validKeys = [
|
|
10
|
-
'Enter',
|
|
11
|
-
' ',
|
|
12
|
-
'ArrowUp',
|
|
13
|
-
'ArrowDown'
|
|
14
|
-
];
|
|
15
|
-
if (validKeys.includes(e.key)) {
|
|
16
|
-
e.preventDefault();
|
|
17
|
-
onToggle();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function handleClick(e) {
|
|
21
|
-
if (disabled) return;
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
onToggle();
|
|
24
|
-
}
|
|
25
|
-
return /*#__PURE__*/ jsx("button", {
|
|
26
|
-
type: "button",
|
|
27
|
-
tabIndex: 0,
|
|
28
|
-
className: classnames('fwe-select', {
|
|
29
|
-
'fwe-focus': focused,
|
|
30
|
-
'fwe-empty': empty,
|
|
31
|
-
'fwe-required': required,
|
|
32
|
-
'fwe-disabled': disabled,
|
|
33
|
-
'fwe-invalid': error
|
|
34
|
-
}),
|
|
35
|
-
onClick: handleClick,
|
|
36
|
-
ref: ref,
|
|
37
|
-
onKeyDown: handleKeyDown,
|
|
38
|
-
disabled: disabled,
|
|
39
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
40
|
-
className: "fwe-select-content",
|
|
41
|
-
children: /*#__PURE__*/ jsx(SelectButtonContent, {
|
|
42
|
-
onClick: onChipClick,
|
|
43
|
-
label: label,
|
|
44
|
-
renderLabelContent: renderLabelContent
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
export { SelectButton };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
interface SelectButtonContentProps {
|
|
2
|
-
label?: string | string[];
|
|
3
|
-
renderLabelContent?: (label?: string | string[]) => JSX.Element;
|
|
4
|
-
onClick: (label: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function SelectButtonContent({ label, renderLabelContent, onClick, }: SelectButtonContentProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { IconCloseSmall } from "@festo-ui/react-icons";
|
|
3
|
-
function SelectButtonContent({ label, renderLabelContent, onClick }) {
|
|
4
|
-
const handleChipClick = (chipLabel)=>(e)=>{
|
|
5
|
-
e.stopPropagation();
|
|
6
|
-
onClick(chipLabel);
|
|
7
|
-
};
|
|
8
|
-
if (renderLabelContent) return renderLabelContent(label);
|
|
9
|
-
if (Array.isArray(label)) return /*#__PURE__*/ jsx("div", {
|
|
10
|
-
className: "fwe-chip-container",
|
|
11
|
-
children: label.map((v)=>/*#__PURE__*/ jsxs("div", {
|
|
12
|
-
className: "fwe-chip chip-text-truncate fwe-pr-4",
|
|
13
|
-
title: v,
|
|
14
|
-
children: [
|
|
15
|
-
v,
|
|
16
|
-
/*#__PURE__*/ jsx("button", {
|
|
17
|
-
type: "button",
|
|
18
|
-
className: "chip-removable",
|
|
19
|
-
onClick: handleChipClick(v),
|
|
20
|
-
children: /*#__PURE__*/ jsx(IconCloseSmall, {
|
|
21
|
-
size: 16
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
]
|
|
25
|
-
}, v))
|
|
26
|
-
});
|
|
27
|
-
return /*#__PURE__*/ jsx(Fragment, {
|
|
28
|
-
children: label
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export { SelectButtonContent };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Key, type Ref } from 'react';
|
|
2
|
-
import type { SelectConfiguration } from '../../../utils/types';
|
|
3
|
-
import type { SelectOptionType } from '../select-option/SelectOption';
|
|
4
|
-
interface SelectOptionsContainerProps<T> {
|
|
5
|
-
options?: SelectOptionType<T>[];
|
|
6
|
-
config?: SelectConfiguration;
|
|
7
|
-
onClose: () => void;
|
|
8
|
-
label?: string | string[];
|
|
9
|
-
onOptionChange: (option: SelectOptionType<T>) => void;
|
|
10
|
-
multiple?: boolean;
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
}
|
|
13
|
-
declare function SelectOptionsContainerComponent<T extends Key | null | undefined>({ options, config, onClose, label, onOptionChange, multiple, children, }: SelectOptionsContainerProps<T>, ref: Ref<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const SelectOptionsContainer: <T>(props: SelectOptionsContainerProps<T> & {
|
|
15
|
-
ref?: Ref<HTMLDivElement>;
|
|
16
|
-
}) => ReturnType<typeof SelectOptionsContainerComponent>;
|
|
17
|
-
export {};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createRef, forwardRef, isValidElement, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { usePopper } from "react-popper";
|
|
4
|
-
import { ListItem } from "./ListItem.js";
|
|
5
|
-
import { SelectScrollContainer } from "./SelectScrollContainer.js";
|
|
6
|
-
import { getChildren } from "./utils.js";
|
|
7
|
-
function SelectOptionsContainerComponent({ options, config, onClose, label, onOptionChange, multiple, children }, ref) {
|
|
8
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
9
|
-
const refObject = 'function' != typeof ref ? ref?.current : null;
|
|
10
|
-
const { styles, attributes } = usePopper(refObject, popperElement, {
|
|
11
|
-
placement: 'bottom-start',
|
|
12
|
-
modifiers: [
|
|
13
|
-
{
|
|
14
|
-
name: 'offset',
|
|
15
|
-
options: {
|
|
16
|
-
offset: [
|
|
17
|
-
0,
|
|
18
|
-
3
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'flip',
|
|
24
|
-
options: {
|
|
25
|
-
fallbackPlacements: [
|
|
26
|
-
'bottom-start',
|
|
27
|
-
'top-start'
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
function getCssProperies() {
|
|
34
|
-
if (config?.contentWidth) return {
|
|
35
|
-
...styles.popper,
|
|
36
|
-
minWidth: `${refObject?.clientWidth}px`,
|
|
37
|
-
width: config?.contentWidth
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
...styles.popper,
|
|
41
|
-
minWidth: `${refObject?.clientWidth}px`
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const allChildren = getChildren(children);
|
|
45
|
-
const childrenList = allChildren.childrenList;
|
|
46
|
-
const usedOptions = options ?? childrenList.map((child)=>child.props.option);
|
|
47
|
-
const { length } = usedOptions;
|
|
48
|
-
const listItemRef = useRef(Array.from({
|
|
49
|
-
length
|
|
50
|
-
}, ()=>/*#__PURE__*/ createRef()));
|
|
51
|
-
const selectedIndex = Array.isArray(label) ? usedOptions.findIndex((option)=>option.label === label.at(-1)) : usedOptions.findIndex((option)=>option.label === label);
|
|
52
|
-
const [init, setInit] = useState(false);
|
|
53
|
-
useEffect(()=>{
|
|
54
|
-
if (!init) requestAnimationFrame(()=>{
|
|
55
|
-
setInit(true);
|
|
56
|
-
const index = -1 === selectedIndex ? 0 : selectedIndex;
|
|
57
|
-
listItemRef.current?.[index].current?.focus();
|
|
58
|
-
});
|
|
59
|
-
}, [
|
|
60
|
-
selectedIndex,
|
|
61
|
-
init
|
|
62
|
-
]);
|
|
63
|
-
return /*#__PURE__*/ jsxs(Fragment, {
|
|
64
|
-
children: [
|
|
65
|
-
/*#__PURE__*/ jsx("div", {
|
|
66
|
-
"aria-hidden": true,
|
|
67
|
-
className: "fr-backdrop",
|
|
68
|
-
onClick: onClose
|
|
69
|
-
}),
|
|
70
|
-
/*#__PURE__*/ jsxs("ul", {
|
|
71
|
-
ref: setPopperElement,
|
|
72
|
-
style: getCssProperies(),
|
|
73
|
-
...attributes.popper,
|
|
74
|
-
className: "fwe-select-options-container",
|
|
75
|
-
role: "listbox",
|
|
76
|
-
children: [
|
|
77
|
-
allChildren.before,
|
|
78
|
-
/*#__PURE__*/ jsx(SelectScrollContainer, {
|
|
79
|
-
length: length,
|
|
80
|
-
config: config,
|
|
81
|
-
children: [
|
|
82
|
-
...options || [],
|
|
83
|
-
...childrenList
|
|
84
|
-
].map((item, i)=>/*#__PURE__*/ jsx(ListItem, {
|
|
85
|
-
withCheckbox: multiple,
|
|
86
|
-
item: item,
|
|
87
|
-
selectedLabel: label,
|
|
88
|
-
onClose: onClose,
|
|
89
|
-
onFocusChange: (index)=>listItemRef.current[index].current?.focus(),
|
|
90
|
-
onOptionChange: onOptionChange,
|
|
91
|
-
ref: listItemRef,
|
|
92
|
-
index: i,
|
|
93
|
-
options: usedOptions
|
|
94
|
-
}, /*#__PURE__*/ (isValidElement(item) ? item.props.option : item).data))
|
|
95
|
-
}),
|
|
96
|
-
allChildren.after
|
|
97
|
-
]
|
|
98
|
-
})
|
|
99
|
-
]
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const SelectOptionsContainer = /*#__PURE__*/ forwardRef(SelectOptionsContainerComponent);
|
|
103
|
-
export { SelectOptionsContainer };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import './Slider.scss';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
export interface SliderProps extends ClassNameProps {
|
|
5
|
-
readonly disabled?: boolean;
|
|
2
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
export interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'onChange' | 'value' | 'defaultValue' | 'min' | 'max' | 'step'> {
|
|
6
4
|
readonly min: number;
|
|
7
5
|
readonly max: number;
|
|
8
6
|
readonly step?: number;
|
|
@@ -10,8 +8,7 @@ export interface SliderProps extends ClassNameProps {
|
|
|
10
8
|
readonly onChangeCommitted?: (value: number) => void;
|
|
11
9
|
readonly label?: string;
|
|
12
10
|
readonly showValue?: boolean;
|
|
13
|
-
readonly onChange?: (event: React.ChangeEvent<HTMLInputElement
|
|
14
|
-
readonly id?: string;
|
|
11
|
+
readonly onChange?: (value: number, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
12
|
readonly widthOffset?: number;
|
|
16
13
|
}
|
|
17
|
-
export declare
|
|
14
|
+
export declare const Slider: (props: SliderProps & import("react").RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "./Slider.css";
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { useForkRef } from "../../utils/useForkRef.js";
|
|
5
6
|
import { useId } from "../../utils/useId.js";
|
|
6
|
-
|
|
7
|
+
const Slider = /*#__PURE__*/ forwardRef(({ disabled = false, label, name, max, min, onChange, onChangeCommitted, step, value, showValue = true, className, id: idProps, widthOffset = 8, ...props }, ref)=>{
|
|
7
8
|
const id = useId(idProps);
|
|
8
9
|
const [innerValue, setInnerValue] = useState(value);
|
|
9
10
|
const [left, setLeft] = useState(null);
|
|
10
11
|
const [numberOffset, setNumberOffset] = useState(0);
|
|
11
12
|
const labelEl = useRef(null);
|
|
13
|
+
const handleRef = useForkRef(ref, labelEl);
|
|
12
14
|
const classes = classnames('fwe-slider', {
|
|
13
15
|
'fr-slider-value': !label && showValue
|
|
14
16
|
}, {
|
|
@@ -40,7 +42,7 @@ function Slider({ disabled = false, label, max, min, onChange, onChangeCommitted
|
|
|
40
42
|
const handleChange = (e)=>{
|
|
41
43
|
const newValue = Number.parseFloat(e.target.value);
|
|
42
44
|
setInnerValue(newValue);
|
|
43
|
-
if (onChange) onChange(
|
|
45
|
+
if (onChange) onChange(newValue, e);
|
|
44
46
|
};
|
|
45
47
|
useEffect(()=>{
|
|
46
48
|
function handleResize() {
|
|
@@ -53,7 +55,7 @@ function Slider({ disabled = false, label, max, min, onChange, onChangeCommitted
|
|
|
53
55
|
updateValuePosition
|
|
54
56
|
]);
|
|
55
57
|
return /*#__PURE__*/ jsxs("label", {
|
|
56
|
-
ref:
|
|
58
|
+
ref: handleRef,
|
|
57
59
|
className: classes,
|
|
58
60
|
htmlFor: id,
|
|
59
61
|
children: [
|
|
@@ -64,6 +66,7 @@ function Slider({ disabled = false, label, max, min, onChange, onChangeCommitted
|
|
|
64
66
|
id: id,
|
|
65
67
|
className: "fwe-slider-input",
|
|
66
68
|
type: "range",
|
|
69
|
+
name: name,
|
|
67
70
|
disabled: disabled,
|
|
68
71
|
min: min,
|
|
69
72
|
max: max,
|
|
@@ -72,7 +75,8 @@ function Slider({ disabled = false, label, max, min, onChange, onChangeCommitted
|
|
|
72
75
|
value: innerValue,
|
|
73
76
|
onKeyUp: handleAfterChange,
|
|
74
77
|
onMouseUp: handleAfterChange,
|
|
75
|
-
onTouchEnd: handleAfterChange
|
|
78
|
+
onTouchEnd: handleAfterChange,
|
|
79
|
+
...props
|
|
76
80
|
}),
|
|
77
81
|
showValue && null !== left && /*#__PURE__*/ jsx("span", {
|
|
78
82
|
className: "fr-slider-value",
|
|
@@ -89,5 +93,6 @@ function Slider({ disabled = false, label, max, min, onChange, onChangeCommitted
|
|
|
89
93
|
})
|
|
90
94
|
]
|
|
91
95
|
});
|
|
92
|
-
}
|
|
96
|
+
});
|
|
97
|
+
Slider.displayName = 'Slider';
|
|
93
98
|
export { Slider };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export interface SwitchProps extends
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'onChange' | 'value' | 'defaultValue' | 'checked'> {
|
|
3
3
|
readonly labelPosition?: 'before' | 'after' | 'below';
|
|
4
4
|
readonly large?: boolean;
|
|
5
5
|
readonly title: string;
|
|
6
6
|
readonly value?: boolean;
|
|
7
7
|
readonly defaultValue?: boolean;
|
|
8
|
-
readonly
|
|
9
|
-
readonly onChange?: (value: boolean) => void;
|
|
10
|
-
readonly id?: string;
|
|
8
|
+
readonly onChange?: (value: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
11
9
|
}
|
|
12
|
-
export declare
|
|
10
|
+
export declare const Switch: (props: SwitchProps & import("react").RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { forwardRef } from "react";
|
|
3
4
|
import { useControlled } from "../../utils/useControlled.js";
|
|
4
5
|
import { useId } from "../../utils/useId.js";
|
|
5
|
-
|
|
6
|
+
const Switch = /*#__PURE__*/ forwardRef(({ labelPosition = 'after', large = false, title, name, required = false, value, defaultValue, disabled = false, onChange, className, id: idProps, ...props }, ref)=>{
|
|
6
7
|
const id = useId(idProps);
|
|
7
8
|
const labelClassName = classnames('fwe-switch', {
|
|
8
9
|
[`fwe-switch-label-${labelPosition}`]: true
|
|
@@ -13,21 +14,25 @@ function Switch({ labelPosition = 'after', large = false, title, value, defaultV
|
|
|
13
14
|
controlled: value,
|
|
14
15
|
default: defaultValue
|
|
15
16
|
});
|
|
16
|
-
const handleChange = ()=>{
|
|
17
|
+
const handleChange = (event)=>{
|
|
17
18
|
const newValue = !currentValue;
|
|
18
19
|
setCurrentValue(newValue);
|
|
19
|
-
if (onChange) onChange(newValue);
|
|
20
|
+
if (onChange) onChange(newValue, event);
|
|
20
21
|
};
|
|
21
22
|
return /*#__PURE__*/ jsxs("label", {
|
|
22
23
|
className: labelClassName,
|
|
23
24
|
htmlFor: id,
|
|
25
|
+
ref: ref,
|
|
24
26
|
children: [
|
|
25
27
|
/*#__PURE__*/ jsx("input", {
|
|
26
28
|
type: "checkbox",
|
|
29
|
+
name: name,
|
|
30
|
+
required: required,
|
|
27
31
|
disabled: disabled,
|
|
28
32
|
checked: currentValue,
|
|
29
|
-
onChange:
|
|
30
|
-
id: id
|
|
33
|
+
onChange: handleChange,
|
|
34
|
+
id: id,
|
|
35
|
+
...props
|
|
31
36
|
}),
|
|
32
37
|
/*#__PURE__*/ jsx("div", {
|
|
33
38
|
className: "fwe-switch-track"
|
|
@@ -38,5 +43,6 @@ function Switch({ labelPosition = 'after', large = false, title, value, defaultV
|
|
|
38
43
|
})
|
|
39
44
|
]
|
|
40
45
|
});
|
|
41
|
-
}
|
|
46
|
+
});
|
|
47
|
+
Switch.displayName = 'Switch';
|
|
42
48
|
export { Switch };
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import './TextArea.scss';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly readonly?: boolean;
|
|
8
|
-
readonly onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
9
|
-
readonly onFocus?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
10
|
-
readonly onInput?: (event: React.FormEvent<HTMLTextAreaElement>) => void;
|
|
11
|
-
readonly onBlur?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
2
|
+
import React, { type ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
export interface TextAreaProps extends Omit<ComponentPropsWithoutRef<'textarea'>, 'onChange' | 'value' | 'defaultValue'> {
|
|
4
|
+
readonly value?: string;
|
|
5
|
+
readonly defaultValue?: string;
|
|
6
|
+
readonly onChange?: (value: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
12
7
|
readonly label: string;
|
|
13
8
|
readonly hint?: string;
|
|
14
9
|
readonly error?: string;
|
|
15
|
-
readonly value?: string;
|
|
16
|
-
readonly defaultValue?: string;
|
|
17
|
-
readonly name?: string;
|
|
18
10
|
readonly rows?: number;
|
|
19
|
-
readonly maxLength?: number;
|
|
20
11
|
readonly id?: string;
|
|
21
12
|
}
|
|
22
|
-
export declare
|
|
13
|
+
export declare const TextArea: (props: TextAreaProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|