@doist/reactist 25.0.0-beta.2 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/README.md +35 -16
  2. package/dist/reactist.cjs.development.js +448 -422
  3. package/dist/reactist.cjs.development.js.map +1 -1
  4. package/dist/reactist.cjs.production.min.js +1 -1
  5. package/dist/reactist.cjs.production.min.js.map +1 -1
  6. package/es/alert/alert.js +13 -13
  7. package/es/alert/alert.js.map +1 -1
  8. package/es/alert/alert.module.css.js +1 -1
  9. package/es/avatar/avatar.js +6 -6
  10. package/es/avatar/avatar.js.map +1 -1
  11. package/es/avatar/avatar.module.css.js +1 -1
  12. package/es/avatar/utils.js.map +1 -1
  13. package/es/badge/badge.js +4 -4
  14. package/es/badge/badge.js.map +1 -1
  15. package/es/badge/badge.module.css.js +1 -1
  16. package/es/banner/banner.js +16 -16
  17. package/es/banner/banner.js.map +1 -1
  18. package/es/banner/banner.module.css.js +1 -1
  19. package/es/base-field/base-field.js +25 -25
  20. package/es/base-field/base-field.js.map +1 -1
  21. package/es/base-field/base-field.module.css.js +1 -1
  22. package/es/box/box.js +12 -12
  23. package/es/box/box.js.map +1 -1
  24. package/es/box/box.module.css.js +1 -1
  25. package/es/box/gap.module.css.js +1 -1
  26. package/es/box/margin.module.css.js +1 -1
  27. package/es/box/padding.module.css.js +1 -1
  28. package/es/box/width.module.css.js +1 -1
  29. package/es/button/button.js +19 -19
  30. package/es/button/button.js.map +1 -1
  31. package/es/button/button.module.css.js +1 -1
  32. package/es/checkbox-field/checkbox-field.js +16 -16
  33. package/es/checkbox-field/checkbox-field.js.map +1 -1
  34. package/es/checkbox-field/checkbox-field.module.css.js +1 -1
  35. package/es/checkbox-field/checkbox-icon.js +3 -3
  36. package/es/checkbox-field/checkbox-icon.js.map +1 -1
  37. package/es/checkbox-field/use-fork-ref.js.map +1 -1
  38. package/es/columns/columns.js +6 -6
  39. package/es/columns/columns.js.map +1 -1
  40. package/es/columns/columns.module.css.js +1 -1
  41. package/es/components/color-picker/color-picker.js +11 -11
  42. package/es/components/color-picker/color-picker.js.map +1 -1
  43. package/es/components/color-picker/index.js +1 -5
  44. package/es/components/color-picker/index.js.map +1 -1
  45. package/es/components/deprecated-button/deprecated-button.js +4 -4
  46. package/es/components/deprecated-button/deprecated-button.js.map +1 -1
  47. package/es/components/deprecated-button/index.js +1 -4
  48. package/es/components/deprecated-button/index.js.map +1 -1
  49. package/es/components/deprecated-dropdown/dropdown.js +11 -11
  50. package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
  51. package/es/components/deprecated-dropdown/index.js +1 -4
  52. package/es/components/deprecated-dropdown/index.js.map +1 -1
  53. package/es/components/deprecated-input/index.js +1 -4
  54. package/es/components/deprecated-input/index.js.map +1 -1
  55. package/es/components/deprecated-input/input.js +3 -3
  56. package/es/components/deprecated-input/input.js.map +1 -1
  57. package/es/components/deprecated-select/index.js +1 -4
  58. package/es/components/deprecated-select/index.js.map +1 -1
  59. package/es/components/deprecated-select/select.js +3 -3
  60. package/es/components/deprecated-select/select.js.map +1 -1
  61. package/es/components/key-capturer/index.js +1 -5
  62. package/es/components/key-capturer/index.js.map +1 -1
  63. package/es/components/key-capturer/key-capturer.js +3 -3
  64. package/es/components/key-capturer/key-capturer.js.map +1 -1
  65. package/es/components/keyboard-shortcut/index.js +1 -4
  66. package/es/components/keyboard-shortcut/index.js.map +1 -1
  67. package/es/components/keyboard-shortcut/keyboard-shortcut.js +4 -4
  68. package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  69. package/es/components/progress-bar/index.js +1 -4
  70. package/es/components/progress-bar/index.js.map +1 -1
  71. package/es/components/progress-bar/progress-bar.js +5 -5
  72. package/es/components/progress-bar/progress-bar.js.map +1 -1
  73. package/es/components/time/index.js +1 -4
  74. package/es/components/time/index.js.map +1 -1
  75. package/es/components/time/time-utils.js.map +1 -1
  76. package/es/components/time/time.js +5 -5
  77. package/es/components/time/time.js.map +1 -1
  78. package/es/divider/divider.js +4 -4
  79. package/es/divider/divider.js.map +1 -1
  80. package/es/divider/divider.module.css.js +1 -1
  81. package/es/heading/heading.js +5 -5
  82. package/es/heading/heading.js.map +1 -1
  83. package/es/heading/heading.module.css.js +1 -1
  84. package/es/hidden/hidden.js +5 -5
  85. package/es/hidden/hidden.js.map +1 -1
  86. package/es/hidden/hidden.module.css.js +1 -1
  87. package/es/hidden-visually/hidden-visually.js +4 -4
  88. package/es/hidden-visually/hidden-visually.js.map +1 -1
  89. package/es/hidden-visually/hidden-visually.module.css.js +1 -1
  90. package/es/icons/alert-icon.js +10 -10
  91. package/es/icons/alert-icon.js.map +1 -1
  92. package/es/icons/close-icon.js +3 -3
  93. package/es/icons/close-icon.js.map +1 -1
  94. package/es/icons/password-hidden-icon.js +6 -6
  95. package/es/icons/password-hidden-icon.js.map +1 -1
  96. package/es/icons/password-visible-icon.js +5 -5
  97. package/es/icons/password-visible-icon.js.map +1 -1
  98. package/es/index.js +13 -15
  99. package/es/index.js.map +1 -1
  100. package/es/inline/inline.js +2 -2
  101. package/es/inline/inline.js.map +1 -1
  102. package/es/loading/loading.js +3 -3
  103. package/es/loading/loading.js.map +1 -1
  104. package/es/menu/menu.js +32 -32
  105. package/es/menu/menu.js.map +1 -1
  106. package/es/modal/modal.js +45 -45
  107. package/es/modal/modal.js.map +1 -1
  108. package/es/modal/modal.module.css.js +1 -1
  109. package/es/notice/notice.js +8 -8
  110. package/es/notice/notice.js.map +1 -1
  111. package/es/notice/notice.module.css.js +1 -1
  112. package/es/password-field/password-field.js +7 -7
  113. package/es/password-field/password-field.js.map +1 -1
  114. package/es/prose/prose.js +4 -4
  115. package/es/prose/prose.js.map +1 -1
  116. package/es/prose/prose.module.css.js +1 -1
  117. package/es/select-field/select-field.js +11 -11
  118. package/es/select-field/select-field.js.map +1 -1
  119. package/es/select-field/select-field.module.css.js +1 -1
  120. package/es/spinner/spinner.js +9 -9
  121. package/es/spinner/spinner.js.map +1 -1
  122. package/es/spinner/spinner.module.css.js +1 -1
  123. package/es/stack/stack.js +4 -4
  124. package/es/stack/stack.js.map +1 -1
  125. package/es/switch-field/switch-field.js +18 -18
  126. package/es/switch-field/switch-field.js.map +1 -1
  127. package/es/switch-field/switch-field.module.css.js +1 -1
  128. package/es/tabs/tabs.js +23 -23
  129. package/es/tabs/tabs.js.map +1 -1
  130. package/es/tabs/tabs.module.css.js +1 -1
  131. package/es/text/text.js +5 -5
  132. package/es/text/text.js.map +1 -1
  133. package/es/text/text.module.css.js +1 -1
  134. package/es/text-area/text-area.js +14 -14
  135. package/es/text-area/text-area.js.map +1 -1
  136. package/es/text-area/text-area.module.css.js +1 -1
  137. package/es/text-field/text-field.js +13 -13
  138. package/es/text-field/text-field.js.map +1 -1
  139. package/es/text-field/text-field.module.css.js +1 -1
  140. package/es/text-link/text-link.js +5 -5
  141. package/es/text-link/text-link.js.map +1 -1
  142. package/es/text-link/text-link.module.css.js +1 -1
  143. package/es/toast/static-toast.js +5 -5
  144. package/es/toast/static-toast.js.map +1 -1
  145. package/es/toast/toast-animation.js.map +1 -1
  146. package/es/toast/toast.module.css.js +1 -1
  147. package/es/toast/use-toasts.js +4 -4
  148. package/es/toast/use-toasts.js.map +1 -1
  149. package/es/tooltip/tooltip.js +9 -9
  150. package/es/tooltip/tooltip.js.map +1 -1
  151. package/es/tooltip/tooltip.module.css.js +1 -1
  152. package/es/utils/common-helpers.js +2 -2
  153. package/es/utils/common-helpers.js.map +1 -1
  154. package/es/utils/polymorphism.js +2 -2
  155. package/es/utils/polymorphism.js.map +1 -1
  156. package/es/utils/responsive-props.js.map +1 -1
  157. package/lib/alert/alert.d.ts +3 -3
  158. package/lib/alert/alert.js +1 -1
  159. package/lib/alert/alert.js.map +1 -1
  160. package/lib/avatar/avatar.d.ts +2 -2
  161. package/lib/avatar/avatar.js +1 -1
  162. package/lib/avatar/avatar.js.map +1 -1
  163. package/lib/avatar/utils.js.map +1 -1
  164. package/lib/badge/badge.d.ts +2 -2
  165. package/lib/badge/badge.js +1 -1
  166. package/lib/badge/badge.js.map +1 -1
  167. package/lib/banner/banner.d.ts +2 -2
  168. package/lib/banner/banner.js +1 -1
  169. package/lib/banner/banner.js.map +1 -1
  170. package/lib/base-field/base-field.d.ts +9 -9
  171. package/lib/base-field/base-field.js +1 -1
  172. package/lib/base-field/base-field.js.map +1 -1
  173. package/lib/box/box.d.ts +15 -15
  174. package/lib/box/box.js +1 -1
  175. package/lib/box/box.js.map +1 -1
  176. package/lib/button/button.d.ts +4 -4
  177. package/lib/button/button.js +1 -1
  178. package/lib/button/button.js.map +1 -1
  179. package/lib/checkbox-field/checkbox-field.js +1 -1
  180. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  181. package/lib/checkbox-field/checkbox-icon.d.ts +1 -1
  182. package/lib/checkbox-field/checkbox-icon.js +1 -1
  183. package/lib/checkbox-field/checkbox-icon.js.map +1 -1
  184. package/lib/checkbox-field/use-fork-ref.js.map +1 -1
  185. package/lib/columns/columns.d.ts +4 -4
  186. package/lib/columns/columns.js +1 -1
  187. package/lib/columns/columns.js.map +1 -1
  188. package/lib/components/color-picker/color-picker.d.ts +3 -3
  189. package/lib/components/color-picker/color-picker.js +1 -1
  190. package/lib/components/color-picker/color-picker.js.map +1 -1
  191. package/lib/components/deprecated-button/deprecated-button.d.ts +4 -4
  192. package/lib/components/deprecated-button/deprecated-button.js +1 -1
  193. package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
  194. package/lib/components/deprecated-dropdown/dropdown.d.ts +5 -5
  195. package/lib/components/deprecated-dropdown/dropdown.js +1 -1
  196. package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
  197. package/lib/components/deprecated-input/input.js +1 -1
  198. package/lib/components/deprecated-input/input.js.map +1 -1
  199. package/lib/components/deprecated-select/select.d.ts +2 -2
  200. package/lib/components/deprecated-select/select.js +1 -1
  201. package/lib/components/deprecated-select/select.js.map +1 -1
  202. package/lib/components/key-capturer/key-capturer.d.ts +5 -5
  203. package/lib/components/key-capturer/key-capturer.js +1 -1
  204. package/lib/components/key-capturer/key-capturer.js.map +1 -1
  205. package/lib/components/keyboard-shortcut/keyboard-shortcut.d.ts +3 -3
  206. package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
  207. package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  208. package/lib/components/progress-bar/progress-bar.d.ts +1 -1
  209. package/lib/components/progress-bar/progress-bar.js +1 -1
  210. package/lib/components/progress-bar/progress-bar.js.map +1 -1
  211. package/lib/components/time/time-utils.d.ts +1 -1
  212. package/lib/components/time/time-utils.js +1 -1
  213. package/lib/components/time/time-utils.js.map +1 -1
  214. package/lib/components/time/time.d.ts +2 -2
  215. package/lib/components/time/time.js +1 -1
  216. package/lib/components/time/time.js.map +1 -1
  217. package/lib/divider/divider.js +1 -1
  218. package/lib/divider/divider.js.map +1 -1
  219. package/lib/heading/heading.d.ts +2 -2
  220. package/lib/heading/heading.js +1 -1
  221. package/lib/heading/heading.js.map +1 -1
  222. package/lib/hidden/hidden.d.ts +4 -4
  223. package/lib/hidden/hidden.js +1 -1
  224. package/lib/hidden/hidden.js.map +1 -1
  225. package/lib/hidden-visually/hidden-visually.d.ts +1 -1
  226. package/lib/hidden-visually/hidden-visually.js +1 -1
  227. package/lib/hidden-visually/hidden-visually.js.map +1 -1
  228. package/lib/icons/alert-icon.js +1 -1
  229. package/lib/icons/alert-icon.js.map +1 -1
  230. package/lib/icons/close-icon.js +1 -1
  231. package/lib/icons/close-icon.js.map +1 -1
  232. package/lib/icons/password-hidden-icon.js +1 -1
  233. package/lib/icons/password-hidden-icon.js.map +1 -1
  234. package/lib/icons/password-visible-icon.js +1 -1
  235. package/lib/icons/password-visible-icon.js.map +1 -1
  236. package/lib/index.js +1 -1
  237. package/lib/inline/inline.d.ts +1 -1
  238. package/lib/inline/inline.js +1 -1
  239. package/lib/inline/inline.js.map +1 -1
  240. package/lib/loading/loading.d.ts +3 -3
  241. package/lib/loading/loading.js +1 -1
  242. package/lib/loading/loading.js.map +1 -1
  243. package/lib/menu/menu.d.ts +1 -1
  244. package/lib/menu/menu.js +1 -1
  245. package/lib/menu/menu.js.map +1 -1
  246. package/lib/modal/modal-stories-components.d.ts +2 -2
  247. package/lib/modal/modal.d.ts +4 -4
  248. package/lib/modal/modal.js +1 -1
  249. package/lib/modal/modal.js.map +1 -1
  250. package/lib/notice/notice.d.ts +1 -1
  251. package/lib/notice/notice.js +1 -1
  252. package/lib/notice/notice.js.map +1 -1
  253. package/lib/password-field/password-field.js +1 -1
  254. package/lib/password-field/password-field.js.map +1 -1
  255. package/lib/prose/prose.js +1 -1
  256. package/lib/prose/prose.js.map +1 -1
  257. package/lib/select-field/select-field.js +1 -1
  258. package/lib/select-field/select-field.js.map +1 -1
  259. package/lib/spinner/spinner.js +1 -1
  260. package/lib/spinner/spinner.js.map +1 -1
  261. package/lib/stack/stack.d.ts +1 -1
  262. package/lib/stack/stack.js +1 -1
  263. package/lib/stack/stack.js.map +1 -1
  264. package/lib/switch-field/switch-field.js +1 -1
  265. package/lib/switch-field/switch-field.js.map +1 -1
  266. package/lib/tabs/tabs.d.ts +5 -6
  267. package/lib/tabs/tabs.js +1 -1
  268. package/lib/tabs/tabs.js.map +1 -1
  269. package/lib/text/text.d.ts +1 -1
  270. package/lib/text/text.js +1 -1
  271. package/lib/text/text.js.map +1 -1
  272. package/lib/text-area/text-area.js +1 -1
  273. package/lib/text-area/text-area.js.map +1 -1
  274. package/lib/text-field/text-field.d.ts +1 -1
  275. package/lib/text-field/text-field.js +1 -1
  276. package/lib/text-field/text-field.js.map +1 -1
  277. package/lib/text-link/text-link.d.ts +1 -1
  278. package/lib/text-link/text-link.js +1 -1
  279. package/lib/text-link/text-link.js.map +1 -1
  280. package/lib/toast/static-toast.d.ts +2 -2
  281. package/lib/toast/static-toast.js +1 -1
  282. package/lib/toast/static-toast.js.map +1 -1
  283. package/lib/toast/toast-animation.d.ts +1 -1
  284. package/lib/toast/toast-animation.js.map +1 -1
  285. package/lib/toast/use-toasts.d.ts +3 -3
  286. package/lib/toast/use-toasts.js +1 -1
  287. package/lib/toast/use-toasts.js.map +1 -1
  288. package/lib/tooltip/tooltip.js +1 -1
  289. package/lib/tooltip/tooltip.js.map +1 -1
  290. package/lib/utils/common-helpers.js +1 -1
  291. package/lib/utils/common-helpers.js.map +1 -1
  292. package/lib/utils/common-types.d.ts +8 -8
  293. package/lib/utils/polymorphism.d.ts +9 -9
  294. package/lib/utils/polymorphism.js +1 -1
  295. package/lib/utils/polymorphism.js.map +1 -1
  296. package/lib/utils/responsive-props.d.ts +3 -3
  297. package/lib/utils/responsive-props.js.map +1 -1
  298. package/lib/utils/test-helpers.d.ts +1 -1
  299. package/package.json +13 -7
  300. package/lib/alert/alert.test.d.ts +0 -1
  301. package/lib/avatar/avatar.test.d.ts +0 -1
  302. package/lib/avatar/utils.test.d.ts +0 -1
  303. package/lib/badge/badge.test.d.ts +0 -1
  304. package/lib/banner/banner.test.d.ts +0 -1
  305. package/lib/box/box.test.d.ts +0 -1
  306. package/lib/button/button.test.d.ts +0 -1
  307. package/lib/checkbox-field/checkbox-field.test.d.ts +0 -1
  308. package/lib/columns/columns.test.d.ts +0 -1
  309. package/lib/components/color-picker/color-picker.test.d.ts +0 -1
  310. package/lib/components/deprecated-button/deprecated-button.test.d.ts +0 -1
  311. package/lib/components/deprecated-dropdown/dropdown.test.d.ts +0 -1
  312. package/lib/components/deprecated-input/input.test.d.ts +0 -1
  313. package/lib/components/deprecated-select/select.test.d.ts +0 -1
  314. package/lib/components/key-capturer/key-capturer.test.d.ts +0 -1
  315. package/lib/components/keyboard-shortcut/keyboard-shortcut.test.d.ts +0 -1
  316. package/lib/components/progress-bar/progress-bar.test.d.ts +0 -1
  317. package/lib/components/time/time-utils.test.d.ts +0 -1
  318. package/lib/components/time/time.test.d.ts +0 -1
  319. package/lib/heading/heading.test.d.ts +0 -1
  320. package/lib/hidden/hidden.test.d.ts +0 -1
  321. package/lib/hidden-visually/hidden-visually.test.d.ts +0 -1
  322. package/lib/inline/inline.test.d.ts +0 -1
  323. package/lib/loading/loading.test.d.ts +0 -1
  324. package/lib/menu/menu.test.d.ts +0 -1
  325. package/lib/modal/modal.test.d.ts +0 -1
  326. package/lib/notice/notice.test.d.ts +0 -1
  327. package/lib/password-field/password-field.test.d.ts +0 -1
  328. package/lib/prose/prose.test.d.ts +0 -1
  329. package/lib/select-field/select-field.test.d.ts +0 -1
  330. package/lib/stack/stack.test.d.ts +0 -1
  331. package/lib/switch-field/switch-field.test.d.ts +0 -1
  332. package/lib/tabs/tabs.test.d.ts +0 -1
  333. package/lib/text/text.test.d.ts +0 -1
  334. package/lib/text-area/text-area.test.d.ts +0 -1
  335. package/lib/text-field/text-field.test.d.ts +0 -1
  336. package/lib/toast/toast.test.d.ts +0 -1
  337. package/lib/tooltip/tooltip.test.d.ts +0 -1
  338. package/styles/color-picker.css +0 -9
  339. package/styles/deprecated-button.css +0 -7
  340. package/styles/dropdown.css +0 -8
  341. package/styles/progress-bar.css +0 -7
  342. package/styles/select.css +0 -1
  343. package/styles/time.css +0 -7
  344. /package/styles/{input.css → index.css} +0 -0
  345. /package/styles/{spinner.module.css.css → spinner.css} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sources":["../../../src/components/deprecated-dropdown/dropdown.tsx"],"sourcesContent":["import * as React from 'react'\nimport ReactDOM from 'react-dom'\nimport classNames from 'classnames'\n\nimport Button from '../deprecated-button'\n\nimport './dropdown.less'\n\ntype BoxProps = {\n onShowBody?: () => void\n onHideBody?: () => void\n allowBodyInteractions?: boolean\n top?: boolean\n right?: boolean\n scrolling_parent?: string\n children?: [\n React.ReactElement<TriggerProps>,\n React.ReactElement<BodyProps> | ((props: BodyProps) => JSX.Element),\n ]\n className?: string\n}\n\ntype BoxState = {\n top: boolean\n showBody: boolean\n}\n\nclass Box extends React.Component<BoxProps, BoxState> {\n public static displayName: string\n\n constructor(props: BoxProps, context: React.Context<unknown>) {\n super(props, context)\n this.state = {\n showBody: false,\n top: props.top || false,\n }\n\n this._timeout = undefined\n }\n\n componentWillUnmount() {\n document.removeEventListener('click', this._handleClickOutside, true)\n if (this._timeout) {\n clearTimeout(this._timeout)\n }\n }\n _timeout?: ReturnType<typeof setTimeout>\n\n _handleClickOutside = (event: MouseEvent) => {\n const dropdownDOMNode = ReactDOM.findDOMNode(this)\n\n if (dropdownDOMNode && !dropdownDOMNode.contains(event.target as Node))\n this._toggleShowBody()\n else if (!this.props.allowBodyInteractions) {\n // won't close when body interactions are allowed\n this._timeout = setTimeout(() => {\n if (this.state.showBody) {\n this._toggleShowBody()\n }\n }, 100)\n }\n }\n\n _toggleShowBody = () => {\n if (!this.state.showBody) {\n // will show\n if (this.props.onShowBody) this.props.onShowBody()\n document.addEventListener('click', this._handleClickOutside, true)\n } else {\n // will hide\n if (this.props.onHideBody) this.props.onHideBody()\n document.removeEventListener('click', this._handleClickOutside, true)\n }\n\n this.setState({\n showBody: !this.state.showBody,\n })\n }\n\n _getTriggerComponent() {\n const _trigger = this.props.children?.[0]\n return _trigger\n ? React.cloneElement(_trigger, { onClick: this._toggleShowBody })\n : undefined\n }\n\n // https://facebook.github.io/react/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components\n _setPosition = (body: HTMLElement | null) => {\n if (body) {\n const scrollingParent = document.getElementById(\n this.props.scrolling_parent ? this.props.scrolling_parent : '',\n )\n\n if (scrollingParent) {\n const dropdown = ReactDOM.findDOMNode(this)\n if (!dropdown) {\n return\n }\n const dropdownVerticalPosition = (ReactDOM.findDOMNode(this) as HTMLElement)\n .offsetTop\n const dropdownTrigger = (dropdown as Element).querySelector('.trigger')\n if (!dropdownTrigger) {\n return\n }\n const dropdownTriggerHeight = dropdownTrigger.clientHeight\n const dropdownBodyHeight = body.clientHeight\n\n const scrollingParentHeight = scrollingParent.clientHeight\n const scrollingParentOffset = scrollingParent.scrollTop\n\n const bottomOffset =\n scrollingParentHeight +\n scrollingParentOffset -\n dropdownVerticalPosition -\n dropdownTriggerHeight\n\n const top = bottomOffset < dropdownBodyHeight\n\n if (top !== this.state.top) {\n this.setState({ top })\n }\n }\n }\n }\n\n _getBodyComponent() {\n if (!this.state.showBody) {\n return null\n }\n const { top } = this.state\n const { right = false, children } = this.props\n const props = { top, right, setPosition: this._setPosition }\n\n const className = classNames({\n body_wrapper: true,\n with_arrow: true,\n top: top,\n bottom: !top,\n })\n\n const body = children?.[1]\n\n const contentMarkup =\n typeof body === 'function'\n ? body(props)\n : body\n ? React.cloneElement(body, props)\n : undefined\n return (\n <div className={className} style={{ position: 'relative' }}>\n {contentMarkup}\n </div>\n )\n }\n\n render() {\n const className = classNames('reactist_dropdown', this.props.className)\n const { top } = this.state\n\n return (\n <div\n style={{ display: 'inline-block' }}\n className={className}\n data-testid=\"reactist-dropdown-box\"\n >\n {top && this._getBodyComponent()}\n {this._getTriggerComponent()}\n {!top && this._getBodyComponent()}\n </div>\n )\n }\n}\n\nBox.displayName = 'Dropdown.Box'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\ntype TriggerProps = Omit<NativeButtonProps, 'title' | 'onClick'> & {\n tooltip?: React.ReactNode\n /**\n * @private the onClick prop is not to be used externally\n */\n onClick?: NativeButtonProps['onClick']\n}\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(function Trigger(\n { children, onClick, tooltip, className, ...props },\n ref,\n) {\n function handleClick(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) {\n event.preventDefault()\n event.stopPropagation()\n if (onClick) onClick(event)\n }\n\n return (\n <Button\n {...props}\n className={classNames('trigger', className)}\n onClick={handleClick}\n tooltip={tooltip}\n ref={ref}\n >\n {children}\n </Button>\n )\n})\n\nTrigger.displayName = 'Dropdown.Trigger'\n\ntype BodyProps = {\n setPosition?: React.Ref<HTMLDivElement>\n children?: React.ReactNode\n top?: boolean\n right?: boolean\n}\n\nfunction Body({ top, right, children, setPosition }: BodyProps) {\n const style: React.CSSProperties = { position: 'absolute', right: 0, top: 0 }\n\n if (top) {\n style.top = 'auto'\n style.bottom = 0\n }\n\n if (right) {\n style.right = 'auto'\n style.left = 0\n }\n\n return (\n <div\n ref={setPosition}\n style={style}\n className=\"body\"\n id=\"reactist-dropdown-body\"\n data-testid=\"reactist-dropdown-body\"\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dropdown.Body'\n\nconst Dropdown = {\n Box,\n Trigger,\n Body,\n}\n\nexport { Dropdown }\n"],"names":["Box","React","constructor","props","context","super","_timeout","_handleClickOutside","event","dropdownDOMNode","ReactDOM","findDOMNode","this","contains","target","_toggleShowBody","allowBodyInteractions","setTimeout","state","showBody","onHideBody","document","removeEventListener","onShowBody","addEventListener","setState","_setPosition","body","scrollingParent","getElementById","scrolling_parent","dropdown","dropdownVerticalPosition","offsetTop","dropdownTrigger","querySelector","top","clientHeight","scrollTop","undefined","componentWillUnmount","clearTimeout","_getTriggerComponent","_trigger","children","_this$props$children","onClick","_getBodyComponent","right","setPosition","className","classNames","body_wrapper","with_arrow","bottom","contentMarkup","style","position","render","display","displayName","Trigger","ref","tooltip","Button","preventDefault","stopPropagation","Body","left","id"],"mappings":"sXA2BA,MAAMA,UAAYC,YAGdC,YAAYC,EAAiBC,GACzBC,MAAMF,EAAOC,QAejBE,qBAEAC,oBAAuBC,IACnB,MAAMC,EAAkBC,EAASC,YAAYC,MAEzCH,IAAoBA,EAAgBI,SAASL,EAAMM,QACnDF,KAAKG,kBACCH,KAAKT,MAAMa,wBAEjBJ,KAAKN,SAAWW,WAAW,KACnBL,KAAKM,MAAMC,UACXP,KAAKG,mBAEV,YAIXA,gBAAkB,KACTH,KAAKM,MAAMC,UAMRP,KAAKT,MAAMiB,YAAYR,KAAKT,MAAMiB,aACtCC,SAASC,oBAAoB,QAASV,KAAKL,qBAAqB,KAL5DK,KAAKT,MAAMoB,YAAYX,KAAKT,MAAMoB,aACtCF,SAASG,iBAAiB,QAASZ,KAAKL,qBAAqB,IAOjEK,KAAKa,SAAS,CACVN,UAAWP,KAAKM,MAAMC,iBAY9BO,aAAgBC,IACZ,GAAIA,EAAM,CACN,MAAMC,EAAkBP,SAASQ,eAC7BjB,KAAKT,MAAM2B,iBAAmBlB,KAAKT,MAAM2B,iBAAmB,IAGhE,GAAIF,EAAiB,CACjB,MAAMG,EAAWrB,EAASC,YAAYC,MACtC,IAAKmB,EACD,OAEJ,MAAMC,EAA4BtB,EAASC,YAAYC,MAClDqB,UACCC,EAAmBH,EAAqBI,cAAc,YAC5D,IAAKD,EACD,OAEJ,MAYME,EATwBR,EAAgBS,aAChBT,EAAgBU,UAK1CN,EAT0BE,EAAgBG,aACnBV,EAAKU,aAa5BD,IAAQxB,KAAKM,MAAMkB,KACnBxB,KAAKa,SAAS,CAAEW,IAAAA,OAvF5BxB,KAAKM,MAAQ,CACTC,UAAU,EACViB,IAAKjC,EAAMiC,MAAO,GAGtBxB,KAAKN,cAAWiC,EAGpBC,uBACInB,SAASC,oBAAoB,QAASV,KAAKL,qBAAqB,GAC5DK,KAAKN,UACLmC,aAAa7B,KAAKN,UAoC1BoC,6BACI,MAAMC,WAAW/B,KAAKT,MAAMyC,iBAAXC,EAAsB,GACvC,OAAOF,EACD1C,eAAmB0C,EAAU,CAAEG,QAASlC,KAAKG,uBAC7CwB,EA0CVQ,oBACI,IAAKnC,KAAKM,MAAMC,SACZ,OAAO,KAEX,MAAMiB,IAAEA,GAAQxB,KAAKM,OACf8B,MAAEA,GAAQ,EAAVJ,SAAiBA,GAAahC,KAAKT,MACnCA,EAAQ,CAAEiC,IAAAA,EAAKY,MAAAA,EAAOC,YAAarC,KAAKc,cAExCwB,EAAYC,EAAW,CACzBC,cAAc,EACdC,YAAY,EACZjB,IAAKA,EACLkB,QAASlB,IAGPT,QAAOiB,SAAAA,EAAW,GAElBW,EACc,mBAAT5B,EACDA,EAAKxB,GACLwB,EACA1B,eAAmB0B,EAAMxB,QACzBoC,EACV,OACItC,uBAAKiD,UAAWA,EAAWM,MAAO,CAAEC,SAAU,aACzCF,GAKbG,SACI,MAAMR,EAAYC,EAAW,oBAAqBvC,KAAKT,MAAM+C,YACvDd,IAAEA,GAAQxB,KAAKM,MAErB,OACIjB,uBACIuD,MAAO,CAAEG,QAAS,gBAClBT,UAAWA,gBACC,yBAEXd,GAAOxB,KAAKmC,oBACZnC,KAAK8B,wBACJN,GAAOxB,KAAKmC,sBA5IxB/C,EACY4D,mBAiJlB5D,EAAI4D,YAAc,eAelB,MAAMC,EAAU5D,cAAkD,WAE9D6D,OADAlB,SAAEA,EAAFE,QAAYA,EAAZiB,QAAqBA,EAArBb,UAA8BA,KAAc/C,iCAS5C,OACIF,gBAAC+D,6CACO7D,OACJ+C,UAAWC,EAAW,UAAWD,GACjCJ,QAVR,SAAqBtC,GACjBA,EAAMyD,iBACNzD,EAAM0D,kBACFpB,GAASA,EAAQtC,IAQjBuD,QAASA,EACTD,IAAKA,IAEJlB,MAcb,SAASuB,GAAK/B,IAAEA,EAAFY,MAAOA,EAAPJ,SAAcA,EAAdK,YAAwBA,IAClC,MAAMO,EAA6B,CAAEC,SAAU,WAAYT,MAAO,EAAGZ,IAAK,GAY1E,OAVIA,IACAoB,EAAMpB,IAAM,OACZoB,EAAMF,OAAS,GAGfN,IACAQ,EAAMR,MAAQ,OACdQ,EAAMY,KAAO,GAIbnE,uBACI6D,IAAKb,EACLO,MAAOA,EACPN,UAAU,OACVmB,GAAG,uCACS,0BAEXzB,GA9BbiB,EAAQD,YAAc,mBAmCtBO,EAAKP,YAAc,iCAEF,CACb5D,IAAAA,EACA6D,QAAAA,EACAM,KAAAA"}
1
+ {"version":3,"file":"dropdown.js","sources":["../../../src/components/deprecated-dropdown/dropdown.tsx"],"sourcesContent":["import * as React from 'react'\nimport ReactDOM from 'react-dom'\nimport classNames from 'classnames'\n\nimport Button from '../deprecated-button'\n\nimport './dropdown.less'\n\ntype BoxProps = {\n onShowBody?: () => void\n onHideBody?: () => void\n allowBodyInteractions?: boolean\n top?: boolean\n right?: boolean\n scrolling_parent?: string\n children?: [\n React.ReactElement<TriggerProps>,\n React.ReactElement<BodyProps> | ((props: BodyProps) => JSX.Element),\n ]\n className?: string\n}\n\ntype BoxState = {\n top: boolean\n showBody: boolean\n}\n\nclass Box extends React.Component<BoxProps, BoxState> {\n public static displayName: string\n\n constructor(props: BoxProps, context: React.Context<unknown>) {\n super(props, context)\n this.state = {\n showBody: false,\n top: props.top || false,\n }\n\n this._timeout = undefined\n }\n\n componentWillUnmount() {\n document.removeEventListener('click', this._handleClickOutside, true)\n if (this._timeout) {\n clearTimeout(this._timeout)\n }\n }\n _timeout?: ReturnType<typeof setTimeout>\n\n _handleClickOutside = (event: MouseEvent) => {\n const dropdownDOMNode = ReactDOM.findDOMNode(this)\n\n if (dropdownDOMNode && !dropdownDOMNode.contains(event.target as Node))\n this._toggleShowBody()\n else if (!this.props.allowBodyInteractions) {\n // won't close when body interactions are allowed\n this._timeout = setTimeout(() => {\n if (this.state.showBody) {\n this._toggleShowBody()\n }\n }, 100)\n }\n }\n\n _toggleShowBody = () => {\n if (!this.state.showBody) {\n // will show\n if (this.props.onShowBody) this.props.onShowBody()\n document.addEventListener('click', this._handleClickOutside, true)\n } else {\n // will hide\n if (this.props.onHideBody) this.props.onHideBody()\n document.removeEventListener('click', this._handleClickOutside, true)\n }\n\n this.setState({\n showBody: !this.state.showBody,\n })\n }\n\n _getTriggerComponent() {\n const _trigger = this.props.children?.[0]\n return _trigger\n ? React.cloneElement(_trigger, { onClick: this._toggleShowBody })\n : undefined\n }\n\n // https://facebook.github.io/react/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components\n _setPosition = (body: HTMLElement | null) => {\n if (body) {\n const scrollingParent = document.getElementById(\n this.props.scrolling_parent ? this.props.scrolling_parent : '',\n )\n\n if (scrollingParent) {\n const dropdown = ReactDOM.findDOMNode(this)\n if (!dropdown) {\n return\n }\n const dropdownVerticalPosition = (ReactDOM.findDOMNode(this) as HTMLElement)\n .offsetTop\n const dropdownTrigger = (dropdown as Element).querySelector('.trigger')\n if (!dropdownTrigger) {\n return\n }\n const dropdownTriggerHeight = dropdownTrigger.clientHeight\n const dropdownBodyHeight = body.clientHeight\n\n const scrollingParentHeight = scrollingParent.clientHeight\n const scrollingParentOffset = scrollingParent.scrollTop\n\n const bottomOffset =\n scrollingParentHeight +\n scrollingParentOffset -\n dropdownVerticalPosition -\n dropdownTriggerHeight\n\n const top = bottomOffset < dropdownBodyHeight\n\n if (top !== this.state.top) {\n this.setState({ top })\n }\n }\n }\n }\n\n _getBodyComponent() {\n if (!this.state.showBody) {\n return null\n }\n const { top } = this.state\n const { right = false, children } = this.props\n const props = { top, right, setPosition: this._setPosition }\n\n const className = classNames({\n body_wrapper: true,\n with_arrow: true,\n top: top,\n bottom: !top,\n })\n\n const body = children?.[1]\n\n const contentMarkup =\n typeof body === 'function'\n ? body(props)\n : body\n ? React.cloneElement(body, props)\n : undefined\n return (\n <div className={className} style={{ position: 'relative' }}>\n {contentMarkup}\n </div>\n )\n }\n\n render() {\n const className = classNames('reactist_dropdown', this.props.className)\n const { top } = this.state\n\n return (\n <div\n style={{ display: 'inline-block' }}\n className={className}\n data-testid=\"reactist-dropdown-box\"\n >\n {top && this._getBodyComponent()}\n {this._getTriggerComponent()}\n {!top && this._getBodyComponent()}\n </div>\n )\n }\n}\n\nBox.displayName = 'Dropdown.Box'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\ntype TriggerProps = Omit<NativeButtonProps, 'title' | 'onClick'> & {\n tooltip?: React.ReactNode\n /**\n * @private the onClick prop is not to be used externally\n */\n onClick?: NativeButtonProps['onClick']\n}\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(function Trigger(\n { children, onClick, tooltip, className, ...props },\n ref,\n) {\n function handleClick(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) {\n event.preventDefault()\n event.stopPropagation()\n if (onClick) onClick(event)\n }\n\n return (\n <Button\n {...props}\n className={classNames('trigger', className)}\n onClick={handleClick}\n tooltip={tooltip}\n ref={ref}\n >\n {children}\n </Button>\n )\n})\n\nTrigger.displayName = 'Dropdown.Trigger'\n\ntype BodyProps = {\n setPosition?: React.Ref<HTMLDivElement>\n children?: React.ReactNode\n top?: boolean\n right?: boolean\n}\n\nfunction Body({ top, right, children, setPosition }: BodyProps) {\n const style: React.CSSProperties = { position: 'absolute', right: 0, top: 0 }\n\n if (top) {\n style.top = 'auto'\n style.bottom = 0\n }\n\n if (right) {\n style.right = 'auto'\n style.left = 0\n }\n\n return (\n <div\n ref={setPosition}\n style={style}\n className=\"body\"\n id=\"reactist-dropdown-body\"\n data-testid=\"reactist-dropdown-body\"\n >\n {children}\n </div>\n )\n}\n\nBody.displayName = 'Dropdown.Body'\n\nconst Dropdown = {\n Box,\n Trigger,\n Body,\n}\n\nexport { Dropdown }\n"],"names":["Box","React","Component","constructor","props","context","super","this","_timeout","_handleClickOutside","event","dropdownDOMNode","ReactDOM","findDOMNode","contains","target","_toggleShowBody","allowBodyInteractions","setTimeout","state","showBody","onHideBody","document","removeEventListener","onShowBody","addEventListener","setState","_setPosition","body","scrollingParent","getElementById","scrolling_parent","dropdown","dropdownVerticalPosition","offsetTop","dropdownTrigger","querySelector","top","clientHeight","scrollTop","undefined","componentWillUnmount","clearTimeout","_getTriggerComponent","_this$props$children","_trigger","children","cloneElement","onClick","_getBodyComponent","right","setPosition","className","classNames","body_wrapper","with_arrow","bottom","contentMarkup","createElement","style","position","render","display","displayName","Trigger","forwardRef","ref","tooltip","_ref","_objectWithoutProperties","objectWithoutProperties","_excluded","Button","preventDefault","stopPropagation","Body","left","id","data-testid"],"mappings":"gqBA2BA,MAAMA,UAAYC,EAAMC,UAGpBC,YAAYC,EAAiBC,GACzBC,MAAMF,EAAOC,GAD2CE,KAgB5DC,cAhB4D,EAAAD,KAkB5DE,oBAAuBC,IACnB,MAAMC,EAAkBC,EAAAA,QAASC,YAAYN,MAEzCI,IAAoBA,EAAgBG,SAASJ,EAAMK,QACnDR,KAAKS,kBACCT,KAAKH,MAAMa,wBAEjBV,KAAKC,SAAWU,WAAW,KACnBX,KAAKY,MAAMC,UACXb,KAAKS,mBAEV,OA7BiDT,KAiC5DS,gBAAkB,KACTT,KAAKY,MAAMC,UAMRb,KAAKH,MAAMiB,YAAYd,KAAKH,MAAMiB,aACtCC,SAASC,oBAAoB,QAAShB,KAAKE,qBAAqB,KAL5DF,KAAKH,MAAMoB,YAAYjB,KAAKH,MAAMoB,aACtCF,SAASG,iBAAiB,QAASlB,KAAKE,qBAAqB,IAOjEF,KAAKmB,SAAS,CACVN,UAAWb,KAAKY,MAAMC,YA7C8Bb,KAyD5DoB,aAAgBC,IACZ,GAAIA,EAAM,CACN,MAAMC,EAAkBP,SAASQ,eAC7BvB,KAAKH,MAAM2B,iBAAmBxB,KAAKH,MAAM2B,iBAAmB,IAGhE,GAAIF,EAAiB,CACjB,MAAMG,EAAWpB,EAAAA,QAASC,YAAYN,MACtC,IAAKyB,EACD,OAEJ,MAAMC,EAA4BrB,EAAQ,QAACC,YAAYN,MAClD2B,UACCC,EAAmBH,EAAqBI,cAAc,YAC5D,IAAKD,EACD,OAEJ,MAYME,EATwBR,EAAgBS,aAChBT,EAAgBU,UAK1CN,EAT0BE,EAAgBG,aACnBV,EAAKU,aAa5BD,IAAQ9B,KAAKY,MAAMkB,KACnB9B,KAAKmB,SAAS,CAAEW,IAAAA,OAvF5B9B,KAAKY,MAAQ,CACTC,UAAU,EACViB,IAAKjC,EAAMiC,MAAO,GAGtB9B,KAAKC,cAAWgC,EAGpBC,uBACInB,SAASC,oBAAoB,QAAShB,KAAKE,qBAAqB,GAC5DF,KAAKC,UACLkC,aAAanC,KAAKC,UAoC1BmC,uBAAoB,IAAAC,EAChB,MAAMC,EAAQ,SAAGtC,KAAKH,MAAM0C,eAAd,EAAGF,EAAsB,GACvC,OAAOC,EACD5C,EAAM8C,aAAaF,EAAU,CAAEG,QAASzC,KAAKS,uBAC7CwB,EA0CVS,oBACI,IAAK1C,KAAKY,MAAMC,SACZ,OAAO,KAEX,MAAMiB,IAAEA,GAAQ9B,KAAKY,OACf+B,MAAEA,GAAQ,EAAVJ,SAAiBA,GAAavC,KAAKH,MACnCA,EAAQ,CAAEiC,IAAAA,EAAKa,MAAAA,EAAOC,YAAa5C,KAAKoB,cAExCyB,EAAYC,EAAAA,QAAW,CACzBC,cAAc,EACdC,YAAY,EACZlB,IAAKA,EACLmB,QAASnB,IAGPT,QAAOkB,SAAAA,EAAW,GAElBW,EACc,mBAAT7B,EACDA,EAAKxB,GACLwB,EACA3B,EAAM8C,aAAanB,EAAMxB,QACzBoC,EACV,OACIvC,EAAKyD,cAAA,MAAA,CAAAN,UAAWA,EAAWO,MAAO,CAAEC,SAAU,aACzCH,GAKbI,SACI,MAAMT,EAAYC,EAAAA,QAAW,oBAAqB9C,KAAKH,MAAMgD,YACvDf,IAAEA,GAAQ9B,KAAKY,MAErB,OACIlB,EAAAyD,cAAA,MAAA,CACIC,MAAO,CAAEG,QAAS,gBAClBV,UAAWA,gBACC,yBAEXf,GAAO9B,KAAK0C,oBACZ1C,KAAKoC,wBACJN,GAAO9B,KAAK0C,sBA5IxBjD,EACY+D,mBAiJlB/D,EAAI+D,YAAc,eAelB,MAAMC,EAAU/D,EAAMgE,YAA4C,SAE9DC,EAAAA,GAAG,IADHpB,SAAEA,EAAFE,QAAYA,EAAZmB,QAAqBA,EAArBf,UAA8BA,GAC3BgB,EADyChE,EACzCiE,EAAAC,wBAAAF,EAAAG,GAQH,OACItE,EAAAyD,cAACc,4CACOpE,GADR,GAAA,CAEIgD,UAAWC,EAAAA,QAAW,UAAWD,GACjCJ,QAVR,SAAqBtC,GACjBA,EAAM+D,iBACN/D,EAAMgE,kBACF1B,GAASA,EAAQtC,IAQjByD,QAASA,EACTD,IAAKA,IAEJpB,MAcb,SAAS6B,GAAKtC,IAAEA,EAAFa,MAAOA,EAAPJ,SAAcA,EAAdK,YAAwBA,IAClC,MAAMQ,EAA6B,CAAEC,SAAU,WAAYV,MAAO,EAAGb,IAAK,GAY1E,OAVIA,IACAsB,EAAMtB,IAAM,OACZsB,EAAMH,OAAS,GAGfN,IACAS,EAAMT,MAAQ,OACdS,EAAMiB,KAAO,GAIb3E,uBACIiE,IAAKf,EACLQ,MAAOA,EACPP,UAAU,OACVyB,GAAG,yBAAwBC,cACf,0BAEXhC,GA9BbkB,EAAQD,YAAc,mBAmCtBY,EAAKZ,YAAc,iCAEF,CACb/D,IAAAA,EACAgE,QAAAA,EACAW,KAAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=(e(r),e(require("classnames")));const u=r.forwardRef((function(e,u){const s=a("reactist_input",e.className);return r.createElement("input",t.objectSpread2(t.objectSpread2({},e),{},{className:s,ref:u}))}));u.displayName="Input",exports.Input=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),r=require("classnames");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var u=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,u.get?u:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,t}var a=n(t),c=u(r);const l=a.forwardRef((function(t,r){const u=c.default("reactist_input",t.className);return a.createElement("input",e.objectSpread2(e.objectSpread2({},t),{},{className:u,ref:r}))}));l.displayName="Input",exports.Input=l;
2
2
  //# sourceMappingURL=input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sources":["../../../src/components/deprecated-input/input.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport './input.less'\n\ninterface Props extends React.InputHTMLAttributes<HTMLInputElement> {\n className?: string\n}\n\n/**\n * @deprecated\n */\nconst Input = React.forwardRef<HTMLInputElement, Props>(function Input(props, ref) {\n const className = classNames('reactist_input', props.className)\n return <input {...props} className={className} ref={ref} />\n})\nInput.displayName = 'Input'\n\nexport { Input }\n"],"names":["Input","React","props","ref","className","classNames","displayName"],"mappings":"kQAYMA,EAAQC,cAA0C,SAAeC,EAAOC,GAC1E,MAAMC,EAAYC,EAAW,iBAAkBH,EAAME,WACrD,OAAOH,2DAAWC,OAAOE,UAAWA,EAAWD,IAAKA,QAExDH,EAAMM,YAAc"}
1
+ {"version":3,"file":"input.js","sources":["../../../src/components/deprecated-input/input.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport './input.less'\n\ninterface Props extends React.InputHTMLAttributes<HTMLInputElement> {\n className?: string\n}\n\n/**\n * @deprecated\n */\nconst Input = React.forwardRef<HTMLInputElement, Props>(function Input(props, ref) {\n const className = classNames('reactist_input', props.className)\n return <input {...props} className={className} ref={ref} />\n})\nInput.displayName = 'Input'\n\nexport { Input }\n"],"names":["Input","React","forwardRef","props","ref","className","classNames","createElement","displayName"],"mappings":"shBAYA,MAAMA,EAAQC,EAAMC,YAAoC,SAAeC,EAAOC,GAC1E,MAAMC,EAAYC,EAAU,QAAC,iBAAkBH,EAAME,WACrD,OAAOJ,EAAAM,cAAA,2CAAWJ,GAAX,GAAA,CAAkBE,UAAWA,EAAWD,IAAKA,QAExDJ,EAAMQ,YAAc"}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import './select.less';
3
- declare type Option = {
3
+ type Option = {
4
4
  /** Optional key for each option. If not provided `value` is used. */
5
5
  key?: string | number;
6
6
  /** Value of the option. */
@@ -10,7 +10,7 @@ declare type Option = {
10
10
  /** Whether the options is disabled or not. */
11
11
  disabled?: boolean;
12
12
  };
13
- declare type Props = {
13
+ type Props = {
14
14
  className?: string;
15
15
  disabled?: boolean;
16
16
  /** Currently selected value. */
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var a=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),l=(e(t),e(require("classnames")));const s=["value","options","onChange","disabled","className","defaultValue"];function u(e){let{value:u,options:o=[],onChange:r,disabled:i=!0,className:d="",defaultValue:n}=e,c=a.objectWithoutProperties(e,s);const p=l("reactist_select",{disabled:i},d);return t.createElement("select",a.objectSpread2({className:p,value:u,onChange:e=>r?r(e.target.value):void 0,disabled:i,defaultValue:n},c),null==o?void 0:o.map(e=>t.createElement("option",{key:e.key||e.value,value:e.value,disabled:e.disabled},e.text)))}u.displayName="Select",u.defaultProps={options:[],disabled:!1},exports.Select=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),a=require("classnames");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,l.get?l:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,t}var u=r(t),n=l(a);const o=["value","options","onChange","disabled","className","defaultValue"];function s(t){let{value:a,options:l=[],onChange:r,disabled:s=!0,className:i="",defaultValue:c}=t,d=e.objectWithoutProperties(t,o);const f=n.default("reactist_select",{disabled:s},i);return u.createElement("select",e.objectSpread2({className:f,value:a,onChange:e=>r?r(e.target.value):void 0,disabled:s,defaultValue:c},d),null==l?void 0:l.map(e=>u.createElement("option",{key:e.key||e.value,value:e.value,disabled:e.disabled},e.text)))}s.displayName="Select",s.defaultProps={options:[],disabled:!1},exports.Select=s;
2
2
  //# sourceMappingURL=select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":["../../../src/components/deprecated-select/select.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","value","options","onChange","disabled","className","defaultValue","otherProps","selectClassName","classNames","React","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":"yUA6BA,SAASA,SAAOC,MACZA,EADYC,QAEZA,EAAU,GAFEC,SAGZA,EAHYC,SAIZA,GAAW,EAJCC,UAKZA,EAAY,GALAC,aAMZA,KACGC,iCAEH,MAAMC,EAAkBC,EAAW,kBAAmB,CAAEL,SAAAA,GAAYC,GACpE,OACIK,0CACIL,UAAWG,EACXP,MAAOA,EACPE,SAAWQ,GAAWR,EAAWA,EAASQ,EAAMC,OAAOX,YAASY,EAChET,SAAUA,EACVE,aAAcA,GACVC,SAEHL,SAAAA,EAASY,IAAKC,GACXL,0BACIM,IAAKD,EAAOC,KAAOD,EAAOd,MAC1BA,MAAOc,EAAOd,MACdG,SAAUW,EAAOX,UAEhBW,EAAOE,QAM5BjB,EAAOkB,YAAc,SACrBlB,EAAOmB,aAAe,CAClBjB,QAAS,GACTE,UAAU"}
1
+ {"version":3,"file":"select.js","sources":["../../../src/components/deprecated-select/select.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","_ref","value","options","onChange","disabled","className","defaultValue","otherProps","_objectWithoutProperties","objectWithoutProperties","_excluded","selectClassName","classNames","React","createElement","_objectSpread","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":"mmBA6BA,SAASA,EAQDC,GAAA,IARQC,MACZA,EADYC,QAEZA,EAAU,GAFEC,SAGZA,EAHYC,SAIZA,GAAW,EAJCC,UAKZA,EAAY,GALAC,aAMZA,GAEIN,EADDO,EACCC,EAAAC,wBAAAT,EAAAU,GACJ,MAAMC,EAAkBC,EAAU,QAAC,kBAAmB,CAAER,SAAAA,GAAYC,GACpE,OACIQ,EACIC,cAAA,SADJC,gBAAA,CACIV,UAAWM,EACXV,MAAOA,EACPE,SAAWa,GAAWb,EAAWA,EAASa,EAAMC,OAAOhB,YAASiB,EAChEd,SAAUA,EACVE,aAAcA,GACVC,GANR,MAQKL,OARL,EAQKA,EAASiB,IAAKC,GACXP,EAAAC,cAAA,SAAA,CACIO,IAAKD,EAAOC,KAAOD,EAAOnB,MAC1BA,MAAOmB,EAAOnB,MACdG,SAAUgB,EAAOhB,UAEhBgB,EAAOE,QAM5BvB,EAAOwB,YAAc,SACrBxB,EAAOyB,aAAe,CAClBtB,QAAS,GACTE,UAAU"}
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- declare type Key = 'ArrowUp' | 'ArrowRight' | 'ArrowDown' | 'ArrowLeft' | 'Enter' | 'Backspace' | 'Escape';
2
+ type Key = 'ArrowUp' | 'ArrowRight' | 'ArrowDown' | 'ArrowLeft' | 'Enter' | 'Backspace' | 'Escape';
3
3
  declare const SUPPORTED_KEYS: Record<string, Key>;
4
4
  declare const KeyCapturerResolver: {
5
5
  resolveByKey(eventKey: string): Key | null;
6
6
  resolveByKeyCode(keyCode: number): Key | null;
7
7
  };
8
- declare type EventHandler = (event: React.SyntheticEvent) => void;
9
- declare type EventHandlerProps = {
8
+ type EventHandler = (event: React.SyntheticEvent) => void;
9
+ type EventHandlerProps = {
10
10
  onArrowUp?: EventHandler;
11
11
  onArrowDown?: EventHandler;
12
12
  onArrowLeft?: EventHandler;
@@ -15,7 +15,7 @@ declare type EventHandlerProps = {
15
15
  onBackspace?: EventHandler;
16
16
  onEscape?: EventHandler;
17
17
  };
18
- declare type PropagateProps = {
18
+ type PropagateProps = {
19
19
  propagateArrowUp?: boolean;
20
20
  propagateArrowDown?: boolean;
21
21
  propagateArrowLeft?: boolean;
@@ -24,7 +24,7 @@ declare type PropagateProps = {
24
24
  propagateBackspace?: boolean;
25
25
  propagateEscape?: boolean;
26
26
  };
27
- declare type KeyCapturerProps = EventHandlerProps & PropagateProps & {
27
+ type KeyCapturerProps = EventHandlerProps & PropagateProps & {
28
28
  eventName?: 'onKeyDown' | 'onKeyDownCapture' | 'onKeyUp' | 'onKeyUpCapture';
29
29
  children: React.ReactElement<unknown>;
30
30
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../../_virtual/_rollupPluginBabelHelpers.js"),e=require("react");const o={resolveByKey(r){switch(r){case"Left":case"ArrowLeft":return"ArrowLeft";case"Up":case"ArrowUp":return"ArrowUp";case"Right":case"ArrowRight":return"ArrowRight";case"Down":case"ArrowDown":return"ArrowDown";case"Enter":return"Enter";case"Backspace":return"Backspace";case"Esc":case"Escape":return"Escape";default:return null}},resolveByKeyCode(r){switch(r){case 37:return"ArrowLeft";case 38:return"ArrowUp";case 39:return"ArrowRight";case 40:return"ArrowDown";case 13:return"Enter";case 8:return"Backspace";case 27:return"Escape";default:return null}}},t={ArrowUp:"onArrowUp",ArrowDown:"onArrowDown",ArrowLeft:"onArrowLeft",ArrowRight:"onArrowRight",Enter:"onEnter",Backspace:"onBackspace",Escape:"onEscape"},n={ArrowUp:"propagateArrowUp",ArrowDown:"propagateArrowDown",ArrowLeft:"propagateArrowLeft",ArrowRight:"propagateArrowRight",Enter:"propagateEnter",Backspace:"propagateBackspace",Escape:"propagateEscape"};exports.KeyCapturer=function(a){const{children:c,eventName:s="onKeyDown"}=a,p=e.useRef(!1);return e.cloneElement(c,r.objectSpread2({[s]:function(r){const e=void 0!==r.key?o.resolveByKey(r.key):o.resolveByKeyCode(r.keyCode);if(!e)return;const c=a[n[e]]||!1,s=a[t[e]];"Enter"===e&&s&&(p.current||229===(r.keyCode||r.which))||s&&(s(r),c||(r.preventDefault(),r.stopPropagation()))}},a.onEnter?{onCompositionStart:()=>{p.current=!0},onCompositionEnd:()=>{p.current=!1}}:void 0))},exports.KeyCapturerResolver=o,exports.SUPPORTED_KEYS={ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ENTER:"Enter",BACKSPACE:"Backspace",ESCAPE:"Escape"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../../_virtual/_rollupPluginBabelHelpers.js");function e(r){if(r&&r.__esModule)return r;var e=Object.create(null);return r&&Object.keys(r).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:function(){return r[t]}})}})),e.default=r,e}var t=e(require("react"));const o={resolveByKey(r){switch(r){case"Left":case"ArrowLeft":return"ArrowLeft";case"Up":case"ArrowUp":return"ArrowUp";case"Right":case"ArrowRight":return"ArrowRight";case"Down":case"ArrowDown":return"ArrowDown";case"Enter":return"Enter";case"Backspace":return"Backspace";case"Esc":case"Escape":return"Escape";default:return null}},resolveByKeyCode(r){switch(r){case 37:return"ArrowLeft";case 38:return"ArrowUp";case 39:return"ArrowRight";case 40:return"ArrowDown";case 13:return"Enter";case 8:return"Backspace";case 27:return"Escape";default:return null}}},n={ArrowUp:"onArrowUp",ArrowDown:"onArrowDown",ArrowLeft:"onArrowLeft",ArrowRight:"onArrowRight",Enter:"onEnter",Backspace:"onBackspace",Escape:"onEscape"},a={ArrowUp:"propagateArrowUp",ArrowDown:"propagateArrowDown",ArrowLeft:"propagateArrowLeft",ArrowRight:"propagateArrowRight",Enter:"propagateEnter",Backspace:"propagateBackspace",Escape:"propagateEscape"};exports.KeyCapturer=function(e){const{children:c,eventName:s="onKeyDown"}=e,p=t.useRef(!1);return t.cloneElement(c,r.objectSpread2({[s]:function(r){const t=void 0!==r.key?o.resolveByKey(r.key):o.resolveByKeyCode(r.keyCode);if(!t)return;const c=e[a[t]]||!1,s=e[n[t]];"Enter"===t&&s&&(p.current||229===(r.keyCode||r.which))||s&&(s(r),c||(r.preventDefault(),r.stopPropagation()))}},e.onEnter?{onCompositionStart:()=>{p.current=!0},onCompositionEnd:()=>{p.current=!1}}:void 0))},exports.KeyCapturerResolver=o,exports.SUPPORTED_KEYS={ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ENTER:"Enter",BACKSPACE:"Backspace",ESCAPE:"Escape"};
2
2
  //# sourceMappingURL=key-capturer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"key-capturer.js","sources":["../../../src/components/key-capturer/key-capturer.tsx"],"sourcesContent":["import * as React from 'react'\n\ntype Key = 'ArrowUp' | 'ArrowRight' | 'ArrowDown' | 'ArrowLeft' | 'Enter' | 'Backspace' | 'Escape'\n\nconst SUPPORTED_KEYS: Record<string, Key> = {\n ARROW_UP: 'ArrowUp',\n ARROW_RIGHT: 'ArrowRight',\n ARROW_DOWN: 'ArrowDown',\n ARROW_LEFT: 'ArrowLeft',\n ENTER: 'Enter',\n BACKSPACE: 'Backspace',\n ESCAPE: 'Escape',\n}\n\nconst KeyCapturerResolver = {\n resolveByKey(eventKey: string): Key | null {\n switch (eventKey) {\n case 'Left': // IE specific\n case 'ArrowLeft': {\n return 'ArrowLeft'\n }\n case 'Up': // IE specific\n case 'ArrowUp': {\n return 'ArrowUp'\n }\n case 'Right': // IE specific\n case 'ArrowRight': {\n return 'ArrowRight'\n }\n case 'Down': // IE specific\n case 'ArrowDown': {\n return 'ArrowDown'\n }\n case 'Enter': {\n return 'Enter'\n }\n case 'Backspace': {\n return 'Backspace'\n }\n case 'Esc': // IE specific\n case 'Escape': {\n return 'Escape'\n }\n default: {\n return null\n }\n }\n },\n\n resolveByKeyCode(keyCode: number): Key | null {\n switch (keyCode) {\n case 37: {\n return 'ArrowLeft'\n }\n case 38: {\n return 'ArrowUp'\n }\n case 39: {\n return 'ArrowRight'\n }\n case 40: {\n return 'ArrowDown'\n }\n case 13: {\n return 'Enter'\n }\n case 8: {\n return 'Backspace'\n }\n case 27: {\n return 'Escape'\n }\n default: {\n return null\n }\n }\n },\n}\n\ntype EventHandler = (event: React.SyntheticEvent) => void\n\ntype EventHandlerProps = {\n onArrowUp?: EventHandler\n onArrowDown?: EventHandler\n onArrowLeft?: EventHandler\n onArrowRight?: EventHandler\n onEnter?: EventHandler\n onBackspace?: EventHandler\n onEscape?: EventHandler\n}\n\ntype PropagateProps = {\n propagateArrowUp?: boolean\n propagateArrowDown?: boolean\n propagateArrowLeft?: boolean\n propagateArrowRight?: boolean\n propagateEnter?: boolean\n propagateBackspace?: boolean\n propagateEscape?: boolean\n}\n\nconst keyEventHandlerMapping: Record<Key, keyof EventHandlerProps> = {\n ArrowUp: 'onArrowUp',\n ArrowDown: 'onArrowDown',\n ArrowLeft: 'onArrowLeft',\n ArrowRight: 'onArrowRight',\n Enter: 'onEnter',\n Backspace: 'onBackspace',\n Escape: 'onEscape',\n}\n\nconst keyPropagatePropMapping: Record<Key, keyof PropagateProps> = {\n ArrowUp: 'propagateArrowUp',\n ArrowDown: 'propagateArrowDown',\n ArrowLeft: 'propagateArrowLeft',\n ArrowRight: 'propagateArrowRight',\n Enter: 'propagateEnter',\n Backspace: 'propagateBackspace',\n Escape: 'propagateEscape',\n}\n\ntype KeyCapturerProps = EventHandlerProps &\n PropagateProps & {\n eventName?: 'onKeyDown' | 'onKeyDownCapture' | 'onKeyUp' | 'onKeyUpCapture'\n children: React.ReactElement<unknown>\n }\n\n/**\n * Use this component to wrap anything you want to handle key events for (e.g. an input).\n * You can specify the `eventName` to capture (defaults to `onKeyDown`).\n * Check the SUPPORTED_KEYS map to see which keys are supported and supply the respective\n * `on${Key}` prop (i.e. `onEnter` or `onArrowDown`).\n * If you want the default behaviour to be preserved (i.e. only want to hook into the event\n * instead of replacing it) set the `propagate${Key}` prop (e.g. propagateBackspace).\n */\nfunction KeyCapturer(props: KeyCapturerProps) {\n const { children, eventName = 'onKeyDown' } = props\n const composingRef = React.useRef(false)\n const composingEventHandlers = props.onEnter\n ? {\n onCompositionStart: () => {\n composingRef.current = true\n },\n onCompositionEnd: () => {\n composingRef.current = false\n },\n }\n : undefined\n\n function handleKeyEvent(event: React.KeyboardEvent<HTMLInputElement>) {\n // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode\n const key =\n event.key !== undefined\n ? KeyCapturerResolver.resolveByKey(event.key)\n : KeyCapturerResolver.resolveByKeyCode(event.keyCode)\n\n if (!key) return\n const propagateEvent = props[keyPropagatePropMapping[key]] || false\n const eventHandler = props[keyEventHandlerMapping[key]]\n\n if (key === 'Enter' && eventHandler) {\n if (\n composingRef.current ||\n // Safari fires the onCompositionEnd event before the keydown event, so we\n // have to rely on the 229 keycode, which is Enter when fired from an IME\n // https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode\n (event.keyCode || event.which) === 229\n ) {\n return\n }\n }\n\n if (eventHandler) {\n eventHandler(event)\n if (!propagateEvent) {\n event.preventDefault()\n event.stopPropagation()\n }\n }\n }\n\n return React.cloneElement(children, {\n [eventName]: handleKeyEvent,\n ...composingEventHandlers,\n })\n}\n\nexport { KeyCapturer, KeyCapturerResolver, SUPPORTED_KEYS }\n"],"names":["KeyCapturerResolver","resolveByKey","eventKey","resolveByKeyCode","keyCode","keyEventHandlerMapping","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Backspace","Escape","keyPropagatePropMapping","props","children","eventName","composingRef","React","[object Object]","event","key","undefined","propagateEvent","eventHandler","current","which","preventDefault","stopPropagation","onEnter","onCompositionStart","onCompositionEnd","ARROW_UP","ARROW_RIGHT","ARROW_DOWN","ARROW_LEFT","ENTER","BACKSPACE","ESCAPE"],"mappings":"0JAcMA,EAAsB,CACxBC,aAAaC,GACT,OAAQA,GACJ,IAAK,OACL,IAAK,YACD,MAAO,YAEX,IAAK,KACL,IAAK,UACD,MAAO,UAEX,IAAK,QACL,IAAK,aACD,MAAO,aAEX,IAAK,OACL,IAAK,YACD,MAAO,YAEX,IAAK,QACD,MAAO,QAEX,IAAK,YACD,MAAO,YAEX,IAAK,MACL,IAAK,SACD,MAAO,SAEX,QACI,OAAO,OAKnBC,iBAAiBC,GACb,OAAQA,GACJ,KAAK,GACD,MAAO,YAEX,KAAK,GACD,MAAO,UAEX,KAAK,GACD,MAAO,aAEX,KAAK,GACD,MAAO,YAEX,KAAK,GACD,MAAO,QAEX,KAAK,EACD,MAAO,YAEX,KAAK,GACD,MAAO,SAEX,QACI,OAAO,QA4BjBC,EAA+D,CACjEC,QAAS,YACTC,UAAW,cACXC,UAAW,cACXC,WAAY,eACZC,MAAO,UACPC,UAAW,cACXC,OAAQ,YAGNC,EAA6D,CAC/DP,QAAS,mBACTC,UAAW,qBACXC,UAAW,qBACXC,WAAY,sBACZC,MAAO,iBACPC,UAAW,qBACXC,OAAQ,uCAiBZ,SAAqBE,GACjB,MAAMC,SAAEA,EAAFC,UAAYA,EAAY,aAAgBF,EACxCG,EAAeC,UAAa,GA4ClC,OAAOA,eAAmBH,mBACtBI,CAACH,GAjCL,SAAwBI,GAEpB,MAAMC,OACYC,IAAdF,EAAMC,IACArB,EAAoBC,aAAamB,EAAMC,KACvCrB,EAAoBG,iBAAiBiB,EAAMhB,SAErD,IAAKiB,EAAK,OACV,MAAME,EAAiBT,EAAMD,EAAwBQ,MAAS,EACxDG,EAAeV,EAAMT,EAAuBgB,IAEtC,UAARA,GAAmBG,IAEfP,EAAaQ,SAIsB,OAAlCL,EAAMhB,SAAWgB,EAAMM,SAM5BF,IACAA,EAAaJ,GACRG,IACDH,EAAMO,iBACNP,EAAMQ,sBAtCad,EAAMe,QAC/B,CACIC,mBAAoB,KAChBb,EAAaQ,SAAU,GAE3BM,iBAAkB,KACdd,EAAaQ,SAAU,SAG/BH,0DA/IkC,CACxCU,SAAU,UACVC,YAAa,aACbC,WAAY,YACZC,WAAY,YACZC,MAAO,QACPC,UAAW,YACXC,OAAQ"}
1
+ {"version":3,"file":"key-capturer.js","sources":["../../../src/components/key-capturer/key-capturer.tsx"],"sourcesContent":["import * as React from 'react'\n\ntype Key = 'ArrowUp' | 'ArrowRight' | 'ArrowDown' | 'ArrowLeft' | 'Enter' | 'Backspace' | 'Escape'\n\nconst SUPPORTED_KEYS: Record<string, Key> = {\n ARROW_UP: 'ArrowUp',\n ARROW_RIGHT: 'ArrowRight',\n ARROW_DOWN: 'ArrowDown',\n ARROW_LEFT: 'ArrowLeft',\n ENTER: 'Enter',\n BACKSPACE: 'Backspace',\n ESCAPE: 'Escape',\n}\n\nconst KeyCapturerResolver = {\n resolveByKey(eventKey: string): Key | null {\n switch (eventKey) {\n case 'Left': // IE specific\n case 'ArrowLeft': {\n return 'ArrowLeft'\n }\n case 'Up': // IE specific\n case 'ArrowUp': {\n return 'ArrowUp'\n }\n case 'Right': // IE specific\n case 'ArrowRight': {\n return 'ArrowRight'\n }\n case 'Down': // IE specific\n case 'ArrowDown': {\n return 'ArrowDown'\n }\n case 'Enter': {\n return 'Enter'\n }\n case 'Backspace': {\n return 'Backspace'\n }\n case 'Esc': // IE specific\n case 'Escape': {\n return 'Escape'\n }\n default: {\n return null\n }\n }\n },\n\n resolveByKeyCode(keyCode: number): Key | null {\n switch (keyCode) {\n case 37: {\n return 'ArrowLeft'\n }\n case 38: {\n return 'ArrowUp'\n }\n case 39: {\n return 'ArrowRight'\n }\n case 40: {\n return 'ArrowDown'\n }\n case 13: {\n return 'Enter'\n }\n case 8: {\n return 'Backspace'\n }\n case 27: {\n return 'Escape'\n }\n default: {\n return null\n }\n }\n },\n}\n\ntype EventHandler = (event: React.SyntheticEvent) => void\n\ntype EventHandlerProps = {\n onArrowUp?: EventHandler\n onArrowDown?: EventHandler\n onArrowLeft?: EventHandler\n onArrowRight?: EventHandler\n onEnter?: EventHandler\n onBackspace?: EventHandler\n onEscape?: EventHandler\n}\n\ntype PropagateProps = {\n propagateArrowUp?: boolean\n propagateArrowDown?: boolean\n propagateArrowLeft?: boolean\n propagateArrowRight?: boolean\n propagateEnter?: boolean\n propagateBackspace?: boolean\n propagateEscape?: boolean\n}\n\nconst keyEventHandlerMapping: Record<Key, keyof EventHandlerProps> = {\n ArrowUp: 'onArrowUp',\n ArrowDown: 'onArrowDown',\n ArrowLeft: 'onArrowLeft',\n ArrowRight: 'onArrowRight',\n Enter: 'onEnter',\n Backspace: 'onBackspace',\n Escape: 'onEscape',\n}\n\nconst keyPropagatePropMapping: Record<Key, keyof PropagateProps> = {\n ArrowUp: 'propagateArrowUp',\n ArrowDown: 'propagateArrowDown',\n ArrowLeft: 'propagateArrowLeft',\n ArrowRight: 'propagateArrowRight',\n Enter: 'propagateEnter',\n Backspace: 'propagateBackspace',\n Escape: 'propagateEscape',\n}\n\ntype KeyCapturerProps = EventHandlerProps &\n PropagateProps & {\n eventName?: 'onKeyDown' | 'onKeyDownCapture' | 'onKeyUp' | 'onKeyUpCapture'\n children: React.ReactElement<unknown>\n }\n\n/**\n * Use this component to wrap anything you want to handle key events for (e.g. an input).\n * You can specify the `eventName` to capture (defaults to `onKeyDown`).\n * Check the SUPPORTED_KEYS map to see which keys are supported and supply the respective\n * `on${Key}` prop (i.e. `onEnter` or `onArrowDown`).\n * If you want the default behaviour to be preserved (i.e. only want to hook into the event\n * instead of replacing it) set the `propagate${Key}` prop (e.g. propagateBackspace).\n */\nfunction KeyCapturer(props: KeyCapturerProps) {\n const { children, eventName = 'onKeyDown' } = props\n const composingRef = React.useRef(false)\n const composingEventHandlers = props.onEnter\n ? {\n onCompositionStart: () => {\n composingRef.current = true\n },\n onCompositionEnd: () => {\n composingRef.current = false\n },\n }\n : undefined\n\n function handleKeyEvent(event: React.KeyboardEvent<HTMLInputElement>) {\n // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode\n const key =\n event.key !== undefined\n ? KeyCapturerResolver.resolveByKey(event.key)\n : KeyCapturerResolver.resolveByKeyCode(event.keyCode)\n\n if (!key) return\n const propagateEvent = props[keyPropagatePropMapping[key]] || false\n const eventHandler = props[keyEventHandlerMapping[key]]\n\n if (key === 'Enter' && eventHandler) {\n if (\n composingRef.current ||\n // Safari fires the onCompositionEnd event before the keydown event, so we\n // have to rely on the 229 keycode, which is Enter when fired from an IME\n // https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode\n (event.keyCode || event.which) === 229\n ) {\n return\n }\n }\n\n if (eventHandler) {\n eventHandler(event)\n if (!propagateEvent) {\n event.preventDefault()\n event.stopPropagation()\n }\n }\n }\n\n return React.cloneElement(children, {\n [eventName]: handleKeyEvent,\n ...composingEventHandlers,\n })\n}\n\nexport { KeyCapturer, KeyCapturerResolver, SUPPORTED_KEYS }\n"],"names":["KeyCapturerResolver","resolveByKey","eventKey","resolveByKeyCode","keyCode","keyEventHandlerMapping","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Backspace","Escape","keyPropagatePropMapping","props","children","eventName","composingRef","React","useRef","cloneElement","_objectSpread","[object Object]","event","key","undefined","propagateEvent","eventHandler","current","which","preventDefault","stopPropagation","onEnter","onCompositionStart","onCompositionEnd","ARROW_UP","ARROW_RIGHT","ARROW_DOWN","ARROW_LEFT","ENTER","BACKSPACE","ESCAPE"],"mappings":"2aAIA,MAUMA,EAAsB,CACxBC,aAAaC,GACT,OAAQA,GACJ,IAAK,OACL,IAAK,YACD,MAAO,YAEX,IAAK,KACL,IAAK,UACD,MAAO,UAEX,IAAK,QACL,IAAK,aACD,MAAO,aAEX,IAAK,OACL,IAAK,YACD,MAAO,YAEX,IAAK,QACD,MAAO,QAEX,IAAK,YACD,MAAO,YAEX,IAAK,MACL,IAAK,SACD,MAAO,SAEX,QACI,OAAO,OAKnBC,iBAAiBC,GACb,OAAQA,GACJ,KAAK,GACD,MAAO,YAEX,KAAK,GACD,MAAO,UAEX,KAAK,GACD,MAAO,aAEX,KAAK,GACD,MAAO,YAEX,KAAK,GACD,MAAO,QAEX,KAAK,EACD,MAAO,YAEX,KAAK,GACD,MAAO,SAEX,QACI,OAAO,QA4BjBC,EAA+D,CACjEC,QAAS,YACTC,UAAW,cACXC,UAAW,cACXC,WAAY,eACZC,MAAO,UACPC,UAAW,cACXC,OAAQ,YAGNC,EAA6D,CAC/DP,QAAS,mBACTC,UAAW,qBACXC,UAAW,qBACXC,WAAY,sBACZC,MAAO,iBACPC,UAAW,qBACXC,OAAQ,uCAiBZ,SAAqBE,GACjB,MAAMC,SAAEA,EAAFC,UAAYA,EAAY,aAAgBF,EACxCG,EAAeC,EAAMC,QAAO,GA4ClC,OAAOD,EAAME,aAAaL,EAAnBM,gBAAA,CACHC,CAACN,GAjCL,SAAwBO,GAEpB,MAAMC,OACYC,IAAdF,EAAMC,IACAxB,EAAoBC,aAAasB,EAAMC,KACvCxB,EAAoBG,iBAAiBoB,EAAMnB,SAErD,IAAKoB,EAAK,OACV,MAAME,EAAiBZ,EAAMD,EAAwBW,MAAS,EACxDG,EAAeb,EAAMT,EAAuBmB,IAEtC,UAARA,GAAmBG,IAEfV,EAAaW,SAIsB,OAAlCL,EAAMnB,SAAWmB,EAAMM,SAM5BF,IACAA,EAAaJ,GACRG,IACDH,EAAMO,iBACNP,EAAMQ,sBAtCajB,EAAMkB,QAC/B,CACIC,mBAAoB,KAChBhB,EAAaW,SAAU,GAE3BM,iBAAkB,KACdjB,EAAaW,SAAU,SAG/BH,0DA/IkC,CACxCU,SAAU,UACVC,YAAa,aACbC,WAAY,YACZC,WAAY,YACZC,MAAO,QACPC,UAAW,YACXC,OAAQ"}
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  declare let globalTranslateKey: (key: string) => string;
3
- declare type TranslateKey = typeof globalTranslateKey;
4
- declare type NativeSpanProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
5
- declare type Props = Omit<NativeSpanProps, 'children'> & {
3
+ type TranslateKey = typeof globalTranslateKey;
4
+ type NativeSpanProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
5
+ type Props = Omit<NativeSpanProps, 'children'> & {
6
6
  /**
7
7
  * The shortcut to be represented as markup. It supports an intuitive syntax where you can
8
8
  * combine modifiers (cmd, ctrl, shift, alt) with single keys all concatenated with plus signs.
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=(e(r),e(require("classnames")));const c=["children","className","translateKey","isMac"];let s=e=>e;function n(e){switch(e.toLowerCase()){case"cmd":case"mod":return"⌘";case"control":case"ctrl":return"⌃";case"alt":return"⌥";case"shift":return"⇧";case"space":return"␣";default:return e}}function l(e){var l,o;let{children:u,className:i,translateKey:p=s,isMac:d=null!=(l=null==(o=navigator.platform)?void 0:o.toUpperCase().includes("MAC"))&&l}=e,m=t.objectWithoutProperties(e,c);const f="string"==typeof u?[u]:u;return r.createElement("span",t.objectSpread2({className:a("reactist_keyboard_shortcut",i,{"reactist_keyboard_shortcut--macos":d})},m),f.map((e,t)=>r.createElement(r.Fragment,{key:t},0===t?null:", ",r.createElement("kbd",null,function(e,t,r){const a=t?n:r,c=/\b(mod|cmd|ctrl|control|alt|shift)\b/i.test(e);return t||(e=e.replace(/\b(mod|cmd)\b/i,"ctrl")),e.split(/\s*\+\s*/).map((function(e){return function(e){return/^(mod|cmd|ctrl|control|alt|shift|space|super)$/i.test(e)}(e)?function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}(a(e)):c&&1===e.length?e.toUpperCase():e}))}(e,d,p).map((e,t)=>r.createElement("kbd",{key:t},e))))))}l.setTranslateKey=e=>{s=e},exports.KeyboardShortcut=l;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),r=require("classnames");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,t}var n=c(t),s=a(r);const l=["children","className","translateKey","isMac"];let o=e=>e;function u(e){switch(e.toLowerCase()){case"cmd":case"mod":return"⌘";case"control":case"ctrl":return"⌃";case"alt":return"⌥";case"shift":return"⇧";case"space":return"␣";default:return e}}function i(t){var r,a;let{children:c,className:i,translateKey:d=o,isMac:p=null!=(r=null==(a=navigator.platform)?void 0:a.toUpperCase().includes("MAC"))&&r}=t,f=e.objectWithoutProperties(t,l);const m="string"==typeof c?[c]:c;return n.createElement("span",e.objectSpread2({className:s.default("reactist_keyboard_shortcut",i,{"reactist_keyboard_shortcut--macos":p})},f),m.map((e,t)=>n.createElement(n.Fragment,{key:t},0===t?null:", ",n.createElement("kbd",null,function(e,t,r){const a=t?u:r,c=/\b(mod|cmd|ctrl|control|alt|shift)\b/i.test(e);return t||(e=e.replace(/\b(mod|cmd)\b/i,"ctrl")),e.split(/\s*\+\s*/).map((function(e){return function(e){return/^(mod|cmd|ctrl|control|alt|shift|space|super)$/i.test(e)}(e)?function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}(a(e)):c&&1===e.length?e.toUpperCase():e}))}(e,p,d).map((e,t)=>n.createElement("kbd",{key:t},e))))))}i.setTranslateKey=e=>{o=e},exports.KeyboardShortcut=i;
2
2
  //# sourceMappingURL=keyboard-shortcut.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard-shortcut.js","sources":["../../../src/components/keyboard-shortcut/keyboard-shortcut.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\n//\n// Support for setting up how to translate modifiers globally.\n//\n\nlet globalTranslateKey = (key: string) => key\n\ntype TranslateKey = typeof globalTranslateKey\n\nKeyboardShortcut.setTranslateKey = (tr: TranslateKey) => {\n globalTranslateKey = tr\n}\n\nfunction translateKeyMac(key: string) {\n switch (key.toLowerCase()) {\n case 'cmd':\n case 'mod':\n return '⌘'\n case 'control':\n case 'ctrl':\n return '⌃'\n case 'alt':\n return '⌥'\n case 'shift':\n return '⇧'\n case 'space':\n return '␣'\n default:\n return key\n }\n}\n\n//\n// Some helpers\n//\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()\n}\n\nfunction hasModifiers(str: string) {\n return /\\b(mod|cmd|ctrl|control|alt|shift)\\b/i.test(str)\n}\n\nfunction isSpecialKey(str: string) {\n return /^(mod|cmd|ctrl|control|alt|shift|space|super)$/i.test(str)\n}\n\nfunction parseKeys(shortcut: string, isMac: boolean, translateKey: TranslateKey) {\n const t = isMac ? translateKeyMac : translateKey\n const _hasModifiers = hasModifiers(shortcut)\n\n function mapIndividualKey(str: string) {\n if (isSpecialKey(str)) {\n return capitalize(t(str))\n }\n if (_hasModifiers && str.length === 1) {\n return str.toUpperCase()\n }\n return str\n }\n\n if (!isMac) {\n shortcut = shortcut.replace(/\\b(mod|cmd)\\b/i, 'ctrl')\n }\n\n return shortcut.split(/\\s*\\+\\s*/).map(mapIndividualKey)\n}\n\n//\n// The KeyboardShortcut component\n//\n\ntype NativeSpanProps = React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLSpanElement>,\n HTMLSpanElement\n>\n\ntype Props = Omit<NativeSpanProps, 'children'> & {\n /**\n * The shortcut to be represented as markup. It supports an intuitive syntax where you can\n * combine modifiers (cmd, ctrl, shift, alt) with single keys all concatenated with plus signs.\n * You can also pass various shortcuts as an array, which will be depicted separated by commas.\n */\n children: string | string[]\n /**\n * A function that allows you to change how some key names are represented. This may be useful,\n * for instance, to translate modifier names that are expressed differently in other languages\n * (e.g. `Ctrl` is named `Strg` in German).\n *\n * It defaults to a global version that leaves the key as is. You can pass your version as a\n * prop, or you can also set your own version of this global default one, so you don't need to\n * pass your own on each invocation of this component.\n *\n * ```js\n * import { KeyboardShortcut } from '@doist/reactist'\n * KeyboardShortcut.setTranslateKey = key => { ... }\n * ```\n *\n * Note: When the component detects the macOS operating system it bypasses key translation for\n * most modifiers and uses macOS-specific symbols. See the `isMac` prop for details.\n */\n translateKey?: TranslateKey\n /**\n * This prop is not meant to be passed. The component will automatically initialize it to `true`\n * if it detects that the current browser / operating system is on macOS, in which case modifier\n * keys are represented using macOS' notation (e.g. ⌘ ⌃ ⌥ ⇧).\n *\n * Though it is discouraged, if you don't want this special treatment in macOS, you can pass\n * `isMac={false}` in all invocations of this component.\n */\n isMac?: boolean\n}\n\nfunction KeyboardShortcut({\n children,\n className,\n translateKey = globalTranslateKey,\n isMac = navigator.platform?.toUpperCase().includes('MAC') ?? false,\n ...props\n}: Props) {\n const shortcuts = typeof children === 'string' ? [children] : children\n return (\n <span\n className={classNames('reactist_keyboard_shortcut', className, {\n 'reactist_keyboard_shortcut--macos': isMac,\n })}\n {...props}\n >\n {shortcuts.map((shortcut, i) => (\n <React.Fragment key={i}>\n {i === 0 ? null : ', '}\n <kbd>\n {parseKeys(shortcut, isMac, translateKey).map((key, j) => (\n <kbd key={j}>{key}</kbd>\n ))}\n </kbd>\n </React.Fragment>\n ))}\n </span>\n )\n}\n\nexport { KeyboardShortcut }\n"],"names":["globalTranslateKey","key","translateKeyMac","toLowerCase","KeyboardShortcut","children","className","translateKey","isMac","navigator","platform","_navigator$platform","toUpperCase","includes","props","shortcuts","React","classNames","reactist_keyboard_shortcut--macos","map","shortcut","i","t","_hasModifiers","test","replace","split","str","isSpecialKey","charAt","slice","capitalize","length","parseKeys","j","setTranslateKey","tr"],"mappings":"oTAOA,IAAIA,EAAsBC,GAAgBA,EAQ1C,SAASC,EAAgBD,GACrB,OAAQA,EAAIE,eACR,IAAK,MACL,IAAK,MACD,MAAO,IACX,IAAK,UACL,IAAK,OACD,MAAO,IACX,IAAK,MACD,MAAO,IACX,IAAK,QACD,MAAO,IACX,IAAK,QACD,MAAO,IACX,QACI,OAAOF,GAsFnB,SAASG,iBAAiBC,SACtBA,EADsBC,UAEtBA,EAFsBC,aAGtBA,EAAeP,EAHOQ,MAItBA,oBAAQC,UAAUC,iBAAVC,EAAoBC,cAAcC,SAAS,cAChDC,iCAEH,MAAMC,EAAgC,iBAAbV,EAAwB,CAACA,GAAYA,EAC9D,OACIW,wCACIV,UAAWW,EAAW,6BAA8BX,EAAW,CAC3DY,oCAAqCV,KAErCM,GAEHC,EAAUI,IAAI,CAACC,EAAUC,IACtBL,gBAACA,YAAef,IAAKoB,GACV,IAANA,EAAU,KAAO,KAClBL,2BApFpB,SAAmBI,EAAkBZ,EAAgBD,GACjD,MAAMe,EAAId,EAAQN,EAAkBK,EAC9BgB,EATC,wCAAwCC,KASZJ,GAgBnC,OAJKZ,IACDY,EAAWA,EAASK,QAAQ,iBAAkB,SAG3CL,EAASM,MAAM,YAAYP,KAdlC,SAA0BQ,GACtB,OATR,SAAsBA,GAClB,MAAO,kDAAkDH,KAAKG,GAQtDC,CAAaD,GAjBzB,SAAoBA,GAChB,OAAOA,EAAIE,OAAO,GAAGjB,cAAgBe,EAAIG,MAAM,GAAG3B,cAiBnC4B,CAAWT,EAAEK,IAEpBJ,GAAgC,IAAfI,EAAIK,OACdL,EAAIf,cAERe,KA0EUM,CAAUb,EAAUZ,EAAOD,GAAcY,IAAI,CAAClB,EAAKiC,IAChDlB,uBAAKf,IAAKiC,GAAIjC,QA7H1CG,EAAiB+B,gBAAmBC,IAChCpC,EAAqBoC"}
