no-frills-ui 0.0.14-alpha.3 → 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.
Files changed (146) hide show
  1. package/dist/index.js +1622 -539
  2. package/dist/index.js.map +1 -1
  3. package/lib-esm/components/Accordion/AccordionStep.d.ts.map +1 -1
  4. package/lib-esm/components/Accordion/AccordionStep.js +27 -38
  5. package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
  6. package/lib-esm/components/Badge/Badge.js +7 -7
  7. package/lib-esm/components/Badge/Badge.js.map +1 -1
  8. package/lib-esm/components/Button/ActionButton.d.ts.map +1 -1
  9. package/lib-esm/components/Button/ActionButton.js +12 -11
  10. package/lib-esm/components/Button/ActionButton.js.map +1 -1
  11. package/lib-esm/components/Button/Button.d.ts +2 -2
  12. package/lib-esm/components/Button/Button.d.ts.map +1 -1
  13. package/lib-esm/components/Button/Button.js +19 -14
  14. package/lib-esm/components/Button/Button.js.map +1 -1
  15. package/lib-esm/components/Button/IconButton.d.ts.map +1 -1
  16. package/lib-esm/components/Button/IconButton.js +15 -14
  17. package/lib-esm/components/Button/IconButton.js.map +1 -1
  18. package/lib-esm/components/Button/LinkButton.d.ts.map +1 -1
  19. package/lib-esm/components/Button/LinkButton.js +7 -6
  20. package/lib-esm/components/Button/LinkButton.js.map +1 -1
  21. package/lib-esm/components/Button/RaisedButton.d.ts.map +1 -1
  22. package/lib-esm/components/Button/RaisedButton.js +15 -14
  23. package/lib-esm/components/Button/RaisedButton.js.map +1 -1
  24. package/lib-esm/components/Card/Card.d.ts.map +1 -1
  25. package/lib-esm/components/Card/Card.js +4 -4
  26. package/lib-esm/components/Card/Card.js.map +1 -1
  27. package/lib-esm/components/Chip/Chip.d.ts +5 -2
  28. package/lib-esm/components/Chip/Chip.d.ts.map +1 -1
  29. package/lib-esm/components/Chip/Chip.js +20 -14
  30. package/lib-esm/components/Chip/Chip.js.map +1 -1
  31. package/lib-esm/components/ChipInput/ChipInput.d.ts +9 -0
  32. package/lib-esm/components/ChipInput/ChipInput.d.ts.map +1 -1
  33. package/lib-esm/components/ChipInput/ChipInput.js +63 -24
  34. package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
  35. package/lib-esm/components/Dialog/AlertDialog.d.ts.map +1 -1
  36. package/lib-esm/components/Dialog/AlertDialog.js +4 -1
  37. package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
  38. package/lib-esm/components/Dialog/Dialog.d.ts +32 -2
  39. package/lib-esm/components/Dialog/Dialog.d.ts.map +1 -1
  40. package/lib-esm/components/Dialog/Dialog.js +84 -1
  41. package/lib-esm/components/Dialog/Dialog.js.map +1 -1
  42. package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +24 -0
  43. package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts.map +1 -1
  44. package/lib-esm/components/DragAndDrop/DragAndDrop.js +85 -3
  45. package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
  46. package/lib-esm/components/DragAndDrop/DragItem.d.ts +4 -0
  47. package/lib-esm/components/DragAndDrop/DragItem.d.ts.map +1 -1
  48. package/lib-esm/components/DragAndDrop/DragItem.js +92 -12
  49. package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
  50. package/lib-esm/components/DragAndDrop/types.d.ts +19 -0
  51. package/lib-esm/components/DragAndDrop/types.d.ts.map +1 -1
  52. package/lib-esm/components/DragAndDrop/types.js.map +1 -1
  53. package/lib-esm/components/Drawer/Drawer.d.ts +76 -1
  54. package/lib-esm/components/Drawer/Drawer.d.ts.map +1 -1
  55. package/lib-esm/components/Drawer/Drawer.js +158 -24
  56. package/lib-esm/components/Drawer/Drawer.js.map +1 -1
  57. package/lib-esm/components/Groups/Group.d.ts.map +1 -1
  58. package/lib-esm/components/Groups/Group.js +10 -8
  59. package/lib-esm/components/Groups/Group.js.map +1 -1
  60. package/lib-esm/components/Groups/GroupLabel.d.ts.map +1 -1
  61. package/lib-esm/components/Groups/GroupLabel.js +3 -3
  62. package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
  63. package/lib-esm/components/Input/Checkbox.d.ts.map +1 -1
  64. package/lib-esm/components/Input/Checkbox.js +63 -58
  65. package/lib-esm/components/Input/Checkbox.js.map +1 -1
  66. package/lib-esm/components/Input/Dropdown.d.ts +8 -0
  67. package/lib-esm/components/Input/Dropdown.d.ts.map +1 -1
  68. package/lib-esm/components/Input/Dropdown.js +54 -31
  69. package/lib-esm/components/Input/Dropdown.js.map +1 -1
  70. package/lib-esm/components/Input/Input.d.ts.map +1 -1
  71. package/lib-esm/components/Input/Input.js +27 -22
  72. package/lib-esm/components/Input/Input.js.map +1 -1
  73. package/lib-esm/components/Input/Radio.d.ts.map +1 -1
  74. package/lib-esm/components/Input/Radio.js +58 -42
  75. package/lib-esm/components/Input/Radio.js.map +1 -1
  76. package/lib-esm/components/Input/RadioButton.d.ts.map +1 -1
  77. package/lib-esm/components/Input/RadioButton.js +12 -12
  78. package/lib-esm/components/Input/RadioButton.js.map +1 -1
  79. package/lib-esm/components/Input/Select.d.ts.map +1 -1
  80. package/lib-esm/components/Input/Select.js +27 -22
  81. package/lib-esm/components/Input/Select.js.map +1 -1
  82. package/lib-esm/components/Input/TextArea.d.ts.map +1 -1
  83. package/lib-esm/components/Input/TextArea.js +27 -22
  84. package/lib-esm/components/Input/TextArea.js.map +1 -1
  85. package/lib-esm/components/Input/Toggle.d.ts.map +1 -1
  86. package/lib-esm/components/Input/Toggle.js +17 -14
  87. package/lib-esm/components/Input/Toggle.js.map +1 -1
  88. package/lib-esm/components/Menu/Menu.d.ts +13 -1
  89. package/lib-esm/components/Menu/Menu.d.ts.map +1 -1
  90. package/lib-esm/components/Menu/Menu.js +98 -3
  91. package/lib-esm/components/Menu/Menu.js.map +1 -1
  92. package/lib-esm/components/Menu/MenuItem.d.ts +6 -3
  93. package/lib-esm/components/Menu/MenuItem.d.ts.map +1 -1
  94. package/lib-esm/components/Menu/MenuItem.js +10 -10
  95. package/lib-esm/components/Menu/MenuItem.js.map +1 -1
  96. package/lib-esm/components/Modal/Modal.d.ts +70 -1
  97. package/lib-esm/components/Modal/Modal.d.ts.map +1 -1
  98. package/lib-esm/components/Modal/Modal.js +145 -11
  99. package/lib-esm/components/Modal/Modal.js.map +1 -1
  100. package/lib-esm/components/Notification/Notification.d.ts +11 -7
  101. package/lib-esm/components/Notification/Notification.d.ts.map +1 -1
  102. package/lib-esm/components/Notification/Notification.js +54 -25
  103. package/lib-esm/components/Notification/Notification.js.map +1 -1
  104. package/lib-esm/components/Notification/NotificationManager.d.ts +11 -1
  105. package/lib-esm/components/Notification/NotificationManager.d.ts.map +1 -1
  106. package/lib-esm/components/Notification/NotificationManager.js +43 -8
  107. package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
  108. package/lib-esm/components/Notification/style.d.ts +4 -0
  109. package/lib-esm/components/Notification/style.d.ts.map +1 -1
  110. package/lib-esm/components/Notification/style.js +30 -15
  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.d.ts.map +1 -1
  114. package/lib-esm/components/Notification/types.js.map +1 -1
  115. package/lib-esm/components/Popover/Popover.d.ts.map +1 -1
  116. package/lib-esm/components/Popover/Popover.js +17 -2
  117. package/lib-esm/components/Popover/Popover.js.map +1 -1
  118. package/lib-esm/components/Spinner/Spinner.d.ts +3 -0
  119. package/lib-esm/components/Spinner/Spinner.d.ts.map +1 -1
  120. package/lib-esm/components/Spinner/Spinner.js +19 -4
  121. package/lib-esm/components/Spinner/Spinner.js.map +1 -1
  122. package/lib-esm/components/Stepper/Stepper.d.ts.map +1 -1
  123. package/lib-esm/components/Stepper/Stepper.js +29 -10
  124. package/lib-esm/components/Stepper/Stepper.js.map +1 -1
  125. package/lib-esm/components/Tabs/Tabs.d.ts.map +1 -1
  126. package/lib-esm/components/Tabs/Tabs.js +45 -12
  127. package/lib-esm/components/Tabs/Tabs.js.map +1 -1
  128. package/lib-esm/components/Toast/Toast.d.ts +25 -4
  129. package/lib-esm/components/Toast/Toast.d.ts.map +1 -1
  130. package/lib-esm/components/Toast/Toast.js +114 -18
  131. package/lib-esm/components/Toast/Toast.js.map +1 -1
  132. package/lib-esm/components/Tooltip/Tooltip.d.ts.map +1 -1
  133. package/lib-esm/components/Tooltip/Tooltip.js +16 -5
  134. package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
  135. package/lib-esm/shared/LayerManager.d.ts.map +1 -1
  136. package/lib-esm/shared/LayerManager.js +63 -1
  137. package/lib-esm/shared/LayerManager.js.map +1 -1
  138. package/lib-esm/shared/constants.d.ts +58 -27
  139. package/lib-esm/shared/constants.d.ts.map +1 -1
  140. package/lib-esm/shared/constants.js +88 -25
  141. package/lib-esm/shared/constants.js.map +1 -1
  142. package/lib-esm/shared/styles.d.ts +1 -1
  143. package/lib-esm/shared/styles.d.ts.map +1 -1
  144. package/lib-esm/shared/styles.js +5 -3
  145. package/lib-esm/shared/styles.js.map +1 -1
  146. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationManager.js","sourceRoot":"","sources":["../../../src/components/Notification/NotificationManager.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACH,SAAS,EACT,MAAM,EACN,KAAK,EACL,aAAa,EACb,UAAU,EACV,IAAI,EACJ,WAAW,EACX,MAAM,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAyB,iBAAiB,EAAuB,MAAM,SAAS,CAAC;AAuBxF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;GAEG;AACH,MAAM,mBAAoB,SAAQ,KAAK,CAAC,SAGvC;IAHD;;QAII,UAAK,GAA6B;YAC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AE7B,MAAC,aAAa,IAAC,IAAI,EAAE,IAAI,aACpB,IAAI,KAAK,iBAAiB,CAAC,IAAI,IAAI,KAAC,IAAI,KAAG,EAC3C,IAAI,KAAK,iBAAiB,CAAC,OAAO,IAAI,KAAC,WAAW,KAAG,EACrD,IAAI,KAAK,iBAAiB,CAAC,OAAO,IAAI,KAAC,aAAa,KAAG,EACvD,IAAI,KAAK,iBAAiB,CAAC,MAAM,IAAI,KAAC,YAAY,KAAG,IAC1C,EAChB,MAAC,UAAU,eACP,MAAC,KAAK,IAAC,IAAI,EAAE,IAAI,aACb,KAAC,UAAU,cAAE,KAAK,GAAc,EAChC,KAAC,WAAW,IAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAC5C,KAAC,KAAK,KAAG,GACC,IACV,EACR,KAAC,IAAI,cAAE,WAAW,GAAQ,EACzB,UAAU,IAAI,CACX,KAAC,MAAM,cACH,KAAC,YAAY,IACT,OAAO,EAAE,GAAG,EAAE;4CACV,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;wCACpB,CAAC,YAEA,UAAU,GACA,GACV,CACZ,IACQ,MAhCR,EAAE,CAiCF,CACZ,CAAC;YACN,CAAC,CAAC,GACM,CACf,CAAC;IACN,CAAC;CACJ;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import React from 'react';\nimport { Close, Info, ReportProblem, ErrorOutline, CheckCircle } from '../../icons';\nimport { ActionButton } from '../Button';\nimport {\n Container,\n Notice,\n Title,\n IconContainer,\n FillParent,\n Body,\n CloseButton,\n Footer,\n} from './style';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\ninterface NotificationManagerProps {\n // Notification Position\n position: NOTIFICATION_POSITION;\n // Callback for when stack is emptied\n onEmpty: () => void;\n}\n\n// Notice prop\ninterface NoticeProp extends NotificationOptions {\n leaving?: boolean;\n}\n\n// Manager state\ninterface NotificationManagerState {\n notices: NoticeProp[];\n}\n\ntype timeouts = {\n [id: string]: NodeJS.Timeout;\n};\n\nconst DEFAULT_DURATION = 5000;\n\n/**\n * Notification Manager class\n */\nclass NotificationManager extends React.Component<\n NotificationManagerProps,\n NotificationManagerState\n> {\n state: NotificationManagerState = {\n notices: [],\n };\n\n // bookkeeping for timeouts\n private timeouts: timeouts = {};\n\n // Set of notification ids\n private set = new Set<string>();\n\n /**\n * Removes a notification from stack if the notification with the given id is found.\n *\n * @param id\n */\n public remove = (id: string) => {\n // Trigger leaving animation.\n this.setState({\n notices: this.state.notices.map((notice) => ({\n ...notice,\n leaving: notice.id === id ? true : notice.leaving,\n })),\n });\n this.set.delete(id);\n\n // Remove notification on animation completion.\n setTimeout(() => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (notice) {\n // call close callback, ignore any errors in callback.\n if (notice.onClose) {\n try {\n notice.onClose();\n } catch (e) {\n console.warn('Error in notification close callback', e.message);\n }\n }\n\n // Remove the notification\n this.setState(\n {\n notices: this.state.notices.filter((notice) => notice.id !== id),\n },\n () => {\n // Check if the stack is empty and then call the\n // empty callback function.\n if (this.state.notices.length === 0) {\n this.props.onEmpty();\n }\n },\n );\n }\n }, 550);\n };\n\n /**\n * Adds a notification to stack.\n *\n * @param notice\n */\n public add = (notice: NotificationOptions) => {\n // Generate unique id if not provided.\n const id = notice.id || (Math.random() * 10 ** 7).toFixed(0);\n\n // De-dupe on id\n if (!this.set.has(id)) {\n // Add notice to the top of stack.\n this.setState({\n notices: [\n {\n ...notice,\n id,\n },\n ...this.state.notices,\n ],\n });\n\n // set timeout for closing the notification.\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(\n () => this.remove(id),\n notice.duration || DEFAULT_DURATION,\n );\n }\n\n // Add id to the set.\n this.set.add(id);\n }\n\n return id;\n };\n\n /**\n * Handler for close button click.\n *\n * @param id\n */\n public closeClickHandler = (id: string) => () => {\n this.remove(id);\n };\n\n /**\n * Pause notification when user is hovering over it.\n *\n * @param id\n */\n public pause = (id: string) => () => {\n clearTimeout(this.timeouts[id]);\n };\n\n /**\n * Restart the removal of notification.\n *\n * @param id\n */\n public resume = (id: string) => () => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(() => this.remove(id), DEFAULT_DURATION);\n }\n };\n\n render() {\n return (\n <Container position={this.props.position}>\n {this.state.notices.map((notice) => {\n const {\n id,\n title,\n description,\n leaving,\n type = NOTIFICATION_TYPE.INFO,\n buttonText,\n buttonClick,\n } = notice;\n return (\n <Notice\n key={id}\n {...notice}\n position={this.props.position}\n className={leaving ? 'leave' : ''}\n onMouseEnter={this.pause(id)}\n onMouseLeave={this.resume(id)}\n >\n <IconContainer type={type}>\n {type === NOTIFICATION_TYPE.INFO && <Info />}\n {type === NOTIFICATION_TYPE.SUCCESS && <CheckCircle />}\n {type === NOTIFICATION_TYPE.WARNING && <ReportProblem />}\n {type === NOTIFICATION_TYPE.DANGER && <ErrorOutline />}\n </IconContainer>\n <FillParent>\n <Title type={type}>\n <FillParent>{title}</FillParent>\n <CloseButton onClick={this.closeClickHandler(id)}>\n <Close />\n </CloseButton>\n </Title>\n <Body>{description}</Body>\n {buttonText && (\n <Footer>\n <ActionButton\n onClick={() => {\n buttonClick?.();\n }}\n >\n {buttonText}\n </ActionButton>\n </Footer>\n )}\n </FillParent>\n </Notice>\n );\n })}\n </Container>\n );\n }\n}\n\nexport default NotificationManager;\n"]}
1
+ {"version":3,"file":"NotificationManager.js","sourceRoot":"","sources":["../../../src/components/Notification/NotificationManager.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACH,SAAS,EACT,MAAM,EACN,KAAK,EACL,aAAa,EACb,UAAU,EACV,IAAI,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ACH,MAAC,MAAM,oBAEC,MAAM,IACV,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EACjC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAC5B,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAC7B,IAAI,EAAC,UAAU,aAEf,MAAC,aAAa,IAAC,IAAI,EAAE,IAAI,iBAAc,MAAM,aACxC,IAAI,KAAK,iBAAiB,CAAC,IAAI,IAAI,KAAC,IAAI,KAAG,EAC3C,IAAI,KAAK,iBAAiB,CAAC,OAAO,IAAI,KAAC,WAAW,KAAG,EACrD,IAAI,KAAK,iBAAiB,CAAC,OAAO,IAAI,KAAC,aAAa,KAAG,EACvD,IAAI,KAAK,iBAAiB,CAAC,MAAM,IAAI,KAAC,YAAY,KAAG,IAC1C,EAChB,MAAC,UAAU,eACP,KAAC,KAAK,IAAC,IAAI,EAAE,IAAI,YAAG,KAAK,GAAS,EAClC,KAAC,IAAI,cAAE,WAAW,GAAQ,EACzB,UAAU,IAAI,CACX,KAAC,MAAM,cACH,KAAC,YAAY,IACT,OAAO,EAAE,GAAG,EAAE;oDACV,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;gDACpB,CAAC,YAEA,UAAU,GACA,GACV,CACZ,IACQ,EACb,KAAC,WAAW,IACR,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,gBACvB,oBAAoB,IAAI,oBAAoB,EACxD,QAAQ,EAAE,CAAC,YAEX,KAAC,KAAK,KAAG,GACC,MAnCT,EAAE,CAoCF,CACZ,CAAC;oBACN,CAAC,CAAC,GACA,IACE,CACf,CAAC;IACN,CAAC;CACJ;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import React from 'react';\nimport { Close, Info, ReportProblem, ErrorOutline, CheckCircle } from '../../icons';\nimport { ActionButton } from '../Button';\nimport {\n Container,\n Notice,\n Title,\n IconContainer,\n FillParent,\n Body,\n CloseButton,\n Footer,\n VisuallyHidden,\n} from './style';\nimport { NOTIFICATION_POSITION, NOTIFICATION_TYPE, NotificationOptions } from './types';\n\ninterface NotificationManagerProps {\n // Notification Position\n position: NOTIFICATION_POSITION;\n // Callback for when stack is emptied\n onEmpty: () => void;\n // Aria label for the notification list\n ariaLabel?: string;\n}\n\n// Notice prop\ninterface NoticeProp extends NotificationOptions {\n leaving?: boolean;\n}\n\n// Manager state\ninterface NotificationManagerState {\n notices: NoticeProp[];\n}\n\ntype timeouts = {\n [id: string]: NodeJS.Timeout;\n};\n\nconst DEFAULT_DURATION = 5000;\n\n/**\n * Notification Manager class\n */\nclass NotificationManager extends React.Component<\n NotificationManagerProps,\n NotificationManagerState\n> {\n state: NotificationManagerState = {\n notices: [],\n };\n\n // bookkeeping for timeouts\n private timeouts: timeouts = {};\n\n // Set of notification ids\n private set = new Set<string>();\n\n // Refs for live regions to ensure they exist before updates\n private politeRegionRef = React.createRef<HTMLDivElement>();\n private assertiveRegionRef = React.createRef<HTMLDivElement>();\n\n /**\n * Removes a notification from stack if the notification with the given id is found.\n *\n * @param id\n */\n public remove = (id: string) => {\n // Trigger leaving animation.\n this.setState({\n notices: this.state.notices.map((notice) => ({\n ...notice,\n leaving: notice.id === id ? true : notice.leaving,\n })),\n });\n this.set.delete(id);\n\n // Remove notification on animation completion.\n setTimeout(() => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (notice) {\n // call close callback, ignore any errors in callback.\n if (notice.onClose) {\n try {\n notice.onClose();\n } catch (e) {\n console.warn('Error in notification close callback', e.message);\n }\n }\n\n // Remove the notification\n this.setState(\n {\n notices: this.state.notices.filter((notice) => notice.id !== id),\n },\n () => {\n // Check if the stack is empty and then call the\n // empty callback function.\n if (this.state.notices.length === 0) {\n this.props.onEmpty();\n }\n },\n );\n }\n }, 550);\n };\n\n /**\n * Adds a notification to stack.\n *\n * @param notice\n */\n public add = async (notice: NotificationOptions) => {\n // Generate unique id if not provided.\n const id = notice.id || (Math.random() * 10 ** 7).toFixed(0);\n\n // De-dupe on id\n if (!this.set.has(id)) {\n const type = notice.type || NOTIFICATION_TYPE.INFO;\n const isUrgent =\n type === NOTIFICATION_TYPE.WARNING || type === NOTIFICATION_TYPE.DANGER;\n\n // Add notice to the top of stack.\n this.setState(\n {\n notices: [\n {\n ...notice,\n id,\n },\n ...this.state.notices,\n ],\n },\n () => {\n // Update live region after state update\n const announcement = `${notice.title} ${notice.description}`;\n this.updateLiveRegion(announcement, isUrgent);\n },\n );\n\n // set timeout for closing the notification.\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(\n () => this.remove(id),\n notice.duration || DEFAULT_DURATION,\n );\n }\n\n // Add id to the set.\n this.set.add(id);\n }\n\n return id;\n };\n\n /**\n * Update live region content with clear-then-set pattern for reliable VoiceOver announcements.\n *\n * @param content - The text content to announce\n * @param isAssertive - Whether to use assertive (alert) or polite (log) live region\n */\n private updateLiveRegion = (content: string, isAssertive: boolean) => {\n const region = isAssertive ? this.assertiveRegionRef.current : this.politeRegionRef.current;\n\n if (region) {\n // Add content after delay\n setTimeout(() => {\n if (region) {\n region.textContent = content;\n }\n }, 150);\n }\n };\n\n /**\n * Handler for close button click.\n *\n * @param id\n */\n public closeClickHandler = (id: string) => () => {\n this.remove(id);\n };\n\n /**\n * Pause notification when user is hovering over it.\n *\n * @param id\n */\n public pause = (id: string) => () => {\n clearTimeout(this.timeouts[id]);\n };\n\n /**\n * Restart the removal of notification.\n *\n * @param id\n */\n public resume = (id: string) => () => {\n const notice = this.state.notices.find((notice) => notice.id === id);\n if (!notice.sticky) {\n this.timeouts[id] = setTimeout(() => this.remove(id), DEFAULT_DURATION);\n }\n };\n\n render() {\n return (\n <Container position={this.props.position}>\n {/* Polite live region - uses role=\"log\" for better VoiceOver compatibility */}\n <VisuallyHidden\n ref={this.politeRegionRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n aria-relevant=\"additions text\"\n />\n\n {/* Assertive live region - pre-rendered and persistent */}\n <VisuallyHidden\n ref={this.assertiveRegionRef}\n role=\"alert\"\n aria-live=\"assertive\"\n aria-atomic=\"true\"\n />\n\n {/* Visual notifications with list semantics */}\n <div role=\"list\" aria-label={this.props.ariaLabel}>\n {this.state.notices.map((notice) => {\n const {\n id,\n title,\n description,\n leaving,\n type = NOTIFICATION_TYPE.INFO,\n buttonText,\n buttonClick,\n closeButtonAriaLabel,\n } = notice;\n\n return (\n <Notice\n key={id}\n {...notice}\n position={this.props.position}\n className={leaving ? 'leave' : ''}\n onMouseEnter={this.pause(id)}\n onMouseLeave={this.resume(id)}\n role=\"listitem\"\n >\n <IconContainer type={type} aria-hidden=\"true\">\n {type === NOTIFICATION_TYPE.INFO && <Info />}\n {type === NOTIFICATION_TYPE.SUCCESS && <CheckCircle />}\n {type === NOTIFICATION_TYPE.WARNING && <ReportProblem />}\n {type === NOTIFICATION_TYPE.DANGER && <ErrorOutline />}\n </IconContainer>\n <FillParent>\n <Title type={type}>{title}</Title>\n <Body>{description}</Body>\n {buttonText && (\n <Footer>\n <ActionButton\n onClick={() => {\n buttonClick?.();\n }}\n >\n {buttonText}\n </ActionButton>\n </Footer>\n )}\n </FillParent>\n <CloseButton\n onClick={this.closeClickHandler(id)}\n aria-label={closeButtonAriaLabel || 'Close notification'}\n tabIndex={0}\n >\n <Close />\n </CloseButton>\n </Notice>\n );\n })}\n </div>\n </Container>\n );\n }\n}\n\nexport default NotificationManager;\n"]}
@@ -42,5 +42,9 @@ export declare const Footer: import("@emotion/styled").StyledComponent<{
42
42
  theme?: import("@emotion/react").Theme;
43
43
  as?: React.ElementType;
44
44
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
45
+ export declare const VisuallyHidden: import("@emotion/styled").StyledComponent<{
46
+ theme?: import("@emotion/react").Theme;
47
+ as?: React.ElementType;
48
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
45
49
  export {};
46
50
  //# sourceMappingURL=style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/style.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6DxF,UAAU,UAAW,SAAQ,mBAAmB;IAC5C,QAAQ,EAAE,qBAAqB,CAAC;CACnC;AAED,eAAO,MAAM,SAAS;;SAlDd,MAAK,WAAU;;cAkDyB,qBAAqB;yGAOpE,CAAC;AAEF,eAAO,MAAM,MAAM;;SA3DX,MAAK,WAAU;;;uBAsItB,CAAC;AAEF,eAAO,MAAM,KAAK;;SAxIV,MAAK,WAAU;;UAwIiB,iBAAiB;yGAMxD,CAAC;AAEF,eAAO,MAAM,UAAU;;SAhJf,MAAK,WAAU;yGAkJtB,CAAC;AAEF,eAAO,MAAM,WAAW;;SApJhB,MAAK,WAAU;qHA8JtB,CAAC;AAEF,eAAO,MAAM,IAAI;;SAhKT,MAAK,WAAU;yGAmKtB,CAAC;AAEF,eAAO,MAAM,aAAa;;SArKlB,MAAK,WAAU;;UAqKyB,iBAAiB;yGAGhE,CAAC;AAEF,eAAO,MAAM,MAAM;;SA1KX,MAAK,WAAU;yGA8KtB,CAAC"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/components/Notification/style.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6DxF,UAAU,UAAW,SAAQ,mBAAmB;IAC5C,QAAQ,EAAE,qBAAqB,CAAC;CACnC;AAED,eAAO,MAAM,SAAS;;SAnDQ,MAAO,WAClC;;cAkD6C,qBAAqB;yGAOpE,CAAC;AAEF,eAAO,MAAM,MAAM;;SA5DW,MAAO,WAClC;;;uBAuIF,CAAC;AAEF,eAAO,MAAM,KAAK;;SA1IY,MAAO,WAClC;;UAyIqC,iBAAiB;yGAMxD,CAAC;AAEF,eAAO,MAAM,UAAU;;SAlJO,MAAO,WAClC;yGAmJF,CAAC;AAEF,eAAO,MAAM,WAAW;;SAtJM,MAAO,WAClC;qHAkKF,CAAC;AAEF,eAAO,MAAM,IAAI;;SArKa,MAAO,WAClC;yGAuKF,CAAC;AAEF,eAAO,MAAM,aAAa;;SA1KI,MAAO,WAClC;;UAyK6C,iBAAiB;yGAGhE,CAAC;AAEF,eAAO,MAAM,MAAM;;SA/KW,MAAO,WAClC;yGAkLF,CAAC;AAEF,eAAO,MAAM,cAAc;;SArLG,MAAO,WAClC;2GA8LF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import styled from '@emotion/styled';
2
- import constants from '../../shared/constants';
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 `var(--success-light, ${constants.SUCCESS_LIGHT})`;
26
+ return getThemeValue(THEME_NAME.SUCCESS_LIGHT);
27
27
  case NOTIFICATION_TYPE.DANGER:
28
- return `var(--error-light, ${constants.ERROR_LIGHT})`;
28
+ return getThemeValue(THEME_NAME.ERROR_LIGHT);
29
29
  case NOTIFICATION_TYPE.WARNING:
30
- return `var(--warning-light, ${constants.WARNING_LIGHT})`;
30
+ return getThemeValue(THEME_NAME.WARNING_LIGHT);
31
31
  default:
32
- return `var(--info-light, ${constants.INFO_LIGHT})`;
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 `var(--success, ${constants.SUCCESS})`;
38
+ return getThemeValue(THEME_NAME.SUCCESS);
39
39
  case NOTIFICATION_TYPE.DANGER:
40
- return `var(--error, ${constants.ERROR})`;
40
+ return getThemeValue(THEME_NAME.ERROR);
41
41
  case NOTIFICATION_TYPE.WARNING:
42
- return `var(--warning, ${constants.WARNING})`;
42
+ return getThemeValue(THEME_NAME.WARNING);
43
43
  case NOTIFICATION_TYPE.INFO:
44
- return `var(--info, ${constants.INFO})`;
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: var(--info, ${constants.INFO})`;
50
+ return `color: ${getThemeValue(THEME_NAME.INFO)}`;
51
51
  case NOTIFICATION_TYPE.SUCCESS:
52
- return `color: var(--success, ${constants.SUCCESS})`;
52
+ return `color: ${getThemeValue(THEME_NAME.SUCCESS)}`;
53
53
  case NOTIFICATION_TYPE.DANGER:
54
- return `color: var(--error, ${constants.ERROR})`;
54
+ return `color: ${getThemeValue(THEME_NAME.ERROR)}`;
55
55
  case NOTIFICATION_TYPE.WARNING:
56
- return `color: var(--warning, ${constants.WARNING})`;
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: none;
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 var(--primary, ${constants.PRIMARY_LIGHT});
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,SAAS,MAAM,wBAAwB,CAAC;AAC/C,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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AC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport constants 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 `var(--success-light, ${constants.SUCCESS_LIGHT})`;\n case NOTIFICATION_TYPE.DANGER:\n return `var(--error-light, ${constants.ERROR_LIGHT})`;\n case NOTIFICATION_TYPE.WARNING:\n return `var(--warning-light, ${constants.WARNING_LIGHT})`;\n default:\n return `var(--info-light, ${constants.INFO_LIGHT})`;\n }\n};\n\nconst getTitleColor = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.SUCCESS:\n return `var(--success, ${constants.SUCCESS})`;\n case NOTIFICATION_TYPE.DANGER:\n return `var(--error, ${constants.ERROR})`;\n case NOTIFICATION_TYPE.WARNING:\n return `var(--warning, ${constants.WARNING})`;\n case NOTIFICATION_TYPE.INFO:\n return `var(--info, ${constants.INFO})`;\n }\n};\n\nconst getTypeStyle = (type: NOTIFICATION_TYPE) => {\n switch (type) {\n case NOTIFICATION_TYPE.INFO:\n return `color: var(--info, ${constants.INFO})`;\n case NOTIFICATION_TYPE.SUCCESS:\n return `color: var(--success, ${constants.SUCCESS})`;\n case NOTIFICATION_TYPE.DANGER:\n return `color: var(--error, ${constants.ERROR})`;\n case NOTIFICATION_TYPE.WARNING:\n return `color: var(--warning, ${constants.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 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 background-color: transparent;\n border: none;\n padding: none;\n cursor: pointer;\n\n &:focus {\n box-shadow: 0 0 0 3px var(--primary, ${constants.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"]}
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,CAA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K,CAAC,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,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;CACxB"}
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,KAAmD,MAAM,OAAO,CAAC;AACxE,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,oDA0IjF;kBA3IuB,OAAO;;QA8I3B,wBAAwB;;QAExB,qCAAqC;;QAErC,oDAAoD;;QAOpD,qDAAqD;;QAErD,6BAA6B;;;;;;;;eA3JT,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: [_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) => {
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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,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,CAAC;AAEF,OAAO,CAAC,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/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/E,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;CACJ,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG5B,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAwE;;;;;;;;2BAQxE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU;MAClF,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,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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,CAAC;AAEF,OAAO,CAAC,YAAY,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,oDAElC;kBAFQ,OAAO;;QAOZ,qBAAqB;;;;;;;AAHzB,KAAK,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAWlE,eAAe,OAAO,CAAC"}
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 constants from '../../shared/constants';
15
+ import { getThemeValue, THEME_NAME } from '../../shared/constants';
5
16
  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});
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
- return _jsx(SpinnerDiv, Object.assign({}, props));
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":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAa;uCACH,SAAS,CAAC,OAAO;sDACF,SAAS,CAAC,kBAAkB;;aAErE,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,OAAO,KAAC,UAAU,oBAAK,KAAK,EAAI,CAAC;AACrC,CAAC;AAID,OAAO,CAAC,SAAS,GAAG;IAChB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC,MAAM;CACzB,CAAC;AAEF,OAAO,CAAC,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACX,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport constants from '../../shared/constants';\n\nconst SpinnerDiv = styled.div<SpinnerProp>`\n border: 4px solid var(--primary, ${constants.PRIMARY});\n border-top: 4px solid var(--border-light-color, ${constants.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 return <SpinnerDiv {...props} />;\n}\n\ntype SpinnerProp = PropTypes.InferProps<typeof Spinner.propTypes>;\n\nSpinner.propTypes = {\n /** Spinner's size */\n size: PropTypes.number,\n};\n\nSpinner.defaultProps = {\n size: 30,\n};\n\nexport default Spinner;\n"]}
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;AAkFH,iBAAwB,OAAO,CAAC,KAAK,EAAE,YAAY,oDA6DlD;kBA7DuB,OAAO;;QAgE3B,qCAAqC;;QAErC,kDAAkD;;;;;;;eAlE9B,OAAO"}
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, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
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 constants from '../../shared/constants';
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 var(--border-light-color, ${constants.BORDER_LIGHT_COLOR});
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: var(--light-grey, ${constants.LIGHT_GREY});
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
- ? `var(--border-light-color, ${constants.BORDER_LIGHT_COLOR})`
44
- : `var(--background, ${constants.BACKGROUND})`};
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: var(--disabled-background, ${constants.DISABLED_BACKGROUND});
53
+ background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};
53
54
  }
54
55
 
55
56
  &:enabled:hover,
56
57
  &:focus {
57
- background-color: var(--primary-light, ${constants.PRIMARY_LIGHTER});
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
- return (_jsxs(Container, { children: [_jsxs(Header, { children: [Children.map(children, (child, index) => {
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 (_jsx(_Fragment, { children: _jsxs(HeaderButton, { active: index === active, type: "button", disabled: child.props.disabled, onClick: stepClickHandler(index), children: [_jsx(Badge, { inline: true, type: getBadgeType(index, child.props.completed, child.props.disabled) }), _jsx(Ellipsis, { children: child.props.name })] }) }));
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]] }));