no-frills-ui 0.0.14-alpha.5 → 0.0.14-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2365 -3152
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +0 -1
- package/lib-esm/components/Accordion/Accordion.js +26 -26
- package/lib-esm/components/Accordion/AccordionStep.d.ts +0 -1
- package/lib-esm/components/Accordion/AccordionStep.js +98 -96
- package/lib-esm/components/Accordion/index.d.ts +0 -1
- package/lib-esm/components/Badge/Badge.d.ts +0 -1
- package/lib-esm/components/Badge/Badge.js +32 -38
- package/lib-esm/components/Badge/index.d.ts +0 -1
- package/lib-esm/components/Button/ActionButton.d.ts +0 -1
- package/lib-esm/components/Button/ActionButton.js +6 -39
- package/lib-esm/components/Button/Button.d.ts +0 -1
- package/lib-esm/components/Button/Button.js +8 -44
- package/lib-esm/components/Button/IconButton.d.ts +0 -1
- package/lib-esm/components/Button/IconButton.js +6 -43
- package/lib-esm/components/Button/LinkButton.d.ts +0 -1
- package/lib-esm/components/Button/LinkButton.js +6 -34
- package/lib-esm/components/Button/RaisedButton.d.ts +0 -1
- package/lib-esm/components/Button/RaisedButton.js +6 -47
- package/lib-esm/components/Button/index.d.ts +0 -1
- package/lib-esm/components/Card/Card.d.ts +0 -1
- package/lib-esm/components/Card/Card.js +8 -13
- package/lib-esm/components/Card/index.d.ts +0 -1
- package/lib-esm/components/Chip/Chip.d.ts +0 -1
- package/lib-esm/components/Chip/Chip.js +35 -43
- package/lib-esm/components/Chip/index.d.ts +0 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +0 -1
- package/lib-esm/components/ChipInput/ChipInput.js +102 -162
- package/lib-esm/components/ChipInput/index.d.ts +0 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +0 -1
- package/lib-esm/components/Dialog/AlertDialog.js +45 -26
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +0 -1
- package/lib-esm/components/Dialog/ConfirmDialog.js +49 -31
- package/lib-esm/components/Dialog/Dialog.d.ts +1 -1
- package/lib-esm/components/Dialog/Dialog.js +76 -106
- package/lib-esm/components/Dialog/PromptDialog.d.ts +0 -1
- package/lib-esm/components/Dialog/PromptDialog.js +82 -44
- package/lib-esm/components/Dialog/index.d.ts +0 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +0 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +66 -71
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +0 -1
- package/lib-esm/components/DragAndDrop/DragItem.js +106 -118
- package/lib-esm/components/DragAndDrop/index.d.ts +0 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +0 -1
- package/lib-esm/components/DragAndDrop/types.js +7 -5
- package/lib-esm/components/Drawer/Drawer.d.ts +0 -1
- package/lib-esm/components/Drawer/Drawer.js +143 -197
- package/lib-esm/components/Drawer/index.d.ts +0 -1
- package/lib-esm/components/Groups/Group.d.ts +0 -1
- package/lib-esm/components/Groups/Group.js +28 -86
- package/lib-esm/components/Groups/GroupLabel.d.ts +0 -1
- package/lib-esm/components/Groups/GroupLabel.js +7 -17
- package/lib-esm/components/Groups/index.d.ts +0 -1
- package/lib-esm/components/Input/Checkbox.d.ts +0 -1
- package/lib-esm/components/Input/Checkbox.js +39 -115
- package/lib-esm/components/Input/Dropdown.d.ts +0 -1
- package/lib-esm/components/Input/Dropdown.js +74 -37
- package/lib-esm/components/Input/Input.d.ts +0 -1
- package/lib-esm/components/Input/Input.js +52 -110
- package/lib-esm/components/Input/Radio.d.ts +0 -1
- package/lib-esm/components/Input/Radio.js +31 -92
- package/lib-esm/components/Input/RadioButton.d.ts +0 -1
- package/lib-esm/components/Input/RadioButton.js +30 -67
- package/lib-esm/components/Input/Select.d.ts +0 -1
- package/lib-esm/components/Input/Select.js +65 -123
- package/lib-esm/components/Input/TextArea.d.ts +0 -1
- package/lib-esm/components/Input/TextArea.js +51 -108
- package/lib-esm/components/Input/Toggle.d.ts +0 -1
- package/lib-esm/components/Input/Toggle.js +29 -80
- package/lib-esm/components/Input/index.d.ts +0 -1
- package/lib-esm/components/Menu/Menu.d.ts +0 -1
- package/lib-esm/components/Menu/Menu.js +47 -62
- package/lib-esm/components/Menu/MenuContext.d.ts +0 -1
- package/lib-esm/components/Menu/MenuContext.js +4 -2
- package/lib-esm/components/Menu/MenuItem.d.ts +0 -1
- package/lib-esm/components/Menu/MenuItem.js +34 -49
- package/lib-esm/components/Menu/index.d.ts +0 -1
- package/lib-esm/components/Modal/Modal.d.ts +0 -1
- package/lib-esm/components/Modal/Modal.js +117 -154
- package/lib-esm/components/Modal/index.d.ts +0 -1
- package/lib-esm/components/Notification/Notification.d.ts +0 -1
- package/lib-esm/components/Notification/Notification.js +54 -66
- package/lib-esm/components/Notification/NotificationManager.d.ts +4 -1
- package/lib-esm/components/Notification/NotificationManager.js +157 -100
- package/lib-esm/components/Notification/index.d.ts +0 -1
- package/lib-esm/components/Notification/style.d.ts +0 -1
- package/lib-esm/components/Notification/style.js +51 -145
- package/lib-esm/components/Notification/types.d.ts +0 -1
- package/lib-esm/components/Notification/types.js +8 -9
- package/lib-esm/components/Popover/Popover.d.ts +0 -1
- package/lib-esm/components/Popover/Popover.js +135 -115
- package/lib-esm/components/Popover/index.d.ts +0 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +0 -1
- package/lib-esm/components/Spinner/Spinner.js +19 -39
- package/lib-esm/components/Spinner/index.d.ts +0 -1
- package/lib-esm/components/Stepper/Step.d.ts +0 -1
- package/lib-esm/components/Stepper/Step.js +15 -22
- package/lib-esm/components/Stepper/Stepper.d.ts +0 -1
- package/lib-esm/components/Stepper/Stepper.js +98 -119
- package/lib-esm/components/Stepper/index.d.ts +0 -1
- package/lib-esm/components/Tabs/Tab.d.ts +0 -1
- package/lib-esm/components/Tabs/Tab.js +11 -10
- package/lib-esm/components/Tabs/Tabs.d.ts +0 -1
- package/lib-esm/components/Tabs/Tabs.js +80 -75
- package/lib-esm/components/Tabs/index.d.ts +0 -1
- package/lib-esm/components/Toast/Toast.d.ts +5 -1
- package/lib-esm/components/Toast/Toast.js +127 -135
- package/lib-esm/components/Toast/ToastStory.d.ts +0 -1
- package/lib-esm/components/Toast/index.d.ts +0 -1
- package/lib-esm/components/Tooltip/Tooltip.d.ts +0 -1
- package/lib-esm/components/Tooltip/Tooltip.js +57 -69
- package/lib-esm/components/Tooltip/index.d.ts +0 -1
- package/lib-esm/components/index.d.ts +0 -1
- package/lib-esm/components/index.js +42 -21
- package/lib-esm/icons/CheckCircle.d.ts +0 -1
- package/lib-esm/icons/CheckCircle.js +21 -4
- package/lib-esm/icons/Close.d.ts +0 -1
- package/lib-esm/icons/Close.js +21 -4
- package/lib-esm/icons/DragIndicator.d.ts +0 -1
- package/lib-esm/icons/DragIndicator.js +21 -4
- package/lib-esm/icons/ErrorOutline.d.ts +0 -1
- package/lib-esm/icons/ErrorOutline.js +15 -4
- package/lib-esm/icons/ExpandMore.d.ts +0 -1
- package/lib-esm/icons/ExpandMore.js +21 -4
- package/lib-esm/icons/FiberManualRecord.d.ts +0 -1
- package/lib-esm/icons/FiberManualRecord.js +23 -4
- package/lib-esm/icons/Info.d.ts +0 -1
- package/lib-esm/icons/Info.js +21 -4
- package/lib-esm/icons/ReportProblem.d.ts +0 -1
- package/lib-esm/icons/ReportProblem.js +21 -4
- package/lib-esm/icons/index.d.ts +0 -1
- package/lib-esm/index.d.ts +0 -1
- package/lib-esm/shared/LayerManager.d.ts +3 -1
- package/lib-esm/shared/LayerManager.js +105 -96
- package/lib-esm/shared/constants.d.ts +0 -1
- package/lib-esm/shared/constants.js +33 -61
- package/lib-esm/shared/styles.d.ts +0 -1
- package/lib-esm/shared/styles.js +20 -26
- package/package.json +15 -5
- package/lib-esm/components/Accordion/Accordion.d.ts.map +0 -1
- package/lib-esm/components/Accordion/Accordion.js.map +0 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts.map +0 -1
- package/lib-esm/components/Accordion/AccordionStep.js.map +0 -1
- package/lib-esm/components/Accordion/index.d.ts.map +0 -1
- package/lib-esm/components/Accordion/index.js +0 -3
- package/lib-esm/components/Accordion/index.js.map +0 -1
- package/lib-esm/components/Badge/Badge.d.ts.map +0 -1
- package/lib-esm/components/Badge/Badge.js.map +0 -1
- package/lib-esm/components/Badge/index.d.ts.map +0 -1
- package/lib-esm/components/Badge/index.js +0 -2
- package/lib-esm/components/Badge/index.js.map +0 -1
- package/lib-esm/components/Button/ActionButton.d.ts.map +0 -1
- package/lib-esm/components/Button/ActionButton.js.map +0 -1
- package/lib-esm/components/Button/Button.d.ts.map +0 -1
- package/lib-esm/components/Button/Button.js.map +0 -1
- package/lib-esm/components/Button/IconButton.d.ts.map +0 -1
- package/lib-esm/components/Button/IconButton.js.map +0 -1
- package/lib-esm/components/Button/LinkButton.d.ts.map +0 -1
- package/lib-esm/components/Button/LinkButton.js.map +0 -1
- package/lib-esm/components/Button/RaisedButton.d.ts.map +0 -1
- package/lib-esm/components/Button/RaisedButton.js.map +0 -1
- package/lib-esm/components/Button/index.d.ts.map +0 -1
- package/lib-esm/components/Button/index.js +0 -6
- package/lib-esm/components/Button/index.js.map +0 -1
- package/lib-esm/components/Card/Card.d.ts.map +0 -1
- package/lib-esm/components/Card/Card.js.map +0 -1
- package/lib-esm/components/Card/index.d.ts.map +0 -1
- package/lib-esm/components/Card/index.js +0 -3
- package/lib-esm/components/Card/index.js.map +0 -1
- package/lib-esm/components/Chip/Chip.d.ts.map +0 -1
- package/lib-esm/components/Chip/Chip.js.map +0 -1
- package/lib-esm/components/Chip/index.d.ts.map +0 -1
- package/lib-esm/components/Chip/index.js +0 -2
- package/lib-esm/components/Chip/index.js.map +0 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts.map +0 -1
- package/lib-esm/components/ChipInput/ChipInput.js.map +0 -1
- package/lib-esm/components/ChipInput/index.d.ts.map +0 -1
- package/lib-esm/components/ChipInput/index.js +0 -2
- package/lib-esm/components/ChipInput/index.js.map +0 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts.map +0 -1
- package/lib-esm/components/Dialog/AlertDialog.js.map +0 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts.map +0 -1
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +0 -1
- package/lib-esm/components/Dialog/Dialog.d.ts.map +0 -1
- package/lib-esm/components/Dialog/Dialog.js.map +0 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts.map +0 -1
- package/lib-esm/components/Dialog/PromptDialog.js.map +0 -1
- package/lib-esm/components/Dialog/index.d.ts.map +0 -1
- package/lib-esm/components/Dialog/index.js +0 -5
- package/lib-esm/components/Dialog/index.js.map +0 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts.map +0 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +0 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts.map +0 -1
- package/lib-esm/components/DragAndDrop/DragItem.js.map +0 -1
- package/lib-esm/components/DragAndDrop/index.d.ts.map +0 -1
- package/lib-esm/components/DragAndDrop/index.js +0 -3
- package/lib-esm/components/DragAndDrop/index.js.map +0 -1
- package/lib-esm/components/DragAndDrop/types.d.ts.map +0 -1
- package/lib-esm/components/DragAndDrop/types.js.map +0 -1
- package/lib-esm/components/Drawer/Drawer.d.ts.map +0 -1
- package/lib-esm/components/Drawer/Drawer.js.map +0 -1
- package/lib-esm/components/Drawer/index.d.ts.map +0 -1
- package/lib-esm/components/Drawer/index.js +0 -2
- package/lib-esm/components/Drawer/index.js.map +0 -1
- package/lib-esm/components/Groups/Group.d.ts.map +0 -1
- package/lib-esm/components/Groups/Group.js.map +0 -1
- package/lib-esm/components/Groups/GroupLabel.d.ts.map +0 -1
- package/lib-esm/components/Groups/GroupLabel.js.map +0 -1
- package/lib-esm/components/Groups/index.d.ts.map +0 -1
- package/lib-esm/components/Groups/index.js +0 -3
- package/lib-esm/components/Groups/index.js.map +0 -1
- package/lib-esm/components/Input/Checkbox.d.ts.map +0 -1
- package/lib-esm/components/Input/Checkbox.js.map +0 -1
- package/lib-esm/components/Input/Dropdown.d.ts.map +0 -1
- package/lib-esm/components/Input/Dropdown.js.map +0 -1
- package/lib-esm/components/Input/Input.d.ts.map +0 -1
- package/lib-esm/components/Input/Input.js.map +0 -1
- package/lib-esm/components/Input/Radio.d.ts.map +0 -1
- package/lib-esm/components/Input/Radio.js.map +0 -1
- package/lib-esm/components/Input/RadioButton.d.ts.map +0 -1
- package/lib-esm/components/Input/RadioButton.js.map +0 -1
- package/lib-esm/components/Input/Select.d.ts.map +0 -1
- package/lib-esm/components/Input/Select.js.map +0 -1
- package/lib-esm/components/Input/TextArea.d.ts.map +0 -1
- package/lib-esm/components/Input/TextArea.js.map +0 -1
- package/lib-esm/components/Input/Toggle.d.ts.map +0 -1
- package/lib-esm/components/Input/Toggle.js.map +0 -1
- package/lib-esm/components/Input/index.d.ts.map +0 -1
- package/lib-esm/components/Input/index.js +0 -9
- package/lib-esm/components/Input/index.js.map +0 -1
- package/lib-esm/components/Menu/Menu.d.ts.map +0 -1
- package/lib-esm/components/Menu/Menu.js.map +0 -1
- package/lib-esm/components/Menu/MenuContext.d.ts.map +0 -1
- package/lib-esm/components/Menu/MenuContext.js.map +0 -1
- package/lib-esm/components/Menu/MenuItem.d.ts.map +0 -1
- package/lib-esm/components/Menu/MenuItem.js.map +0 -1
- package/lib-esm/components/Menu/index.d.ts.map +0 -1
- package/lib-esm/components/Menu/index.js +0 -3
- package/lib-esm/components/Menu/index.js.map +0 -1
- package/lib-esm/components/Modal/Modal.d.ts.map +0 -1
- package/lib-esm/components/Modal/Modal.js.map +0 -1
- package/lib-esm/components/Modal/index.d.ts.map +0 -1
- package/lib-esm/components/Modal/index.js +0 -2
- package/lib-esm/components/Modal/index.js.map +0 -1
- package/lib-esm/components/Notification/Notification.d.ts.map +0 -1
- package/lib-esm/components/Notification/Notification.js.map +0 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts.map +0 -1
- package/lib-esm/components/Notification/NotificationManager.js.map +0 -1
- package/lib-esm/components/Notification/index.d.ts.map +0 -1
- package/lib-esm/components/Notification/index.js +0 -3
- package/lib-esm/components/Notification/index.js.map +0 -1
- package/lib-esm/components/Notification/style.d.ts.map +0 -1
- package/lib-esm/components/Notification/style.js.map +0 -1
- package/lib-esm/components/Notification/types.d.ts.map +0 -1
- package/lib-esm/components/Notification/types.js.map +0 -1
- package/lib-esm/components/Popover/Popover.d.ts.map +0 -1
- package/lib-esm/components/Popover/Popover.js.map +0 -1
- package/lib-esm/components/Popover/index.d.ts.map +0 -1
- package/lib-esm/components/Popover/index.js +0 -2
- package/lib-esm/components/Popover/index.js.map +0 -1
- package/lib-esm/components/Spinner/Spinner.d.ts.map +0 -1
- package/lib-esm/components/Spinner/Spinner.js.map +0 -1
- package/lib-esm/components/Spinner/index.d.ts.map +0 -1
- package/lib-esm/components/Spinner/index.js +0 -2
- package/lib-esm/components/Spinner/index.js.map +0 -1
- package/lib-esm/components/Stepper/Step.d.ts.map +0 -1
- package/lib-esm/components/Stepper/Step.js.map +0 -1
- package/lib-esm/components/Stepper/Stepper.d.ts.map +0 -1
- package/lib-esm/components/Stepper/Stepper.js.map +0 -1
- package/lib-esm/components/Stepper/index.d.ts.map +0 -1
- package/lib-esm/components/Stepper/index.js +0 -4
- package/lib-esm/components/Stepper/index.js.map +0 -1
- package/lib-esm/components/Tabs/Tab.d.ts.map +0 -1
- package/lib-esm/components/Tabs/Tab.js.map +0 -1
- package/lib-esm/components/Tabs/Tabs.d.ts.map +0 -1
- package/lib-esm/components/Tabs/Tabs.js.map +0 -1
- package/lib-esm/components/Tabs/index.d.ts.map +0 -1
- package/lib-esm/components/Tabs/index.js +0 -3
- package/lib-esm/components/Tabs/index.js.map +0 -1
- package/lib-esm/components/Toast/Toast.d.ts.map +0 -1
- package/lib-esm/components/Toast/Toast.js.map +0 -1
- package/lib-esm/components/Toast/ToastStory.d.ts.map +0 -1
- package/lib-esm/components/Toast/ToastStory.js +0 -35
- package/lib-esm/components/Toast/ToastStory.js.map +0 -1
- package/lib-esm/components/Toast/index.d.ts.map +0 -1
- package/lib-esm/components/Toast/index.js +0 -2
- package/lib-esm/components/Toast/index.js.map +0 -1
- package/lib-esm/components/Tooltip/Tooltip.d.ts.map +0 -1
- package/lib-esm/components/Tooltip/Tooltip.js.map +0 -1
- package/lib-esm/components/Tooltip/index.d.ts.map +0 -1
- package/lib-esm/components/Tooltip/index.js +0 -2
- package/lib-esm/components/Tooltip/index.js.map +0 -1
- package/lib-esm/components/index.d.ts.map +0 -1
- package/lib-esm/components/index.js.map +0 -1
- package/lib-esm/icons/CheckCircle.d.ts.map +0 -1
- package/lib-esm/icons/CheckCircle.js.map +0 -1
- package/lib-esm/icons/Close.d.ts.map +0 -1
- package/lib-esm/icons/Close.js.map +0 -1
- package/lib-esm/icons/DragIndicator.d.ts.map +0 -1
- package/lib-esm/icons/DragIndicator.js.map +0 -1
- package/lib-esm/icons/ErrorOutline.d.ts.map +0 -1
- package/lib-esm/icons/ErrorOutline.js.map +0 -1
- package/lib-esm/icons/ExpandMore.d.ts.map +0 -1
- package/lib-esm/icons/ExpandMore.js.map +0 -1
- package/lib-esm/icons/FiberManualRecord.d.ts.map +0 -1
- package/lib-esm/icons/FiberManualRecord.js.map +0 -1
- package/lib-esm/icons/Info.d.ts.map +0 -1
- package/lib-esm/icons/Info.js.map +0 -1
- package/lib-esm/icons/ReportProblem.d.ts.map +0 -1
- package/lib-esm/icons/ReportProblem.js.map +0 -1
- package/lib-esm/icons/index.d.ts.map +0 -1
- package/lib-esm/icons/index.js +0 -9
- package/lib-esm/icons/index.js.map +0 -1
- package/lib-esm/index.d.ts.map +0 -1
- package/lib-esm/index.js +0 -2
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/shared/LayerManager.d.ts.map +0 -1
- package/lib-esm/shared/LayerManager.js.map +0 -1
- package/lib-esm/shared/constants.d.ts.map +0 -1
- package/lib-esm/shared/constants.js.map +0 -1
- package/lib-esm/shared/styles.d.ts.map +0 -1
- package/lib-esm/shared/styles.js.map +0 -1
|
@@ -1,57 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
13
2
|
import React, { useContext } from 'react';
|
|
14
3
|
import styled from '@emotion/styled';
|
|
15
|
-
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
16
|
-
import Checkbox from '../Input/Checkbox';
|
|
17
|
-
import MenuContext from './MenuContext';
|
|
18
|
-
const Container = styled.button `
|
|
19
|
-
font-weight: ${(props) => (props.selected ? 'bold' : 'normal')};
|
|
20
|
-
padding: 8px 6px;
|
|
21
|
-
border: none;
|
|
22
|
-
background-color: transparent;
|
|
23
|
-
font-size: 16px;
|
|
24
|
-
border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};
|
|
25
|
-
min-height: 41px;
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
position: relative;
|
|
30
|
-
color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};
|
|
31
|
-
|
|
32
|
-
&:hover,
|
|
33
|
-
&:focus,
|
|
34
|
-
&:focus-within {
|
|
35
|
-
background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};
|
|
36
|
-
}
|
|
4
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
|
+
import Checkbox from '../Input/Checkbox.js';
|
|
6
|
+
import MenuContext from './MenuContext.js';
|
|
37
7
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const MenuItemInner = (props, ref)
|
|
43
|
-
var _a, _b;
|
|
8
|
+
const Container = /*#__PURE__*/ styled("button", {
|
|
9
|
+
target: "ea4jlaf0",
|
|
10
|
+
label: "Container"
|
|
11
|
+
})("font-weight:", (props)=>props.selected ? 'bold' : 'normal', ";padding:8px;border:none;border-left:4px solid\n ", (props)=>props.selected && !props.multiselect ? getThemeValue(THEME_NAME.TEXT_COLOR_DARK) : 'transparent', ";background-color:transparent;font-size:16px;border-bottom:1px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";min-height:41px;display:flex;align-items:center;cursor:pointer;position:relative;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:hover,&:focus,&:focus-within{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";}& > label{margin:0 4px 0 0;}", "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiL2hvbWUvcnVubmVyL3dvcmsvbm8tZnJpbGxzLXVpL25vLWZyaWxscy11aS9zcmMvY29tcG9uZW50cy9NZW51L01lbnVJdGVtLnRzeCIsInNvdXJjZXMiOlsiL2hvbWUvcnVubmVyL3dvcmsvbm8tZnJpbGxzLXVpL25vLWZyaWxscy11aS9zcmMvY29tcG9uZW50cy9NZW51L01lbnVJdGVtLnRzeCJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QsIHsgU3ludGhldGljRXZlbnQsIHVzZUNvbnRleHQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBnZXRUaGVtZVZhbHVlLCBUSEVNRV9OQU1FIH0gZnJvbSAnLi4vLi4vc2hhcmVkL2NvbnN0YW50cyc7XG5pbXBvcnQgQ2hlY2tib3ggZnJvbSAnLi4vSW5wdXQvQ2hlY2tib3gnO1xuaW1wb3J0IE1lbnVDb250ZXh0LCB7IE1lbnVDb250ZXh0VHlwZSB9IGZyb20gJy4vTWVudUNvbnRleHQnO1xuXG5pbnRlcmZhY2UgTWVudUl0ZW1Qcm9wczxUPiB7XG4gICAgLyoqIFZhbHVlIG9mIHRoZSBlbGVtZW50ICovXG4gICAgdmFsdWU6IFQ7XG59XG5cbmNvbnN0IENvbnRhaW5lciA9IHN0eWxlZC5idXR0b248eyBzZWxlY3RlZDogYm9vbGVhbjsgbXVsdGlzZWxlY3Q/OiBib29sZWFuIH0+YFxuICAgIGZvbnQtd2VpZ2h0OiAkeyhwcm9wcykgPT4gKHByb3BzLnNlbGVjdGVkID8gJ2JvbGQnIDogJ25vcm1hbCcpfTtcbiAgICBwYWRkaW5nOiA4cHg7XG4gICAgYm9yZGVyOiBub25lO1xuICAgIGJvcmRlci1sZWZ0OiA0cHggc29saWRcbiAgICAgICAgJHsocHJvcHMpID0+XG4gICAgICAgICAgICBwcm9wcy5zZWxlY3RlZCAmJiAhcHJvcHMubXVsdGlzZWxlY3RcbiAgICAgICAgICAgICAgICA/IGdldFRoZW1lVmFsdWUoVEhFTUVfTkFNRS5URVhUX0NPTE9SX0RBUkspXG4gICAgICAgICAgICAgICAgOiAndHJhbnNwYXJlbnQnfTtcbiAgICBiYWNrZ3JvdW5kLWNvbG9yOiB0cmFuc3BhcmVudDtcbiAgICBmb250LXNpemU6IDE2cHg7XG4gICAgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkICR7Z2V0VGhlbWVWYWx1ZShUSEVNRV9OQU1FLkJPUkRFUl9MSUdIVF9DT0xPUil9O1xuICAgIG1pbi1oZWlnaHQ6IDQxcHg7XG4gICAgZGlzcGxheTogZmxleDtcbiAgICBhbGlnbi1pdGVtczogY2VudGVyO1xuICAgIGN1cnNvcjogcG9pbnRlcjtcbiAgICBwb3NpdGlvbjogcmVsYXRpdmU7XG4gICAgY29sb3I6ICR7Z2V0VGhlbWVWYWx1ZShUSEVNRV9OQU1FLlRFWFRfQ09MT1JfREFSSyl9O1xuXG4gICAgJjpob3ZlcixcbiAgICAmOmZvY3VzLFxuICAgICY6Zm9jdXMtd2l0aGluIHtcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogJHtnZXRUaGVtZVZhbHVlKFRIRU1FX05BTUUuQk9SREVSX0xJR0hUX0NPTE9SKX07XG4gICAgfVxuXG4gICAgJiA+IGxhYmVsIHtcbiAgICAgICAgbWFyZ2luOiAwIDRweCAwIDA7XG4gICAgfVxuYDtcblxuY29uc3QgTWVudUl0ZW1Jbm5lciA9IDxULD4oXG4gICAgcHJvcHM6IE1lbnVJdGVtUHJvcHM8VD4gJiBSZWFjdC5Qcm9wc1dpdGhDaGlsZHJlbixcbiAgICByZWY6IFJlYWN0LlJlZjxIVE1MQnV0dG9uRWxlbWVudD4sXG4pID0+IHtcbiAgICBjb25zdCBjb250ZXh0ID0gdXNlQ29udGV4dChNZW51Q29udGV4dCkgYXMgTWVudUNvbnRleHRUeXBlPFQ+O1xuICAgIGNvbnN0IHsgdmFsdWUsIGNoaWxkcmVuLCAuLi5yZXN0IH0gPSBwcm9wcztcbiAgICBjb25zdCBjbGlja0hhbmRsZXIgPSAoZTogU3ludGhldGljRXZlbnQpID0+IHtcbiAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTtcbiAgICAgICAgY29udGV4dC51cGRhdGVWYWx1ZSh2YWx1ZSBhcyBUICYgVFtdKTtcbiAgICB9O1xuXG4gICAgY29uc3Qgc2VsZWN0ZWQgPSBjb250ZXh0Lm11bHRpU2VsZWN0XG4gICAgICAgID8gY29udGV4dC52YWx1ZT8uaW5jbHVkZXM/Lih2YWx1ZSlcbiAgICAgICAgOiBjb250ZXh0LnZhbHVlID09PSB2YWx1ZTtcblxuICAgIHJldHVybiAoXG4gICAgICAgIDxDb250YWluZXJcbiAgICAgICAgICAgIHsuLi5yZXN0fVxuICAgICAgICAgICAgcmVmPXtyZWZ9XG4gICAgICAgICAgICB0eXBlPVwiYnV0dG9uXCJcbiAgICAgICAgICAgIHJvbGU9XCJvcHRpb25cIlxuICAgICAgICAgICAgYXJpYS1zZWxlY3RlZD17c2VsZWN0ZWR9XG4gICAgICAgICAgICBzZWxlY3RlZD17c2VsZWN0ZWR9XG4gICAgICAgICAgICBvbkNsaWNrPXtjbGlja0hhbmRsZXJ9XG4gICAgICAgICAgICBtdWx0aXNlbGVjdD17Y29udGV4dC5tdWx0aVNlbGVjdCA/IHRydWUgOiB1bmRlZmluZWR9XG4gICAgICAgID5cbiAgICAgICAgICAgIHtjb250ZXh0Lm11bHRpU2VsZWN0ICYmIChcbiAgICAgICAgICAgICAgICA8Q2hlY2tib3hcbiAgICAgICAgICAgICAgICAgICAgY2hlY2tlZD17c2VsZWN0ZWR9XG4gICAgICAgICAgICAgICAgICAgIHJlYWRPbmx5XG4gICAgICAgICAgICAgICAgICAgIHRhYkluZGV4PXstMX1cbiAgICAgICAgICAgICAgICAgICAgb25DbGljaz17KGUpID0+IGUuc3RvcFByb3BhZ2F0aW9uKCl9XG4gICAgICAgICAgICAgICAgLz5cbiAgICAgICAgICAgICl9XG4gICAgICAgICAgICB7Y2hpbGRyZW59XG4gICAgICAgIDwvQ29udGFpbmVyPlxuICAgICk7XG59O1xuXG5jb25zdCBNZW51SXRlbSA9IFJlYWN0LmZvcndhcmRSZWYoTWVudUl0ZW1Jbm5lcikgYXMgPFQ+KFxuICAgIHByb3BzOiBNZW51SXRlbVByb3BzPFQ+ICYgUmVhY3QuUHJvcHNXaXRoQ2hpbGRyZW4gJiB7IHJlZj86IFJlYWN0LlJlZjxIVE1MQnV0dG9uRWxlbWVudD4gfSxcbikgPT4gUmV0dXJuVHlwZTx0eXBlb2YgTWVudUl0ZW1Jbm5lcj47XG5cbmV4cG9ydCBkZWZhdWx0IE1lbnVJdGVtO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVdrQiJ9 */");
|
|
12
|
+
const MenuItemInner = (props, ref)=>{
|
|
44
13
|
const context = useContext(MenuContext);
|
|
45
|
-
const { value, children
|
|
46
|
-
const clickHandler = (e)
|
|
14
|
+
const { value, children, ...rest } = props;
|
|
15
|
+
const clickHandler = (e)=>{
|
|
47
16
|
e.stopPropagation();
|
|
48
17
|
context.updateValue(value);
|
|
49
18
|
};
|
|
50
|
-
const selected = context.multiSelect
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
19
|
+
const selected = context.multiSelect ? context.value?.includes?.(value) : context.value === value;
|
|
20
|
+
return /*#__PURE__*/ jsxs(Container, {
|
|
21
|
+
...rest,
|
|
22
|
+
ref: ref,
|
|
23
|
+
type: "button",
|
|
24
|
+
role: "option",
|
|
25
|
+
"aria-selected": selected,
|
|
26
|
+
selected: selected,
|
|
27
|
+
onClick: clickHandler,
|
|
28
|
+
multiselect: context.multiSelect ? true : undefined,
|
|
29
|
+
children: [
|
|
30
|
+
context.multiSelect && /*#__PURE__*/ jsx(Checkbox, {
|
|
31
|
+
checked: selected,
|
|
32
|
+
readOnly: true,
|
|
33
|
+
tabIndex: -1,
|
|
34
|
+
onClick: (e)=>e.stopPropagation()
|
|
35
|
+
}),
|
|
36
|
+
children
|
|
37
|
+
]
|
|
38
|
+
});
|
|
54
39
|
};
|
|
55
|
-
const MenuItem = React.forwardRef(MenuItemInner);
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
const MenuItem = /*#__PURE__*/ React.forwardRef(MenuItemInner);
|
|
41
|
+
|
|
42
|
+
export { MenuItem as default };
|
|
@@ -1,81 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
13
2
|
import React from 'react';
|
|
14
3
|
import PropTypes from 'prop-types';
|
|
15
|
-
import LayerManager, { LAYER_POSITION } from '../../shared/LayerManager';
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import LayerManager, { LAYER_POSITION } from '../../shared/LayerManager.js';
|
|
5
|
+
import { DialogContainer } from '../Dialog/Dialog.js';
|
|
6
|
+
|
|
18
7
|
const modalPropTypes = {
|
|
19
|
-
/** Opens the modal */
|
|
20
|
-
|
|
21
|
-
/** Closes the modal on
|
|
22
|
-
|
|
23
|
-
/** Closes the modal on overlay click */
|
|
24
|
-
closeOnOverlayClick: PropTypes.bool,
|
|
25
|
-
/** Call back function called when the modal closes. */
|
|
26
|
-
onClose: PropTypes.func,
|
|
8
|
+
/** Opens the modal */ open: PropTypes.bool.isRequired,
|
|
9
|
+
/** Closes the modal on esc */ closeOnEsc: PropTypes.bool,
|
|
10
|
+
/** Closes the modal on overlay click */ closeOnOverlayClick: PropTypes.bool,
|
|
11
|
+
/** Call back function called when the modal closes. */ onClose: PropTypes.func
|
|
27
12
|
};
|
|
28
|
-
/**
|
|
29
|
-
* Modal component
|
|
30
|
-
*
|
|
31
|
-
* A dialog window that sits on top of the main application content.
|
|
32
|
-
* It disrupts the user's workflow to demand attention for a critical task or decision.
|
|
33
|
-
*
|
|
34
|
-
* Accessibility:
|
|
35
|
-
* - Implements ARIA `role="dialog"` and `aria-modal="true"`.
|
|
36
|
-
* - Traps focus effectively within the modal while open.
|
|
37
|
-
* - Restores focus to the triggering element upon closure.
|
|
38
|
-
* - Supports closing via ESC key and overlay click.
|
|
39
|
-
*/
|
|
40
13
|
class Modal extends React.Component {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Syncs state with props.
|
|
16
|
+
*/ static getDerivedStateFromProps(props) {
|
|
17
|
+
if (props.open) {
|
|
18
|
+
return {
|
|
19
|
+
open: true
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Lifecycle method to save the currently focused element when the modal mounts while open.
|
|
26
|
+
*/ componentDidMount() {
|
|
27
|
+
if (this.props.open) {
|
|
28
|
+
this.lastFocusedElement = document.activeElement;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Lifecycle method to restore focus when the modal unmounts.
|
|
33
|
+
*/ componentWillUnmount() {
|
|
34
|
+
if (this.props.open) {
|
|
35
|
+
this.restoreFocus();
|
|
36
|
+
}
|
|
37
|
+
// Clean up layer references
|
|
38
|
+
if (this.closeCallback) {
|
|
39
|
+
this.closeCallback();
|
|
40
|
+
this.closeCallback = null;
|
|
41
|
+
}
|
|
42
|
+
this.layer = null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Lifecycle method to handle Modal updates.
|
|
46
|
+
* Manages opening/closing logic via LayerManager and focus preservation.
|
|
47
|
+
*/ getSnapshotBeforeUpdate(prevProps) {
|
|
48
|
+
const { open, closeOnEsc, closeOnOverlayClick, children, ...rest } = this.props;
|
|
49
|
+
if (prevProps.open && !open) {
|
|
50
|
+
this.closeCallback?.();
|
|
51
|
+
this.restoreFocus();
|
|
52
|
+
}
|
|
53
|
+
if (!prevProps.open && open) {
|
|
54
|
+
// Save current focus
|
|
55
|
+
this.lastFocusedElement = document.activeElement;
|
|
56
|
+
this.layer = LayerManager.renderLayer({
|
|
57
|
+
overlay: true,
|
|
58
|
+
exitDelay: 300,
|
|
59
|
+
position: LAYER_POSITION.DIALOG,
|
|
60
|
+
closeCallback: this.onClose,
|
|
61
|
+
closeOnEsc: closeOnEsc,
|
|
62
|
+
closeOnOverlayClick: closeOnOverlayClick,
|
|
63
|
+
component: /*#__PURE__*/ jsx(DialogContainer, {
|
|
64
|
+
...rest,
|
|
65
|
+
ref: this.setModalRef,
|
|
66
|
+
role: "dialog",
|
|
67
|
+
"aria-modal": "true",
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
onKeyDown: this.handleKeyDown,
|
|
70
|
+
onClick: (e)=>e.stopPropagation(),
|
|
71
|
+
elevated: true,
|
|
72
|
+
children: children
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
this.closeCallback = this.layer[1];
|
|
76
|
+
this.forceUpdate();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Renders the Modal component via the LayerManager portal.
|
|
81
|
+
*/ render() {
|
|
82
|
+
if (this.state.open && this.layer) {
|
|
83
|
+
const [Component] = this.layer;
|
|
84
|
+
return /*#__PURE__*/ jsx(Component, {});
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
constructor(...args){
|
|
89
|
+
super(...args), this.state = {
|
|
90
|
+
open: false
|
|
91
|
+
}, /**
|
|
92
|
+
* Internal close handler.
|
|
93
|
+
* Restores focus and calls the external onClose callback.
|
|
94
|
+
*/ this.onClose = ()=>{
|
|
52
95
|
this.restoreFocus();
|
|
53
96
|
this.setState({
|
|
54
|
-
open: false
|
|
97
|
+
open: false
|
|
55
98
|
});
|
|
56
|
-
|
|
99
|
+
this.props.onClose?.();
|
|
57
100
|
this.closeCallback = null;
|
|
58
101
|
this.layer = null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* Retrieves all focusable elements within the modal.
|
|
64
|
-
*/
|
|
65
|
-
this.getFocusableElements = () => {
|
|
66
|
-
if (!this.modalRef.current)
|
|
67
|
-
return [];
|
|
102
|
+
}, this.lastFocusedElement = null, this.modalRef = /*#__PURE__*/ React.createRef(), /**
|
|
103
|
+
* Retrieves all focusable elements within the modal.
|
|
104
|
+
*/ this.getFocusableElements = ()=>{
|
|
105
|
+
if (!this.modalRef.current) return [];
|
|
68
106
|
return Array.from(this.modalRef.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
this.handleKeyDown = (e) => {
|
|
107
|
+
}, /**
|
|
108
|
+
* Handles keydown events to implement the focus trap.
|
|
109
|
+
* Traps Tab and Shift+Tab within the modal.
|
|
110
|
+
*/ this.handleKeyDown = (e)=>{
|
|
75
111
|
if (e.key === 'Tab') {
|
|
76
112
|
const focusableElements = this.getFocusableElements();
|
|
77
|
-
if (focusableElements.length === 0)
|
|
78
|
-
return;
|
|
113
|
+
if (focusableElements.length === 0) return;
|
|
79
114
|
const firstElement = focusableElements[0];
|
|
80
115
|
const lastElement = focusableElements[focusableElements.length - 1];
|
|
81
116
|
if (e.shiftKey) {
|
|
@@ -83,47 +118,40 @@ class Modal extends React.Component {
|
|
|
83
118
|
lastElement.focus();
|
|
84
119
|
e.preventDefault();
|
|
85
120
|
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
121
|
+
} else {
|
|
88
122
|
if (document.activeElement === lastElement) {
|
|
89
123
|
firstElement.focus();
|
|
90
124
|
e.preventDefault();
|
|
91
125
|
}
|
|
92
126
|
}
|
|
93
127
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*/
|
|
98
|
-
this.restoreFocus = () => {
|
|
128
|
+
}, /**
|
|
129
|
+
* Restores focus to the element that was focused before the modal opened.
|
|
130
|
+
*/ this.restoreFocus = ()=>{
|
|
99
131
|
if (this.lastFocusedElement) {
|
|
100
132
|
// Check if the element is still in the document
|
|
101
133
|
const elementToBeFocused = this.lastFocusedElement;
|
|
102
134
|
this.lastFocusedElement = null;
|
|
103
|
-
setTimeout(()
|
|
135
|
+
setTimeout(()=>{
|
|
104
136
|
if (document.body.contains(elementToBeFocused)) {
|
|
105
137
|
elementToBeFocused.focus();
|
|
106
138
|
}
|
|
107
139
|
}, 100);
|
|
108
140
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*/
|
|
114
|
-
this.setModalRef = (node) => {
|
|
141
|
+
}, /**
|
|
142
|
+
* Callback ref to capture the Modal DOM element.
|
|
143
|
+
* Triggers initial focus setting when the element mounts.
|
|
144
|
+
*/ this.setModalRef = (node)=>{
|
|
115
145
|
// Update ref
|
|
116
146
|
this.modalRef.current = node;
|
|
117
147
|
if (node) {
|
|
118
148
|
// Set initial focus when the node is mounted
|
|
119
149
|
this.setInitialFocus(node);
|
|
120
150
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*/
|
|
126
|
-
this.setInitialFocus = (root) => {
|
|
151
|
+
}, /**
|
|
152
|
+
* Sets initial focus within the modal.
|
|
153
|
+
* Tries to focus the header (first child) first, then the first interactive element, or falls back to the container.
|
|
154
|
+
*/ this.setInitialFocus = (root)=>{
|
|
127
155
|
// Try to find the header (assumed to be the first child)
|
|
128
156
|
const firstChild = root.firstElementChild;
|
|
129
157
|
if (firstChild) {
|
|
@@ -138,82 +166,17 @@ class Modal extends React.Component {
|
|
|
138
166
|
const focusableElements = this.getFocusableElements();
|
|
139
167
|
if (focusableElements.length > 0) {
|
|
140
168
|
focusableElements[0].focus();
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
169
|
+
} else {
|
|
143
170
|
// Fallback to container
|
|
144
171
|
root.focus();
|
|
145
172
|
}
|
|
146
173
|
};
|
|
147
174
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Syncs state with props.
|
|
150
|
-
*/
|
|
151
|
-
static getDerivedStateFromProps(props) {
|
|
152
|
-
if (props.open) {
|
|
153
|
-
return {
|
|
154
|
-
open: true,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Lifecycle method to save the currently focused element when the modal mounts while open.
|
|
161
|
-
*/
|
|
162
|
-
componentDidMount() {
|
|
163
|
-
if (this.props.open) {
|
|
164
|
-
this.lastFocusedElement = document.activeElement;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Lifecycle method to restore focus when the modal unmounts.
|
|
169
|
-
*/
|
|
170
|
-
componentWillUnmount() {
|
|
171
|
-
if (this.props.open) {
|
|
172
|
-
this.restoreFocus();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Lifecycle method to handle Modal updates.
|
|
177
|
-
* Manages opening/closing logic via LayerManager and focus preservation.
|
|
178
|
-
*/
|
|
179
|
-
getSnapshotBeforeUpdate(prevProps) {
|
|
180
|
-
var _a;
|
|
181
|
-
const _b = this.props, { open, closeOnEsc, closeOnOverlayClick, children } = _b, rest = __rest(_b, ["open", "closeOnEsc", "closeOnOverlayClick", "children"]);
|
|
182
|
-
if (prevProps.open && !open) {
|
|
183
|
-
(_a = this.closeCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
184
|
-
this.restoreFocus();
|
|
185
|
-
}
|
|
186
|
-
if (!prevProps.open && open) {
|
|
187
|
-
// Save current focus
|
|
188
|
-
this.lastFocusedElement = document.activeElement;
|
|
189
|
-
this.layer = LayerManager.renderLayer({
|
|
190
|
-
overlay: true,
|
|
191
|
-
exitDelay: 300,
|
|
192
|
-
position: LAYER_POSITION.DIALOG,
|
|
193
|
-
closeCallback: this.onClose,
|
|
194
|
-
closeOnEsc: closeOnEsc,
|
|
195
|
-
closeOnOverlayClick: closeOnOverlayClick,
|
|
196
|
-
component: (_jsx(ModalContainer, Object.assign({}, rest, { ref: this.setModalRef, role: "dialog", "aria-modal": "true", tabIndex: -1, onKeyDown: this.handleKeyDown, onClick: (e) => e.stopPropagation(), elevated: true, children: children }))),
|
|
197
|
-
});
|
|
198
|
-
this.closeCallback = this.layer[1];
|
|
199
|
-
this.forceUpdate();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Renders the Modal component via the LayerManager portal.
|
|
204
|
-
*/
|
|
205
|
-
render() {
|
|
206
|
-
if (this.state.open && this.layer) {
|
|
207
|
-
const [Component] = this.layer;
|
|
208
|
-
return _jsx(Component, {});
|
|
209
|
-
}
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
175
|
}
|
|
213
176
|
Modal.propTypes = modalPropTypes;
|
|
214
177
|
Modal.defaultProps = {
|
|
215
178
|
closeOnEsc: true,
|
|
216
|
-
closeOnOverlayClick: true
|
|
179
|
+
closeOnOverlayClick: true
|
|
217
180
|
};
|
|
218
|
-
|
|
219
|
-
|
|
181
|
+
|
|
182
|
+
export { Modal as default };
|
|
@@ -1,72 +1,57 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { flushSync } from 'react-dom';
|
|
5
5
|
import { createRoot } from 'react-dom/client';
|
|
6
|
-
import LayerManager, { LAYER_POSITION } from '../../shared/LayerManager';
|
|
7
|
-
import NotificationManager from './NotificationManager';
|
|
8
|
-
import { NOTIFICATION_POSITION, NOTIFICATION_TYPE } from './types';
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import LayerManager, { LAYER_POSITION } from '../../shared/LayerManager.js';
|
|
7
|
+
import NotificationManager from './NotificationManager.js';
|
|
8
|
+
import { NOTIFICATION_POSITION, NOTIFICATION_TYPE } from './types.js';
|
|
9
|
+
|
|
10
|
+
/** This component is only used for storybook documentation */ class StoryProps extends React.Component {
|
|
11
11
|
render() {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
StoryProps.propTypes = {
|
|
16
|
-
/** Title of the notification */
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/** Duration for the notification in milliseconds */
|
|
23
|
-
duration: PropTypes.number,
|
|
24
|
-
/** Creates sticky notification */
|
|
25
|
-
sticky: PropTypes.bool,
|
|
26
|
-
/** Type of notification */
|
|
27
|
-
type: PropTypes.oneOf([
|
|
16
|
+
/** Title of the notification */ title: PropTypes.string.isRequired,
|
|
17
|
+
/** Body of the notification */ description: PropTypes.string.isRequired,
|
|
18
|
+
/** Id for the notification, helps in de-duplication. */ id: PropTypes.string,
|
|
19
|
+
/** Duration for the notification in milliseconds */ duration: PropTypes.number,
|
|
20
|
+
/** Creates sticky notification */ sticky: PropTypes.bool,
|
|
21
|
+
/** Type of notification */ type: PropTypes.oneOf([
|
|
28
22
|
NOTIFICATION_TYPE.INFO,
|
|
29
23
|
NOTIFICATION_TYPE.SUCCESS,
|
|
30
24
|
NOTIFICATION_TYPE.WARNING,
|
|
31
|
-
NOTIFICATION_TYPE.DANGER
|
|
25
|
+
NOTIFICATION_TYPE.DANGER
|
|
32
26
|
]),
|
|
33
|
-
/** Action button text */
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
/** Notification close callback. */
|
|
38
|
-
onClose: PropTypes.func,
|
|
39
|
-
/** Aria label for the close button on the notification. Defaults to "Close notification" */
|
|
40
|
-
closeButtonAriaLabel: PropTypes.string,
|
|
27
|
+
/** Action button text */ buttonText: PropTypes.string,
|
|
28
|
+
/** Action button click callback */ buttonClick: PropTypes.func,
|
|
29
|
+
/** Notification close callback. */ onClose: PropTypes.func,
|
|
30
|
+
/** Aria label for the close button on the notification. Defaults to "Close notification" */ closeButtonAriaLabel: PropTypes.string
|
|
41
31
|
};
|
|
42
32
|
StoryProps.defaultProps = {
|
|
43
33
|
duration: 5000,
|
|
44
34
|
sticky: false,
|
|
45
|
-
type: NOTIFICATION_TYPE.INFO
|
|
35
|
+
type: NOTIFICATION_TYPE.INFO
|
|
46
36
|
};
|
|
47
|
-
/** Maps notification position to layer position */
|
|
48
|
-
const positionMap = {
|
|
37
|
+
/** Maps notification position to layer position */ const positionMap = {
|
|
49
38
|
[NOTIFICATION_POSITION.TOP_LEFT]: LAYER_POSITION.TOP_LEFT,
|
|
50
39
|
[NOTIFICATION_POSITION.TOP_RIGHT]: LAYER_POSITION.TOP_RIGHT,
|
|
51
40
|
[NOTIFICATION_POSITION.BOTTOM_LEFT]: LAYER_POSITION.BOTTOM_LEFT,
|
|
52
|
-
[NOTIFICATION_POSITION.BOTTOM_RIGHT]: LAYER_POSITION.BOTTOM_RIGHT
|
|
41
|
+
[NOTIFICATION_POSITION.BOTTOM_RIGHT]: LAYER_POSITION.BOTTOM_RIGHT
|
|
53
42
|
};
|
|
54
|
-
/** Notification class */
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/** Helps in maintaining single instance for different positions. */
|
|
58
|
-
this.containers = new Map();
|
|
43
|
+
/** Notification class */ class Notification {
|
|
44
|
+
constructor(){
|
|
45
|
+
/** Helps in maintaining single instance for different positions. */ this.containers = new Map();
|
|
59
46
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.add = (position, options, ariaLabel = 'Notifications') => {
|
|
47
|
+
* Adds a notification
|
|
48
|
+
*
|
|
49
|
+
* @param position - The position where the notification should appear
|
|
50
|
+
* @param options - Configuration options for the notification
|
|
51
|
+
* @returns The notification ID or a promise that resolves to the notification ID
|
|
52
|
+
*/ this.add = (position, options, ariaLabel = 'Notifications')=>{
|
|
67
53
|
if (!this.containers.has(position)) {
|
|
68
|
-
/** Callback ref to capture the NotificationManager instance when it mounts */
|
|
69
|
-
const refCallback = (instance) => {
|
|
54
|
+
/** Callback ref to capture the NotificationManager instance when it mounts */ const refCallback = (instance)=>{
|
|
70
55
|
if (instance) {
|
|
71
56
|
const container = this.containers.get(position);
|
|
72
57
|
if (container) {
|
|
@@ -79,7 +64,12 @@ class Notification {
|
|
|
79
64
|
closeOnOverlayClick: false,
|
|
80
65
|
position: positionMap[position],
|
|
81
66
|
alwaysOnTop: true,
|
|
82
|
-
component: (
|
|
67
|
+
component: /*#__PURE__*/ jsx(NotificationManager, {
|
|
68
|
+
ref: refCallback,
|
|
69
|
+
position: position,
|
|
70
|
+
onEmpty: ()=>this.destroy(position),
|
|
71
|
+
ariaLabel: ariaLabel
|
|
72
|
+
})
|
|
83
73
|
});
|
|
84
74
|
// Create a div to mount the Component
|
|
85
75
|
const div = document.createElement('div');
|
|
@@ -88,11 +78,11 @@ class Notification {
|
|
|
88
78
|
this.containers.set(position, {
|
|
89
79
|
manager: null,
|
|
90
80
|
root,
|
|
91
|
-
div
|
|
81
|
+
div
|
|
92
82
|
});
|
|
93
83
|
// Render the Component which will trigger the LayerManager's useEffect
|
|
94
|
-
flushSync(()
|
|
95
|
-
root.render(
|
|
84
|
+
flushSync(()=>{
|
|
85
|
+
root.render(/*#__PURE__*/ jsx(Component, {}));
|
|
96
86
|
});
|
|
97
87
|
}
|
|
98
88
|
const container = this.containers.get(position);
|
|
@@ -100,8 +90,8 @@ class Notification {
|
|
|
100
90
|
return container.manager.add(options);
|
|
101
91
|
}
|
|
102
92
|
// If manager is not ready yet, wait a bit and retry
|
|
103
|
-
return new Promise((resolve)
|
|
104
|
-
setTimeout(()
|
|
93
|
+
return new Promise((resolve)=>{
|
|
94
|
+
setTimeout(()=>{
|
|
105
95
|
const container = this.containers.get(position);
|
|
106
96
|
if (container && container.manager) {
|
|
107
97
|
resolve(container.manager.add(options));
|
|
@@ -110,24 +100,22 @@ class Notification {
|
|
|
110
100
|
});
|
|
111
101
|
};
|
|
112
102
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.remove = (position, id) => {
|
|
103
|
+
* Removes a notification
|
|
104
|
+
*
|
|
105
|
+
* @param position - The position of the notification container
|
|
106
|
+
* @param id - The unique ID of the notification to remove
|
|
107
|
+
*/ this.remove = (position, id)=>{
|
|
119
108
|
const container = this.containers.get(position);
|
|
120
109
|
if (container && container.manager) {
|
|
121
110
|
container.manager.remove(id);
|
|
122
111
|
}
|
|
123
112
|
};
|
|
124
113
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.destroy = (position) => {
|
|
114
|
+
* Destroys entire stack of notifications at a position.
|
|
115
|
+
* Unmounts the React root and cleans up DOM elements.
|
|
116
|
+
*
|
|
117
|
+
* @param position - The position of the notification container to destroy
|
|
118
|
+
*/ this.destroy = (position)=>{
|
|
131
119
|
const container = this.containers.get(position);
|
|
132
120
|
if (container) {
|
|
133
121
|
container.root.unmount();
|
|
@@ -139,6 +127,6 @@ class Notification {
|
|
|
139
127
|
};
|
|
140
128
|
}
|
|
141
129
|
}
|
|
142
|
-
/** Export a singleton instance */
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
/** Export a singleton instance */ var Notification$1 = new Notification();
|
|
131
|
+
|
|
132
|
+
export { StoryProps, Notification$1 as default };
|
|
@@ -57,7 +57,10 @@ declare class NotificationManager extends React.Component<NotificationManagerPro
|
|
|
57
57
|
* @param id
|
|
58
58
|
*/
|
|
59
59
|
resume: (id: string) => () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Clean up all pending timeouts when component unmounts
|
|
62
|
+
*/
|
|
63
|
+
componentWillUnmount(): void;
|
|
60
64
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
61
65
|
}
|
|
62
66
|
export default NotificationManager;
|
|
63
|
-
//# sourceMappingURL=NotificationManager.d.ts.map
|