1
+ {"version":3,"file":"keyboard-shortcut.js","sources":["../../../src/components/keyboard-shortcut/keyboard-shortcut.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\n//\n// Support for setting up how to translate modifiers globally.\n//\n\nlet globalTranslateKey = (key: string) => key\n\ntype TranslateKey = typeof globalTranslateKey\n\nKeyboardShortcut.setTranslateKey = (tr: TranslateKey) => {\n globalTranslateKey = tr\n}\n\nfunction translateKeyMac(key: string) {\n switch (key.toLowerCase()) {\n case 'cmd':\n case 'mod':\n return '⌘'\n case 'control':\n case 'ctrl':\n return '⌃'\n case 'alt':\n return '⌥'\n case 'shift':\n return '⇧'\n case 'space':\n return '␣'\n default:\n return key\n }\n}\n\n//\n// Some helpers\n//\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()\n}\n\nfunction hasModifiers(str: string) {\n return /\\b(mod|cmd|ctrl|control|alt|shift)\\b/i.test(str)\n}\n\nfunction isSpecialKey(str: string) {\n return /^(mod|cmd|ctrl|control|alt|shift|space|super)$/i.test(str)\n}\n\nfunction parseKeys(shortcut: string, isMac: boolean, translateKey: TranslateKey) {\n const t = isMac ? translateKeyMac : translateKey\n const _hasModifiers = hasModifiers(shortcut)\n\n function mapIndividualKey(str: string) {\n if (isSpecialKey(str)) {\n return capitalize(t(str))\n }\n if (_hasModifiers && str.length === 1) {\n return str.toUpperCase()\n }\n return str\n }\n\n if (!isMac) {\n shortcut = shortcut.replace(/\\b(mod|cmd)\\b/i, 'ctrl')\n }\n\n return shortcut.split(/\\s*\\+\\s*/).map(mapIndividualKey)\n}\n\n//\n// The KeyboardShortcut component\n//\n\ntype NativeSpanProps = React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLSpanElement>,\n HTMLSpanElement\n>\n\ntype Props = Omit<NativeSpanProps, 'children'> & {\n /**\n * The shortcut to be represented as markup. It supports an intuitive syntax where you can\n * combine modifiers (cmd, ctrl, shift, alt) with single keys all concatenated with plus signs.\n * You can also pass various shortcuts as an array, which will be depicted separated by commas.\n */\n children: string | string[]\n /**\n * A function that allows you to change how some key names are represented. This may be useful,\n * for instance, to translate modifier names that are expressed differently in other languages\n * (e.g. `Ctrl` is named `Strg` in German).\n *\n * It defaults to a global version that leaves the key as is. You can pass your version as a\n * prop, or you can also set your own version of this global default one, so you don't need to\n * pass your own on each invocation of this component.\n *\n * ```js\n * import { KeyboardShortcut } from '@doist/reactist'\n * KeyboardShortcut.setTranslateKey = key => { ... }\n * ```\n *\n * Note: When the component detects the macOS operating system it bypasses key translation for\n * most modifiers and uses macOS-specific symbols. See the `isMac` prop for details.\n */\n translateKey?: TranslateKey\n /**\n * This prop is not meant to be passed. The component will automatically initialize it to `true`\n * if it detects that the current browser / operating system is on macOS, in which case modifier\n * keys are represented using macOS' notation (e.g. ⌘ ⌃ ⌥ ⇧).\n *\n * Though it is discouraged, if you don't want this special treatment in macOS, you can pass\n * `isMac={false}` in all invocations of this component.\n */\n isMac?: boolean\n}\n\nfunction KeyboardShortcut({\n children,\n className,\n translateKey = globalTranslateKey,\n isMac = navigator.platform?.toUpperCase().includes('MAC') ?? false,\n ...props\n}: Props) {\n const shortcuts = typeof children === 'string' ? [children] : children\n return (\n <span\n className={classNames('reactist_keyboard_shortcut', className, {\n 'reactist_keyboard_shortcut--macos': isMac,\n })}\n {...props}\n >\n {shortcuts.map((shortcut, i) => (\n <React.Fragment key={i}>\n {i === 0 ? null : ', '}\n <kbd>\n {parseKeys(shortcut, isMac, translateKey).map((key, j) => (\n <kbd key={j}>{key}</kbd>\n ))}\n </kbd>\n </React.Fragment>\n ))}\n </span>\n )\n}\n\nexport { KeyboardShortcut }\n"],"names":["globalTranslateKey","key","translateKeyMac","toLowerCase","KeyboardShortcut","_ref","_navigator$platform$t","_navigator$platform","children","className","translateKey","isMac","navigator","platform","toUpperCase","includes","props","_objectWithoutProperties","objectWithoutProperties","_excluded","shortcuts","React","_objectSpread","classNames","reactist_keyboard_shortcut--macos","map","shortcut","i","createElement","Fragment","t","_hasModifiers","test","replace","split","str","isSpecialKey","charAt","slice","capitalize","length","parseKeys","j","setTranslateKey","tr"],"mappings":"8kBAOA,IAAIA,EAAsBC,GAAgBA,EAQ1C,SAASC,EAAgBD,GACrB,OAAQA,EAAIE,eACR,IAAK,MACL,IAAK,MACD,MAAO,IACX,IAAK,UACL,IAAK,OACD,MAAO,IACX,IAAK,MACD,MAAO,IACX,IAAK,QACD,MAAO,IACX,IAAK,QACD,MAAO,IACX,QACI,OAAOF,GAsFnB,SAASG,EAMDC,GAAA,IAAAC,EAAAC,EAAA,IANkBC,SACtBA,EADsBC,UAEtBA,EAFsBC,aAGtBA,EAAeV,EAHOW,MAItBA,EAA6D,OAArDC,EAAA,OAAAA,EAAAA,UAAUC,eAAV,EAAAN,EAAoBO,cAAcC,SAAS,SAAUT,GAEzDD,EADDW,EACCC,EAAAC,wBAAAb,EAAAc,GACJ,MAAMC,EAAgC,iBAAbZ,EAAwB,CAACA,GAAYA,EAC9D,OACIa,uBAAAC,gBAAA,CACIb,UAAWc,EAAAA,QAAW,6BAA8Bd,EAAW,CAC3De,oCAAqCb,KAErCK,GAEHI,EAAUK,IAAI,CAACC,EAAUC,IACtBN,EAACO,cAAAP,EAAMQ,SAAQ,CAAC5B,IAAK0B,GACV,IAANA,EAAU,KAAO,KAClBN,EAAAO,cAAA,MAAA,KApFpB,SAAmBF,EAAkBf,EAAgBD,GACjD,MAAMoB,EAAInB,EAAQT,EAAkBQ,EAC9BqB,EATC,wCAAwCC,KASZN,GAgBnC,OAJKf,IACDe,EAAWA,EAASO,QAAQ,iBAAkB,SAG3CP,EAASQ,MAAM,YAAYT,KAdlC,SAA0BU,GACtB,OATR,SAAsBA,GAClB,MAAO,kDAAkDH,KAAKG,GAQtDC,CAAaD,GAjBzB,SAAoBA,GAChB,OAAOA,EAAIE,OAAO,GAAGvB,cAAgBqB,EAAIG,MAAM,GAAGnC,cAiBnCoC,CAAWT,EAAEK,IAEpBJ,GAAgC,IAAfI,EAAIK,OACdL,EAAIrB,cAERqB,KA0EUM,CAAUf,EAAUf,EAAOD,GAAce,IAAI,CAACxB,EAAKyC,IAChDrB,EAAKO,cAAA,MAAA,CAAA3B,IAAKyC,GAAIzC,QA7H1CG,EAAiBuC,gBAAmBC,IAChC5C,EAAqB4C"}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import './progress-bar.less';
3
- declare type Props = {
3
+ type Props = {
4
4
  /** Additional css class applied to the progress bar. */
5
5
  className?: string;
6
6
  /** How much of the progress bar should be filled. Number between 0 and 100 inclusive. */
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),a=(e(r),e(require("classnames"))),t=require("../../hidden-visually/hidden-visually.js");function s({fillPercentage:e=0,className:s,"aria-valuetext":l}){const i=a("reactist_progress_bar",s),n=e<0?0:e>100?100:e;return r.createElement("div",{className:i},r.createElement("div",{className:"inner",style:{width:n+"%"}}),r.createElement(t.HiddenVisually,null,r.createElement("progress",{value:n,max:100,"aria-valuetext":null!=l?l:void 0})))}s.displayName="ProgressBar",exports.ProgressBar=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../../hidden-visually/hidden-visually.js"),t=require("classnames");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,r}var n=l(e),s=a(t);function u({fillPercentage:e=0,className:t,"aria-valuetext":a}){const l=s.default("reactist_progress_bar",t),u=e<0?0:e>100?100:e;return n.createElement("div",{className:l},n.createElement("div",{className:"inner",style:{width:u+"%"}}),n.createElement(r.HiddenVisually,null,n.createElement("progress",{value:u,max:100,"aria-valuetext":null!=a?a:void 0})))}u.displayName="ProgressBar",exports.ProgressBar=u;
2
2
  //# sourceMappingURL=progress-bar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress-bar.js","sources":["../../../src/components/progress-bar/progress-bar.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HiddenVisually } from '../../hidden-visually'\nimport classNames from 'classnames'\n\nimport './progress-bar.less'\n\ntype Props = {\n /** Additional css class applied to the progress bar. */\n className?: string\n /** How much of the progress bar should be filled. Number between 0 and 100 inclusive. */\n fillPercentage?: number\n /** Defines the human readable text alternative for assitive technologies. */\n 'aria-valuetext'?: string\n}\nfunction ProgressBar({ fillPercentage = 0, className, 'aria-valuetext': ariaValuetext }: Props) {\n const finalClassName = classNames('reactist_progress_bar', className)\n const width = fillPercentage < 0 ? 0 : fillPercentage > 100 ? 100 : fillPercentage\n return (\n <div className={finalClassName}>\n <div className=\"inner\" style={{ width: `${width}%` }} />\n <HiddenVisually>\n <progress value={width} max={100} aria-valuetext={ariaValuetext ?? undefined} />\n </HiddenVisually>\n </div>\n )\n}\nProgressBar.displayName = 'ProgressBar'\n\nexport { ProgressBar }\n"],"names":["ProgressBar","fillPercentage","className","aria-valuetext","ariaValuetext","finalClassName","classNames","width","React","style","HiddenVisually","value","max","undefined","displayName"],"mappings":"yPAcA,SAASA,GAAYC,eAAEA,EAAiB,EAAnBC,UAAsBA,EAAWC,iBAAkBC,IACpE,MAAMC,EAAiBC,EAAW,wBAAyBJ,GACrDK,EAAQN,EAAiB,EAAI,EAAIA,EAAiB,IAAM,IAAMA,EACpE,OACIO,uBAAKN,UAAWG,GACZG,uBAAKN,UAAU,QAAQO,MAAO,CAAEF,MAAUA,SAC1CC,gBAACE,sBACGF,4BAAUG,MAAOJ,EAAOK,IAAK,2BAAqBR,EAAAA,OAAiBS,MAKnFb,EAAYc,YAAc"}
1
+ {"version":3,"file":"progress-bar.js","sources":["../../../src/components/progress-bar/progress-bar.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HiddenVisually } from '../../hidden-visually'\nimport classNames from 'classnames'\n\nimport './progress-bar.less'\n\ntype Props = {\n /** Additional css class applied to the progress bar. */\n className?: string\n /** How much of the progress bar should be filled. Number between 0 and 100 inclusive. */\n fillPercentage?: number\n /** Defines the human readable text alternative for assitive technologies. */\n 'aria-valuetext'?: string\n}\nfunction ProgressBar({ fillPercentage = 0, className, 'aria-valuetext': ariaValuetext }: Props) {\n const finalClassName = classNames('reactist_progress_bar', className)\n const width = fillPercentage < 0 ? 0 : fillPercentage > 100 ? 100 : fillPercentage\n return (\n <div className={finalClassName}>\n <div className=\"inner\" style={{ width: `${width}%` }} />\n <HiddenVisually>\n <progress value={width} max={100} aria-valuetext={ariaValuetext ?? undefined} />\n </HiddenVisually>\n </div>\n )\n}\nProgressBar.displayName = 'ProgressBar'\n\nexport { ProgressBar }\n"],"names":["ProgressBar","fillPercentage","className","aria-valuetext","ariaValuetext","finalClassName","classNames","width","React","createElement","style","HiddenVisually","value","max","undefined","displayName"],"mappings":"mhBAcA,SAASA,GAAYC,eAAEA,EAAiB,EAAnBC,UAAsBA,EAAWC,iBAAkBC,IACpE,MAAMC,EAAiBC,EAAAA,QAAW,wBAAyBJ,GACrDK,EAAQN,EAAiB,EAAI,EAAIA,EAAiB,IAAM,IAAMA,EACpE,OACIO,EAAAC,cAAA,MAAA,CAAKP,UAAWG,GACZG,EAAAC,cAAA,MAAA,CAAKP,UAAU,QAAQQ,MAAO,CAAEH,MAAUA,EAAL,OACrCC,EAAAC,cAACE,EAAAA,eAAc,KACXH,EAAAC,cAAA,WAAA,CAAUG,MAAOL,EAAOM,IAAK,IAAqBV,iBAAAC,MAAAA,EAAAA,OAAiBU,MAKnFd,EAAYe,YAAc"}
@@ -1,4 +1,4 @@
1
- declare type TimeConfig = {
1
+ type TimeConfig = {
2
2
  locale?: string;
3
3
  longFormat?: string;
4
4
  shortFormatCurrentYear?: string;
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("dayjs")),r=e(require("dayjs/plugin/localizedFormat"));t.extend(r),exports.TimeUtils={SHORT_FORMAT_CURRENT_YEAR:"L",SHORT_FORMAT_PAST_YEAR:"LL",LONG_FORMAT:"LL, LT",timeAgo(e,r={}){const{locale:o="en",shortFormatCurrentYear:a=this.SHORT_FORMAT_CURRENT_YEAR,shortFormatPastYear:s=this.SHORT_FORMAT_PAST_YEAR,daysSuffix:i="d",hoursSuffix:m="h",minutesSuffix:R="m",momentsAgo:n="moments ago"}=r,f=t(),T=t(1e3*e);T.locale(o);const u=f.diff(T,"minute"),_=f.diff(T,"hour"),l=f.diff(T,"day");return l>1?T.isSame(f,"year")?T.format(a):T.format(s):1===l?""+l+i:_>0&&_<=23?""+_+m:u>0&&u<=59?""+u+R:n},formatTime(e,r={}){const{locale:o="en",shortFormatCurrentYear:a=this.SHORT_FORMAT_CURRENT_YEAR,shortFormatPastYear:s=this.SHORT_FORMAT_PAST_YEAR}=r,i=t(1e3*e);return i.locale(o),i.isSame(t(),"year")?i.format(a):i.format(s)},formatTimeLong(e,r={}){const{locale:o="en",longFormat:a=this.LONG_FORMAT}=r,s=t(1e3*e);return s.locale(o),s.format(a)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("dayjs"),t=require("dayjs/plugin/localizedFormat");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(e);a.default.extend(r(t).default),exports.TimeUtils={SHORT_FORMAT_CURRENT_YEAR:"L",SHORT_FORMAT_PAST_YEAR:"LL",LONG_FORMAT:"LL, LT",timeAgo(e,t={}){const{locale:r="en",shortFormatCurrentYear:o=this.SHORT_FORMAT_CURRENT_YEAR,shortFormatPastYear:f=this.SHORT_FORMAT_PAST_YEAR,daysSuffix:s="d",hoursSuffix:u="h",minutesSuffix:i="m",momentsAgo:l="moments ago"}=t,m=a.default(),R=a.default(1e3*e);R.locale(r);const n=m.diff(R,"minute"),T=m.diff(R,"hour"),_=m.diff(R,"day");return _>1?R.isSame(m,"year")?R.format(o):R.format(f):1===_?""+_+s:T>0&&T<=23?""+T+u:n>0&&n<=59?""+n+i:l},formatTime(e,t={}){const{locale:r="en",shortFormatCurrentYear:o=this.SHORT_FORMAT_CURRENT_YEAR,shortFormatPastYear:f=this.SHORT_FORMAT_PAST_YEAR}=t,s=a.default(1e3*e);return s.locale(r),s.isSame(a.default(),"year")?s.format(o):s.format(f)},formatTimeLong(e,t={}){const{locale:r="en",longFormat:o=this.LONG_FORMAT}=t,f=a.default(1e3*e);return f.locale(r),f.format(o)}};
2
2
  //# sourceMappingURL=time-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","this","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":"iNAcAA,EAAMC,OAAOC,qBAaK,CACdC,0BAA2B,IAC3BC,uBAAwB,KACxBC,YAAa,SAEbC,QAAQC,EAAmBC,EAAqB,IAC5C,MAAMC,OACFA,EAAS,KADPC,uBAEFA,EAAyBC,KAAKR,0BAF5BS,oBAGFA,EAAsBD,KAAKP,uBAHzBS,WAIFA,EAAa,IAJXC,YAKFA,EAAc,IALZC,cAMFA,EAAgB,IANdC,WAOFA,EAAa,eACbR,EACES,EAAMjB,IACNkB,EAAOlB,EAAkB,IAAZO,GACnBW,EAAKT,OAAOA,GACZ,MAAMU,EAAcF,EAAIG,KAAKF,EAAM,UAC7BG,EAAYJ,EAAIG,KAAKF,EAAM,QAC3BI,EAAWL,EAAIG,KAAKF,EAAM,OAEhC,OAAII,EAAW,EACPJ,EAAKK,OAAON,EAAK,QACVC,EAAKM,OAAOd,GAEZQ,EAAKM,OAAOZ,GAEH,IAAbU,KACGA,EAAWT,EACdQ,EAAY,GAAKA,GAAa,MAC3BA,EAAYP,EACfK,EAAc,GAAKA,GAAe,MAC/BA,EAAcJ,EAEjBC,GAIfS,WAAWlB,EAAmBC,EAAqB,IAC/C,MAAMC,OACFA,EAAS,KADPC,uBAEFA,EAAyBC,KAAKR,0BAF5BS,oBAGFA,EAAsBD,KAAKP,wBAC3BI,EACEU,EAAOlB,EAAkB,IAAZO,GAEnB,OADAW,EAAKT,OAAOA,GACRS,EAAKK,OAAOvB,IAAS,QACdkB,EAAKM,OAAOd,GAEZQ,EAAKM,OAAOZ,IAI3Bc,eAAenB,EAAmBC,EAAqB,IACnD,MAAMC,OAAEA,EAAS,KAAXkB,WAAiBA,EAAahB,KAAKN,aAAgBG,EACnDU,EAAOlB,EAAkB,IAAZO,GAEnB,OADAW,EAAKT,OAAOA,GACLS,EAAKM,OAAOG"}
1
+ {"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","this","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":"wNAcAA,EAAAA,QAAMC,YAAOC,2BAaK,CACdC,0BAA2B,IAC3BC,uBAAwB,KACxBC,YAAa,SAEbC,QAAQC,EAAmBC,EAAqB,IAC5C,MAAMC,OACFA,EAAS,KADPC,uBAEFA,EAAyBC,KAAKR,0BAF5BS,oBAGFA,EAAsBD,KAAKP,uBAHzBS,WAIFA,EAAa,IAJXC,YAKFA,EAAc,IALZC,cAMFA,EAAgB,IANdC,WAOFA,EAAa,eACbR,EACES,EAAMjB,EAAAA,UACNkB,EAAOlB,EAAAA,QAAkB,IAAZO,GACnBW,EAAKT,OAAOA,GACZ,MAAMU,EAAcF,EAAIG,KAAKF,EAAM,UAC7BG,EAAYJ,EAAIG,KAAKF,EAAM,QAC3BI,EAAWL,EAAIG,KAAKF,EAAM,OAEhC,OAAII,EAAW,EACPJ,EAAKK,OAAON,EAAK,QACVC,EAAKM,OAAOd,GAEZQ,EAAKM,OAAOZ,GAEH,IAAbU,EACGA,GAAAA,EAAWT,EACdQ,EAAY,GAAKA,GAAa,GAC3BA,GAAAA,EAAYP,EACfK,EAAc,GAAKA,GAAe,GAC/BA,GAAAA,EAAcJ,EAEjBC,GAIfS,WAAWlB,EAAmBC,EAAqB,IAC/C,MAAMC,OACFA,EAAS,KADPC,uBAEFA,EAAyBC,KAAKR,0BAF5BS,oBAGFA,EAAsBD,KAAKP,wBAC3BI,EACEU,EAAOlB,EAAAA,QAAkB,IAAZO,GAEnB,OADAW,EAAKT,OAAOA,GACRS,EAAKK,OAAOvB,YAAS,QACdkB,EAAKM,OAAOd,GAEZQ,EAAKM,OAAOZ,IAI3Bc,eAAenB,EAAmBC,EAAqB,IACnD,MAAMC,OAAEA,EAAS,KAAXkB,WAAiBA,EAAahB,KAAKN,aAAgBG,EACnDU,EAAOlB,EAAAA,QAAkB,IAAZO,GAEnB,OADAW,EAAKT,OAAOA,GACLS,EAAKM,OAAOG"}
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { TimeConfig } from './time-utils';
3
3
  import './time.less';
4
- declare type Props = {
4
+ type Props = {
5
5
  /** UNIX timestamp of the time to display. */
6
6
  time?: number;
7
7
  /** Configuration for localization. */
@@ -18,7 +18,7 @@ declare type Props = {
18
18
  /** When hovering over time it expands to the full absolute version. */
19
19
  expandFullyOnHover?: boolean;
20
20
  };
21
- declare type State = {
21
+ type State = {
22
22
  hovered: boolean;
23
23
  mouseX?: number;
24
24
  mouseY?: number;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../tooltip/tooltip.js"),s=require("./time-utils.js");class r extends e.Component{constructor(e){super(e),this.refreshInterval=void 0,this.refreshInterval=void 0,this.state={hovered:!1,mouseX:void 0,mouseY:void 0}}componentDidMount(){this.props.refresh&&this._refresh()}componentDidUpdate(e){!e.refresh&&this.props.refresh&&this._refresh(),e.refresh&&!this.props.refresh&&this.refreshInterval&&clearTimeout(this.refreshInterval)}componentWillUnmount(){this.refreshInterval&&clearTimeout(this.refreshInterval)}_setHovered(e,t){const{mouseX:s,mouseY:r}=this.state,{clientX:o,clientY:i}=t;o===s&&i===r||this.setState(()=>({hovered:e,mouseX:o,mouseY:i}))}_renderTime(e){if(this.props.time){if(this.state.hovered){if(this.props.expandFullyOnHover&&!this.props.tooltipOnHover)return s.TimeUtils.formatTimeLong(this.props.time,e);if(this.props.expandOnHover&&!this.props.tooltipOnHover)return s.TimeUtils.formatTime(this.props.time,e)}return s.TimeUtils.timeAgo(this.props.time,e)}}_refresh(){this.refreshInterval=setInterval(()=>{this.forceUpdate()},6e4)}render(){let r="reactist_time";this.props.className&&(r=this.props.className);const o=this._renderTime(this.props.config);return e.createElement("time",{className:r,onMouseEnter:e=>this._setHovered(!0,e),onMouseLeave:e=>this._setHovered(!1,e)},this.props.tooltipOnHover?e.createElement(t.Tooltip,{content:this.props.tooltip||this.props.time&&s.TimeUtils.formatTimeLong(this.props.time,this.props.config)},e.createElement("span",null,o)):o)}}r.displayName=void 0,r.defaultProps=void 0,r.displayName="Time",r.defaultProps={expandOnHover:!1,expandFullyOnHover:!1,tooltipOnHover:!1,refresh:!0,config:{locale:"en",daysSuffix:"d",hoursSuffix:"h",minutesSuffix:"m",momentsAgo:"moments ago"}},exports.Time=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../tooltip/tooltip.js"),r=require("./time-utils.js");function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,t}var o=s(e);class i extends o.Component{constructor(e){super(e),this.refreshInterval=void 0,this.refreshInterval=void 0,this.state={hovered:!1,mouseX:void 0,mouseY:void 0}}componentDidMount(){this.props.refresh&&this._refresh()}componentDidUpdate(e){!e.refresh&&this.props.refresh&&this._refresh(),e.refresh&&!this.props.refresh&&this.refreshInterval&&clearTimeout(this.refreshInterval)}componentWillUnmount(){this.refreshInterval&&clearTimeout(this.refreshInterval)}_setHovered(e,t){const{mouseX:r,mouseY:s}=this.state,{clientX:o,clientY:i}=t;o===r&&i===s||this.setState(()=>({hovered:e,mouseX:o,mouseY:i}))}_renderTime(e){if(this.props.time){if(this.state.hovered){if(this.props.expandFullyOnHover&&!this.props.tooltipOnHover)return r.TimeUtils.formatTimeLong(this.props.time,e);if(this.props.expandOnHover&&!this.props.tooltipOnHover)return r.TimeUtils.formatTime(this.props.time,e)}return r.TimeUtils.timeAgo(this.props.time,e)}}_refresh(){this.refreshInterval=setInterval(()=>{this.forceUpdate()},6e4)}render(){let e="reactist_time";this.props.className&&(e=this.props.className);const s=this._renderTime(this.props.config);return o.createElement("time",{className:e,onMouseEnter:e=>this._setHovered(!0,e),onMouseLeave:e=>this._setHovered(!1,e)},this.props.tooltipOnHover?o.createElement(t.Tooltip,{content:this.props.tooltip||this.props.time&&r.TimeUtils.formatTimeLong(this.props.time,this.props.config)},o.createElement("span",null,s)):s)}}i.displayName=void 0,i.defaultProps=void 0,i.displayName="Time",i.defaultProps={expandOnHover:!1,expandFullyOnHover:!1,tooltipOnHover:!1,refresh:!0,config:{locale:"en",daysSuffix:"d",hoursSuffix:"h",minutesSuffix:"m",momentsAgo:"moments ago"}},exports.Time=i;
2
2
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","sources":["../../../src/components/time/time.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Tooltip } from '../../tooltip'\nimport { TimeUtils, TimeConfig } from './time-utils'\n\nimport './time.less'\n\nconst DELAY = 60000\n\ntype Props = {\n /** UNIX timestamp of the time to display. */\n time?: number\n /** Configuration for localization. */\n config?: TimeConfig\n /** Additional css class applied to the time element. */\n className?: string\n tooltipOnHover?: boolean\n /** Refresh the component every DELAY seconds. */\n refresh?: boolean\n /** If you don't want to use the default time format on the tooltip use this prop to supply a custom text */\n tooltip?: React.ReactNode\n /** When hovering over time it expands to short absolute version. */\n expandOnHover?: boolean\n /** When hovering over time it expands to the full absolute version. */\n expandFullyOnHover?: boolean\n}\n\ntype State = {\n hovered: boolean\n mouseX?: number\n mouseY?: number\n}\n\nclass Time extends React.Component<Props, State> {\n public static displayName: string\n public static defaultProps: Props\n\n constructor(props: Props) {\n super(props)\n this.refreshInterval = undefined\n\n this.state = {\n hovered: false,\n mouseX: undefined,\n mouseY: undefined,\n }\n }\n\n componentDidMount() {\n if (this.props.refresh) {\n this._refresh()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!prevProps.refresh && this.props.refresh) {\n this._refresh()\n }\n\n if (prevProps.refresh && !this.props.refresh) {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n }\n\n componentWillUnmount() {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n\n refreshInterval?: ReturnType<typeof setTimeout>\n\n _setHovered(hovered: boolean, event: React.MouseEvent) {\n const { mouseX, mouseY } = this.state\n const { clientX, clientY } = event\n if (clientX !== mouseX || clientY !== mouseY) {\n // mouse has moved\n this.setState(() => ({\n hovered,\n mouseX: clientX,\n mouseY: clientY,\n }))\n }\n }\n\n _renderTime(config: Props['config']) {\n if (!this.props.time) {\n return\n }\n if (this.state.hovered) {\n if (this.props.expandFullyOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTimeLong(this.props.time, config)\n }\n if (this.props.expandOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTime(this.props.time, config)\n }\n }\n return TimeUtils.timeAgo(this.props.time, config)\n }\n\n _refresh() {\n this.refreshInterval = setInterval(() => {\n this.forceUpdate()\n }, DELAY)\n }\n\n render() {\n let className = 'reactist_time'\n if (this.props.className) {\n className = this.props.className\n }\n\n const timeComponent = this._renderTime(this.props.config)\n\n return (\n <time\n className={className}\n onMouseEnter={(event) => this._setHovered(true, event)}\n onMouseLeave={(event) => this._setHovered(false, event)}\n >\n {this.props.tooltipOnHover ? (\n <Tooltip\n content={\n this.props.tooltip ||\n (this.props.time &&\n TimeUtils.formatTimeLong(this.props.time, this.props.config))\n }\n >\n <span>{timeComponent}</span>\n </Tooltip>\n ) : (\n timeComponent\n )}\n </time>\n )\n }\n}\nTime.displayName = 'Time'\n\nTime.defaultProps = {\n expandOnHover: false,\n expandFullyOnHover: false,\n tooltipOnHover: false,\n refresh: true,\n config: {\n locale: 'en',\n daysSuffix: 'd',\n hoursSuffix: 'h',\n minutesSuffix: 'm',\n momentsAgo: 'moments ago',\n },\n}\n\nexport { Time }\n"],"names":["Time","React","constructor","props","super","refreshInterval","this","undefined","state","hovered","mouseX","mouseY","componentDidMount","refresh","_refresh","componentDidUpdate","prevProps","clearTimeout","componentWillUnmount","_setHovered","event","clientX","clientY","setState","_renderTime","config","time","expandFullyOnHover","tooltipOnHover","TimeUtils","formatTimeLong","expandOnHover","formatTime","timeAgo","setInterval","forceUpdate","render","className","timeComponent","onMouseEnter","onMouseLeave","Tooltip","content","tooltip","displayName","defaultProps","locale","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo"],"mappings":"8JAiCA,MAAMA,UAAaC,YAIfC,YAAYC,GACRC,MAAMD,QAkCVE,uBAjCIC,KAAKD,qBAAkBE,EAEvBD,KAAKE,MAAQ,CACTC,SAAS,EACTC,YAAQH,EACRI,YAAQJ,GAIhBK,oBACQN,KAAKH,MAAMU,SACXP,KAAKQ,WAIbC,mBAAmBC,IACVA,EAAUH,SAAWP,KAAKH,MAAMU,SACjCP,KAAKQ,WAGLE,EAAUH,UAAYP,KAAKH,MAAMU,SAC7BP,KAAKD,iBACLY,aAAaX,KAAKD,iBAK9Ba,uBACQZ,KAAKD,iBACLY,aAAaX,KAAKD,iBAM1Bc,YAAYV,EAAkBW,GAC1B,MAAMV,OAAEA,EAAFC,OAAUA,GAAWL,KAAKE,OAC1Ba,QAAEA,EAAFC,QAAWA,GAAYF,EACzBC,IAAYX,GAAUY,IAAYX,GAElCL,KAAKiB,SAAS,MACVd,QAAAA,EACAC,OAAQW,EACRV,OAAQW,KAKpBE,YAAYC,GACR,GAAKnB,KAAKH,MAAMuB,KAAhB,CAGA,GAAIpB,KAAKE,MAAMC,QAAS,CACpB,GAAIH,KAAKH,MAAMwB,qBAAuBrB,KAAKH,MAAMyB,eAC7C,OAAOC,YAAUC,eAAexB,KAAKH,MAAMuB,KAAMD,GAErD,GAAInB,KAAKH,MAAM4B,gBAAkBzB,KAAKH,MAAMyB,eACxC,OAAOC,YAAUG,WAAW1B,KAAKH,MAAMuB,KAAMD,GAGrD,OAAOI,YAAUI,QAAQ3B,KAAKH,MAAMuB,KAAMD,IAG9CX,WACIR,KAAKD,gBAAkB6B,YAAY,KAC/B5B,KAAK6B,eAjGH,KAqGVC,SACI,IAAIC,EAAY,gBACZ/B,KAAKH,MAAMkC,YACXA,EAAY/B,KAAKH,MAAMkC,WAG3B,MAAMC,EAAgBhC,KAAKkB,YAAYlB,KAAKH,MAAMsB,QAElD,OACIxB,wBACIoC,UAAWA,EACXE,aAAenB,GAAUd,KAAKa,aAAY,EAAMC,GAChDoB,aAAepB,GAAUd,KAAKa,aAAY,EAAOC,IAEhDd,KAAKH,MAAMyB,eACR3B,gBAACwC,WACGC,QACIpC,KAAKH,MAAMwC,SACVrC,KAAKH,MAAMuB,MACRG,YAAUC,eAAexB,KAAKH,MAAMuB,KAAMpB,KAAKH,MAAMsB,SAG7DxB,4BAAOqC,IAGXA,IApGdtC,EACY4C,mBADZ5C,EAEY6C,oBAwGlB7C,EAAK4C,YAAc,OAEnB5C,EAAK6C,aAAe,CAChBd,eAAe,EACfJ,oBAAoB,EACpBC,gBAAgB,EAChBf,SAAS,EACTY,OAAQ,CACJqB,OAAQ,KACRC,WAAY,IACZC,YAAa,IACbC,cAAe,IACfC,WAAY"}
1
+ {"version":3,"file":"time.js","sources":["../../../src/components/time/time.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Tooltip } from '../../tooltip'\nimport { TimeUtils, TimeConfig } from './time-utils'\n\nimport './time.less'\n\nconst DELAY = 60000\n\ntype Props = {\n /** UNIX timestamp of the time to display. */\n time?: number\n /** Configuration for localization. */\n config?: TimeConfig\n /** Additional css class applied to the time element. */\n className?: string\n tooltipOnHover?: boolean\n /** Refresh the component every DELAY seconds. */\n refresh?: boolean\n /** If you don't want to use the default time format on the tooltip use this prop to supply a custom text */\n tooltip?: React.ReactNode\n /** When hovering over time it expands to short absolute version. */\n expandOnHover?: boolean\n /** When hovering over time it expands to the full absolute version. */\n expandFullyOnHover?: boolean\n}\n\ntype State = {\n hovered: boolean\n mouseX?: number\n mouseY?: number\n}\n\nclass Time extends React.Component<Props, State> {\n public static displayName: string\n public static defaultProps: Props\n\n constructor(props: Props) {\n super(props)\n this.refreshInterval = undefined\n\n this.state = {\n hovered: false,\n mouseX: undefined,\n mouseY: undefined,\n }\n }\n\n componentDidMount() {\n if (this.props.refresh) {\n this._refresh()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!prevProps.refresh && this.props.refresh) {\n this._refresh()\n }\n\n if (prevProps.refresh && !this.props.refresh) {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n }\n\n componentWillUnmount() {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n\n refreshInterval?: ReturnType<typeof setTimeout>\n\n _setHovered(hovered: boolean, event: React.MouseEvent) {\n const { mouseX, mouseY } = this.state\n const { clientX, clientY } = event\n if (clientX !== mouseX || clientY !== mouseY) {\n // mouse has moved\n this.setState(() => ({\n hovered,\n mouseX: clientX,\n mouseY: clientY,\n }))\n }\n }\n\n _renderTime(config: Props['config']) {\n if (!this.props.time) {\n return\n }\n if (this.state.hovered) {\n if (this.props.expandFullyOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTimeLong(this.props.time, config)\n }\n if (this.props.expandOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTime(this.props.time, config)\n }\n }\n return TimeUtils.timeAgo(this.props.time, config)\n }\n\n _refresh() {\n this.refreshInterval = setInterval(() => {\n this.forceUpdate()\n }, DELAY)\n }\n\n render() {\n let className = 'reactist_time'\n if (this.props.className) {\n className = this.props.className\n }\n\n const timeComponent = this._renderTime(this.props.config)\n\n return (\n <time\n className={className}\n onMouseEnter={(event) => this._setHovered(true, event)}\n onMouseLeave={(event) => this._setHovered(false, event)}\n >\n {this.props.tooltipOnHover ? (\n <Tooltip\n content={\n this.props.tooltip ||\n (this.props.time &&\n TimeUtils.formatTimeLong(this.props.time, this.props.config))\n }\n >\n <span>{timeComponent}</span>\n </Tooltip>\n ) : (\n timeComponent\n )}\n </time>\n )\n }\n}\nTime.displayName = 'Time'\n\nTime.defaultProps = {\n expandOnHover: false,\n expandFullyOnHover: false,\n tooltipOnHover: false,\n refresh: true,\n config: {\n locale: 'en',\n daysSuffix: 'd',\n hoursSuffix: 'h',\n minutesSuffix: 'm',\n momentsAgo: 'moments ago',\n },\n}\n\nexport { Time }\n"],"names":["Time","React","Component","constructor","props","super","this","refreshInterval","undefined","state","hovered","mouseX","mouseY","componentDidMount","refresh","_refresh","componentDidUpdate","prevProps","clearTimeout","componentWillUnmount","_setHovered","event","clientX","clientY","setState","_renderTime","config","time","expandFullyOnHover","tooltipOnHover","TimeUtils","formatTimeLong","expandOnHover","formatTime","timeAgo","setInterval","forceUpdate","render","className","timeComponent","createElement","onMouseEnter","onMouseLeave","Tooltip","content","tooltip","displayName","defaultProps","locale","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo"],"mappings":"ybAiCA,MAAMA,UAAaC,EAAMC,UAIrBC,YAAYC,GACRC,MAAMD,GADcE,KAmCxBC,qBAnCwB,EAEpBD,KAAKC,qBAAkBC,EAEvBF,KAAKG,MAAQ,CACTC,SAAS,EACTC,YAAQH,EACRI,YAAQJ,GAIhBK,oBACQP,KAAKF,MAAMU,SACXR,KAAKS,WAIbC,mBAAmBC,IACVA,EAAUH,SAAWR,KAAKF,MAAMU,SACjCR,KAAKS,WAGLE,EAAUH,UAAYR,KAAKF,MAAMU,SAC7BR,KAAKC,iBACLW,aAAaZ,KAAKC,iBAK9BY,uBACQb,KAAKC,iBACLW,aAAaZ,KAAKC,iBAM1Ba,YAAYV,EAAkBW,GAC1B,MAAMV,OAAEA,EAAFC,OAAUA,GAAWN,KAAKG,OAC1Ba,QAAEA,EAAFC,QAAWA,GAAYF,EACzBC,IAAYX,GAAUY,IAAYX,GAElCN,KAAKkB,SAAS,KAAO,CACjBd,QAAAA,EACAC,OAAQW,EACRV,OAAQW,KAKpBE,YAAYC,GACR,GAAKpB,KAAKF,MAAMuB,KAAhB,CAGA,GAAIrB,KAAKG,MAAMC,QAAS,CACpB,GAAIJ,KAAKF,MAAMwB,qBAAuBtB,KAAKF,MAAMyB,eAC7C,OAAOC,EAAAA,UAAUC,eAAezB,KAAKF,MAAMuB,KAAMD,GAErD,GAAIpB,KAAKF,MAAM4B,gBAAkB1B,KAAKF,MAAMyB,eACxC,OAAOC,EAAAA,UAAUG,WAAW3B,KAAKF,MAAMuB,KAAMD,GAGrD,OAAOI,EAAAA,UAAUI,QAAQ5B,KAAKF,MAAMuB,KAAMD,IAG9CX,WACIT,KAAKC,gBAAkB4B,YAAY,KAC/B7B,KAAK8B,eAjGH,KAqGVC,SACI,IAAIC,EAAY,gBACZhC,KAAKF,MAAMkC,YACXA,EAAYhC,KAAKF,MAAMkC,WAG3B,MAAMC,EAAgBjC,KAAKmB,YAAYnB,KAAKF,MAAMsB,QAElD,OACIzB,EACIuC,cAAA,OAAA,CAAAF,UAAWA,EACXG,aAAepB,GAAUf,KAAKc,aAAY,EAAMC,GAChDqB,aAAerB,GAAUf,KAAKc,aAAY,EAAOC,IAEhDf,KAAKF,MAAMyB,eACR5B,EAAAuC,cAACG,EAAAA,QAAO,CACJC,QACItC,KAAKF,MAAMyC,SACVvC,KAAKF,MAAMuB,MACRG,EAASA,UAACC,eAAezB,KAAKF,MAAMuB,KAAMrB,KAAKF,MAAMsB,SAG7DzB,EAAAuC,cAAA,OAAA,KAAOD,IAGXA,IApGdvC,EACY8C,mBADZ9C,EAEY+C,oBAwGlB/C,EAAK8C,YAAc,OAEnB9C,EAAK+C,aAAe,CAChBf,eAAe,EACfJ,oBAAoB,EACpBC,gBAAgB,EAChBf,SAAS,EACTY,OAAQ,CACJsB,OAAQ,KACRC,WAAY,IACZC,YAAa,IACbC,cAAe,IACfC,WAAY"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../utils/responsive-props.js"),s=require("../box/box.js"),i=require("./divider.module.css.js");const o=["weight"];exports.Divider=function(u){let{weight:l="tertiary"}=u,a=e.objectWithoutProperties(u,o);return r.createElement(s.Box,e.objectSpread2({as:"hr",className:t.getClassNames(i.default,"weight",l)},a))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../utils/responsive-props.js"),i=require("../box/box.js"),u=require("./divider.module.css.js");function s(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,r}var o=s(r);const a=["weight"];exports.Divider=function(r){let{weight:s="tertiary"}=r,l=e.objectWithoutProperties(r,a);return o.createElement(i.Box,e.objectSpread2({as:"hr",className:t.getClassNames(u.default,"weight",s)},l))};
2
2
  //# sourceMappingURL=divider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"divider.js","sources":["../../src/divider/divider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport type { DividerWeight } from '../utils/common-types'\n\nimport styles from './divider.module.css'\n\ninterface DividerProps {\n weight?: Exclude<DividerWeight, 'none'>\n}\n\nfunction Divider({ weight = 'tertiary', ...props }: DividerProps) {\n return <Box as=\"hr\" className={getClassNames(styles, 'weight', weight)} {...props} />\n}\n\nexport type { DividerProps, DividerWeight }\nexport { Divider }\n"],"names":["weight","props","React","Box","as","className","getClassNames","styles"],"mappings":"8RAWA,gBAAiBA,OAAEA,EAAS,cAAeC,iCACvC,OAAOC,gBAACC,uBAAIC,GAAG,KAAKC,UAAWC,gBAAcC,UAAQ,SAAUP,IAAaC"}
1
+ {"version":3,"file":"divider.js","sources":["../../src/divider/divider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport type { DividerWeight } from '../utils/common-types'\n\nimport styles from './divider.module.css'\n\ninterface DividerProps {\n weight?: Exclude<DividerWeight, 'none'>\n}\n\nfunction Divider({ weight = 'tertiary', ...props }: DividerProps) {\n return <Box as=\"hr\" className={getClassNames(styles, 'weight', weight)} {...props} />\n}\n\nexport type { DividerProps, DividerWeight }\nexport { Divider }\n"],"names":["_ref","weight","props","_objectWithoutProperties","objectWithoutProperties","_excluded","React","createElement","Box","_objectSpread","as","className","getClassNames","styles"],"mappings":"yjBAWA,SAAgEA,GAAA,IAA/CC,OAAEA,EAAS,YAAoCD,EAArBE,EAAqBC,EAAAC,wBAAAJ,EAAAK,GAC5D,OAAOC,EAAAC,cAACC,EAADA,IAAAC,gBAAA,CAAKC,GAAG,KAAKC,UAAWC,EAAaA,cAACC,UAAQ,SAAUZ,IAAaC"}
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import type { ObfuscatedClassName, Tone } from '../utils/common-types';
3
3
  import type { BoxProps } from '../box';
4
- declare type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6';
5
- declare type HeadingProps = Omit<React.HTMLAttributes<HTMLHeadingElement>, 'className' | 'children'> & {
4
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6';
5
+ type HeadingProps = Omit<React.HTMLAttributes<HTMLHeadingElement>, 'className' | 'children'> & {
6
6
  children: React.ReactNode;
7
7
  /**
8
8
  * The semantic level of the heading.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),l=require("react"),t=require("../utils/responsive-props.js"),a=require("../box/box.js"),s=require("./heading.module.css.js");const r=["level","weight","size","tone","children","lineClamp","align","exceptionallySetClassName"];exports.Heading=l.forwardRef((function(i,n){let{level:o,weight:u="regular",size:p,tone:d="normal",children:g,lineClamp:c,align:m,exceptionallySetClassName:f}=i,h=e.objectWithoutProperties(i,r);const C="h"+o,x="string"==typeof c?parseInt(c,10)>1:(c||0)>1;return l.createElement(a.Box,e.objectSpread2(e.objectSpread2({},h),{},{className:[f,s.default.heading,"regular"!==u?t.getClassNames(s.default,"weight",u):null,"normal"!==d?t.getClassNames(s.default,"tone",d):null,t.getClassNames(s.default,"size",p),x?s.default.lineClampMultipleLines:null,c?t.getClassNames(s.default,"lineClamp",c.toString()):null],textAlign:m,paddingRight:c?"xsmall":void 0,as:C,ref:n}),g)}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),l=require("../utils/responsive-props.js"),r=require("../box/box.js"),a=require("./heading.module.css.js");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var r=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,r.get?r:{enumerable:!0,get:function(){return e[l]}})}})),t.default=e,t}var i=n(t);const s=["level","weight","size","tone","children","lineClamp","align","exceptionallySetClassName"];exports.Heading=i.forwardRef((function(t,n){let{level:u,weight:o="regular",size:c,tone:d="normal",children:p,lineClamp:g,align:f,exceptionallySetClassName:m}=t,b=e.objectWithoutProperties(t,s);const j="h"+u,h="string"==typeof g?parseInt(g,10)>1:(g||0)>1;return i.createElement(r.Box,e.objectSpread2(e.objectSpread2({},b),{},{className:[m,a.default.heading,"regular"!==o?l.getClassNames(a.default,"weight",o):null,"normal"!==d?l.getClassNames(a.default,"tone",d):null,l.getClassNames(a.default,"size",c),h?a.default.lineClampMultipleLines:null,g?l.getClassNames(a.default,"lineClamp",g.toString()):null],textAlign:f,paddingRight:g?"xsmall":void 0,as:j,ref:n}),p)}));
2
2
  //# sourceMappingURL=heading.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"heading.js","sources":["../../src/heading/heading.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport styles from './heading.module.css'\nimport type { ObfuscatedClassName, Tone } from '../utils/common-types'\nimport type { BoxProps } from '../box'\n\ntype HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'\ntype HeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n\ntype HeadingProps = Omit<React.HTMLAttributes<HTMLHeadingElement>, 'className' | 'children'> & {\n children: React.ReactNode\n /**\n * The semantic level of the heading.\n */\n level: HeadingLevel\n\n /**\n * The weight of the heading. Used to de-emphasize the heading visually when using 'medium' or 'light'.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'medium' | 'light'\n\n /**\n * Shifts the default heading visual text size up or down, depending on the original size\n * imposed by the `level`. The heading continues to be semantically at the given level.\n *\n * By default, no value is applied, and the default size from the level is applied. The values\n * have the following effect:\n *\n * - 'smaller' shifts the default level size down in the font-size scale (it tends to make the\n * level look visually as if it were of the immediately lower level).\n * - 'larger' has the opposite effect than 'smaller' shifting the visual font size up in the\n * scale.\n * - 'largest' can be thought of as applying 'larger' twice.\n *\n * @see level\n * @default undefined\n */\n size?: 'smaller' | 'larger' | 'largest'\n\n /**\n * The tone (semantic color) of the heading.\n *\n * @default 'normal'\n */\n tone?: Tone\n\n /**\n * Used to truncate the heading to a given number of lines.\n *\n * It will add an ellipsis (`…`) to the text at the end of the last line, only if the text was\n * truncated. If the text fits without it being truncated, no ellipsis is added.\n *\n * By default, the text is not truncated at all, no matter how many lines it takes to render it.\n *\n * @default undefined\n */\n lineClamp?: 1 | 2 | 3 | 4 | 5 | '1' | '2' | '3' | '4' | '5'\n\n /**\n * How to align the heading text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Heading = React.forwardRef<HTMLHeadingElement, HeadingProps & ObfuscatedClassName>(\n function Heading(\n {\n level,\n weight = 'regular',\n size,\n tone = 'normal',\n children,\n lineClamp,\n align,\n exceptionallySetClassName,\n ...props\n },\n ref,\n ) {\n // In TypeScript v4.1, this would be properly recognized without needing the type assertion\n // https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types\n const headingElementName = `h${level}` as HeadingElement\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? parseInt(lineClamp, 10) > 1 : (lineClamp || 0) > 1\n\n return (\n <Box\n {...props}\n className={[\n exceptionallySetClassName,\n styles.heading,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\n getClassNames(styles, 'size', size),\n lineClampMultipleLines ? styles.lineClampMultipleLines : null,\n lineClamp ? getClassNames(styles, 'lineClamp', lineClamp.toString()) : null,\n ]}\n textAlign={align}\n // Prevents emojis from being cut-off\n // See https://github.com/Doist/reactist/pull/528\n paddingRight={lineClamp ? 'xsmall' : undefined}\n as={headingElementName}\n ref={ref}\n >\n {children}\n </Box>\n )\n },\n)\n\nexport type { HeadingProps, HeadingLevel }\nexport { Heading }\n"],"names":["React","ref","level","weight","size","tone","children","lineClamp","align","exceptionallySetClassName","props","headingElementName","lineClampMultipleLines","parseInt","Box","className","styles","heading","getClassNames","toString","textAlign","paddingRight","undefined","as"],"mappings":"+WAqEgBA,cACZ,WAYIC,OAXAC,MACIA,EADJC,OAEIA,EAAS,UAFbC,KAGIA,EAHJC,KAIIA,EAAO,SAJXC,SAKIA,EALJC,UAMIA,EANJC,MAOIA,EAPJC,0BAQIA,KACGC,iCAMP,MAAMC,MAAyBT,EACzBU,EACmB,iBAAdL,EAAyBM,SAASN,EAAW,IAAM,GAAKA,GAAa,GAAK,EAErF,OACIP,gBAACc,yCACOJ,OACJK,UAAW,CACPN,EACAO,UAAOC,QACI,YAAXd,EAAuBe,gBAAcF,UAAQ,SAAUb,GAAU,KACxD,WAATE,EAAoBa,gBAAcF,UAAQ,OAAQX,GAAQ,KAC1Da,gBAAcF,UAAQ,OAAQZ,GAC9BQ,EAAyBI,UAAOJ,uBAAyB,KACzDL,EAAYW,gBAAcF,UAAQ,YAAaT,EAAUY,YAAc,MAE3EC,UAAWZ,EAGXa,aAAcd,EAAY,cAAWe,EACrCC,GAAIZ,EACJV,IAAKA,IAEJK"}
1
+ {"version":3,"file":"heading.js","sources":["../../src/heading/heading.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport styles from './heading.module.css'\nimport type { ObfuscatedClassName, Tone } from '../utils/common-types'\nimport type { BoxProps } from '../box'\n\ntype HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'\ntype HeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n\ntype HeadingProps = Omit<React.HTMLAttributes<HTMLHeadingElement>, 'className' | 'children'> & {\n children: React.ReactNode\n /**\n * The semantic level of the heading.\n */\n level: HeadingLevel\n\n /**\n * The weight of the heading. Used to de-emphasize the heading visually when using 'medium' or 'light'.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'medium' | 'light'\n\n /**\n * Shifts the default heading visual text size up or down, depending on the original size\n * imposed by the `level`. The heading continues to be semantically at the given level.\n *\n * By default, no value is applied, and the default size from the level is applied. The values\n * have the following effect:\n *\n * - 'smaller' shifts the default level size down in the font-size scale (it tends to make the\n * level look visually as if it were of the immediately lower level).\n * - 'larger' has the opposite effect than 'smaller' shifting the visual font size up in the\n * scale.\n * - 'largest' can be thought of as applying 'larger' twice.\n *\n * @see level\n * @default undefined\n */\n size?: 'smaller' | 'larger' | 'largest'\n\n /**\n * The tone (semantic color) of the heading.\n *\n * @default 'normal'\n */\n tone?: Tone\n\n /**\n * Used to truncate the heading to a given number of lines.\n *\n * It will add an ellipsis (`…`) to the text at the end of the last line, only if the text was\n * truncated. If the text fits without it being truncated, no ellipsis is added.\n *\n * By default, the text is not truncated at all, no matter how many lines it takes to render it.\n *\n * @default undefined\n */\n lineClamp?: 1 | 2 | 3 | 4 | 5 | '1' | '2' | '3' | '4' | '5'\n\n /**\n * How to align the heading text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Heading = React.forwardRef<HTMLHeadingElement, HeadingProps & ObfuscatedClassName>(\n function Heading(\n {\n level,\n weight = 'regular',\n size,\n tone = 'normal',\n children,\n lineClamp,\n align,\n exceptionallySetClassName,\n ...props\n },\n ref,\n ) {\n // In TypeScript v4.1, this would be properly recognized without needing the type assertion\n // https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types\n const headingElementName = `h${level}` as HeadingElement\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? parseInt(lineClamp, 10) > 1 : (lineClamp || 0) > 1\n\n return (\n <Box\n {...props}\n className={[\n exceptionallySetClassName,\n styles.heading,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\n getClassNames(styles, 'size', size),\n lineClampMultipleLines ? styles.lineClampMultipleLines : null,\n lineClamp ? getClassNames(styles, 'lineClamp', lineClamp.toString()) : null,\n ]}\n textAlign={align}\n // Prevents emojis from being cut-off\n // See https://github.com/Doist/reactist/pull/528\n paddingRight={lineClamp ? 'xsmall' : undefined}\n as={headingElementName}\n ref={ref}\n >\n {children}\n </Box>\n )\n },\n)\n\nexport type { HeadingProps, HeadingLevel }\nexport { Heading }\n"],"names":["React","forwardRef","ref","level","weight","size","tone","children","lineClamp","align","exceptionallySetClassName","_ref","props","_objectWithoutProperties","objectWithoutProperties","_excluded","headingElementName","lineClampMultipleLines","parseInt","createElement","Box","className","styles","heading","getClassNames","toString","textAlign","paddingRight","undefined","as"],"mappings":"0oBAqEgBA,EAAMC,YAClB,SAYIC,EAAAA,GAAG,IAXHC,MACIA,EADJC,OAEIA,EAAS,UAFbC,KAGIA,EAHJC,KAIIA,EAAO,SAJXC,SAKIA,EALJC,UAMIA,EANJC,MAOIA,EAPJC,0BAQIA,GAGDC,EAFIC,EAEJC,EAAAC,wBAAAH,EAAAI,GAIH,MAAMC,MAAyBb,EACzBc,EACmB,iBAAdT,EAAyBU,SAASV,EAAW,IAAM,GAAKA,GAAa,GAAK,EAErF,OACIR,EAACmB,cAAAC,yCACOR,GADR,GAAA,CAEIS,UAAW,CACPX,EACAY,EAAM,QAACC,QACI,YAAXnB,EAAuBoB,gBAAcF,EAAAA,QAAQ,SAAUlB,GAAU,KACxD,WAATE,EAAoBkB,EAAaA,cAACF,EAAD,QAAS,OAAQhB,GAAQ,KAC1DkB,EAAaA,cAACF,UAAQ,OAAQjB,GAC9BY,EAAyBK,EAAAA,QAAOL,uBAAyB,KACzDT,EAAYgB,EAAaA,cAACF,UAAQ,YAAad,EAAUiB,YAAc,MAE3EC,UAAWjB,EAGXkB,aAAcnB,EAAY,cAAWoB,EACrCC,GAAIb,EACJd,IAAKA,IAEJK"}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ResponsiveBreakpoints } from '../utils/responsive-props';
3
- declare type AboveProp = {
3
+ type AboveProp = {
4
4
  /**
5
5
  * Hides the element on viewport sizes equal or larger to the one given.
6
6
  *
@@ -12,7 +12,7 @@ declare type AboveProp = {
12
12
  above: Exclude<ResponsiveBreakpoints, 'desktop'>;
13
13
  below?: never;
14
14
  };
15
- declare type BelowProp = {
15
+ type BelowProp = {
16
16
  /**
17
17
  * Hides the element on viewport sizes equal or smaller to the one given.
18
18
  *
@@ -24,7 +24,7 @@ declare type BelowProp = {
24
24
  below: Exclude<ResponsiveBreakpoints, 'mobile'>;
25
25
  above?: never;
26
26
  };
27
- declare type CommonProps = {
27
+ type CommonProps = {
28
28
  children: React.ReactNode;
29
29
  /**
30
30
  * hides the element when on print media.
@@ -35,7 +35,7 @@ declare type CommonProps = {
35
35
  */
36
36
  display?: 'inline' | 'block';
37
37
  };
38
- declare type HiddenProps = CommonProps & (AboveProp | BelowProp | Required<Pick<CommonProps, 'print'>>);
38
+ type HiddenProps = CommonProps & (AboveProp | BelowProp | Required<Pick<CommonProps, 'print'>>);
39
39
  /**
40
40
  * A component that allows to specify how to hide itself on certain responsive screen sizes, or on
41
41
  * print media.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),o=require("react"),i=require("../utils/polymorphism.js"),n=require("../box/box.js"),t=require("./hidden.module.css.js");const l=["display","children","exceptionallySetClassName"];exports.Hidden=i.polymorphicComponent((function(i,r){let{display:s="block",children:a,exceptionallySetClassName:d}=i,b=e.objectWithoutProperties(i,l);const p="print"in b&&b.print,c="above"in b,u="below"in b,h="below"in b&&"desktop"===b.below||"above"in b&&"mobile"===b.above;return c&&u&&console.warn('<Hidden /> should receive either above="…" or below="…" but not both'),c||u||p||console.warn("<Hidden /> did not receive any criteria to hide itself"),"above"in b&&delete b.above,"below"in b&&delete b.below,"print"in b&&delete b.print,o.createElement(n.Box,e.objectSpread2(e.objectSpread2({},b),{},{ref:r,className:[d,p?t.default.hiddenOnPrint:null],display:c&&u?"none":{mobile:u?"none":s,tablet:h?"none":s,desktop:c?"none":s}}),a)}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),o=require("../box/box.js"),r=require("./hidden.module.css.js"),n=require("../utils/polymorphism.js");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,t}var l=i(t);const a=["display","children","exceptionallySetClassName"];exports.Hidden=n.polymorphicComponent((function(t,n){let{display:i="block",children:s,exceptionallySetClassName:d}=t,c=e.objectWithoutProperties(t,a);const u="print"in c&&c.print,b="above"in c,p="below"in c,f="below"in c&&"desktop"===c.below||"above"in c&&"mobile"===c.above;return b&&p&&console.warn('<Hidden /> should receive either above="…" or below="…" but not both'),b||p||u||console.warn("<Hidden /> did not receive any criteria to hide itself"),"above"in c&&delete c.above,"below"in c&&delete c.below,"print"in c&&delete c.print,l.createElement(o.Box,e.objectSpread2(e.objectSpread2({},c),{},{ref:n,className:[d,u?r.default.hiddenOnPrint:null],display:b&&p?"none":{mobile:p?"none":i,tablet:f?"none":i,desktop:b?"none":i}}),s)}));
2
2
  //# sourceMappingURL=hidden.js.map