@doist/reactist 29.1.1 → 30.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 (227) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/reactist.cjs.development.js +6749 -1832
  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/avatar/avatar.js +106 -36
  7. package/es/avatar/avatar.js.map +1 -1
  8. package/es/avatar/utils.js +17 -19
  9. package/es/avatar/utils.js.map +1 -1
  10. package/es/badge/badge.js +50 -6
  11. package/es/badge/badge.js.map +1 -1
  12. package/es/banner/banner.js +384 -41
  13. package/es/banner/banner.js.map +1 -1
  14. package/es/base-field/base-field.js +367 -77
  15. package/es/base-field/base-field.js.map +1 -1
  16. package/es/box/box.js +139 -61
  17. package/es/box/box.js.map +1 -1
  18. package/es/button/button.js +346 -36
  19. package/es/button/button.js.map +1 -1
  20. package/es/checkbox-field/checkbox-field.js +71 -48
  21. package/es/checkbox-field/checkbox-field.js.map +1 -1
  22. package/es/checkbox-field/checkbox-icon.js +88 -28
  23. package/es/checkbox-field/checkbox-icon.js.map +1 -1
  24. package/es/checkbox-field/use-fork-ref.js +15 -20
  25. package/es/checkbox-field/use-fork-ref.js.map +1 -1
  26. package/es/columns/columns.js +46 -23
  27. package/es/columns/columns.js.map +1 -1
  28. package/es/components/color-picker/color-picker.js +190 -46
  29. package/es/components/color-picker/color-picker.js.map +1 -1
  30. package/es/components/deprecated-button/deprecated-button.js +102 -9
  31. package/es/components/deprecated-button/deprecated-button.js.map +1 -1
  32. package/es/components/deprecated-button/index.js +5 -2
  33. package/es/components/deprecated-button/index.js.map +1 -1
  34. package/es/components/deprecated-dropdown/dropdown.js +234 -134
  35. package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
  36. package/es/components/deprecated-dropdown/index.js +4 -1
  37. package/es/components/deprecated-dropdown/index.js.map +1 -1
  38. package/es/components/deprecated-input/index.js +5 -2
  39. package/es/components/deprecated-input/index.js.map +1 -1
  40. package/es/components/deprecated-input/input.js +27 -4
  41. package/es/components/deprecated-input/input.js.map +1 -1
  42. package/es/components/deprecated-select/select.js +110 -7
  43. package/es/components/deprecated-select/select.js.map +1 -1
  44. package/es/components/key-capturer/key-capturer.js +190 -137
  45. package/es/components/key-capturer/key-capturer.js.map +1 -1
  46. package/es/components/keyboard-shortcut/keyboard-shortcut.js +65 -45
  47. package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  48. package/es/components/progress-bar/progress-bar.js +61 -9
  49. package/es/components/progress-bar/progress-bar.js.map +1 -1
  50. package/es/components/time/index.js +5 -2
  51. package/es/components/time/index.js.map +1 -1
  52. package/es/components/time/time-utils.js +59 -53
  53. package/es/components/time/time-utils.js.map +1 -1
  54. package/es/components/time/time.js +94 -91
  55. package/es/components/time/time.js.map +1 -1
  56. package/es/divider/divider.js +44 -5
  57. package/es/divider/divider.js.map +1 -1
  58. package/es/heading/heading.js +122 -20
  59. package/es/heading/heading.js.map +1 -1
  60. package/es/hidden/hidden.js +36 -30
  61. package/es/hidden/hidden.js.map +1 -1
  62. package/es/hidden-visually/hidden-visually.js +9 -4
  63. package/es/hidden-visually/hidden-visually.js.map +1 -1
  64. package/es/icons/alert-icon.js +145 -18
  65. package/es/icons/alert-icon.js.map +1 -1
  66. package/es/icons/banner-icon.js +213 -25
  67. package/es/icons/banner-icon.js.map +1 -1
  68. package/es/icons/close-icon.js +26 -3
  69. package/es/icons/close-icon.js.map +1 -1
  70. package/es/icons/password-hidden-icon.js +40 -6
  71. package/es/icons/password-hidden-icon.js.map +1 -1
  72. package/es/icons/password-visible-icon.js +33 -5
  73. package/es/icons/password-visible-icon.js.map +1 -1
  74. package/es/index.js +9 -9
  75. package/es/inline/inline.js +24 -9
  76. package/es/inline/inline.js.map +1 -1
  77. package/es/loading/loading.js +63 -17
  78. package/es/loading/loading.js.map +1 -1
  79. package/es/menu/menu.js +469 -92
  80. package/es/menu/menu.js.map +1 -1
  81. package/es/modal/modal.js +675 -112
  82. package/es/modal/modal.js.map +1 -1
  83. package/es/notice/notice.js +77 -10
  84. package/es/notice/notice.js.map +1 -1
  85. package/es/password-field/password-field.js +89 -11
  86. package/es/password-field/password-field.js.map +1 -1
  87. package/es/prose/prose.js +48 -9
  88. package/es/prose/prose.js.map +1 -1
  89. package/es/select-field/select-field.js +150 -19
  90. package/es/select-field/select-field.js.map +1 -1
  91. package/es/spinner/spinner.js +39 -6
  92. package/es/spinner/spinner.js.map +1 -1
  93. package/es/stack/stack.js +29 -17
  94. package/es/stack/stack.js.map +1 -1
  95. package/es/switch-field/switch-field.js +225 -42
  96. package/es/switch-field/switch-field.js.map +1 -1
  97. package/es/tabs/tabs.js +207 -109
  98. package/es/tabs/tabs.js.map +1 -1
  99. package/es/text/text.js +27 -17
  100. package/es/text/text.js.map +1 -1
  101. package/es/text-area/text-area.js +264 -54
  102. package/es/text-area/text-area.js.map +1 -1
  103. package/es/text-field/text-field.js +204 -31
  104. package/es/text-field/text-field.js.map +1 -1
  105. package/es/text-link/text-link.js +21 -10
  106. package/es/text-link/text-link.js.map +1 -1
  107. package/es/toast/static-toast.js +143 -25
  108. package/es/toast/static-toast.js.map +1 -1
  109. package/es/toast/toast-animation.js +159 -109
  110. package/es/toast/toast-animation.js.map +1 -1
  111. package/es/toast/use-toasts.js +309 -84
  112. package/es/toast/use-toasts.js.map +1 -1
  113. package/es/tooltip/tooltip.js +88 -32
  114. package/es/tooltip/tooltip.js.map +1 -1
  115. package/es/utils/common-helpers.js +12 -11
  116. package/es/utils/common-helpers.js.map +1 -1
  117. package/es/utils/polymorphism.js +84 -1
  118. package/es/utils/polymorphism.js.map +1 -1
  119. package/es/utils/responsive-props.js +43 -32
  120. package/es/utils/responsive-props.js.map +1 -1
  121. package/lib/avatar/avatar.js +109 -35
  122. package/lib/avatar/avatar.js.map +1 -1
  123. package/lib/avatar/utils.js +17 -19
  124. package/lib/avatar/utils.js.map +1 -1
  125. package/lib/badge/badge.js +53 -5
  126. package/lib/badge/badge.js.map +1 -1
  127. package/lib/banner/banner.js +385 -38
  128. package/lib/banner/banner.js.map +1 -1
  129. package/lib/base-field/base-field.js +366 -73
  130. package/lib/base-field/base-field.js.map +1 -1
  131. package/lib/box/box.js +141 -61
  132. package/lib/box/box.js.map +1 -1
  133. package/lib/button/button.js +347 -35
  134. package/lib/button/button.js.map +1 -1
  135. package/lib/checkbox-field/checkbox-field.js +73 -46
  136. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  137. package/lib/checkbox-field/checkbox-icon.js +92 -28
  138. package/lib/checkbox-field/checkbox-icon.js.map +1 -1
  139. package/lib/checkbox-field/use-fork-ref.js +15 -20
  140. package/lib/checkbox-field/use-fork-ref.js.map +1 -1
  141. package/lib/columns/columns.js +49 -22
  142. package/lib/columns/columns.js.map +1 -1
  143. package/lib/components/color-picker/color-picker.js +189 -45
  144. package/lib/components/color-picker/color-picker.js.map +1 -1
  145. package/lib/components/deprecated-button/deprecated-button.js +104 -9
  146. package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
  147. package/lib/components/deprecated-dropdown/dropdown.js +235 -133
  148. package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
  149. package/lib/components/deprecated-input/input.js +28 -4
  150. package/lib/components/deprecated-input/input.js.map +1 -1
  151. package/lib/components/deprecated-select/select.js +112 -7
  152. package/lib/components/deprecated-select/select.js.map +1 -1
  153. package/lib/components/key-capturer/key-capturer.js +188 -135
  154. package/lib/components/key-capturer/key-capturer.js.map +1 -1
  155. package/lib/components/keyboard-shortcut/keyboard-shortcut.js +67 -45
  156. package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  157. package/lib/components/progress-bar/progress-bar.js +60 -8
  158. package/lib/components/progress-bar/progress-bar.js.map +1 -1
  159. package/lib/components/time/time-utils.js +59 -53
  160. package/lib/components/time/time-utils.js.map +1 -1
  161. package/lib/components/time/time.js +93 -90
  162. package/lib/components/time/time.js.map +1 -1
  163. package/lib/divider/divider.js +47 -4
  164. package/lib/divider/divider.js.map +1 -1
  165. package/lib/heading/heading.js +125 -19
  166. package/lib/heading/heading.js.map +1 -1
  167. package/lib/hidden/hidden.js +39 -29
  168. package/lib/hidden/hidden.js.map +1 -1
  169. package/lib/hidden-visually/hidden-visually.js +11 -3
  170. package/lib/hidden-visually/hidden-visually.js.map +1 -1
  171. package/lib/icons/alert-icon.js +149 -18
  172. package/lib/icons/alert-icon.js.map +1 -1
  173. package/lib/icons/banner-icon.js +217 -25
  174. package/lib/icons/banner-icon.js.map +1 -1
  175. package/lib/icons/close-icon.js +29 -3
  176. package/lib/icons/close-icon.js.map +1 -1
  177. package/lib/icons/password-hidden-icon.js +43 -6
  178. package/lib/icons/password-hidden-icon.js.map +1 -1
  179. package/lib/icons/password-visible-icon.js +36 -5
  180. package/lib/icons/password-visible-icon.js.map +1 -1
  181. package/lib/inline/inline.js +27 -8
  182. package/lib/inline/inline.js.map +1 -1
  183. package/lib/loading/loading.js +67 -17
  184. package/lib/loading/loading.js.map +1 -1
  185. package/lib/menu/menu.js +471 -91
  186. package/lib/menu/menu.js.map +1 -1
  187. package/lib/modal/modal.js +671 -106
  188. package/lib/modal/modal.js.map +1 -1
  189. package/lib/notice/notice.js +75 -8
  190. package/lib/notice/notice.js.map +1 -1
  191. package/lib/password-field/password-field.js +92 -10
  192. package/lib/password-field/password-field.js.map +1 -1
  193. package/lib/prose/prose.js +51 -8
  194. package/lib/prose/prose.js.map +1 -1
  195. package/lib/select-field/select-field.js +152 -17
  196. package/lib/select-field/select-field.js.map +1 -1
  197. package/lib/spinner/spinner.js +39 -6
  198. package/lib/spinner/spinner.js.map +1 -1
  199. package/lib/stack/stack.js +29 -15
  200. package/lib/stack/stack.js.map +1 -1
  201. package/lib/switch-field/switch-field.js +225 -38
  202. package/lib/switch-field/switch-field.js.map +1 -1
  203. package/lib/tabs/tabs.js +207 -107
  204. package/lib/tabs/tabs.js.map +1 -1
  205. package/lib/text/text.js +30 -16
  206. package/lib/text/text.js.map +1 -1
  207. package/lib/text-area/text-area.js +264 -52
  208. package/lib/text-area/text-area.js.map +1 -1
  209. package/lib/text-field/text-field.js +207 -30
  210. package/lib/text-field/text-field.js.map +1 -1
  211. package/lib/text-link/text-link.js +24 -9
  212. package/lib/text-link/text-link.js.map +1 -1
  213. package/lib/toast/static-toast.js +142 -22
  214. package/lib/toast/static-toast.js.map +1 -1
  215. package/lib/toast/toast-animation.js +158 -108
  216. package/lib/toast/toast-animation.js.map +1 -1
  217. package/lib/toast/use-toasts.js +310 -82
  218. package/lib/toast/use-toasts.js.map +1 -1
  219. package/lib/tooltip/tooltip.js +87 -31
  220. package/lib/tooltip/tooltip.js.map +1 -1
  221. package/lib/utils/common-helpers.js +12 -11
  222. package/lib/utils/common-helpers.js.map +1 -1
  223. package/lib/utils/polymorphism.js +84 -1
  224. package/lib/utils/polymorphism.js.map +1 -1
  225. package/lib/utils/responsive-props.js +43 -32
  226. package/lib/utils/responsive-props.js.map +1 -1
  227. package/package.json +12 -3
