no-frills-ui 0.0.14-alpha.4 → 0.0.14-alpha.5
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 +1335 -493
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.js +11 -29
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.js +7 -7
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts.map +1 -1
- package/lib-esm/components/Button/ActionButton.js +12 -11
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts.map +1 -1
- package/lib-esm/components/Button/Button.js +14 -13
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts.map +1 -1
- package/lib-esm/components/Button/IconButton.js +15 -14
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts.map +1 -1
- package/lib-esm/components/Button/LinkButton.js +7 -6
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts.map +1 -1
- package/lib-esm/components/Button/RaisedButton.js +15 -14
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts.map +1 -1
- package/lib-esm/components/Card/Card.js +4 -4
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.js +8 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.js +20 -20
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.js +4 -1
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +26 -1
- package/lib-esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib-esm/components/Dialog/Dialog.js +84 -1
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.js +8 -8
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +76 -1
- package/lib-esm/components/Drawer/Drawer.d.ts.map +1 -1
- package/lib-esm/components/Drawer/Drawer.js +158 -24
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts.map +1 -1
- package/lib-esm/components/Groups/Group.js +10 -8
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.d.ts.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.js +3 -3
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts.map +1 -1
- package/lib-esm/components/Input/Checkbox.js +63 -58
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +8 -0
- package/lib-esm/components/Input/Dropdown.d.ts.map +1 -1
- package/lib-esm/components/Input/Dropdown.js +54 -31
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts.map +1 -1
- package/lib-esm/components/Input/Input.js +27 -21
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts.map +1 -1
- package/lib-esm/components/Input/Radio.js +58 -42
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts.map +1 -1
- package/lib-esm/components/Input/RadioButton.js +12 -12
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts.map +1 -1
- package/lib-esm/components/Input/Select.js +27 -21
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts.map +1 -1
- package/lib-esm/components/Input/TextArea.js +27 -21
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts.map +1 -1
- package/lib-esm/components/Input/Toggle.js +17 -14
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +13 -1
- package/lib-esm/components/Menu/Menu.d.ts.map +1 -1
- package/lib-esm/components/Menu/Menu.js +98 -3
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +6 -3
- package/lib-esm/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib-esm/components/Menu/MenuItem.js +10 -10
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +70 -1
- package/lib-esm/components/Modal/Modal.d.ts.map +1 -1
- package/lib-esm/components/Modal/Modal.js +145 -11
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +3 -1
- package/lib-esm/components/Notification/Notification.d.ts.map +1 -1
- package/lib-esm/components/Notification/Notification.js +4 -2
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +11 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.js +43 -8
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +4 -0
- package/lib-esm/components/Notification/style.d.ts.map +1 -1
- package/lib-esm/components/Notification/style.js +30 -15
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Notification/types.d.ts +2 -0
- package/lib-esm/components/Notification/types.d.ts.map +1 -1
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts.map +1 -1
- package/lib-esm/components/Popover/Popover.js +17 -2
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +3 -0
- package/lib-esm/components/Spinner/Spinner.d.ts.map +1 -1
- package/lib-esm/components/Spinner/Spinner.js +19 -4
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts.map +1 -1
- package/lib-esm/components/Stepper/Stepper.js +29 -10
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib-esm/components/Tabs/Tabs.js +45 -12
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +25 -4
- package/lib-esm/components/Toast/Toast.d.ts.map +1 -1
- package/lib-esm/components/Toast/Toast.js +114 -18
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib-esm/components/Tooltip/Tooltip.js +16 -5
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts.map +1 -1
- package/lib-esm/shared/LayerManager.js +63 -1
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +58 -27
- package/lib-esm/shared/constants.d.ts.map +1 -1
- package/lib-esm/shared/constants.js +88 -25
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.d.ts.map +1 -1
- package/lib-esm/shared/styles.js +5 -3
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import
|
|
2
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
3
3
|
import { Card } from '../Card';
|
|
4
4
|
import { NOTIFICATION_POSITION, NOTIFICATION_TYPE } from './types';
|
|
5
5
|
const getEntryAnimation = (position) => {
|
|
@@ -23,37 +23,37 @@ const getExitAnimation = (position) => {
|
|
|
23
23
|
const getBorderColor = (type) => {
|
|
24
24
|
switch (type) {
|
|
25
25
|
case NOTIFICATION_TYPE.SUCCESS:
|
|
26
|
-
return
|
|
26
|
+
return getThemeValue(THEME_NAME.SUCCESS_LIGHT);
|
|
27
27
|
case NOTIFICATION_TYPE.DANGER:
|
|
28
|
-
return
|
|
28
|
+
return getThemeValue(THEME_NAME.ERROR_LIGHT);
|
|
29
29
|
case NOTIFICATION_TYPE.WARNING:
|
|
30
|
-
return
|
|
30
|
+
return getThemeValue(THEME_NAME.WARNING_LIGHT);
|
|
31
31
|
default:
|
|
32
|
-
return
|
|
32
|
+
return getThemeValue(THEME_NAME.INFO_LIGHT);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const getTitleColor = (type) => {
|
|
36
36
|
switch (type) {
|
|
37
37
|
case NOTIFICATION_TYPE.SUCCESS:
|
|
38
|
-
return
|
|
38
|
+
return getThemeValue(THEME_NAME.SUCCESS);
|
|
39
39
|
case NOTIFICATION_TYPE.DANGER:
|
|
40
|
-
return
|
|
40
|
+
return getThemeValue(THEME_NAME.ERROR);
|
|
41
41
|
case NOTIFICATION_TYPE.WARNING:
|
|
42
|
-
return
|
|
42
|
+
return getThemeValue(THEME_NAME.WARNING);
|
|
43
43
|
case NOTIFICATION_TYPE.INFO:
|
|
44
|
-
return
|
|
44
|
+
return getThemeValue(THEME_NAME.INFO);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const getTypeStyle = (type) => {
|
|
48
48
|
switch (type) {
|
|
49
49
|
case NOTIFICATION_TYPE.INFO:
|
|
50
|
-
return `color:
|
|
50
|
+
return `color: ${getThemeValue(THEME_NAME.INFO)}`;
|
|
51
51
|
case NOTIFICATION_TYPE.SUCCESS:
|
|
52
|
-
return `color:
|
|
52
|
+
return `color: ${getThemeValue(THEME_NAME.SUCCESS)}`;
|
|
53
53
|
case NOTIFICATION_TYPE.DANGER:
|
|
54
|
-
return `color:
|
|
54
|
+
return `color: ${getThemeValue(THEME_NAME.ERROR)}`;
|
|
55
55
|
case NOTIFICATION_TYPE.WARNING:
|
|
56
|
-
return `color:
|
|
56
|
+
return `color: ${getThemeValue(THEME_NAME.WARNING)}`;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
export const Container = styled.div `
|
|
@@ -64,6 +64,7 @@ export const Container = styled.div `
|
|
|
64
64
|
: 'column-reverse'};
|
|
65
65
|
`;
|
|
66
66
|
export const Notice = styled(Card) `
|
|
67
|
+
position: relative;
|
|
67
68
|
border-radius: 3px;
|
|
68
69
|
border-left: 4px solid ${(props) => getBorderColor(props.type)};
|
|
69
70
|
width: 300px;
|
|
@@ -150,13 +151,16 @@ export const FillParent = styled.div `
|
|
|
150
151
|
flex: 1;
|
|
151
152
|
`;
|
|
152
153
|
export const CloseButton = styled.button `
|
|
154
|
+
position: absolute;
|
|
153
155
|
background-color: transparent;
|
|
154
156
|
border: none;
|
|
155
|
-
padding:
|
|
157
|
+
padding: 0;
|
|
158
|
+
top: 4px;
|
|
159
|
+
right: 4px;
|
|
156
160
|
cursor: pointer;
|
|
157
161
|
|
|
158
162
|
&:focus {
|
|
159
|
-
box-shadow: 0 0 0 3px
|
|
163
|
+
box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};
|
|
160
164
|
border-radius: 3px;
|
|
161
165
|
}
|
|
162
166
|
`;
|
|
@@ -173,4 +177,15 @@ export const Footer = styled.div `
|
|
|
173
177
|
justify-content: flex-end;
|
|
174
178
|
padding: 0 5px;
|
|
175
179
|
`;
|
|
180
|
+
export const VisuallyHidden = styled.span `
|
|
181
|
+
position: absolute;
|
|
182
|
+
width: 1px;
|
|
183
|
+
height: 1px;
|
|
184
|
+
padding: 0;
|
|
185
|
+
margin: -1px;
|
|
186
|
+
overflow: hidden;
|
|
187
|
+
clip: rect(0, 0, 0, 0);
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
border: 0;
|
|
190
|
+
`;
|
|
176
191
|
//# sourceMappingURL=style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/components/Notification/style.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/components/Notification/style.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAuB,MAAM,SAAS,CAAC;AAExF,MAAM,iBAAiB,GAAG,CAAC,QAA+B,EAAE,EAAE;IAC1D,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,qBAAqB,CAAC,QAAQ,CAAC;QACpC,KAAK,qBAAqB,CAAC,WAAW;YAClC,OAAO,SAAS,CAAC;QACrB;YACI,OAAO,UAAU,CAAC;IAC1B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,QAA+B,EAAE,EAAE;IACzD,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,qBAAqB,CAAC,QAAQ,CAAC;QACpC,KAAK,qBAAqB,CAAC,WAAW;YAClC,OAAO,UAAU,CAAC;QACtB;YACI,OAAO,WAAW,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAuB,EAAE,EAAE;IAC/C,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,iBAAiB,CAAC,OAAO;YAC1B,OAAO,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACnD,KAAK,iBAAiB,CAAC,MAAM;YACzB,OAAO,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACjD,KAAK,iBAAiB,CAAC,OAAO;YAC1B,OAAO,aA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C,IAAI,CAAA;;;;;;;;;;CAUxC,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { Card } from '../Card';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\nconst getEntryAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'in-left';\n default:\n return 'in-right';\n }\n};\n\nconst getExitAnimation = (position: NOTIFICATION_POSITION) => {\n switch (position) {\n case NOTIFICATION_POSITION.TOP_LEFT:\n case NOTIFICATION_POSITION.BOTTOM_LEFT:\n return 'out-left';\n default:\n return 'out-right';\n }\n};\n\nconst getBorderColor = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.SUCCESS:\n return getThemeValue(THEME_NAME.SUCCESS_LIGHT);\n case NOTIFICATION_TYPE.DANGER:\n return getThemeValue(THEME_NAME.ERROR_LIGHT);\n case NOTIFICATION_TYPE.WARNING:\n return getThemeValue(THEME_NAME.WARNING_LIGHT);\n default:\n return getThemeValue(THEME_NAME.INFO_LIGHT);\n }\n};\n\nconst getTitleColor = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.SUCCESS:\n return getThemeValue(THEME_NAME.SUCCESS);\n case NOTIFICATION_TYPE.DANGER:\n return getThemeValue(THEME_NAME.ERROR);\n case NOTIFICATION_TYPE.WARNING:\n return getThemeValue(THEME_NAME.WARNING);\n case NOTIFICATION_TYPE.INFO:\n return getThemeValue(THEME_NAME.INFO);\n }\n};\n\nconst getTypeStyle = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.INFO:\n return `color: ${getThemeValue(THEME_NAME.INFO)}`;\n case NOTIFICATION_TYPE.SUCCESS:\n return `color: ${getThemeValue(THEME_NAME.SUCCESS)}`;\n case NOTIFICATION_TYPE.DANGER:\n return `color: ${getThemeValue(THEME_NAME.ERROR)}`;\n case NOTIFICATION_TYPE.WARNING:\n return `color: ${getThemeValue(THEME_NAME.WARNING)}`;\n }\n};\n\ninterface NoticeProp extends NotificationOptions {\n position: NOTIFICATION_POSITION;\n}\n\nexport const Container = styled.div<{ position: NOTIFICATION_POSITION }>`\n display: flex;\n flex-direction: ${(props) =>\n props.position === NOTIFICATION_POSITION.TOP_LEFT ||\n props.position === NOTIFICATION_POSITION.TOP_RIGHT\n ? 'column'\n : 'column-reverse'};\n`;\n\nexport const Notice = styled(Card)<NoticeProp>`\n position: relative;\n border-radius: 3px;\n border-left: 4px solid ${(props) => getBorderColor(props.type)};\n width: 300px;\n display: flex;\n padding: 0 5px 5px 0;\n overflow: hidden;\n animation: ${(props) => getEntryAnimation(props.position)} 0.6s ease;\n\n & svg {\n fill: currentColor;\n vertical-align: middle;\n width: 20px;\n height: 20px;\n }\n\n &.leave {\n animation: ${(props) => getExitAnimation(props.position)} 0.6s;\n }\n\n @keyframes in-right {\n from {\n transform: translateX(100%);\n max-height: 0;\n opacity: 0;\n }\n\n to {\n transform: translateX(0%);\n max-height: 150px;\n opacity: 1;\n }\n }\n\n @keyframes out-right {\n to {\n transform: translateX(100%);\n max-height: 0;\n opacity: 0;\n }\n\n from {\n transform: translateX(0%);\n max-height: 100px;\n opacity: 1;\n }\n }\n\n @keyframes in-left {\n from {\n transform: translateX(-100%);\n max-height: 0;\n opacity: 0;\n }\n\n to {\n transform: translateX(0%);\n max-height: 150px;\n opacity: 1;\n }\n }\n\n @keyframes out-left {\n to {\n transform: translateX(-100%);\n max-height: 0;\n opacity: 0;\n }\n\n from {\n transform: translateX(0%);\n max-height: 100px;\n opacity: 1;\n }\n }\n`;\n\nexport const Title = styled.div<{ type: NOTIFICATION_TYPE }>`\n padding: 5px 0;\n font-size: 14px;\n color: ${(props) => getTitleColor(props.type)};\n display: flex;\n align-items: center;\n`;\n\nexport const FillParent = styled.div`\n flex: 1;\n`;\n\nexport const CloseButton = styled.button`\n position: absolute;\n background-color: transparent;\n border: none;\n padding: 0;\n top: 4px;\n right: 4px;\n cursor: pointer;\n\n &:focus {\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n border-radius: 3px;\n }\n`;\n\nexport const Body = styled.div`\n padding: 5px 5px 5px 0;\n font-size: 14px;\n`;\n\nexport const IconContainer = styled.div<{ type: NOTIFICATION_TYPE }>`\n padding: 6px 10px;\n ${(props) => getTypeStyle(props.type)};\n`;\n\nexport const Footer = styled.div`\n display: flex;\n justify-content: flex-end;\n padding: 0 5px;\n`;\n\nexport const VisuallyHidden = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n`;\n"]}
|
|
@@ -31,5 +31,7 @@ export interface NotificationOptions {
|
|
|
31
31
|
buttonClick?: () => void;
|
|
32
32
|
/** Notification close callback. */
|
|
33
33
|
onClose?: () => void;
|
|
34
|
+
/** aria label for the close button on the notification */
|
|
35
|
+
closeButtonAriaLabel?: string;
|
|
34
36
|
}
|
|
35
37
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,oBAAY,qBAAqB;IAC7B,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAChC;AAED,4BAA4B;AAC5B,oBAAY,iBAAiB;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;CACtB;AAED,MAAM,WAAW,mBAAmB;IAChC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,oBAAY,qBAAqB;IAC7B,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAChC;AAED,4BAA4B;AAC5B,oBAAY,iBAAiB;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;CACtB;AAED,MAAM,WAAW,mBAAmB;IAChC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Notification/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC7B,8CAAqB,CAAA;IACrB,gDAAuB,CAAA;IACvB,oDAA2B,CAAA;IAC3B,sDAA6B,CAAA;AACjC,CAAC,EALW,qBAAqB,KAArB,qBAAqB,QAKhC;AAED,4BAA4B;AAC5B,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;AACvB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B","sourcesContent":["/** Position for Notification */\nexport enum NOTIFICATION_POSITION {\n TOP_LEFT = 'TOP_LEFT',\n TOP_RIGHT = 'TOP_RIGHT',\n BOTTOM_LEFT = 'BOTTOM_LEFT',\n BOTTOM_RIGHT = 'BOTTOM_RIGHT',\n}\n\n/** Type of Notifications */\nexport enum NOTIFICATION_TYPE {\n INFO = 'INFO',\n SUCCESS = 'SUCCESS',\n DANGER = 'DANGER',\n WARNING = 'WARNING',\n}\n\nexport interface NotificationOptions {\n /** Title of the notification */\n title: string;\n /** Body of the notification */\n description: string;\n /** Id for the notification, helps in de-duplication. */\n id?: string;\n /** Duration for the notification in milliseconds */\n duration?: number;\n /** Creates sticky notification */\n sticky?: boolean;\n /** Type of notification */\n type?: NOTIFICATION_TYPE;\n /** Action button text */\n buttonText?: string;\n /** Action button click callback */\n buttonClick?: () => void;\n /** Notification close callback. */\n onClose?: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Notification/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC7B,8CAAqB,CAAA;IACrB,gDAAuB,CAAA;IACvB,oDAA2B,CAAA;IAC3B,sDAA6B,CAAA;AACjC,CAAC,EALW,qBAAqB,KAArB,qBAAqB,QAKhC;AAED,4BAA4B;AAC5B,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;AACvB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B","sourcesContent":["/** Position for Notification */\nexport enum NOTIFICATION_POSITION {\n TOP_LEFT = 'TOP_LEFT',\n TOP_RIGHT = 'TOP_RIGHT',\n BOTTOM_LEFT = 'BOTTOM_LEFT',\n BOTTOM_RIGHT = 'BOTTOM_RIGHT',\n}\n\n/** Type of Notifications */\nexport enum NOTIFICATION_TYPE {\n INFO = 'INFO',\n SUCCESS = 'SUCCESS',\n DANGER = 'DANGER',\n WARNING = 'WARNING',\n}\n\nexport interface NotificationOptions {\n /** Title of the notification */\n title: string;\n /** Body of the notification */\n description: string;\n /** Id for the notification, helps in de-duplication. */\n id?: string;\n /** Duration for the notification in milliseconds */\n duration?: number;\n /** Creates sticky notification */\n sticky?: boolean;\n /** Type of notification */\n type?: NOTIFICATION_TYPE;\n /** Action button text */\n buttonText?: string;\n /** Action button click callback */\n buttonClick?: () => void;\n /** Notification close callback. */\n onClose?: () => void;\n /** aria label for the close button on the notification */\n closeButtonAriaLabel?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAC/E,OAAO,SAAS,MAAM,YAAY,CAAC;AAInC,oBAAY,gBAAgB;IACxB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAChC;AAgFD,iBAAwB,OAAO,CAC3B,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,oDA8JjF;kBA/JuB,OAAO;;QAkK3B,wBAAwB;;QAExB,qCAAqC;;QAErC,oDAAoD;;QAOpD,qDAAqD;;QAErD,6BAA6B;;;;;;;;eA/KT,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
5
|
import { Card } from '../Card';
|
|
@@ -85,6 +85,9 @@ export default function Popover(props) {
|
|
|
85
85
|
const [translate, setTranslate] = useState({ x: 0, y: 0 });
|
|
86
86
|
const popperRef = useRef();
|
|
87
87
|
const containerRef = useRef();
|
|
88
|
+
const triggerRef = useRef(null);
|
|
89
|
+
const popperId = useId();
|
|
90
|
+
const triggerId = useId();
|
|
88
91
|
const close = useCallback(() => {
|
|
89
92
|
setClosing(true);
|
|
90
93
|
setTimeout(() => {
|
|
@@ -94,6 +97,12 @@ export default function Popover(props) {
|
|
|
94
97
|
props.onClose();
|
|
95
98
|
}
|
|
96
99
|
setClosing(false);
|
|
100
|
+
// Restore focus to the trigger element after animation completes
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
if (triggerRef.current) {
|
|
103
|
+
triggerRef.current.focus();
|
|
104
|
+
}
|
|
105
|
+
}, 50);
|
|
97
106
|
}, 280);
|
|
98
107
|
}, [props]);
|
|
99
108
|
const keyupEventHandler = useCallback((e) => {
|
|
@@ -182,7 +191,13 @@ export default function Popover(props) {
|
|
|
182
191
|
popperRef.current.focus();
|
|
183
192
|
}
|
|
184
193
|
}, [open, props.position]);
|
|
185
|
-
return (_jsxs(PopoverDiv, { ref: containerRef, children: [
|
|
194
|
+
return (_jsxs(PopoverDiv, { ref: containerRef, children: [React.createElement(props.element, {
|
|
195
|
+
ref: triggerRef,
|
|
196
|
+
id: triggerId,
|
|
197
|
+
'aria-expanded': open,
|
|
198
|
+
'aria-haspopup': 'dialog',
|
|
199
|
+
'aria-controls': popperId,
|
|
200
|
+
}), open && (_jsx(Popper, { elevated: true, tabIndex: 0, role: "dialog", "aria-labelledby": triggerId, id: popperId, position: props.position, translateX: translate.x, translateY: translate.y, className: closing && 'closing', ref: popperRef, onClick: (e) => {
|
|
186
201
|
e.stopPropagation();
|
|
187
202
|
e.nativeEvent.stopImmediatePropagation();
|
|
188
203
|
}, children: props.children }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,yCAAqB,CAAA;IACrB,2CAAuB,CAAA;IACvB,+CAA2B,CAAA;IAC3B,iDAA6B,CAAA;AACjC,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAOD,MAAM,WAAW,GAAG;IAChB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;;;KAG5B;IACD,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE;;;KAG7B;IACD,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE;;;KAGhC;IACD,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;;;KAG/B;CAC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AC,YAAY,GAAG;IACnB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,gBAAgB,CAAC,WAAW;CACzC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { Card } from '../Card';\n\nexport enum POPOVER_POSITION {\n TOP_LEFT = 'TOP_LEFT',\n TOP_RIGHT = 'TOP_RIGHT',\n BOTTOM_LEFT = 'BOTTOM_LEFT',\n BOTTOM_RIGHT = 'BOTTOM_RIGHT',\n}\n\ninterface translate {\n x: number;\n y: number;\n}\n\nconst positionMap = {\n [POPOVER_POSITION.TOP_LEFT]: `\n bottom: calc(100% - 10px);\n left: 0;\n `,\n [POPOVER_POSITION.TOP_RIGHT]: `\n bottom: calc(100% - 10px);\n right: 0;\n `,\n [POPOVER_POSITION.BOTTOM_RIGHT]: `\n top: calc(100% - 10px);\n right: 0;\n `,\n [POPOVER_POSITION.BOTTOM_LEFT]: `\n top: calc(100% - 10px);\n left: 0;\n `,\n};\n\nconst PopoverDiv = styled.div`\n position: relative;\n display: inline-flex;\n`;\n\nconst Popper = styled(Card)<{ position: POPOVER_POSITION; translateX: number; translateY: number }>`\n position: absolute;\n width: 100%;\n min-width: 200px;\n overflow: auto;\n animation: enter 0.3s linear;\n border-radius: 3px;\n z-index: 1;\n transform: translate(${(props) => props.translateX}px, ${(props) => props.translateY}px);\n ${(props) => positionMap[props.position]}\n\n &.closing {\n /* max-height: 0px;\n opacity: 0;\n overflow: hidden; */\n animation: exit 0.3s linear;\n }\n\n @keyframes enter {\n from {\n max-height: 0px;\n opacity: 1;\n overflow: hidden;\n }\n to {\n max-height: 300px;\n opacity: 1;\n overflow: hidden;\n }\n }\n\n @keyframes exit {\n to {\n max-height: 0px;\n opacity: 1;\n overflow: hidden;\n }\n from {\n max-height: 300px;\n opacity: 1;\n overflow: hidden;\n }\n }\n`;\n\nconst KEY_CODES = {\n ESC: 27,\n};\n\nexport default function Popover(\n props: React.PropsWithChildren<PropTypes.InferProps<typeof Popover.propTypes>>,\n) {\n const [open, setOpen] = useState(props.open);\n const [closing, setClosing] = useState(false);\n const [translate, setTranslate] = useState<translate>({ x: 0, y: 0 });\n const popperRef = useRef<HTMLDivElement>();\n const containerRef = useRef<HTMLDivElement>();\n\n const close = useCallback(() => {\n setClosing(true);\n setTimeout(() => {\n setOpen(false);\n setTranslate({ x: 0, y: 0 });\n if (props.onClose) {\n props.onClose();\n }\n setClosing(false);\n }, 280);\n }, [props]);\n\n const keyupEventHandler = useCallback(\n (e: KeyboardEvent) => {\n if (props.closeOnEsc && e.keyCode === KEY_CODES.ESC) {\n close();\n }\n },\n [close, props.closeOnEsc],\n );\n\n const clickOutsideHandler = useCallback(\n (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n close();\n }\n },\n [close],\n );\n\n /**\n * Get called on popover mount.\n */\n useEffect(() => {\n document.addEventListener('keyup', keyupEventHandler);\n\n return () => {\n document.removeEventListener('keyup', keyupEventHandler);\n document.removeEventListener('click', clickOutsideHandler);\n };\n }, [clickOutsideHandler, close, keyupEventHandler]);\n\n useEffect(() => {\n if (props.open) {\n setOpen(true);\n // Use requestAnimationFrame to add listener after current event loop\n requestAnimationFrame(() => {\n document.addEventListener('click', clickOutsideHandler);\n });\n } else {\n if (open) {\n close();\n }\n }\n\n return () => {\n document.removeEventListener('click', clickOutsideHandler);\n };\n }, [props.open, open, clickOutsideHandler, close]);\n\n useEffect(() => {\n if (open) {\n const { top, left, right } = popperRef.current.getBoundingClientRect();\n const height = popperRef.current.scrollHeight;\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n const translation = { x: 0, y: 0 };\n\n if (props.position === POPOVER_POSITION.BOTTOM_LEFT) {\n // overflow can happen at bottom and right\n if (viewportHeight - top - height < 0) {\n translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);\n }\n if (viewportWidth - right < 0) {\n translation.x = -1 * (Math.abs(viewportWidth - right) + 5);\n }\n } else if (props.position == POPOVER_POSITION.BOTTOM_RIGHT) {\n // overflow can happen at bottom and left\n if (viewportHeight - top - height < 0) {\n translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);\n }\n if (left < 0) {\n translation.x = Math.abs(left) + 5;\n }\n } else if (props.position === POPOVER_POSITION.TOP_LEFT) {\n // overflow can happen at top and right\n if (top - height < 0) {\n translation.y = Math.abs(top - height) + 5;\n }\n if (viewportWidth - right < 0) {\n translation.x = -1 * (Math.abs(viewportWidth - right) + 5);\n }\n } else {\n // overflow can happen at top and left\n if (top - height < 0) {\n translation.y = Math.abs(top - height) + 5;\n }\n if (left < 0) {\n translation.x = Math.abs(left) + 5;\n }\n }\n // Note it can still overflow, but in that case fitting popper inside the\n // window is not possible.\n setTranslate(translation);\n popperRef.current.focus();\n }\n }, [open, props.position]);\n\n return (\n <PopoverDiv ref={containerRef}>\n <props.element />\n {open && (\n <Popper\n elevated\n tabIndex={0}\n position={props.position}\n translateX={translate.x}\n translateY={translate.y}\n className={closing && 'closing'}\n ref={popperRef}\n onClick={(e) => {\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n }}\n >\n {props.children}\n </Popper>\n )}\n </PopoverDiv>\n );\n}\n\nPopover.propTypes = {\n /** Opens the popover */\n open: PropTypes.bool.isRequired,\n /** Anchor element for the popover */\n element: PropTypes.func,\n /** Position of the popover around anchor element */\n position: PropTypes.oneOf([\n POPOVER_POSITION.TOP_LEFT,\n POPOVER_POSITION.TOP_RIGHT,\n POPOVER_POSITION.BOTTOM_LEFT,\n POPOVER_POSITION.BOTTOM_RIGHT,\n ]),\n /** If the popover should close on `esc` key press */\n closeOnEsc: PropTypes.bool,\n /** Popover close callback */\n onClose: PropTypes.func,\n};\n\nPopover.defaultProps = {\n closeOnEsc: true,\n position: POPOVER_POSITION.BOTTOM_LEFT,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Pop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AY,GAAG;IACnB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,gBAAgB,CAAC,WAAW;CACzC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { Card } from '../Card';\n\nexport enum POPOVER_POSITION {\n TOP_LEFT = 'TOP_LEFT',\n TOP_RIGHT = 'TOP_RIGHT',\n BOTTOM_LEFT = 'BOTTOM_LEFT',\n BOTTOM_RIGHT = 'BOTTOM_RIGHT',\n}\n\ninterface translate {\n x: number;\n y: number;\n}\n\nconst positionMap = {\n [POPOVER_POSITION.TOP_LEFT]: `\n bottom: calc(100% - 10px);\n left: 0;\n `,\n [POPOVER_POSITION.TOP_RIGHT]: `\n bottom: calc(100% - 10px);\n right: 0;\n `,\n [POPOVER_POSITION.BOTTOM_RIGHT]: `\n top: calc(100% - 10px);\n right: 0;\n `,\n [POPOVER_POSITION.BOTTOM_LEFT]: `\n top: calc(100% - 10px);\n left: 0;\n `,\n};\n\nconst PopoverDiv = styled.div`\n position: relative;\n display: inline-flex;\n`;\n\nconst Popper = styled(Card)<{ position: POPOVER_POSITION; translateX: number; translateY: number }>`\n position: absolute;\n width: 100%;\n min-width: 200px;\n overflow: auto;\n animation: enter 0.3s linear;\n border-radius: 3px;\n z-index: 1;\n transform: translate(${(props) => props.translateX}px, ${(props) => props.translateY}px);\n ${(props) => positionMap[props.position]}\n\n &.closing {\n /* max-height: 0px;\n opacity: 0;\n overflow: hidden; */\n animation: exit 0.3s linear;\n }\n\n @keyframes enter {\n from {\n max-height: 0px;\n opacity: 1;\n overflow: hidden;\n }\n to {\n max-height: 300px;\n opacity: 1;\n overflow: hidden;\n }\n }\n\n @keyframes exit {\n to {\n max-height: 0px;\n opacity: 1;\n overflow: hidden;\n }\n from {\n max-height: 300px;\n opacity: 1;\n overflow: hidden;\n }\n }\n`;\n\nconst KEY_CODES = {\n ESC: 27,\n};\n\nexport default function Popover(\n props: React.PropsWithChildren<PropTypes.InferProps<typeof Popover.propTypes>>,\n) {\n const [open, setOpen] = useState(props.open);\n const [closing, setClosing] = useState(false);\n const [translate, setTranslate] = useState<translate>({ x: 0, y: 0 });\n const popperRef = useRef<HTMLDivElement>();\n const containerRef = useRef<HTMLDivElement>();\n const triggerRef = useRef<HTMLElement | null>(null);\n const popperId = useId();\n const triggerId = useId();\n\n const close = useCallback(() => {\n setClosing(true);\n setTimeout(() => {\n setOpen(false);\n setTranslate({ x: 0, y: 0 });\n\n if (props.onClose) {\n props.onClose();\n }\n setClosing(false);\n\n // Restore focus to the trigger element after animation completes\n setTimeout(() => {\n if (triggerRef.current) {\n triggerRef.current.focus();\n }\n }, 50);\n }, 280);\n }, [props]);\n\n const keyupEventHandler = useCallback(\n (e: KeyboardEvent) => {\n if (props.closeOnEsc && e.keyCode === KEY_CODES.ESC) {\n close();\n }\n },\n [close, props.closeOnEsc],\n );\n\n const clickOutsideHandler = useCallback(\n (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n close();\n }\n },\n [close],\n );\n\n /**\n * Get called on popover mount.\n */\n useEffect(() => {\n document.addEventListener('keyup', keyupEventHandler);\n\n return () => {\n document.removeEventListener('keyup', keyupEventHandler);\n document.removeEventListener('click', clickOutsideHandler);\n };\n }, [clickOutsideHandler, close, keyupEventHandler]);\n\n useEffect(() => {\n if (props.open) {\n setOpen(true);\n // Use requestAnimationFrame to add listener after current event loop\n requestAnimationFrame(() => {\n document.addEventListener('click', clickOutsideHandler);\n });\n } else {\n if (open) {\n close();\n }\n }\n\n return () => {\n document.removeEventListener('click', clickOutsideHandler);\n };\n }, [props.open, open, clickOutsideHandler, close]);\n\n useEffect(() => {\n if (open) {\n const { top, left, right } = popperRef.current.getBoundingClientRect();\n const height = popperRef.current.scrollHeight;\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n const translation = { x: 0, y: 0 };\n\n if (props.position === POPOVER_POSITION.BOTTOM_LEFT) {\n // overflow can happen at bottom and right\n if (viewportHeight - top - height < 0) {\n translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);\n }\n if (viewportWidth - right < 0) {\n translation.x = -1 * (Math.abs(viewportWidth - right) + 5);\n }\n } else if (props.position == POPOVER_POSITION.BOTTOM_RIGHT) {\n // overflow can happen at bottom and left\n if (viewportHeight - top - height < 0) {\n translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);\n }\n if (left < 0) {\n translation.x = Math.abs(left) + 5;\n }\n } else if (props.position === POPOVER_POSITION.TOP_LEFT) {\n // overflow can happen at top and right\n if (top - height < 0) {\n translation.y = Math.abs(top - height) + 5;\n }\n if (viewportWidth - right < 0) {\n translation.x = -1 * (Math.abs(viewportWidth - right) + 5);\n }\n } else {\n // overflow can happen at top and left\n if (top - height < 0) {\n translation.y = Math.abs(top - height) + 5;\n }\n if (left < 0) {\n translation.x = Math.abs(left) + 5;\n }\n }\n // Note it can still overflow, but in that case fitting popper inside the\n // window is not possible.\n setTranslate(translation);\n popperRef.current.focus();\n }\n }, [open, props.position]);\n\n return (\n <PopoverDiv ref={containerRef}>\n {React.createElement(props.element, {\n ref: triggerRef,\n id: triggerId,\n 'aria-expanded': open,\n 'aria-haspopup': 'dialog',\n 'aria-controls': popperId,\n })}\n {open && (\n <Popper\n elevated\n tabIndex={0}\n role=\"dialog\"\n aria-labelledby={triggerId}\n id={popperId}\n position={props.position}\n translateX={translate.x}\n translateY={translate.y}\n className={closing && 'closing'}\n ref={popperRef}\n onClick={(e) => {\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n }}\n >\n {props.children}\n </Popper>\n )}\n </PopoverDiv>\n );\n}\n\nPopover.propTypes = {\n /** Opens the popover */\n open: PropTypes.bool.isRequired,\n /** Anchor element for the popover */\n element: PropTypes.func,\n /** Position of the popover around anchor element */\n position: PropTypes.oneOf([\n POPOVER_POSITION.TOP_LEFT,\n POPOVER_POSITION.TOP_RIGHT,\n POPOVER_POSITION.BOTTOM_LEFT,\n POPOVER_POSITION.BOTTOM_RIGHT,\n ]),\n /** If the popover should close on `esc` key press */\n closeOnEsc: PropTypes.bool,\n /** Popover close callback */\n onClose: PropTypes.func,\n};\n\nPopover.defaultProps = {\n closeOnEsc: true,\n position: POPOVER_POSITION.BOTTOM_LEFT,\n};\n"]}
|
|
@@ -4,9 +4,12 @@ declare namespace Spinner {
|
|
|
4
4
|
var propTypes: {
|
|
5
5
|
/** Spinner's size */
|
|
6
6
|
size: PropTypes.Requireable<number>;
|
|
7
|
+
/** Accessible label for screen readers */
|
|
8
|
+
label: PropTypes.Requireable<string>;
|
|
7
9
|
};
|
|
8
10
|
var defaultProps: {
|
|
9
11
|
size: number;
|
|
12
|
+
label: string;
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
type SpinnerProp = PropTypes.InferProps<typeof Spinner.propTypes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/components/Spinner/Spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAuBnC,iBAAS,OAAO,CAAC,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/components/Spinner/Spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAuBnC,iBAAS,OAAO,CAAC,KAAK,EAAE,WAAW,oDAWlC;kBAXQ,OAAO;;QAgBZ,qBAAqB;;QAErB,0CAA0C;;;;;;;;AAL9C,KAAK,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAclE,eAAe,OAAO,CAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
13
|
import PropTypes from 'prop-types';
|
|
3
14
|
import styled from '@emotion/styled';
|
|
4
|
-
import
|
|
15
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
5
16
|
const SpinnerDiv = styled.div `
|
|
6
|
-
border: 4px solid
|
|
7
|
-
border-top: 4px solid
|
|
17
|
+
border: 4px solid ${getThemeValue(THEME_NAME.PRIMARY)};
|
|
18
|
+
border-top: 4px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};
|
|
8
19
|
border-radius: 50%;
|
|
9
20
|
width: ${(props) => props.size}px;
|
|
10
21
|
height: ${(props) => props.size}px;
|
|
@@ -21,14 +32,18 @@ const SpinnerDiv = styled.div `
|
|
|
21
32
|
}
|
|
22
33
|
`;
|
|
23
34
|
function Spinner(props) {
|
|
24
|
-
|
|
35
|
+
const { label } = props, rest = __rest(props, ["label"]);
|
|
36
|
+
return (_jsx(SpinnerDiv, Object.assign({}, rest, { role: "status", "aria-label": label, "aria-live": "polite", "aria-busy": "true" })));
|
|
25
37
|
}
|
|
26
38
|
Spinner.propTypes = {
|
|
27
39
|
/** Spinner's size */
|
|
28
40
|
size: PropTypes.number,
|
|
41
|
+
/** Accessible label for screen readers */
|
|
42
|
+
label: PropTypes.string,
|
|
29
43
|
};
|
|
30
44
|
Spinner.defaultProps = {
|
|
31
45
|
size: 30,
|
|
46
|
+
label: 'Loading',
|
|
32
47
|
};
|
|
33
48
|
export default Spinner;
|
|
34
49
|
//# sourceMappingURL=Spinner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../../../src/components/Spinner/Spinner.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../../../src/components/Spinner/Spinner.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAa;wBAClB,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;4BAC7B,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC;;aAE3D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI;cACpB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI;;;;;;;;;;;;CAYlC,CAAC;AAEF,SAAS,OAAO,CAAC,KAAkB;IAC/B,MAAM,EAAE,KAAK,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA1B,SAAkB,CAAQ,CAAC;IACjC,OAAO,CACH,KAAC,UAAU,oBACH,IAAI,IACR,IAAI,EAAC,QAAQ,gBACD,KAAK,eACP,QAAQ,eACR,MAAM,IAClB,CACL,CAAC;AACN,CAAC;AAID,OAAO,CAAC,SAAS,GAAG;IAChB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC,MAAM;IACtB,0CAA0C;IAC1C,KAAK,EAAE,SAAS,CAAC,MAAM;CAC1B,CAAC;AAEF,OAAO,CAAC,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,SAAS;CACnB,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst SpinnerDiv = styled.div<SpinnerProp>`\n border: 4px solid ${getThemeValue(THEME_NAME.PRIMARY)};\n border-top: 4px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n border-radius: 50%;\n width: ${(props) => props.size}px;\n height: ${(props) => props.size}px;\n margin: 0 auto;\n animation: spin 1s linear infinite;\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n`;\n\nfunction Spinner(props: SpinnerProp) {\n const { label, ...rest } = props;\n return (\n <SpinnerDiv\n {...rest}\n role=\"status\"\n aria-label={label}\n aria-live=\"polite\"\n aria-busy=\"true\"\n />\n );\n}\n\ntype SpinnerProp = PropTypes.InferProps<typeof Spinner.propTypes>;\n\nSpinner.propTypes = {\n /** Spinner's size */\n size: PropTypes.number,\n /** Accessible label for screen readers */\n label: PropTypes.string,\n};\n\nSpinner.defaultProps = {\n size: 30,\n label: 'Loading',\n};\n\nexport default Spinner;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,iBAAiB,EAA4B,MAAM,OAAO,CAAC;AAC9E,OAAO,SAAS,MAAM,YAAY,CAAC;AAMnC,KAAK,YAAY,GAAG,iBAAiB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,iBAAiB,EAA4B,MAAM,OAAO,CAAC;AAC9E,OAAO,SAAS,MAAM,YAAY,CAAC;AAMnC,KAAK,YAAY,GAAG,iBAAiB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC,CAAC;AAmFH,iBAAwB,OAAO,CAAC,KAAK,EAAE,YAAY,oDAiFlD;kBAjFuB,OAAO;;QAoF3B,qCAAqC;;QAErC,kDAAkD;;;;;;;eAtF9B,OAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { Children, useState, isValidElement } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
|
-
import
|
|
5
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants';
|
|
6
6
|
import { Ellipsis } from '../../shared/styles';
|
|
7
7
|
import { Badge, BADGE_TYPE } from '../Badge';
|
|
8
8
|
const Container = styled.div `
|
|
@@ -15,7 +15,7 @@ const Header = styled.div `
|
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: row;
|
|
17
17
|
justify-content: space-between;
|
|
18
|
-
border-bottom: 1px solid
|
|
18
|
+
border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};
|
|
19
19
|
|
|
20
20
|
@media (min-width: 601px) {
|
|
21
21
|
&::before {
|
|
@@ -24,7 +24,7 @@ const Header = styled.div `
|
|
|
24
24
|
left: 0;
|
|
25
25
|
right: 0;
|
|
26
26
|
height: 2px;
|
|
27
|
-
background-color:
|
|
27
|
+
background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};
|
|
28
28
|
content: ' ';
|
|
29
29
|
z-index: 0;
|
|
30
30
|
}
|
|
@@ -40,21 +40,22 @@ const HeaderButton = styled.button `
|
|
|
40
40
|
font-size: 16px;
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
background-color: ${(props) => props.active
|
|
43
|
-
?
|
|
44
|
-
:
|
|
43
|
+
? getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)
|
|
44
|
+
: getThemeValue(THEME_NAME.BACKGROUND)};
|
|
45
45
|
font-weight: ${(props) => (props.active ? 'bold' : 'normal')};
|
|
46
46
|
overflow: hidden;
|
|
47
47
|
display: flex;
|
|
48
48
|
align-items: center;
|
|
49
|
+
color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};
|
|
49
50
|
|
|
50
51
|
&:disabled {
|
|
51
52
|
cursor: not-allowed;
|
|
52
|
-
background-color:
|
|
53
|
+
background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
&:enabled:hover,
|
|
56
57
|
&:focus {
|
|
57
|
-
background-color:
|
|
58
|
+
background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHTER)};
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
@media (max-width: 600px) {
|
|
@@ -84,9 +85,13 @@ export default function Stepper(props) {
|
|
|
84
85
|
const [active, setActive] = useState(props.active);
|
|
85
86
|
const { children, onStepClick } = props;
|
|
86
87
|
const childrenArray = Children.toArray(children);
|
|
88
|
+
const stepRefs = [];
|
|
87
89
|
const stepClickHandler = (index) => () => {
|
|
90
|
+
var _a;
|
|
88
91
|
setActive(index);
|
|
89
92
|
onStepClick === null || onStepClick === void 0 ? void 0 : onStepClick(index);
|
|
93
|
+
// Move focus to the active step
|
|
94
|
+
(_a = stepRefs[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
90
95
|
};
|
|
91
96
|
const getBadgeType = (index, completed, disabled) => {
|
|
92
97
|
if (disabled) {
|
|
@@ -100,10 +105,24 @@ export default function Stepper(props) {
|
|
|
100
105
|
}
|
|
101
106
|
return BADGE_TYPE.DISABLED;
|
|
102
107
|
};
|
|
103
|
-
|
|
108
|
+
// Keyboard navigation for step buttons
|
|
109
|
+
const onStepKeyDown = (index) => (e) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
const next = (index + 1) % childrenArray.length;
|
|
114
|
+
(_a = stepRefs[next]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
115
|
+
}
|
|
116
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
const prev = (index - 1 + childrenArray.length) % childrenArray.length;
|
|
119
|
+
(_b = stepRefs[prev]) === null || _b === void 0 ? void 0 : _b.focus();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return (_jsxs(Container, { children: [_jsxs(Header, { role: "tablist", "aria-label": "Stepper Steps", children: [Children.map(children, (child, index) => {
|
|
104
123
|
if (!isValidElement(child))
|
|
105
124
|
return null;
|
|
106
|
-
return (
|
|
125
|
+
return (_jsxs(HeaderButton, { ref: (el) => (stepRefs[index] = el), active: index === active, type: "button", role: "tab", "aria-selected": index === active, "aria-disabled": !!child.props.disabled, tabIndex: index === active ? 0 : -1, disabled: child.props.disabled, onClick: stepClickHandler(index), onKeyDown: onStepKeyDown(index), children: [_jsx(Badge, { inline: true, type: getBadgeType(index, child.props.completed, child.props.disabled) }), _jsx(Ellipsis, { children: child.props.name })] }));
|
|
107
126
|
}), _jsxs(MobileHeader, { children: [_jsx("span", { children: isValidElement(childrenArray[active])
|
|
108
127
|
? childrenArray[active].props.name
|
|
109
128
|
: '' }), _jsxs(Badge, { inline: true, type: BADGE_TYPE.PRIMARY, children: [active + 1, " of ", Children.count(children)] })] })] }), childrenArray[active]] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAqB,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAA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,CAAC,aAE/B,KAAC,KAAK,IACF,MAAM,QACN,IAAI,EAAE,YAAY,CACd,KAAK,EACL,KAAK,CAAC,KAAK,CAAC,SAAS,EACrB,KAAK,CAAC,KAAK,CAAC,QAAQ,CACvB,GACH,EACF,KAAC,QAAQ,cAAE,KAAK,CAAC,KAAK,CAAC,IAAI,GAAY,IAC5B,CAClB,CAAC;oBACN,CAAC,CAAC,EACF,MAAC,YAAY,eACT,yBACK,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oCAClC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI;oCAClC,CAAC,CAAC,EAAE,GACL,EACP,MAAC,KAAK,IAAC,MAAM,QAAC,IAAI,EAAE,UAAU,CAAC,OAAO,aACjC,MAAM,GAAG,CAAC,UAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IACrC,IACG,IACV,EACR,aAAa,CAAC,MAAM,CAAC,IACd,CACf,CAAC;AACN,CAAC;AAED,OAAO,CAAC,SAAS,GAAG;IAChB,qCAAqC;IACrC,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,kDAAkD;IAClD,WAAW,EAAE,SAAS,CAAC,IAAI;CAC9B,CAAC;AAEF,OAAO,CAAC,YAAY,GAAG;IACnB,MAAM,EAAE,CAAC;CACZ,CAAC","sourcesContent":["import { Children, PropsWithChildren, useState, isValidElement } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { Ellipsis } from '../../shared/styles';\nimport { Badge, BADGE_TYPE } from '../Badge';\n\ntype StepperProps = PropsWithChildren<{\n active: number;\n onStepClick?: (index: number) => void;\n}>;\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\nexport default function Stepper(props: StepperProps) {\n const [active, setActive] = useState(props.active);\n const { children, onStepClick } = props;\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>\n <Header role=\"tablist\" aria-label=\"Stepper Steps\">\n {Children.map(children, (child, index) => {\n if (!isValidElement(child)) return null;\n return (\n <HeaderButton\n ref={(el) => (stepRefs[index] = el)}\n active={index === active}\n type=\"button\"\n role=\"tab\"\n aria-selected={index === active}\n aria-disabled={!!child.props.disabled}\n tabIndex={index === active ? 0 : -1}\n disabled={child.props.disabled}\n onClick={stepClickHandler(index)}\n onKeyDown={onStepKeyDown(index)}\n >\n <Badge\n inline\n type={getBadgeType(\n index,\n child.props.completed,\n child.props.disabled,\n )}\n />\n <Ellipsis>{child.props.name}</Ellipsis>\n </HeaderButton>\n );\n })}\n <MobileHeader>\n <span>\n {isValidElement(childrenArray[active])\n ? childrenArray[active].props.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\nStepper.propTypes = {\n /** Index of currently active step */\n active: PropTypes.number,\n /** Callback function for click event on a step */\n onStepClick: PropTypes.func,\n};\n\nStepper.defaultProps = {\n active: 0,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,iBAAiB,EAAkB,MAAM,OAAO,CAAC;AACzF,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,iBAAiB,EAAkB,MAAM,OAAO,CAAC;AACzF,OAAO,SAAS,MAAM,YAAY,CAAC;AA4CnC,KAAK,UAAU,GAAG,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAEH,iBAAwB,IAAI,CAAC,KAAK,EAAE,UAAU,oDA2E7C;kBA3EuB,IAAI;;QA8ExB,uBAAuB;;QAEvB,6BAA6B;;QAE7B,8CAA8C;;QAE9C,2CAA2C;;;;;;;eApFvB,IAAI"}
|