no-frills-ui 0.0.14-alpha.8 → 0.0.14-rc.0
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/README.md +2 -3
- package/dist/index.js +841 -710
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +9 -13
- package/lib-esm/components/Accordion/Accordion.js +3 -10
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
- package/lib-esm/components/Accordion/AccordionStep.js +33 -28
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.d.ts +13 -16
- package/lib-esm/components/Badge/Badge.js +10 -20
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts +9 -5
- package/lib-esm/components/Button/ActionButton.js +18 -3
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +9 -5
- package/lib-esm/components/Button/Button.js +17 -5
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts +9 -5
- package/lib-esm/components/Button/IconButton.js +18 -3
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts +9 -5
- package/lib-esm/components/Button/LinkButton.js +18 -3
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
- package/lib-esm/components/Button/RaisedButton.js +18 -3
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts +4 -6
- package/lib-esm/components/Card/Card.js +16 -3
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +2 -2
- package/lib-esm/components/Chip/Chip.js +14 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -39
- package/lib-esm/components/ChipInput/ChipInput.js +35 -36
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +4 -11
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
- package/lib-esm/components/Dialog/ConfirmDialog.js +4 -12
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +8 -14
- package/lib-esm/components/Dialog/Dialog.js +11 -9
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
- package/lib-esm/components/Dialog/PromptDialog.js +10 -18
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +37 -59
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +23 -26
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +2 -2
- package/lib-esm/components/DragAndDrop/DragItem.js +40 -38
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +3 -3
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +24 -31
- package/lib-esm/components/Drawer/Drawer.js +49 -45
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts +6 -8
- package/lib-esm/components/Groups/Group.js +12 -10
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +30 -26
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +8 -18
- package/lib-esm/components/Input/Dropdown.js +42 -17
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +8 -3
- package/lib-esm/components/Input/Input.js +20 -19
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +4 -8
- package/lib-esm/components/Input/Radio.js +16 -13
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +4 -8
- package/lib-esm/components/Input/RadioButton.js +15 -12
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts +6 -13
- package/lib-esm/components/Input/Select.js +21 -18
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts +6 -13
- package/lib-esm/components/Input/TextArea.js +29 -24
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +4 -9
- package/lib-esm/components/Input/Toggle.js +12 -10
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +4 -14
- package/lib-esm/components/Menu/Menu.js +24 -16
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +4 -4
- package/lib-esm/components/Menu/MenuContext.js +1 -0
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +10 -4
- package/lib-esm/components/Menu/MenuItem.js +19 -5
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +17 -23
- package/lib-esm/components/Modal/Modal.js +37 -34
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +39 -34
- package/lib-esm/components/Notification/Notification.js +16 -39
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +4 -4
- package/lib-esm/components/Notification/NotificationManager.js +18 -14
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/index.d.ts +1 -0
- package/lib-esm/components/Notification/style.d.ts +2 -3
- package/lib-esm/components/Notification/style.js +11 -11
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +42 -44
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -15
- package/lib-esm/components/Spinner/Spinner.js +12 -13
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Step.d.ts +15 -12
- package/lib-esm/components/Stepper/Step.js +10 -8
- package/lib-esm/components/Stepper/Step.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
- package/lib-esm/components/Stepper/Stepper.js +25 -23
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tab.d.ts +10 -16
- package/lib-esm/components/Tabs/Tab.js +0 -8
- package/lib-esm/components/Tabs/Tab.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
- package/lib-esm/components/Tabs/Tabs.js +39 -31
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +7 -7
- package/lib-esm/components/Toast/Toast.js +13 -12
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
- package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
- package/lib-esm/components/Tooltip/Tooltip.js +11 -21
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/icons/CheckCircle.js +2 -2
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.js +2 -2
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/Info.js +2 -2
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.js +2 -2
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/index.js +43 -0
- package/lib-esm/shared/LayerManager.d.ts +5 -4
- package/lib-esm/shared/LayerManager.js +123 -111
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/styles.js +4 -4
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +66 -31
- package/lib-esm/components/index.js +0 -43
- /package/lib-esm/{components/index.js.map → index.js.map} +0 -0
|
@@ -25,7 +25,7 @@ declare class NotificationManager extends React.Component<NotificationManagerPro
|
|
|
25
25
|
*
|
|
26
26
|
* @param id
|
|
27
27
|
*/
|
|
28
|
-
remove: (id
|
|
28
|
+
remove: (id?: string) => void;
|
|
29
29
|
/**
|
|
30
30
|
* Adds a notification to stack.
|
|
31
31
|
*
|
|
@@ -44,19 +44,19 @@ declare class NotificationManager extends React.Component<NotificationManagerPro
|
|
|
44
44
|
*
|
|
45
45
|
* @param id
|
|
46
46
|
*/
|
|
47
|
-
closeClickHandler: (id
|
|
47
|
+
closeClickHandler: (id?: string) => () => void;
|
|
48
48
|
/**
|
|
49
49
|
* Pause notification when user is hovering over it.
|
|
50
50
|
*
|
|
51
51
|
* @param id
|
|
52
52
|
*/
|
|
53
|
-
pause: (id
|
|
53
|
+
pause: (id?: string) => () => void;
|
|
54
54
|
/**
|
|
55
55
|
* Restart the removal of notification.
|
|
56
56
|
*
|
|
57
57
|
* @param id
|
|
58
58
|
*/
|
|
59
|
-
resume: (id
|
|
59
|
+
resume: (id?: string) => () => void;
|
|
60
60
|
/**
|
|
61
61
|
* Clean up all pending timeouts when component unmounts
|
|
62
62
|
*/
|
|
@@ -9,7 +9,7 @@ import CheckCircle$3 from '../../icons/ErrorOutline.js';
|
|
|
9
9
|
import ActionButton from '../Button/ActionButton.js';
|
|
10
10
|
import Close from '../../icons/Close.js';
|
|
11
11
|
|
|
12
|
-
const DEFAULT_DURATION = 5000;
|
|
12
|
+
const DEFAULT_DURATION$1 = 5000;
|
|
13
13
|
/**
|
|
14
14
|
* Notification Manager class
|
|
15
15
|
*/ class NotificationManager extends React.Component {
|
|
@@ -106,6 +106,7 @@ const DEFAULT_DURATION = 5000;
|
|
|
106
106
|
*
|
|
107
107
|
* @param id
|
|
108
108
|
*/ this.remove = (id)=>{
|
|
109
|
+
if (!id) return;
|
|
109
110
|
// Trigger leaving animation.
|
|
110
111
|
this.setState({
|
|
111
112
|
notices: this.state.notices.map((notice)=>({
|
|
@@ -150,22 +151,22 @@ const DEFAULT_DURATION = 5000;
|
|
|
150
151
|
const type = notice.type || NOTIFICATION_TYPE.INFO;
|
|
151
152
|
const isUrgent = type === NOTIFICATION_TYPE.WARNING || type === NOTIFICATION_TYPE.DANGER;
|
|
152
153
|
// Add notice to the top of stack.
|
|
153
|
-
this.setState({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
this.setState((prevState)=>({
|
|
155
|
+
notices: [
|
|
156
|
+
{
|
|
157
|
+
...notice,
|
|
158
|
+
id
|
|
159
|
+
},
|
|
160
|
+
...prevState.notices
|
|
161
|
+
]
|
|
162
|
+
}), ()=>{
|
|
162
163
|
// Update live region after state update
|
|
163
164
|
const announcement = `${notice.title} ${notice.description}`;
|
|
164
165
|
this.updateLiveRegion(announcement, isUrgent);
|
|
165
166
|
});
|
|
166
167
|
// set timeout for closing the notification.
|
|
167
168
|
if (!notice.sticky) {
|
|
168
|
-
this.timeouts[id] = setTimeout(()=>this.remove(id), notice.duration || DEFAULT_DURATION);
|
|
169
|
+
this.timeouts[id] = setTimeout(()=>this.remove(id), notice.duration || DEFAULT_DURATION$1);
|
|
169
170
|
}
|
|
170
171
|
// Add id to the set.
|
|
171
172
|
this.set.add(id);
|
|
@@ -197,15 +198,18 @@ const DEFAULT_DURATION = 5000;
|
|
|
197
198
|
*
|
|
198
199
|
* @param id
|
|
199
200
|
*/ this.pause = (id)=>()=>{
|
|
200
|
-
|
|
201
|
+
if (id && this.timeouts[id]) {
|
|
202
|
+
clearTimeout(this.timeouts[id]);
|
|
203
|
+
delete this.timeouts[id];
|
|
204
|
+
}
|
|
201
205
|
}, /**
|
|
202
206
|
* Restart the removal of notification.
|
|
203
207
|
*
|
|
204
208
|
* @param id
|
|
205
209
|
*/ this.resume = (id)=>()=>{
|
|
206
210
|
const notice = this.state.notices.find((notice)=>notice.id === id);
|
|
207
|
-
if (!notice.
|
|
208
|
-
this.timeouts[id] = setTimeout(()=>this.remove(id), DEFAULT_DURATION);
|
|
211
|
+
if (!notice?.sticky && id && !this.timeouts[id]) {
|
|
212
|
+
this.timeouts[id] = setTimeout(()=>this.remove(id), DEFAULT_DURATION$1);
|
|
209
213
|
}
|
|
210
214
|
};
|
|
211
215
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationManager.js","sources":["../../../src/components/Notification/NotificationManager.tsx"],"sourcesContent":["import React from 'react';\nimport { Close, Info, ReportProblem, ErrorOutline, CheckCircle } from '../../icons';\nimport { ActionButton } from '../Button';\nimport {\n Container,\n Notice,\n Title,\n IconContainer,\n FillParent,\n Body,\n CloseButton,\n Footer,\n VisuallyHidden,\n} from './style';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\ninterface NotificationManagerProps {\n // Notification Position\n position: NOTIFICATION_POSITION;\n // Callback for when stack is emptied\n onEmpty: () => void;\n // Aria label for the notification list\n ariaLabel?: string;\n}\n\n// Notice prop\ninterface NoticeProp extends NotificationOptions {\n leaving?: boolean;\n}\n\n// Manager state\ninterface NotificationManagerState {\n notices: NoticeProp[];\n}\n\ntype timeouts = {\n [id: string]: NodeJS.Timeout;\n};\n\nconst DEFAULT_DURATION = 5000;\n\n/**\n * Notification Manager class\n */\nclass NotificationManager extends React.Component<\n NotificationManagerProps,\n NotificationManagerState\n> {\n state: NotificationManagerState = {\n notices: [],\n };\n\n // bookkeeping for timeouts\n private timeouts: timeouts = {};\n\n // Set of notification ids\n private set = new Set<string>();\n\n // Refs for live regions to ensure they exist before updates\n private politeRegionRef = React.createRef<HTMLDivElement>();\n private assertiveRegionRef = React.createRef<HTMLDivElement>();\n\n /**\n * Removes a notification from stack if the notification with the given id is found.\n *\n * @param id\n */\n public remove = (id: string) => {\n // Trigger leaving animation.\n this.setState({\n notices: this.state.notices.map((notice) => ({\n ...notice,\n leaving: notice.id === id ? true : notice.leaving,\n })),\n });\n this.set.delete(id);\n\n // Remove notification on animation completion.\n setTimeout(() => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (notice) {\n // call close callback, ignore any errors in callback.\n if (notice.onClose) {\n try {\n notice.onClose();\n } catch (e) {\n console.warn('Error in notification close callback', e.message);\n }\n }\n\n // Remove the notification\n this.setState(\n {\n notices: this.state.notices.filter((notice) => notice.id !== id),\n },\n () => {\n // Check if the stack is empty and then call the\n // empty callback function.\n if (this.state.notices.length === 0) {\n this.props.onEmpty();\n }\n },\n );\n }\n }, 550);\n };\n\n /**\n * Adds a notification to stack.\n *\n * @param notice\n */\n public add = async (notice: NotificationOptions) => {\n // Generate unique id if not provided.\n const id = notice.id || (Math.random() * 10 ** 7).toFixed(0);\n\n // De-dupe on id\n if (!this.set.has(id)) {\n const type = notice.type || NOTIFICATION_TYPE.INFO;\n const isUrgent =\n type === NOTIFICATION_TYPE.WARNING || type === NOTIFICATION_TYPE.DANGER;\n\n // Add notice to the top of stack.\n this.setState(\n {\n notices: [\n {\n ...notice,\n id,\n },\n ...this.state.notices,\n ],\n },\n () => {\n // Update live region after state update\n const announcement = `${notice.title} ${notice.description}`;\n this.updateLiveRegion(announcement, isUrgent);\n },\n );\n\n // set timeout for closing the notification.\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(\n () => this.remove(id),\n notice.duration || DEFAULT_DURATION,\n );\n }\n\n // Add id to the set.\n this.set.add(id);\n }\n\n return id;\n };\n\n /**\n * Update live region content with clear-then-set pattern for reliable VoiceOver announcements.\n *\n * @param content - The text content to announce\n * @param isAssertive - Whether to use assertive (alert) or polite (log) live region\n */\n private updateLiveRegion = (content: string, isAssertive: boolean) => {\n const region = isAssertive ? this.assertiveRegionRef.current : this.politeRegionRef.current;\n\n if (region) {\n // Add content after delay\n setTimeout(() => {\n if (region) {\n region.textContent = content;\n }\n }, 150);\n }\n };\n\n /**\n * Handler for close button click.\n *\n * @param id\n */\n public closeClickHandler = (id: string) => () => {\n this.remove(id);\n };\n\n /**\n * Pause notification when user is hovering over it.\n *\n * @param id\n */\n public pause = (id: string) => () => {\n clearTimeout(this.timeouts[id]);\n };\n\n /**\n * Restart the removal of notification.\n *\n * @param id\n */\n public resume = (id: string) => () => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(() => this.remove(id), DEFAULT_DURATION);\n }\n };\n\n /**\n * Clean up all pending timeouts when component unmounts\n */\n componentWillUnmount() {\n // Clear all pending timeouts\n Object.keys(this.timeouts).forEach((id) => {\n clearTimeout(this.timeouts[id]);\n });\n this.timeouts = {};\n this.set.clear();\n }\n\n render() {\n return (\n <Container position={this.props.position}>\n {/* Polite live region - uses role=\"log\" for better VoiceOver compatibility */}\n <VisuallyHidden\n ref={this.politeRegionRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n aria-relevant=\"additions text\"\n />\n\n {/* Assertive live region - pre-rendered and persistent */}\n <VisuallyHidden\n ref={this.assertiveRegionRef}\n role=\"alert\"\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n />\n\n {/* Visual notifications with list semantics */}\n <div role=\"list\" aria-label={this.props.ariaLabel}>\n {this.state.notices.map((notice) => {\n const {\n id,\n title,\n description,\n leaving,\n type = NOTIFICATION_TYPE.INFO,\n buttonText,\n buttonClick,\n closeButtonAriaLabel,\n } = notice;\n\n return (\n <Notice\n key={id}\n {...notice}\n position={this.props.position}\n className={leaving ? 'leave' : ''}\n onMouseEnter={this.pause(id)}\n onMouseLeave={this.resume(id)}\n role=\"listitem\"\n >\n <IconContainer type={type} aria-hidden=\"true\">\n {type === NOTIFICATION_TYPE.INFO && <Info />}\n {type === NOTIFICATION_TYPE.SUCCESS && <CheckCircle />}\n {type === NOTIFICATION_TYPE.WARNING && <ReportProblem />}\n {type === NOTIFICATION_TYPE.DANGER && <ErrorOutline />}\n </IconContainer>\n <FillParent>\n <Title type={type}>{title}</Title>\n <Body>{description}</Body>\n {buttonText && (\n <Footer>\n <ActionButton\n onClick={() => {\n buttonClick?.();\n }}\n >\n {buttonText}\n </ActionButton>\n </Footer>\n )}\n </FillParent>\n <CloseButton\n onClick={this.closeClickHandler(id)}\n aria-label={closeButtonAriaLabel || 'Close notification'}\n tabIndex={0}\n >\n <Close />\n </CloseButton>\n </Notice>\n );\n })}\n </div>\n </Container>\n );\n }\n}\n\nexport default NotificationManager;\n"],"names":["DEFAULT_DURATION","NotificationManager","React","Component","componentWillUnmount","Object","keys","timeouts","forEach","id","clearTimeout","set","clear","render","_jsxs","Container","position","props","_jsx","VisuallyHidden","ref","politeRegionRef","role","aria-live","aria-atomic","aria-relevant","assertiveRegionRef","div","aria-label","ariaLabel","state","notices","map","notice","title","description","leaving","type","NOTIFICATION_TYPE","INFO","buttonText","buttonClick","closeButtonAriaLabel","Notice","className","onMouseEnter","pause","onMouseLeave","resume","IconContainer","aria-hidden","Info","SUCCESS","CheckCircle","WARNING","ReportProblem","DANGER","ErrorOutline","FillParent","Title","Body","Footer","ActionButton","onClick","CloseButton","closeClickHandler","tabIndex","Close","Set","createRef","remove","setState","delete","setTimeout","find","onClose","e","console","warn","message","filter","length","onEmpty","add","Math","random","toFixed","has","isUrgent","announcement","updateLiveRegion","sticky","duration","content","isAssertive","region","current","textContent"],"mappings":";;;;;;;;;;;AAuCA,MAAMA,gBAAAA,GAAmB,IAAA;AAEzB;;IAGA,MAAMC,mBAAAA,SAA4BC,KAAAA,CAAMC,SAAS,CAAA;AAgK7C;;AAEC,QACDC,oBAAAA,GAAuB;;QAEnBC,MAAAA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AA,CAAG,CAAA;YAClC,CAAA;;;;QAMC,IAAA,CACMuC,MAAAA,GAAS,CAACvC,EAAAA,GAAe,IAAA;AAC5B,gBAAA,MAAMwB,MAAAA,GAAS,IAAI,CAACH,KAAK,CAACC,OAAO,CAAC2C,IAAI,CAAC,CAACzC,MAAAA,GAAWA,MAAAA,CAAOxB,EAAE,KAAKA,EAAAA,CAAAA;gBACjE,IAAI,CAACwB,MAAAA,CAAO0D,MAAM,EAAE;oBAChB,IAAI,CAACpF,QAAQ,CAACE,EAAAA,CAAG,GAAGgE,UAAAA,CAAW,IAAM,IAAI,CAACH,MAAM,CAAC7D,EAAAA,CAAAA,EAAKT,gBAAAA,CAAAA;AAC1D,gBAAA;AACJ,YAAA,CAAA;;AA6FJ;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationManager.js","sources":["../../../src/components/Notification/NotificationManager.tsx"],"sourcesContent":["import React from 'react';\nimport { Close, Info, ReportProblem, ErrorOutline, CheckCircle } from '../../icons';\nimport { ActionButton } from '../Button';\nimport {\n Container,\n Notice,\n Title,\n IconContainer,\n FillParent,\n Body,\n CloseButton,\n Footer,\n VisuallyHidden,\n} from './style';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\ninterface NotificationManagerProps {\n // Notification Position\n position: NOTIFICATION_POSITION;\n // Callback for when stack is emptied\n onEmpty: () => void;\n // Aria label for the notification list\n ariaLabel?: string;\n}\n\n// Notice prop\ninterface NoticeProp extends NotificationOptions {\n leaving?: boolean;\n}\n\n// Manager state\ninterface NotificationManagerState {\n notices: NoticeProp[];\n}\n\ntype timeouts = {\n [id: string]: NodeJS.Timeout;\n};\n\nconst DEFAULT_DURATION = 5000;\n\n/**\n * Notification Manager class\n */\nclass NotificationManager extends React.Component<\n NotificationManagerProps,\n NotificationManagerState\n> {\n state: NotificationManagerState = {\n notices: [],\n };\n\n // bookkeeping for timeouts\n private timeouts: timeouts = {};\n\n // Set of notification ids\n private set = new Set<string>();\n\n // Refs for live regions to ensure they exist before updates\n private politeRegionRef = React.createRef<HTMLDivElement>();\n private assertiveRegionRef = React.createRef<HTMLDivElement>();\n\n /**\n * Removes a notification from stack if the notification with the given id is found.\n *\n * @param id\n */\n public remove = (id?: string) => {\n if (!id) return;\n\n // Trigger leaving animation.\n this.setState({\n notices: this.state.notices.map((notice) => ({\n ...notice,\n leaving: notice.id === id ? true : notice.leaving,\n })),\n });\n this.set.delete(id);\n\n // Remove notification on animation completion.\n setTimeout(() => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (notice) {\n // call close callback, ignore any errors in callback.\n if (notice.onClose) {\n try {\n notice.onClose();\n } catch (e: unknown) {\n console.warn('Error in notification close callback', (e as Error).message);\n }\n }\n\n // Remove the notification\n this.setState(\n {\n notices: this.state.notices.filter((notice) => notice.id !== id),\n },\n () => {\n // Check if the stack is empty and then call the\n // empty callback function.\n if (this.state.notices.length === 0) {\n this.props.onEmpty();\n }\n },\n );\n }\n }, 550);\n };\n\n /**\n * Adds a notification to stack.\n *\n * @param notice\n */\n public add = async (notice: NotificationOptions) => {\n // Generate unique id if not provided.\n const id = notice.id || (Math.random() * 10 ** 7).toFixed(0);\n\n // De-dupe on id\n if (!this.set.has(id)) {\n const type = notice.type || NOTIFICATION_TYPE.INFO;\n const isUrgent =\n type === NOTIFICATION_TYPE.WARNING || type === NOTIFICATION_TYPE.DANGER;\n\n // Add notice to the top of stack.\n this.setState(\n (prevState) => ({\n notices: [\n {\n ...notice,\n id,\n },\n ...prevState.notices,\n ],\n }),\n () => {\n // Update live region after state update\n const announcement = `${notice.title} ${notice.description}`;\n this.updateLiveRegion(announcement, isUrgent);\n },\n );\n\n // set timeout for closing the notification.\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(\n () => this.remove(id),\n notice.duration || DEFAULT_DURATION,\n );\n }\n\n // Add id to the set.\n this.set.add(id);\n }\n\n return id;\n };\n\n /**\n * Update live region content with clear-then-set pattern for reliable VoiceOver announcements.\n *\n * @param content - The text content to announce\n * @param isAssertive - Whether to use assertive (alert) or polite (log) live region\n */\n private updateLiveRegion = (content: string, isAssertive: boolean) => {\n const region = isAssertive ? this.assertiveRegionRef.current : this.politeRegionRef.current;\n\n if (region) {\n // Add content after delay\n setTimeout(() => {\n if (region) {\n region.textContent = content;\n }\n }, 150);\n }\n };\n\n /**\n * Handler for close button click.\n *\n * @param id\n */\n public closeClickHandler = (id?: string) => () => {\n this.remove(id);\n };\n\n /**\n * Pause notification when user is hovering over it.\n *\n * @param id\n */\n public pause = (id?: string) => () => {\n if (id && this.timeouts[id]) {\n clearTimeout(this.timeouts[id]);\n delete this.timeouts[id];\n }\n };\n\n /**\n * Restart the removal of notification.\n *\n * @param id\n */\n public resume = (id?: string) => () => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (!notice?.sticky && id && !this.timeouts[id]) {\n this.timeouts[id] = setTimeout(() => this.remove(id), DEFAULT_DURATION);\n }\n };\n\n /**\n * Clean up all pending timeouts when component unmounts\n */\n componentWillUnmount() {\n // Clear all pending timeouts\n Object.keys(this.timeouts).forEach((id) => {\n clearTimeout(this.timeouts[id]);\n });\n this.timeouts = {};\n this.set.clear();\n }\n\n render() {\n return (\n <Container position={this.props.position}>\n {/* Polite live region - uses role=\"log\" for better VoiceOver compatibility */}\n <VisuallyHidden\n ref={this.politeRegionRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n aria-relevant=\"additions text\"\n />\n\n {/* Assertive live region - pre-rendered and persistent */}\n <VisuallyHidden\n ref={this.assertiveRegionRef}\n role=\"alert\"\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n />\n\n {/* Visual notifications with list semantics */}\n <div role=\"list\" aria-label={this.props.ariaLabel}>\n {this.state.notices.map((notice) => {\n const {\n id,\n title,\n description,\n leaving,\n type = NOTIFICATION_TYPE.INFO,\n buttonText,\n buttonClick,\n closeButtonAriaLabel,\n } = notice;\n\n return (\n <Notice\n key={id}\n {...notice}\n position={this.props.position}\n className={leaving ? 'leave' : ''}\n onMouseEnter={this.pause(id)}\n onMouseLeave={this.resume(id)}\n role=\"listitem\"\n >\n <IconContainer type={type} aria-hidden=\"true\">\n {type === NOTIFICATION_TYPE.INFO && <Info />}\n {type === NOTIFICATION_TYPE.SUCCESS && <CheckCircle />}\n {type === NOTIFICATION_TYPE.WARNING && <ReportProblem />}\n {type === NOTIFICATION_TYPE.DANGER && <ErrorOutline />}\n </IconContainer>\n <FillParent>\n <Title type={type}>{title}</Title>\n <Body>{description}</Body>\n {buttonText && (\n <Footer>\n <ActionButton\n onClick={() => {\n buttonClick?.();\n }}\n >\n {buttonText}\n </ActionButton>\n </Footer>\n )}\n </FillParent>\n <CloseButton\n onClick={this.closeClickHandler(id)}\n aria-label={closeButtonAriaLabel || 'Close notification'}\n tabIndex={0}\n >\n <Close />\n </CloseButton>\n </Notice>\n );\n })}\n </div>\n </Container>\n );\n }\n}\n\nexport default NotificationManager;\n"],"names":["DEFAULT_DURATION","NotificationManager","React","Component","componentWillUnmount","Object","keys","timeouts","forEach","id","clearTimeout","set","clear","render","_jsxs","Container","position","props","_jsx","VisuallyHidden","ref","politeRegionRef","role","aria-live","aria-atomic","aria-relevant","assertiveRegionRef","div","aria-label","ariaLabel","state","notices","map","notice","title","description","leaving","type","NOTIFICATION_TYPE","INFO","buttonText","buttonClick","closeButtonAriaLabel","Notice","className","onMouseEnter","pause","onMouseLeave","resume","IconContainer","aria-hidden","Info","SUCCESS","CheckCircle","WARNING","ReportProblem","DANGER","ErrorOutline","FillParent","Title","Body","Footer","ActionButton","onClick","CloseButton","closeClickHandler","tabIndex","Close","Set","createRef","remove","setState","delete","setTimeout","find","onClose","e","console","warn","message","filter","length","onEmpty","add","Math","random","toFixed","has","isUrgent","prevState","announcement","updateLiveRegion","sticky","duration","content","isAssertive","region","current","textContent"],"mappings":";;;;;;;;;;;AAuCA,MAAMA,kBAAAA,GAAmB,IAAA;AAEzB;;IAGA,MAAMC,mBAAAA,SAA4BC,KAAAA,CAAMC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AA;YAChB,CAAA;;;;QAMC,IAAA,CACMqC,KAAAA,GAAQ,CAACrC,EAAAA,GAAgB,IAAA;AAC5B,gBAAA,IAAIA,MAAM,IAAI,CAACF,QAAQ,CAACE,GAAG,EAAE;AACzBC,oBAAAA,YAAAA,CAAa,IAAI,CAACH,QAAQ,CAACE,EAAAA,CAAG,CAAA;AAC9B,oBAAA,OAAO,IAAI,CAACF,QAAQ,CAACE,EAAAA,CAAG;AAC5B,gBAAA;YACJ,CAAA;;;;QAMC,IAAA,CACMuC,MAAAA,GAAS,CAACvC,EAAAA,GAAgB,IAAA;AAC7B,gBAAA,MAAMwB,MAAAA,GAAS,IAAI,CAACH,KAAK,CAACC,OAAO,CAAC2C,IAAI,CAAC,CAACzC,MAAAA,GAAWA,MAAAA,CAAOxB,EAAE,KAAKA,EAAAA,CAAAA;gBACjE,IAAI,CAACwB,MAAAA,EAAQ2D,MAAAA,IAAUnF,EAAAA,IAAM,CAAC,IAAI,CAACF,QAAQ,CAACE,EAAAA,CAAG,EAAE;oBAC7C,IAAI,CAACF,QAAQ,CAACE,EAAAA,CAAG,GAAGgE,UAAAA,CAAW,IAAM,IAAI,CAACH,MAAM,CAAC7D,EAAAA,CAAAA,EAAKT,kBAAAA,CAAAA;AAC1D,gBAAA;AACJ,YAAA,CAAA;;AA6FJ;;;;"}
|
|
@@ -9,9 +9,8 @@ export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
|
9
9
|
position: NOTIFICATION_POSITION;
|
|
10
10
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
11
11
|
export declare const Notice: import("@emotion/styled").StyledComponent<{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} & import("../Card/Card").CardExtraProps & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
12
|
+
elevated?: boolean;
|
|
13
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement> & {
|
|
15
14
|
theme?: import("@emotion/react").Theme;
|
|
16
15
|
} & NoticeProp, {}, {}>;
|
|
17
16
|
export declare const Title: import("@emotion/styled").StyledComponent<{
|
|
@@ -57,42 +57,42 @@ const getTypeStyle = (type)=>{
|
|
|
57
57
|
return `color: ${getThemeValue(THEME_NAME.WARNING)}`;
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
const Container = /*#__PURE__*/ styled("div", {
|
|
61
|
-
target: "
|
|
60
|
+
const Container$2 = /*#__PURE__*/ styled("div", {
|
|
61
|
+
target: "e10n1sw0",
|
|
62
62
|
label: "Container"
|
|
63
63
|
})("display:flex;flex-direction:", (props)=>props.position === NOTIFICATION_POSITION.TOP_LEFT || props.position === NOTIFICATION_POSITION.TOP_RIGHT ? 'column' : 'column-reverse', ";");
|
|
64
64
|
const Notice = /*#__PURE__*/ styled(Card, {
|
|
65
|
-
target: "
|
|
65
|
+
target: "e10n1sw1",
|
|
66
66
|
label: "Notice"
|
|
67
67
|
})("position:relative;border-radius:3px;border-left:4px solid ", (props)=>getBorderColor(props.type), ";width:300px;display:flex;padding:0 5px 5px 0;overflow:hidden;animation:", (props)=>getEntryAnimation(props.position), " 0.6s ease;& svg{fill:currentColor;vertical-align:middle;width:20px;height:20px;}&.leave{animation:", (props)=>getExitAnimation(props.position), " 0.6s;}@keyframes in-right{from{transform:translateX(100%);max-height:0;opacity:0;}to{transform:translateX(0%);max-height:150px;opacity:1;}}@keyframes out-right{to{transform:translateX(100%);max-height:0;opacity:0;}from{transform:translateX(0%);max-height:100px;opacity:1;}}@keyframes in-left{from{transform:translateX(-100%);max-height:0;opacity:0;}to{transform:translateX(0%);max-height:150px;opacity:1;}}@keyframes out-left{to{transform:translateX(-100%);max-height:0;opacity:0;}from{transform:translateX(0%);max-height:100px;opacity:1;}}");
|
|
68
68
|
const Title = /*#__PURE__*/ styled("div", {
|
|
69
|
-
target: "
|
|
69
|
+
target: "e10n1sw2",
|
|
70
70
|
label: "Title"
|
|
71
71
|
})("padding:5px 0;font-size:14px;color:", (props)=>getTitleColor(props.type), ";display:flex;align-items:center;");
|
|
72
72
|
const FillParent = /*#__PURE__*/ styled("div", {
|
|
73
|
-
target: "
|
|
73
|
+
target: "e10n1sw3",
|
|
74
74
|
label: "FillParent"
|
|
75
75
|
})("flex:1;");
|
|
76
76
|
const CloseButton = /*#__PURE__*/ styled("button", {
|
|
77
|
-
target: "
|
|
77
|
+
target: "e10n1sw4",
|
|
78
78
|
label: "CloseButton"
|
|
79
79
|
})("position:absolute;background-color:transparent;border:none;padding:0;top:4px;right:4px;cursor:pointer;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:focus{box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";border-radius:3px;}");
|
|
80
80
|
const Body = /*#__PURE__*/ styled("div", {
|
|
81
|
-
target: "
|
|
81
|
+
target: "e10n1sw5",
|
|
82
82
|
label: "Body"
|
|
83
83
|
})("padding:5px 5px 5px 0;font-size:14px;");
|
|
84
84
|
const IconContainer = /*#__PURE__*/ styled("div", {
|
|
85
|
-
target: "
|
|
85
|
+
target: "e10n1sw6",
|
|
86
86
|
label: "IconContainer"
|
|
87
87
|
})("padding:6px 10px;", (props)=>getTypeStyle(props.type), ";");
|
|
88
88
|
const Footer = /*#__PURE__*/ styled("div", {
|
|
89
|
-
target: "
|
|
89
|
+
target: "e10n1sw7",
|
|
90
90
|
label: "Footer"
|
|
91
91
|
})("display:flex;justify-content:flex-end;padding:0 5px;");
|
|
92
92
|
const VisuallyHidden = /*#__PURE__*/ styled("span", {
|
|
93
|
-
target: "
|
|
93
|
+
target: "e10n1sw8",
|
|
94
94
|
label: "VisuallyHidden"
|
|
95
95
|
})("position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;");
|
|
96
96
|
|
|
97
|
-
export { Body, CloseButton, Container, FillParent, Footer, IconContainer, Notice, Title, VisuallyHidden };
|
|
97
|
+
export { Body, CloseButton, Container$2 as Container, FillParent, Footer, IconContainer, Notice, Title, VisuallyHidden };
|
|
98
98
|
//# sourceMappingURL=style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/Notification/style.ts"],"sourcesContent":["import styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { Card } from '../Card';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\nconst getEntryAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'in-left';\n default:\n return 'in-right';\n }\n};\n\nconst getExitAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'out-left';\n default:\n return 'out-right';\n }\n};\n\nconst getBorderColor = (type
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/Notification/style.ts"],"sourcesContent":["import styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { Card } from '../Card';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\nconst getEntryAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'in-left';\n default:\n return 'in-right';\n }\n};\n\nconst getExitAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'out-left';\n default:\n return 'out-right';\n }\n};\n\nconst getBorderColor = (type?: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.SUCCESS:\n return getThemeValue(THEME_NAME.SUCCESS_LIGHT);\n case NOTIFICATION_TYPE.DANGER:\n return getThemeValue(THEME_NAME.ERROR_LIGHT);\n case NOTIFICATION_TYPE.WARNING:\n return getThemeValue(THEME_NAME.WARNING_LIGHT);\n default:\n return getThemeValue(THEME_NAME.INFO_LIGHT);\n }\n};\n\nconst getTitleColor = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.SUCCESS:\n return getThemeValue(THEME_NAME.SUCCESS);\n case NOTIFICATION_TYPE.DANGER:\n return getThemeValue(THEME_NAME.ERROR);\n case NOTIFICATION_TYPE.WARNING:\n return getThemeValue(THEME_NAME.WARNING);\n case NOTIFICATION_TYPE.INFO:\n return getThemeValue(THEME_NAME.INFO);\n }\n};\n\nconst getTypeStyle = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.INFO:\n return `color: ${getThemeValue(THEME_NAME.INFO)}`;\n case NOTIFICATION_TYPE.SUCCESS:\n return `color: ${getThemeValue(THEME_NAME.SUCCESS)}`;\n case NOTIFICATION_TYPE.DANGER:\n return `color: ${getThemeValue(THEME_NAME.ERROR)}`;\n case NOTIFICATION_TYPE.WARNING:\n return `color: ${getThemeValue(THEME_NAME.WARNING)}`;\n }\n};\n\ninterface NoticeProp extends NotificationOptions {\n position: NOTIFICATION_POSITION;\n}\n\nexport const Container = styled.div<{ position: NOTIFICATION_POSITION }>`\n display: flex;\n flex-direction: ${(props) =>\n props.position === NOTIFICATION_POSITION.TOP_LEFT ||\n props.position === NOTIFICATION_POSITION.TOP_RIGHT\n ? 'column'\n : 'column-reverse'};\n`;\n\nexport const Notice = styled(Card)<NoticeProp>`\n position: relative;\n border-radius: 3px;\n border-left: 4px solid ${(props) => getBorderColor(props.type)};\n width: 300px;\n display: flex;\n padding: 0 5px 5px 0;\n overflow: hidden;\n animation: ${(props) => getEntryAnimation(props.position)} 0.6s ease;\n\n & svg {\n fill: currentColor;\n vertical-align: middle;\n width: 20px;\n height: 20px;\n }\n\n &.leave {\n animation: ${(props) => getExitAnimation(props.position)} 0.6s;\n }\n\n @keyframes in-right {\n from {\n transform: translateX(100%);\n max-height: 0;\n opacity: 0;\n }\n\n to {\n transform: translateX(0%);\n max-height: 150px;\n opacity: 1;\n }\n }\n\n @keyframes out-right {\n to {\n transform: translateX(100%);\n max-height: 0;\n opacity: 0;\n }\n\n from {\n transform: translateX(0%);\n max-height: 100px;\n opacity: 1;\n }\n }\n\n @keyframes in-left {\n from {\n transform: translateX(-100%);\n max-height: 0;\n opacity: 0;\n }\n\n to {\n transform: translateX(0%);\n max-height: 150px;\n opacity: 1;\n }\n }\n\n @keyframes out-left {\n to {\n transform: translateX(-100%);\n max-height: 0;\n opacity: 0;\n }\n\n from {\n transform: translateX(0%);\n max-height: 100px;\n opacity: 1;\n }\n }\n`;\n\nexport const Title = styled.div<{ type: NOTIFICATION_TYPE }>`\n padding: 5px 0;\n font-size: 14px;\n color: ${(props) => getTitleColor(props.type)};\n display: flex;\n align-items: center;\n`;\n\nexport const FillParent = styled.div`\n flex: 1;\n`;\n\nexport const CloseButton = styled.button`\n position: absolute;\n background-color: transparent;\n border: none;\n padding: 0;\n top: 4px;\n right: 4px;\n cursor: pointer;\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};\n\n &:focus {\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n border-radius: 3px;\n }\n`;\n\nexport const Body = styled.div`\n padding: 5px 5px 5px 0;\n font-size: 14px;\n`;\n\nexport const IconContainer = styled.div<{ type: NOTIFICATION_TYPE }>`\n padding: 6px 10px;\n ${(props) => getTypeStyle(props.type)};\n`;\n\nexport const Footer = styled.div`\n display: flex;\n justify-content: flex-end;\n padding: 0 5px;\n`;\n\nexport const VisuallyHidden = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n`;\n"],"names":["getEntryAnimation","position","NOTIFICATION_POSITION","TOP_LEFT","BOTTOM_LEFT","getExitAnimation","getBorderColor","type","NOTIFICATION_TYPE","SUCCESS","getThemeValue","THEME_NAME","SUCCESS_LIGHT","DANGER","ERROR_LIGHT","WARNING","WARNING_LIGHT","INFO_LIGHT","getTitleColor","ERROR","INFO","getTypeStyle","Container","styled","props","TOP_RIGHT","Notice","Card","Title","FillParent","CloseButton","TEXT_COLOR_DARK","PRIMARY_LIGHT","Body","IconContainer","Footer","VisuallyHidden"],"mappings":";;;;;AAKA,MAAMA,oBAAoB,CAACC,QAAAA,GAAAA;IACvB,OAAQA,QAAAA;AACJ,QAAA,KAAKC,sBAAsBC,QAAQ;AACnC,QAAA,KAAKD,sBAAsBE,WAAW;YAClC,OAAO,SAAA;AACX,QAAA;YACI,OAAO,UAAA;AACf;AACJ,CAAA;AAEA,MAAMC,mBAAmB,CAACJ,QAAAA,GAAAA;IACtB,OAAQA,QAAAA;AACJ,QAAA,KAAKC,sBAAsBC,QAAQ;AACnC,QAAA,KAAKD,sBAAsBE,WAAW;YAClC,OAAO,UAAA;AACX,QAAA;YACI,OAAO,WAAA;AACf;AACJ,CAAA;AAEA,MAAME,iBAAiB,CAACC,IAAAA,GAAAA;IACpB,OAAQA,IAAAA;AACJ,QAAA,KAAKC,kBAAkBC,OAAO;YAC1B,OAAOC,aAAAA,CAAcC,WAAWC,aAAa,CAAA;AACjD,QAAA,KAAKJ,kBAAkBK,MAAM;YACzB,OAAOH,aAAAA,CAAcC,WAAWG,WAAW,CAAA;AAC/C,QAAA,KAAKN,kBAAkBO,OAAO;YAC1B,OAAOL,aAAAA,CAAcC,WAAWK,aAAa,CAAA;AACjD,QAAA;YACI,OAAON,aAAAA,CAAcC,WAAWM,UAAU,CAAA;AAClD;AACJ,CAAA;AAEA,MAAMC,gBAAgB,CAACX,IAAAA,GAAAA;IACnB,OAAQA,IAAAA;AACJ,QAAA,KAAKC,kBAAkBC,OAAO;YAC1B,OAAOC,aAAAA,CA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_POSITION {
|
|
4
3
|
TOP_LEFT = "TOP_LEFT",
|
|
5
4
|
TOP_RIGHT = "TOP_RIGHT",
|
|
6
5
|
BOTTOM_LEFT = "BOTTOM_LEFT",
|
|
7
6
|
BOTTOM_RIGHT = "BOTTOM_RIGHT"
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
type PopoverProps = {
|
|
9
|
+
/** Opens the popover */
|
|
10
|
+
open: boolean;
|
|
11
|
+
/** Anchor element for the popover */
|
|
12
|
+
element: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* Position of the popover around anchor element
|
|
15
|
+
* @default POPOVER_POSITION.BOTTOM_LEFT
|
|
16
|
+
*/
|
|
17
|
+
position?: POPOVER_POSITION;
|
|
18
|
+
/**
|
|
19
|
+
* If the popover should close on `esc` key press
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
closeOnEsc?: boolean;
|
|
23
|
+
/** Popover close callback */
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
};
|
|
26
|
+
declare const Popover: React.ForwardRefExoticComponent<PopoverProps & {
|
|
27
|
+
children?: React.ReactNode | undefined;
|
|
28
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
28
29
|
export default Popover;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React, { useState, useRef, useId, useCallback, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import Card from '../Card/Card.js';
|
|
6
5
|
|
|
@@ -11,7 +10,7 @@ var POPOVER_POSITION = /*#__PURE__*/ function(POPOVER_POSITION) {
|
|
|
11
10
|
POPOVER_POSITION["BOTTOM_RIGHT"] = "BOTTOM_RIGHT";
|
|
12
11
|
return POPOVER_POSITION;
|
|
13
12
|
}({});
|
|
14
|
-
const positionMap = {
|
|
13
|
+
const positionMap$2 = {
|
|
15
14
|
["TOP_LEFT"]: `
|
|
16
15
|
bottom: calc(100% - 10px);
|
|
17
16
|
left: 0;
|
|
@@ -30,25 +29,30 @@ const positionMap = {
|
|
|
30
29
|
`
|
|
31
30
|
};
|
|
32
31
|
const PopoverDiv = /*#__PURE__*/ styled("div", {
|
|
33
|
-
target: "
|
|
32
|
+
target: "ejcb1ps0",
|
|
34
33
|
label: "PopoverDiv"
|
|
35
34
|
})("position:relative;display:inline-flex;");
|
|
36
35
|
const Popper = /*#__PURE__*/ styled(Card, {
|
|
37
|
-
target: "
|
|
36
|
+
target: "ejcb1ps1",
|
|
38
37
|
label: "Popper"
|
|
39
|
-
})("position:absolute;width:100%;min-width:200px;overflow:auto;animation:enter 0.3s linear;border-radius:3px;z-index:1;transform:translate(", (props)=>props.translateX, "px,", (props)=>props.translateY, "px);", (props)=>positionMap[props.position], " &.closing{animation:exit 0.3s linear;}@keyframes enter{from{max-height:0px;opacity:1;overflow:hidden;}to{max-height:300px;opacity:1;overflow:hidden;}}@keyframes exit{to{max-height:0px;opacity:1;overflow:hidden;}from{max-height:300px;opacity:1;overflow:hidden;}}");
|
|
38
|
+
})("position:absolute;width:100%;min-width:200px;overflow:auto;animation:enter 0.3s linear;border-radius:3px;z-index:1;transform:translate(", (props)=>props.translateX, "px,", (props)=>props.translateY, "px);", (props)=>positionMap$2[props.position], " &.closing{animation:exit 0.3s linear;}@keyframes enter{from{max-height:0px;opacity:1;overflow:hidden;}to{max-height:300px;opacity:1;overflow:hidden;}}@keyframes exit{to{max-height:0px;opacity:1;overflow:hidden;}from{max-height:300px;opacity:1;overflow:hidden;}}");
|
|
40
39
|
const KEY_CODES = {
|
|
41
40
|
ESC: 27
|
|
42
41
|
};
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Popover Component
|
|
44
|
+
* @param props - Component props
|
|
45
|
+
* @param ref - Ref forwarded to the underlying HTMLDivElement
|
|
46
|
+
*/ function PopoverComponent(props, ref) {
|
|
47
|
+
const { open: propsOpen, element, position = "BOTTOM_LEFT", closeOnEsc = true, onClose, children, ...rest } = props;
|
|
48
|
+
const [open, setOpen] = useState(propsOpen);
|
|
45
49
|
const [closing, setClosing] = useState(false);
|
|
46
50
|
const [translate, setTranslate] = useState({
|
|
47
51
|
x: 0,
|
|
48
52
|
y: 0
|
|
49
53
|
});
|
|
50
|
-
const popperRef = useRef();
|
|
51
|
-
const containerRef = useRef();
|
|
54
|
+
const popperRef = useRef(null);
|
|
55
|
+
const containerRef = useRef(null);
|
|
52
56
|
const triggerRef = useRef(null);
|
|
53
57
|
const closeTimeoutRef = useRef(null);
|
|
54
58
|
const focusTimeoutRef = useRef(null);
|
|
@@ -69,8 +73,8 @@ function Popover(props) {
|
|
|
69
73
|
x: 0,
|
|
70
74
|
y: 0
|
|
71
75
|
});
|
|
72
|
-
if (
|
|
73
|
-
|
|
76
|
+
if (onClose) {
|
|
77
|
+
onClose();
|
|
74
78
|
}
|
|
75
79
|
setClosing(false);
|
|
76
80
|
// Restore focus to the trigger element after animation completes
|
|
@@ -83,15 +87,15 @@ function Popover(props) {
|
|
|
83
87
|
closeTimeoutRef.current = null;
|
|
84
88
|
}, 280);
|
|
85
89
|
}, [
|
|
86
|
-
|
|
90
|
+
onClose
|
|
87
91
|
]);
|
|
88
92
|
const keyupEventHandler = useCallback((e)=>{
|
|
89
|
-
if (
|
|
93
|
+
if (closeOnEsc && e.keyCode === KEY_CODES.ESC) {
|
|
90
94
|
close();
|
|
91
95
|
}
|
|
92
96
|
}, [
|
|
93
97
|
close,
|
|
94
|
-
|
|
98
|
+
closeOnEsc
|
|
95
99
|
]);
|
|
96
100
|
const clickOutsideHandler = useCallback((e)=>{
|
|
97
101
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -111,7 +115,7 @@ function Popover(props) {
|
|
|
111
115
|
keyupEventHandler
|
|
112
116
|
]);
|
|
113
117
|
useEffect(()=>{
|
|
114
|
-
if (
|
|
118
|
+
if (propsOpen) {
|
|
115
119
|
setOpen(true);
|
|
116
120
|
// Use requestAnimationFrame to add listener after current event loop
|
|
117
121
|
const rafId = requestAnimationFrame(()=>{
|
|
@@ -127,22 +131,22 @@ function Popover(props) {
|
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
}, [
|
|
130
|
-
|
|
134
|
+
propsOpen,
|
|
131
135
|
open,
|
|
132
136
|
clickOutsideHandler,
|
|
133
137
|
close
|
|
134
138
|
]);
|
|
135
139
|
useEffect(()=>{
|
|
136
140
|
if (open) {
|
|
137
|
-
const { top, left, right } = popperRef.current
|
|
138
|
-
const height = popperRef.current
|
|
141
|
+
const { top = 0, left = 0, right = 0 } = popperRef.current?.getBoundingClientRect() ?? {};
|
|
142
|
+
const height = popperRef.current?.scrollHeight ?? 0;
|
|
139
143
|
const viewportWidth = document.documentElement.clientWidth;
|
|
140
144
|
const viewportHeight = document.documentElement.clientHeight;
|
|
141
145
|
const translation = {
|
|
142
146
|
x: 0,
|
|
143
147
|
y: 0
|
|
144
148
|
};
|
|
145
|
-
if (
|
|
149
|
+
if (position === "BOTTOM_LEFT") {
|
|
146
150
|
// overflow can happen at bottom and right
|
|
147
151
|
if (viewportHeight - top - height < 0) {
|
|
148
152
|
translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);
|
|
@@ -150,7 +154,7 @@ function Popover(props) {
|
|
|
150
154
|
if (viewportWidth - right < 0) {
|
|
151
155
|
translation.x = -1 * (Math.abs(viewportWidth - right) + 5);
|
|
152
156
|
}
|
|
153
|
-
} else if (
|
|
157
|
+
} else if (position == "BOTTOM_RIGHT") {
|
|
154
158
|
// overflow can happen at bottom and left
|
|
155
159
|
if (viewportHeight - top - height < 0) {
|
|
156
160
|
translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);
|
|
@@ -158,7 +162,7 @@ function Popover(props) {
|
|
|
158
162
|
if (left < 0) {
|
|
159
163
|
translation.x = Math.abs(left) + 5;
|
|
160
164
|
}
|
|
161
|
-
} else if (
|
|
165
|
+
} else if (position === "TOP_LEFT") {
|
|
162
166
|
// overflow can happen at top and right
|
|
163
167
|
if (top - height < 0) {
|
|
164
168
|
translation.y = Math.abs(top - height) + 5;
|
|
@@ -178,11 +182,11 @@ function Popover(props) {
|
|
|
178
182
|
// Note it can still overflow, but in that case fitting popper inside the
|
|
179
183
|
// window is not possible.
|
|
180
184
|
setTranslate(translation);
|
|
181
|
-
popperRef.current
|
|
185
|
+
popperRef.current?.focus();
|
|
182
186
|
}
|
|
183
187
|
}, [
|
|
184
188
|
open,
|
|
185
|
-
|
|
189
|
+
position
|
|
186
190
|
]);
|
|
187
191
|
/**
|
|
188
192
|
* Cleanup timeouts on unmount
|
|
@@ -196,10 +200,19 @@ function Popover(props) {
|
|
|
196
200
|
}
|
|
197
201
|
};
|
|
198
202
|
}, []);
|
|
203
|
+
const forwardRef = (node)=>{
|
|
204
|
+
containerRef.current = node;
|
|
205
|
+
if (typeof ref === 'function') {
|
|
206
|
+
ref(node);
|
|
207
|
+
} else if (ref) {
|
|
208
|
+
ref.current = node;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
199
211
|
return /*#__PURE__*/ jsxs(PopoverDiv, {
|
|
200
|
-
ref:
|
|
212
|
+
ref: forwardRef,
|
|
213
|
+
...rest,
|
|
201
214
|
children: [
|
|
202
|
-
/*#__PURE__*/ React.createElement(
|
|
215
|
+
/*#__PURE__*/ React.createElement(element, {
|
|
203
216
|
ref: triggerRef,
|
|
204
217
|
id: triggerId,
|
|
205
218
|
'aria-expanded': open,
|
|
@@ -212,36 +225,21 @@ function Popover(props) {
|
|
|
212
225
|
role: "dialog",
|
|
213
226
|
"aria-labelledby": triggerId,
|
|
214
227
|
id: popperId,
|
|
215
|
-
position:
|
|
228
|
+
position: position,
|
|
216
229
|
translateX: translate.x,
|
|
217
230
|
translateY: translate.y,
|
|
218
|
-
className: closing
|
|
231
|
+
className: closing ? 'closing' : '',
|
|
219
232
|
ref: popperRef,
|
|
220
233
|
onClick: (e)=>{
|
|
221
234
|
e.stopPropagation();
|
|
222
235
|
e.nativeEvent.stopImmediatePropagation();
|
|
223
236
|
},
|
|
224
|
-
children:
|
|
237
|
+
children: children
|
|
225
238
|
})
|
|
226
239
|
]
|
|
227
240
|
});
|
|
228
241
|
}
|
|
229
|
-
Popover
|
|
230
|
-
/** Opens the popover */ open: PropTypes.bool.isRequired,
|
|
231
|
-
/** Anchor element for the popover */ element: PropTypes.func,
|
|
232
|
-
/** Position of the popover around anchor element */ position: PropTypes.oneOf([
|
|
233
|
-
"TOP_LEFT",
|
|
234
|
-
"TOP_RIGHT",
|
|
235
|
-
"BOTTOM_LEFT",
|
|
236
|
-
"BOTTOM_RIGHT"
|
|
237
|
-
]),
|
|
238
|
-
/** If the popover should close on `esc` key press */ closeOnEsc: PropTypes.bool,
|
|
239
|
-
/** Popover close callback */ onClose: PropTypes.func
|
|
240
|
-
};
|
|
241
|
-
Popover.defaultProps = {
|
|
242
|
-
closeOnEsc: true,
|
|
243
|
-
position: "BOTTOM_LEFT"
|
|
244
|
-
};
|
|
242
|
+
const Popover = /*#__PURE__*/ React.forwardRef(PopoverComponent);
|
|
245
243
|
|
|
246
244
|
export { POPOVER_POSITION, Popover as default };
|
|
247
245
|
//# sourceMappingURL=Popover.js.map
|