no-frills-ui 0.0.14-alpha.1 → 0.0.14-alpha.10

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.
Files changed (222) hide show
  1. package/README.md +28 -22
  2. package/dist/index.js +3419 -2768
  3. package/dist/index.js.map +1 -1
  4. package/lib-esm/components/Accordion/Accordion.d.ts +11 -16
  5. package/lib-esm/components/Accordion/Accordion.js +25 -29
  6. package/lib-esm/components/Accordion/Accordion.js.map +1 -1
  7. package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
  8. package/lib-esm/components/Accordion/AccordionStep.js +111 -109
  9. package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
  10. package/lib-esm/components/Badge/Badge.d.ts +13 -16
  11. package/lib-esm/components/Badge/Badge.js +31 -51
  12. package/lib-esm/components/Badge/Badge.js.map +1 -1
  13. package/lib-esm/components/Button/ActionButton.d.ts +9 -5
  14. package/lib-esm/components/Button/ActionButton.js +18 -38
  15. package/lib-esm/components/Button/ActionButton.js.map +1 -1
  16. package/lib-esm/components/Button/Button.d.ts +9 -5
  17. package/lib-esm/components/Button/Button.js +18 -40
  18. package/lib-esm/components/Button/Button.js.map +1 -1
  19. package/lib-esm/components/Button/IconButton.d.ts +9 -5
  20. package/lib-esm/components/Button/IconButton.js +18 -42
  21. package/lib-esm/components/Button/IconButton.js.map +1 -1
  22. package/lib-esm/components/Button/LinkButton.d.ts +9 -5
  23. package/lib-esm/components/Button/LinkButton.js +18 -32
  24. package/lib-esm/components/Button/LinkButton.js.map +1 -1
  25. package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
  26. package/lib-esm/components/Button/RaisedButton.js +18 -46
  27. package/lib-esm/components/Button/RaisedButton.js.map +1 -1
  28. package/lib-esm/components/Card/Card.d.ts +4 -6
  29. package/lib-esm/components/Card/Card.js +18 -13
  30. package/lib-esm/components/Card/Card.js.map +1 -1
  31. package/lib-esm/components/Chip/Chip.d.ts +6 -3
  32. package/lib-esm/components/Chip/Chip.js +44 -43
  33. package/lib-esm/components/Chip/Chip.js.map +1 -1
  34. package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -30
  35. package/lib-esm/components/ChipInput/ChipInput.js +121 -139
  36. package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
  37. package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
  38. package/lib-esm/components/Dialog/AlertDialog.js +44 -28
  39. package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
  40. package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
  41. package/lib-esm/components/Dialog/ConfirmDialog.js +49 -33
  42. package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
  43. package/lib-esm/components/Dialog/Dialog.d.ts +40 -18
  44. package/lib-esm/components/Dialog/Dialog.js +125 -70
  45. package/lib-esm/components/Dialog/Dialog.js.map +1 -1
  46. package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
  47. package/lib-esm/components/Dialog/PromptDialog.js +78 -49
  48. package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
  49. package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +43 -41
  50. package/lib-esm/components/DragAndDrop/DragAndDrop.js +104 -31
  51. package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
  52. package/lib-esm/components/DragAndDrop/DragItem.d.ts +5 -1
  53. package/lib-esm/components/DragAndDrop/DragItem.js +171 -92
  54. package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
  55. package/lib-esm/components/DragAndDrop/types.d.ts +22 -3
  56. package/lib-esm/components/DragAndDrop/types.js +9 -6
  57. package/lib-esm/components/DragAndDrop/types.js.map +1 -1
  58. package/lib-esm/components/Drawer/Drawer.d.ts +86 -22
  59. package/lib-esm/components/Drawer/Drawer.js +176 -97
  60. package/lib-esm/components/Drawer/Drawer.js.map +1 -1
  61. package/lib-esm/components/Drawer/index.d.ts +1 -1
  62. package/lib-esm/components/Groups/Group.d.ts +5 -8
  63. package/lib-esm/components/Groups/Group.js +34 -79
  64. package/lib-esm/components/Groups/Group.js.map +1 -1
  65. package/lib-esm/components/Groups/GroupLabel.js +8 -17
  66. package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
  67. package/lib-esm/components/Input/Checkbox.d.ts +12 -15
  68. package/lib-esm/components/Input/Checkbox.js +51 -118
  69. package/lib-esm/components/Input/Checkbox.js.map +1 -1
  70. package/lib-esm/components/Input/Dropdown.d.ts +11 -12
  71. package/lib-esm/components/Input/Dropdown.js +133 -52
  72. package/lib-esm/components/Input/Dropdown.js.map +1 -1
  73. package/lib-esm/components/Input/Input.d.ts +3 -3
  74. package/lib-esm/components/Input/Input.js +61 -109
  75. package/lib-esm/components/Input/Input.js.map +1 -1
  76. package/lib-esm/components/Input/Radio.d.ts +4 -8
  77. package/lib-esm/components/Input/Radio.js +35 -79
  78. package/lib-esm/components/Input/Radio.js.map +1 -1
  79. package/lib-esm/components/Input/RadioButton.d.ts +4 -8
  80. package/lib-esm/components/Input/RadioButton.js +34 -71
  81. package/lib-esm/components/Input/RadioButton.js.map +1 -1
  82. package/lib-esm/components/Input/Select.d.ts +6 -13
  83. package/lib-esm/components/Input/Select.js +75 -122
  84. package/lib-esm/components/Input/Select.js.map +1 -1
  85. package/lib-esm/components/Input/TextArea.d.ts +6 -13
  86. package/lib-esm/components/Input/TextArea.js +64 -108
  87. package/lib-esm/components/Input/TextArea.js.map +1 -1
  88. package/lib-esm/components/Input/Toggle.d.ts +4 -9
  89. package/lib-esm/components/Input/Toggle.js +31 -80
  90. package/lib-esm/components/Input/Toggle.js.map +1 -1
  91. package/lib-esm/components/Menu/Menu.d.ts +8 -6
  92. package/lib-esm/components/Menu/Menu.js +116 -31
  93. package/lib-esm/components/Menu/Menu.js.map +1 -1
  94. package/lib-esm/components/Menu/MenuContext.d.ts +11 -5
  95. package/lib-esm/components/Menu/MenuContext.js +6 -2
  96. package/lib-esm/components/Menu/MenuContext.js.map +1 -1
  97. package/lib-esm/components/Menu/MenuItem.d.ts +7 -4
  98. package/lib-esm/components/Menu/MenuItem.js +46 -47
  99. package/lib-esm/components/Menu/MenuItem.js.map +1 -1
  100. package/lib-esm/components/Modal/Modal.d.ts +75 -16
  101. package/lib-esm/components/Modal/Modal.js +150 -51
  102. package/lib-esm/components/Modal/Modal.js.map +1 -1
  103. package/lib-esm/components/Notification/Notification.d.ts +46 -39
  104. package/lib-esm/components/Notification/Notification.js +80 -87
  105. package/lib-esm/components/Notification/Notification.js.map +1 -1
  106. package/lib-esm/components/Notification/NotificationManager.d.ts +19 -5
  107. package/lib-esm/components/Notification/NotificationManager.js +177 -79
  108. package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
  109. package/lib-esm/components/Notification/style.d.ts +6 -3
  110. package/lib-esm/components/Notification/style.js +64 -140
  111. package/lib-esm/components/Notification/style.js.map +1 -1
  112. package/lib-esm/components/Notification/types.d.ts +2 -0
  113. package/lib-esm/components/Notification/types.js +9 -10
  114. package/lib-esm/components/Notification/types.js.map +1 -1
  115. package/lib-esm/components/Popover/Popover.d.ts +21 -20
  116. package/lib-esm/components/Popover/Popover.js +159 -126
  117. package/lib-esm/components/Popover/Popover.js.map +1 -1
  118. package/lib-esm/components/Spinner/Spinner.d.ts +14 -12
  119. package/lib-esm/components/Spinner/Spinner.js +22 -27
  120. package/lib-esm/components/Spinner/Spinner.js.map +1 -1
  121. package/lib-esm/components/Stepper/Step.d.ts +15 -12
  122. package/lib-esm/components/Stepper/Step.js +18 -25
  123. package/lib-esm/components/Stepper/Step.js.map +1 -1
  124. package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
  125. package/lib-esm/components/Stepper/Stepper.js +104 -102
  126. package/lib-esm/components/Stepper/Stepper.js.map +1 -1
  127. package/lib-esm/components/Tabs/Tab.d.ts +10 -16
  128. package/lib-esm/components/Tabs/Tab.js +9 -15
  129. package/lib-esm/components/Tabs/Tab.js.map +1 -1
  130. package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
  131. package/lib-esm/components/Tabs/Tabs.js +97 -55
  132. package/lib-esm/components/Tabs/Tabs.js.map +1 -1
  133. package/lib-esm/components/Toast/Toast.d.ts +34 -7
  134. package/lib-esm/components/Toast/Toast.js +200 -109
  135. package/lib-esm/components/Toast/Toast.js.map +1 -1
  136. package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
  137. package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
  138. package/lib-esm/components/Tooltip/Tooltip.js +52 -67
  139. package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
  140. package/lib-esm/components/index.d.ts +1 -0
  141. package/lib-esm/components/index.js +43 -20
  142. package/lib-esm/components/index.js.map +1 -1
  143. package/lib-esm/icons/CheckCircle.d.ts +1 -1
  144. package/lib-esm/icons/CheckCircle.js +22 -4
  145. package/lib-esm/icons/CheckCircle.js.map +1 -1
  146. package/lib-esm/icons/Close.d.ts +1 -1
  147. package/lib-esm/icons/Close.js +22 -4
  148. package/lib-esm/icons/Close.js.map +1 -1
  149. package/lib-esm/icons/DragIndicator.d.ts +1 -1
  150. package/lib-esm/icons/DragIndicator.js +22 -4
  151. package/lib-esm/icons/DragIndicator.js.map +1 -1
  152. package/lib-esm/icons/ErrorOutline.d.ts +1 -1
  153. package/lib-esm/icons/ErrorOutline.js +16 -4
  154. package/lib-esm/icons/ErrorOutline.js.map +1 -1
  155. package/lib-esm/icons/ExpandMore.d.ts +1 -1
  156. package/lib-esm/icons/ExpandMore.js +22 -4
  157. package/lib-esm/icons/ExpandMore.js.map +1 -1
  158. package/lib-esm/icons/FiberManualRecord.d.ts +1 -1
  159. package/lib-esm/icons/FiberManualRecord.js +24 -4
  160. package/lib-esm/icons/FiberManualRecord.js.map +1 -1
  161. package/lib-esm/icons/Info.d.ts +1 -1
  162. package/lib-esm/icons/Info.js +22 -4
  163. package/lib-esm/icons/Info.js.map +1 -1
  164. package/lib-esm/icons/ReportProblem.d.ts +1 -1
  165. package/lib-esm/icons/ReportProblem.js +22 -4
  166. package/lib-esm/icons/ReportProblem.js.map +1 -1
  167. package/lib-esm/shared/LayerManager.d.ts +34 -4
  168. package/lib-esm/shared/LayerManager.js +248 -114
  169. package/lib-esm/shared/LayerManager.js.map +1 -1
  170. package/lib-esm/shared/constants.d.ts +58 -27
  171. package/lib-esm/shared/constants.js +62 -26
  172. package/lib-esm/shared/constants.js.map +1 -1
  173. package/lib-esm/shared/styles.d.ts +1 -1
  174. package/lib-esm/shared/styles.js +21 -24
  175. package/lib-esm/shared/styles.js.map +1 -1
  176. package/package.json +130 -74
  177. package/lib-esm/components/Accordion/index.js +0 -3
  178. package/lib-esm/components/Accordion/index.js.map +0 -1
  179. package/lib-esm/components/Badge/index.js +0 -2
  180. package/lib-esm/components/Badge/index.js.map +0 -1
  181. package/lib-esm/components/Button/index.js +0 -6
  182. package/lib-esm/components/Button/index.js.map +0 -1
  183. package/lib-esm/components/Card/index.js +0 -3
  184. package/lib-esm/components/Card/index.js.map +0 -1
  185. package/lib-esm/components/Chip/index.js +0 -2
  186. package/lib-esm/components/Chip/index.js.map +0 -1
  187. package/lib-esm/components/ChipInput/index.js +0 -2
  188. package/lib-esm/components/ChipInput/index.js.map +0 -1
  189. package/lib-esm/components/Dialog/index.js +0 -5
  190. package/lib-esm/components/Dialog/index.js.map +0 -1
  191. package/lib-esm/components/DragAndDrop/index.js +0 -3
  192. package/lib-esm/components/DragAndDrop/index.js.map +0 -1
  193. package/lib-esm/components/Drawer/index.js +0 -2
  194. package/lib-esm/components/Drawer/index.js.map +0 -1
  195. package/lib-esm/components/Groups/index.js +0 -3
  196. package/lib-esm/components/Groups/index.js.map +0 -1
  197. package/lib-esm/components/Input/index.js +0 -9
  198. package/lib-esm/components/Input/index.js.map +0 -1
  199. package/lib-esm/components/Menu/index.js +0 -3
  200. package/lib-esm/components/Menu/index.js.map +0 -1
  201. package/lib-esm/components/Modal/index.js +0 -2
  202. package/lib-esm/components/Modal/index.js.map +0 -1
  203. package/lib-esm/components/Notification/index.js +0 -3
  204. package/lib-esm/components/Notification/index.js.map +0 -1
  205. package/lib-esm/components/Popover/index.js +0 -2
  206. package/lib-esm/components/Popover/index.js.map +0 -1
  207. package/lib-esm/components/Spinner/index.js +0 -2
  208. package/lib-esm/components/Spinner/index.js.map +0 -1
  209. package/lib-esm/components/Stepper/index.js +0 -4
  210. package/lib-esm/components/Stepper/index.js.map +0 -1
  211. package/lib-esm/components/Tabs/index.js +0 -3
  212. package/lib-esm/components/Tabs/index.js.map +0 -1
  213. package/lib-esm/components/Toast/ToastStory.js +0 -35
  214. package/lib-esm/components/Toast/ToastStory.js.map +0 -1
  215. package/lib-esm/components/Toast/index.js +0 -2
  216. package/lib-esm/components/Toast/index.js.map +0 -1
  217. package/lib-esm/components/Tooltip/index.js +0 -2
  218. package/lib-esm/components/Tooltip/index.js.map +0 -1
  219. package/lib-esm/icons/index.js +0 -9
  220. package/lib-esm/icons/index.js.map +0 -1
  221. package/lib-esm/index.js +0 -2
  222. package/lib-esm/index.js.map +0 -1