@@ -1,41 +1,97 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import * as React from 'react';
2
3
  import { useTooltipStore, TooltipAnchor, Tooltip as Tooltip$1, TooltipArrow } from '@ariakit/react';
3
- import { Box } from '../box/box.js';
4
4
  import modules_95f1407a from './tooltip.module.css.js';
5
+ import { Box } from '../box/box.js';
5
6
 
6
- var defaultShowTimeout = 500;
7
- var defaultHideTimeout = 100;
8
- var TooltipContext = React.createContext({
9
- showTimeout: defaultShowTimeout,
10
- hideTimeout: defaultHideTimeout,
7
+ const defaultShowTimeout = 500;
8
+ const defaultHideTimeout = 100;
9
+ const TooltipContext = /*#__PURE__*/React.createContext({
10
+ showTimeout: defaultShowTimeout,
11
+ hideTimeout: defaultHideTimeout
11
12
  });
12
- function TooltipProvider(_a) {
13
- var _b = _a.showTimeout, showTimeout = _b === void 0 ? defaultShowTimeout : _b, _c = _a.hideTimeout, hideTimeout = _c === void 0 ? defaultHideTimeout : _c, children = _a.children;
14
- var value = React.useMemo(function () { return ({ showTimeout: showTimeout, hideTimeout: hideTimeout }); }, [showTimeout, hideTimeout]);
15
- return React.createElement(TooltipContext.Provider, { value: value }, children);
13
+ function TooltipProvider(t0) {
14
+ const $ = c(6);
15
+ const {
16
+ showTimeout: t1,
17
+ hideTimeout: t2,
18
+ children
19
+ } = t0;
20
+ const showTimeout = t1 === undefined ? defaultShowTimeout : t1;
21
+ const hideTimeout = t2 === undefined ? defaultHideTimeout : t2;
22
+ let t3;
23
+ if ($[0] !== hideTimeout || $[1] !== showTimeout) {
24
+ t3 = {
25
+ showTimeout,
26
+ hideTimeout
27
+ };
28
+ $[0] = hideTimeout;
29
+ $[1] = showTimeout;
30
+ $[2] = t3;
31
+ } else {
32
+ t3 = $[2];
33
+ }
34
+ const value = t3;
35
+ let t4;
36
+ if ($[3] !== children || $[4] !== value) {
37
+ t4 = /*#__PURE__*/React.createElement(TooltipContext.Provider, {
38
+ value: value
39
+ }, children);
40
+ $[3] = children;
41
+ $[4] = value;
42
+ $[5] = t4;
43
+ } else {
44
+ t4 = $[5];
45
+ }
46
+ return t4;
16
47
  }
17
- var Tooltip = React.forwardRef(function (_a, ref) {
18
- var children = _a.children, content = _a.content, _b = _a.position, position = _b === void 0 ? 'top' : _b, _c = _a.gapSize, gapSize = _c === void 0 ? 3 : _c, _d = _a.withArrow, withArrow = _d === void 0 ? false : _d, showTimeout = _a.showTimeout, hideTimeout = _a.hideTimeout, exceptionallySetClassName = _a.exceptionallySetClassName;
19
- var _e = React.useContext(TooltipContext), globalShowTimeout = _e.showTimeout, globalHideTimeout = _e.hideTimeout;
20
- var tooltip = useTooltipStore({
21
- placement: position,
22
- showTimeout: showTimeout !== null && showTimeout !== void 0 ? showTimeout : globalShowTimeout,
23
- hideTimeout: hideTimeout !== null && hideTimeout !== void 0 ? hideTimeout : globalHideTimeout,
24
- });
25
- React.useImperativeHandle(ref, function () { return tooltip; }, [tooltip]);
26
- var isOpen = tooltip.useState('open');
27
- var child = React.Children.only(children);
28
- if (!child) {
29
- return child;
30
- }
31
- if (typeof child.ref === 'string') {
32
- throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded');
33
- }
34
- return (React.createElement(React.Fragment, null,
35
- React.createElement(TooltipAnchor, { render: child, store: tooltip, ref: child.ref }),
36
- isOpen && content ? (React.createElement(Tooltip$1, { store: tooltip, gutter: gapSize, render: React.createElement(Box, { className: [modules_95f1407a.tooltip, exceptionallySetClassName], background: "toast", borderRadius: "standard", paddingX: "small", paddingY: "xsmall", maxWidth: "medium", width: "fitContent", overflow: "hidden", textAlign: "center" }) },
37
- withArrow ? React.createElement(TooltipArrow, null) : null,
38
- typeof content === 'function' ? content() : content)) : null));
48
+ const Tooltip = /*#__PURE__*/React.forwardRef(({
49
+ children,
50
+ content,
51
+ position = 'top',
52
+ gapSize = 3,
53
+ withArrow = false,
54
+ showTimeout,
55
+ hideTimeout,
56
+ exceptionallySetClassName
57
+ }, ref) => {
58
+ const {
59
+ showTimeout: globalShowTimeout,
60
+ hideTimeout: globalHideTimeout
61
+ } = React.useContext(TooltipContext);
62
+ const tooltip = useTooltipStore({
63
+ placement: position,
64
+ showTimeout: showTimeout ?? globalShowTimeout,
65
+ hideTimeout: hideTimeout ?? globalHideTimeout
66
+ });
67
+ React.useImperativeHandle(ref, () => tooltip, [tooltip]);
68
+ const isOpen = tooltip.useState('open');
69
+ const child = React.Children.only(children);
70
+ if (!child) {
71
+ return child;
72
+ }
73
+ if (typeof child.ref === 'string') {
74
+ throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded');
75
+ }
76
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipAnchor, {
77
+ render: child,
78
+ store: tooltip,
79
+ ref: child.ref
80
+ }), isOpen && content ? /*#__PURE__*/React.createElement(Tooltip$1, {
81
+ store: tooltip,
82
+ gutter: gapSize,
83
+ render: /*#__PURE__*/React.createElement(Box, {
84
+ className: [modules_95f1407a.tooltip, exceptionallySetClassName],
85
+ background: "toast",
86
+ borderRadius: "standard",
87
+ paddingX: "small",
88
+ paddingY: "xsmall",
89
+ maxWidth: "medium",
90
+ width: "fitContent",
91
+ overflow: "hidden",
92
+ textAlign: "center"
93
+ })
94
+ }, withArrow ? /*#__PURE__*/React.createElement(TooltipArrow, null) : null, typeof content === 'function' ? content() : content) : null);
39
95
  });
40
96
  Tooltip.displayName = 'Tooltip';
41
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":[null],"names":["AriakitTooltip","styles"],"mappings":";;;;;AAgBA,IAAM,kBAAkB,GAAG,GAAG,CAAA;AAC9B,IAAM,kBAAkB,GAAG,GAAG,CAAA;AAO9B,IAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAsB;AAC5D,IAAA,WAAW,EAAE,kBAAkB;AAC/B,IAAA,WAAW,EAAE,kBAAkB;AAClC,CAAA,CAAC,CAAA;AAEF,SAAS,eAAe,CAAC,EAOvB,EAAA;AANE,IAAA,IAAA,EAAA,GAAA,EAAA,CAAA,WAAgC,EAAhC,WAAW,GAAG,EAAA,KAAA,KAAA,CAAA,GAAA,kBAAkB,KAAA,EAChC,EAAA,GAAA,EAAA,CAAA,WAAgC,EAAhC,WAAW,GAAG,EAAA,KAAA,KAAA,CAAA,GAAA,kBAAkB,GAAA,EAAA,EAChC,QAAQ,GAAA,EAAA,CAAA,QAAA,CAAA;IAKR,IAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,YAAA,EAAM,QAAC,EAAE,WAAW,EAAA,WAAA,EAAE,WAAW,EAAA,WAAA,EAAE,EAAC,EAAA,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAA;IAC7F,OAAO,KAAA,CAAA,aAAA,CAAC,cAAc,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EAAG,QAAQ,CAA2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AC7B,QAA+E,CAClF,CAAA;IAED,IAAI,CAAC,KAAK,EAAE;AACR,QAAA,OAAO,KAAK,CAAA;KACf;AAED,IAAA,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC/B,QAAA,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;KACrF;AAED,IAAA,QACI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;AACI,QAAA,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAI,CAAA;AAC/D,QAAA,MAAM,IAAI,OAAO,IACd,KAAC,CAAA,aAAA,CAAAA,SAAc,EACX,EAAA,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,EACf,MAAM,EACF,KAAA,CAAA,aAAA,CAAC,GAAG,EAAA,EACA,SAAS,EAAE,CAACC,gBAAM,CAAC,OAAO,EAAE,yBAAyB,CAAC,EACtD,UAAU,EAAC,OAAO,EAClB,YAAY,EAAC,UAAU,EACvB,QAAQ,EAAC,OAAO,EAChB,QAAQ,EAAC,QAAQ,EACjB,QAAQ,EAAC,QAAQ,EACjB,KAAK,EAAC,YAAY,EAClB,QAAQ,EAAC,QAAQ,EACjB,SAAS,EAAC,QAAQ,EACpB,CAAA,EAAA;YAGL,SAAS,GAAG,KAAA,CAAA,aAAA,CAAC,YAAY,EAAG,IAAA,CAAA,GAAG,IAAI;YACnC,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,EAAE,GAAG,OAAO,CACvC,IACjB,IAAI,CACT,EACN;AACL,CAAC,EACJ;AAED,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
1
+ {"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n useTooltipStore,\n} from '@ariakit/react'\n\nimport { Box } from '../box'\n\nimport styles from './tooltip.module.css'\n\nimport type { TooltipStore, TooltipStoreState } from '@ariakit/react'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\nconst defaultShowTimeout = 500\nconst defaultHideTimeout = 100\n\ntype TooltipContextState = {\n showTimeout: number\n hideTimeout: number\n}\n\nconst TooltipContext = React.createContext<TooltipContextState>({\n showTimeout: defaultShowTimeout,\n hideTimeout: defaultHideTimeout,\n})\n\nfunction TooltipProvider({\n showTimeout = defaultShowTimeout,\n hideTimeout = defaultHideTimeout,\n children,\n}: React.PropsWithChildren<{\n showTimeout?: number\n hideTimeout?: number\n}>) {\n const value = React.useMemo(() => ({ showTimeout, hideTimeout }), [showTimeout, hideTimeout])\n return <TooltipContext.Provider value={value}>{children}</TooltipContext.Provider>\n}\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n\n /**\n * The amount of time in milliseconds to wait before showing the tooltip\n * Use `<TooltipContext.Provider>` to set a global value for all tooltips\n * @default 500\n */\n showTimeout?: number\n\n /**\n * The amount of time in milliseconds to wait before hiding the tooltip\n * Use `<TooltipContext.Provider>` to set a global value for all tooltips\n * @default 100\n */\n hideTimeout?: number\n}\n\nconst Tooltip = React.forwardRef<TooltipStore, TooltipProps>(\n (\n {\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n showTimeout,\n hideTimeout,\n exceptionallySetClassName,\n },\n ref,\n ) => {\n const { showTimeout: globalShowTimeout, hideTimeout: globalHideTimeout } =\n React.useContext(TooltipContext)\n\n const tooltip = useTooltipStore({\n placement: position,\n showTimeout: showTimeout ?? globalShowTimeout,\n hideTimeout: hideTimeout ?? globalHideTimeout,\n })\n\n React.useImperativeHandle(ref, () => tooltip, [tooltip])\n\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n },\n)\n\nTooltip.displayName = 'Tooltip'\n\nexport type { TooltipProps }\nexport { Tooltip, TooltipProvider }\n"],"names":["defaultShowTimeout","defaultHideTimeout","TooltipContext","React","createContext","showTimeout","hideTimeout","TooltipProvider","t0","$","_c","t1","t2","children","undefined","t3","value","t4","createElement","Provider","Tooltip","forwardRef","content","position","gapSize","withArrow","exceptionallySetClassName","ref","globalShowTimeout","globalHideTimeout","useContext","tooltip","useTooltipStore","placement","useImperativeHandle","isOpen","useState","child","Children","only","Error","Fragment","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow","displayName"],"mappings":";;;;;;AAgBA,MAAMA,kBAAkB,GAAG,GAAG,CAAA;AAC9B,MAAMC,kBAAkB,GAAG,GAAG,CAAA;AAO9B,MAAMC,cAAc,gBAAGC,KAAK,CAACC,aAAa,CAAsB;AAC5DC,EAAAA,WAAW,EAAEL,kBAAkB;AAC/BM,EAAAA,WAAW,EAAEL,kBAAAA;AACjB,CAAC,CAAC,CAAA;AAEF,SAAAM,gBAAAC,EAAA,EAAA;EAAA,MAAAC,CAAA,GAAAC,CAAA,CAAA,CAAA,CAAA,CAAA;AAAyB,EAAA,MAAA;AAAAL,IAAAA,WAAA,EAAAM,EAAA;AAAAL,IAAAA,WAAA,EAAAM,EAAA;AAAAC,IAAAA,QAAAA;AAAA,GAAA,GAAAL,EAOvB,CAAA;EANE,MAAAH,WAAA,GAAAM,EAAgC,KAAhCG,SAAgC,GAAhCd,kBAAgC,GAAhCW,EAAgC,CAAA;EAChC,MAAAL,WAAA,GAAAM,EAAgC,KAAhCE,SAAgC,GAAhCb,kBAAgC,GAAhCW,EAAgC,CAAA;AAAA,EAAA,IAAAG,EAAA,CAAA;AAAA,EAAA,IAAAN,CAAA,CAAAH,CAAAA,CAAAA,KAAAA,WAAA,IA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CAAClB,OAAO,EAAEL,yBAAyB,CAAE;AACvDwB,MAAAA,UAAU,EAAC,OAAO;AAClBC,MAAAA,YAAY,EAAC,UAAU;AACvBC,MAAAA,QAAQ,EAAC,OAAO;AAChBC,MAAAA,QAAQ,EAAC,QAAQ;AACjBC,MAAAA,QAAQ,EAAC,QAAQ;AACjBC,MAAAA,KAAK,EAAC,YAAY;AAClBC,MAAAA,QAAQ,EAAC,QAAQ;AACjBC,MAAAA,SAAS,EAAC,QAAA;KACb,CAAA;GAGJhC,EAAAA,SAAS,gBAAGtB,KAAA,CAAAe,aAAA,CAACwC,YAAY,EAAA,IAAE,CAAC,GAAG,IAAI,EACnC,OAAOpC,OAAO,KAAK,UAAU,GAAGA,OAAO,EAAE,GAAGA,OACjC,CAAC,GACjB,IACN,CAAC,CAAA;AAEX,CACJ,EAAC;AAEDF,OAAO,CAACuC,WAAW,GAAG,SAAS;;;;"}
@@ -1,24 +1,25 @@
1
1
  import * as React from 'react';
2
2
 
3
- var uid = 0;
3
+ let uid = 0;
4
4
  function uniqueId() {
5
- return uid++;
5
+ return uid++;
6
6
  }
7
7
  function generateElementId(prefix) {
8
- var num = uniqueId();
9
- return "".concat(prefix, "-").concat(num);
8
+ const num = uniqueId();
9
+ return `${prefix}-${num}`;
10
10
  }
11
+
11
12
  /**
12
13
  * @deprecated Use `useId` available from React 18 or above instead.
13
14
  */
14
15
  function useId(providedId) {
15
- var ref = React.useRef(providedId !== null && providedId !== void 0 ? providedId : null);
16
- // eslint-disable-next-line react-hooks/refs
17
- if (!ref.current) {
18
- ref.current = generateElementId('element');
19
- }
20
- // eslint-disable-next-line react-hooks/refs
21
- return ref.current;
16
+ const ref = React.useRef(providedId ?? null);
17
+ // eslint-disable-next-line react-hooks/refs
18
+ if (!ref.current) {
19
+ ref.current = generateElementId('element');
20
+ }
21
+ // eslint-disable-next-line react-hooks/refs
22
+ return ref.current;
22
23
  }
23
24
 
24
25
  export { generateElementId, useId };
@@ -1 +1 @@
1
- {"version":3,"file":"common-helpers.js","sources":["../../src/utils/common-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA,IAAI,GAAG,GAAG,CAAC,CAAA;AACX,SAAS,QAAQ,GAAA;IACb,OAAO,GAAG,EAAE,CAAA;AAChB,CAAC;AAEK,SAAU,iBAAiB,CAAC,MAAc,EAAA;AAC5C,IAAA,IAAM,GAAG,GAAG,QAAQ,EAAE,CAAA;AACtB,IAAA,OAAO,EAAG,CAAA,MAAA,CAAA,MAAM,EAAI,GAAA,CAAA,CAAA,MAAA,CAAA,GAAG,CAAE,CAAA;AAC7B,CAAC;AAED;;AAEG;AACG,SAAU,KAAK,CAAC,UAAmB,EAAA;AACrC,IAAA,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAgB,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,UAAU,GAAI,IAAI,CAAC,CAAA;;AAE3D,IAAA,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;AACd,QAAA,GAAG,CAAC,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;KAC7C;;IAED,OAAO,GAAG,CAAC,OAAO,CAAA;AACtB;;;;"}
1
+ {"version":3,"file":"common-helpers.js","sources":["../../src/utils/common-helpers.ts"],"sourcesContent":["import * as React from 'react'\n\nlet uid = 0\nfunction uniqueId() {\n return uid++\n}\n\nexport function generateElementId(prefix: string): string {\n const num = uniqueId()\n return `${prefix}-${num}`\n}\n\n/**\n * @deprecated Use `useId` available from React 18 or above instead.\n */\nexport function useId(providedId?: string): string {\n const ref = React.useRef<string | null>(providedId ?? null)\n // eslint-disable-next-line react-hooks/refs\n if (!ref.current) {\n ref.current = generateElementId('element')\n }\n // eslint-disable-next-line react-hooks/refs\n return ref.current\n}\n"],"names":["uid","uniqueId","generateElementId","prefix","num","useId","providedId","ref","React","useRef","current"],"mappings":";;AAEA,IAAIA,GAAG,GAAG,CAAC,CAAA;AACX,SAASC,QAAQA,GAAG;AAChB,EAAA,OAAOD,GAAG,EAAE,CAAA;AAChB,CAAA;AAEO,SAASE,iBAAiBA,CAACC,MAAc,EAAU;AACtD,EAAA,MAAMC,GAAG,GAAGH,QAAQ,EAAE,CAAA;AACtB,EAAA,OAAO,CAAGE,EAAAA,MAAM,CAAIC,CAAAA,EAAAA,GAAG,CAAE,CAAA,CAAA;AAC7B,CAAA;;AAEA;AACA;AACA;AACO,SAASC,KAAKA,CAACC,UAAmB,EAAU;EAC/C,MAAMC,GAAG,GAAGC,KAAK,CAACC,MAAM,CAAgBH,UAAU,IAAI,IAAI,CAAC,CAAA;AAC3D;AACA,EAAA,IAAI,CAACC,GAAG,CAACG,OAAO,EAAE;AACdH,IAAAA,GAAG,CAACG,OAAO,GAAGR,iBAAiB,CAAC,SAAS,CAAC,CAAA;AAC9C,GAAA;AACA;EACA,OAAOK,GAAG,CAACG,OAAO,CAAA;AACtB;;;;"}
@@ -1,6 +1,89 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
+
5
+ /**
6
+ * If a set of props include the `className` prop, we replace it with a `exceptionallySetClassName`
7
+ * prop instead.
8
+ *
9
+ * This can be customized via the second generic parameter, as there are cases where it may be
10
+ * needed to omit this behaviour and keep the `className`. You can also instruct it to remove the
11
+ * `className` prop while not replacing it with the `exceptionallySetClassName` one.
12
+ *
13
+ * @see ObfuscatedClassName['exceptionallySetClassName'] for details about this prop
14
+ * @see PolymorphicComponent for details about this feature
15
+ */
16
+
17
+ /**
18
+ * Given a component or element type, and a set of additional props, this builds the entire set of
19
+ * props for a polymorphic component.
20
+ *
21
+ * It does three things:
22
+ *
23
+ * 1. it merges the element type props with the `OwnProps`
24
+ * 2. it adds the `as` prop to allow for polymorphism to happen
25
+ * 3. it optionally obfuscates or omits the className prop if present
26
+ *
27
+ * @see PolymorphicProp
28
+ * @see WithObfuscatedClassName
29
+ */
30
+
31
+ /**
32
+ * The function passed to React.forwardRef, but typed in a way that's prepared for polymorphism via
33
+ * the `as` prop. It also allows to specify if the `className` prop should be obfuscated or omitted.
34
+ *
35
+ * @see PolymorphicComponentProps
36
+ * @see WithObfuscatedClassName
37
+ */
38
+
39
+ /**
40
+ * A component that can customize the React element type that it renders (a.k.a. a polymorphic
41
+ * component). This is achieved by passing a prop `as={ElementType}` or `as="html-tag-name"`.
42
+ *
43
+ * It transparently takes care of forwarding refs, and properly sets the ref type depending on the
44
+ * element type.
45
+ *
46
+ * ## Recognizing props based on the polymorphic type
47
+ *
48
+ * The `ComponentType` argument sets the default type for the `as` prop. Whatever the `as` prop
49
+ * component or HTML element is, the type system will automatically allow you to pass props that are
50
+ * not explicitly defined by you, but that are recognized as valid props to be passed to the
51
+ * component you are rendering.
52
+ *
53
+ * For instance, see the following example:
54
+ *
55
+ * ```jsx
56
+ * <Box as="label" htmlFor="field-id">Hello</Box>
57
+ * ```
58
+ *
59
+ * The `htmlFor` prop is exclusive to label elements. If you omit the `as="label"` prop, the type
60
+ * system will consider the `htmlFor` prop to be an error. The same happens if you pass a value of
61
+ * an incorrect type to such prop. For instance, the example below will issue a type error:
62
+ *
63
+ * ```jsx
64
+ * <Box as="label" htmlFor={123}>Hello</Box>
65
+ * ```
66
+ *
67
+ * ## Omitting or obfuscating the `className` prop
68
+ *
69
+ * If a set of props include the `className` prop, we replace it with a `exceptionallySetClassName`
70
+ * prop instead.
71
+ *
72
+ * This is to discourage customizing design system components via custom styling, while still
73
+ * leaving the door open to do it as an escape hatch when the design system still has shortcomings
74
+ * with respect to the product designs we want to achieve.
75
+ *
76
+ * The cumbersome name also serves the purpose of aiding in easily searching for the places in the
77
+ * code where this escape hatch was needed, in order to identify areas where the design system
78
+ * components need to improve to better match our needs.
79
+ *
80
+ * This behaviour can be customized via an optional second generic argument that allows to disable
81
+ * this feature, or to omit the `className` altogether without replacing it with the obfuscated prop
82
+ * name.
83
+ *
84
+ * @deprecated Use Ariakit's composition instead (https://ariakit.org/guide/composition)
85
+ */
86
+
4
87
  /**
5
88
  * A wrapper to use React.forwardRef with polymorphic components in a type-safe manner. This is a
6
89
  * convenience over merely using React.forwardRef directly, and then manually forcing the resulting
@@ -9,7 +92,7 @@ import * as React from 'react';
9
92
  * @deprecated Use Ariakit's composition instead (https://ariakit.org/guide/composition)
10
93
  */
11
94
  function polymorphicComponent(render) {
12
- return React.forwardRef(render);
95
+ return /*#__PURE__*/React.forwardRef(render);
13
96
  }
14
97
 
15
98
  export { polymorphicComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"polymorphism.js","sources":["../../src/utils/polymorphism.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AAoLA;;;;;;AAMG;AACH,SAAS,oBAAoB,CAI3B,MAA6E,EAAA;AAC3E,IAAA,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAI7B,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"polymorphism.js","sources":["../../src/utils/polymorphism.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport * as React from 'react'\n\nimport type { ObfuscatedClassName } from './common-types'\n\ntype Merge<P1, P2> = Omit<P1, keyof P2> & P2\n\ntype EmptyObject = {\n [K in any]: never\n}\n\ntype ObfuscateClassNameMode = 'keepClassName' | 'obfuscateClassName' | 'omitClassName'\n\n/**\n * If a set of props include the `className` prop, we replace it with a `exceptionallySetClassName`\n * prop instead.\n *\n * This can be customized via the second generic parameter, as there are cases where it may be\n * needed to omit this behaviour and keep the `className`. You can also instruct it to remove the\n * `className` prop while not replacing it with the `exceptionallySetClassName` one.\n *\n * @see ObfuscatedClassName['exceptionallySetClassName'] for details about this prop\n * @see PolymorphicComponent for details about this feature\n */\ntype WithObfuscatedClassName<\n Props,\n ShouldObfuscateClassName extends ObfuscateClassNameMode,\n> = 'className' extends keyof Props\n ? ShouldObfuscateClassName extends 'obfuscateClassName'\n ? Omit<Props, 'className'> & ObfuscatedClassName\n : ShouldObfuscateClassName extends 'omitClassName'\n ? Omit<Props, 'className'>\n : ShouldObfuscateClassName extends 'keepClassName'\n ? Props\n : never\n : Props\n\ntype PolymorphicProp<ComponentType extends React.ElementType> = {\n /**\n * Used to instruct this component what React element to render as. It can be both a string\n * representing a HTML tag name, or a React component.\n *\n * When using this prop, the component you apply it to will also recognize in its props types\n * all the props from the component or HTML element you are rendering it as.\n *\n * Some uses for this feature:\n *\n * - Using some of our layout components, while at the same time being able to set them to use\n * semantic HTML elements needed for accessibility purposes (e.g. `nav`, `main`, etc).\n * - Using a design system link component, but have it internally use a client-side router link\n * implemented via a React component (e.g. react-router's `Link`).\n *\n * Keep in mind that not all compositions of this kind may work well, especially when composing\n * with another React component and not with a HTML tag name. In particular, if the components\n * being composed have opposing concerns of clashing features (e.g. they have contradicting\n * styles applied to them) things may not go well. In those cases prefer to nest them instead.\n *\n * @see PolymorphicComponent\n */\n as?: ComponentType\n}\n\n/**\n * Given a component or element type, and a set of additional props, this builds the entire set of\n * props for a polymorphic component.\n *\n * It does three things:\n *\n * 1. it merges the element type props with the `OwnProps`\n * 2. it adds the `as` prop to allow for polymorphism to happen\n * 3. it optionally obfuscates or omits the className prop if present\n *\n * @see PolymorphicProp\n * @see WithObfuscatedClassName\n */\ntype PolymorphicComponentProps<\n ComponentType extends React.ElementType,\n OwnProps,\n ShouldObfuscateClassName extends ObfuscateClassNameMode,\n> = Merge<\n WithObfuscatedClassName<React.ComponentProps<ComponentType>, ShouldObfuscateClassName>,\n OwnProps & PolymorphicProp<ComponentType>\n>\n\ntype ElementTagNameMap = HTMLElementTagNameMap &\n Pick<SVGElementTagNameMap, Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>>\n\ntype ElementByTag<TagName extends keyof ElementTagNameMap> = ElementTagNameMap[TagName]\n\ntype ElementByTagOrAny<ComponentType extends React.ElementType> =\n ComponentType extends keyof ElementTagNameMap ? ElementByTag<ComponentType> : any\n\n/**\n * The function passed to React.forwardRef, but typed in a way that's prepared for polymorphism via\n * the `as` prop. It also allows to specify if the `className` prop should be obfuscated or omitted.\n *\n * @see PolymorphicComponentProps\n * @see WithObfuscatedClassName\n */\ninterface ForwardRefFunction<\n ComponentType extends React.ElementType,\n OwnProps,\n ShouldObfuscateClassName extends ObfuscateClassNameMode,\n> {\n (\n props: PolymorphicComponentProps<ComponentType, OwnProps, ShouldObfuscateClassName>,\n ref:\n | ((instance: ElementByTagOrAny<ComponentType> | null) => void)\n | React.MutableRefObject<ElementByTagOrAny<ComponentType> | null>\n | null,\n ): React.ReactElement | null\n displayName?: string\n}\n\n/**\n * A component that can customize the React element type that it renders (a.k.a. a polymorphic\n * component). This is achieved by passing a prop `as={ElementType}` or `as=\"html-tag-name\"`.\n *\n * It transparently takes care of forwarding refs, and properly sets the ref type depending on the\n * element type.\n *\n * ## Recognizing props based on the polymorphic type\n *\n * The `ComponentType` argument sets the default type for the `as` prop. Whatever the `as` prop\n * component or HTML element is, the type system will automatically allow you to pass props that are\n * not explicitly defined by you, but that are recognized as valid props to be passed to the\n * component you are rendering.\n *\n * For instance, see the following example:\n *\n * ```jsx\n * <Box as=\"label\" htmlFor=\"field-id\">Hello</Box>\n * ```\n *\n * The `htmlFor` prop is exclusive to label elements. If you omit the `as=\"label\"` prop, the type\n * system will consider the `htmlFor` prop to be an error. The same happens if you pass a value of\n * an incorrect type to such prop. For instance, the example below will issue a type error:\n *\n * ```jsx\n * <Box as=\"label\" htmlFor={123}>Hello</Box>\n * ```\n *\n * ## Omitting or obfuscating the `className` prop\n *\n * If a set of props include the `className` prop, we replace it with a `exceptionallySetClassName`\n * prop instead.\n *\n * This is to discourage customizing design system components via custom styling, while still\n * leaving the door open to do it as an escape hatch when the design system still has shortcomings\n * with respect to the product designs we want to achieve.\n *\n * The cumbersome name also serves the purpose of aiding in easily searching for the places in the\n * code where this escape hatch was needed, in order to identify areas where the design system\n * components need to improve to better match our needs.\n *\n * This behaviour can be customized via an optional second generic argument that allows to disable\n * this feature, or to omit the `className` altogether without replacing it with the obfuscated prop\n * name.\n *\n * @deprecated Use Ariakit's composition instead (https://ariakit.org/guide/composition)\n */\ninterface PolymorphicComponent<\n ComponentType extends React.ElementType,\n OwnProps,\n ShouldObfuscateClassName extends ObfuscateClassNameMode = 'obfuscateClassName',\n> {\n <TT extends React.ElementType = ComponentType>(\n props: PolymorphicComponentProps<TT, OwnProps, ShouldObfuscateClassName>,\n ): React.ReactElement | null\n readonly $$typeof: symbol\n defaultProps?: Partial<\n PolymorphicComponentProps<ComponentType, OwnProps, ShouldObfuscateClassName>\n >\n propTypes?: React.WeakValidationMap<\n PolymorphicComponentProps<ComponentType, OwnProps, ShouldObfuscateClassName>\n >\n displayName?: string\n}\n\n/**\n * A wrapper to use React.forwardRef with polymorphic components in a type-safe manner. This is a\n * convenience over merely using React.forwardRef directly, and then manually forcing the resulting\n * value to be typed using `as PolymorphicComponent<…>`.\n *\n * @deprecated Use Ariakit's composition instead (https://ariakit.org/guide/composition)\n */\nfunction polymorphicComponent<\n ComponentType extends React.ElementType = 'div',\n OwnProps = EmptyObject,\n ShouldObfuscateClassName extends ObfuscateClassNameMode = 'obfuscateClassName',\n>(render: ForwardRefFunction<ComponentType, OwnProps, ShouldObfuscateClassName>) {\n return React.forwardRef(render) as PolymorphicComponent<\n ComponentType,\n OwnProps,\n ShouldObfuscateClassName\n >\n}\n\nexport type { PolymorphicComponent }\nexport { polymorphicComponent }\n"],"names":["polymorphicComponent","render","React","forwardRef"],"mappings":";;AAAA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,oBAAoBA,CAI3BC,MAA6E,EAAE;AAC7E,EAAA,oBAAOC,KAAK,CAACC,UAAU,CAACF,MAAM,CAAC,CAAA;AAKnC;;;;"}
@@ -1,4 +1,14 @@
1
- var DEBUG = process.env.NODE_ENV === 'development';
1
+ /**
2
+ * A responsive prop supports receiving values of its given base type, or an object mapping a
3
+ * responsive breakpoint name to a value from the prop's base type.
4
+ *
5
+ * Some examples:
6
+ *
7
+ * - `align={{ mobile: 'left', tablet: 'center', desktop: 'right' }}`
8
+ */
9
+
10
+ const DEBUG = process.env.NODE_ENV === 'development';
11
+
2
12
  /**
3
13
  * Builds a css module class name for a given prop + prop-value combination.
4
14
  *
@@ -17,27 +27,28 @@ var DEBUG = process.env.NODE_ENV === 'development';
17
27
  * @param value the given prop's value
18
28
  */
19
29
  function getClassNames(styles, property, value) {
20
- if (!value) {
21
- return null;
22
- }
23
- var classList = [];
24
- if (typeof value === 'string') {
25
- classList.push(styles["".concat(property, "-").concat(value)]);
26
- }
27
- else {
28
- if (value.mobile)
29
- classList.push(styles["".concat(property, "-").concat(value.mobile)]);
30
- if (value.tablet)
31
- classList.push(styles["tablet-".concat(property, "-").concat(value.tablet)]);
32
- if (value.desktop)
33
- classList.push(styles["desktop-".concat(property, "-").concat(value.desktop)]);
34
- }
35
- if (DEBUG && !classList.every(Boolean)) {
36
- // eslint-disable-next-line no-console
37
- console.warn('Not all generated class names were found', { property: property, value: value, classList: classList });
38
- }
39
- return classList;
30
+ if (!value) {
31
+ return null;
32
+ }
33
+ const classList = [];
34
+ if (typeof value === 'string') {
35
+ classList.push(styles[`${property}-${value}`]);
36
+ } else {
37
+ if (value.mobile) classList.push(styles[`${property}-${value.mobile}`]);
38
+ if (value.tablet) classList.push(styles[`tablet-${property}-${value.tablet}`]);
39
+ if (value.desktop) classList.push(styles[`desktop-${property}-${value.desktop}`]);
40
+ }
41
+ if (DEBUG && !classList.every(Boolean)) {
42
+ // eslint-disable-next-line no-console
43
+ console.warn('Not all generated class names were found', {
44
+ property,
45
+ value,
46
+ classList
47
+ });
48
+ }
49
+ return classList;
40
50
  }
51
+
41
52
  /**
42
53
  * A mapping over a responsive prop value.
43
54
  *
@@ -49,17 +60,17 @@ function getClassNames(styles, property, value) {
49
60
  * @param mapper the mapping function
50
61
  */
51
62
  function mapResponsiveProp(fromValue, mapper) {
52
- if (!fromValue) {
53
- return undefined;
54
- }
55
- if (typeof fromValue !== 'object') {
56
- return mapper(fromValue);
57
- }
58
- return {
59
- mobile: fromValue.mobile ? mapper(fromValue.mobile) : undefined,
60
- tablet: fromValue.tablet ? mapper(fromValue.tablet) : undefined,
61
- desktop: fromValue.desktop ? mapper(fromValue.desktop) : undefined,
62
- };
63
+ if (!fromValue) {
64
+ return undefined;
65
+ }
66
+ if (typeof fromValue !== 'object') {
67
+ return mapper(fromValue);
68
+ }
69
+ return {
70
+ mobile: fromValue.mobile ? mapper(fromValue.mobile) : undefined,
71
+ tablet: fromValue.tablet ? mapper(fromValue.tablet) : undefined,
72
+ desktop: fromValue.desktop ? mapper(fromValue.desktop) : undefined
73
+ };
63
74
  }
64
75
 
65
76
  export { getClassNames, mapResponsiveProp };
@@ -1 +1 @@
1
- {"version":3,"file":"responsive-props.js","sources":["../../src/utils/responsive-props.ts"],"sourcesContent":[null],"names":[],"mappings":"AAgBA,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAA;AAEpD;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,aAAa,CAClB,MAA8B,EAC9B,QAAgB,EAChB,KAAgD,EAAA;IAEhD,IAAI,CAAC,KAAK,EAAE;AACR,QAAA,OAAO,IAAI,CAAA;KACd;IAED,IAAM,SAAS,GAA8B,EAAE,CAAA;AAE/C,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC3B,QAAA,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC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,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS;AAC/D,QAAA,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS;AAC/D,QAAA,OAAO,EAAE,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS;KACrE,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"responsive-props.js","sources":["../../src/utils/responsive-props.ts"],"sourcesContent":["type ResponsiveBreakpoints = 'mobile' | 'tablet' | 'desktop'\n\ntype Atom = string | number | boolean\n\n/**\n * A responsive prop supports receiving values of its given base type, or an object mapping a\n * responsive breakpoint name to a value from the prop's base type.\n *\n * Some examples:\n *\n * - `align={{ mobile: 'left', tablet: 'center', desktop: 'right' }}`\n */\ntype ResponsiveProp<AtomType extends Atom> =\n | AtomType\n | Readonly<{ [key in ResponsiveBreakpoints]?: AtomType }>\n\nconst DEBUG = process.env.NODE_ENV === 'development'\n\n/**\n * Builds a css module class name for a given prop + prop-value combination.\n *\n * We have a convention of building the internal utility-based class names system in a way that\n * resembles the prop for which it is used and the value of the prop. For instance, in a component\n * with a prop `width` with possible values `narrow` and `wide`, we encode the styles for each of\n * these alternatives in the class-names `.width-narrow` and `.width-wide`.\n *\n * Furthermore, this helper is aware of responsive prop values. For instance, if you provide the\n * `width` prop above with the value `['narrow', 'wide']` this returns `['narrow', 'tablet-wide']`.\n * That is, it returns an array of class names, following the same convention above, but also\n * prefixing by the viewport width variant (`tablet-` or `desktop-`).\n *\n * @param styles the class names mapping imported from a css module\n * @param property the prop name\n * @param value the given prop's value\n */\nfunction getClassNames(\n styles: Record<string, string>,\n property: string,\n value: ResponsiveProp<string> | null | undefined,\n): Array<string | undefined> | null {\n if (!value) {\n return null\n }\n\n const classList: Array<string | undefined> = []\n\n if (typeof value === 'string') {\n classList.push(styles[`${property}-${value}`])\n } else {\n if (value.mobile) classList.push(styles[`${property}-${value.mobile}`])\n if (value.tablet) classList.push(styles[`tablet-${property}-${value.tablet}`])\n if (value.desktop) classList.push(styles[`desktop-${property}-${value.desktop}`])\n }\n\n if (DEBUG && !classList.every(Boolean)) {\n // eslint-disable-next-line no-console\n console.warn('Not all generated class names were found', { property, value, classList })\n }\n\n return classList\n}\n\n/**\n * A mapping over a responsive prop value.\n *\n * Since response values can be an object but also a scalar value, this helper makes it easier to\n * to map the values when it's an object but keeps it consistent for the case when it is a scalar\n * value as well.\n *\n * @param fromValue the responsive prop value\n * @param mapper the mapping function\n */\nfunction mapResponsiveProp<From extends Atom, To extends Atom>(\n fromValue: ResponsiveProp<From> | undefined,\n mapper: (from: From) => To,\n): ResponsiveProp<To> | undefined {\n if (!fromValue) {\n return undefined\n }\n\n if (typeof fromValue !== 'object') {\n return mapper(fromValue)\n }\n\n return {\n mobile: fromValue.mobile ? mapper(fromValue.mobile) : undefined,\n tablet: fromValue.tablet ? mapper(fromValue.tablet) : undefined,\n desktop: fromValue.desktop ? mapper(fromValue.desktop) : undefined,\n }\n}\n\nexport type { ResponsiveBreakpoints, ResponsiveProp }\nexport { getClassNames, mapResponsiveProp }\n"],"names":["DEBUG","process","env","NODE_ENV","getClassNames","styles","property","value","classList","push","mobile","tablet","desktop","every","Boolean","console","warn","mapResponsiveProp","fromValue","mapper","undefined"],"mappings":"AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,MAAMA,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,CAAA;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAClBC,MAA8B,EAC9BC,QAAgB,EAChBC,KAAgD,EAChB;EAChC,IAAI,CAACA,KAAK,EAAE;AACR,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;EAEA,MAAMC,SAAoC,GAAG,EAAE,CAAA;AAE/C,EAAA,I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MAAM,CAACD,SAAS,CAAC,CAAA;AAC5B,GAAA;EAEA,OAAO;AACHR,IAAAA,MAAM,EAAEQ,SAAS,CAACR,MAAM,GAAGS,MAAM,CAACD,SAAS,CAACR,MAAM,CAAC,GAAGU,SAAS;AAC/DT,IAAAA,MAAM,EAAEO,SAAS,CAACP,MAAM,GAAGQ,MAAM,CAACD,SAAS,CAACP,MAAM,CAAC,GAAGS,SAAS;IAC/DR,OAAO,EAAEM,SAAS,CAACN,OAAO,GAAGO,MAAM,CAACD,SAAS,CAACN,OAAO,CAAC,GAAGQ,SAAAA;GAC5D,CAAA;AACL;;;;"}
@@ -2,13 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
5
+ var _extends = require('@babel/runtime/helpers/extends');
6
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
+ var reactCompilerRuntime = require('react-compiler-runtime');
6
8
  var React = require('react');
7
9
  var box = require('../box/box.js');
8
10
  var responsiveProps = require('../utils/responsive-props.js');
9
11
  var utils = require('./utils.js');
10
12
  var avatar_module = require('./avatar.module.css.js');
11
13
 
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
12
16
  function _interopNamespace(e) {
13
17
  if (e && e.__esModule) return e;
14
18
  var n = Object.create(null);
@@ -27,42 +31,112 @@ function _interopNamespace(e) {
27
31
  return Object.freeze(n);
28
32
  }
29
33
 
34
+ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
35
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
30
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
31
37
 
32
- var AVATAR_COLORS = [
33
- '#fcc652',
34
- '#e9952c',
35
- '#e16b2d',
36
- '#d84b40',
37
- '#e8435a',
38
- '#e5198a',
39
- '#ad3889',
40
- '#86389c',
41
- '#a8a8a8',
42
- '#98be2f',
43
- '#5d9d50',
44
- '#5f9f85',
45
- '#5bbcb6',
46
- '#32a3bf',
47
- '#2bafeb',
48
- '#2d88c3',
49
- '#3863cc',
50
- '#5e5e5e',
51
- ];
52
- function Avatar(_a) {
53
- var user = _a.user, avatarUrl = _a.avatarUrl, _b = _a.size, size = _b === void 0 ? 'l' : _b, className = _a.className, _c = _a.colorList, colorList = _c === void 0 ? AVATAR_COLORS : _c, exceptionallySetClassName = _a.exceptionallySetClassName, props = tslib.__rest(_a, ["user", "avatarUrl", "size", "className", "colorList", "exceptionallySetClassName"]);
54
- var userInitials = utils.getInitials(user.name) || utils.getInitials(user.email);
55
- var avatarSize = size ? size : 'l';
56
- var style = avatarUrl
57
- ? {
58
- backgroundImage: "url(".concat(avatarUrl, ")"),
59
- textIndent: '-9999px', // hide the initials
60
- }
61
- : {
62
- backgroundColor: colorList[utils.emailToIndex(user.email, colorList.length)],
63
- };
64
- var sizeClassName = responsiveProps.getClassNames(avatar_module["default"], 'size', avatarSize);
65
- return (React__namespace.createElement(box.Box, tslib.__assign({ className: [className, avatar_module["default"].avatar, sizeClassName, exceptionallySetClassName], style: style }, props), userInitials));
38
+ const _excluded = ["user", "avatarUrl", "size", "className", "colorList", "exceptionallySetClassName"];
39
+ const AVATAR_COLORS = ['#fcc652', '#e9952c', '#e16b2d', '#d84b40', '#e8435a', '#e5198a', '#ad3889', '#86389c', '#a8a8a8', '#98be2f', '#5d9d50', '#5f9f85', '#5bbcb6', '#32a3bf', '#2bafeb', '#2d88c3', '#3863cc', '#5e5e5e'];
40
+ function Avatar(t0) {
41
+ const $ = reactCompilerRuntime.c(26);
42
+ let avatarUrl;
43
+ let className;
44
+ let exceptionallySetClassName;
45
+ let props;
46
+ let t1;
47
+ let t2;
48
+ let user;
49
+ if ($[0] !== t0) {
50
+ var _t = t0;
51
+ ({
52
+ user,
53
+ avatarUrl,
54
+ size: t1,
55
+ className,
56
+ colorList: t2,
57
+ exceptionallySetClassName
58
+ } = _t);
59
+ props = _objectWithoutProperties__default["default"](_t, _excluded);
60
+ $[0] = t0;
61
+ $[1] = avatarUrl;
62
+ $[2] = className;
63
+ $[3] = exceptionallySetClassName;
64
+ $[4] = props;
65
+ $[5] = t1;
66
+ $[6] = t2;
67
+ $[7] = user;
68
+ } else {
69
+ avatarUrl = $[1];
70
+ className = $[2];
71
+ exceptionallySetClassName = $[3];
72
+ props = $[4];
73
+ t1 = $[5];
74
+ t2 = $[6];
75
+ user = $[7];
76
+ }
77
+ const size = t1 === undefined ? "l" : t1;
78
+ const colorList = t2 === undefined ? AVATAR_COLORS : t2;
79
+ let t3;
80
+ if ($[8] !== user.email || $[9] !== user.name) {
81
+ t3 = utils.getInitials(user.name) || utils.getInitials(user.email);
82
+ $[8] = user.email;
83
+ $[9] = user.name;
84
+ $[10] = t3;
85
+ } else {
86
+ t3 = $[10];
87
+ }
88
+ const userInitials = t3;
89
+ const avatarSize = size ? size : "l";
90
+ let t4;
91
+ if ($[11] !== avatarUrl || $[12] !== colorList || $[13] !== user.email) {
92
+ t4 = avatarUrl ? {
93
+ backgroundImage: `url(${avatarUrl})`,
94
+ textIndent: "-9999px"
95
+ } : {
96
+ backgroundColor: colorList[utils.emailToIndex(user.email, colorList.length)]
97
+ };
98
+ $[11] = avatarUrl;
99
+ $[12] = colorList;
100
+ $[13] = user.email;
101
+ $[14] = t4;
102
+ } else {
103
+ t4 = $[14];
104
+ }
105
+ const style = t4;
106
+ let t5;
107
+ if ($[15] !== avatarSize) {
108
+ t5 = responsiveProps.getClassNames(avatar_module["default"], "size", avatarSize);
109
+ $[15] = avatarSize;
110
+ $[16] = t5;
111
+ } else {
112
+ t5 = $[16];
113
+ }
114
+ const sizeClassName = t5;
115
+ let t6;
116
+ if ($[17] !== className || $[18] !== exceptionallySetClassName || $[19] !== sizeClassName) {
117
+ t6 = [className, avatar_module["default"].avatar, sizeClassName, exceptionallySetClassName];
118
+ $[17] = className;
119
+ $[18] = exceptionallySetClassName;
120
+ $[19] = sizeClassName;
121
+ $[20] = t6;
122
+ } else {
123
+ t6 = $[20];
124
+ }
125
+ let t7;
126
+ if ($[21] !== props || $[22] !== style || $[23] !== t6 || $[24] !== userInitials) {
127
+ t7 = /*#__PURE__*/React__namespace.createElement(box.Box, _extends__default["default"]({
128
+ className: t6,
129
+ style: style
130
+ }, props), userInitials);
131
+ $[21] = props;
132
+ $[22] = style;
133
+ $[23] = t6;
134
+ $[24] = userInitials;
135
+ $[25] = t7;
136
+ } else {
137
+ t7 = $[25];
138
+ }
139
+ return t7;
66
140
  }
67
141
  Avatar.displayName = 'Avatar';
68
142