@doist/reactist 11.6.0 → 12.0.1

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 (264) hide show
  1. package/dist/reactist.cjs.development.js +1335 -1493
  2. package/dist/reactist.cjs.development.js.map +1 -1
  3. package/dist/reactist.cjs.production.min.js +1 -1
  4. package/dist/reactist.cjs.production.min.js.map +1 -1
  5. package/es/_virtual/_rollupPluginBabelHelpers.js +18 -21
  6. package/es/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  7. package/es/components/checkbox/checkbox.js +7 -9
  8. package/es/components/checkbox/checkbox.js.map +1 -1
  9. package/es/components/color-picker/color-picker.js +24 -28
  10. package/es/components/color-picker/color-picker.js.map +1 -1
  11. package/es/components/deprecated-button/deprecated-button.js +16 -18
  12. package/es/components/deprecated-button/deprecated-button.js.map +1 -1
  13. package/es/components/deprecated-loading/deprecated-loading.js +7 -10
  14. package/es/components/deprecated-loading/deprecated-loading.js.map +1 -1
  15. package/es/components/deprecated-modal/deprecated-modal.js +69 -101
  16. package/es/components/deprecated-modal/deprecated-modal.js.map +1 -1
  17. package/es/components/deprecated-modal/index.js +4 -4
  18. package/es/components/deprecated-modal/index.js.map +1 -1
  19. package/es/components/dropdown/dropdown.js +86 -85
  20. package/es/components/dropdown/dropdown.js.map +1 -1
  21. package/es/components/icons/CloseIcon.svg.js +9 -11
  22. package/es/components/icons/CloseIcon.svg.js.map +1 -1
  23. package/es/components/input/input.js +4 -3
  24. package/es/components/input/input.js.map +1 -1
  25. package/es/components/key-capturer/key-capturer.js +22 -19
  26. package/es/components/key-capturer/key-capturer.js.map +1 -1
  27. package/es/components/keyboard-shortcut/keyboard-shortcut.js +20 -26
  28. package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  29. package/es/components/menu/menu.js +112 -142
  30. package/es/components/menu/menu.js.map +1 -1
  31. package/es/components/notification/notification.js +32 -32
  32. package/es/components/notification/notification.js.map +1 -1
  33. package/es/components/popover/popover.js +85 -91
  34. package/es/components/popover/popover.js.map +1 -1
  35. package/es/components/popover/positioning-utils.js +49 -65
  36. package/es/components/popover/positioning-utils.js.map +1 -1
  37. package/es/components/progress-bar/progress-bar.js +8 -8
  38. package/es/components/progress-bar/progress-bar.js.map +1 -1
  39. package/es/components/select/select.js +20 -25
  40. package/es/components/select/select.js.map +1 -1
  41. package/es/components/time/time-utils.js +30 -47
  42. package/es/components/time/time-utils.js.map +1 -1
  43. package/es/components/time/time.js +43 -56
  44. package/es/components/time/time.js.map +1 -1
  45. package/es/components/tooltip/tooltip.js +43 -46
  46. package/es/components/tooltip/tooltip.js.map +1 -1
  47. package/es/hooks/use-previous/use-previous.js +2 -2
  48. package/es/hooks/use-previous/use-previous.js.map +1 -1
  49. package/es/new-components/alert/alert.js +7 -6
  50. package/es/new-components/alert/alert.js.map +1 -1
  51. package/es/new-components/avatar/avatar.js +19 -18
  52. package/es/new-components/avatar/avatar.js.map +1 -1
  53. package/es/new-components/avatar/utils.js +12 -9
  54. package/es/new-components/avatar/utils.js.map +1 -1
  55. package/es/new-components/base-button/base-button.js +25 -29
  56. package/es/new-components/base-button/base-button.js.map +1 -1
  57. package/es/new-components/base-field/base-field.js +20 -18
  58. package/es/new-components/base-field/base-field.js.map +1 -1
  59. package/es/new-components/box/box.js +51 -52
  60. package/es/new-components/box/box.js.map +1 -1
  61. package/es/new-components/button/button.js +13 -15
  62. package/es/new-components/button/button.js.map +1 -1
  63. package/es/new-components/button-link/button-link.js +13 -15
  64. package/es/new-components/button-link/button-link.js.map +1 -1
  65. package/es/new-components/checkbox-field/checkbox-field.js +25 -33
  66. package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
  67. package/es/new-components/checkbox-field/checkbox-icon.js +21 -19
  68. package/es/new-components/checkbox-field/checkbox-icon.js.map +1 -1
  69. package/es/new-components/columns/columns.js +24 -27
  70. package/es/new-components/columns/columns.js.map +1 -1
  71. package/es/new-components/common-helpers.js +3 -3
  72. package/es/new-components/common-helpers.js.map +1 -1
  73. package/es/new-components/divider/divider.js +7 -6
  74. package/es/new-components/divider/divider.js.map +1 -1
  75. package/es/new-components/heading/heading.js +17 -17
  76. package/es/new-components/heading/heading.js.map +1 -1
  77. package/es/new-components/hidden/hidden.js +14 -13
  78. package/es/new-components/hidden/hidden.js.map +1 -1
  79. package/es/new-components/hidden-visually/hidden-visually.js +3 -2
  80. package/es/new-components/hidden-visually/hidden-visually.js.map +1 -1
  81. package/es/new-components/icons/alert-icon.js +13 -11
  82. package/es/new-components/icons/alert-icon.js.map +1 -1
  83. package/es/new-components/icons/close-icon.js +2 -1
  84. package/es/new-components/icons/close-icon.js.map +1 -1
  85. package/es/new-components/icons/password-hidden-icon.js +2 -1
  86. package/es/new-components/icons/password-hidden-icon.js.map +1 -1
  87. package/es/new-components/icons/password-visible-icon.js +2 -1
  88. package/es/new-components/icons/password-visible-icon.js.map +1 -1
  89. package/es/new-components/inline/inline.js +15 -19
  90. package/es/new-components/inline/inline.js.map +1 -1
  91. package/es/new-components/loading/loading.js +11 -10
  92. package/es/new-components/loading/loading.js.map +1 -1
  93. package/es/new-components/modal/modal.js +60 -64
  94. package/es/new-components/modal/modal.js.map +1 -1
  95. package/es/new-components/notice/notice.js +5 -4
  96. package/es/new-components/notice/notice.js.map +1 -1
  97. package/es/new-components/password-field/password-field.js +40 -46
  98. package/es/new-components/password-field/password-field.js.map +1 -1
  99. package/es/new-components/responsive-props.js +5 -5
  100. package/es/new-components/responsive-props.js.map +1 -1
  101. package/es/new-components/select-field/select-field.js +23 -23
  102. package/es/new-components/select-field/select-field.js.map +1 -1
  103. package/es/new-components/spinner/spinner.js +3 -3
  104. package/es/new-components/spinner/spinner.js.map +1 -1
  105. package/es/new-components/stack/stack.js +18 -22
  106. package/es/new-components/stack/stack.js.map +1 -1
  107. package/es/new-components/switch-field/switch-field.js +31 -41
  108. package/es/new-components/switch-field/switch-field.js.map +1 -1
  109. package/es/new-components/tabs/tabs.js +92 -78
  110. package/es/new-components/tabs/tabs.js.map +1 -1
  111. package/es/new-components/tabs/tabs.module.css.js +1 -1
  112. package/es/new-components/text/text.js +16 -17
  113. package/es/new-components/text/text.js.map +1 -1
  114. package/es/new-components/text-area/text-area.js +14 -14
  115. package/es/new-components/text-area/text-area.js.map +1 -1
  116. package/es/new-components/text-field/text-field.js +21 -22
  117. package/es/new-components/text-field/text-field.js.map +1 -1
  118. package/es/new-components/text-link/text-link.js +10 -10
  119. package/es/new-components/text-link/text-link.js.map +1 -1
  120. package/es/utils/polymorphism.js.map +1 -1
  121. package/lib/_virtual/_rollupPluginBabelHelpers.js +1 -1
  122. package/lib/components/checkbox/checkbox.js +1 -1
  123. package/lib/components/checkbox/checkbox.js.map +1 -1
  124. package/lib/components/color-picker/color-picker.js +1 -1
  125. package/lib/components/color-picker/color-picker.js.map +1 -1
  126. package/lib/components/deprecated-button/deprecated-button.d.ts +3 -3
  127. package/lib/components/deprecated-button/deprecated-button.js +1 -1
  128. package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
  129. package/lib/components/deprecated-loading/deprecated-loading.js +1 -1
  130. package/lib/components/deprecated-loading/deprecated-loading.js.map +1 -1
  131. package/lib/components/deprecated-modal/deprecated-modal.d.ts +2 -2
  132. package/lib/components/deprecated-modal/deprecated-modal.js +1 -1
  133. package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -1
  134. package/lib/components/deprecated-modal/index.js.map +1 -1
  135. package/lib/components/dropdown/dropdown.d.ts +5 -2
  136. package/lib/components/dropdown/dropdown.js +1 -1
  137. package/lib/components/dropdown/dropdown.js.map +1 -1
  138. package/lib/components/icons/CloseIcon.svg.js +1 -1
  139. package/lib/components/icons/CloseIcon.svg.js.map +1 -1
  140. package/lib/components/input/input.js +1 -1
  141. package/lib/components/input/input.js.map +1 -1
  142. package/lib/components/key-capturer/key-capturer.d.ts +1 -1
  143. package/lib/components/key-capturer/key-capturer.js +1 -1
  144. package/lib/components/key-capturer/key-capturer.js.map +1 -1
  145. package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
  146. package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  147. package/lib/components/menu/menu.d.ts +7 -7
  148. package/lib/components/menu/menu.js +1 -1
  149. package/lib/components/menu/menu.js.map +1 -1
  150. package/lib/components/notification/notification.js +1 -1
  151. package/lib/components/notification/notification.js.map +1 -1
  152. package/lib/components/popover/popover.d.ts +1 -1
  153. package/lib/components/popover/popover.js +1 -1
  154. package/lib/components/popover/popover.js.map +1 -1
  155. package/lib/components/popover/positioning-utils.js +1 -1
  156. package/lib/components/popover/positioning-utils.js.map +1 -1
  157. package/lib/components/progress-bar/progress-bar.js +1 -1
  158. package/lib/components/progress-bar/progress-bar.js.map +1 -1
  159. package/lib/components/select/select.js +1 -1
  160. package/lib/components/select/select.js.map +1 -1
  161. package/lib/components/time/time-utils.js +1 -1
  162. package/lib/components/time/time-utils.js.map +1 -1
  163. package/lib/components/time/time.js +1 -1
  164. package/lib/components/time/time.js.map +1 -1
  165. package/lib/components/tooltip/index.d.ts +1 -2
  166. package/lib/components/tooltip/tooltip.d.ts +3 -3
  167. package/lib/components/tooltip/tooltip.js +1 -1
  168. package/lib/components/tooltip/tooltip.js.map +1 -1
  169. package/lib/hooks/use-previous/use-previous.js +1 -1
  170. package/lib/hooks/use-previous/use-previous.js.map +1 -1
  171. package/lib/index.d.ts +2 -1
  172. package/lib/new-components/alert/alert.d.ts +1 -1
  173. package/lib/new-components/alert/alert.js +1 -1
  174. package/lib/new-components/alert/alert.js.map +1 -1
  175. package/lib/new-components/avatar/avatar.js +1 -1
  176. package/lib/new-components/avatar/avatar.js.map +1 -1
  177. package/lib/new-components/avatar/utils.d.ts +1 -1
  178. package/lib/new-components/avatar/utils.js +1 -1
  179. package/lib/new-components/avatar/utils.js.map +1 -1
  180. package/lib/new-components/base-button/base-button.js +1 -1
  181. package/lib/new-components/base-button/base-button.js.map +1 -1
  182. package/lib/new-components/base-field/base-field.d.ts +1 -1
  183. package/lib/new-components/base-field/base-field.js +1 -1
  184. package/lib/new-components/base-field/base-field.js.map +1 -1
  185. package/lib/new-components/box/box.js +1 -1
  186. package/lib/new-components/box/box.js.map +1 -1
  187. package/lib/new-components/button/button.d.ts +1 -58
  188. package/lib/new-components/button/button.js +1 -1
  189. package/lib/new-components/button/button.js.map +1 -1
  190. package/lib/new-components/button-link/button-link.js +1 -1
  191. package/lib/new-components/button-link/button-link.js.map +1 -1
  192. package/lib/new-components/checkbox-field/checkbox-field.d.ts +1 -1
  193. package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
  194. package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
  195. package/lib/new-components/checkbox-field/checkbox-icon.js +1 -1
  196. package/lib/new-components/checkbox-field/checkbox-icon.js.map +1 -1
  197. package/lib/new-components/columns/columns.js +1 -1
  198. package/lib/new-components/columns/columns.js.map +1 -1
  199. package/lib/new-components/common-helpers.js +1 -1
  200. package/lib/new-components/common-helpers.js.map +1 -1
  201. package/lib/new-components/common-types.d.ts +1 -1
  202. package/lib/new-components/divider/divider.js +1 -1
  203. package/lib/new-components/divider/divider.js.map +1 -1
  204. package/lib/new-components/heading/heading.d.ts +2 -2
  205. package/lib/new-components/heading/heading.js +1 -1
  206. package/lib/new-components/heading/heading.js.map +1 -1
  207. package/lib/new-components/hidden/hidden.js +1 -1
  208. package/lib/new-components/hidden/hidden.js.map +1 -1
  209. package/lib/new-components/hidden-visually/hidden-visually.js +1 -1
  210. package/lib/new-components/hidden-visually/hidden-visually.js.map +1 -1
  211. package/lib/new-components/icons/alert-icon.d.ts +1 -1
  212. package/lib/new-components/icons/alert-icon.js +1 -1
  213. package/lib/new-components/icons/alert-icon.js.map +1 -1
  214. package/lib/new-components/icons/close-icon.js +1 -1
  215. package/lib/new-components/icons/close-icon.js.map +1 -1
  216. package/lib/new-components/icons/password-hidden-icon.js +1 -1
  217. package/lib/new-components/icons/password-hidden-icon.js.map +1 -1
  218. package/lib/new-components/icons/password-visible-icon.js +1 -1
  219. package/lib/new-components/icons/password-visible-icon.js.map +1 -1
  220. package/lib/new-components/inline/inline.js +1 -1
  221. package/lib/new-components/inline/inline.js.map +1 -1
  222. package/lib/new-components/loading/loading.js +1 -1
  223. package/lib/new-components/loading/loading.js.map +1 -1
  224. package/lib/new-components/modal/modal.js +1 -1
  225. package/lib/new-components/modal/modal.js.map +1 -1
  226. package/lib/new-components/notice/notice.d.ts +1 -1
  227. package/lib/new-components/notice/notice.js +1 -1
  228. package/lib/new-components/notice/notice.js.map +1 -1
  229. package/lib/new-components/password-field/password-field.d.ts +1 -1
  230. package/lib/new-components/password-field/password-field.js +1 -1
  231. package/lib/new-components/password-field/password-field.js.map +1 -1
  232. package/lib/new-components/responsive-props.d.ts +1 -1
  233. package/lib/new-components/responsive-props.js +1 -1
  234. package/lib/new-components/responsive-props.js.map +1 -1
  235. package/lib/new-components/select-field/select-field.d.ts +1 -1
  236. package/lib/new-components/select-field/select-field.js +1 -1
  237. package/lib/new-components/select-field/select-field.js.map +1 -1
  238. package/lib/new-components/spinner/spinner.js +1 -1
  239. package/lib/new-components/spinner/spinner.js.map +1 -1
  240. package/lib/new-components/stack/stack.js +1 -1
  241. package/lib/new-components/stack/stack.js.map +1 -1
  242. package/lib/new-components/switch-field/switch-field.d.ts +1 -1
  243. package/lib/new-components/switch-field/switch-field.js +1 -1
  244. package/lib/new-components/switch-field/switch-field.js.map +1 -1
  245. package/lib/new-components/tabs/tabs.d.ts +13 -3
  246. package/lib/new-components/tabs/tabs.js +1 -1
  247. package/lib/new-components/tabs/tabs.js.map +1 -1
  248. package/lib/new-components/tabs/tabs.module.css.js +1 -1
  249. package/lib/new-components/test-helpers.d.ts +4 -3
  250. package/lib/new-components/text/text.js +1 -1
  251. package/lib/new-components/text/text.js.map +1 -1
  252. package/lib/new-components/text-area/text-area.js +1 -1
  253. package/lib/new-components/text-area/text-area.js.map +1 -1
  254. package/lib/new-components/text-field/text-field.d.ts +1 -1
  255. package/lib/new-components/text-field/text-field.js +1 -1
  256. package/lib/new-components/text-field/text-field.js.map +1 -1
  257. package/lib/new-components/text-link/text-link.js +1 -1
  258. package/lib/new-components/text-link/text-link.js.map +1 -1
  259. package/lib/utils/polymorphism.js.map +1 -1
  260. package/package.json +45 -38
  261. package/styles/menu.css +1 -1
  262. package/styles/reactist.css +2 -2
  263. package/styles/tabs.css +1 -1
  264. package/styles/tabs.module.css.css +1 -1
