no-frills-ui 0.0.14-alpha.7 → 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 +926 -795
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +9 -13
- package/lib-esm/components/Accordion/Accordion.js +4 -10
- package/lib-esm/components/Accordion/Accordion.js.map +1 -0
- package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
- package/lib-esm/components/Accordion/AccordionStep.js +41 -35
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -0
- package/lib-esm/components/Badge/Badge.d.ts +13 -16
- package/lib-esm/components/Badge/Badge.js +12 -21
- package/lib-esm/components/Badge/Badge.js.map +1 -0
- package/lib-esm/components/Button/ActionButton.d.ts +9 -5
- package/lib-esm/components/Button/ActionButton.js +20 -4
- package/lib-esm/components/Button/ActionButton.js.map +1 -0
- package/lib-esm/components/Button/Button.d.ts +9 -5
- package/lib-esm/components/Button/Button.js +19 -6
- package/lib-esm/components/Button/Button.js.map +1 -0
- package/lib-esm/components/Button/IconButton.d.ts +9 -5
- package/lib-esm/components/Button/IconButton.js +20 -4
- package/lib-esm/components/Button/IconButton.js.map +1 -0
- package/lib-esm/components/Button/LinkButton.d.ts +9 -5
- package/lib-esm/components/Button/LinkButton.js +20 -4
- package/lib-esm/components/Button/LinkButton.js.map +1 -0
- package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
- package/lib-esm/components/Button/RaisedButton.js +20 -4
- package/lib-esm/components/Button/RaisedButton.js.map +1 -0
- package/lib-esm/components/Card/Card.d.ts +4 -6
- package/lib-esm/components/Card/Card.js +18 -4
- package/lib-esm/components/Card/Card.js.map +1 -0
- package/lib-esm/components/Chip/Chip.d.ts +2 -2
- package/lib-esm/components/Chip/Chip.js +17 -10
- package/lib-esm/components/Chip/Chip.js.map +1 -0
- package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -39
- package/lib-esm/components/ChipInput/ChipInput.js +39 -39
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -0
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +5 -11
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -0
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
- package/lib-esm/components/Dialog/ConfirmDialog.js +5 -12
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -0
- package/lib-esm/components/Dialog/Dialog.d.ts +8 -14
- package/lib-esm/components/Dialog/Dialog.js +13 -10
- package/lib-esm/components/Dialog/Dialog.js.map +1 -0
- package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
- package/lib-esm/components/Dialog/PromptDialog.js +14 -21
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -0
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +37 -59
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +26 -28
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -0
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +2 -2
- package/lib-esm/components/DragAndDrop/DragItem.js +43 -40
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -0
- package/lib-esm/components/DragAndDrop/types.d.ts +3 -3
- package/lib-esm/components/DragAndDrop/types.js +1 -0
- package/lib-esm/components/DragAndDrop/types.js.map +1 -0
- package/lib-esm/components/Drawer/Drawer.d.ts +24 -31
- package/lib-esm/components/Drawer/Drawer.js +50 -45
- package/lib-esm/components/Drawer/Drawer.js.map +1 -0
- package/lib-esm/components/Groups/Group.d.ts +6 -8
- package/lib-esm/components/Groups/Group.js +15 -12
- package/lib-esm/components/Groups/Group.js.map +1 -0
- package/lib-esm/components/Groups/GroupLabel.js +2 -1
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -0
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +34 -29
- package/lib-esm/components/Input/Checkbox.js.map +1 -0
- package/lib-esm/components/Input/Dropdown.d.ts +8 -18
- package/lib-esm/components/Input/Dropdown.js +44 -18
- package/lib-esm/components/Input/Dropdown.js.map +1 -0
- package/lib-esm/components/Input/Input.d.ts +8 -3
- package/lib-esm/components/Input/Input.js +24 -22
- package/lib-esm/components/Input/Input.js.map +1 -0
- package/lib-esm/components/Input/Radio.d.ts +4 -8
- package/lib-esm/components/Input/Radio.js +20 -16
- package/lib-esm/components/Input/Radio.js.map +1 -0
- package/lib-esm/components/Input/RadioButton.d.ts +4 -8
- package/lib-esm/components/Input/RadioButton.js +19 -15
- package/lib-esm/components/Input/RadioButton.js.map +1 -0
- package/lib-esm/components/Input/Select.d.ts +6 -13
- package/lib-esm/components/Input/Select.js +26 -22
- package/lib-esm/components/Input/Select.js.map +1 -0
- package/lib-esm/components/Input/TextArea.d.ts +6 -13
- package/lib-esm/components/Input/TextArea.js +33 -27
- package/lib-esm/components/Input/TextArea.js.map +1 -0
- package/lib-esm/components/Input/Toggle.d.ts +4 -9
- package/lib-esm/components/Input/Toggle.js +15 -12
- package/lib-esm/components/Input/Toggle.js.map +1 -0
- package/lib-esm/components/Menu/Menu.d.ts +4 -14
- package/lib-esm/components/Menu/Menu.js +26 -17
- package/lib-esm/components/Menu/Menu.js.map +1 -0
- package/lib-esm/components/Menu/MenuContext.d.ts +4 -4
- package/lib-esm/components/Menu/MenuContext.js +2 -0
- package/lib-esm/components/Menu/MenuContext.js.map +1 -0
- package/lib-esm/components/Menu/MenuItem.d.ts +10 -4
- package/lib-esm/components/Menu/MenuItem.js +21 -6
- package/lib-esm/components/Menu/MenuItem.js.map +1 -0
- package/lib-esm/components/Modal/Modal.d.ts +17 -23
- package/lib-esm/components/Modal/Modal.js +38 -34
- package/lib-esm/components/Modal/Modal.js.map +1 -0
- package/lib-esm/components/Notification/Notification.d.ts +39 -34
- package/lib-esm/components/Notification/Notification.js +17 -39
- package/lib-esm/components/Notification/Notification.js.map +1 -0
- package/lib-esm/components/Notification/NotificationManager.d.ts +4 -4
- package/lib-esm/components/Notification/NotificationManager.js +19 -14
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -0
- 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 +21 -20
- package/lib-esm/components/Notification/style.js.map +1 -0
- package/lib-esm/components/Notification/types.js +1 -0
- package/lib-esm/components/Notification/types.js.map +1 -0
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +44 -45
- package/lib-esm/components/Popover/Popover.js.map +1 -0
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -15
- package/lib-esm/components/Spinner/Spinner.js +14 -14
- package/lib-esm/components/Spinner/Spinner.js.map +1 -0
- package/lib-esm/components/Stepper/Step.d.ts +15 -12
- package/lib-esm/components/Stepper/Step.js +12 -9
- package/lib-esm/components/Stepper/Step.js.map +1 -0
- package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
- package/lib-esm/components/Stepper/Stepper.js +30 -27
- package/lib-esm/components/Stepper/Stepper.js.map +1 -0
- package/lib-esm/components/Tabs/Tab.d.ts +10 -16
- package/lib-esm/components/Tabs/Tab.js +1 -8
- package/lib-esm/components/Tabs/Tab.js.map +1 -0
- package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
- package/lib-esm/components/Tabs/Tabs.js +43 -34
- package/lib-esm/components/Tabs/Tabs.js.map +1 -0
- package/lib-esm/components/Toast/Toast.d.ts +7 -7
- package/lib-esm/components/Toast/Toast.js +17 -15
- package/lib-esm/components/Toast/Toast.js.map +1 -0
- 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 +14 -23
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -0
- package/lib-esm/icons/CheckCircle.js +3 -2
- package/lib-esm/icons/CheckCircle.js.map +1 -0
- package/lib-esm/icons/Close.js +1 -0
- package/lib-esm/icons/Close.js.map +1 -0
- package/lib-esm/icons/DragIndicator.js +1 -0
- package/lib-esm/icons/DragIndicator.js.map +1 -0
- package/lib-esm/icons/ErrorOutline.js +3 -2
- package/lib-esm/icons/ErrorOutline.js.map +1 -0
- package/lib-esm/icons/ExpandMore.js +1 -0
- package/lib-esm/icons/ExpandMore.js.map +1 -0
- package/lib-esm/icons/FiberManualRecord.js +1 -0
- package/lib-esm/icons/FiberManualRecord.js.map +1 -0
- package/lib-esm/icons/Info.js +3 -2
- package/lib-esm/icons/Info.js.map +1 -0
- package/lib-esm/icons/ReportProblem.js +3 -2
- package/lib-esm/icons/ReportProblem.js.map +1 -0
- package/lib-esm/index.js +43 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/shared/LayerManager.d.ts +5 -4
- package/lib-esm/shared/LayerManager.js +125 -112
- package/lib-esm/shared/LayerManager.js.map +1 -0
- package/lib-esm/shared/constants.js +1 -0
- package/lib-esm/shared/constants.js.map +1 -0
- package/lib-esm/shared/styles.js +9 -8
- package/lib-esm/shared/styles.js.map +1 -0
- package/package.json +66 -31
- package/lib-esm/components/index.js +0 -42
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { useState, Children, isValidElement } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useState, Children, isValidElement } from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
6
5
|
import { Ellipsis } from '../../shared/styles.js';
|
|
7
6
|
import Badge, { BADGE_TYPE } from '../Badge/Badge.js';
|
|
8
7
|
|
|
9
|
-
const Container = /*#__PURE__*/ styled("div", {
|
|
10
|
-
target: "
|
|
8
|
+
const Container$1 = /*#__PURE__*/ styled("div", {
|
|
9
|
+
target: "e14em2c80",
|
|
11
10
|
label: "Container"
|
|
12
|
-
})("flex:1;display:flex;flex-direction:column;min-height:400px;"
|
|
11
|
+
})("flex:1;display:flex;flex-direction:column;min-height:400px;");
|
|
13
12
|
const Header = /*#__PURE__*/ styled("div", {
|
|
14
|
-
target: "
|
|
13
|
+
target: "e14em2c81",
|
|
15
14
|
label: "Header"
|
|
16
|
-
})("display:flex;flex-direction:row;justify-content:space-between;border-bottom:1px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";@media (min-width:601px){&::before{position:absolute;top:25px;left:0;right:0;height:2px;background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";content:' ';z-index:0;}}& > *{z-index:1;}"
|
|
15
|
+
})("display:flex;flex-direction:row;justify-content:space-between;border-bottom:1px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";@media (min-width:601px){&::before{position:absolute;top:25px;left:0;right:0;height:2px;background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";content:' ';z-index:0;}}& > *{z-index:1;}");
|
|
17
16
|
const HeaderButton = /*#__PURE__*/ styled("button", {
|
|
18
|
-
target: "
|
|
17
|
+
target: "e14em2c82",
|
|
19
18
|
label: "HeaderButton"
|
|
20
|
-
})("border:none;padding:16px 24px 16px 16px;font-size:16px;cursor:pointer;background-color:", (props)=>props.active ? getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR) : getThemeValue(THEME_NAME.BACKGROUND), ";font-weight:", (props)=>props.active ? 'bold' : 'normal', ";overflow:hidden;display:flex;align-items:center;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:disabled{cursor:not-allowed;background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:enabled:hover,&:focus{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHTER), ";}@media (max-width:600px){&{display:none;}}"
|
|
19
|
+
})("border:none;padding:16px 24px 16px 16px;font-size:16px;cursor:pointer;background-color:", (props)=>props.active ? getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR) : getThemeValue(THEME_NAME.BACKGROUND), ";font-weight:", (props)=>props.active ? 'bold' : 'normal', ";overflow:hidden;display:flex;align-items:center;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:disabled{cursor:not-allowed;background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:enabled:hover,&:focus{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHTER), ";}@media (max-width:600px){&{display:none;}}");
|
|
21
20
|
const MobileHeader = /*#__PURE__*/ styled("div", {
|
|
22
|
-
target: "
|
|
21
|
+
target: "e14em2c83",
|
|
23
22
|
label: "MobileHeader"
|
|
24
|
-
})("padding:16px;font-size:16px;line-height:18px;align-items:center;font-weight:bold;flex:1;display:flex;flex-direction:row;justify-content:space-between;@media (min-width:601px){&{display:none;}}"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
})("padding:16px;font-size:16px;line-height:18px;align-items:center;font-weight:bold;flex:1;display:flex;flex-direction:row;justify-content:space-between;@media (min-width:601px){&{display:none;}}");
|
|
24
|
+
/**
|
|
25
|
+
* Stepper Component
|
|
26
|
+
* @param props - Component props
|
|
27
|
+
* @param ref - Ref forwarded to the underlying HTMLDivElement
|
|
28
|
+
*/ function StepperComponent(props, ref) {
|
|
29
|
+
const { active: propsActive = 0, onStepClick, children, ...rest } = props;
|
|
30
|
+
const [active, setActive] = useState(propsActive);
|
|
28
31
|
const childrenArray = Children.toArray(children);
|
|
29
32
|
const stepRefs = [];
|
|
30
33
|
const stepClickHandler = (index)=>()=>{
|
|
@@ -55,7 +58,9 @@ function Stepper(props) {
|
|
|
55
58
|
stepRefs[prev]?.focus();
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
|
-
return /*#__PURE__*/ jsxs(Container, {
|
|
61
|
+
return /*#__PURE__*/ jsxs(Container$1, {
|
|
62
|
+
ref: ref,
|
|
63
|
+
...rest,
|
|
59
64
|
children: [
|
|
60
65
|
/*#__PURE__*/ jsxs(Header, {
|
|
61
66
|
role: "tablist",
|
|
@@ -63,24 +68,27 @@ function Stepper(props) {
|
|
|
63
68
|
children: [
|
|
64
69
|
Children.map(children, (child, index)=>{
|
|
65
70
|
if (!/*#__PURE__*/ isValidElement(child)) return null;
|
|
71
|
+
const reactElement = child;
|
|
66
72
|
return /*#__PURE__*/ jsxs(HeaderButton, {
|
|
67
|
-
ref: (el)=>
|
|
73
|
+
ref: (el)=>{
|
|
74
|
+
stepRefs[index] = el;
|
|
75
|
+
},
|
|
68
76
|
active: index === active,
|
|
69
77
|
type: "button",
|
|
70
78
|
role: "tab",
|
|
71
79
|
"aria-selected": index === active,
|
|
72
|
-
"aria-disabled": !!
|
|
80
|
+
"aria-disabled": !!reactElement.props.disabled,
|
|
73
81
|
tabIndex: index === active ? 0 : -1,
|
|
74
|
-
disabled:
|
|
82
|
+
disabled: reactElement.props.disabled,
|
|
75
83
|
onClick: stepClickHandler(index),
|
|
76
84
|
onKeyDown: onStepKeyDown(index),
|
|
77
85
|
children: [
|
|
78
86
|
/*#__PURE__*/ jsx(Badge, {
|
|
79
87
|
inline: true,
|
|
80
|
-
type: getBadgeType(index,
|
|
88
|
+
type: getBadgeType(index, reactElement.props.completed || false, reactElement.props.disabled || false)
|
|
81
89
|
}),
|
|
82
90
|
/*#__PURE__*/ jsx(Ellipsis, {
|
|
83
|
-
children:
|
|
91
|
+
children: reactElement.props.name
|
|
84
92
|
})
|
|
85
93
|
]
|
|
86
94
|
});
|
|
@@ -107,12 +115,7 @@ function Stepper(props) {
|
|
|
107
115
|
]
|
|
108
116
|
});
|
|
109
117
|
}
|
|
110
|
-
Stepper
|
|
111
|
-
/** Index of currently active step */ active: PropTypes.number,
|
|
112
|
-
/** Callback function for click event on a step */ onStepClick: PropTypes.func
|
|
113
|
-
};
|
|
114
|
-
Stepper.defaultProps = {
|
|
115
|
-
active: 0
|
|
116
|
-
};
|
|
118
|
+
const Stepper = /*#__PURE__*/ React.forwardRef(StepperComponent);
|
|
117
119
|
|
|
118
120
|
export { Stepper as default };
|
|
121
|
+
//# sourceMappingURL=Stepper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stepper.js","sources":["../../../src/components/Stepper/Stepper.tsx"],"sourcesContent":["import React, { Children, PropsWithChildren, useState, isValidElement } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { Ellipsis } from '../../shared/styles';\nimport { Badge, BADGE_TYPE } from '../Badge';\n\nconst Container = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n min-height: 400px;\n`;\n\nconst Header = styled.div`\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n\n @media (min-width: 601px) {\n &::before {\n position: absolute;\n top: 25px;\n left: 0;\n right: 0;\n height: 2px;\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n content: ' ';\n z-index: 0;\n }\n }\n\n & > * {\n z-index: 1;\n }\n`;\n\nconst HeaderButton = styled.button<{ active: boolean }>`\n border: none;\n padding: 16px 24px 16px 16px;\n font-size: 16px;\n cursor: pointer;\n background-color: ${(props) =>\n props.active\n ? getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)\n : getThemeValue(THEME_NAME.BACKGROUND)};\n font-weight: ${(props) => (props.active ? 'bold' : 'normal')};\n overflow: hidden;\n display: flex;\n align-items: center;\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};\n\n &:disabled {\n cursor: not-allowed;\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:enabled:hover,\n &:focus {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHTER)};\n }\n\n @media (max-width: 600px) {\n & {\n display: none;\n }\n }\n`;\n\nconst MobileHeader = styled.div`\n padding: 16px;\n font-size: 16px;\n line-height: 18px;\n align-items: center;\n font-weight: bold;\n flex: 1;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n @media (min-width: 601px) {\n & {\n display: none;\n }\n }\n`;\n\ntype StepperProps = PropsWithChildren<{\n /**\n * Index of currently active step\n * @default 0\n */\n active?: number;\n /** Callback function for click event on a step */\n onStepClick?: (index: number) => void;\n}> &\n React.HTMLAttributes<HTMLDivElement>;\n\n/**\n * Stepper Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\n */\nfunction StepperComponent(props: StepperProps, ref: React.Ref<HTMLDivElement>) {\n const { active: propsActive = 0, onStepClick, children, ...rest } = props;\n\n const [active, setActive] = useState(propsActive);\n const childrenArray = Children.toArray(children);\n const stepRefs = [] as Array<HTMLButtonElement | null>;\n\n const stepClickHandler = (index: number) => () => {\n setActive(index);\n onStepClick?.(index);\n // Move focus to the active step\n stepRefs[index]?.focus();\n };\n\n const getBadgeType = (index: number, completed: boolean, disabled: boolean) => {\n if (disabled) {\n return BADGE_TYPE.DISABLED;\n } else if (index === active) {\n return BADGE_TYPE.PRIMARY;\n } else if (completed) {\n return BADGE_TYPE.SUCCESS;\n }\n return BADGE_TYPE.DISABLED;\n };\n\n // Keyboard navigation for step buttons\n const onStepKeyDown = (index: number) => (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {\n e.preventDefault();\n const next = (index + 1) % childrenArray.length;\n stepRefs[next]?.focus();\n } else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {\n e.preventDefault();\n const prev = (index - 1 + childrenArray.length) % childrenArray.length;\n stepRefs[prev]?.focus();\n }\n };\n\n return (\n <Container ref={ref} {...rest}>\n <Header role=\"tablist\" aria-label=\"Stepper Steps\">\n {Children.map(children, (child, index) => {\n if (!isValidElement(child)) return null;\n const reactElement = child as React.ReactElement<{\n disabled?: boolean;\n completed?: boolean;\n name?: string;\n }>;\n return (\n <HeaderButton\n ref={(el) => {\n stepRefs[index] = el;\n }}\n active={index === active}\n type=\"button\"\n role=\"tab\"\n aria-selected={index === active}\n aria-disabled={!!reactElement.props.disabled}\n tabIndex={index === active ? 0 : -1}\n disabled={reactElement.props.disabled}\n onClick={stepClickHandler(index)}\n onKeyDown={onStepKeyDown(index)}\n >\n <Badge\n inline\n type={getBadgeType(\n index,\n reactElement.props.completed || false,\n reactElement.props.disabled || false,\n )}\n />\n <Ellipsis>{reactElement.props.name}</Ellipsis>\n </HeaderButton>\n );\n })}\n <MobileHeader>\n <span>\n {isValidElement(childrenArray[active])\n ? (childrenArray[active] as React.ReactElement<{ name?: string }>).props\n .name\n : ''}\n </span>\n <Badge inline type={BADGE_TYPE.PRIMARY}>\n {active + 1} of {Children.count(children)}\n </Badge>\n </MobileHeader>\n </Header>\n {childrenArray[active]}\n </Container>\n );\n}\n\nconst Stepper = React.forwardRef(StepperComponent);\nexport default Stepper;\n"],"names":["Container","styled","Header","getThemeValue","THEME_NAME","BORDER_LIGHT_COLOR","LIGHT_GREY","HeaderButton","props","active","BACKGROUND","TEXT_COLOR_DARK","DISABLED_BACKGROUND","PRIMARY_LIGHTER","MobileHeader","StepperComponent","ref","propsActive","onStepClick","children","rest","setActive","useState","childrenArray","Children","toArray","stepRefs","stepClickHandler","index","focus","getBadgeType","completed","disabled","BADGE_TYPE","DISABLED","PRIMARY","SUCCESS","onStepKeyDown","e","key","preventDefault","next","length","prev","_jsxs","role","aria-label","map","child","isValidElement","reactElement","el","type","aria-selected","aria-disabled","tabIndex","onClick","onKeyDown","_jsx","Badge","inline","Ellipsis","name","span","count","Stepper","React","forwardRef"],"mappings":";;;;;;;AAMA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAOlB,MAAMC,MAAAA,iBAASD,MAAAA,CAAAA,KAAAA,EAAAA;;;AAIgBE,CAAAA,CAAAA,CAAAA,wFAAAA,EAAAA,aAAAA,CAAcC,UAAAA,CAAWC,kBAAkB,CAAA,EAAA,4GAAA,EAS1CF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,4CA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cAAAA,CAAe1B,aAAa,CAACd,MAAAA,CAAO,CAAA,GAC9Bc,aAAa,CAACd,MAAAA,CAAO,CAA2CD,KAAK,CACjEsD,IAAI,GACT;;0CAEVlB,IAAA,CAACe,KAAAA,EAAAA;gCAAMC,MAAM,EAAA,IAAA;AAACR,gCAAAA,IAAAA,EAAMnB,WAAWE,OAAO;;oCACjC1B,MAAAA,GAAS,CAAA;AAAE,oCAAA,MAAA;AAAKe,oCAAAA,QAAAA,CAASwC,KAAK,CAAC7C,QAAAA;;;;;;;AAI3CI,YAAAA,aAAa,CAACd,MAAAA;;;AAG3B;AAEA,MAAMwD,OAAAA,iBAAUC,KAAAA,CAAMC,UAAU,CAACpD,gBAAAA;;;;"}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
13
|
-
};
|
|
14
|
-
defaultProps: {
|
|
15
|
-
disabled: boolean;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
2
|
+
type TabProps = PropsWithChildren<{
|
|
3
|
+
/** Name of the tab. This shown in the tab's button */
|
|
4
|
+
name: string;
|
|
5
|
+
/**
|
|
6
|
+
* If the tab is disabled
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
declare const Tab: (props: TabProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
12
|
export default Tab;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
|
|
4
3
|
const Tab = (props)=>{
|
|
5
4
|
const { children } = props;
|
|
@@ -7,12 +6,6 @@ const Tab = (props)=>{
|
|
|
7
6
|
children: children
|
|
8
7
|
});
|
|
9
8
|
};
|
|
10
|
-
Tab.propTypes = {
|
|
11
|
-
/** Name of the tab. This shown in the tab's button */ name: PropTypes.string.isRequired,
|
|
12
|
-
/** If the tab is disabled */ disabled: PropTypes.bool
|
|
13
|
-
};
|
|
14
|
-
Tab.defaultProps = {
|
|
15
|
-
disabled: false
|
|
16
|
-
};
|
|
17
9
|
|
|
18
10
|
export { Tab as default };
|
|
11
|
+
//# sourceMappingURL=Tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.js","sources":["../../../src/components/Tabs/Tab.tsx"],"sourcesContent":["import { PropsWithChildren } from 'react';\n\ntype TabProps = PropsWithChildren<{\n /** Name of the tab. This shown in the tab's button */\n name: string;\n /**\n * If the tab is disabled\n * @default false\n */\n disabled?: boolean;\n}>;\n\nconst Tab = (props: TabProps) => {\n const { children } = props;\n return <>{children}</>;\n};\n\nexport default Tab;\n"],"names":["Tab","props","children","_jsx","_Fragment"],"mappings":";;AAYA,MAAMA,MAAM,CAACC,KAAAA,GAAAA;IACT,MAAM,EAAEC,QAAQ,EAAE,GAAGD,KAAAA;IACrB,qBAAOE,GAAA,CAAAC,QAAA,EAAA;AAAGF,QAAAA,QAAAA,EAAAA;;AACd;;;;"}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const Tabs: import("react").ForwardRefExoticComponent<{
|
|
2
|
+
/**
|
|
3
|
+
* Active Tab Index
|
|
4
|
+
* @default 0
|
|
5
|
+
*/
|
|
4
6
|
active?: number;
|
|
7
|
+
/** OnChange event handler */
|
|
5
8
|
onChange?: (index: number) => void;
|
|
6
|
-
|
|
7
|
-
bodyProps?:
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var propTypes: {
|
|
12
|
-
/** Active Tab Index */
|
|
13
|
-
active: PropTypes.Requireable<number>;
|
|
14
|
-
/** OnChange event handler */
|
|
15
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
-
/** Props for div that contains tab buttons */
|
|
17
|
-
props: PropTypes.Requireable<object>;
|
|
18
|
-
/** Props for div that contains tab body */
|
|
19
|
-
bodyProps: PropTypes.Requireable<object>;
|
|
20
|
-
};
|
|
21
|
-
var defaultProps: {
|
|
22
|
-
active: number;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
9
|
+
/** Props for div that contains tab body */
|
|
10
|
+
bodyProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
11
|
+
} & {
|
|
12
|
+
children?: import("react").ReactNode | undefined;
|
|
13
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
14
|
export default Tabs;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { useState, Children, useEffect, isValidElement } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import { forwardRef, useState, Children, useEffect, isValidElement } from 'react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
6
5
|
|
|
7
6
|
const Button = /*#__PURE__*/ styled("button", {
|
|
8
|
-
target: "
|
|
7
|
+
target: "ewz2woa0",
|
|
9
8
|
label: "Button"
|
|
10
|
-
})("background-color:transparent;border:none;padding:8px 12px;font-size:14px;border-radius:3px 3px 0 0;border-bottom:", (props)=>props.active ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}` : 'none', ";color:", (props)=>props.active ? getThemeValue(THEME_NAME.PRIMARY) : getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";cursor:pointer;&:hover,&:focus{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHTER), ";border-bottom:", (props)=>props.active ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}` : `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}`, ";}&[disabled]{background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";color:", getThemeValue(THEME_NAME.DISABLED), ";border-bottom:3px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}"
|
|
9
|
+
})("background-color:transparent;border:none;padding:8px 12px;font-size:14px;border-radius:3px 3px 0 0;border-bottom:", (props)=>props.active ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}` : 'none', ";color:", (props)=>props.active ? getThemeValue(THEME_NAME.PRIMARY) : getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";cursor:pointer;&:hover,&:focus{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHTER), ";border-bottom:", (props)=>props.active ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}` : `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}`, ";}&[disabled]{background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";color:", getThemeValue(THEME_NAME.DISABLED), ";border-bottom:3px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}");
|
|
11
10
|
const ButtonContainer = /*#__PURE__*/ styled("div", {
|
|
12
|
-
target: "
|
|
11
|
+
target: "ewz2woa1",
|
|
13
12
|
label: "ButtonContainer"
|
|
14
|
-
})("border-bottom:1px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";margin-bottom:5px;position:relative;"
|
|
13
|
+
})("border-bottom:1px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";margin-bottom:5px;position:relative;");
|
|
15
14
|
const TabBody = /*#__PURE__*/ styled("div", {
|
|
16
|
-
target: "
|
|
15
|
+
target: "ewz2woa2",
|
|
17
16
|
label: "TabBody"
|
|
18
|
-
})("min-height:150px;"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
})("min-height:150px;");
|
|
18
|
+
/**
|
|
19
|
+
* Tabs Component
|
|
20
|
+
* @param props - Component props
|
|
21
|
+
* @param ref - Ref forwarded to the underlying HTMLDivElement
|
|
22
|
+
*/ function TabsComponent(props, ref) {
|
|
23
|
+
const { active: propsActive = 0, onChange, bodyProps, children, ...rest } = props;
|
|
24
|
+
const [active, setActive] = useState(propsActive);
|
|
22
25
|
const tabRefs = [];
|
|
23
26
|
const childrenArray = Children.toArray(children);
|
|
24
27
|
const switchTab = (index)=>()=>{
|
|
25
28
|
setActive(index);
|
|
26
29
|
tabRefs[index]?.focus();
|
|
27
|
-
|
|
30
|
+
onChange?.(index);
|
|
28
31
|
};
|
|
29
32
|
// Keyboard navigation for tab buttons
|
|
30
33
|
const onTabKeyDown = (index)=>(e)=>{
|
|
@@ -39,29 +42,41 @@ function Tabs(props) {
|
|
|
39
42
|
}
|
|
40
43
|
};
|
|
41
44
|
useEffect(()=>{
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
if (propsActive !== undefined) {
|
|
46
|
+
setActive(propsActive);
|
|
47
|
+
onChange?.(propsActive);
|
|
48
|
+
}
|
|
44
49
|
}, [
|
|
45
|
-
|
|
50
|
+
propsActive,
|
|
51
|
+
onChange
|
|
46
52
|
]);
|
|
47
53
|
// Generate unique IDs for tabs and panels using sanitized tab name and index
|
|
48
54
|
const sanitize = (str)=>str.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase();
|
|
49
55
|
const tabIds = childrenArray.map((child, i)=>{
|
|
50
56
|
const name = /*#__PURE__*/ isValidElement(child) && child.props.name ? child.props.name : `tab${i}`;
|
|
51
|
-
return `nfui-tab-${sanitize(name)}-${i}`;
|
|
57
|
+
return `nfui-tab-${sanitize(name || '')}-${i}`;
|
|
52
58
|
});
|
|
53
59
|
const panelIds = childrenArray.map((child, i)=>{
|
|
54
60
|
const name = /*#__PURE__*/ isValidElement(child) && child.props.name ? child.props.name : `tab${i}`;
|
|
55
|
-
return `nfui-tabpanel-${sanitize(name)}-${i}`;
|
|
61
|
+
return `nfui-tabpanel-${sanitize(name || '')}-${i}`;
|
|
56
62
|
});
|
|
63
|
+
// Sanity check for active index
|
|
64
|
+
if (active === undefined || active < 0 || active >= childrenArray.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
57
67
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
58
68
|
children: [
|
|
59
69
|
/*#__PURE__*/ jsx(ButtonContainer, {
|
|
60
70
|
role: "tablist",
|
|
61
71
|
"aria-label": "Tabs",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
ref: ref,
|
|
73
|
+
...rest,
|
|
74
|
+
children: childrenArray.map((child, index)=>{
|
|
75
|
+
const reactElement = child;
|
|
76
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
77
|
+
ref: (el)=>{
|
|
78
|
+
tabRefs[index] = el;
|
|
79
|
+
},
|
|
65
80
|
id: tabIds[index],
|
|
66
81
|
type: "button",
|
|
67
82
|
role: "tab",
|
|
@@ -71,30 +86,24 @@ function Tabs(props) {
|
|
|
71
86
|
active: active === index,
|
|
72
87
|
onClick: switchTab(index),
|
|
73
88
|
onKeyDown: onTabKeyDown(index),
|
|
74
|
-
disabled: /*#__PURE__*/ isValidElement(child) ?
|
|
75
|
-
"aria-disabled": /*#__PURE__*/ isValidElement(child) ?
|
|
76
|
-
children: /*#__PURE__*/ isValidElement(child) ?
|
|
77
|
-
}, tabIds[index])
|
|
89
|
+
disabled: /*#__PURE__*/ isValidElement(child) ? reactElement.props.disabled : false,
|
|
90
|
+
"aria-disabled": /*#__PURE__*/ isValidElement(child) ? reactElement.props.disabled : false,
|
|
91
|
+
children: /*#__PURE__*/ isValidElement(child) ? reactElement.props.name : ''
|
|
92
|
+
}, tabIds[index]);
|
|
93
|
+
})
|
|
78
94
|
}),
|
|
79
95
|
/*#__PURE__*/ jsx(TabBody, {
|
|
96
|
+
...bodyProps,
|
|
80
97
|
id: panelIds[active],
|
|
81
98
|
role: "tabpanel",
|
|
82
99
|
"aria-labelledby": tabIds[active],
|
|
83
100
|
tabIndex: 0,
|
|
84
|
-
...props.bodyProps,
|
|
85
101
|
children: childrenArray[active]
|
|
86
102
|
})
|
|
87
103
|
]
|
|
88
104
|
});
|
|
89
105
|
}
|
|
90
|
-
Tabs
|
|
91
|
-
/** Active Tab Index */ active: PropTypes.number,
|
|
92
|
-
/** OnChange event handler */ onChange: PropTypes.func,
|
|
93
|
-
/** Props for div that contains tab buttons */ props: PropTypes.object,
|
|
94
|
-
/** Props for div that contains tab body */ bodyProps: PropTypes.object
|
|
95
|
-
};
|
|
96
|
-
Tabs.defaultProps = {
|
|
97
|
-
active: 0
|
|
98
|
-
};
|
|
106
|
+
const Tabs = /*#__PURE__*/ forwardRef(TabsComponent);
|
|
99
107
|
|
|
100
108
|
export { Tabs as default };
|
|
109
|
+
//# sourceMappingURL=Tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import {\n useState,\n Children,\n useEffect,\n PropsWithChildren,\n isValidElement,\n forwardRef,\n} from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Button = styled.button<{ active: boolean }>`\n background-color: transparent;\n border: none;\n padding: 8px 12px;\n font-size: 14px;\n border-radius: 3px 3px 0 0;\n border-bottom: ${(props) =>\n props.active ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}` : 'none'};\n color: ${(props) =>\n props.active\n ? getThemeValue(THEME_NAME.PRIMARY)\n : getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};\n cursor: pointer;\n\n &:hover,\n &:focus {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHTER)};\n border-bottom: ${(props) =>\n props.active\n ? `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}`\n : `3px solid ${getThemeValue(THEME_NAME.PRIMARY)}`};\n }\n\n &[disabled] {\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n border-bottom: 3px solid ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n`;\n\nconst ButtonContainer = styled.div`\n border-bottom: 1px solid ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n margin-bottom: 5px;\n position: relative;\n`;\n\nconst TabBody = styled.div`\n min-height: 150px;\n`;\n\ntype ITabsProps = PropsWithChildren<{\n /**\n * Active Tab Index\n * @default 0\n */\n active?: number;\n /** OnChange event handler */\n onChange?: (index: number) => void;\n /** Props for div that contains tab body */\n bodyProps?: React.HTMLAttributes<HTMLDivElement>;\n}>;\n\n/**\n * Tabs Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\n */\nfunction TabsComponent(props: ITabsProps, ref: React.Ref<HTMLDivElement>) {\n const { active: propsActive = 0, onChange, bodyProps, children, ...rest } = props;\n const [active, setActive] = useState(propsActive);\n const tabRefs = [] as Array<HTMLButtonElement | null>;\n const childrenArray = Children.toArray(children);\n\n const switchTab = (index: number) => () => {\n setActive(index);\n tabRefs[index]?.focus();\n onChange?.(index);\n };\n\n // Keyboard navigation for tab buttons\n const onTabKeyDown = (index: number) => (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {\n e.preventDefault();\n const next = (index + 1) % childrenArray.length;\n tabRefs[next]?.focus();\n } else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {\n e.preventDefault();\n const prev = (index - 1 + childrenArray.length) % childrenArray.length;\n tabRefs[prev]?.focus();\n }\n };\n\n useEffect(() => {\n if (propsActive !== undefined) {\n setActive(propsActive);\n onChange?.(propsActive);\n }\n }, [propsActive, onChange]);\n\n // Generate unique IDs for tabs and panels using sanitized tab name and index\n const sanitize = (str: string) => str.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase();\n const tabIds = childrenArray.map((child, i) => {\n const name =\n isValidElement(child) && (child as React.ReactElement<{ name?: string }>).props.name\n ? (child as React.ReactElement<{ name?: string }>).props.name\n : `tab${i}`;\n return `nfui-tab-${sanitize(name || '')}-${i}`;\n });\n const panelIds = childrenArray.map((child, i) => {\n const name =\n isValidElement(child) && (child as React.ReactElement<{ name?: string }>).props.name\n ? (child as React.ReactElement<{ name?: string }>).props.name\n : `tab${i}`;\n return `nfui-tabpanel-${sanitize(name || '')}-${i}`;\n });\n\n // Sanity check for active index\n if (active === undefined || active < 0 || active >= childrenArray.length) {\n return null;\n }\n\n return (\n <>\n <ButtonContainer role=\"tablist\" aria-label=\"Tabs\" ref={ref} {...rest}>\n {childrenArray.map((child, index) => {\n const reactElement = child as React.ReactElement<{\n disabled?: boolean;\n name?: string;\n }>;\n return (\n <Button\n key={tabIds[index]}\n ref={(el) => {\n tabRefs[index] = el;\n }}\n id={tabIds[index]}\n type=\"button\"\n role=\"tab\"\n aria-selected={active === index}\n aria-controls={panelIds[index]}\n tabIndex={active === index ? 0 : -1}\n active={active === index}\n onClick={switchTab(index)}\n onKeyDown={onTabKeyDown(index)}\n disabled={isValidElement(child) ? reactElement.props.disabled : false}\n aria-disabled={\n isValidElement(child) ? reactElement.props.disabled : false\n }\n >\n {isValidElement(child) ? reactElement.props.name : ''}\n </Button>\n );\n })}\n </ButtonContainer>\n <TabBody\n {...bodyProps}\n id={panelIds[active]}\n role=\"tabpanel\"\n aria-labelledby={tabIds[active]}\n tabIndex={0}\n >\n {childrenArray[active]}\n </TabBody>\n </>\n );\n}\n\nconst Tabs = forwardRef(TabsComponent);\nexport default Tabs;\n"],"names":["Button","styled","props","active","getThemeValue","THEME_NAME","PRIMARY","TEXT_COLOR_DARK","PRIMARY_LIGHTER","DISABLED_BACKGROUND","DISABLED","DISABLED_BORDER","ButtonContainer","TabBody","TabsComponent","ref","propsActive","onChange","bodyProps","children","rest","setActive","useState","tabRefs","childrenArray","Children","toArray","switchTab","index","focus","onTabKeyDown","e","key","preventDefault","next","length","prev","useEffect","undefined","sanitize","str","replace","toLowerCase","tabIds","map","child","i","name","isValidElement","panelIds","_jsxs","_Fragment","_jsx","role","aria-label","reactElement","el","id","type","aria-selected","a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AAAA,MAAM,CAACf,KAAAA,CAAM,CAAA;AAqB9B,gBAAA,CAAA;;0BAEJwB,GAAA,CAACvC,OAAAA,EAAAA;AACI,gBAAA,GAAGK,SAAS;gBACbuC,EAAAA,EAAIR,QAAQ,CAAC9C,MAAAA,CAAO;gBACpBkD,IAAAA,EAAK,UAAA;gBACLa,iBAAAA,EAAiBvB,MAAM,CAACxC,MAAAA,CAAO;gBAC/B0D,QAAAA,EAAU,CAAA;AAETrC,gBAAAA,QAAAA,EAAAA,aAAa,CAACrB,MAAAA;;;;AAI/B;AAEA,MAAMgE,qBAAOC,UAAAA,CAAWtD,aAAAA;;;;"}
|
|
@@ -13,13 +13,13 @@ export declare enum TOAST_TYPE {
|
|
|
13
13
|
DANGER = "DANGER"
|
|
14
14
|
}
|
|
15
15
|
declare class Toast {
|
|
16
|
-
private element
|
|
17
|
-
private ariaLiveContainer
|
|
18
|
-
private toast
|
|
19
|
-
private timeout
|
|
20
|
-
private root
|
|
21
|
-
private politeRegion
|
|
22
|
-
private assertiveRegion
|
|
16
|
+
private element?;
|
|
17
|
+
private ariaLiveContainer?;
|
|
18
|
+
private toast?;
|
|
19
|
+
private timeout?;
|
|
20
|
+
private root?;
|
|
21
|
+
private politeRegion?;
|
|
22
|
+
private assertiveRegion?;
|
|
23
23
|
private isPaused;
|
|
24
24
|
private currentOptions;
|
|
25
25
|
constructor();
|