@festo-ui/react 4.0.3-pre-20221213.1 → 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,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Prompt;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _TextInput = _interopRequireDefault(require("../../forms/text-input/TextInput"));
|
|
9
|
+
var _Modal = _interopRequireDefault(require("./Modal"));
|
|
10
|
+
var _ModalFooter = _interopRequireDefault(require("./ModalFooter"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function Prompt(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
title,
|
|
18
|
+
subtitle,
|
|
19
|
+
hint,
|
|
20
|
+
label,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
onOk,
|
|
24
|
+
onCancel,
|
|
25
|
+
cancel,
|
|
26
|
+
ok,
|
|
27
|
+
...props
|
|
28
|
+
} = _ref;
|
|
29
|
+
const [innerValue, setInnerValue] = (0, _react.useState)(value);
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
setInnerValue(value);
|
|
32
|
+
}, [value]);
|
|
33
|
+
function handleChange(e) {
|
|
34
|
+
setInnerValue(e.target.value);
|
|
35
|
+
if (onChange) {
|
|
36
|
+
onChange(e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.default, {
|
|
40
|
+
head: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
41
|
+
children: [subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
42
|
+
className: "fwe-modal-h2",
|
|
43
|
+
children: subtitle
|
|
44
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
|
|
45
|
+
className: "fwe-modal-h1",
|
|
46
|
+
children: title
|
|
47
|
+
})]
|
|
48
|
+
}),
|
|
49
|
+
body: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInput.default, {
|
|
50
|
+
onChange: handleChange,
|
|
51
|
+
label: label,
|
|
52
|
+
hint: hint,
|
|
53
|
+
value: innerValue
|
|
54
|
+
}),
|
|
55
|
+
...props,
|
|
56
|
+
children: (cancel || ok) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ModalFooter.default, {
|
|
57
|
+
children: [cancel && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
58
|
+
type: "button",
|
|
59
|
+
"aria-label": "Cancel",
|
|
60
|
+
className: "fwe-btn",
|
|
61
|
+
onClick: onCancel,
|
|
62
|
+
children: cancel
|
|
63
|
+
}), ok && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
64
|
+
type: "button",
|
|
65
|
+
"aria-label": "Ok",
|
|
66
|
+
className: "fwe-btn fwe-btn-hero",
|
|
67
|
+
onClick: () => onOk(innerValue),
|
|
68
|
+
children: ok
|
|
69
|
+
})]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.PaginationType = 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
|
+
let PaginationType;
|
|
14
|
+
exports.PaginationType = PaginationType;
|
|
15
|
+
(function (PaginationType) {
|
|
16
|
+
PaginationType["Simple"] = "SIMPLE";
|
|
17
|
+
PaginationType["Numeric"] = "NUMERIC";
|
|
18
|
+
PaginationType["Dots"] = "DOTS";
|
|
19
|
+
})(PaginationType || (exports.PaginationType = PaginationType = {}));
|
|
20
|
+
function Pagination(props) {
|
|
21
|
+
const {
|
|
22
|
+
pageMax,
|
|
23
|
+
onChange,
|
|
24
|
+
pageCurrent,
|
|
25
|
+
defaultPageCurrent = 1,
|
|
26
|
+
type = PaginationType.Numeric,
|
|
27
|
+
className
|
|
28
|
+
} = props;
|
|
29
|
+
const controlled = pageCurrent !== undefined;
|
|
30
|
+
const [innerPageCurrent, setInnerPageCurrent] = (0, _react.useState)(controlled ? pageCurrent : defaultPageCurrent);
|
|
31
|
+
const dotArray = Array.from(new Array(pageMax).keys());
|
|
32
|
+
(0, _react.useEffect)(() => {
|
|
33
|
+
if (controlled) {
|
|
34
|
+
setInnerPageCurrent(pageCurrent);
|
|
35
|
+
}
|
|
36
|
+
}, [pageCurrent, controlled]);
|
|
37
|
+
function handleChange(newPage) {
|
|
38
|
+
if (!controlled) {
|
|
39
|
+
setInnerPageCurrent(newPage);
|
|
40
|
+
}
|
|
41
|
+
if (onChange) {
|
|
42
|
+
onChange(newPage);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function onBtnDown() {
|
|
46
|
+
if (innerPageCurrent > 1) {
|
|
47
|
+
const newPageCurrent = innerPageCurrent - 1;
|
|
48
|
+
handleChange(newPageCurrent);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function onBtnUp() {
|
|
52
|
+
if (innerPageCurrent < pageMax) {
|
|
53
|
+
const newPageCurrent = innerPageCurrent + 1;
|
|
54
|
+
handleChange(newPageCurrent);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function onDotClick(index) {
|
|
58
|
+
const newPageCurrent = index + 1;
|
|
59
|
+
handleChange(newPageCurrent);
|
|
60
|
+
}
|
|
61
|
+
function handleKeyPress(event, index) {
|
|
62
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
63
|
+
onDotClick(index);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
67
|
+
children: [type !== PaginationType.Dots && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
68
|
+
className: (0, _classnames.default)('fwe-pagination fwe-p-m', {
|
|
69
|
+
'fwe-d-none': pageMax < 2
|
|
70
|
+
}, className),
|
|
71
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
72
|
+
className: (0, _classnames.default)('fwe-navigate-btn-down', {
|
|
73
|
+
'fwe-disabled': innerPageCurrent <= 1
|
|
74
|
+
}),
|
|
75
|
+
onClick: onBtnDown,
|
|
76
|
+
type: "button",
|
|
77
|
+
"aria-label": "navigate-btn-down"
|
|
78
|
+
}), type === PaginationType.Numeric && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
79
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
80
|
+
className: "fwe-page-current",
|
|
81
|
+
children: innerPageCurrent
|
|
82
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
83
|
+
className: "fwe-page-max",
|
|
84
|
+
children: pageMax
|
|
85
|
+
})]
|
|
86
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
87
|
+
className: (0, _classnames.default)('fwe-navigate-btn-up', {
|
|
88
|
+
'fwe-disabled': innerPageCurrent >= pageMax,
|
|
89
|
+
'fwe-ml-4': type === PaginationType.Simple
|
|
90
|
+
}),
|
|
91
|
+
onClick: onBtnUp,
|
|
92
|
+
type: "button",
|
|
93
|
+
"aria-label": "navigate-btn-up"
|
|
94
|
+
})]
|
|
95
|
+
}), type === PaginationType.Dots && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
96
|
+
className: (0, _classnames.default)('fwe-p-m', {
|
|
97
|
+
'fwe-d-none': pageMax < 2
|
|
98
|
+
}, className),
|
|
99
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
|
+
className: "fwe-pagination",
|
|
101
|
+
children: dotArray.map(index => /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
102
|
+
tabIndex: 0,
|
|
103
|
+
role: "button",
|
|
104
|
+
className: (0, _classnames.default)('fwe-page-dot', {
|
|
105
|
+
'fwe-selected': index + 1 === innerPageCurrent
|
|
106
|
+
}),
|
|
107
|
+
onClick: () => onDotClick(index),
|
|
108
|
+
"aria-label": "page-dot",
|
|
109
|
+
onKeyPress: e => handleKeyPress(e, index)
|
|
110
|
+
}, index))
|
|
111
|
+
})
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
var _default = Pagination;
|
|
116
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Popover = _interopRequireDefault(require("../popover/Popover"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function Legend(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
items,
|
|
13
|
+
...props
|
|
14
|
+
} = _ref;
|
|
15
|
+
const content = items.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("dl", {
|
|
16
|
+
className: "fr-legend",
|
|
17
|
+
children: items.map(item => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
18
|
+
className: "fr-legend-content",
|
|
19
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("dt", {
|
|
20
|
+
children: item.name
|
|
21
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("dt", {
|
|
22
|
+
children: item.text
|
|
23
|
+
})]
|
|
24
|
+
}, item.name))
|
|
25
|
+
}) : null;
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
27
|
+
popoverContent: content,
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
var _default = Legend;
|
|
32
|
+
exports.default = _default;
|
|
@@ -0,0 +1,117 @@
|
|
|
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 _reactPopper = require("react-popper");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _useOnClickOutside = _interopRequireDefault(require("../../../helper/useOnClickOutside"));
|
|
11
|
+
var _useForkRef = _interopRequireDefault(require("../../../helper/useForkRef"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
function Popover(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
popoverContent,
|
|
19
|
+
children,
|
|
20
|
+
position,
|
|
21
|
+
fallbackPositions,
|
|
22
|
+
open = false,
|
|
23
|
+
onStatusChange,
|
|
24
|
+
wrapper,
|
|
25
|
+
className,
|
|
26
|
+
flip = true,
|
|
27
|
+
containerClassName,
|
|
28
|
+
stopPropagation,
|
|
29
|
+
arrow = true
|
|
30
|
+
} = _ref;
|
|
31
|
+
const [showPopper, setShowPopper] = (0, _react.useState)(open);
|
|
32
|
+
const referenceElement = (0, _react.useRef)(null);
|
|
33
|
+
const [popperElement, setPopperElement] = (0, _react.useState)(null);
|
|
34
|
+
const [arrowElement, setArrowElement] = (0, _react.useState)(null);
|
|
35
|
+
const popperElRef = (0, _react.useRef)(null);
|
|
36
|
+
const combinedRef = (0, _useForkRef.default)(popperElRef, setPopperElement);
|
|
37
|
+
const classes = (0, _classnames.default)(className);
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
39
|
+
setShowPopper(open);
|
|
40
|
+
}, [open]);
|
|
41
|
+
const {
|
|
42
|
+
styles,
|
|
43
|
+
attributes
|
|
44
|
+
} = (0, _reactPopper.usePopper)(referenceElement.current, popperElement, {
|
|
45
|
+
placement: position,
|
|
46
|
+
modifiers: [{
|
|
47
|
+
name: 'arrow',
|
|
48
|
+
options: {
|
|
49
|
+
element: arrowElement
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
name: 'offset',
|
|
53
|
+
options: {
|
|
54
|
+
offset: [0, 24]
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
name: 'flip',
|
|
58
|
+
options: {
|
|
59
|
+
fallbackPlacements: flip ? fallbackPositions : [position || 'auto']
|
|
60
|
+
}
|
|
61
|
+
}]
|
|
62
|
+
});
|
|
63
|
+
const handleChange = (e, status) => {
|
|
64
|
+
if (stopPropagation) {
|
|
65
|
+
e?.stopPropagation();
|
|
66
|
+
}
|
|
67
|
+
setShowPopper(status);
|
|
68
|
+
if (onStatusChange) {
|
|
69
|
+
onStatusChange(status);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function closePopover(event) {
|
|
73
|
+
handleChange(event, false);
|
|
74
|
+
}
|
|
75
|
+
(0, _useOnClickOutside.default)(popperElRef, closePopover, referenceElement);
|
|
76
|
+
function handleKeyDown(event) {
|
|
77
|
+
if (event.key === 'Enter') {
|
|
78
|
+
handleChange(undefined, true);
|
|
79
|
+
}
|
|
80
|
+
if (event.key === 'Escape') {
|
|
81
|
+
handleChange(undefined, false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function handleKeyUp(event) {
|
|
85
|
+
if (event.key === ' ') {
|
|
86
|
+
handleChange(undefined, true);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const childrenWrapper = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
90
|
+
tabIndex: 0,
|
|
91
|
+
role: "button",
|
|
92
|
+
className: classes,
|
|
93
|
+
ref: referenceElement,
|
|
94
|
+
onKeyDown: handleKeyDown,
|
|
95
|
+
onKeyUp: handleKeyUp,
|
|
96
|
+
onClick: e => handleChange(e, !showPopper),
|
|
97
|
+
children: children
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
100
|
+
children: [wrapper ? wrapper(childrenWrapper) : childrenWrapper, showPopper && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
101
|
+
className: (0, _classnames.default)('fwe-popover-container', containerClassName),
|
|
102
|
+
ref: combinedRef,
|
|
103
|
+
style: styles.popper,
|
|
104
|
+
...attributes.popper,
|
|
105
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
106
|
+
className: "fwe-popover",
|
|
107
|
+
children: popoverContent
|
|
108
|
+
}), arrow && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
109
|
+
ref: setArrowElement,
|
|
110
|
+
style: styles.arrow,
|
|
111
|
+
id: "arrow"
|
|
112
|
+
})]
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
var _default = Popover;
|
|
117
|
+
exports.default = _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 _Popover = _interopRequireDefault(require("../popover/Popover"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function PopoverMenu(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
icon,
|
|
15
|
+
menu,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
const [showPopper, setShowPopper] = (0, _react.useState)(false);
|
|
20
|
+
const handleClick = item => {
|
|
21
|
+
if (item.action) {
|
|
22
|
+
item.action(item.data);
|
|
23
|
+
}
|
|
24
|
+
setShowPopper(false);
|
|
25
|
+
};
|
|
26
|
+
const content = /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
27
|
+
className: "fwe-list-group",
|
|
28
|
+
children: menu.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
29
|
+
className: "fwe-list-group-item",
|
|
30
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
className: "fwe-btn fwe-btn-link fwe-dark",
|
|
33
|
+
onClick: () => handleClick(item),
|
|
34
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
35
|
+
className: `fwe-icon fwe-pr-0 ${item.icon}`
|
|
36
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
37
|
+
children: item.text
|
|
38
|
+
})]
|
|
39
|
+
})
|
|
40
|
+
}, item.icon + item.text))
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
|
+
className: (0, _classnames.default)('fwe-popover-menu', className),
|
|
44
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
45
|
+
popoverContent: content,
|
|
46
|
+
position: "right",
|
|
47
|
+
open: showPopper,
|
|
48
|
+
onStatusChange: setShowPopper,
|
|
49
|
+
...props,
|
|
50
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
className: "fwe-btn fwe-btn-link fwe-dark origin",
|
|
53
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
54
|
+
className: `fwe-icon fwe-pr-0 ${icon}`
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var _default = PopoverMenu;
|
|
61
|
+
exports.default = _default;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 _reactPopper = require("react-popper");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function Tooltip(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
title,
|
|
17
|
+
position = 'bottom'
|
|
18
|
+
} = _ref;
|
|
19
|
+
const [showPopper, setShowPopper] = (0, _react.useState)(false);
|
|
20
|
+
const referenceElement = (0, _react.useRef)(null);
|
|
21
|
+
const [popperElement, setPopperElement] = (0, _react.useState)(null);
|
|
22
|
+
const [arrowElement, setArrowElement] = (0, _react.useState)(null);
|
|
23
|
+
const {
|
|
24
|
+
styles,
|
|
25
|
+
attributes
|
|
26
|
+
} = (0, _reactPopper.usePopper)(referenceElement.current, popperElement, {
|
|
27
|
+
placement: position,
|
|
28
|
+
modifiers: [{
|
|
29
|
+
name: 'arrow',
|
|
30
|
+
options: {
|
|
31
|
+
element: arrowElement
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
name: 'offset',
|
|
35
|
+
options: {
|
|
36
|
+
offset: [0, 24]
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
name: 'flip',
|
|
40
|
+
options: {
|
|
41
|
+
fallbackPlacements: ['right', 'left', 'top']
|
|
42
|
+
}
|
|
43
|
+
}]
|
|
44
|
+
});
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
46
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
47
|
+
className: (0, _classnames.default)('fr-tooltip-container', className),
|
|
48
|
+
ref: referenceElement,
|
|
49
|
+
onMouseEnter: () => setShowPopper(true),
|
|
50
|
+
onMouseLeave: () => setShowPopper(false),
|
|
51
|
+
children: children
|
|
52
|
+
}), showPopper && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
53
|
+
className: "fwe-popover-container",
|
|
54
|
+
id: "tooltip",
|
|
55
|
+
ref: setPopperElement,
|
|
56
|
+
style: styles.popper,
|
|
57
|
+
...attributes.popper,
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
59
|
+
ref: setArrowElement,
|
|
60
|
+
style: styles.arrow,
|
|
61
|
+
id: "arrow"
|
|
62
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
63
|
+
className: "fwe-popover",
|
|
64
|
+
children: title
|
|
65
|
+
})]
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
var _default = Tooltip;
|
|
70
|
+
exports.default = _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 Progress(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
background = 'white',
|
|
13
|
+
error = false,
|
|
14
|
+
progress,
|
|
15
|
+
className
|
|
16
|
+
} = _ref;
|
|
17
|
+
const classes = (0, _classnames.default)('fwe-progress-bar', {
|
|
18
|
+
'fwe-bg-red': error
|
|
19
|
+
}, {
|
|
20
|
+
'fwe-progress-bar-black': background === 'black'
|
|
21
|
+
}, {
|
|
22
|
+
'fwe-progress-bar-background': background === 'background'
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
25
|
+
className: (0, _classnames.default)('fwe-progress', className),
|
|
26
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
27
|
+
className: classes,
|
|
28
|
+
role: "progressbar",
|
|
29
|
+
style: {
|
|
30
|
+
width: `${progress}%`
|
|
31
|
+
},
|
|
32
|
+
"aria-valuenow": progress,
|
|
33
|
+
"aria-valuemin": 0,
|
|
34
|
+
"aria-valuemax": 100,
|
|
35
|
+
"aria-label": "progressbar"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var _default = Progress;
|
|
40
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ClearButton;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
function ClearButton(props) {
|
|
9
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
10
|
+
role: "button",
|
|
11
|
+
tabIndex: -1,
|
|
12
|
+
className: "fwe-clear-icon",
|
|
13
|
+
"aria-label": "Clear",
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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 _useSearchInput = _interopRequireDefault(require("./useSearchInput"));
|
|
9
|
+
var _useOnClickOutside = _interopRequireDefault(require("../../helper/useOnClickOutside"));
|
|
10
|
+
var _ClearButton = _interopRequireDefault(require("./ClearButton"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function SearchInput(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
defaultValue,
|
|
16
|
+
disabled,
|
|
17
|
+
label,
|
|
18
|
+
value,
|
|
19
|
+
suggestions,
|
|
20
|
+
onChange,
|
|
21
|
+
onSearch,
|
|
22
|
+
onKeyboardNavigate
|
|
23
|
+
} = _ref;
|
|
24
|
+
const inputRef = (0, _react.useRef)(null);
|
|
25
|
+
const containerRef = (0, _react.useRef)(null);
|
|
26
|
+
const cappedSuggestions = suggestions?.slice(0, 10) ?? [];
|
|
27
|
+
const {
|
|
28
|
+
handleFocus,
|
|
29
|
+
handleInput,
|
|
30
|
+
handleClearQuery,
|
|
31
|
+
handleSuggestionClick,
|
|
32
|
+
handleOutsideClick,
|
|
33
|
+
handleKeyDown,
|
|
34
|
+
hideSuggestionList,
|
|
35
|
+
selectedSuggestionIndex,
|
|
36
|
+
innerValue
|
|
37
|
+
} = (0, _useSearchInput.default)(inputRef, cappedSuggestions, value, defaultValue, onChange, onSearch, onKeyboardNavigate);
|
|
38
|
+
(0, _useOnClickOutside.default)(containerRef, handleOutsideClick);
|
|
39
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
40
|
+
className: "fwe-search-input fwe-w-100",
|
|
41
|
+
ref: containerRef,
|
|
42
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
43
|
+
ref: inputRef,
|
|
44
|
+
className: "fwe-w-100",
|
|
45
|
+
disabled: disabled,
|
|
46
|
+
placeholder: label,
|
|
47
|
+
onFocus: handleFocus,
|
|
48
|
+
type: "search",
|
|
49
|
+
onInput: handleInput,
|
|
50
|
+
onKeyDown: handleKeyDown,
|
|
51
|
+
value: innerValue
|
|
52
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
|
+
className: "fwe-search-icon"
|
|
54
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClearButton.default, {
|
|
55
|
+
onClick: handleClearQuery
|
|
56
|
+
}), Boolean(suggestions?.length) && !hideSuggestionList && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
57
|
+
className: "fwe-search-suggestions",
|
|
58
|
+
children: [cappedSuggestions.map((suggestion, i) =>
|
|
59
|
+
/*#__PURE__*/
|
|
60
|
+
// key event is handled via parent
|
|
61
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
62
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
63
|
+
role: "option",
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
"aria-selected": selectedSuggestionIndex === i,
|
|
66
|
+
onClick: () => handleSuggestionClick(suggestion),
|
|
67
|
+
className: `fwe-search-suggestion ${selectedSuggestionIndex === i ? 'fwe-selected' : ''}`,
|
|
68
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
69
|
+
// eslint-disable-next-line react/no-danger
|
|
70
|
+
dangerouslySetInnerHTML: {
|
|
71
|
+
__html: suggestion.template
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}, suggestion.value)), suggestions && suggestions.length > 10 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
75
|
+
className: "fwe-ml-xxs",
|
|
76
|
+
children: "..."
|
|
77
|
+
})]
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var _default = SearchInput;
|
|
82
|
+
exports.default = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class SearchSuggestion {
|
|
8
|
+
/**
|
|
9
|
+
* a html-string. e.g.: '<b> hello </b>'
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This Value will be used as new query when the user selects the suggestion.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a basic Suggestion from a string. The first query match is highlighted by bold tags.
|
|
18
|
+
* @param suggestionString The suggested string (should contain the whole query)
|
|
19
|
+
* @param query The current query. This string will be highlighted.
|
|
20
|
+
* @returns a html-string.
|
|
21
|
+
*/
|
|
22
|
+
static basicSuggestion(suggestionString, query) {
|
|
23
|
+
const i = suggestionString.toLocaleLowerCase().indexOf(query.toLocaleLowerCase());
|
|
24
|
+
let template = suggestionString;
|
|
25
|
+
if (i !== -1) {
|
|
26
|
+
const boldStart = i;
|
|
27
|
+
const boldEnd = i + query.length;
|
|
28
|
+
const part1 = suggestionString.substring(0, boldStart);
|
|
29
|
+
const part2 = suggestionString.substring(boldStart, boldEnd);
|
|
30
|
+
const part3 = suggestionString.substring(boldEnd, suggestionString.length);
|
|
31
|
+
template = `${part1}<b>${part2}</b>${part3}`;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
value: suggestionString,
|
|
35
|
+
template
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = SearchSuggestion;
|