@festo-ui/react 4.0.3-pre-20221213.1 → 5.0.0-dev.46
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/index.css +3 -3202
- package/index.d.ts +50 -48
- package/index.js +50 -4797
- package/lib/components/accordion/Accordion.d.ts +9 -9
- package/lib/components/accordion/Accordion.js +38 -0
- package/lib/components/accordion/AccordionContext.d.ts +11 -11
- package/lib/components/accordion/AccordionContext.js +3 -0
- package/lib/components/accordion/accordion-header/AccordionHeader.d.ts +4 -4
- package/lib/components/accordion/accordion-header/AccordionHeader.js +17 -0
- package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -9
- package/lib/components/accordion/accordion-item/AccordionItem.js +64 -0
- package/lib/components/accordion/accordion-item/AccordionItemContext.d.ts +8 -8
- package/lib/components/accordion/accordion-item/AccordionItemContext.js +3 -0
- package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.d.ts +4 -4
- package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +71 -0
- package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.d.ts +4 -4
- package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +41 -0
- package/lib/components/breadcrumb/Breadcrumb.d.ts +14 -14
- package/lib/components/breadcrumb/Breadcrumb.js +45 -0
- package/lib/components/buttons/button/Button.d.ts +12 -12
- package/lib/components/buttons/button/Button.js +37 -0
- package/lib/components/card/Card.d.ts +4 -4
- package/lib/components/card/Card.js +13 -0
- package/lib/components/card/CardBody.d.ts +7 -7
- package/lib/components/card/CardBody.js +18 -0
- package/lib/components/card/CardHeader.d.ts +9 -9
- package/lib/components/card/CardHeader.js +23 -0
- package/lib/components/card/CardNotification.d.ts +9 -9
- package/lib/components/card/CardNotification.js +26 -0
- package/lib/components/chips/chip/Chip.d.ts +19 -19
- package/lib/components/chips/chip/Chip.js +46 -0
- package/lib/components/chips/chip/DeleteIcon.d.ts +2 -0
- package/lib/components/chips/chip/DeleteIcon.js +7 -0
- package/lib/components/chips/chip-container/ChipContainer.d.ts +8 -8
- package/lib/components/chips/chip-container/ChipContainer.js +17 -0
- package/lib/components/link-button/LinkButton.d.ts +10 -10
- package/lib/components/link-button/LinkButton.js +26 -0
- package/lib/components/loading-indicator/LoadingIndicator.d.ts +7 -7
- package/lib/components/loading-indicator/LoadingIndicator.js +40 -0
- package/lib/components/modals/AlertModal.d.ts +14 -14
- package/lib/components/modals/AlertModal.js +76 -0
- package/lib/components/modals/ConfirmModal.d.ts +13 -13
- package/lib/components/modals/ConfirmModal.js +56 -0
- package/lib/components/modals/Modal.d.ts +11 -11
- package/lib/components/modals/Modal.js +76 -0
- package/lib/components/modals/ModalFooter.d.ts +4 -4
- package/lib/components/modals/ModalFooter.js +18 -0
- package/lib/components/modals/Prompt.d.ts +16 -16
- package/lib/components/modals/Prompt.js +65 -0
- package/lib/components/pagination/Pagination.d.ts +17 -17
- package/lib/components/pagination/Pagination.js +107 -0
- package/lib/components/popovers/legend/Legend.d.ts +12 -12
- package/lib/components/popovers/legend/Legend.js +25 -0
- package/lib/components/popovers/popover/Popover.d.ts +18 -18
- package/lib/components/popovers/popover/Popover.js +109 -0
- package/lib/components/popovers/popover-menu/PopoverMenu.d.ts +15 -15
- package/lib/components/popovers/popover-menu/PopoverMenu.js +54 -0
- package/lib/components/popovers/tooltip/Tooltip.d.ts +10 -10
- package/lib/components/popovers/tooltip/Tooltip.js +64 -0
- package/lib/components/progress/Progress.d.ts +9 -9
- package/lib/components/progress/Progress.js +32 -0
- package/lib/components/search-input/ClearButton.d.ts +2 -0
- package/lib/components/search-input/ClearButton.js +10 -0
- package/lib/components/search-input/SearchInput.d.ts +15 -0
- package/lib/components/search-input/SearchInput.js +75 -0
- package/lib/components/search-input/SearchSuggestion.d.ts +17 -0
- package/lib/components/search-input/SearchSuggestion.js +32 -0
- package/lib/components/search-input/useSearchInput.d.ts +13 -0
- package/lib/components/search-input/useSearchInput.js +94 -0
- package/lib/components/snackbar/Snackbar.d.ts +23 -23
- package/lib/components/snackbar/Snackbar.js +87 -0
- package/lib/components/snackbar/SnackbarContext.d.ts +8 -8
- package/lib/components/snackbar/SnackbarContext.js +2 -0
- package/lib/components/snackbar/SnackbarProvider.d.ts +8 -8
- package/lib/components/snackbar/SnackbarProvider.js +58 -0
- package/lib/components/snackbar/useSnackbar.d.ts +3 -3
- package/lib/components/snackbar/useSnackbar.js +3 -0
- package/lib/components/stepper-horizontal/StepperHorizontal.d.ts +7 -7
- package/lib/components/stepper-horizontal/StepperHorizontal.js +62 -0
- package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.d.ts +7 -7
- package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +23 -0
- package/lib/components/stepper-vertical/StepperVertical.d.ts +7 -7
- package/lib/components/stepper-vertical/StepperVertical.js +37 -0
- package/lib/components/stepper-vertical/step-vertical/StepVertical.d.ts +12 -12
- package/lib/components/stepper-vertical/step-vertical/StepVertical.js +77 -0
- package/lib/components/tab/Tabs.d.ts +23 -23
- package/lib/components/tab/Tabs.js +229 -0
- package/lib/components/tab/interfaces.d.ts +5 -0
- package/lib/components/tab/interfaces.js +1 -0
- package/lib/components/tab/tab-pane/TabPane.d.ts +11 -13
- package/lib/components/tab/tab-pane/TabPane.js +23 -0
- package/lib/components/tab/useTabScroll.d.ts +24 -24
- package/lib/components/tab/useTabScroll.js +233 -0
- package/lib/components/table-header-cell/TableHeaderCell.d.ts +7 -7
- package/lib/components/table-header-cell/TableHeaderCell.js +21 -0
- package/lib/forms/checkbox/Checkbox.d.ts +16 -16
- package/lib/forms/checkbox/Checkbox.js +88 -0
- package/lib/forms/color-indicator/ColorIndicator.d.ts +12 -12
- package/lib/forms/color-indicator/ColorIndicator.js +122 -0
- package/lib/forms/color-picker/ColorHelper.d.ts +9 -9
- package/lib/forms/color-picker/ColorHelper.js +142 -0
- package/lib/forms/color-picker/ColorPicker.d.ts +15 -15
- package/lib/forms/color-picker/ColorPicker.js +539 -0
- package/lib/forms/date-picker/DatePicker.d.ts +22 -21
- package/lib/forms/date-picker/DatePicker.js +124 -0
- package/lib/forms/date-range-picker/DateRangePicker.d.ts +20 -20
- package/lib/forms/date-range-picker/DateRangePicker.js +135 -0
- package/lib/forms/radio/RadioButton.d.ts +15 -15
- package/lib/forms/radio/RadioButton.js +56 -0
- package/lib/forms/radio/RadioGroup.d.ts +13 -13
- package/lib/forms/radio/RadioGroup.js +35 -0
- package/lib/forms/radio/RadioGroupContext.d.ts +12 -12
- package/lib/forms/radio/RadioGroupContext.js +3 -0
- package/lib/forms/segment/Segment.d.ts +14 -14
- package/lib/forms/segment/Segment.js +77 -0
- package/lib/forms/segment/segment-control/SegmentControl.d.ts +15 -15
- package/lib/forms/segment/segment-control/SegmentControl.js +64 -0
- package/lib/forms/select/Select.d.ts +26 -26
- package/lib/forms/select/Select.js +281 -0
- package/lib/forms/select/select-option/SelectOption.d.ts +10 -10
- package/lib/forms/select/select-option/SelectOption.js +16 -0
- package/lib/forms/slider/Slider.d.ts +18 -17
- package/lib/forms/slider/Slider.js +92 -0
- package/lib/forms/switch/Switch.d.ts +13 -12
- package/lib/forms/switch/Switch.js +51 -0
- package/lib/forms/text-area/TextArea.d.ts +22 -21
- package/lib/forms/text-area/TextArea.js +108 -0
- package/lib/forms/text-editor/TextEditor.d.ts +29 -29
- package/lib/forms/text-editor/TextEditor.js +255 -0
- package/lib/forms/text-editor/TextEditorButton.d.ts +14 -14
- package/lib/forms/text-editor/TextEditorButton.js +82 -0
- package/lib/forms/text-input/TextInput.d.ts +21 -21
- package/lib/forms/text-input/TextInput.js +75 -0
- package/lib/forms/time-picker/TimePicker.d.ts +18 -18
- package/lib/forms/time-picker/TimePicker.js +161 -0
- package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.d.ts +12 -12
- package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +213 -0
- package/lib/helper/index.d.ts +2 -2
- package/lib/helper/index.js +7 -0
- package/lib/helper/setRef.d.ts +2 -2
- package/lib/helper/setRef.js +7 -0
- package/lib/helper/types.d.ts +7 -7
- package/lib/helper/types.js +1 -0
- package/lib/helper/useControlled.d.ts +6 -6
- package/lib/helper/useControlled.js +18 -0
- package/lib/helper/useForkRef.d.ts +2 -2
- package/lib/helper/useForkRef.js +20 -0
- package/lib/helper/useId.d.ts +1 -0
- package/lib/helper/useId.js +21 -0
- package/lib/helper/useOnClickOutside.d.ts +2 -2
- package/lib/helper/useOnClickOutside.js +18 -0
- package/node/index.js +370 -0
- package/node/lib/components/accordion/Accordion.js +46 -0
- package/node/lib/components/accordion/AccordionContext.js +10 -0
- package/node/lib/components/accordion/accordion-header/AccordionHeader.js +25 -0
- package/node/lib/components/accordion/accordion-item/AccordionItem.js +71 -0
- package/node/lib/components/accordion/accordion-item/AccordionItemContext.js +10 -0
- package/node/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.js +78 -0
- package/node/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.js +49 -0
- package/node/lib/components/breadcrumb/Breadcrumb.js +52 -0
- package/node/lib/components/buttons/button/Button.js +44 -0
- package/node/lib/components/card/Card.js +21 -0
- package/node/lib/components/card/CardBody.js +25 -0
- package/node/lib/components/card/CardHeader.js +30 -0
- package/node/lib/components/card/CardNotification.js +33 -0
- package/node/lib/components/chips/chip/Chip.js +54 -0
- package/node/lib/components/chips/chip/DeleteIcon.js +13 -0
- package/node/lib/components/chips/chip-container/ChipContainer.js +25 -0
- package/node/lib/components/link-button/LinkButton.js +33 -0
- package/node/lib/components/loading-indicator/LoadingIndicator.js +48 -0
- package/node/lib/components/modals/AlertModal.js +82 -0
- package/node/lib/components/modals/ConfirmModal.js +62 -0
- package/node/lib/components/modals/Modal.js +84 -0
- package/node/lib/components/modals/ModalFooter.js +26 -0
- package/node/lib/components/modals/Prompt.js +72 -0
- package/node/lib/components/pagination/Pagination.js +116 -0
- package/node/lib/components/popovers/legend/Legend.js +32 -0
- package/node/lib/components/popovers/popover/Popover.js +117 -0
- package/node/lib/components/popovers/popover-menu/PopoverMenu.js +61 -0
- package/node/lib/components/popovers/tooltip/Tooltip.js +70 -0
- package/node/lib/components/progress/Progress.js +40 -0
- package/node/lib/components/search-input/ClearButton.js +16 -0
- package/node/lib/components/search-input/SearchInput.js +82 -0
- package/node/lib/components/search-input/SearchSuggestion.js +39 -0
- package/node/lib/components/search-input/useSearchInput.js +101 -0
- package/node/lib/components/snackbar/Snackbar.js +94 -0
- package/node/lib/components/snackbar/SnackbarContext.js +10 -0
- package/node/lib/components/snackbar/SnackbarProvider.js +65 -0
- package/node/lib/components/snackbar/useSnackbar.js +11 -0
- package/node/lib/components/stepper-horizontal/StepperHorizontal.js +70 -0
- package/node/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js +31 -0
- package/node/lib/components/stepper-vertical/StepperVertical.js +47 -0
- package/node/lib/components/stepper-vertical/step-vertical/StepVertical.js +84 -0
- package/node/lib/components/tab/Tabs.js +237 -0
- package/node/lib/components/tab/interfaces.js +5 -0
- package/node/lib/components/tab/tab-pane/TabPane.js +31 -0
- package/node/lib/components/tab/useTabScroll.js +236 -0
- package/node/lib/components/table-header-cell/TableHeaderCell.js +29 -0
- package/node/lib/forms/checkbox/Checkbox.js +97 -0
- package/node/lib/forms/color-indicator/ColorIndicator.js +130 -0
- package/node/lib/forms/color-picker/ColorHelper.js +149 -0
- package/node/lib/forms/color-picker/ColorPicker.js +549 -0
- package/node/lib/forms/date-picker/DatePicker.js +131 -0
- package/node/lib/forms/date-range-picker/DateRangePicker.js +142 -0
- package/node/lib/forms/radio/RadioButton.js +63 -0
- package/node/lib/forms/radio/RadioGroup.js +43 -0
- package/node/lib/forms/radio/RadioGroupContext.js +10 -0
- package/node/lib/forms/segment/Segment.js +84 -0
- package/node/lib/forms/segment/segment-control/SegmentControl.js +72 -0
- package/node/lib/forms/select/Select.js +289 -0
- package/node/lib/forms/select/select-option/SelectOption.js +26 -0
- package/node/lib/forms/slider/Slider.js +101 -0
- package/node/lib/forms/switch/Switch.js +58 -0
- package/node/lib/forms/text-area/TextArea.js +117 -0
- package/node/lib/forms/text-editor/TextEditor.js +261 -0
- package/node/lib/forms/text-editor/TextEditorButton.js +88 -0
- package/node/lib/forms/text-input/TextInput.js +84 -0
- package/node/lib/forms/time-picker/TimePicker.js +169 -0
- package/node/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.js +222 -0
- package/node/lib/helper/index.js +15 -0
- package/node/lib/helper/setRef.js +13 -0
- package/node/lib/helper/types.js +5 -0
- package/node/lib/helper/useControlled.js +24 -0
- package/node/lib/helper/useForkRef.js +26 -0
- package/node/lib/helper/useId.js +27 -0
- package/node/lib/helper/useOnClickOutside.js +24 -0
- package/package.json +20 -10
- package/README.md +0 -17
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _flatpickr = _interopRequireDefault(require("flatpickr"));
|
|
9
|
+
var _rangePlugin = _interopRequireDefault(require("flatpickr/dist/plugins/rangePlugin"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _useId = _interopRequireDefault(require("../../helper/useId"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function DateRangePicker(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
disabled,
|
|
19
|
+
error,
|
|
20
|
+
formatDate,
|
|
21
|
+
hint,
|
|
22
|
+
onChange,
|
|
23
|
+
options,
|
|
24
|
+
required,
|
|
25
|
+
defaultValue = new Date()
|
|
26
|
+
} = _ref;
|
|
27
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
28
|
+
const [calendar, setCalendar] = (0, _react.useState)(null);
|
|
29
|
+
const id = (0, _useId.default)();
|
|
30
|
+
function toggle() {
|
|
31
|
+
const newOpen = !open;
|
|
32
|
+
setOpen(newOpen);
|
|
33
|
+
if (newOpen) {
|
|
34
|
+
calendar?.open();
|
|
35
|
+
} else {
|
|
36
|
+
calendar?.close();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const inputRef = (0, _react.useRef)(null);
|
|
40
|
+
const input2Ref = (0, _react.useRef)(null);
|
|
41
|
+
const containerRef = (0, _react.useRef)(null);
|
|
42
|
+
(0, _react.useEffect)(() => {
|
|
43
|
+
function handleChange(dates) {
|
|
44
|
+
if (onChange) {
|
|
45
|
+
onChange(dates);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function handleClose() {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
inputRef.current?.blur();
|
|
51
|
+
input2Ref.current?.blur();
|
|
52
|
+
}
|
|
53
|
+
if (containerRef.current && inputRef.current && input2Ref.current && calendar === null) {
|
|
54
|
+
setCalendar((0, _flatpickr.default)(inputRef.current, {
|
|
55
|
+
defaultDate: defaultValue,
|
|
56
|
+
plugins: [(0, _rangePlugin.default)({
|
|
57
|
+
input: input2Ref.current
|
|
58
|
+
})],
|
|
59
|
+
onChange: v => handleChange(v),
|
|
60
|
+
position: 'below center',
|
|
61
|
+
positionElement: containerRef.current,
|
|
62
|
+
formatDate,
|
|
63
|
+
closeOnSelect: !options?.keepOpenOnDateChange ?? true,
|
|
64
|
+
clickOpens: false,
|
|
65
|
+
onClose: handleClose,
|
|
66
|
+
minDate: options?.minDate,
|
|
67
|
+
maxDate: options?.maxDate
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
}, [inputRef, input2Ref, containerRef, formatDate, options, onChange, calendar, defaultValue]);
|
|
71
|
+
(0, _react.useEffect)(() => () => {
|
|
72
|
+
if (calendar !== null) {
|
|
73
|
+
calendar.destroy();
|
|
74
|
+
}
|
|
75
|
+
}, [calendar]);
|
|
76
|
+
const handleKeyDown = event => {
|
|
77
|
+
if (event.key === 'Enter') {
|
|
78
|
+
toggle();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const handleKeyUp = event => {
|
|
82
|
+
if (event.key === ' ') {
|
|
83
|
+
toggle();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
|
+
tabIndex: 0,
|
|
88
|
+
role: "button",
|
|
89
|
+
className: (0, _classnames.default)('fr-date-range-picker', className),
|
|
90
|
+
onClick: toggle,
|
|
91
|
+
onKeyDown: handleKeyDown,
|
|
92
|
+
onKeyUp: handleKeyUp,
|
|
93
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
94
|
+
className: "fwe-input-text fwe-input-text-icon",
|
|
95
|
+
htmlFor: id,
|
|
96
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
97
|
+
className: (0, _classnames.default)('fwe-icon fwe-icon-time-calendar', {
|
|
98
|
+
'fwe-color-hero': open && !disabled,
|
|
99
|
+
'fwe-color-control-disabled': disabled
|
|
100
|
+
})
|
|
101
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
102
|
+
ref: containerRef,
|
|
103
|
+
className: "fr-date-range-picker-inputs",
|
|
104
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
105
|
+
ref: inputRef,
|
|
106
|
+
"aria-label": "picked start date",
|
|
107
|
+
type: "text",
|
|
108
|
+
readOnly: true,
|
|
109
|
+
required: required,
|
|
110
|
+
className: (0, _classnames.default)({
|
|
111
|
+
'fwe-border-hero': open && !disabled
|
|
112
|
+
}),
|
|
113
|
+
disabled: disabled,
|
|
114
|
+
id: id
|
|
115
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
116
|
+
ref: input2Ref,
|
|
117
|
+
"aria-label": "picked end date",
|
|
118
|
+
type: "text",
|
|
119
|
+
readOnly: true,
|
|
120
|
+
required: required,
|
|
121
|
+
className: (0, _classnames.default)({
|
|
122
|
+
'fwe-border-hero': open && !disabled
|
|
123
|
+
}),
|
|
124
|
+
disabled: disabled
|
|
125
|
+
})]
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
127
|
+
className: (0, _classnames.default)('fwe-input-text-label', {
|
|
128
|
+
'fwe-color-text-disabled': disabled
|
|
129
|
+
}),
|
|
130
|
+
children: children
|
|
131
|
+
}), hint && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
132
|
+
className: "fwe-input-text-info",
|
|
133
|
+
children: hint
|
|
134
|
+
}), error && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
135
|
+
className: "fwe-input-text-invalid",
|
|
136
|
+
children: error
|
|
137
|
+
})]
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var _default = DateRangePicker;
|
|
142
|
+
exports.default = _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _RadioGroupContext = _interopRequireDefault(require("./RadioGroupContext"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function RadioButton(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
id,
|
|
15
|
+
onChange,
|
|
16
|
+
value,
|
|
17
|
+
name,
|
|
18
|
+
checked,
|
|
19
|
+
labelPosition = 'after',
|
|
20
|
+
large = false,
|
|
21
|
+
disabled = false,
|
|
22
|
+
required = false,
|
|
23
|
+
children,
|
|
24
|
+
className
|
|
25
|
+
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
disabled: groupDisabled,
|
|
28
|
+
labelPosition: groupLabelPosition,
|
|
29
|
+
large: groupLarge,
|
|
30
|
+
name: groupName,
|
|
31
|
+
required: groupRequired,
|
|
32
|
+
value: groupValue
|
|
33
|
+
} = (0, _react.useContext)(_RadioGroupContext.default);
|
|
34
|
+
const innerLabelPosition = groupLabelPosition || labelPosition;
|
|
35
|
+
const classes = (0, _classnames.default)('fwe-radio', {
|
|
36
|
+
'fwe-radio-label-below': innerLabelPosition === 'below'
|
|
37
|
+
}, {
|
|
38
|
+
'fwe-radio-label-before': innerLabelPosition === 'before'
|
|
39
|
+
}, {
|
|
40
|
+
'fwe-radio-lg': large || groupLarge
|
|
41
|
+
}, className);
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
43
|
+
className: classes,
|
|
44
|
+
htmlFor: id,
|
|
45
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
46
|
+
checked: checked,
|
|
47
|
+
type: "radio",
|
|
48
|
+
id: id,
|
|
49
|
+
name: groupName || name,
|
|
50
|
+
value: value || groupValue,
|
|
51
|
+
onChange: () => onChange(value),
|
|
52
|
+
disabled: disabled || groupDisabled,
|
|
53
|
+
required: required || groupRequired
|
|
54
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
55
|
+
className: "fwe-radio-checkmark"
|
|
56
|
+
}), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
57
|
+
className: "fwe-radio-label-content",
|
|
58
|
+
children: children
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var _default = RadioButton;
|
|
63
|
+
exports.default = _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _RadioGroupContext = _interopRequireDefault(require("./RadioGroupContext"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function RadioGroup(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
value,
|
|
15
|
+
name,
|
|
16
|
+
checked,
|
|
17
|
+
labelPosition = 'after',
|
|
18
|
+
large,
|
|
19
|
+
disabled,
|
|
20
|
+
required,
|
|
21
|
+
children,
|
|
22
|
+
className
|
|
23
|
+
} = _ref;
|
|
24
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
25
|
+
value,
|
|
26
|
+
name,
|
|
27
|
+
checked,
|
|
28
|
+
labelPosition,
|
|
29
|
+
large,
|
|
30
|
+
disabled,
|
|
31
|
+
required
|
|
32
|
+
}), []);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioGroupContext.default.Provider, {
|
|
34
|
+
value: contextValue,
|
|
35
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
36
|
+
className: (0, _classnames.default)('fwe-radio-group', className),
|
|
37
|
+
role: "radiogroup",
|
|
38
|
+
children: children
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var _default = RadioGroup;
|
|
43
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const RadioGroupContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
9
|
+
var _default = RadioGroupContext;
|
|
10
|
+
exports.default = _default;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _useControlled = _interopRequireDefault(require("../../helper/useControlled"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const defaultConfig = {
|
|
13
|
+
outline: true,
|
|
14
|
+
iconOnly: true
|
|
15
|
+
};
|
|
16
|
+
function Segment(props) {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
legend,
|
|
20
|
+
config,
|
|
21
|
+
onChange,
|
|
22
|
+
className,
|
|
23
|
+
value: valueProps
|
|
24
|
+
} = props;
|
|
25
|
+
const innerConfig = {
|
|
26
|
+
...defaultConfig,
|
|
27
|
+
...config
|
|
28
|
+
};
|
|
29
|
+
let useIcon = false;
|
|
30
|
+
let useIconAndText = false;
|
|
31
|
+
let tmpValue = '';
|
|
32
|
+
_react.default.Children.forEach(children, (child, index) => {
|
|
33
|
+
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (index === 0 && child.props.icon !== null) {
|
|
37
|
+
if (innerConfig.iconOnly) {
|
|
38
|
+
useIcon = true;
|
|
39
|
+
} else {
|
|
40
|
+
useIconAndText = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (child.props.checked) {
|
|
44
|
+
tmpValue = child.props.value;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
});
|
|
48
|
+
const [value, setValue] = (0, _useControlled.default)({
|
|
49
|
+
controlled: valueProps,
|
|
50
|
+
default: tmpValue
|
|
51
|
+
});
|
|
52
|
+
const handleChange = (event, _value) => {
|
|
53
|
+
if (onChange) {
|
|
54
|
+
onChange(event, _value);
|
|
55
|
+
}
|
|
56
|
+
setValue(_value);
|
|
57
|
+
};
|
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
|
|
59
|
+
className: (0, _classnames.default)('fwe-segment', {
|
|
60
|
+
'fwe-segment-outline': innerConfig.outline,
|
|
61
|
+
'fwe-segment-icon': useIcon,
|
|
62
|
+
'fwe-segment-icon-text': useIconAndText
|
|
63
|
+
}, className),
|
|
64
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("legend", {
|
|
65
|
+
className: "fwe-sr-only fwe-d-inline-block",
|
|
66
|
+
children: legend
|
|
67
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
68
|
+
className: "fwe-segment-group",
|
|
69
|
+
children: _react.default.Children.map(children, child => {
|
|
70
|
+
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
74
|
+
...child.props,
|
|
75
|
+
onChange: handleChange,
|
|
76
|
+
iconOnly: innerConfig.iconOnly,
|
|
77
|
+
checked: child.props.value === value
|
|
78
|
+
});
|
|
79
|
+
})
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var _default = Segment;
|
|
84
|
+
exports.default = _default;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
function SegmentControl(props) {
|
|
14
|
+
const {
|
|
15
|
+
label,
|
|
16
|
+
checked,
|
|
17
|
+
disabled,
|
|
18
|
+
name,
|
|
19
|
+
value,
|
|
20
|
+
icon,
|
|
21
|
+
onChange,
|
|
22
|
+
iconOnly,
|
|
23
|
+
id,
|
|
24
|
+
className
|
|
25
|
+
} = props;
|
|
26
|
+
const componentId = (0, _react.useRef)(id ?? (Math.random() * Date.now()).toString().replace('.', '-'));
|
|
27
|
+
let viewMode = 'text';
|
|
28
|
+
if (icon) {
|
|
29
|
+
viewMode = iconOnly ? 'icon' : 'icon-text';
|
|
30
|
+
}
|
|
31
|
+
const prefix = 'fwe-icon-';
|
|
32
|
+
let innerIcon = icon;
|
|
33
|
+
if (icon && icon.indexOf(prefix) === -1) {
|
|
34
|
+
innerIcon = prefix + icon;
|
|
35
|
+
}
|
|
36
|
+
const handleChange = event => {
|
|
37
|
+
if (onChange) {
|
|
38
|
+
onChange(event, value);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
42
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
43
|
+
className: "fwe-segment-input",
|
|
44
|
+
type: "radio",
|
|
45
|
+
id: componentId.current,
|
|
46
|
+
name: name,
|
|
47
|
+
value: value,
|
|
48
|
+
checked: checked,
|
|
49
|
+
disabled: disabled,
|
|
50
|
+
onChange: e => handleChange(e)
|
|
51
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
52
|
+
className: (0, _classnames.default)('fwe-segment-label', className),
|
|
53
|
+
htmlFor: componentId.current,
|
|
54
|
+
children: [viewMode === 'icon' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
55
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
56
|
+
className: "fwe-sr-only",
|
|
57
|
+
children: label
|
|
58
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
className: (0, _classnames.default)('fwe-icon', innerIcon)
|
|
61
|
+
})]
|
|
62
|
+
}), viewMode === 'text' && label, viewMode === 'icon-text' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
63
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
64
|
+
"aria-hidden": "true",
|
|
65
|
+
className: (0, _classnames.default)('fwe-icon', innerIcon)
|
|
66
|
+
}), label]
|
|
67
|
+
})]
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
var _default = SegmentControl;
|
|
72
|
+
exports.default = _default;
|