no-frills-ui 0.0.14-alpha.2 → 0.0.14-alpha.4
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 +411 -120
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +1 -0
- package/lib-esm/components/Accordion/Accordion.d.ts.map +1 -0
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts +1 -0
- package/lib-esm/components/Accordion/AccordionStep.d.ts.map +1 -0
- package/lib-esm/components/Accordion/AccordionStep.js +18 -11
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Accordion/index.d.ts +1 -0
- package/lib-esm/components/Accordion/index.d.ts.map +1 -0
- package/lib-esm/components/Accordion/index.js.map +1 -1
- package/lib-esm/components/Badge/Badge.d.ts +1 -0
- package/lib-esm/components/Badge/Badge.d.ts.map +1 -0
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Badge/index.d.ts +1 -0
- package/lib-esm/components/Badge/index.d.ts.map +1 -0
- package/lib-esm/components/Badge/index.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts +1 -0
- package/lib-esm/components/Button/ActionButton.d.ts.map +1 -0
- package/lib-esm/components/Button/ActionButton.js +2 -2
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +3 -2
- package/lib-esm/components/Button/Button.d.ts.map +1 -0
- package/lib-esm/components/Button/Button.js +6 -2
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts +1 -0
- package/lib-esm/components/Button/IconButton.d.ts.map +1 -0
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts +1 -0
- package/lib-esm/components/Button/LinkButton.d.ts.map +1 -0
- package/lib-esm/components/Button/LinkButton.js +1 -1
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts +1 -0
- package/lib-esm/components/Button/RaisedButton.d.ts.map +1 -0
- package/lib-esm/components/Button/RaisedButton.js +1 -1
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Button/index.d.ts +1 -0
- package/lib-esm/components/Button/index.d.ts.map +1 -0
- package/lib-esm/components/Button/index.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts +1 -0
- package/lib-esm/components/Card/Card.d.ts.map +1 -0
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Card/index.d.ts +1 -0
- package/lib-esm/components/Card/index.d.ts.map +1 -0
- package/lib-esm/components/Card/index.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +6 -2
- package/lib-esm/components/Chip/Chip.d.ts.map +1 -0
- package/lib-esm/components/Chip/Chip.js +14 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/Chip/index.d.ts +1 -0
- package/lib-esm/components/Chip/index.d.ts.map +1 -0
- package/lib-esm/components/Chip/index.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +10 -0
- package/lib-esm/components/ChipInput/ChipInput.d.ts.map +1 -0
- package/lib-esm/components/ChipInput/ChipInput.js +43 -4
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/ChipInput/index.d.ts +1 -0
- package/lib-esm/components/ChipInput/index.d.ts.map +1 -0
- package/lib-esm/components/ChipInput/index.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +1 -0
- package/lib-esm/components/Dialog/AlertDialog.d.ts.map +1 -0
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +1 -0
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts.map +1 -0
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +9 -4
- package/lib-esm/components/Dialog/Dialog.d.ts.map +1 -0
- package/lib-esm/components/Dialog/Dialog.js +17 -13
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts +1 -0
- package/lib-esm/components/Dialog/PromptDialog.d.ts.map +1 -0
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/Dialog/index.d.ts +1 -0
- package/lib-esm/components/Dialog/index.d.ts.map +1 -0
- package/lib-esm/components/Dialog/index.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +25 -0
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts.map +1 -0
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +85 -3
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +5 -0
- package/lib-esm/components/DragAndDrop/DragItem.d.ts.map +1 -0
- package/lib-esm/components/DragAndDrop/DragItem.js +86 -6
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/index.d.ts +1 -0
- package/lib-esm/components/DragAndDrop/index.d.ts.map +1 -0
- package/lib-esm/components/DragAndDrop/index.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +20 -0
- package/lib-esm/components/DragAndDrop/types.d.ts.map +1 -0
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +1 -0
- package/lib-esm/components/Drawer/Drawer.d.ts.map +1 -0
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Drawer/index.d.ts +1 -0
- package/lib-esm/components/Drawer/index.d.ts.map +1 -0
- package/lib-esm/components/Drawer/index.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts +1 -0
- package/lib-esm/components/Groups/Group.d.ts.map +1 -0
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.d.ts +1 -0
- package/lib-esm/components/Groups/GroupLabel.d.ts.map +1 -0
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Groups/index.d.ts +1 -0
- package/lib-esm/components/Groups/index.d.ts.map +1 -0
- package/lib-esm/components/Groups/index.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +1 -0
- package/lib-esm/components/Input/Checkbox.d.ts.map +1 -0
- package/lib-esm/components/Input/Checkbox.js +1 -1
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +1 -0
- package/lib-esm/components/Input/Dropdown.d.ts.map +1 -0
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +1 -0
- package/lib-esm/components/Input/Input.d.ts.map +1 -0
- package/lib-esm/components/Input/Input.js +0 -1
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +1 -0
- package/lib-esm/components/Input/Radio.d.ts.map +1 -0
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +1 -0
- package/lib-esm/components/Input/RadioButton.d.ts.map +1 -0
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts +1 -0
- package/lib-esm/components/Input/Select.d.ts.map +1 -0
- package/lib-esm/components/Input/Select.js +0 -1
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts +1 -0
- package/lib-esm/components/Input/TextArea.d.ts.map +1 -0
- package/lib-esm/components/Input/TextArea.js +0 -1
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +1 -0
- package/lib-esm/components/Input/Toggle.d.ts.map +1 -0
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Input/index.d.ts +1 -0
- package/lib-esm/components/Input/index.d.ts.map +1 -0
- package/lib-esm/components/Input/index.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +1 -0
- package/lib-esm/components/Menu/Menu.d.ts.map +1 -0
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +1 -0
- package/lib-esm/components/Menu/MenuContext.d.ts.map +1 -0
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +1 -0
- package/lib-esm/components/Menu/MenuItem.d.ts.map +1 -0
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Menu/index.d.ts +1 -0
- package/lib-esm/components/Menu/index.d.ts.map +1 -0
- package/lib-esm/components/Menu/index.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +1 -0
- package/lib-esm/components/Modal/Modal.d.ts.map +1 -0
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Modal/index.d.ts +1 -0
- package/lib-esm/components/Modal/index.d.ts.map +1 -0
- package/lib-esm/components/Modal/index.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +10 -7
- package/lib-esm/components/Notification/Notification.d.ts.map +1 -0
- package/lib-esm/components/Notification/Notification.js +51 -24
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +1 -0
- package/lib-esm/components/Notification/NotificationManager.d.ts.map +1 -0
- 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/index.d.ts.map +1 -0
- package/lib-esm/components/Notification/index.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +1 -0
- package/lib-esm/components/Notification/style.d.ts.map +1 -0
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Notification/types.d.ts +1 -0
- package/lib-esm/components/Notification/types.d.ts.map +1 -0
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +1 -0
- package/lib-esm/components/Popover/Popover.d.ts.map +1 -0
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Popover/index.d.ts +1 -0
- package/lib-esm/components/Popover/index.d.ts.map +1 -0
- package/lib-esm/components/Popover/index.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +1 -0
- package/lib-esm/components/Spinner/Spinner.d.ts.map +1 -0
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Spinner/index.d.ts +1 -0
- package/lib-esm/components/Spinner/index.d.ts.map +1 -0
- package/lib-esm/components/Spinner/index.js.map +1 -1
- package/lib-esm/components/Stepper/Step.d.ts +1 -0
- package/lib-esm/components/Stepper/Step.d.ts.map +1 -0
- package/lib-esm/components/Stepper/Step.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts +1 -0
- package/lib-esm/components/Stepper/Stepper.d.ts.map +1 -0
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Stepper/index.d.ts +1 -0
- package/lib-esm/components/Stepper/index.d.ts.map +1 -0
- package/lib-esm/components/Stepper/index.js.map +1 -1
- package/lib-esm/components/Tabs/Tab.d.ts +1 -0
- package/lib-esm/components/Tabs/Tab.d.ts.map +1 -0
- package/lib-esm/components/Tabs/Tab.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts +1 -0
- package/lib-esm/components/Tabs/Tabs.d.ts.map +1 -0
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Tabs/index.d.ts +1 -0
- package/lib-esm/components/Tabs/index.d.ts.map +1 -0
- package/lib-esm/components/Tabs/index.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +1 -0
- package/lib-esm/components/Toast/Toast.d.ts.map +1 -0
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Toast/ToastStory.d.ts +1 -0
- package/lib-esm/components/Toast/ToastStory.d.ts.map +1 -0
- package/lib-esm/components/Toast/ToastStory.js.map +1 -1
- package/lib-esm/components/Toast/index.d.ts +1 -0
- package/lib-esm/components/Toast/index.d.ts.map +1 -0
- package/lib-esm/components/Toast/index.js.map +1 -1
- package/lib-esm/components/Tooltip/Tooltip.d.ts +1 -0
- package/lib-esm/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/components/Tooltip/index.d.ts +1 -0
- package/lib-esm/components/Tooltip/index.d.ts.map +1 -0
- package/lib-esm/components/Tooltip/index.js.map +1 -1
- package/lib-esm/components/index.d.ts +1 -0
- package/lib-esm/components/index.d.ts.map +1 -0
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/icons/CheckCircle.d.ts +1 -0
- package/lib-esm/icons/CheckCircle.d.ts.map +1 -0
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/Close.d.ts +1 -0
- package/lib-esm/icons/Close.d.ts.map +1 -0
- package/lib-esm/icons/Close.js.map +1 -1
- package/lib-esm/icons/DragIndicator.d.ts +1 -0
- package/lib-esm/icons/DragIndicator.d.ts.map +1 -0
- package/lib-esm/icons/DragIndicator.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.d.ts +1 -0
- package/lib-esm/icons/ErrorOutline.d.ts.map +1 -0
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/ExpandMore.d.ts +1 -0
- package/lib-esm/icons/ExpandMore.d.ts.map +1 -0
- package/lib-esm/icons/ExpandMore.js.map +1 -1
- package/lib-esm/icons/FiberManualRecord.d.ts +1 -0
- package/lib-esm/icons/FiberManualRecord.d.ts.map +1 -0
- package/lib-esm/icons/FiberManualRecord.js.map +1 -1
- package/lib-esm/icons/Info.d.ts +1 -0
- package/lib-esm/icons/Info.d.ts.map +1 -0
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.d.ts +1 -0
- package/lib-esm/icons/ReportProblem.d.ts.map +1 -0
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/icons/index.d.ts +1 -0
- package/lib-esm/icons/index.d.ts.map +1 -0
- package/lib-esm/icons/index.js.map +1 -1
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.d.ts.map +1 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts +28 -1
- package/lib-esm/shared/LayerManager.d.ts.map +1 -0
- package/lib-esm/shared/LayerManager.js +82 -36
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +1 -0
- package/lib-esm/shared/constants.d.ts.map +1 -0
- package/lib-esm/shared/constants.js +7 -7
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -0
- package/lib-esm/shared/styles.d.ts.map +1 -0
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75,27 +75,27 @@ function CheckCircle(props) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
var constants = {
|
|
78
|
-
PRIMARY: '#
|
|
78
|
+
PRIMARY: '#1f7ac5',
|
|
79
79
|
PRIMARY_LIGHT: '#64baff',
|
|
80
80
|
PRIMARY_LIGHTER: '#cfe9ff',
|
|
81
81
|
BACKDROP_COLOR: '#2681da80',
|
|
82
|
-
INFO: '#
|
|
82
|
+
INFO: '#1d6eaf',
|
|
83
83
|
INFO_LIGHT: '#64baff',
|
|
84
|
-
SUCCESS: '#
|
|
84
|
+
SUCCESS: '#1a835f',
|
|
85
85
|
SUCCESS_LIGHT: '#80eac6',
|
|
86
|
-
WARNING: '#
|
|
86
|
+
WARNING: '#916b01',
|
|
87
87
|
WARNING_LIGHT: '#ffba00',
|
|
88
|
-
ERROR: '#
|
|
88
|
+
ERROR: '#bb2828',
|
|
89
89
|
ERROR_LIGHT: '#f1a5a5',
|
|
90
90
|
BORDER_COLOR: '#555555',
|
|
91
91
|
TOAST: '#5f5f5f',
|
|
92
|
-
TOOLTIP_COLOR: 'rgba(0,0,0,0.
|
|
92
|
+
TOOLTIP_COLOR: 'rgba(0,0,0,0.6)',
|
|
93
93
|
BORDER_LIGHT_COLOR: '#eeeeee',
|
|
94
94
|
BACKGROUND: '#ffffff',
|
|
95
95
|
DISABLED_BACKGROUND: '#fafafa',
|
|
96
96
|
DISABLED_BORDER: '#aaa',
|
|
97
97
|
LIGHT_GREY: '#ccc',
|
|
98
|
-
DISABLED: '#
|
|
98
|
+
DISABLED: '#737373',
|
|
99
99
|
SHADOW: '0px 1px 3px 0px rgba(0,0,0,0.1), 0px 1px 2px 0px rgba(0,0,0,0.06)',
|
|
100
100
|
HOVER_SHADOW: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
101
101
|
MODAL_SHADOW: '0px 8px 17px 2px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12), 0px 5px 5px -3px rgba(0,0,0,0.2)',
|
|
@@ -193,18 +193,26 @@ const Card = styled.div `
|
|
|
193
193
|
|
|
194
194
|
const Step$1 = styled(Card) `
|
|
195
195
|
transition: all 0.6s ease;
|
|
196
|
+
overflow: visible;
|
|
196
197
|
|
|
197
198
|
${(props) => props.open &&
|
|
198
199
|
`
|
|
199
200
|
margin: 20px 5px;
|
|
200
201
|
`}
|
|
201
|
-
|
|
202
|
-
${(props) => props.focused && `box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});`}
|
|
203
202
|
`;
|
|
204
|
-
const StepHeader = styled.
|
|
203
|
+
const StepHeader = styled.button `
|
|
205
204
|
padding: 20px 15px;
|
|
206
205
|
display: flex;
|
|
207
206
|
justify-content: space-between;
|
|
207
|
+
background: none;
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: 10px;
|
|
210
|
+
width: 100%;
|
|
211
|
+
font-size: inherit;
|
|
212
|
+
|
|
213
|
+
&:focus-visible {
|
|
214
|
+
box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});
|
|
215
|
+
}
|
|
208
216
|
|
|
209
217
|
& input {
|
|
210
218
|
appearance: none;
|
|
@@ -219,7 +227,7 @@ const StepHeader = styled.div `
|
|
|
219
227
|
|
|
220
228
|
${(props) => props.disabled
|
|
221
229
|
? `
|
|
222
|
-
color: ${constants.
|
|
230
|
+
color: ${constants.DISABLED};
|
|
223
231
|
`
|
|
224
232
|
: `
|
|
225
233
|
cursor: pointer;
|
|
@@ -278,15 +286,14 @@ const AccordionStepFooter = styled.div `
|
|
|
278
286
|
`;
|
|
279
287
|
function AccordionStep(props) {
|
|
280
288
|
const [height, setHeight] = React.useState(0);
|
|
281
|
-
const [focused, setFocused] = React.useState(false);
|
|
282
289
|
const { open, disabled, header, errorText, completed, onStepClick } = props;
|
|
290
|
+
// Generate unique IDs for ARIA relationships
|
|
291
|
+
const headerId = React.useId();
|
|
292
|
+
const regionId = React.useId();
|
|
283
293
|
const ref = (el) => setHeight((el === null || el === void 0 ? void 0 : el.scrollHeight) || 0);
|
|
284
|
-
|
|
285
|
-
setFocused(!focused);
|
|
286
|
-
};
|
|
287
|
-
return (jsxRuntime.jsxs(Step$1, Object.assign({}, props, { focused: focused, elevated: props.open, children: [jsxRuntime.jsxs(StepHeader, { open: open, disabled: disabled, onClick: onStepClick, children: [jsxRuntime.jsxs(HeaderContainer, { open: open, completed: completed, children: [jsxRuntime.jsx("input", { type: "checkbox", checked: open, disabled: disabled, onFocus: toggleFocus, onBlur: toggleFocus }), jsxRuntime.jsx(FiberManualRecord, {}), jsxRuntime.jsx(Ellipsis, { children: header })] }), jsxRuntime.jsxs(ExpandContainer, { open: open, children: [errorText && (jsxRuntime.jsx(Badge, { css: react.css `
|
|
294
|
+
return (jsxRuntime.jsxs(Step$1, Object.assign({}, props, { elevated: props.open, children: [jsxRuntime.jsxs(StepHeader, { open: open, disabled: disabled, onClick: onStepClick, "aria-expanded": open ? 'true' : 'false', "aria-controls": regionId, id: headerId, children: [jsxRuntime.jsxs(HeaderContainer, { open: open, completed: completed, children: [jsxRuntime.jsx(FiberManualRecord, { "aria-hidden": "true" }), jsxRuntime.jsx(Ellipsis, { children: header })] }), jsxRuntime.jsxs(ExpandContainer, { open: open, children: [errorText && (jsxRuntime.jsx(Badge, { css: react.css `
|
|
288
295
|
margin-right: 15px;
|
|
289
|
-
`, inline: true, type: exports.BADGE_TYPE.DANGER, children: errorText })), jsxRuntime.jsx(ExpandMore, {})] })] }), jsxRuntime.jsx(StepBody, { ref: ref, height: open ? height : 0, children: open && props.children })] })));
|
|
296
|
+
`, inline: true, type: exports.BADGE_TYPE.DANGER, children: errorText })), jsxRuntime.jsx(ExpandMore, { "aria-hidden": "true" })] })] }), jsxRuntime.jsx(StepBody, { ref: ref, height: open ? height : 0, role: "region", id: regionId, "aria-labelledby": headerId, "aria-hidden": open ? 'false' : 'true', children: open && props.children })] })));
|
|
290
297
|
}
|
|
291
298
|
AccordionStep.propTypes = {
|
|
292
299
|
/** Header text for the step */
|
|
@@ -303,7 +310,7 @@ AccordionStep.defaultProps = {
|
|
|
303
310
|
disabled: false,
|
|
304
311
|
};
|
|
305
312
|
|
|
306
|
-
|
|
313
|
+
const StyledButton = styled.button `
|
|
307
314
|
border: 1px solid var(--border-color, ${constants.BORDER_COLOR});
|
|
308
315
|
border-radius: 5px;
|
|
309
316
|
height: 32px;
|
|
@@ -338,11 +345,14 @@ var Button$2 = styled.button `
|
|
|
338
345
|
}
|
|
339
346
|
|
|
340
347
|
&:disabled {
|
|
341
|
-
background-color: var(--border-light-color, ${constants.
|
|
348
|
+
background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});
|
|
342
349
|
border-color: var(--light-grey, ${constants.LIGHT_GREY});
|
|
343
350
|
color: var(--disabled, ${constants.DISABLED});
|
|
344
351
|
}
|
|
345
352
|
`;
|
|
353
|
+
StyledButton.defaultProps = {
|
|
354
|
+
type: 'button',
|
|
355
|
+
};
|
|
346
356
|
|
|
347
357
|
var LinkButton = styled.button `
|
|
348
358
|
min-width: 100px;
|
|
@@ -374,7 +384,7 @@ var LinkButton = styled.button `
|
|
|
374
384
|
|
|
375
385
|
&:disabled {
|
|
376
386
|
border-color: ${constants.BORDER_COLOR};
|
|
377
|
-
color: ${constants.
|
|
387
|
+
color: ${constants.DISABLED};
|
|
378
388
|
}
|
|
379
389
|
`;
|
|
380
390
|
|
|
@@ -414,7 +424,7 @@ var RaisedButton = styled.button `
|
|
|
414
424
|
}
|
|
415
425
|
|
|
416
426
|
&:disabled {
|
|
417
|
-
background-color: ${constants.
|
|
427
|
+
background-color: ${constants.DISABLED_BACKGROUND};
|
|
418
428
|
border-color: ${constants.LIGHT_GREY};
|
|
419
429
|
color: ${constants.DISABLED};
|
|
420
430
|
}
|
|
@@ -458,8 +468,8 @@ var ActionButton = styled.button `
|
|
|
458
468
|
}
|
|
459
469
|
|
|
460
470
|
&:disabled {
|
|
461
|
-
border: 1px solid ${constants.
|
|
462
|
-
background-color: var(--border-light-color, ${constants.
|
|
471
|
+
border: 1px solid ${constants.BORDER_LIGHT_COLOR};
|
|
472
|
+
background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});
|
|
463
473
|
color: var(--disabled, ${constants.DISABLED});
|
|
464
474
|
}
|
|
465
475
|
`;
|
|
@@ -541,7 +551,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
541
551
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
542
552
|
};
|
|
543
553
|
|
|
544
|
-
const Container$8 = styled.
|
|
554
|
+
const Container$8 = styled.span `
|
|
545
555
|
padding: 5px;
|
|
546
556
|
padding-left: 15px;
|
|
547
557
|
border-radius: 16px;
|
|
@@ -556,22 +566,28 @@ const Container$8 = styled.div `
|
|
|
556
566
|
}
|
|
557
567
|
`;
|
|
558
568
|
const Button$1 = styled.button `
|
|
559
|
-
color:
|
|
560
|
-
background-color: var(--
|
|
569
|
+
color: var(--background-color, ${constants.BACKGROUND});
|
|
570
|
+
background-color: var(--border-color, ${constants.DISABLED});
|
|
561
571
|
border-radius: 50%;
|
|
562
572
|
border: none;
|
|
563
|
-
padding:
|
|
573
|
+
padding: 4px;
|
|
564
574
|
display: inline-flex;
|
|
565
575
|
margin-left: 5px;
|
|
566
576
|
`;
|
|
567
577
|
function Chip(props) {
|
|
568
|
-
const { label, onCloseClick } = props, rest = __rest(props, ["label", "onCloseClick"]);
|
|
578
|
+
const { label, onCloseClick, closeButtonAriaLabel } = props, rest = __rest(props, ["label", "onCloseClick", "closeButtonAriaLabel"]);
|
|
569
579
|
const keyUpHandler = (e) => {
|
|
570
|
-
if (e.
|
|
571
|
-
onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
|
|
580
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
581
|
+
onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick(e);
|
|
572
582
|
}
|
|
573
583
|
};
|
|
574
|
-
|
|
584
|
+
const buttonKeyDownHandler = (e) => {
|
|
585
|
+
// Stop propagation to prevent DragAndDrop from capturing Space/Enter
|
|
586
|
+
if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'Enter') {
|
|
587
|
+
e.stopPropagation();
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
return (jsxRuntime.jsxs(Container$8, Object.assign({}, rest, { onKeyUp: keyUpHandler, children: [label, jsxRuntime.jsx(Button$1, { onClick: onCloseClick, onKeyDown: buttonKeyDownHandler, "aria-label": closeButtonAriaLabel !== null && closeButtonAriaLabel !== void 0 ? closeButtonAriaLabel : `Remove ${label}`, children: jsxRuntime.jsx(Close, { height: 16, width: 16 }) })] })));
|
|
575
591
|
}
|
|
576
592
|
|
|
577
593
|
exports.ORIENTATION = void 0;
|
|
@@ -586,23 +602,36 @@ const Item = styled.div `
|
|
|
586
602
|
cursor: ${(props) => (props.showIndicator ? 'default' : 'move')};
|
|
587
603
|
display: flex;
|
|
588
604
|
user-select: ${(props) => (props.showIndicator ? 'auto' : 'none')};
|
|
589
|
-
border-top: 2px
|
|
605
|
+
border-top: 2px dashed
|
|
590
606
|
${(props) => props.orientation === exports.ORIENTATION.VERTICAL && props.active > 0
|
|
591
607
|
? constants.PRIMARY
|
|
592
608
|
: 'transparent'};
|
|
593
|
-
border-bottom: 2px
|
|
609
|
+
border-bottom: 2px dashed
|
|
594
610
|
${(props) => props.orientation === exports.ORIENTATION.VERTICAL && props.active < 0
|
|
595
611
|
? constants.PRIMARY
|
|
596
612
|
: 'transparent'};
|
|
597
|
-
border-left: 2px
|
|
613
|
+
border-left: 2px dashed
|
|
598
614
|
${(props) => props.orientation === exports.ORIENTATION.HORIZONTAL && props.active > 0
|
|
599
615
|
? constants.PRIMARY
|
|
600
616
|
: 'transparent'};
|
|
601
|
-
border-right: 2px
|
|
617
|
+
border-right: 2px dashed
|
|
602
618
|
${(props) => props.orientation === exports.ORIENTATION.HORIZONTAL && props.active < 0
|
|
603
619
|
? constants.PRIMARY
|
|
604
620
|
: 'transparent'};
|
|
605
621
|
opacity: ${(props) => (props.dragging ? 0.5 : 1)};
|
|
622
|
+
border-radius: 10px;
|
|
623
|
+
|
|
624
|
+
&:focus {
|
|
625
|
+
box-shadow: 0 0 0 4px var(--primary, ${constants.PRIMARY_LIGHT});
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
&:focus:not(:focus-visible) {
|
|
629
|
+
box-shadow: none;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
&:focus-visible {
|
|
633
|
+
box-shadow: 0 0 0 4px var(--primary, ${constants.PRIMARY_LIGHT});
|
|
634
|
+
}
|
|
606
635
|
`;
|
|
607
636
|
/** Styled component for the drag handle indicator */
|
|
608
637
|
const DragKnob = styled.div `
|
|
@@ -648,7 +677,7 @@ const Container$7 = styled.div `
|
|
|
648
677
|
* @returns A draggable item with optional drag indicator and visual feedback
|
|
649
678
|
*/
|
|
650
679
|
function DragItem(props) {
|
|
651
|
-
const { index, orientation, children, showIndicator, dragOver } = props;
|
|
680
|
+
const { index, orientation, children, showIndicator, dragOver, totalItems, setAnnouncement } = props;
|
|
652
681
|
const [active, setActive] = React.useState(0);
|
|
653
682
|
const [touchTimer, setTouchTimer] = React.useState(null);
|
|
654
683
|
const context = React.useContext(DragContext);
|
|
@@ -750,6 +779,71 @@ function DragItem(props) {
|
|
|
750
779
|
document.body.style.overflow = 'auto';
|
|
751
780
|
}
|
|
752
781
|
};
|
|
782
|
+
/**
|
|
783
|
+
* Keyboard navigation handler for reordering items
|
|
784
|
+
* @param e Keyboard event
|
|
785
|
+
*/
|
|
786
|
+
const handleKeyDown = (e) => {
|
|
787
|
+
const isVertical = orientation === exports.ORIENTATION.VERTICAL;
|
|
788
|
+
const moveUp = isVertical ? 'ArrowUp' : 'ArrowLeft';
|
|
789
|
+
const moveDown = isVertical ? 'ArrowDown' : 'ArrowRight';
|
|
790
|
+
const isGrabbed = context.isDragging && context.startIndex === index;
|
|
791
|
+
// Space to grab/drop
|
|
792
|
+
if (e.key === ' ' || e.key === 'Spacebar') {
|
|
793
|
+
e.preventDefault();
|
|
794
|
+
if (isGrabbed) {
|
|
795
|
+
// Drop at current position
|
|
796
|
+
context.drop(index);
|
|
797
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.droppedAnnouncementTemplate, {
|
|
798
|
+
position: index + 1,
|
|
799
|
+
}));
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
// Grab item
|
|
803
|
+
context.startGrab(index);
|
|
804
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.grabbedAnnouncementTemplate, {
|
|
805
|
+
position: index + 1,
|
|
806
|
+
}));
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
// Enter to drop
|
|
810
|
+
else if (e.key === 'Enter' && isGrabbed) {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
context.drop(index);
|
|
813
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.droppedAnnouncementTemplate, {
|
|
814
|
+
position: index + 1,
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
// Escape to cancel
|
|
818
|
+
else if (e.key === 'Escape' && isGrabbed) {
|
|
819
|
+
e.preventDefault();
|
|
820
|
+
context.cancel();
|
|
821
|
+
setAnnouncement(context.i18n.cancelledAnnouncementTemplate);
|
|
822
|
+
}
|
|
823
|
+
// Arrow keys to move while grabbed
|
|
824
|
+
else if (isGrabbed) {
|
|
825
|
+
if (e.key === moveUp && index > 0) {
|
|
826
|
+
e.preventDefault();
|
|
827
|
+
// Move without dropping - just reorder and update startIndex
|
|
828
|
+
const newIndex = index - 1;
|
|
829
|
+
context.onDrop(context.startIndex, newIndex);
|
|
830
|
+
context.setStartIndex(newIndex);
|
|
831
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {
|
|
832
|
+
position: newIndex + 1,
|
|
833
|
+
}));
|
|
834
|
+
}
|
|
835
|
+
else if (e.key === moveDown && index < totalItems - 1) {
|
|
836
|
+
e.preventDefault();
|
|
837
|
+
// Move without dropping - just reorder and update startIndex
|
|
838
|
+
const newIndex = index + 1;
|
|
839
|
+
context.onDrop(context.startIndex, newIndex);
|
|
840
|
+
context.setStartIndex(newIndex);
|
|
841
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {
|
|
842
|
+
position: newIndex + 1,
|
|
843
|
+
}));
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
};
|
|
753
847
|
/** Cleanup touch timer on unmount */
|
|
754
848
|
React.useEffect(() => {
|
|
755
849
|
return () => {
|
|
@@ -767,7 +861,9 @@ function DragItem(props) {
|
|
|
767
861
|
setActive(0);
|
|
768
862
|
}
|
|
769
863
|
}, [dragOver, context.startIndex, index, context.isDragging]);
|
|
770
|
-
return (jsxRuntime.jsxs(Item, { draggable: !showIndicator, showIndicator: showIndicator, active: active, dragging: context.isDragging && context.startIndex === index, orientation: orientation, "data-drag-index": index,
|
|
864
|
+
return (jsxRuntime.jsxs(Item, { draggable: !showIndicator, showIndicator: showIndicator, active: active, dragging: context.isDragging && context.startIndex === index, orientation: orientation, "data-drag-index": index, tabIndex: 0, role: "listitem", "aria-label": context.i18n.replacePlaceholders(context.i18n.itemAriaLabelTemplate, {
|
|
865
|
+
position: index + 1,
|
|
866
|
+
}), "aria-grabbed": context.isDragging && context.startIndex === index, onKeyDown: handleKeyDown, onDragStart: !showIndicator ? dragStartHandler : undefined, onDragOver: dragOverHandler, onDragLeave: dragExitHandler, onDrop: dropHandler, onTouchStart: !showIndicator ? touchStartHandler : undefined, onTouchMove: touchMoveHandler, onTouchEnd: touchEndHandler, onTouchCancel: touchEndHandler, children: [showIndicator && (jsxRuntime.jsx(DragKnob, { draggable: true, role: "button", "aria-label": context.i18n.dragHandleAriaLabel, onDragStart: dragStartHandler, onTouchStart: touchStartHandler, onKeyDown: handleKeyDown, tabIndex: -1, children: jsxRuntime.jsx(CheckCircle, {}) })), jsxRuntime.jsx(Container$7, { children: children })] }));
|
|
771
867
|
}
|
|
772
868
|
|
|
773
869
|
/** Container Component */
|
|
@@ -778,6 +874,18 @@ const Container$6 = styled.div `
|
|
|
778
874
|
flex-wrap: wrap;
|
|
779
875
|
flex-direction: ${(props) => (props.orientation === exports.ORIENTATION.HORIZONTAL ? 'row' : 'column')};
|
|
780
876
|
`;
|
|
877
|
+
/** Visually hidden but accessible to screen readers */
|
|
878
|
+
const VisuallyHidden$1 = styled.div `
|
|
879
|
+
position: absolute;
|
|
880
|
+
width: 1px;
|
|
881
|
+
height: 1px;
|
|
882
|
+
padding: 0;
|
|
883
|
+
margin: -1px;
|
|
884
|
+
overflow: hidden;
|
|
885
|
+
clip: rect(0, 0, 0, 0);
|
|
886
|
+
white-space: nowrap;
|
|
887
|
+
border-width: 0;
|
|
888
|
+
`;
|
|
781
889
|
/**
|
|
782
890
|
* A drag and drop container component that enables reordering of child elements.
|
|
783
891
|
*
|
|
@@ -804,10 +912,37 @@ const Container$6 = styled.div `
|
|
|
804
912
|
* @returns {JSX.Element} A draggable container with reorderable items
|
|
805
913
|
*/
|
|
806
914
|
function DragAndDrop(props) {
|
|
807
|
-
const { orientation, children, onDrop, showIndicator } = props;
|
|
915
|
+
const { orientation, children, onDrop, showIndicator, itemAriaLabelTemplate, dragHandleAriaLabel, grabbedAnnouncementTemplate, movedAnnouncementTemplate, droppedAnnouncementTemplate, cancelledAnnouncementTemplate, } = props;
|
|
808
916
|
const [startIndex, setStartIndex] = React.useState(null);
|
|
917
|
+
const [originalIndex, setOriginalIndex] = React.useState(null);
|
|
809
918
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
810
919
|
const [dragOver, setDragOver] = React.useState(null);
|
|
920
|
+
const [announcement, setAnnouncement] = React.useState('');
|
|
921
|
+
const childrenArray = React.Children.toArray(children);
|
|
922
|
+
const totalItems = childrenArray.length;
|
|
923
|
+
/**
|
|
924
|
+
* Replace placeholders in i18n templates
|
|
925
|
+
*/
|
|
926
|
+
const replacePlaceholders = (template, data) => {
|
|
927
|
+
var _a, _b, _c, _d, _e, _f;
|
|
928
|
+
return template
|
|
929
|
+
.replace(/\{:position\}/g, String((_a = data.position) !== null && _a !== void 0 ? _a : ''))
|
|
930
|
+
.replace(/\{:grabKey\}/g, (_b = data.grabKey) !== null && _b !== void 0 ? _b : 'Space')
|
|
931
|
+
.replace(/\{:dropKey\}/g, (_c = data.dropKey) !== null && _c !== void 0 ? _c : 'Space')
|
|
932
|
+
.replace(/\{:altDropKey\}/g, (_d = data.altDropKey) !== null && _d !== void 0 ? _d : 'Enter')
|
|
933
|
+
.replace(/\{:cancelKey\}/g, (_e = data.cancelKey) !== null && _e !== void 0 ? _e : 'Escape')
|
|
934
|
+
.replace(/\{:moveKeys\}/g, (_f = data.moveKeys) !== null && _f !== void 0 ? _f : (orientation === exports.ORIENTATION.VERTICAL ? 'Arrow Up/Down' : 'Arrow Left/Right'));
|
|
935
|
+
};
|
|
936
|
+
// i18n configuration object
|
|
937
|
+
const i18n = {
|
|
938
|
+
itemAriaLabelTemplate: itemAriaLabelTemplate,
|
|
939
|
+
dragHandleAriaLabel: dragHandleAriaLabel,
|
|
940
|
+
grabbedAnnouncementTemplate: grabbedAnnouncementTemplate,
|
|
941
|
+
movedAnnouncementTemplate: movedAnnouncementTemplate,
|
|
942
|
+
droppedAnnouncementTemplate: droppedAnnouncementTemplate,
|
|
943
|
+
cancelledAnnouncementTemplate: cancelledAnnouncementTemplate,
|
|
944
|
+
replacePlaceholders,
|
|
945
|
+
};
|
|
811
946
|
/**
|
|
812
947
|
* Drop handler invoked when a draggable item is released.
|
|
813
948
|
* @param index
|
|
@@ -817,15 +952,58 @@ function DragAndDrop(props) {
|
|
|
817
952
|
onDrop === null || onDrop === void 0 ? void 0 : onDrop(startIndex, index);
|
|
818
953
|
}
|
|
819
954
|
setStartIndex(null);
|
|
955
|
+
setOriginalIndex(null);
|
|
820
956
|
setIsDragging(false);
|
|
821
957
|
};
|
|
822
|
-
|
|
958
|
+
/**
|
|
959
|
+
* Cancel handler to restore item to original position
|
|
960
|
+
*/
|
|
961
|
+
const cancel = () => {
|
|
962
|
+
if (originalIndex !== null && startIndex !== null && startIndex !== originalIndex) {
|
|
963
|
+
onDrop === null || onDrop === void 0 ? void 0 : onDrop(startIndex, originalIndex);
|
|
964
|
+
}
|
|
965
|
+
setStartIndex(null);
|
|
966
|
+
setOriginalIndex(null);
|
|
967
|
+
setIsDragging(false);
|
|
968
|
+
};
|
|
969
|
+
/**
|
|
970
|
+
* Start grab handler to track original position
|
|
971
|
+
*/
|
|
972
|
+
const startGrab = (index) => {
|
|
973
|
+
setStartIndex(index);
|
|
974
|
+
setOriginalIndex(index);
|
|
975
|
+
setIsDragging(true);
|
|
976
|
+
};
|
|
977
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DragContext.Provider, { value: {
|
|
978
|
+
startIndex,
|
|
979
|
+
setStartIndex,
|
|
980
|
+
drop,
|
|
981
|
+
onDrop,
|
|
982
|
+
cancel,
|
|
983
|
+
startGrab,
|
|
984
|
+
isDragging,
|
|
985
|
+
setIsDragging,
|
|
986
|
+
setDragOver,
|
|
987
|
+
i18n,
|
|
988
|
+
}, children: jsxRuntime.jsx(Container$6, { orientation: orientation, role: "list", children: React.Children.map(childrenArray, (child, index) => (jsxRuntime.jsx(DragItem, { index: index, orientation: orientation, showIndicator: showIndicator, dragOver: dragOver, totalItems: totalItems, setAnnouncement: setAnnouncement, children: child }))) }) }), jsxRuntime.jsx(VisuallyHidden$1, { role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement })] }));
|
|
823
989
|
}
|
|
824
990
|
DragAndDrop.defaultProps = {
|
|
825
991
|
/** Orientation of the list layout */
|
|
826
992
|
orientation: exports.ORIENTATION.VERTICAL,
|
|
827
993
|
/** Whether to display drag indicators for each list item */
|
|
828
994
|
showIndicator: false,
|
|
995
|
+
/** Default item aria-label template */
|
|
996
|
+
itemAriaLabelTemplate: 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',
|
|
997
|
+
/** Default drag handle aria-label */
|
|
998
|
+
dragHandleAriaLabel: 'Drag to reorder',
|
|
999
|
+
/** Default grabbed announcement template */
|
|
1000
|
+
grabbedAnnouncementTemplate: 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',
|
|
1001
|
+
/** Default moved announcement template */
|
|
1002
|
+
movedAnnouncementTemplate: 'Item moved to position {:position}',
|
|
1003
|
+
/** Default dropped announcement template */
|
|
1004
|
+
droppedAnnouncementTemplate: 'Item dropped at position {:position}',
|
|
1005
|
+
/** Default cancelled announcement template */
|
|
1006
|
+
cancelledAnnouncementTemplate: 'Drag cancelled, item restored to original position',
|
|
829
1007
|
};
|
|
830
1008
|
|
|
831
1009
|
// Label component for the ChipInput
|
|
@@ -946,6 +1124,22 @@ const ErrorContainer$4 = styled.div `
|
|
|
946
1124
|
line-height: 14px;
|
|
947
1125
|
margin-left: 3px;
|
|
948
1126
|
`;
|
|
1127
|
+
// Visually hidden but accessible to screen readers
|
|
1128
|
+
const VisuallyHidden = styled.ul `
|
|
1129
|
+
position: absolute;
|
|
1130
|
+
width: 1px;
|
|
1131
|
+
height: 1px;
|
|
1132
|
+
padding: 0;
|
|
1133
|
+
margin: -1px;
|
|
1134
|
+
overflow: hidden;
|
|
1135
|
+
clip: rect(0, 0, 0, 0);
|
|
1136
|
+
white-space: nowrap;
|
|
1137
|
+
border-width: 0;
|
|
1138
|
+
|
|
1139
|
+
& li {
|
|
1140
|
+
list-style: none;
|
|
1141
|
+
}
|
|
1142
|
+
`;
|
|
949
1143
|
/**
|
|
950
1144
|
* A chip input component that allows users to add and remove chips (tags) by typing and pressing Enter.
|
|
951
1145
|
* @component
|
|
@@ -964,9 +1158,21 @@ function ChipInput(props) {
|
|
|
964
1158
|
const [touched, setTouched] = React.useState(false);
|
|
965
1159
|
const [value, setValue] = React.useState(props.value);
|
|
966
1160
|
const InputRef = React.useRef(null);
|
|
1161
|
+
const [announcement, setAnnouncement] = React.useState('');
|
|
1162
|
+
const errorId = React.useId();
|
|
1163
|
+
/**
|
|
1164
|
+
* Replace {:label} placeholder in template string
|
|
1165
|
+
*/
|
|
1166
|
+
const replacePlaceholder = (template, label) => {
|
|
1167
|
+
if (!template)
|
|
1168
|
+
return undefined;
|
|
1169
|
+
return template.replace(/\{:label\}/g, label);
|
|
1170
|
+
};
|
|
967
1171
|
// Sync internal value with props.value
|
|
968
1172
|
React.useEffect(() => {
|
|
969
|
-
|
|
1173
|
+
if (Array.isArray(props.value)) {
|
|
1174
|
+
setValue(props.value);
|
|
1175
|
+
}
|
|
970
1176
|
}, [props.value]);
|
|
971
1177
|
/**
|
|
972
1178
|
* Update the chip values and notify changes.
|
|
@@ -1004,6 +1210,7 @@ function ChipInput(props) {
|
|
|
1004
1210
|
const newValue = [...value, text.trim()];
|
|
1005
1211
|
updateValue(newValue);
|
|
1006
1212
|
setText('');
|
|
1213
|
+
setAnnouncement(replacePlaceholder(props.addedAnnouncementTemplate, text.trim()));
|
|
1007
1214
|
}
|
|
1008
1215
|
};
|
|
1009
1216
|
/**
|
|
@@ -1013,6 +1220,7 @@ function ChipInput(props) {
|
|
|
1013
1220
|
const removeChip = (chipToRemove) => {
|
|
1014
1221
|
const newValue = value.filter((chip) => chip !== chipToRemove);
|
|
1015
1222
|
updateValue(newValue);
|
|
1223
|
+
setAnnouncement(replacePlaceholder(props.removedAnnouncementTemplate, chipToRemove));
|
|
1016
1224
|
};
|
|
1017
1225
|
/**
|
|
1018
1226
|
* Moves a chip from one position to another.
|
|
@@ -1030,7 +1238,7 @@ function ChipInput(props) {
|
|
|
1030
1238
|
updateValue(newItems);
|
|
1031
1239
|
};
|
|
1032
1240
|
// Render the component
|
|
1033
|
-
return (jsxRuntime.jsxs(Label$6, { text: text, touched: touched, errorText: props.errorText, children: [jsxRuntime.jsx("input", Object.assign({}, props, { ref: InputRef,
|
|
1241
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(Label$6, { text: text, touched: touched, errorText: props.errorText, children: [jsxRuntime.jsx("input", Object.assign({}, props, { ref: InputRef, value: text, onChange: handleChange, onFocus: handleFocus, onKeyUp: handleKeyUp, required: props.required && value.length === 0, "aria-required": props.required, "aria-invalid": !!props.errorText, "aria-describedby": props.errorText ? errorId : undefined })), jsxRuntime.jsx("div", { children: (value === null || value === void 0 ? void 0 : value.length) > 0 && (jsxRuntime.jsx(DragAndDrop, { orientation: exports.ORIENTATION.HORIZONTAL, onDrop: onDrop, children: value.map((chip) => (jsxRuntime.jsx(Chip, { label: chip, onCloseClick: () => removeChip(chip), closeButtonAriaLabel: replacePlaceholder(props.closeButtonAriaLabel, chip) }, chip))) })) }), jsxRuntime.jsx("span", { children: props.label }), props.errorText && jsxRuntime.jsx(ErrorContainer$4, { id: errorId, children: props.errorText })] }), jsxRuntime.jsx(VisuallyHidden, { "aria-live": "polite", "aria-atomic": "true", children: announcement })] }));
|
|
1034
1242
|
}
|
|
1035
1243
|
ChipInput.propTypes = {
|
|
1036
1244
|
/** Label for the field */
|
|
@@ -1041,9 +1249,18 @@ ChipInput.propTypes = {
|
|
|
1041
1249
|
value: PropTypes.arrayOf(PropTypes.string),
|
|
1042
1250
|
/** Callback when chips change */
|
|
1043
1251
|
onChange: PropTypes.func,
|
|
1252
|
+
/** Aria label for the close button on chip. Defaults to "Remove {label}" */
|
|
1253
|
+
closeButtonAriaLabel: PropTypes.string,
|
|
1254
|
+
/** Announcement text when a chip is added. Defaults to "{label} was added" */
|
|
1255
|
+
addedAnnouncementTemplate: PropTypes.string,
|
|
1256
|
+
/** Announcement text when a chip is removed. Defaults to "{label} was removed" */
|
|
1257
|
+
removedAnnouncementTemplate: PropTypes.string,
|
|
1044
1258
|
};
|
|
1045
1259
|
ChipInput.defaultProps = {
|
|
1046
1260
|
value: [],
|
|
1261
|
+
closeButtonAriaLabel: 'Remove {:label}',
|
|
1262
|
+
addedAnnouncementTemplate: '{:label} was added',
|
|
1263
|
+
removedAnnouncementTemplate: '{:label} was removed',
|
|
1047
1264
|
};
|
|
1048
1265
|
|
|
1049
1266
|
/** Enums for layer position on screen. */
|
|
@@ -1115,6 +1332,32 @@ const KEY_CODES$1 = {
|
|
|
1115
1332
|
* This way we need not worry about the z-index and can freely keep on creating
|
|
1116
1333
|
* new layers. The staring layer z-index is 10000. Leaving enough z-index for the
|
|
1117
1334
|
* user if they desires so.
|
|
1335
|
+
*
|
|
1336
|
+
* @important Usage Pattern
|
|
1337
|
+
* To avoid creating duplicate layers (especially in React Strict Mode or Next.js),
|
|
1338
|
+
* always call `renderLayer` only once - either in a lifecycle method (like `componentDidUpdate`)
|
|
1339
|
+
* or in an imperative method (like `open()`).
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* // ❌ Don't call renderLayer in render() method
|
|
1343
|
+
* render() {
|
|
1344
|
+
* if (this.state.show) {
|
|
1345
|
+
* const [Component, closeFn] = LayerManager.renderLayer({ ... }); // Creates new layer on every render
|
|
1346
|
+
* return <Component />;
|
|
1347
|
+
* }
|
|
1348
|
+
* }
|
|
1349
|
+
*
|
|
1350
|
+
* @example
|
|
1351
|
+
* // ✅ Do call renderLayer once in a method and store the component
|
|
1352
|
+
* open() {
|
|
1353
|
+
* const [Component, closeFn] = LayerManager.renderLayer({ ... });
|
|
1354
|
+
* this.setState({ LayerComponent: Component });
|
|
1355
|
+
* }
|
|
1356
|
+
*
|
|
1357
|
+
* render() {
|
|
1358
|
+
* const { LayerComponent } = this.state;
|
|
1359
|
+
* return LayerComponent ? <LayerComponent /> : null;
|
|
1360
|
+
* }
|
|
1118
1361
|
*/
|
|
1119
1362
|
class LayerManager {
|
|
1120
1363
|
/**
|
|
@@ -1154,59 +1397,79 @@ class LayerManager {
|
|
|
1154
1397
|
* @param config
|
|
1155
1398
|
*/
|
|
1156
1399
|
this.renderLayer = (config) => {
|
|
1400
|
+
// SSR guard
|
|
1401
|
+
if (typeof document === 'undefined') {
|
|
1402
|
+
return [() => null, () => { }];
|
|
1403
|
+
}
|
|
1157
1404
|
// Merge default config with the provided config.
|
|
1158
1405
|
const layerConfig = Object.assign(Object.assign({}, defaultConfig), config);
|
|
1159
1406
|
// Get the z-index for the new layer
|
|
1160
1407
|
const currentIndex = layerConfig.alwaysOnTop ? 2147483647 : this.nextIndex++;
|
|
1161
|
-
//
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
const currentLayer = {
|
|
1167
|
-
id: `nf-layer-manager-${currentIndex}`,
|
|
1168
|
-
config: layerConfig,
|
|
1169
|
-
element: divElement,
|
|
1170
|
-
};
|
|
1171
|
-
this.layers.push(currentLayer);
|
|
1172
|
-
const overlayClickHandler = (layer) => () => {
|
|
1173
|
-
if (layer.config.closeOnOverlayClick !== false) {
|
|
1408
|
+
// Create a unique ID for tracking this layer
|
|
1409
|
+
const layerId = `nf-layer-manager-${currentIndex}`;
|
|
1410
|
+
const overlayClickHandler = () => {
|
|
1411
|
+
const layer = this.layers.find((l) => l.id === layerId);
|
|
1412
|
+
if (layer && layer.config.closeOnOverlayClick !== false) {
|
|
1174
1413
|
this.unmount(layer);
|
|
1175
1414
|
}
|
|
1176
1415
|
};
|
|
1416
|
+
const closeFn = (resp) => {
|
|
1417
|
+
const layer = this.layers.find((l) => l.id === layerId);
|
|
1418
|
+
if (layer) {
|
|
1419
|
+
this.unmount(layer, resp);
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1177
1422
|
// Return callback which will trigger the un-mount.
|
|
1178
1423
|
return [
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
// This class will help component in triggering the entry animation.
|
|
1182
|
-
function TestLayer() {
|
|
1424
|
+
() => {
|
|
1425
|
+
const [divElement, setDivElement] = React.useState(null);
|
|
1183
1426
|
React.useEffect(() => {
|
|
1184
|
-
//
|
|
1185
|
-
|
|
1186
|
-
|
|
1427
|
+
// Create the div element only once when component mounts
|
|
1428
|
+
const div = document.createElement('div');
|
|
1429
|
+
div.setAttribute('id', layerId);
|
|
1430
|
+
document.body.appendChild(div);
|
|
1431
|
+
// Add layer to stack
|
|
1432
|
+
const currentLayer = {
|
|
1433
|
+
id: layerId,
|
|
1434
|
+
config: layerConfig,
|
|
1435
|
+
element: div,
|
|
1436
|
+
};
|
|
1437
|
+
this.layers.push(currentLayer);
|
|
1438
|
+
setDivElement(div);
|
|
1439
|
+
// Add entry animation class after a short delay
|
|
1187
1440
|
setTimeout(() => {
|
|
1188
|
-
|
|
1441
|
+
div.setAttribute('class', 'nf-layer-enter');
|
|
1189
1442
|
}, 10);
|
|
1190
|
-
// Cleanup function
|
|
1443
|
+
// Cleanup function - remove div when component unmounts
|
|
1191
1444
|
return () => {
|
|
1192
|
-
document.body.
|
|
1445
|
+
if (document.body.contains(div)) {
|
|
1446
|
+
document.body.removeChild(div);
|
|
1447
|
+
}
|
|
1448
|
+
// Remove from layers array
|
|
1449
|
+
const index = this.layers.findIndex((layer) => layer.id === layerId);
|
|
1450
|
+
if (index !== -1) {
|
|
1451
|
+
this.layers.splice(index, 1);
|
|
1452
|
+
}
|
|
1193
1453
|
};
|
|
1194
|
-
}, []);
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1454
|
+
}, []); // Empty dependency array - run only once
|
|
1455
|
+
if (!divElement) {
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
return ReactDOM.createPortal(jsxRuntime.jsx(Container$5, Object.assign({ onClick: overlayClickHandler, zIndex: currentIndex }, layerConfig, { children: layerConfig.component })), divElement);
|
|
1199
1459
|
},
|
|
1460
|
+
closeFn,
|
|
1200
1461
|
];
|
|
1201
1462
|
};
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1463
|
+
if (typeof document !== 'undefined') {
|
|
1464
|
+
document.body.addEventListener('keyup', (e) => {
|
|
1465
|
+
if (this.layers.length && e.keyCode === KEY_CODES$1.ESC) {
|
|
1466
|
+
const lastLayer = this.layers.slice(-1)[0];
|
|
1467
|
+
if (lastLayer.config.closeOnEsc !== false) {
|
|
1468
|
+
this.unmount(lastLayer);
|
|
1469
|
+
}
|
|
1207
1470
|
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1210
1473
|
}
|
|
1211
1474
|
}
|
|
1212
1475
|
// Return the instance of the class to create a Singleton.
|
|
@@ -1234,10 +1497,23 @@ class Dialog extends React.Component {
|
|
|
1234
1497
|
super(...arguments);
|
|
1235
1498
|
this.state = {
|
|
1236
1499
|
show: false,
|
|
1500
|
+
LayerComponent: undefined,
|
|
1237
1501
|
};
|
|
1238
1502
|
this.open = (closeCallback) => {
|
|
1503
|
+
const _a = this.props, { closeOnEsc, closeOnOverlayClick, children } = _a, rest = __rest(_a, ["closeOnEsc", "closeOnOverlayClick", "children"]);
|
|
1504
|
+
const [Component, closeFn] = LayerManager$1.renderLayer({
|
|
1505
|
+
exitDelay: 300,
|
|
1506
|
+
overlay: true,
|
|
1507
|
+
closeOnEsc,
|
|
1508
|
+
closeCallback: this.closeCallback,
|
|
1509
|
+
closeOnOverlayClick,
|
|
1510
|
+
position: LAYER_POSITION.DIALOG,
|
|
1511
|
+
component: (jsxRuntime.jsx(DialogContainer, Object.assign({}, rest, { onClick: (e) => e.stopPropagation(), elevated: true, children: children }))),
|
|
1512
|
+
});
|
|
1513
|
+
this.closeDialog = closeFn;
|
|
1239
1514
|
this.setState({
|
|
1240
1515
|
show: true,
|
|
1516
|
+
LayerComponent: Component,
|
|
1241
1517
|
});
|
|
1242
1518
|
this.onCloseFn = closeCallback;
|
|
1243
1519
|
};
|
|
@@ -1249,6 +1525,7 @@ class Dialog extends React.Component {
|
|
|
1249
1525
|
var _a;
|
|
1250
1526
|
this.setState({
|
|
1251
1527
|
show: false,
|
|
1528
|
+
LayerComponent: undefined,
|
|
1252
1529
|
});
|
|
1253
1530
|
(_a = this.onCloseFn) === null || _a === void 0 ? void 0 : _a.call(this, resp);
|
|
1254
1531
|
};
|
|
@@ -1257,19 +1534,9 @@ class Dialog extends React.Component {
|
|
|
1257
1534
|
return this.state.show !== nextState.show;
|
|
1258
1535
|
}
|
|
1259
1536
|
render() {
|
|
1260
|
-
const
|
|
1261
|
-
if (this.state.show) {
|
|
1262
|
-
|
|
1263
|
-
exitDelay: 300,
|
|
1264
|
-
overlay: true,
|
|
1265
|
-
closeOnEsc,
|
|
1266
|
-
closeCallback: this.closeCallback,
|
|
1267
|
-
closeOnOverlayClick,
|
|
1268
|
-
position: LAYER_POSITION.DIALOG,
|
|
1269
|
-
component: (jsxRuntime.jsx(DialogContainer, Object.assign({}, rest, { onClick: (e) => e.stopPropagation(), elevated: true, children: children }))),
|
|
1270
|
-
});
|
|
1271
|
-
this.closeDialog = closeFn;
|
|
1272
|
-
return jsxRuntime.jsx(Component, {});
|
|
1537
|
+
const { LayerComponent } = this.state;
|
|
1538
|
+
if (this.state.show && LayerComponent) {
|
|
1539
|
+
return jsxRuntime.jsx(LayerComponent, {});
|
|
1273
1540
|
}
|
|
1274
1541
|
else {
|
|
1275
1542
|
return null;
|
|
@@ -1300,7 +1567,7 @@ class AlertDialog extends React.Component {
|
|
|
1300
1567
|
this.close = () => this.dialog.current.close();
|
|
1301
1568
|
}
|
|
1302
1569
|
render() {
|
|
1303
|
-
return (jsxRuntime.jsxs(Dialog, Object.assign({}, this.props.dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: [this.props.header && jsxRuntime.jsx(Header$1, { children: this.props.header }), jsxRuntime.jsx(Body$1, { children: this.props.body }), jsxRuntime.jsx(Footer$1, { children: jsxRuntime.jsx(
|
|
1570
|
+
return (jsxRuntime.jsxs(Dialog, Object.assign({}, this.props.dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: [this.props.header && jsxRuntime.jsx(Header$1, { children: this.props.header }), jsxRuntime.jsx(Body$1, { children: this.props.body }), jsxRuntime.jsx(Footer$1, { children: jsxRuntime.jsx(StyledButton, { onClick: this.close, children: this.props.buttonText }) })] })));
|
|
1304
1571
|
}
|
|
1305
1572
|
}
|
|
1306
1573
|
AlertDialog.propTypes = {
|
|
@@ -1339,7 +1606,7 @@ class ConfirmDialog extends React.Component {
|
|
|
1339
1606
|
}
|
|
1340
1607
|
render() {
|
|
1341
1608
|
const { header, body, yesText, noText, dialogProps } = this.props;
|
|
1342
|
-
return (jsxRuntime.jsxs(Dialog, Object.assign({}, dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: [header && jsxRuntime.jsx(Header$1, { children: header }), jsxRuntime.jsx(Body$1, { children: body }), jsxRuntime.jsxs(Footer$1, { children: [jsxRuntime.jsx(
|
|
1609
|
+
return (jsxRuntime.jsxs(Dialog, Object.assign({}, dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: [header && jsxRuntime.jsx(Header$1, { children: header }), jsxRuntime.jsx(Body$1, { children: body }), jsxRuntime.jsxs(Footer$1, { children: [jsxRuntime.jsx(StyledButton, { onClick: this.cancel, children: noText }), jsxRuntime.jsx(ActionButton, { onClick: this.confirm, children: yesText })] })] })));
|
|
1343
1610
|
}
|
|
1344
1611
|
}
|
|
1345
1612
|
ConfirmDialog.propTypes = {
|
|
@@ -1362,7 +1629,6 @@ ConfirmDialog.defaultProps = {
|
|
|
1362
1629
|
const Label$5 = styled.label `
|
|
1363
1630
|
display: inline-flex;
|
|
1364
1631
|
flex-direction: column;
|
|
1365
|
-
flex: 1;
|
|
1366
1632
|
position: relative;
|
|
1367
1633
|
margin: 10px 5px;
|
|
1368
1634
|
`;
|
|
@@ -1503,7 +1769,6 @@ Input$4.propTypes = {
|
|
|
1503
1769
|
const Label$4 = styled.label `
|
|
1504
1770
|
display: inline-flex;
|
|
1505
1771
|
flex-direction: column;
|
|
1506
|
-
flex: 1;
|
|
1507
1772
|
position: relative;
|
|
1508
1773
|
margin: 10px 5px;
|
|
1509
1774
|
`;
|
|
@@ -1642,7 +1907,6 @@ TextArea.propTypes = {
|
|
|
1642
1907
|
const Label$3 = styled.label `
|
|
1643
1908
|
display: inline-flex;
|
|
1644
1909
|
flex-direction: column;
|
|
1645
|
-
flex: 1;
|
|
1646
1910
|
position: relative;
|
|
1647
1911
|
margin: 10px 5px;
|
|
1648
1912
|
pointer-events: none;
|
|
@@ -1898,7 +2162,7 @@ function Checkbox(props) {
|
|
|
1898
2162
|
}
|
|
1899
2163
|
}
|
|
1900
2164
|
}, [props.indeterminate]);
|
|
1901
|
-
return (jsxRuntime.jsxs(Label$2, { children: [jsxRuntime.jsx(Input$3, Object.assign({}, props, { ref: ref, type: "checkbox" })), jsxRuntime.jsx("span", { children: props.label })] }));
|
|
2165
|
+
return (jsxRuntime.jsxs(Label$2, { children: [jsxRuntime.jsx(Input$3, Object.assign({}, props, { ref: ref, type: "checkbox", "aria-checked": props.indeterminate ? 'mixed' : props.checked })), jsxRuntime.jsx("span", { children: props.label })] }));
|
|
1902
2166
|
}
|
|
1903
2167
|
Checkbox.propTypes = {
|
|
1904
2168
|
/** Label for the field */
|
|
@@ -2521,7 +2785,7 @@ class PromptDialog extends React.Component {
|
|
|
2521
2785
|
}
|
|
2522
2786
|
render() {
|
|
2523
2787
|
const { header, body, inputProps, submitText, cancelText, dialogProps } = this.props;
|
|
2524
|
-
return (jsxRuntime.jsx(Dialog, Object.assign({}, dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: jsxRuntime.jsxs("form", { onSubmit: this.submit, children: [header && jsxRuntime.jsx(Header$1, { children: header }), jsxRuntime.jsxs(Body$1, { children: [jsxRuntime.jsx(BodyText, { children: body }), jsxRuntime.jsx("div", { style: { display: 'flex' }, children: jsxRuntime.jsx(Input$4, Object.assign({ style: { width: 'auto', flex: '1' }, value: this.state.value, onChange: this.valueChange }, inputProps)) })] }), jsxRuntime.jsxs(Footer$1, { children: [jsxRuntime.jsx(
|
|
2788
|
+
return (jsxRuntime.jsx(Dialog, Object.assign({}, dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: jsxRuntime.jsxs("form", { onSubmit: this.submit, children: [header && jsxRuntime.jsx(Header$1, { children: header }), jsxRuntime.jsxs(Body$1, { children: [jsxRuntime.jsx(BodyText, { children: body }), jsxRuntime.jsx("div", { style: { display: 'flex' }, children: jsxRuntime.jsx(Input$4, Object.assign({ style: { width: 'auto', flex: '1' }, value: this.state.value, onChange: this.valueChange }, inputProps)) })] }), jsxRuntime.jsxs(Footer$1, { children: [jsxRuntime.jsx(StyledButton, { type: "button", onClick: this.cancel, children: cancelText }), jsxRuntime.jsx(ActionButton, { children: submitText })] })] }) })));
|
|
2525
2789
|
}
|
|
2526
2790
|
}
|
|
2527
2791
|
PromptDialog.propTypes = {
|
|
@@ -3202,56 +3466,83 @@ class Notification {
|
|
|
3202
3466
|
/**
|
|
3203
3467
|
* Adds a notification
|
|
3204
3468
|
*
|
|
3205
|
-
* @param position
|
|
3206
|
-
* @param options
|
|
3469
|
+
* @param position - The position where the notification should appear
|
|
3470
|
+
* @param options - Configuration options for the notification
|
|
3471
|
+
* @returns The notification ID or a promise that resolves to the notification ID
|
|
3207
3472
|
*/
|
|
3208
3473
|
this.add = (position, options) => {
|
|
3209
|
-
let notification;
|
|
3210
3474
|
if (!this.containers.has(position)) {
|
|
3211
|
-
|
|
3212
|
-
const
|
|
3475
|
+
/** Callback ref to capture the NotificationManager instance when it mounts */
|
|
3476
|
+
const refCallback = (instance) => {
|
|
3477
|
+
if (instance) {
|
|
3478
|
+
const container = this.containers.get(position);
|
|
3479
|
+
if (container) {
|
|
3480
|
+
container.manager = instance;
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
};
|
|
3213
3484
|
const [Component] = LayerManager$1.renderLayer({
|
|
3214
3485
|
closeOnEsc: false,
|
|
3215
3486
|
closeOnOverlayClick: false,
|
|
3216
3487
|
position: positionMap[position],
|
|
3217
3488
|
alwaysOnTop: true,
|
|
3218
|
-
component: (jsxRuntime.jsx(NotificationManager, { ref:
|
|
3489
|
+
component: (jsxRuntime.jsx(NotificationManager, { ref: refCallback, position: position, onEmpty: () => this.destroy(position) })),
|
|
3219
3490
|
});
|
|
3491
|
+
// Create a div to mount the Component
|
|
3492
|
+
const div = document.createElement('div');
|
|
3493
|
+
document.body.appendChild(div);
|
|
3494
|
+
const root = client.createRoot(div);
|
|
3220
3495
|
this.containers.set(position, {
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3496
|
+
manager: null,
|
|
3497
|
+
root,
|
|
3498
|
+
div,
|
|
3224
3499
|
});
|
|
3500
|
+
// Render the Component which will trigger the LayerManager's useEffect
|
|
3225
3501
|
ReactDOM.flushSync(() => {
|
|
3226
|
-
|
|
3502
|
+
root.render(jsxRuntime.jsx(Component, {}));
|
|
3227
3503
|
});
|
|
3228
|
-
notification = ref;
|
|
3229
3504
|
}
|
|
3230
|
-
|
|
3231
|
-
|
|
3505
|
+
const container = this.containers.get(position);
|
|
3506
|
+
if (container && container.manager) {
|
|
3507
|
+
return container.manager.add(options);
|
|
3232
3508
|
}
|
|
3233
|
-
|
|
3509
|
+
// If manager is not ready yet, wait a bit and retry
|
|
3510
|
+
return new Promise((resolve) => {
|
|
3511
|
+
setTimeout(() => {
|
|
3512
|
+
const container = this.containers.get(position);
|
|
3513
|
+
if (container && container.manager) {
|
|
3514
|
+
resolve(container.manager.add(options));
|
|
3515
|
+
}
|
|
3516
|
+
}, 10);
|
|
3517
|
+
});
|
|
3234
3518
|
};
|
|
3235
3519
|
/**
|
|
3236
3520
|
* Removes a notification
|
|
3237
3521
|
*
|
|
3238
|
-
* @param position
|
|
3239
|
-
* @param id
|
|
3522
|
+
* @param position - The position of the notification container
|
|
3523
|
+
* @param id - The unique ID of the notification to remove
|
|
3240
3524
|
*/
|
|
3241
3525
|
this.remove = (position, id) => {
|
|
3242
|
-
|
|
3243
|
-
|
|
3526
|
+
const container = this.containers.get(position);
|
|
3527
|
+
if (container && container.manager) {
|
|
3528
|
+
container.manager.remove(id);
|
|
3244
3529
|
}
|
|
3245
3530
|
};
|
|
3246
3531
|
/**
|
|
3247
|
-
* Destroys entire stack of notifications.
|
|
3532
|
+
* Destroys entire stack of notifications at a position.
|
|
3533
|
+
* Unmounts the React root and cleans up DOM elements.
|
|
3248
3534
|
*
|
|
3249
|
-
* @param position
|
|
3535
|
+
* @param position - The position of the notification container to destroy
|
|
3250
3536
|
*/
|
|
3251
3537
|
this.destroy = (position) => {
|
|
3252
|
-
const
|
|
3253
|
-
|
|
3254
|
-
|
|
3538
|
+
const container = this.containers.get(position);
|
|
3539
|
+
if (container) {
|
|
3540
|
+
container.root.unmount();
|
|
3541
|
+
if (document.body.contains(container.div)) {
|
|
3542
|
+
document.body.removeChild(container.div);
|
|
3543
|
+
}
|
|
3544
|
+
this.containers.delete(position);
|
|
3545
|
+
}
|
|
3255
3546
|
};
|
|
3256
3547
|
}
|
|
3257
3548
|
}
|
|
@@ -3700,7 +3991,7 @@ exports.AccordionStepFooter = AccordionStepFooter;
|
|
|
3700
3991
|
exports.ActionButton = ActionButton;
|
|
3701
3992
|
exports.AlertDialog = AlertDialog;
|
|
3702
3993
|
exports.Badge = Badge;
|
|
3703
|
-
exports.Button =
|
|
3994
|
+
exports.Button = StyledButton;
|
|
3704
3995
|
exports.Card = Card;
|
|
3705
3996
|
exports.CardBody = Body$1;
|
|
3706
3997
|
exports.CardFooter = Footer$1;
|