@@ -1,49 +1,49 @@
1
- import { objectSpread2 as _objectSpread2, objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { useEffect, useMemo, createElement, useContext, useState, createContext } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { polymorphicComponent } from '../../utils/polymorphism.js';
5
5
  import { Inline } from '../inline/inline.js';
6
- import { useTabState, Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1 } from 'reakit/Tab';
6
+ import { useTabState, Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1 } from 'ariakit/tab';
7
7
  import { usePrevious } from '../../hooks/use-previous/use-previous.js';
8
8
  import styles from './tabs.module.css.js';
9
9
 
10
- var _excluded = ["color", "variant"],
11
- _excluded2 = ["children", "space"],
12
- _excluded3 = ["color", "variant"],
13
- _excluded4 = ["children", "id", "as", "render"],
14
- _excluded5 = ["color", "variant"];
15
- var TabsContext = /*#__PURE__*/createContext(null);
10
+ const _excluded = ["as", "children", "id", "exceptionallySetClassName"],
11
+ _excluded2 = ["children", "space"],
12
+ _excluded3 = ["children", "id", "as", "render"];
13
+ const TabsContext = /*#__PURE__*/createContext(null);
16
14
  /**
17
15
  * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.
18
16
  */
19
17
 
20
- function Tabs(_ref) {
21
- var children = _ref.children,
22
- selectedId = _ref.selectedId,
23
- _ref$color = _ref.color,
24
- color = _ref$color === void 0 ? 'primary' : _ref$color,
25
- _ref$variant = _ref.variant,
26
- variant = _ref$variant === void 0 ? 'normal' : _ref$variant;
27
- var tabState = useTabState({
28
- selectedId: selectedId
18
+ function Tabs({
19
+ children,
20
+ selectedId,
21
+ defaultSelectedId,
22
+ color = 'primary',
23
+ variant = 'normal',
24
+ onSelectedIdChange
25
+ }) {
26
+ const tabState = useTabState({
27
+ selectedId,
28
+ setSelectedId: onSelectedIdChange
29
29
  });
30
- var previousSelectedId = usePrevious(selectedId);
31
- var actualSelectedId = tabState.selectedId,
32
- select = tabState.select;
33
- useEffect(function selectTab() {
34
- if (previousSelectedId !== selectedId && selectedId !== actualSelectedId && selectedId !== undefined) {
35
- select(selectedId);
30
+ const previousDefaultSelectedId = usePrevious(defaultSelectedId);
31
+ const {
32
+ selectedId: actualSelectedId,
33
+ select
34
+ } = tabState;
35
+ useEffect(function selectDefaultTab() {
36
+ if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
37
+ select(defaultSelectedId);
36
38
  }
37
- }, [selectedId, actualSelectedId, select, previousSelectedId]);
38
- var memoizedTabState = useMemo(function memoizeTabState() {
39
- return _objectSpread2(_objectSpread2({}, tabState), {}, {
40
- color: color,
41
- variant: variant
42
- });
43
- }, // There is no guarantee that useTabState returns a stable object when there are no changes, so
44
- // following reakit/Tab's example we only return a new objet when any of its values have changed
45
- // eslint-disable-next-line
46
- [color, variant].concat(Object.values(tabState)));
39
+ }, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
40
+ const memoizedTabState = useMemo(function memoizeTabState() {
41
+ return {
42
+ tabState,
43
+ color,
44
+ variant
45
+ };
46
+ }, [color, variant, tabState]);
47
47
  return /*#__PURE__*/createElement(TabsContext.Provider, {
48
48
  value: memoizedTabState
49
49
  }, children);
@@ -52,43 +52,57 @@ function Tabs(_ref) {
52
52
  * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.
53
53
  */
54
54
 
55
- function Tab(_ref2) {
56
- var children = _ref2.children,
57
- id = _ref2.id;
58
- var tabContextValue = useContext(TabsContext);
55
+ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
56
+ let {
57
+ as,
58
+ children,
59
+ id,
60
+ exceptionallySetClassName
61
+ } = _ref,
62
+ props = _objectWithoutProperties(_ref, _excluded);
63
+
64
+ const tabContextValue = useContext(TabsContext);
59
65
 
60
66
  if (!tabContextValue) {
61
67
  return null;
62
68
  }
63
69
 
64
- var color = tabContextValue.color,
65
- variant = tabContextValue.variant,
66
- tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded);
67
-
68
- return /*#__PURE__*/createElement(Tab$1, Object.assign({
69
- className: classNames(styles.tab, styles["tab-" + (variant !== null && variant !== void 0 ? variant : '')], styles["tab-" + (color !== null && color !== void 0 ? color : '')]),
70
- id: id
71
- }, tabState), children);
72
- }
70
+ const {
71
+ color,
72
+ variant,
73
+ tabState
74
+ } = tabContextValue;
75
+ return /*#__PURE__*/createElement(Tab$1, _objectSpread2(_objectSpread2({}, props), {}, {
76
+ as: as,
77
+ className: classNames(exceptionallySetClassName, styles.tab, styles["tab-" + (variant != null ? variant : '')], styles["tab-" + (color != null ? color : '')]),
78
+ id: id,
79
+ state: tabState,
80
+ ref: ref
81
+ }), children);
82
+ });
73
83
  /**
74
84
  * A component used to group `<Tab>` elements together.
75
85
  */
76
86
 
77
- function TabList(_ref3) {
78
- var children = _ref3.children,
79
- _ref3$space = _ref3.space,
80
- space = _ref3$space === void 0 ? 'medium' : _ref3$space,
81
- props = _objectWithoutPropertiesLoose(_ref3, _excluded2);
87
+ function TabList(_ref2) {
88
+ let {
89
+ children,
90
+ space = 'medium'
91
+ } = _ref2,
92
+ props = _objectWithoutProperties(_ref2, _excluded2);
82
93
 
83
- var tabContextValue = useContext(TabsContext);
94
+ const tabContextValue = useContext(TabsContext);
84
95
 
85
96
  if (!tabContextValue) {
86
97
  return null;
87
98
  }
88
99
 
89
- var tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded3);
90
-
91
- return /*#__PURE__*/createElement(TabList$1, Object.assign({}, props, tabState), /*#__PURE__*/createElement(Inline, {
100
+ const {
101
+ tabState
102
+ } = tabContextValue;
103
+ return /*#__PURE__*/createElement(TabList$1, _objectSpread2({
104
+ state: tabState
105
+ }, props), /*#__PURE__*/createElement(Inline, {
92
106
  space: space
93
107
  }, children));
94
108
  }
@@ -96,21 +110,18 @@ function TabList(_ref3) {
96
110
  * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
97
111
  */
98
112
 
99
- var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
100
- var children = _ref4.children,
101
- id = _ref4.id,
102
- as = _ref4.as,
103
- _ref4$render = _ref4.render,
104
- render = _ref4$render === void 0 ? 'always' : _ref4$render,
105
- props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
106
-
107
- var tabContextValue = useContext(TabsContext);
108
-
109
- var _React$useState = useState(false),
110
- tabRendered = _React$useState[0],
111
- setTabRendered = _React$useState[1];
112
-
113
- var tabIsActive = (tabContextValue === null || tabContextValue === void 0 ? void 0 : tabContextValue.selectedId) === id;
113
+ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
114
+ let {
115
+ children,
116
+ id,
117
+ as,
118
+ render = 'always'
119
+ } = _ref3,
120
+ props = _objectWithoutProperties(_ref3, _excluded3);
121
+
122
+ const tabContextValue = useContext(TabsContext);
123
+ const [tabRendered, setTabRendered] = useState(false);
124
+ const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
114
125
  useEffect(function trackTabRenderedState() {
115
126
  if (!tabRendered && tabIsActive) {
116
127
  setTabRendered(true);
@@ -121,11 +132,13 @@ var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
121
132
  return null;
122
133
  }
123
134
 
124
- var tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded5);
125
-
126
- return /*#__PURE__*/createElement(TabPanel$1, Object.assign({
135
+ const {
136
+ tabState
137
+ } = tabContextValue;
138
+ return /*#__PURE__*/createElement(TabPanel$1, _objectSpread2(_objectSpread2({
127
139
  tabId: id
128
- }, tabState, props, {
140
+ }, props), {}, {
141
+ state: tabState,
129
142
  as: as,
130
143
  ref: ref
131
144
  }), render === 'always' ? children : null, render === 'active' && tabIsActive ? children : null, render === 'lazy' && (tabIsActive || tabRendered) ? children : null);
@@ -135,11 +148,12 @@ var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
135
148
  * component. Can be placed freely within the main `<Tabs>` component.
136
149
  */
137
150
 
138
- function TabAwareSlot(_ref5) {
139
- var children = _ref5.children;
140
- var tabContextValue = useContext(TabsContext);
151
+ function TabAwareSlot({
152
+ children
153
+ }) {
154
+ const tabContextValue = useContext(TabsContext);
141
155
  return tabContextValue ? children({
142
- selectedId: tabContextValue.selectedId
156
+ selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
143
157
  }) : null;
144
158
  }
145
159
 
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStateReturn,\n} from 'reakit/Tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\nconst TabsContext = React.createContext<\n (TabStateReturn & Omit<TabsProps, 'children' | 'selectedId'>) | null\n>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab\n */\n selectedId?: string | null\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nexport function Tabs({\n children,\n selectedId,\n color = 'primary',\n variant = 'normal',\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId })\n const previousSelectedId = usePrevious(selectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectTab() {\n if (\n previousSelectedId !== selectedId &&\n selectedId !== actualSelectedId &&\n selectedId !== undefined\n ) {\n select(selectedId)\n }\n },\n [selectedId, actualSelectedId, select, previousSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n ...tabState,\n color,\n variant,\n }\n },\n // There is no guarantee that useTabState returns a stable object when there are no changes, so\n // following reakit/Tab's example we only return a new objet when any of its values have changed\n // eslint-disable-next-line\n [color, variant, ...Object.values(tabState)],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nexport function Tab({ children, id }: TabProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTab\n className={classNames(\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n {...tabState}\n >\n {children}\n </BaseTab>\n )\n}\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nexport function TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabList {...props} {...tabState}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nexport const TabPanel = polymorphicComponent<'div', TabPanelProps, 'omitClassName'>(\n function TabPanel(\n { children, id, as, render = 'always', ...props },\n ref,\n ): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...tabState} {...props} as={as} ref={ref}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n },\n)\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nexport function TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue.selectedId }) : null\n}\n"],"names":["TabsContext","React","Tabs","children","selectedId","color","variant","tabState","useTabState","previousSelectedId","usePrevious","actualSelectedId","select","selectTab","undefined","memoizedTabState","memoizeTabState","Object","values","Provider","value","Tab","id","tabContextValue","BaseTab","className","classNames","styles","tab","TabList","space","props","BaseTabList","Inline","TabPanel","polymorphicComponent","ref","as","render","tabRendered","setTabRendered","tabIsActive","trackTabRenderedState","BaseTabPanel","tabId","TabAwareSlot"],"mappings":"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"}
1
+ {"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabState,\n} from 'ariakit/tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\ntype TabsContextValue = {\n tabState: TabState\n} & Pick<TabsProps, 'color' | 'variant'>\n\nconst TabsContext = React.createContext<TabsContextValue | null>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab. Assigning a value makes this a\n * controlled component\n */\n selectedId?: string | null\n /**\n * The tab to initially select. This can be used if the component should not\n * be a controlled component but needs to have a tab selected\n */\n defaultSelectedId?: string | null\n /**\n * Called with the tab id when a tab is selected\n */\n onSelectedIdChange?: (selectedId: string | null | undefined) => void\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nexport function Tabs({\n children,\n selectedId,\n defaultSelectedId,\n color = 'primary',\n variant = 'normal',\n onSelectedIdChange,\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId, setSelectedId: onSelectedIdChange })\n const previousDefaultSelectedId = usePrevious(defaultSelectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectDefaultTab() {\n if (\n !selectedId &&\n defaultSelectedId !== previousDefaultSelectedId &&\n defaultSelectedId !== actualSelectedId &&\n defaultSelectedId !== undefined\n ) {\n select(defaultSelectedId)\n }\n },\n [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n tabState,\n color,\n variant,\n }\n },\n [color, variant, tabState],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nexport const Tab = polymorphicComponent<'button', TabProps>(function Tab(\n { as, children, id, exceptionallySetClassName, ...props },\n ref,\n): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, tabState } = tabContextValue\n\n return (\n <BaseTab\n {...props}\n as={as}\n className={classNames(\n exceptionallySetClassName,\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n state={tabState}\n ref={ref}\n >\n {children}\n </BaseTab>\n )\n})\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nexport function TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { tabState } = tabContextValue\n\n return (\n <BaseTabList state={tabState} {...props}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nexport const TabPanel = polymorphicComponent<'div', TabPanelProps, 'omitClassName'>(\n function TabPanel(\n { children, id, as, render = 'always', ...props },\n ref,\n ): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.tabState.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...props} state={tabState} as={as} ref={ref}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n },\n)\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nexport function TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue?.tabState.selectedId }) : null\n}\n"],"names":["TabsContext","React","Tabs","children","selectedId","defaultSelectedId","color","variant","onSelectedIdChange","tabState","useTabState","setSelectedId","previousDefaultSelectedId","usePrevious","actualSelectedId","select","selectDefaultTab","undefined","memoizedTabState","memoizeTabState","Provider","value","Tab","polymorphicComponent","ref","as","id","exceptionallySetClassName","props","tabContextValue","BaseTab","className","classNames","styles","tab","state","TabList","space","BaseTabList","Inline","TabPanel","render","tabRendered","setTabRendered","tabIsActive","trackTabRenderedState","BaseTabPanel","tabId","TabAwareSlot"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- var modules_40c67f5b = {"tab":"bae5f7d8","tab-normal":"ad3e25c3","tab-primary":"_3a9a0bad","tab-secondary":"_143d4b7d","tab-tertiary":"c9c5d77d","tab-plain":"_92c440c0"};
1
+ var modules_40c67f5b = {"tab":"_15d4bbf4","tab-normal":"ca31866d","tab-primary":"_421272bd","tab-secondary":"acbdf95a","tab-tertiary":"_8c59ab40","tab-plain":"a41904c9"};
2
2
 
3
3
  export default modules_40c67f5b;
4
4
  //# sourceMappingURL=tabs.module.css.js.map
@@ -1,27 +1,26 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { createElement } from 'react';
3
3
  import { polymorphicComponent } from '../../utils/polymorphism.js';
4
4
  import { getClassNames } from '../responsive-props.js';
5
5
  import { Box } from '../box/box.js';
6
6
  import styles from './text.module.css.js';
7
7
 
8
- var _excluded = ["as", "size", "weight", "tone", "align", "children", "lineClamp", "exceptionallySetClassName"];
9
- var Text = /*#__PURE__*/polymorphicComponent(function Text(_ref, ref) {
10
- var as = _ref.as,
11
- _ref$size = _ref.size,
12
- size = _ref$size === void 0 ? 'body' : _ref$size,
13
- _ref$weight = _ref.weight,
14
- weight = _ref$weight === void 0 ? 'regular' : _ref$weight,
15
- _ref$tone = _ref.tone,
16
- tone = _ref$tone === void 0 ? 'normal' : _ref$tone,
17
- align = _ref.align,
18
- children = _ref.children,
19
- lineClamp = _ref.lineClamp,
20
- exceptionallySetClassName = _ref.exceptionallySetClassName,
21
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
8
+ const _excluded = ["as", "size", "weight", "tone", "align", "children", "lineClamp", "exceptionallySetClassName"];
9
+ const Text = /*#__PURE__*/polymorphicComponent(function Text(_ref, ref) {
10
+ let {
11
+ as,
12
+ size = 'body',
13
+ weight = 'regular',
14
+ tone = 'normal',
15
+ align,
16
+ children,
17
+ lineClamp,
18
+ exceptionallySetClassName
19
+ } = _ref,
20
+ props = _objectWithoutProperties(_ref, _excluded);
22
21
 
23
- var lineClampMultipleLines = typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp !== null && lineClamp !== void 0 ? lineClamp : 1) > 1;
24
- return /*#__PURE__*/createElement(Box, Object.assign({}, props, {
22
+ const lineClampMultipleLines = typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp != null ? lineClamp : 1) > 1;
23
+ return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
25
24
  as: as,
26
25
  className: [exceptionallySetClassName, styles.text, size !== 'body' ? getClassNames(styles, 'size', size) : null, weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null, tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null, lineClampMultipleLines ? styles.lineClampMultipleLines : null, lineClamp ? getClassNames(styles, 'lineClamp', lineClamp.toString()) : null],
27
26
  textAlign: align,
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sources":["../../../src/new-components/text/text.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../responsive-props'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\nimport type { Tone } from '../common-types'\nimport type { BoxProps } from '../box'\n\nimport styles from './text.module.css'\n\ntype TextProps = {\n children: React.ReactNode\n /**\n * The size of the text.\n *\n * The supported values, from smaller size to larger size, are:\n * 'caption', 'copy', 'body', and 'subtitle'\n *\n * @default 'body'\n */\n size?: 'caption' | 'copy' | 'body' | 'subtitle'\n /**\n * The weight of the text font.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'semibold' | 'bold'\n /**\n * The tone (semantic color) of the text.\n *\n * @default 'normal'\n */\n tone?: Tone\n /**\n * Used to truncate the text 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 * How to align the text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Text = polymorphicComponent<'div', TextProps>(function Text(\n {\n as,\n size = 'body',\n weight = 'regular',\n tone = 'normal',\n align,\n children,\n lineClamp,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp ?? 1) > 1\n\n return (\n <Box\n {...props}\n as={as}\n className={[\n exceptionallySetClassName,\n styles.text,\n size !== 'body' ? getClassNames(styles, 'size', size) : null,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\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 ref={ref}\n >\n {children}\n </Box>\n )\n})\n\nexport type { TextProps }\nexport { Text }\n"],"names":["Text","polymorphicComponent","ref","as","size","weight","tone","align","children","lineClamp","exceptionallySetClassName","props","lineClampMultipleLines","Number","React","Box","className","styles","text","getClassNames","toString","textAlign","paddingRight","undefined"],"mappings":";;;;;;;;IAoDMA,IAAI,gBAAGC,oBAAoB,CAAmB,SAASD,IAAT,OAYhDE,GAZgD;MAE5CC,UAAAA;uBACAC;MAAAA,8BAAO;yBACPC;MAAAA,kCAAS;uBACTC;MAAAA,8BAAO;MACPC,aAAAA;MACAC,gBAAAA;MACAC,iBAAAA;MACAC,iCAAAA;MACGC;;AAIP,MAAMC,sBAAsB,GACxB,OAAOH,SAAP,KAAqB,QAArB,GAAgCI,MAAM,CAACJ,SAAD,CAAN,GAAoB,CAApD,GAAwD,CAACA,SAAD,aAACA,SAAD,cAACA,SAAD,GAAc,CAAd,IAAmB,CAD/E;AAGA,sBACIK,aAAA,CAACC,GAAD,oBACQJ;AACJR,IAAAA,EAAE,EAAEA;AACJa,IAAAA,SAAS,EAAE,CACPN,yBADO,EAEPO,MAAM,CAACC,IAFA,EAGPd,IAAI,KAAK,MAAT,GAAkBe,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBb,IAAjB,CAA/B,GAAwD,IAHjD,EAIPC,MAAM,KAAK,SAAX,GAAuBc,aAAa,CAACF,MAAD,EAAS,QAAT,EAAmBZ,MAAnB,CAApC,GAAiE,IAJ1D,EAKPC,IAAI,KAAK,QAAT,GAAoBa,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBX,IAAjB,CAAjC,GAA0D,IALnD,EAMPM,sBAAsB,GAAGK,MAAM,CAACL,sBAAV,GAAmC,IANlD,EAOPH,SAAS,GAAGU,aAAa,CAACF,MAAD,EAAS,WAAT,EAAsBR,SAAS,CAACW,QAAV,EAAtB,CAAhB,GAA8D,IAPhE;AASXC,IAAAA,SAAS,EAAEd;AACX;AACA;AACAe,IAAAA,YAAY,EAAEb,SAAS,GAAG,QAAH,GAAcc;AACrCrB,IAAAA,GAAG,EAAEA;IAhBT,EAkBKM,QAlBL,CADJ;AAsBH,CAvCgC;;;;"}
1
+ {"version":3,"file":"text.js","sources":["../../../src/new-components/text/text.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../responsive-props'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\nimport type { Tone } from '../common-types'\nimport type { BoxProps } from '../box'\n\nimport styles from './text.module.css'\n\ntype TextProps = {\n children: React.ReactNode\n /**\n * The size of the text.\n *\n * The supported values, from smaller size to larger size, are:\n * 'caption', 'copy', 'body', and 'subtitle'\n *\n * @default 'body'\n */\n size?: 'caption' | 'copy' | 'body' | 'subtitle'\n /**\n * The weight of the text font.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'semibold' | 'bold'\n /**\n * The tone (semantic color) of the text.\n *\n * @default 'normal'\n */\n tone?: Tone\n /**\n * Used to truncate the text 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 * How to align the text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Text = polymorphicComponent<'div', TextProps>(function Text(\n {\n as,\n size = 'body',\n weight = 'regular',\n tone = 'normal',\n align,\n children,\n lineClamp,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp ?? 1) > 1\n\n return (\n <Box\n {...props}\n as={as}\n className={[\n exceptionallySetClassName,\n styles.text,\n size !== 'body' ? getClassNames(styles, 'size', size) : null,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\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 ref={ref}\n >\n {children}\n </Box>\n )\n})\n\nexport type { TextProps }\nexport { Text }\n"],"names":["Text","polymorphicComponent","ref","as","size","weight","tone","align","children","lineClamp","exceptionallySetClassName","props","lineClampMultipleLines","Number","React","Box","className","styles","text","getClassNames","toString","textAlign","paddingRight","undefined"],"mappings":";;;;;;;;MAoDMA,IAAI,gBAAGC,oBAAoB,CAAmB,SAASD,IAAT,OAYhDE,GAZgD;MAChD;IACIC,EADJ;IAEIC,IAAI,GAAG,MAFX;IAGIC,MAAM,GAAG,SAHb;IAIIC,IAAI,GAAG,QAJX;IAKIC,KALJ;IAMIC,QANJ;IAOIC,SAPJ;IAQIC;;MACGC;;EAIP,MAAMC,sBAAsB,GACxB,OAAOH,SAAP,KAAqB,QAArB,GAAgCI,MAAM,CAACJ,SAAD,CAAN,GAAoB,CAApD,GAAwD,CAACA,SAAD,WAACA,SAAD,GAAc,CAAd,IAAmB,CAD/E;EAGA,oBACIK,aAAA,CAACC,GAAD,oCACQJ,KADR;IAEIR,EAAE,EAAEA,EAFR;IAGIa,SAAS,EAAE,CACPN,yBADO,EAEPO,MAAM,CAACC,IAFA,EAGPd,IAAI,KAAK,MAAT,GAAkBe,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBb,IAAjB,CAA/B,GAAwD,IAHjD,EAIPC,MAAM,KAAK,SAAX,GAAuBc,aAAa,CAACF,MAAD,EAAS,QAAT,EAAmBZ,MAAnB,CAApC,GAAiE,IAJ1D,EAKPC,IAAI,KAAK,QAAT,GAAoBa,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBX,IAAjB,CAAjC,GAA0D,IALnD,EAMPM,sBAAsB,GAAGK,MAAM,CAACL,sBAAV,GAAmC,IANlD,EAOPH,SAAS,GAAGU,aAAa,CAACF,MAAD,EAAS,WAAT,EAAsBR,SAAS,CAACW,QAAV,EAAtB,CAAhB,GAA8D,IAPhE,CAHf;IAYIC,SAAS,EAAEd,KAZf;;;IAeIe,YAAY,EAAEb,SAAS,GAAG,QAAH,GAAcc,SAfzC;IAgBIrB,GAAG,EAAEA;MAEJM,QAlBL,CADJ;AAsBH,CAvCgC;;;;"}
@@ -1,19 +1,21 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { createElement } from 'react';
3
3
  import { Box } from '../box/box.js';
4
4
  import { BaseField } from '../base-field/base-field.js';
5
5
  import styles from './text-area.module.css.js';
6
6
 
7
- var _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth"];
7
+ const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth"];
8
8
 
9
9
  function TextArea(_ref) {
10
- var id = _ref.id,
11
- label = _ref.label,
12
- secondaryLabel = _ref.secondaryLabel,
13
- auxiliaryLabel = _ref.auxiliaryLabel,
14
- hint = _ref.hint,
15
- maxWidth = _ref.maxWidth,
16
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
10
+ let {
11
+ id,
12
+ label,
13
+ secondaryLabel,
14
+ auxiliaryLabel,
15
+ hint,
16
+ maxWidth
17
+ } = _ref,
18
+ props = _objectWithoutProperties(_ref, _excluded);
17
19
 
18
20
  return /*#__PURE__*/createElement(BaseField, {
19
21
  id: id,
@@ -23,11 +25,9 @@ function TextArea(_ref) {
23
25
  hint: hint,
24
26
  className: styles.container,
25
27
  maxWidth: maxWidth
26
- }, function (extraProps) {
27
- return /*#__PURE__*/createElement(Box, {
28
- width: "full"
29
- }, /*#__PURE__*/createElement("textarea", Object.assign({}, props, extraProps)));
30
- });
28
+ }, extraProps => /*#__PURE__*/createElement(Box, {
29
+ width: "full"
30
+ }, /*#__PURE__*/createElement("textarea", _objectSpread2(_objectSpread2({}, props), extraProps))));
31
31
  }
32
32
 
33
33
  export { TextArea };
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement> & {\n rows?: number\n}\n\nfunction TextArea({\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n ...props\n}: TextAreaProps) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n className={styles.container}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box width=\"full\">\n <textarea {...props} {...extraProps} />\n </Box>\n )}\n </BaseField>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","props","React","BaseField","className","styles","container","extraProps","Box","width"],"mappings":";;;;;;;;AASA,SAASA,QAAT;MACIC,UAAAA;MACAC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;MACAC,gBAAAA;MACGC;;AAEH,sBACIC,aAAA,CAACC,SAAD;AACIR,IAAAA,EAAE,EAAEA;AACJC,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNK,IAAAA,SAAS,EAAEC,MAAM,CAACC;AAClBN,IAAAA,QAAQ,EAAEA;GAPd,EASK,UAACO,UAAD;AAAA,wBACGL,aAAA,CAACM,GAAD;AAAKC,MAAAA,KAAK,EAAC;KAAX,eACIP,aAAA,WAAA,oBAAcD,OAAWM,WAAzB,CADJ,CADH;AAAA,GATL,CADJ;AAiBH;;;;"}
1
+ {"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement> & {\n rows?: number\n}\n\nfunction TextArea({\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n ...props\n}: TextAreaProps) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n className={styles.container}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box width=\"full\">\n <textarea {...props} {...extraProps} />\n </Box>\n )}\n </BaseField>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","props","React","BaseField","className","styles","container","extraProps","Box","width"],"mappings":";;;;;;;;AASA,SAASA,QAAT;MAAkB;IACdC,EADc;IAEdC,KAFc;IAGdC,cAHc;IAIdC,cAJc;IAKdC,IALc;IAMdC;;MACGC;;EAEH,oBACIC,aAAA,CAACC,SAAD;IACIR,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNK,SAAS,EAAEC,MAAM,CAACC;IAClBN,QAAQ,EAAEA;GAPd,EASMO,UAAD,iBACGL,aAAA,CAACM,GAAD;IAAKC,KAAK,EAAC;GAAX,eACIP,aAAA,WAAA,oCAAcD,KAAd,GAAyBM,UAAzB,EADJ,CAVR,CADJ;AAiBH;;;;"}
@@ -1,22 +1,23 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { forwardRef, createElement } from 'react';
3
3
  import { Box } from '../box/box.js';
4
4
  import { BaseField } from '../base-field/base-field.js';
5
5
  import styles from './text-field.module.css.js';
6
6
 
7
- var _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "type", "maxWidth", "hidden", "aria-describedby"];
8
- var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
9
- var id = _ref.id,
10
- label = _ref.label,
11
- secondaryLabel = _ref.secondaryLabel,
12
- auxiliaryLabel = _ref.auxiliaryLabel,
13
- hint = _ref.hint,
14
- _ref$type = _ref.type,
15
- type = _ref$type === void 0 ? 'text' : _ref$type,
16
- maxWidth = _ref.maxWidth,
17
- hidden = _ref.hidden,
18
- ariaDescribedBy = _ref['aria-describedby'],
19
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
7
+ const _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "type", "maxWidth", "hidden", "aria-describedby"];
8
+ const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
9
+ let {
10
+ id,
11
+ label,
12
+ secondaryLabel,
13
+ auxiliaryLabel,
14
+ hint,
15
+ type = 'text',
16
+ maxWidth,
17
+ hidden,
18
+ 'aria-describedby': ariaDescribedBy
19
+ } = _ref,
20
+ props = _objectWithoutProperties(_ref, _excluded);
20
21
 
21
22
  return /*#__PURE__*/createElement(BaseField, {
22
23
  id: id,
@@ -27,14 +28,12 @@ var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
27
28
  maxWidth: maxWidth,
28
29
  hidden: hidden,
29
30
  "aria-describedby": ariaDescribedBy
30
- }, function (extraProps) {
31
- return /*#__PURE__*/createElement(Box, {
32
- className: styles.inputWrapper
33
- }, /*#__PURE__*/createElement("input", Object.assign({}, props, extraProps, {
34
- type: type,
35
- ref: ref
36
- })));
37
- });
31
+ }, extraProps => /*#__PURE__*/createElement(Box, {
32
+ className: styles.inputWrapper
33
+ }, /*#__PURE__*/createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
34
+ type: type,
35
+ ref: ref
36
+ }))));
38
37
  });
39
38
 
40
39
  export { TextField };
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> & {\n type?: TextFieldType\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.inputWrapper}>\n <input {...props} {...extraProps} type={type} ref={ref} />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","type","maxWidth","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","inputWrapper"],"mappings":";;;;;;;IAYMA,SAAS,gBAAGC,UAAA,CAAmD,SAASD,SAAT,OAajEE,GAbiE;MAE7DC,UAAAA;MACAC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;uBACAC;MAAAA,8BAAO;MACPC,gBAAAA;MACAC,cAAAA;MACoBC,uBAApB;MACGC;;AAIP,sBACIX,aAAA,CAACY,SAAD;AACIV,IAAAA,EAAE,EAAEA;AACJC,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNE,IAAAA,QAAQ,EAAEA;AACVC,IAAAA,MAAM,EAAEA;wBACUC;GARtB,EAUK,UAACG,UAAD;AAAA,wBACGb,aAAA,CAACc,GAAD;AAAKC,MAAAA,SAAS,EAAEC,MAAM,CAACC;KAAvB,eACIjB,aAAA,QAAA,oBAAWW,OAAWE;AAAYN,MAAAA,IAAI,EAAEA;AAAMN,MAAAA,GAAG,EAAEA;MAAnD,CADJ,CADH;AAAA,GAVL,CADJ;AAkBH,CAjCiB;;;;"}
1
+ {"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> & {\n type?: TextFieldType\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.inputWrapper}>\n <input {...props} {...extraProps} type={type} ref={ref} />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","type","maxWidth","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","inputWrapper"],"mappings":";;;;;;;MAYMA,SAAS,gBAAGC,UAAA,CAAmD,SAASD,SAAT,OAajEE,GAbiE;MACjE;IACIC,EADJ;IAEIC,KAFJ;IAGIC,cAHJ;IAIIC,cAJJ;IAKIC,IALJ;IAMIC,IAAI,GAAG,MANX;IAOIC,QAPJ;IAQIC,MARJ;IASI,oBAAoBC;;MACjBC;;EAIP,oBACIX,aAAA,CAACY,SAAD;IACIV,EAAE,EAAEA;IACJC,KAAK,EAAEA;IACPC,cAAc,EAAEA;IAChBC,cAAc,EAAEA;IAChBC,IAAI,EAAEA;IACNE,QAAQ,EAAEA;IACVC,MAAM,EAAEA;wBACUC;GARtB,EAUMG,UAAD,iBACGb,aAAA,CAACc,GAAD;IAAKC,SAAS,EAAEC,MAAM,CAACC;GAAvB,eACIjB,aAAA,QAAA,mDAAWW,KAAX,GAAsBE,UAAtB;IAAkCN,IAAI,EAAEA,IAAxC;IAA8CN,GAAG,EAAEA;KADvD,CAXR,CADJ;AAkBH,CAjCiB;;;;"}
@@ -1,19 +1,19 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { createElement } from 'react';
3
3
  import { polymorphicComponent } from '../../utils/polymorphism.js';
4
4
  import { Box } from '../box/box.js';
5
5
  import styles from './text-link.module.css.js';
6
6
 
7
- var _excluded = ["as", "openInNewTab", "exceptionallySetClassName"];
8
- var TextLink = /*#__PURE__*/polymorphicComponent(function TextLink(_ref, ref) {
9
- var _ref$as = _ref.as,
10
- as = _ref$as === void 0 ? 'a' : _ref$as,
11
- _ref$openInNewTab = _ref.openInNewTab,
12
- openInNewTab = _ref$openInNewTab === void 0 ? false : _ref$openInNewTab,
13
- exceptionallySetClassName = _ref.exceptionallySetClassName,
14
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
7
+ const _excluded = ["as", "openInNewTab", "exceptionallySetClassName"];
8
+ const TextLink = /*#__PURE__*/polymorphicComponent(function TextLink(_ref, ref) {
9
+ let {
10
+ as = 'a',
11
+ openInNewTab = false,
12
+ exceptionallySetClassName
13
+ } = _ref,
14
+ props = _objectWithoutProperties(_ref, _excluded);
15
15
 
16
- return /*#__PURE__*/createElement(Box, Object.assign({}, props, {
16
+ return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
17
17
  as: as,
18
18
  display: "inline",
19
19
  className: [exceptionallySetClassName, styles.container],
@@ -1 +1 @@
1
- {"version":3,"file":"text-link.js","sources":["../../../src/new-components/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","Box","display","className","styles","container","target","undefined","rel"],"mappings":";;;;;;;IAQMA,QAAQ,gBAAGC,oBAAoB,CAAqB,SAASD,QAAT,OAEtDE,GAFsD;qBACpDC;MAAAA,0BAAK;+BAAKC;MAAAA,8CAAe;MAAOC,iCAAAA;MAA8BC;;AAGhE,sBACIC,aAAA,CAACC,GAAD,oBACQF;AACJH,IAAAA,EAAE,EAAEA;AACJM,IAAAA,OAAO,EAAC;AACRC,IAAAA,SAAS,EAAE,CAACL,yBAAD,EAA4BM,MAAM,CAACC,SAAnC;AACXV,IAAAA,GAAG,EAAEA;AACLW,IAAAA,MAAM,EAAET,YAAY,GAAG,QAAH,GAAcU;AAClCC,IAAAA,GAAG,EAAEX,YAAY,GAAG,qBAAH,GAA2BU;IAPhD,CADJ;AAWH,CAfoC;;;;"}
1
+ {"version":3,"file":"text-link.js","sources":["../../../src/new-components/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","Box","display","className","styles","container","target","undefined","rel"],"mappings":";;;;;;;MAQMA,QAAQ,gBAAGC,oBAAoB,CAAqB,SAASD,QAAT,OAEtDE,GAFsD;MACtD;IAAEC,EAAE,GAAG,GAAP;IAAYC,YAAY,GAAG,KAA3B;IAAkCC;;MAA8BC;;EAGhE,oBACIC,aAAA,CAACC,GAAD,oCACQF,KADR;IAEIH,EAAE,EAAEA,EAFR;IAGIM,OAAO,EAAC,QAHZ;IAIIC,SAAS,EAAE,CAACL,yBAAD,EAA4BM,MAAM,CAACC,SAAnC,CAJf;IAKIV,GAAG,EAAEA,GALT;IAMIW,MAAM,EAAET,YAAY,GAAG,QAAH,GAAcU,SANtC;IAOIC,GAAG,EAAEX,YAAY,GAAG,qBAAH,GAA2BU;KARpD;AAWH,CAfoC;;;;"}
@@ -1 +1 @@
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\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\ntype ObfuscatedClassName = {\n /**\n * Used internally to set the `className` prop of the main container element for this component.\n *\n * Aside from the different name, the prop behaves the same as the native `className`. The only\n * reason for the name change is to discourage applying custom CSS to the design system\n * components, which are supposed to _eventually_ provide all the styling features we may need.\n *\n * This prop is meant to be used only in certain circumstances, when you really need a escape\n * hatch to apply custom styles to a component. Before reaching for this feature, try harder to\n * see if you can solve your needs with what the design system provides.\n *\n * For instance, instead of applying layout-related styles to a non-layout component, consider\n * wrapping it inside a layout component.\n *\n * @see PolymorphicComponent\n */\n exceptionallySetClassName?: string\n}\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<\n 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 */\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 * @see PolymorphicComponent for details about what this type does\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, ObfuscatedClassName }\nexport { polymorphicComponent }\n"],"names":["polymorphicComponent","render","React"],"mappings":";;AAAA;AAqMA;;;;;;;;AAOA,SAASA,oBAAT,CAIEC,MAJF;AAKI,sBAAOC,UAAA,CAAiBD,MAAjB,CAAP;AAKH;;;;"}
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\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\ntype ObfuscatedClassName = {\n /**\n * Used internally to set the `className` prop of the main container element for this component.\n *\n * Aside from the different name, the prop behaves the same as the native `className`. The only\n * reason for the name change is to discourage applying custom CSS to the design system\n * components, which are supposed to _eventually_ provide all the styling features we may need.\n *\n * This prop is meant to be used only in certain circumstances, when you really need a escape\n * hatch to apply custom styles to a component. Before reaching for this feature, try harder to\n * see if you can solve your needs with what the design system provides.\n *\n * For instance, instead of applying layout-related styles to a non-layout component, consider\n * wrapping it inside a layout component.\n *\n * @see PolymorphicComponent\n */\n exceptionallySetClassName?: string\n}\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<\n 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 */\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 * @see PolymorphicComponent for details about what this type does\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, ObfuscatedClassName }\nexport { polymorphicComponent }\n"],"names":["polymorphicComponent","render","React"],"mappings":";;AAAA;AAqMA;;;;;;;;AAOA,SAASA,oBAAT,CAIEC,MAJF;EAKI,oBAAOC,UAAA,CAAiBD,MAAjB,CAAP;AAKH;;;;"}