@@ -1,146 +1,148 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
3
- import PropTypes from 'prop-types';
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import React, { useState, useRef, useId, useCallback, useEffect } from 'react';
4
3
  import styled from '@emotion/styled';
5
- import { Card } from '../Card';
6
- export var POPOVER_POSITION;
7
- (function (POPOVER_POSITION) {
4
+ import Card from '../Card/Card.js';
5
+
6
+ var POPOVER_POSITION = /*#__PURE__*/ function(POPOVER_POSITION) {
8
7
  POPOVER_POSITION["TOP_LEFT"] = "TOP_LEFT";
9
8
  POPOVER_POSITION["TOP_RIGHT"] = "TOP_RIGHT";
10
9
  POPOVER_POSITION["BOTTOM_LEFT"] = "BOTTOM_LEFT";
11
10
  POPOVER_POSITION["BOTTOM_RIGHT"] = "BOTTOM_RIGHT";
12
- })(POPOVER_POSITION || (POPOVER_POSITION = {}));
13
- const positionMap = {
14
- [POPOVER_POSITION.TOP_LEFT]: `
11
+ return POPOVER_POSITION;
12
+ }({});
13
+ const positionMap$2 = {
14
+ ["TOP_LEFT"]: `
15
15
  bottom: calc(100% - 10px);
16
16
  left: 0;
17
17
  `,
18
- [POPOVER_POSITION.TOP_RIGHT]: `
18
+ ["TOP_RIGHT"]: `
19
19
  bottom: calc(100% - 10px);
20
20
  right: 0;
21
21
  `,
22
- [POPOVER_POSITION.BOTTOM_RIGHT]: `
22
+ ["BOTTOM_RIGHT"]: `
23
23
  top: calc(100% - 10px);
24
24
  right: 0;
25
25
  `,
26
- [POPOVER_POSITION.BOTTOM_LEFT]: `
26
+ ["BOTTOM_LEFT"]: `
27
27
  top: calc(100% - 10px);
28
28
  left: 0;
29
29
  `
30
30
  };
31
- const PopoverDiv = styled.div `
32
- position: relative;
33
- display: inline-flex;
34
- `;
35
- const Popper = styled(Card) `
36
- position: absolute;
37
- width: 100%;
38
- min-width: 200px;
39
- overflow: auto;
40
- animation: enter .3s linear;
41
- border-radius: 3px;
42
- z-index: 1;
43
- transform: translate(${props => props.translateX}px, ${props => props.translateY}px);
44
- ${props => positionMap[props.position]}
45
-
46
- &.closing {
47
- /* max-height: 0px;
48
- opacity: 0;
49
- overflow: hidden; */
50
- animation: exit .3s linear;
51
- }
52
-
53
- @keyframes enter {
54
- from {
55
- max-height: 0px;
56
- opacity: 1;
57
- overflow: hidden;
58
- }
59
- to {
60
- max-height: 300px;
61
- opacity: 1;
62
- overflow: hidden;
63
- }
64
- }
65
-
66
- @keyframes exit {
67
- to {
68
- max-height: 0px;
69
- opacity: 1;
70
- overflow: hidden;
71
- }
72
- from {
73
- max-height: 300px;
74
- opacity: 1;
75
- overflow: hidden;
76
- }
77
- }
78
- `;
31
+ const PopoverDiv = /*#__PURE__*/ styled("div", {
32
+ target: "egy90l40",
33
+ label: "PopoverDiv"
34
+ })("position:relative;display:inline-flex;");
35
+ const Popper = /*#__PURE__*/ styled(Card, {
36
+ target: "egy90l41",
37
+ label: "Popper"
38
+ })("position:absolute;width:100%;min-width:200px;overflow:auto;animation:enter 0.3s linear;border-radius:3px;z-index:1;transform:translate(", (props)=>props.translateX, "px,", (props)=>props.translateY, "px);", (props)=>positionMap$2[props.position], " &.closing{animation:exit 0.3s linear;}@keyframes enter{from{max-height:0px;opacity:1;overflow:hidden;}to{max-height:300px;opacity:1;overflow:hidden;}}@keyframes exit{to{max-height:0px;opacity:1;overflow:hidden;}from{max-height:300px;opacity:1;overflow:hidden;}}");
79
39
  const KEY_CODES = {
80
40
  ESC: 27
81
41
  };
82
- export default function Popover(props) {
83
- const [open, setOpen] = useState(props.open);
42
+ function PopoverComponent(props, ref) {
43
+ const { open: propsOpen, element, position = "BOTTOM_LEFT", closeOnEsc = true, onClose, children, ...rest } = props;
44
+ const [open, setOpen] = useState(propsOpen);
84
45
  const [closing, setClosing] = useState(false);
85
- const [translate, setTranslate] = useState({ x: 0, y: 0 });
86
- const popperRef = useRef();
87
- const containerRef = useRef();
88
- const close = () => {
46
+ const [translate, setTranslate] = useState({
47
+ x: 0,
48
+ y: 0
49
+ });
50
+ const popperRef = useRef(null);
51
+ const containerRef = useRef(null);
52
+ const triggerRef = useRef(null);
53
+ const closeTimeoutRef = useRef(null);
54
+ const focusTimeoutRef = useRef(null);
55
+ const popperId = useId();
56
+ const triggerId = useId();
57
+ const close = useCallback(()=>{
58
+ // Clear any existing timeouts first
59
+ if (closeTimeoutRef.current) {
60
+ clearTimeout(closeTimeoutRef.current);
61
+ }
62
+ if (focusTimeoutRef.current) {
63
+ clearTimeout(focusTimeoutRef.current);
64
+ }
89
65
  setClosing(true);
90
- setTimeout(() => {
66
+ closeTimeoutRef.current = setTimeout(()=>{
91
67
  setOpen(false);
92
- setTranslate({ x: 0, y: 0 });
93
- if (props.onClose) {
94
- props.onClose();
68
+ setTranslate({
69
+ x: 0,
70
+ y: 0
71
+ });
72
+ if (onClose) {
73
+ onClose();
95
74
  }
96
75
  setClosing(false);
76
+ // Restore focus to the trigger element after animation completes
77
+ focusTimeoutRef.current = setTimeout(()=>{
78
+ if (triggerRef.current && document.body.contains(triggerRef.current)) {
79
+ triggerRef.current.focus();
80
+ }
81
+ focusTimeoutRef.current = null;
82
+ }, 50);
83
+ closeTimeoutRef.current = null;
97
84
  }, 280);
98
- };
99
- const keyupEventHandler = (e) => {
100
- if (props.closeOnEsc && e.keyCode === KEY_CODES.ESC) {
85
+ }, [
86
+ onClose
87
+ ]);
88
+ const keyupEventHandler = useCallback((e)=>{
89
+ if (closeOnEsc && e.keyCode === KEY_CODES.ESC) {
101
90
  close();
102
91
  }
103
- };
104
- const clickOutsideHandler = (e) => {
92
+ }, [
93
+ close,
94
+ closeOnEsc
95
+ ]);
96
+ const clickOutsideHandler = useCallback((e)=>{
105
97
  if (containerRef.current && !containerRef.current.contains(e.target)) {
106
98
  close();
107
99
  }
108
- };
100
+ }, [
101
+ close
102
+ ]);
109
103
  /**
110
104
  * Get called on popover mount.
111
- */
112
- useEffect(() => {
105
+ */ useEffect(()=>{
113
106
  document.addEventListener('keyup', keyupEventHandler);
114
- return () => {
107
+ return ()=>{
115
108
  document.removeEventListener('keyup', keyupEventHandler);
116
- document.removeEventListener('click', clickOutsideHandler);
117
109
  };
118
- }, []);
119
- useEffect(() => {
120
- if (props.open) {
110
+ }, [
111
+ keyupEventHandler
112
+ ]);
113
+ useEffect(()=>{
114
+ if (propsOpen) {
121
115
  setOpen(true);
122
116
  // Use requestAnimationFrame to add listener after current event loop
123
- requestAnimationFrame(() => {
117
+ const rafId = requestAnimationFrame(()=>{
124
118
  document.addEventListener('click', clickOutsideHandler);
125
119
  });
126
- }
127
- else {
120
+ return ()=>{
121
+ cancelAnimationFrame(rafId);
122
+ document.removeEventListener('click', clickOutsideHandler);
123
+ };
124
+ } else {
128
125
  if (open) {
129
126
  close();
130
127
  }
131
128
  }
132
- return () => {
133
- document.removeEventListener('click', clickOutsideHandler);
134
- };
135
- }, [props.open]);
136
- useEffect(() => {
129
+ }, [
130
+ propsOpen,
131
+ open,
132
+ clickOutsideHandler,
133
+ close
134
+ ]);
135
+ useEffect(()=>{
137
136
  if (open) {
138
- const { top, left, right } = popperRef.current.getBoundingClientRect();
139
- const height = popperRef.current.scrollHeight;
137
+ const { top = 0, left = 0, right = 0 } = popperRef.current?.getBoundingClientRect() ?? {};
138
+ const height = popperRef.current?.scrollHeight ?? 0;
140
139
  const viewportWidth = document.documentElement.clientWidth;
141
140
  const viewportHeight = document.documentElement.clientHeight;
142
- const translation = { x: 0, y: 0 };
143
- if (props.position === POPOVER_POSITION.BOTTOM_LEFT) {
141
+ const translation = {
142
+ x: 0,
143
+ y: 0
144
+ };
145
+ if (position === "BOTTOM_LEFT") {
144
146
  // overflow can happen at bottom and right
145
147
  if (viewportHeight - top - height < 0) {
146
148
  translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);
@@ -148,8 +150,7 @@ export default function Popover(props) {
148
150
  if (viewportWidth - right < 0) {
149
151
  translation.x = -1 * (Math.abs(viewportWidth - right) + 5);
150
152
  }
151
- }
152
- else if (props.position == POPOVER_POSITION.BOTTOM_RIGHT) {
153
+ } else if (position == "BOTTOM_RIGHT") {
153
154
  // overflow can happen at bottom and left
154
155
  if (viewportHeight - top - height < 0) {
155
156
  translation.y = -1 * (Math.abs(viewportHeight - top - height) + 5);
@@ -157,8 +158,7 @@ export default function Popover(props) {
157
158
  if (left < 0) {
158
159
  translation.x = Math.abs(left) + 5;
159
160
  }
160
- }
161
- else if (props.position === POPOVER_POSITION.TOP_LEFT) {
161
+ } else if (position === "TOP_LEFT") {
162
162
  // overflow can happen at top and right
163
163
  if (top - height < 0) {
164
164
  translation.y = Math.abs(top - height) + 5;
@@ -166,8 +166,7 @@ export default function Popover(props) {
166
166
  if (viewportWidth - right < 0) {
167
167
  translation.x = -1 * (Math.abs(viewportWidth - right) + 5);
168
168
  }
169
- }
170
- else {
169
+ } else {
171
170
  // overflow can happen at top and left
172
171
  if (top - height < 0) {
173
172
  translation.y = Math.abs(top - height) + 5;
@@ -179,30 +178,64 @@ export default function Popover(props) {
179
178
  // Note it can still overflow, but in that case fitting popper inside the
180
179
  // window is not possible.
181
180
  setTranslate(translation);
182
- popperRef.current.focus();
181
+ popperRef.current?.focus();
183
182
  }
184
- }, [open]);
185
- return (_jsxs(PopoverDiv, { ref: containerRef, children: [_jsx(props.element, {}), open && (_jsx(Popper, { elevated: true, tabIndex: 0, position: props.position, translateX: translate.x, translateY: translate.y, className: closing && 'closing', ref: popperRef, onClick: e => { e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); }, children: props.children }))] }));
183
+ }, [
184
+ open,
185
+ position
186
+ ]);
187
+ /**
188
+ * Cleanup timeouts on unmount
189
+ */ useEffect(()=>{
190
+ return ()=>{
191
+ if (closeTimeoutRef.current) {
192
+ clearTimeout(closeTimeoutRef.current);
193
+ }
194
+ if (focusTimeoutRef.current) {
195
+ clearTimeout(focusTimeoutRef.current);
196
+ }
197
+ };
198
+ }, []);
199
+ const forwardRef = (node)=>{
200
+ containerRef.current = node;
201
+ if (typeof ref === 'function') {
202
+ ref(node);
203
+ } else if (ref) {
204
+ ref.current = node;
205
+ }
206
+ };
207
+ return /*#__PURE__*/ jsxs(PopoverDiv, {
208
+ ref: forwardRef,
209
+ ...rest,
210
+ children: [
211
+ /*#__PURE__*/ React.createElement(element, {
212
+ ref: triggerRef,
213
+ id: triggerId,
214
+ 'aria-expanded': open,
215
+ 'aria-haspopup': 'dialog',
216
+ 'aria-controls': popperId
217
+ }),
218
+ open && /*#__PURE__*/ jsx(Popper, {
219
+ elevated: true,
220
+ tabIndex: 0,
221
+ role: "dialog",
222
+ "aria-labelledby": triggerId,
223
+ id: popperId,
224
+ position: position,
225
+ translateX: translate.x,
226
+ translateY: translate.y,
227
+ className: closing ? 'closing' : '',
228
+ ref: popperRef,
229
+ onClick: (e)=>{
230
+ e.stopPropagation();
231
+ e.nativeEvent.stopImmediatePropagation();
232
+ },
233
+ children: children
234
+ })
235
+ ]
236
+ });
186
237
  }
187
- Popover.propTypes = {
188
- /** Opens the popover */
189
- open: PropTypes.bool.isRequired,
190
- /** Anchor element for the popover */
191
- element: PropTypes.func,
192
- /** Position of the popover around anchor element */
193
- position: PropTypes.oneOf([
194
- POPOVER_POSITION.TOP_LEFT,
195
- POPOVER_POSITION.TOP_RIGHT,
196
- POPOVER_POSITION.BOTTOM_LEFT,
197
- POPOVER_POSITION.BOTTOM_RIGHT,
198
- ]),
199
- /** If the popover should close on `esc` key press */
200
- closeOnEsc: PropTypes.bool,
201
- /** Popover close callback */
202
- onClose: PropTypes.func,
203
- };
204
- Popover.defaultProps = {
205
- closeOnEsc: true,
206
- position: POPOVER_POSITION.BOTTOM_LEFT,
207
- };
208
- //# sourceMappingURL=Popover.js.map
238
+ const Popover = /*#__PURE__*/ React.forwardRef(PopoverComponent);
239
+
240
+ export { POPOVER_POSITION, Popover as default };
241
+ //# sourceMappingURL=Popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAE/B,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;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,WA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,CACH,MAAC,UAAU,IAAC,GAAG,EAAE,YAAY,aACzB,KAAC,KAAK,CAAC,OAAO,KAAG,EACf,IAAI,IAAI,CACN,KAAC,MAAM,IACH,QAAQ,QACR,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,SAAS,CAAC,CAAC,EACvB,UAAU,EAAE,SAAS,CAAC,CAAC,EACvB,SAAS,EAAE,OAAO,IAAI,SAAS,EAC/B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC,YAE/E,KAAK,CAAC,QAAQ,GACV,CACZ,IACQ,CAChB,CAAA;AACL,CAAC;AAED,OAAO,CAAC,SAAS,GAAG;IAChB,wBAAwB;IACxB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC/B,qCAAqC;IACrC,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;QACtB,gBAAgB,CAAC,QAAQ;QACzB,gBAAgB,CAAC,SAAS;QAC1B,gBAAgB,CAAC,WAAW;QAC5B,gBAAgB,CAAC,YAAY;KAChC,CAAC;IACF,qDAAqD;IACrD,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,6BAA6B;IAC7B,OAAO,EAAE,SAAS,CAAC,IAAI;CAC1B,CAAA;AAED,OAAO,CAAC,YAAY,GAAG;IACnB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,gBAAgB,CAAC,WAAW;CACzC,CAAA"}
1
+ {"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useId, useRef, useState } from 'react';\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\ntype PopoverProps = {\n /** Opens the popover */\n open: boolean;\n /** Anchor element for the popover */\n element: React.ElementType;\n /**\n * Position of the popover around anchor element\n * @default POPOVER_POSITION.BOTTOM_LEFT\n */\n position?: POPOVER_POSITION;\n /**\n * If the popover should close on `esc` key press\n * @default true\n */\n closeOnEsc?: boolean;\n /** Popover close callback */\n onClose?: () => void;\n};\n\nfunction PopoverComponent(\n props: React.PropsWithChildren<PopoverProps>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n open: propsOpen,\n element,\n position = POPOVER_POSITION.BOTTOM_LEFT,\n closeOnEsc = true,\n onClose,\n children,\n ...rest\n } = props;\n\n const [open, setOpen] = useState<boolean>(propsOpen);\n const [closing, setClosing] = useState<boolean>(false);\n const [translate, setTranslate] = useState<Translate>({ x: 0, y: 0 });\n const popperRef = useRef<HTMLDivElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const closeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const focusTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const popperId = useId();\n const triggerId = useId();\n\n const close = useCallback(() => {\n // Clear any existing timeouts first\n if (closeTimeoutRef.current) {\n clearTimeout(closeTimeoutRef.current);\n }\n if (focusTimeoutRef.current) {\n clearTimeout(focusTimeoutRef.current);\n }\n\n setClosing(true);\n closeTimeoutRef.current = setTimeout(() => {\n setOpen(false);\n setTranslate({ x: 0, y: 0 });\n\n if (onClose) {\n onClose();\n }\n setClosing(false);\n\n // Restore focus to the trigger element after animation completes\n focusTimeoutRef.current = setTimeout(() => {\n if (triggerRef.current && document.body.contains(triggerRef.current)) {\n triggerRef.current.focus();\n }\n focusTimeoutRef.current = null;\n }, 50);\n closeTimeoutRef.current = null;\n }, 280);\n }, [onClose]);\n\n const keyupEventHandler = useCallback(\n (e: KeyboardEvent) => {\n if (closeOnEsc && e.keyCode === KEY_CODES.ESC) {\n close();\n }\n },\n [close, 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 };\n }, [keyupEventHandler]);\n\n useEffect(() => {\n if (propsOpen) {\n setOpen(true);\n // Use requestAnimationFrame to add listener after current event loop\n const rafId = requestAnimationFrame(() => {\n document.addEventListener('click', clickOutsideHandler);\n });\n\n return () => {\n cancelAnimationFrame(rafId);\n document.removeEventListener('click', clickOutsideHandler);\n };\n } else {\n if (open) {\n close();\n }\n }\n }, [propsOpen, open, clickOutsideHandler, close]);\n\n useEffect(() => {\n if (open) {\n const {\n top = 0,\n left = 0,\n right = 0,\n } = popperRef.current?.getBoundingClientRect() ?? {};\n const height = popperRef.current?.scrollHeight ?? 0;\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n const translation = { x: 0, y: 0 };\n\n if (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 (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 (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, position]);\n\n /**\n * Cleanup timeouts on unmount\n */\n useEffect(() => {\n return () => {\n if (closeTimeoutRef.current) {\n clearTimeout(closeTimeoutRef.current);\n }\n if (focusTimeoutRef.current) {\n clearTimeout(focusTimeoutRef.current);\n }\n };\n }, []);\n\n const forwardRef = (node: HTMLDivElement | null) => {\n containerRef.current = node;\n\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n };\n\n return (\n <PopoverDiv ref={forwardRef} {...rest}>\n {React.createElement(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={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 {children}\n </Popper>\n )}\n </PopoverDiv>\n );\n}\n\nconst Popover = React.forwardRef(PopoverComponent);\nexport default Popover;\n"],"names":["POPOVER_POSITION","positionMap","PopoverDiv","styled","Popper","Card","props","translateX","translateY","position","KEY_CODES","ESC","PopoverComponent","ref","open","propsOpen","element","closeOnEsc","onClose","children","rest","setOpen","useState","closing","setClosing","translate","setTranslate","x","y","popperRef","useRef","containerRef","triggerRef","closeTimeoutRef","focusTimeoutRef","popperId","useId","triggerId","close","useCallback","current","clearTimeout","setTimeout","document","body","contains","focus","keyupEventHandler","e","keyCode","clickOutsideHandler","target","useEffect","addEventListener","removeEventListener","rafId","requestAnimationFrame","cancelAnimationFrame","top","left","right","getBoundingClientRect","height","scrollHeight","viewportWidth","documentElement","clientWidth","viewportHeight","clientHeight","translation","Math","abs","forwardRef","node","_jsxs","React","createElement","id","_jsx","elevated","tabIndex","role","aria-labelledby","className","onClick","stopPropagation","nativeEvent","stopImmediatePropagation","Popover"],"mappings":";;;;;AAIO,IAAA,gBAAKA,iBAAAA,SAAAA,gBAAAA,EAAAA;;;;;AAAAA,IAAAA,OAAAA,gBAAAA;AAKX,CAAA,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,EAAiB7C,SAAAA;gBACjBwC,EAAAA,EAAI1C,QAAAA;gBACJ1B,QAAAA,EAAUA,QAAAA;AACVF,gBAAAA,UAAAA,EAAYkB,UAAUE,CAAC;AACvBnB,gBAAAA,UAAAA,EAAYiB,UAAUG,CAAC;AACvBuD,gBAAAA,SAAAA,EAAW5D,UAAU,SAAA,GAAY,EAAA;gBACjCV,GAAAA,EAAKgB,SAAAA;AACLuD,gBAAAA,OAAAA,EAAS,CAACpC,CAAAA,GAAAA;AACNA,oBAAAA,CAAAA,CAAEqC,eAAe,EAAA;oBACjBrC,CAAAA,CAAEsC,WAAW,CAACC,wBAAwB,EAAA;AAC1C,gBAAA,CAAA;AAECpE,gBAAAA,QAAAA,EAAAA;;;;AAKrB;AAEA,MAAMqE,OAAAA,iBAAUb,KAAAA,CAAMH,UAAU,CAAC5D,gBAAAA;;;;"}
@@ -1,13 +1,15 @@
1
- import PropTypes from 'prop-types';
2
- declare function Spinner(props: SpinnerProp): import("@emotion/react/jsx-runtime").JSX.Element;
3
- declare namespace Spinner {
4
- var propTypes: {
5
- /** Spinner's size */
6
- size: PropTypes.Requireable<number>;
7
- };
8
- var defaultProps: {
9
- size: number;
10
- };
11
- }
12
- type SpinnerProp = PropTypes.InferProps<typeof Spinner.propTypes>;
1
+ import React from 'react';
2
+ type SpinnerProp = {
3
+ /**
4
+ * Spinner's size
5
+ * @default 30
6
+ */
7
+ size?: number;
8
+ /**
9
+ * Accessible label for screen readers
10
+ * @default 'Loading'
11
+ */
12
+ label?: string;
13
+ };
14
+ declare const Spinner: React.ForwardRefExoticComponent<SpinnerProp & React.RefAttributes<HTMLDivElement>>;
13
15
  export default Spinner;
@@ -1,30 +1,25 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from '@emotion/react/jsx-runtime';
2
+ import React from 'react';
2
3
  import styled from '@emotion/styled';
3
- import PropTypes from 'prop-types';
4
- import constants from '../../shared/constants';
5
- const SpinnerDiv = styled.div `
6
- border: 4px solid var(--primary, ${constants.PRIMARY});
7
- border-top: 4px solid var(--border-light-color, ${constants.BORDER_LIGHT_COLOR});
8
- border-radius: 50%;
9
- width: ${props => props.size}px;
10
- height: ${props => props.size}px;
11
- margin: 0 auto;
12
- animation: spin 1s linear infinite;
4
+ import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
13
5
 
14
- @keyframes spin {
15
- 0% { transform: rotate(0deg); }
16
- 100% { transform: rotate(360deg); }
17
- }
18
- `;
19
- function Spinner(props) {
20
- return _jsx(SpinnerDiv, Object.assign({}, props));
6
+ const SpinnerDiv = /*#__PURE__*/ styled("div", {
7
+ target: "ejfhe5c0",
8
+ label: "SpinnerDiv"
9
+ })("border:4px solid ", getThemeValue(THEME_NAME.PRIMARY), ";border-top:4px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";border-radius:50%;width:", (props)=>props.size, "px;height:", (props)=>props.size, "px;margin:0 auto;animation:spin 1s linear infinite;@keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}");
10
+ function SpinnerComponent(props, ref) {
11
+ const { label = 'Loading', size = 30, ...rest } = props;
12
+ return /*#__PURE__*/ jsx(SpinnerDiv, {
13
+ ...rest,
14
+ ref: ref,
15
+ size: size,
16
+ role: "status",
17
+ "aria-label": label || undefined,
18
+ "aria-live": "polite",
19
+ "aria-busy": "true"
20
+ });
21
21
  }
22
- Spinner.propTypes = {
23
- /** Spinner's size */
24
- size: PropTypes.number
25
- };
26
- Spinner.defaultProps = {
27
- size: 30,
28
- };
29
- export default Spinner;
30
- //# sourceMappingURL=Spinner.js.map
22
+ const Spinner = /*#__PURE__*/ React.forwardRef(SpinnerComponent);
23
+
24
+ export { Spinner as default };
25
+ //# sourceMappingURL=Spinner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../../../src/components/Spinner/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAa;uCACH,SAAS,CAAC,OAAO;sDACF,SAAS,CAAC,kBAAkB;;aAErE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI;cAClB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI;;;;;;;;CAQhC,CAAC;AAEF,SAAS,OAAO,CAAC,KAAkB;IAC/B,OAAO,KAAC,UAAU,oBAAK,KAAK,EAAI,CAAA;AACpC,CAAC;AAID,OAAO,CAAC,SAAS,GAAG;IAChB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC,MAAM;CACzB,CAAA;AAED,OAAO,CAAC,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACX,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Spinner.js","sources":["../../../src/components/Spinner/Spinner.tsx"],"sourcesContent":["import React from 'react';\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\ntype SpinnerProp = {\n /**\n * Spinner's size\n * @default 30\n */\n size?: number;\n /**\n * Accessible label for screen readers\n * @default 'Loading'\n */\n label?: string;\n};\n\nfunction SpinnerComponent(props: SpinnerProp, ref: React.Ref<HTMLDivElement>) {\n const { label = 'Loading', size = 30, ...rest } = props;\n return (\n <SpinnerDiv\n {...rest}\n ref={ref}\n size={size}\n role=\"status\"\n aria-label={label || undefined}\n aria-live=\"polite\"\n aria-busy=\"true\"\n />\n );\n}\n\nconst Spinner = React.forwardRef<HTMLDivElement, SpinnerProp>(SpinnerComponent);\nexport default Spinner;\n"],"names":["SpinnerDiv","styled","getThemeValue","THEME_NAME","PRIMARY","BORDER_LIGHT_COLOR","props","size","SpinnerComponent","ref","label","rest","_jsx","role","aria-label","undefined","aria-live","aria-busy","Spinner","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,UAAAA,iBAAaC,MAAAA,CAAAA,KAAAA,EAAAA;;;AACKC,CAAAA,CAAAA,CAAAA,mBAAAA,EAAAA,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,CAAA,EAAA,wBAAA,EAC5BF,aAAAA,CAAcC,WAAWE,kBAAkB,CAAA,EAAA,2BAAA,EAE1D,CAACC,KAAAA,GAAUA,MAAMC,IAAI,EAAA,YAAA,EACpB,CAACD,KAAAA,GAAUA,MAAMC,IAAI,EAAA,gIAAA,CAAA;AA2BnC,SAASC,gBAAAA,CAAiBF,KAAkB,EAAEG,GAA8B,EAAA;IACxE,MAAM,EAAEC,QAAQ,SAAS,EAAEH,OAAO,EAAE,EAAE,GAAGI,IAAAA,EAAM,GAAGL,KAAAA;AAClD,IAAA,qBACIM,GAAA,CAACZ,UAAAA,EAAAA;AACI,QAAA,GAAGW,IAAI;QACRF,GAAAA,EAAKA,GAAAA;QACLF,IAAAA,EAAMA,IAAAA;QACNM,IAAAA,EAAK,QAAA;AACLC,QAAAA,YAAAA,EAAYJ,KAAAA,IAASK,SAAAA;QACrBC,WAAAA,EAAU,QAAA;QACVC,WAAAA,EAAU;;AAGtB;AAEA,MAAMC,OAAAA,iBAAUC,KAAAA,CAAMC,UAAU,CAA8BZ,gBAAAA;;;;"}
@@ -1,17 +1,20 @@
1
1
  import React from 'react';
2
- interface StepProps {
3
- /** Name of the step to be displayed in the header */
2
+ declare const Step: React.ForwardRefExoticComponent<{
3
+ /**
4
+ * Name of the step to be displayed in the header
5
+ */
4
6
  name: string;
5
- /** Disables the step */
7
+ /**
8
+ * Disables the step
9
+ * @default false
10
+ */
6
11
  disabled?: boolean;
7
- /** Marks the step as completed */
12
+ /**
13
+ * Marks the step as completed
14
+ * @default false
15
+ */
8
16
  completed?: boolean;
9
- }
10
- declare function Step(props: React.PropsWithChildren<StepProps>): import("@emotion/react/jsx-runtime").JSX.Element;
11
- declare namespace Step {
12
- var defaultProps: {
13
- disabled: boolean;
14
- completed: boolean;
15
- };
16
- }
17
+ } & React.HTMLAttributes<HTMLDivElement> & {
18
+ children?: React.ReactNode | undefined;
19
+ } & React.RefAttributes<HTMLDivElement>>;
17
20
  export default Step;
@@ -1,27 +1,20 @@
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
- };
12
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from '@emotion/react/jsx-runtime';
2
+ import React from 'react';
13
3
  import styled from '@emotion/styled';
14
- const Container = styled.div `
15
- flex: 1;
16
- display: flex;
17
- flex-direction: column;
18
- `;
19
- export default function Step(props) {
20
- const { name, disabled, completed } = props, rest = __rest(props, ["name", "disabled", "completed"]);
21
- return _jsx(Container, Object.assign({}, rest));
4
+
5
+ const Container = /*#__PURE__*/ styled("div", {
6
+ target: "e67x9110",
7
+ label: "Container"
8
+ })("flex:1;display:flex;flex-direction:column;");
9
+ function StepComponent(props, ref) {
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+ const { name, disabled, completed, ...rest } = props;
12
+ return /*#__PURE__*/ jsx(Container, {
13
+ ...rest,
14
+ ref: ref
15
+ });
22
16
  }
23
- Step.defaultProps = {
24
- disabled: false,
25
- completed: false,
26
- };
27
- //# sourceMappingURL=Step.js.map
17
+ const Step = /*#__PURE__*/ React.forwardRef(StepComponent);
18
+
19
+ export { Step as default };
20
+ //# sourceMappingURL=Step.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step.js","sourceRoot":"","sources":["../../../src/components/Stepper/Step.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI3B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAyC;IAClE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA9C,iCAAsC,CAAQ,CAAC;IACrD,OAAO,KAAC,SAAS,oBAAK,IAAI,EAAI,CAAC;AACnC,CAAC;AAED,IAAI,CAAC,YAAY,GAAG;IAChB,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,KAAK;CACnB,CAAA"}
1
+ {"version":3,"file":"Step.js","sources":["../../../src/components/Stepper/Step.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\n\nconst Container = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n`;\n\ntype StepProps = {\n /**\n * Name of the step to be displayed in the header\n */\n name: string;\n /**\n * Disables the step\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the step as completed\n * @default false\n */\n completed?: boolean;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nfunction StepComponent(props: React.PropsWithChildren<StepProps>, ref: React.Ref<HTMLDivElement>) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { name, disabled, completed, ...rest } = props;\n return <Container {...rest} ref={ref} />;\n}\n\nconst Step = React.forwardRef(StepComponent);\nexport default Step;\n"],"names":["Container","styled","StepComponent","props","ref","name","disabled","completed","rest","_jsx","Step","React","forwardRef"],"mappings":";;;;AAGA,MAAMA,SAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAuBlB,SAASC,aAAAA,CAAcC,KAAyC,EAAEC,GAA8B,EAAA;;IAE5F,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,IAAAA,EAAM,GAAGL,KAAAA;AAC/C,IAAA,qBAAOM,GAAA,CAACT,SAAAA,EAAAA;AAAW,QAAA,GAAGQ,IAAI;QAAEJ,GAAAA,EAAKA;;AACrC;AAEA,MAAMM,IAAAA,iBAAOC,KAAAA,CAAMC,UAAU,CAACV,aAAAA;;;;"}
@@ -1,19 +1,13 @@
1
- import PropTypes from 'prop-types';
2
- type StepperProps = {
3
- active: number;
1
+ import React from 'react';
2
+ declare const Stepper: React.ForwardRefExoticComponent<{
3
+ /**
4
+ * Index of currently active step
5
+ * @default 0
6
+ */
7
+ active?: number;
8
+ /** Callback function for click event on a step */
4
9
  onStepClick?: (index: number) => void;
5
- children: any;
6
- };
7
- declare function Stepper(props: StepperProps): import("@emotion/react/jsx-runtime").JSX.Element;
8
- declare namespace Stepper {
9
- var propTypes: {
10
- /** Index of currently active step */
11
- active: PropTypes.Requireable<number>;
12
- /** Callback function for click event on a step */
13
- onStepClick: PropTypes.Requireable<(...args: any[]) => any>;
14
- };
15
- var defaultProps: {
16
- active: number;
17
- };
18
- }
10
+ } & {
11
+ children?: React.ReactNode | undefined;
12
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
19
13
  export default Stepper;