@festo-ui/react 4.0.3-pre-20221124.8 → 5.0.0-dev.102
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,237 @@
|
|
|
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 = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _useForkRef = _interopRequireDefault(require("../../helper/useForkRef"));
|
|
10
|
+
var _useTabScroll = _interopRequireDefault(require("./useTabScroll"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
let nextId = 0;
|
|
16
|
+
const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
17
|
+
let {
|
|
18
|
+
config,
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
onChange,
|
|
22
|
+
viewType = 'responsive',
|
|
23
|
+
showDivider = false,
|
|
24
|
+
...props
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [useCompactDensity, setCompactDensity] = (0, _react.useState)(true);
|
|
27
|
+
const componentId = (0, _react.useRef)(`tabs-${++nextId}`);
|
|
28
|
+
const elRef = (0, _react.useRef)(null);
|
|
29
|
+
const combinedRef = (0, _useForkRef.default)(ref, elRef);
|
|
30
|
+
const scrollContent = (0, _react.useRef)(null);
|
|
31
|
+
const scrollArea = (0, _react.useRef)(null);
|
|
32
|
+
const observer = (0, _react.useRef)(null);
|
|
33
|
+
let activeId = '';
|
|
34
|
+
_react.default.Children.forEach(children, (element, i) => {
|
|
35
|
+
if ( /*#__PURE__*/_react.default.isValidElement(element)) {
|
|
36
|
+
if (activeId === '') {
|
|
37
|
+
activeId = `${componentId.current}-tab-panel-${i}`;
|
|
38
|
+
} else if (element.props.active) {
|
|
39
|
+
activeId = `${componentId.current}-tab-panel-${i}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const [currentId, setId] = (0, _react.useState)(activeId);
|
|
44
|
+
const innerChildren = _react.default.Children.map(children, (element, i) => {
|
|
45
|
+
if ( /*#__PURE__*/(0, _react.isValidElement)(element)) {
|
|
46
|
+
const newId = `${componentId.current}-tab-panel-${i}`;
|
|
47
|
+
return /*#__PURE__*/_react.default.cloneElement(element, {
|
|
48
|
+
isVisible: newId === currentId,
|
|
49
|
+
active: newId === currentId,
|
|
50
|
+
id: newId,
|
|
51
|
+
tabId: `${componentId.current}-tab-${i}`,
|
|
52
|
+
...element.props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
});
|
|
57
|
+
const [handleTabScroll, classes, style] = (0, _useTabScroll.default)(innerChildren?.length ?? 0, componentId.current, {
|
|
58
|
+
elRef,
|
|
59
|
+
scrollContent,
|
|
60
|
+
scrollArea
|
|
61
|
+
});
|
|
62
|
+
(0, _react.useEffect)(() => {
|
|
63
|
+
const {
|
|
64
|
+
current
|
|
65
|
+
} = scrollArea;
|
|
66
|
+
if (current) {
|
|
67
|
+
const initialWidth = current.offsetWidth;
|
|
68
|
+
if (initialWidth > 768) {
|
|
69
|
+
setCompactDensity(false);
|
|
70
|
+
}
|
|
71
|
+
observer.current = new ResizeObserver(() => {
|
|
72
|
+
const width = current.offsetWidth;
|
|
73
|
+
if (width > 768 && useCompactDensity) {
|
|
74
|
+
setCompactDensity(false);
|
|
75
|
+
} else if (width <= 768 && !useCompactDensity) {
|
|
76
|
+
setCompactDensity(true);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (current) {
|
|
80
|
+
observer.current.observe(current);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return () => {
|
|
84
|
+
if (current && observer && observer.current) {
|
|
85
|
+
observer.current.unobserve(current);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}, [useCompactDensity]);
|
|
89
|
+
const showTabPane = id => {
|
|
90
|
+
if (id === undefined || id === null) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (onChange) {
|
|
94
|
+
onChange({
|
|
95
|
+
previous: currentId,
|
|
96
|
+
current: id
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
setId(id);
|
|
100
|
+
};
|
|
101
|
+
function handleClick(e, index, id) {
|
|
102
|
+
handleTabScroll(e, index);
|
|
103
|
+
if (id !== undefined) {
|
|
104
|
+
showTabPane(id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return (
|
|
108
|
+
/*#__PURE__*/
|
|
109
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
110
|
+
(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
111
|
+
children: viewType === 'legacy' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
112
|
+
className: (0, _classnames.default)('fwe-legacy-tabs', className),
|
|
113
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
114
|
+
role: "tablist",
|
|
115
|
+
className: (0, _classnames.default)('fwe-legacy-tab-bar', {
|
|
116
|
+
'fwe-legacy-tab-bar-full-width': config?.tabBar?.fullWidth
|
|
117
|
+
}, {
|
|
118
|
+
'fwe-legacy-tab-items-equal-width': config?.tabItems?.appearance === 'equal'
|
|
119
|
+
}, {
|
|
120
|
+
'fwe-legacy-tab-items-fill': config?.tabItems?.appearance === 'fill'
|
|
121
|
+
}),
|
|
122
|
+
children: innerChildren && innerChildren.map((child, i) => {
|
|
123
|
+
const {
|
|
124
|
+
active,
|
|
125
|
+
icon,
|
|
126
|
+
name,
|
|
127
|
+
id,
|
|
128
|
+
tabId
|
|
129
|
+
} = child.props;
|
|
130
|
+
return (
|
|
131
|
+
/*#__PURE__*/
|
|
132
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
133
|
+
(0, _jsxRuntime.jsx)("li", {
|
|
134
|
+
className: (0, _classnames.default)('fwe-legacy-tab-item', {
|
|
135
|
+
'fwe-active': active
|
|
136
|
+
}),
|
|
137
|
+
onClick: () => showTabPane(id),
|
|
138
|
+
children: icon ?
|
|
139
|
+
/*#__PURE__*/
|
|
140
|
+
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
141
|
+
(0, _jsxRuntime.jsxs)("a", {
|
|
142
|
+
id: tabId,
|
|
143
|
+
className: (0, _classnames.default)('fwe-legacy-tab-link', {
|
|
144
|
+
'fwe-can-swap-icon': innerChildren.length === 2 && i === 1
|
|
145
|
+
}),
|
|
146
|
+
role: "tab",
|
|
147
|
+
"aria-controls": id,
|
|
148
|
+
"aria-selected": active,
|
|
149
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
150
|
+
className: `fwe-icon ${icon}`
|
|
151
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
152
|
+
children: name
|
|
153
|
+
})]
|
|
154
|
+
}) :
|
|
155
|
+
/*#__PURE__*/
|
|
156
|
+
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
157
|
+
(0, _jsxRuntime.jsx)("a", {
|
|
158
|
+
id: tabId,
|
|
159
|
+
className: "fwe-legacy-tab-link",
|
|
160
|
+
role: "tab",
|
|
161
|
+
"aria-controls": id,
|
|
162
|
+
"aria-selected": active,
|
|
163
|
+
children: name
|
|
164
|
+
})
|
|
165
|
+
}, tabId)
|
|
166
|
+
);
|
|
167
|
+
})
|
|
168
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
169
|
+
className: "fwe-legacy-tab-panel-content",
|
|
170
|
+
children: innerChildren
|
|
171
|
+
})]
|
|
172
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
173
|
+
className: "fr-tab-bar",
|
|
174
|
+
role: "tablist",
|
|
175
|
+
ref: combinedRef,
|
|
176
|
+
...props,
|
|
177
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
178
|
+
className: (0, _classnames.default)('fr-tab-scroller', classes),
|
|
179
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
180
|
+
className: (0, _classnames.default)('fr-tab-scroller-scroll-area fr-tab-scroller-scroll-area--scroll', {
|
|
181
|
+
'fr-tab-scroller-scroll-area--compact': useCompactDensity
|
|
182
|
+
}),
|
|
183
|
+
ref: scrollArea,
|
|
184
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
185
|
+
className: (0, _classnames.default)('fr-tab-scroller-scroll-content', {
|
|
186
|
+
'fr-tab-scroller-scroll-content--with-divider': showDivider
|
|
187
|
+
}),
|
|
188
|
+
ref: scrollContent,
|
|
189
|
+
style: style,
|
|
190
|
+
children: [innerChildren && innerChildren.map((child, i) => {
|
|
191
|
+
const {
|
|
192
|
+
active,
|
|
193
|
+
name,
|
|
194
|
+
id,
|
|
195
|
+
tabId
|
|
196
|
+
} = child.props;
|
|
197
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
198
|
+
type: "button",
|
|
199
|
+
role: "tab",
|
|
200
|
+
className: (0, _classnames.default)('fr-tab', {
|
|
201
|
+
'fr-tab--active': active
|
|
202
|
+
}),
|
|
203
|
+
id: tabId,
|
|
204
|
+
"aria-controls": id,
|
|
205
|
+
"aria-selected": active,
|
|
206
|
+
tabIndex: i === 0 ? 0 : 1,
|
|
207
|
+
onClick: e => handleClick(e, i, id),
|
|
208
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
209
|
+
className: "fr-tab-content",
|
|
210
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
211
|
+
className: "fr-tab-text-label",
|
|
212
|
+
children: name
|
|
213
|
+
})
|
|
214
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
215
|
+
className: (0, _classnames.default)('fr-tab-indicator', {
|
|
216
|
+
'fr-tab-indicator--active': active
|
|
217
|
+
}),
|
|
218
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
219
|
+
className: "fr-tab-indicator-content fr-tab-indicator-content--underline"
|
|
220
|
+
})
|
|
221
|
+
})]
|
|
222
|
+
}, tabId);
|
|
223
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
224
|
+
className: "fr-tab-scroller-divider-line"
|
|
225
|
+
})]
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
229
|
+
className: "fr-tab-panel-content",
|
|
230
|
+
children: innerChildren
|
|
231
|
+
})]
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
var _default = Tabs;
|
|
237
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function TabPane(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
isVisible = false,
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
tabId,
|
|
16
|
+
id
|
|
17
|
+
} = _ref;
|
|
18
|
+
const tabPaneClasses = (0, _classnames.default)({
|
|
19
|
+
'fr-show': isVisible
|
|
20
|
+
}, {
|
|
21
|
+
'fr-hide': !isVisible
|
|
22
|
+
}, className);
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
24
|
+
id: id,
|
|
25
|
+
"aria-labelledby": tabId,
|
|
26
|
+
className: tabPaneClasses,
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var _default = TabPane;
|
|
31
|
+
exports.default = _default;
|
|
@@ -0,0 +1,236 @@
|
|
|
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 useTabScroll = (tabLength, componentId, refs) => {
|
|
9
|
+
const {
|
|
10
|
+
elRef,
|
|
11
|
+
scrollContent,
|
|
12
|
+
scrollArea
|
|
13
|
+
} = refs;
|
|
14
|
+
const [style, setStyle] = (0, _react.useState)({});
|
|
15
|
+
const [classes, setClasses] = (0, _react.useState)('');
|
|
16
|
+
function getScrollContentStyleValue(propName) {
|
|
17
|
+
return scrollContent.current ? window.getComputedStyle(scrollContent.current).getPropertyValue(propName) : '';
|
|
18
|
+
}
|
|
19
|
+
function calculateCurrentTranslateX() {
|
|
20
|
+
const transformValue = getScrollContentStyleValue('transform');
|
|
21
|
+
if (transformValue === 'none') {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// the transform value is in form of 'matrix(a, b, c, d, tx, ty)'
|
|
26
|
+
// get all the parenthesized values
|
|
27
|
+
const match = /\((.+?)\)/.exec(transformValue);
|
|
28
|
+
if (!match) {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
const matrixParams = match[1];
|
|
32
|
+
// we need value of tx -> translateX
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
+
const [a, b, c, d, tx, ty] = matrixParams.split(',');
|
|
35
|
+
return parseFloat(tx);
|
|
36
|
+
}
|
|
37
|
+
function getScrollPosition() {
|
|
38
|
+
const currentTranslateX = calculateCurrentTranslateX();
|
|
39
|
+
const scrollLeft = scrollArea.current?.scrollLeft ?? 0;
|
|
40
|
+
return scrollLeft - currentTranslateX;
|
|
41
|
+
}
|
|
42
|
+
function calculateScrollEdges() {
|
|
43
|
+
const scrollContentWidth = scrollContent.current?.offsetWidth ?? 0;
|
|
44
|
+
const scrollAreaWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
45
|
+
return {
|
|
46
|
+
left: 0,
|
|
47
|
+
right: scrollContentWidth - scrollAreaWidth
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function clampScrollValue(scrollX) {
|
|
51
|
+
const edges = calculateScrollEdges();
|
|
52
|
+
return Math.min(Math.max(edges.left, scrollX), edges.right);
|
|
53
|
+
}
|
|
54
|
+
function getIncrementScrollOperation(scrollX) {
|
|
55
|
+
const currentScrollX = getScrollPosition();
|
|
56
|
+
const targetScrollX = scrollX + currentScrollX;
|
|
57
|
+
const safeScrollX = clampScrollValue(targetScrollX);
|
|
58
|
+
const scrollDelta = safeScrollX - currentScrollX;
|
|
59
|
+
return {
|
|
60
|
+
finalScrollPosition: safeScrollX,
|
|
61
|
+
scrollDelta
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function getAnimatingScrollPosition() {
|
|
65
|
+
const currentTranslateX = calculateCurrentTranslateX();
|
|
66
|
+
const scrollLeft = scrollArea.current?.scrollLeft ?? 0;
|
|
67
|
+
return scrollLeft - currentTranslateX;
|
|
68
|
+
}
|
|
69
|
+
function stopScrollAnimation() {
|
|
70
|
+
const currentScrollPosition = getAnimatingScrollPosition();
|
|
71
|
+
setClasses('');
|
|
72
|
+
setStyle({
|
|
73
|
+
transform: 'translateX(0px)'
|
|
74
|
+
});
|
|
75
|
+
if (scrollArea.current) {
|
|
76
|
+
scrollArea.current.scrollLeft = currentScrollPosition;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function animate(animation) {
|
|
80
|
+
// no animation needed
|
|
81
|
+
if (animation.scrollDelta === 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
stopScrollAnimation();
|
|
85
|
+
|
|
86
|
+
// this animation uses the flip approach
|
|
87
|
+
// https://aerotwist.com/blog/flip-your-animations/
|
|
88
|
+
// https://css-tricks.com/animating-layouts-with-the-flip-technique/
|
|
89
|
+
if (scrollArea.current) {
|
|
90
|
+
scrollArea.current.scrollLeft = animation.finalScrollPosition;
|
|
91
|
+
}
|
|
92
|
+
setStyle({
|
|
93
|
+
transform: `translateX(${animation.scrollDelta}px)`
|
|
94
|
+
});
|
|
95
|
+
// force repaint
|
|
96
|
+
if (scrollArea.current) {
|
|
97
|
+
scrollArea.current.getBoundingClientRect();
|
|
98
|
+
}
|
|
99
|
+
requestAnimationFrame(() => {
|
|
100
|
+
setClasses('fr-tab-scroller--animating');
|
|
101
|
+
setStyle({
|
|
102
|
+
transform: 'none'
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function incrementScroll(scrollXIncrement) {
|
|
107
|
+
// no scroll needed
|
|
108
|
+
if (scrollXIncrement === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const scrollOperation = getIncrementScrollOperation(scrollXIncrement);
|
|
112
|
+
animate(scrollOperation);
|
|
113
|
+
}
|
|
114
|
+
function computeDimensions(tab) {
|
|
115
|
+
const rootWidth = tab.offsetWidth;
|
|
116
|
+
const rootLeft = tab.offsetLeft;
|
|
117
|
+
const tabContent = tab.querySelector('.fr-tab-content');
|
|
118
|
+
const contentWidth = tabContent?.offsetWidth ?? 0;
|
|
119
|
+
const contentLeft = tabContent?.offsetLeft ?? 0;
|
|
120
|
+
return {
|
|
121
|
+
contentLeft: rootLeft + contentLeft,
|
|
122
|
+
contentRight: rootLeft + contentLeft + contentWidth,
|
|
123
|
+
rootLeft,
|
|
124
|
+
rootRight: rootLeft + rootWidth
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth) {
|
|
128
|
+
const nextTab = elRef.current?.querySelector(`#${componentId}-tab-${nextIndex}`);
|
|
129
|
+
if (nextTab === null || nextTab === undefined) {
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
const nextTabDimensions = computeDimensions(nextTab);
|
|
133
|
+
const relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
|
|
134
|
+
const relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
|
|
135
|
+
const leftIncrement = relativeContentRight - 48;
|
|
136
|
+
const rightIncrement = relativeContentLeft + 48;
|
|
137
|
+
if (nextIndex < index) {
|
|
138
|
+
return Math.min(leftIncrement, 0);
|
|
139
|
+
}
|
|
140
|
+
return Math.max(rightIncrement, 0);
|
|
141
|
+
}
|
|
142
|
+
function findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth) {
|
|
143
|
+
/**
|
|
144
|
+
* tabs are laid out in the tab scroller like this:
|
|
145
|
+
*
|
|
146
|
+
* scroll position
|
|
147
|
+
* +---+
|
|
148
|
+
* | | bar width
|
|
149
|
+
* | +-----------------------------------+
|
|
150
|
+
* | | |
|
|
151
|
+
* | v v
|
|
152
|
+
* | +-----------------------------------+
|
|
153
|
+
* v | tab scroller |
|
|
154
|
+
* +------------+--------------+-------------------+
|
|
155
|
+
* | tab | tab | tab |
|
|
156
|
+
* +------------+--------------+-------------------+
|
|
157
|
+
* | |
|
|
158
|
+
* +-----------------------------------+
|
|
159
|
+
*
|
|
160
|
+
* to determine the next adjacent index, we look at the tab root left and
|
|
161
|
+
* tab root right, both relative to the scroll position. if the tab root
|
|
162
|
+
* left is less than 0, then we know it's out of view to the left. if the
|
|
163
|
+
* tab root right minus the bar width is greater than 0, we know the tab is
|
|
164
|
+
* out of view to the right. from there, we either increment or decrement
|
|
165
|
+
* the index.
|
|
166
|
+
*/
|
|
167
|
+
const relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
|
|
168
|
+
const relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
|
|
169
|
+
const relativeRootDelta = relativeRootLeft + relativeRootRight;
|
|
170
|
+
const leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
|
|
171
|
+
const rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
|
|
172
|
+
if (leftEdgeIsCloser) {
|
|
173
|
+
return index - 1;
|
|
174
|
+
}
|
|
175
|
+
if (rightEdgeIsCloser) {
|
|
176
|
+
return index + 1;
|
|
177
|
+
}
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
function indexIsInRange(index) {
|
|
181
|
+
return index >= 0 && index < tabLength;
|
|
182
|
+
}
|
|
183
|
+
function scrollIntoView(index, tab) {
|
|
184
|
+
const scrollPosition = getScrollPosition();
|
|
185
|
+
const barWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
186
|
+
const tabDimensions = computeDimensions(tab);
|
|
187
|
+
const nextIndex = findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth);
|
|
188
|
+
if (!indexIsInRange(nextIndex)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const scrollIncrement = calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth);
|
|
192
|
+
incrementScroll(scrollIncrement);
|
|
193
|
+
}
|
|
194
|
+
function scrollTo(scrollX) {
|
|
195
|
+
const currentScrollX = getScrollPosition();
|
|
196
|
+
const safeScrollX = clampScrollValue(scrollX);
|
|
197
|
+
const scrollDelta = safeScrollX - currentScrollX;
|
|
198
|
+
animate({
|
|
199
|
+
finalScrollPosition: safeScrollX,
|
|
200
|
+
scrollDelta
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function handleTabScroll(e, index) {
|
|
204
|
+
const scrollContentWidth = scrollContent.current?.offsetWidth ?? 0;
|
|
205
|
+
const scrollAreaWidth = scrollArea.current?.offsetWidth ?? 0;
|
|
206
|
+
|
|
207
|
+
// check if no scroll is needed
|
|
208
|
+
if (scrollAreaWidth > scrollContentWidth) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// check index
|
|
213
|
+
if (!indexIsInRange(index)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// always scroll to 0 if scrolling to the first tab
|
|
218
|
+
if (index === 0) {
|
|
219
|
+
scrollTo(0);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// always scroll to the max value if scrolling to the last tab
|
|
224
|
+
if (index === tabLength - 1 && scrollContent.current) {
|
|
225
|
+
scrollTo(scrollContent.current.offsetWidth);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (e.currentTarget instanceof HTMLElement) {
|
|
229
|
+
const currentTab = e.currentTarget;
|
|
230
|
+
scrollIntoView(index, currentTab);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return [handleTabScroll, classes, style];
|
|
234
|
+
};
|
|
235
|
+
var _default = useTabScroll;
|
|
236
|
+
exports.default = _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const TableHeaderCell = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
12
|
+
function handleClick(event) {
|
|
13
|
+
if (props.onClick) {
|
|
14
|
+
props.onClick(event);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
18
|
+
...props,
|
|
19
|
+
className: (0, _classnames.default)('fwe-table-order', {
|
|
20
|
+
'fwe-active': props.active
|
|
21
|
+
}, {
|
|
22
|
+
'fwe-table-order-descending': !props.ascending
|
|
23
|
+
}, props.className),
|
|
24
|
+
onClick: handleClick,
|
|
25
|
+
ref: ref
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _default = TableHeaderCell;
|
|
29
|
+
exports.default = _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 Checkbox(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
id,
|
|
16
|
+
checked,
|
|
17
|
+
onChange,
|
|
18
|
+
name,
|
|
19
|
+
large = false,
|
|
20
|
+
valid = true,
|
|
21
|
+
labelPosition = 'after',
|
|
22
|
+
required,
|
|
23
|
+
disabled = false,
|
|
24
|
+
indeterminate = false,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
} = _ref;
|
|
29
|
+
const [isChecked, setChecked] = (0, _react.useState)(checked);
|
|
30
|
+
const [isIndeterminate, setIndeterminate] = (0, _react.useState)(indeterminate);
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
setChecked(checked);
|
|
33
|
+
setIndeterminate(indeterminate);
|
|
34
|
+
}, [checked, indeterminate]);
|
|
35
|
+
const handleChange = () => {
|
|
36
|
+
const newChecked = !isChecked;
|
|
37
|
+
if (indeterminate) {
|
|
38
|
+
setIndeterminate(false);
|
|
39
|
+
}
|
|
40
|
+
setChecked(newChecked);
|
|
41
|
+
onChange(newChecked);
|
|
42
|
+
};
|
|
43
|
+
const containerClasses = (0, _classnames.default)('fwe-checkbox-container', {
|
|
44
|
+
'fr-checkbox-large': large
|
|
45
|
+
}, {
|
|
46
|
+
'fr-checkbox-invalid': !valid || required
|
|
47
|
+
}, {
|
|
48
|
+
'fwe-disabled': disabled
|
|
49
|
+
}, {
|
|
50
|
+
'fwe-checked': isChecked
|
|
51
|
+
}, {
|
|
52
|
+
'fwe-label-below': labelPosition === 'below'
|
|
53
|
+
}, {
|
|
54
|
+
'fwe-label-before': labelPosition === 'before'
|
|
55
|
+
}, {
|
|
56
|
+
'fr-checkbox-indeterminate': isIndeterminate
|
|
57
|
+
}, className);
|
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
59
|
+
className: containerClasses,
|
|
60
|
+
htmlFor: id,
|
|
61
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
62
|
+
name: name,
|
|
63
|
+
type: "checkbox",
|
|
64
|
+
id: id,
|
|
65
|
+
disabled: disabled,
|
|
66
|
+
onChange: () => handleChange(),
|
|
67
|
+
...props
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
69
|
+
className: "fwe-checkbox-indicator-container",
|
|
70
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
|
+
className: "fwe-checkbox-indicator-background"
|
|
72
|
+
}), !isIndeterminate && isChecked && (large ? /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
73
|
+
width: "24px",
|
|
74
|
+
height: "24px",
|
|
75
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
76
|
+
d: "M17.5 7L10 14.5 7.501 12l-1.5 1.501L10 17.5l9-9z",
|
|
77
|
+
fill: "#fff"
|
|
78
|
+
})
|
|
79
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
width: "16",
|
|
82
|
+
height: "16",
|
|
83
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
84
|
+
d: "M6 12L3 9l1.25-1.25L6 9.5l5.75-5.75L13 5l-7 7z",
|
|
85
|
+
fill: "#fff"
|
|
86
|
+
})
|
|
87
|
+
})), isIndeterminate && !isChecked && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
88
|
+
className: "fwe-indeterminate-indicator"
|
|
89
|
+
})]
|
|
90
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
91
|
+
className: "fwe-checkbox-title",
|
|
92
|
+
children: children
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
var _default = Checkbox;
|
|
97
|
+
exports.default = _default;
|