@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
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "@headlessui/react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { forwardRef, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { useControlled } from "../../utils/useControlled.js";
|
|
6
|
+
import { useId } from "../../utils/useId.js";
|
|
7
|
+
import "./MultiSelect.css";
|
|
8
|
+
function MultiSelectComponent({ defaultValue = [], value: controlled, label, options = [], onChange, disabled, name, id: idProp, hint, error, placeholder, className, ...props }, ref) {
|
|
9
|
+
const id = useId(idProp);
|
|
10
|
+
const labelId = `${id}-label`;
|
|
11
|
+
const [value, setValue] = useControlled({
|
|
12
|
+
controlled,
|
|
13
|
+
default: defaultValue,
|
|
14
|
+
onChange
|
|
15
|
+
});
|
|
16
|
+
const selectedOptions = useMemo(()=>options.filter((option)=>!option.disabled && (value ?? []).includes(option.data)), [
|
|
17
|
+
options,
|
|
18
|
+
value
|
|
19
|
+
]);
|
|
20
|
+
function handleChange(nextOptions) {
|
|
21
|
+
setValue(nextOptions.map((option)=>option.data));
|
|
22
|
+
}
|
|
23
|
+
const chipsRef = useRef(null);
|
|
24
|
+
const [overflowCount, setOverflowCount] = useState(0);
|
|
25
|
+
const measureOverflow = useCallback((optionCount)=>{
|
|
26
|
+
const container = chipsRef.current;
|
|
27
|
+
if (!container) return void setOverflowCount(0);
|
|
28
|
+
const allChildren = Array.from(container.children);
|
|
29
|
+
const optionChildren = allChildren.filter((child)=>'true' === child.dataset.optionChip);
|
|
30
|
+
for (const child of optionChildren)child.style.display = '';
|
|
31
|
+
const containerRect = container.getBoundingClientRect();
|
|
32
|
+
const isOverflow = optionChildren.some((child)=>{
|
|
33
|
+
const childRect = child.getBoundingClientRect();
|
|
34
|
+
return childRect.right > containerRect.right;
|
|
35
|
+
});
|
|
36
|
+
if (isOverflow && optionCount > 1) {
|
|
37
|
+
let remainingWidth = containerRect.width - 64;
|
|
38
|
+
let count = 0;
|
|
39
|
+
for (const child of optionChildren){
|
|
40
|
+
const width = child.getBoundingClientRect().width + 8;
|
|
41
|
+
if (width <= remainingWidth) {
|
|
42
|
+
remainingWidth -= width;
|
|
43
|
+
child.style.display = '';
|
|
44
|
+
} else {
|
|
45
|
+
count++;
|
|
46
|
+
child.style.display = 'none';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setOverflowCount(count);
|
|
50
|
+
} else setOverflowCount(0);
|
|
51
|
+
}, []);
|
|
52
|
+
useLayoutEffect(()=>{
|
|
53
|
+
measureOverflow(selectedOptions.length);
|
|
54
|
+
const container = chipsRef.current;
|
|
55
|
+
if (!container) return;
|
|
56
|
+
const observer = new ResizeObserver(()=>{
|
|
57
|
+
measureOverflow(selectedOptions.length);
|
|
58
|
+
});
|
|
59
|
+
observer.observe(container);
|
|
60
|
+
return ()=>observer.disconnect();
|
|
61
|
+
}, [
|
|
62
|
+
selectedOptions,
|
|
63
|
+
measureOverflow
|
|
64
|
+
]);
|
|
65
|
+
return /*#__PURE__*/ jsx(Listbox, {
|
|
66
|
+
value: selectedOptions,
|
|
67
|
+
onChange: handleChange,
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
multiple: true,
|
|
70
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
71
|
+
className: classnames(className, 'fwe-select-wrapper', {
|
|
72
|
+
'fwe-disabled': disabled
|
|
73
|
+
}),
|
|
74
|
+
ref: ref,
|
|
75
|
+
...props,
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(ListboxButton, {
|
|
78
|
+
className: classnames('fwe-select', {
|
|
79
|
+
'fwe-invalid': error
|
|
80
|
+
}),
|
|
81
|
+
id: id,
|
|
82
|
+
"aria-labelledby": label ? labelId : void 0,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
children: selectedOptions.length > 0 ? /*#__PURE__*/ jsxs("span", {
|
|
85
|
+
ref: chipsRef,
|
|
86
|
+
className: "fr-multiselect-chip-container",
|
|
87
|
+
children: [
|
|
88
|
+
selectedOptions.map((o)=>/*#__PURE__*/ jsx("span", {
|
|
89
|
+
"data-option-chip": "true",
|
|
90
|
+
className: classnames('fwe-chip', {
|
|
91
|
+
'fwe-disabled': disabled
|
|
92
|
+
}),
|
|
93
|
+
style: {
|
|
94
|
+
minWidth: 0,
|
|
95
|
+
flexShrink: 1 === selectedOptions.length ? 1 : 0
|
|
96
|
+
},
|
|
97
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
98
|
+
className: "fr-multiselect-chip-ellipsis",
|
|
99
|
+
children: o.label
|
|
100
|
+
})
|
|
101
|
+
}, String(o.data))),
|
|
102
|
+
overflowCount > 0 && /*#__PURE__*/ jsxs(Fragment, {
|
|
103
|
+
children: [
|
|
104
|
+
/*#__PURE__*/ jsx("span", {
|
|
105
|
+
children: "..."
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsx("span", {
|
|
108
|
+
className: "fwe-chip",
|
|
109
|
+
children: overflowCount
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
}) : placeholder ?? ''
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsx("label", {
|
|
117
|
+
className: "fwe-select-label",
|
|
118
|
+
id: labelId,
|
|
119
|
+
htmlFor: id,
|
|
120
|
+
children: label || ''
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsx(ListboxOptions, {
|
|
123
|
+
className: "fwe-options-container fwe-options-container--multi-select",
|
|
124
|
+
as: "ul",
|
|
125
|
+
portal: false,
|
|
126
|
+
style: {
|
|
127
|
+
minWidth: 'var(--button-width)'
|
|
128
|
+
},
|
|
129
|
+
anchor: {
|
|
130
|
+
to: 'bottom start',
|
|
131
|
+
gap: 12,
|
|
132
|
+
padding: 8
|
|
133
|
+
},
|
|
134
|
+
children: options.map((option)=>/*#__PURE__*/ jsx(ListboxOption, {
|
|
135
|
+
value: option,
|
|
136
|
+
disabled: option.disabled,
|
|
137
|
+
as: "li",
|
|
138
|
+
style: {
|
|
139
|
+
cursor: option.disabled ? 'default' : 'pointer'
|
|
140
|
+
},
|
|
141
|
+
children: ({ selected })=>/*#__PURE__*/ jsxs("label", {
|
|
142
|
+
className: classnames('fwe-checkbox', {
|
|
143
|
+
'fwe-disabled': option.disabled
|
|
144
|
+
}),
|
|
145
|
+
style: {
|
|
146
|
+
pointerEvents: 'none',
|
|
147
|
+
cursor: 'pointer'
|
|
148
|
+
},
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ jsx("input", {
|
|
151
|
+
type: "checkbox",
|
|
152
|
+
checked: selected,
|
|
153
|
+
disabled: option.disabled,
|
|
154
|
+
readOnly: true,
|
|
155
|
+
tabIndex: -1,
|
|
156
|
+
style: {
|
|
157
|
+
pointerEvents: 'none',
|
|
158
|
+
cursor: 'pointer'
|
|
159
|
+
}
|
|
160
|
+
}),
|
|
161
|
+
/*#__PURE__*/ jsx("span", {
|
|
162
|
+
className: "fwe-checkbox-checkmark"
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ jsx("span", {
|
|
165
|
+
className: "fwe-checkbox-label-content",
|
|
166
|
+
children: option.label
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
}, String(option.data)))
|
|
171
|
+
}),
|
|
172
|
+
name && (value ?? []).map((selectedValue, index)=>/*#__PURE__*/ jsx("input", {
|
|
173
|
+
type: "hidden",
|
|
174
|
+
name: name,
|
|
175
|
+
value: String(selectedValue),
|
|
176
|
+
disabled: disabled
|
|
177
|
+
}, `${name}-${String(selectedValue)}-${index}`)),
|
|
178
|
+
hint && !error && /*#__PURE__*/ jsx("div", {
|
|
179
|
+
className: "fwe-select-description",
|
|
180
|
+
children: hint
|
|
181
|
+
}),
|
|
182
|
+
error && /*#__PURE__*/ jsx("div", {
|
|
183
|
+
className: "fwe-select-invalid",
|
|
184
|
+
children: error
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const MultiSelect = /*#__PURE__*/ forwardRef(MultiSelectComponent);
|
|
191
|
+
MultiSelect.displayName = 'MultiSelect';
|
|
192
|
+
export { MultiSelect };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export interface RadioButtonProps extends
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface RadioButtonProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'onChange' | 'checked' | 'defaultChecked' | 'value'> {
|
|
3
3
|
readonly id?: string;
|
|
4
4
|
readonly defaultChecked?: boolean;
|
|
5
5
|
readonly checked?: boolean;
|
|
6
|
-
readonly onChange?: (value: string) => void;
|
|
6
|
+
readonly onChange?: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
7
|
readonly name?: string;
|
|
8
8
|
readonly value?: string;
|
|
9
9
|
readonly labelPosition?: 'before' | 'after' | 'below';
|
|
@@ -11,4 +11,4 @@ export interface RadioButtonProps extends ClassNamePropsWithChildren {
|
|
|
11
11
|
readonly disabled?: boolean;
|
|
12
12
|
readonly required?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export declare
|
|
14
|
+
export declare const RadioButton: (props: RadioButtonProps & import("react").RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import { useContext } from "react";
|
|
3
|
+
import { forwardRef, useContext } from "react";
|
|
4
4
|
import { useId } from "../../utils/useId.js";
|
|
5
5
|
import { RadioGroupContext } from "./RadioGroupContext.js";
|
|
6
|
-
|
|
7
|
-
const { id: idProps, onChange, value, name, defaultChecked: defaultCheckedProp, checked, labelPosition = 'after', large = false, disabled = false, required = false, children, className } = props;
|
|
6
|
+
const RadioButton = /*#__PURE__*/ forwardRef(({ id: idProps, onChange, value, name, defaultChecked: defaultCheckedProp, checked, labelPosition = 'after', large = false, disabled = false, required = false, children, className, ...props }, ref)=>{
|
|
8
7
|
const { disabled: groupDisabled, labelPosition: groupLabelPosition, large: groupLarge, name: groupName, value: groupValue, required: groupRequired, handleValueChange: onGroupValueChange, isControlled } = useContext(RadioGroupContext);
|
|
9
8
|
const innerLabelPosition = groupLabelPosition ?? labelPosition;
|
|
10
9
|
const classes = classnames('fwe-radio', {
|
|
@@ -15,21 +14,22 @@ function RadioButton(props) {
|
|
|
15
14
|
'fwe-radio-lg': large || groupLarge
|
|
16
15
|
}, className);
|
|
17
16
|
const controlledChecked = void 0 !== checked || isControlled && void 0 !== groupValue ? Boolean(checked || groupValue === value) : void 0;
|
|
18
|
-
|
|
17
|
+
function getDefaultChecked() {
|
|
19
18
|
if (void 0 !== controlledChecked) return;
|
|
20
19
|
if (void 0 !== defaultCheckedProp) return defaultCheckedProp;
|
|
21
20
|
if (!isControlled && void 0 !== groupValue) return groupValue === value;
|
|
22
|
-
}
|
|
21
|
+
}
|
|
23
22
|
const defaultChecked = getDefaultChecked();
|
|
24
23
|
function handleChange(event) {
|
|
25
24
|
const newValue = event.target.value;
|
|
26
25
|
if (newValue) onGroupValueChange?.(newValue);
|
|
27
|
-
onChange?.(newValue);
|
|
26
|
+
onChange?.(newValue, event);
|
|
28
27
|
}
|
|
29
28
|
const id = useId(idProps);
|
|
30
29
|
return /*#__PURE__*/ jsxs("label", {
|
|
31
30
|
className: classes,
|
|
32
31
|
htmlFor: id,
|
|
32
|
+
ref: ref,
|
|
33
33
|
children: [
|
|
34
34
|
/*#__PURE__*/ jsxs("div", {
|
|
35
35
|
className: "fwe-radio-check",
|
|
@@ -43,12 +43,12 @@ function RadioButton(props) {
|
|
|
43
43
|
value: value,
|
|
44
44
|
onChange: handleChange,
|
|
45
45
|
disabled: disabled || groupDisabled,
|
|
46
|
-
required: required || groupRequired
|
|
46
|
+
required: required || groupRequired,
|
|
47
|
+
...props
|
|
47
48
|
}),
|
|
48
49
|
/*#__PURE__*/ jsx("div", {
|
|
49
50
|
className: "fwe-radio-checkmark"
|
|
50
|
-
})
|
|
51
|
-
' '
|
|
51
|
+
})
|
|
52
52
|
]
|
|
53
53
|
}),
|
|
54
54
|
/*#__PURE__*/ jsx("div", {
|
|
@@ -57,5 +57,6 @@ function RadioButton(props) {
|
|
|
57
57
|
})
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
|
-
}
|
|
60
|
+
});
|
|
61
|
+
RadioButton.displayName = 'RadioButton';
|
|
61
62
|
export { RadioButton };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
export interface RadioGroupProps extends ComponentPropsWithoutRef<'div'> {
|
|
2
|
+
export interface RadioGroupProps extends Omit<ComponentPropsWithoutRef<'div'>, 'value' | 'defaultValue'> {
|
|
3
3
|
readonly name?: string;
|
|
4
|
+
readonly required?: boolean;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly value?: string;
|
|
4
7
|
readonly defaultValue?: string;
|
|
5
8
|
readonly onValueChange?: (value: string) => void;
|
|
6
|
-
readonly value?: string;
|
|
7
9
|
readonly labelPosition?: 'before' | 'after' | 'below';
|
|
8
10
|
readonly large?: boolean;
|
|
9
|
-
readonly disabled?: boolean;
|
|
10
|
-
readonly required?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare const RadioGroup: (props: RadioGroupProps & import("react").RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ClassNamePropsWithChildren } from '../../utils/types';
|
|
1
|
+
import React, { type ChangeEvent, type ComponentPropsWithoutRef, type PropsWithChildren } from 'react';
|
|
3
2
|
export interface SegmentConfiguration {
|
|
4
3
|
readonly outline?: boolean;
|
|
5
4
|
readonly iconOnly?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export interface SegmentProps extends
|
|
6
|
+
export interface SegmentProps extends PropsWithChildren, Omit<ComponentPropsWithoutRef<'fieldset'>, 'onChange' | 'defaultValue' | 'required' | 'disabled'> {
|
|
8
7
|
readonly legend: string;
|
|
9
8
|
readonly config?: SegmentConfiguration;
|
|
10
|
-
readonly onChange?: (event:
|
|
9
|
+
readonly onChange?: (value: any, event: ChangeEvent<HTMLInputElement>) => void;
|
|
11
10
|
readonly value?: any;
|
|
12
11
|
}
|
|
13
|
-
export declare
|
|
12
|
+
export declare const Segment: (props: SegmentProps & React.RefAttributes<HTMLFieldSetElement>) => React.ReactElement | null;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import react from "react";
|
|
3
|
+
import react, { Children, forwardRef, isValidElement } from "react";
|
|
4
4
|
import { useControlled } from "../../utils/useControlled.js";
|
|
5
5
|
const defaultConfig = {
|
|
6
6
|
outline: true,
|
|
7
7
|
iconOnly: true
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
const { children, legend, config, onChange, className, value: valueProps } = props;
|
|
9
|
+
const Segment = /*#__PURE__*/ forwardRef(({ children, legend, config, onChange, className, value: valueProps, ...props }, ref)=>{
|
|
11
10
|
const innerConfig = {
|
|
12
11
|
...defaultConfig,
|
|
13
12
|
...config
|
|
@@ -15,8 +14,8 @@ function Segment(props) {
|
|
|
15
14
|
let useIcon = false;
|
|
16
15
|
let useIconAndText = false;
|
|
17
16
|
let tmpValue = '';
|
|
18
|
-
|
|
19
|
-
if (!/*#__PURE__*/
|
|
17
|
+
Children.forEach(children, (child, index)=>{
|
|
18
|
+
if (!/*#__PURE__*/ isValidElement(child)) return null;
|
|
20
19
|
if (0 === index && null !== child.props.icon) if (innerConfig.iconOnly) useIcon = true;
|
|
21
20
|
else useIconAndText = true;
|
|
22
21
|
if (child.props.checked) tmpValue = child.props.value;
|
|
@@ -26,8 +25,8 @@ function Segment(props) {
|
|
|
26
25
|
controlled: valueProps,
|
|
27
26
|
default: tmpValue
|
|
28
27
|
});
|
|
29
|
-
const handleChange = (
|
|
30
|
-
if (onChange) onChange(
|
|
28
|
+
const handleChange = (_value, event)=>{
|
|
29
|
+
if (onChange) onChange(_value, event);
|
|
31
30
|
setValue(_value);
|
|
32
31
|
};
|
|
33
32
|
return /*#__PURE__*/ jsxs("fieldset", {
|
|
@@ -36,6 +35,8 @@ function Segment(props) {
|
|
|
36
35
|
'fwe-segment-icon': useIcon,
|
|
37
36
|
'fwe-segment-icon-text': useIconAndText
|
|
38
37
|
}, className),
|
|
38
|
+
ref: ref,
|
|
39
|
+
...props,
|
|
39
40
|
children: [
|
|
40
41
|
/*#__PURE__*/ jsx("legend", {
|
|
41
42
|
className: "fwe-sr-only fwe-d-inline-block",
|
|
@@ -46,7 +47,6 @@ function Segment(props) {
|
|
|
46
47
|
children: react.Children.map(children, (child)=>{
|
|
47
48
|
if (!/*#__PURE__*/ react.isValidElement(child)) return null;
|
|
48
49
|
return /*#__PURE__*/ react.cloneElement(child, {
|
|
49
|
-
...child.props,
|
|
50
50
|
onChange: handleChange,
|
|
51
51
|
iconOnly: innerConfig.iconOnly,
|
|
52
52
|
checked: child.props.value === value
|
|
@@ -55,5 +55,6 @@ function Segment(props) {
|
|
|
55
55
|
})
|
|
56
56
|
]
|
|
57
57
|
});
|
|
58
|
-
}
|
|
58
|
+
});
|
|
59
|
+
Segment.displayName = 'Segment';
|
|
59
60
|
export { Segment };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export interface SegmentControlProps extends ClassNameProps {
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface SegmentControlProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'onChange' | 'value'> {
|
|
4
3
|
readonly label: string;
|
|
5
|
-
readonly name: string;
|
|
6
4
|
readonly value: any;
|
|
7
5
|
readonly checked?: boolean;
|
|
8
|
-
readonly disabled?: boolean;
|
|
9
6
|
readonly icon?: React.ReactNode;
|
|
10
|
-
readonly onChange?: (event: React.ChangeEvent<HTMLInputElement
|
|
11
|
-
readonly id?: string;
|
|
7
|
+
readonly onChange?: (value: any, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
8
|
readonly iconOnly?: boolean;
|
|
13
9
|
}
|
|
14
|
-
export declare
|
|
10
|
+
export declare const SegmentControl: (props: SegmentControlProps & import("react").RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import { useRef } from "react";
|
|
3
|
+
import { forwardRef, useRef } from "react";
|
|
4
4
|
import { IconWrapper } from "../../../components/icon-wrapper/IconWrapper.js";
|
|
5
|
-
|
|
6
|
-
const { label, checked, disabled, name, value, icon, onChange, id, className, iconOnly } = props;
|
|
5
|
+
const SegmentControl = /*#__PURE__*/ forwardRef(({ label, checked, disabled, name, value, icon, onChange, id, className, iconOnly, ...props }, ref)=>{
|
|
7
6
|
const componentId = useRef(id ?? (Math.random() * Date.now()).toString().replace('.', '-'));
|
|
8
7
|
let viewMode = 'text';
|
|
9
8
|
if (icon) viewMode = iconOnly ? 'icon' : 'icon-text';
|
|
10
9
|
const handleChange = (event)=>{
|
|
11
|
-
if (onChange) onChange(
|
|
10
|
+
if (onChange) onChange(value, event);
|
|
12
11
|
};
|
|
13
12
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
14
13
|
children: [
|
|
@@ -20,11 +19,13 @@ function SegmentControl(props) {
|
|
|
20
19
|
value: value,
|
|
21
20
|
checked: checked,
|
|
22
21
|
disabled: disabled,
|
|
23
|
-
onChange: (e)=>handleChange(e)
|
|
22
|
+
onChange: (e)=>handleChange(e),
|
|
23
|
+
...props
|
|
24
24
|
}),
|
|
25
25
|
/*#__PURE__*/ jsxs("label", {
|
|
26
26
|
className: classnames('fwe-segment-label', className),
|
|
27
27
|
htmlFor: componentId.current,
|
|
28
|
+
ref: ref,
|
|
28
29
|
children: [
|
|
29
30
|
'icon' === viewMode && /*#__PURE__*/ jsxs(Fragment, {
|
|
30
31
|
children: [
|
|
@@ -53,5 +54,6 @@ function SegmentControl(props) {
|
|
|
53
54
|
})
|
|
54
55
|
]
|
|
55
56
|
});
|
|
56
|
-
}
|
|
57
|
+
});
|
|
58
|
+
SegmentControl.displayName = 'SegmentControl';
|
|
57
59
|
export { SegmentControl };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly defaultValue?: T;
|
|
7
|
-
readonly defaultOpen?: boolean;
|
|
8
|
-
readonly open?: boolean;
|
|
9
|
-
readonly value?: T;
|
|
10
|
-
readonly label?: string;
|
|
11
|
-
readonly options?: SelectOptionType<T>[];
|
|
12
|
-
readonly required?: boolean;
|
|
13
|
-
readonly onChange?: (value: T) => void;
|
|
14
|
-
readonly config?: SelectConfiguration;
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type Ref } from 'react';
|
|
3
|
+
export interface SelectOption<T> {
|
|
4
|
+
readonly data: T;
|
|
5
|
+
readonly label: ReactNode;
|
|
15
6
|
readonly disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectProps<T> extends Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange' | 'value' | 'defaultValue'> {
|
|
9
|
+
readonly value?: T;
|
|
10
|
+
readonly defaultValue?: T;
|
|
16
11
|
readonly name?: string;
|
|
12
|
+
readonly disabled?: boolean;
|
|
13
|
+
readonly required?: boolean;
|
|
14
|
+
readonly label?: string;
|
|
15
|
+
readonly options?: SelectOption<T>[];
|
|
17
16
|
readonly hint?: string;
|
|
18
17
|
readonly error?: string;
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
18
|
+
readonly placeholder?: string;
|
|
19
|
+
readonly onChange?: (value: T) => void;
|
|
21
20
|
}
|
|
22
|
-
declare function SelectComponent<T>({ defaultValue,
|
|
21
|
+
declare function SelectComponent<T>({ defaultValue, value: controlled, label, options, onChange, disabled, name, id: idProp, hint, error, placeholder, className, ...props }: SelectProps<T>, ref: Ref<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
23
22
|
export declare const Select: <T>(props: SelectProps<T> & {
|
|
24
23
|
ref?: Ref<HTMLDivElement>;
|
|
25
24
|
}) => ReturnType<typeof SelectComponent>;
|