@doist/reactist 14.0.0 → 15.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 (48) hide show
  1. package/dist/reactist.cjs.development.js +504 -234
  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/components/color-picker/color-picker.js +1 -0
  6. package/es/components/color-picker/color-picker.js.map +1 -1
  7. package/es/components/deprecated-dropdown/dropdown.js +4 -2
  8. package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
  9. package/es/components/menu/menu.js +5 -2
  10. package/es/components/menu/menu.js.map +1 -1
  11. package/es/index.js +3 -2
  12. package/es/index.js.map +1 -1
  13. package/es/new-components/deprecated-modal/modal.js +219 -0
  14. package/es/new-components/deprecated-modal/modal.js.map +1 -0
  15. package/es/new-components/deprecated-modal/modal.module.css.js +4 -0
  16. package/es/new-components/deprecated-modal/modal.module.css.js.map +1 -0
  17. package/es/new-components/modal/modal.js +64 -11
  18. package/es/new-components/modal/modal.js.map +1 -1
  19. package/es/new-components/modal/modal.module.css.js +1 -1
  20. package/es/new-components/tabs/tabs.module.css.js +1 -1
  21. package/lib/components/color-picker/color-picker.js +1 -1
  22. package/lib/components/color-picker/color-picker.js.map +1 -1
  23. package/lib/components/deprecated-dropdown/dropdown.d.ts +6 -2
  24. package/lib/components/deprecated-dropdown/dropdown.js +1 -1
  25. package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
  26. package/lib/components/menu/menu.js +1 -1
  27. package/lib/components/menu/menu.js.map +1 -1
  28. package/lib/index.d.ts +3 -2
  29. package/lib/index.js +1 -1
  30. package/lib/new-components/deprecated-modal/index.d.ts +1 -0
  31. package/lib/new-components/deprecated-modal/modal-stories-components.d.ts +35 -0
  32. package/lib/new-components/deprecated-modal/modal.d.ts +157 -0
  33. package/lib/new-components/deprecated-modal/modal.js +2 -0
  34. package/lib/new-components/deprecated-modal/modal.js.map +1 -0
  35. package/lib/new-components/deprecated-modal/modal.module.css.js +2 -0
  36. package/lib/new-components/deprecated-modal/modal.module.css.js.map +1 -0
  37. package/lib/new-components/deprecated-modal/modal.test.d.ts +1 -0
  38. package/lib/new-components/modal/modal-stories-components.d.ts +2 -1
  39. package/lib/new-components/modal/modal.d.ts +1 -1
  40. package/lib/new-components/modal/modal.js +1 -1
  41. package/lib/new-components/modal/modal.js.map +1 -1
  42. package/lib/new-components/modal/modal.module.css.js +1 -1
  43. package/lib/new-components/tabs/tabs.module.css.js +1 -1
  44. package/package.json +6 -7
  45. package/styles/menu.css +1 -1
  46. package/styles/reactist.css +5 -4
  47. package/styles/tabs.css +1 -1
  48. package/styles/tabs.module.css.css +1 -1
@@ -10,14 +10,16 @@ var classNames = _interopDefault(require('classnames'));
10
10
  var flattenChildren = _interopDefault(require('react-keyed-flatten-children'));
11
11
  var tooltip = require('ariakit/tooltip');
12
12
  var ariakitUtils = require('ariakit-utils');
13
- var tab = require('ariakit/tab');
14
- var dialog = require('@reach/dialog');
15
13
  var FocusLock = _interopDefault(require('react-focus-lock'));
14
+ var ariaHidden = require('aria-hidden');
15
+ var dialog = require('ariakit/dialog');
16
+ var portal = require('ariakit/portal');
17
+ var tab = require('ariakit/tab');
16
18
  var ReactDOM = _interopDefault(require('react-dom'));
17
19
  var dayjs = _interopDefault(require('dayjs'));
18
20
  var LocalizedFormat = _interopDefault(require('dayjs/plugin/localizedFormat'));
19
21
  var Ariakit = require('ariakit/menu');
20
- var portal = require('ariakit/portal');
22
+ var dialog$1 = require('@reach/dialog');
21
23
 
22
24
  function ownKeys(object, enumerableOnly) {
23
25
  var keys = Object.keys(object);
@@ -1536,194 +1538,72 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(_ref, ref) {
1536
1538
  }))));
1537
1539
  });
1538
1540
 
1539
- /**
1540
- * usePrevious tracks the change of the given value -
1541
- * when a given value has been changed from a previous call,
1542
- * it will return the value prior to the change.
1543
- *
1544
- * Example:
1545
- *
1546
- * const [x, setX] = useState(1)
1547
- * const prevX = usePrevious(x)
1548
- *
1549
- * Suppose `setX(2)` is called, then in the next component render
1550
- * x = 2 and prevX = 1
1551
- */
1541
+ function getInitials(name) {
1542
+ var _initials;
1552
1543
 
1553
- function usePrevious(value) {
1554
- const ref = React.useRef(null);
1555
- React.useEffect(() => {
1556
- ref.current = value;
1557
- }, [value]);
1558
- return ref.current;
1559
- }
1544
+ if (!name) {
1545
+ return '';
1546
+ }
1560
1547
 
1561
- var modules_40c67f5b = {"tab":"_76bbcdaa","track":"_531eb92b","tab-neutral":"_13321d47","tab-themed":"_58c4d63d","track-neutral":"_11ef0184","track-themed":"ce590259","track-xsmall":"d8366aff","track-small":"e28fbcf0","track-medium":"_1e1d7d0e","track-large":"_611e18a3","track-xlarge":"_7e083426","track-xxlarge":"_37c54913"};
1548
+ const seed = name.trim().split(' ');
1549
+ const firstInitial = seed[0];
1550
+ const lastInitial = seed[seed.length - 1];
1551
+ let initials = firstInitial == null ? void 0 : firstInitial[0];
1562
1552
 
1563
- const _excluded$m = ["as", "children", "id", "exceptionallySetClassName"],
1564
- _excluded2$1 = ["children", "space"],
1565
- _excluded3 = ["children", "id", "as", "render"];
1566
- const TabsContext = /*#__PURE__*/React.createContext(null);
1567
- /**
1568
- * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.
1569
- */
1553
+ if (firstInitial != null && lastInitial != null && initials != null && // Better readable this way.
1554
+ // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
1555
+ firstInitial[0] !== lastInitial[0]) {
1556
+ initials += lastInitial[0];
1557
+ }
1570
1558
 
1571
- function Tabs({
1572
- children,
1573
- selectedId,
1574
- defaultSelectedId,
1575
- variant = 'neutral',
1576
- onSelectedIdChange
1577
- }) {
1578
- const tabState = tab.useTabState({
1579
- selectedId,
1580
- setSelectedId: onSelectedIdChange
1581
- });
1582
- const previousDefaultSelectedId = usePrevious(defaultSelectedId);
1583
- const {
1584
- selectedId: actualSelectedId,
1585
- select
1586
- } = tabState;
1587
- React.useEffect(function selectDefaultTab() {
1588
- if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
1589
- select(defaultSelectedId);
1590
- }
1591
- }, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
1592
- const memoizedTabState = React.useMemo(function memoizeTabState() {
1593
- return {
1594
- tabState,
1595
- variant
1596
- };
1597
- }, [variant, tabState]);
1598
- return /*#__PURE__*/React.createElement(TabsContext.Provider, {
1599
- value: memoizedTabState
1600
- }, children);
1559
+ return (_initials = initials) == null ? void 0 : _initials.toUpperCase();
1601
1560
  }
1602
- /**
1603
- * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.
1604
- */
1605
-
1606
- const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
1607
- let {
1608
- as,
1609
- children,
1610
- id,
1611
- exceptionallySetClassName
1612
- } = _ref,
1613
- props = _objectWithoutProperties(_ref, _excluded$m);
1614
1561
 
1615
- const tabContextValue = React.useContext(TabsContext);
1562
+ function emailToIndex(email, maxIndex) {
1563
+ const seed = email.split('@')[0];
1564
+ const hash = seed ? seed.charCodeAt(0) + seed.charCodeAt(seed.length - 1) || 0 : 0;
1565
+ return hash % maxIndex;
1566
+ }
1616
1567
 
1617
- if (!tabContextValue) {
1618
- return null;
1619
- }
1568
+ var modules_08f3eeac = {"avatar":"_38a1be89","size-xxs":"d32e92ae","size-xs":"_0667d719","size-s":"cf529fcf","size-m":"_6e268eab","size-l":"d64c62cf","size-xl":"_44fb77de","size-xxl":"_01f85e0e","size-xxxl":"_41a5fe19","tablet-size-xxs":"_6ab1577d","tablet-size-xs":"b52a4963","tablet-size-s":"_714a8419","tablet-size-m":"_81cd4d51","tablet-size-l":"bf0a4edb","tablet-size-xl":"e4f0dabd","tablet-size-xxl":"_67ea065d","tablet-size-xxxl":"_2af7f76f","desktop-size-xxs":"_759081dc","desktop-size-xs":"_8290d1c1","desktop-size-s":"_48ea172d","desktop-size-m":"_758f6641","desktop-size-l":"f9ada088","desktop-size-xl":"d3bb7470","desktop-size-xxl":"_9a312ee3","desktop-size-xxxl":"a1d30c23"};
1620
1569
 
1621
- const {
1622
- variant,
1623
- tabState
1624
- } = tabContextValue;
1625
- return /*#__PURE__*/React.createElement(tab.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
1626
- as: as,
1627
- className: classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]),
1628
- id: id,
1629
- state: tabState,
1630
- ref: ref
1631
- }), children);
1632
- });
1633
- /**
1634
- * A component used to group `<Tab>` elements together.
1635
- */
1570
+ const _excluded$m = ["user", "avatarUrl", "size", "className", "colorList", "exceptionallySetClassName"];
1571
+ const AVATAR_COLORS = ['#fcc652', '#e9952c', '#e16b2d', '#d84b40', '#e8435a', '#e5198a', '#ad3889', '#86389c', '#a8a8a8', '#98be2f', '#5d9d50', '#5f9f85', '#5bbcb6', '#32a3bf', '#2bafeb', '#2d88c3', '#3863cc', '#5e5e5e'];
1636
1572
 
1637
- function TabList(_ref2) {
1573
+ function Avatar(_ref) {
1638
1574
  let {
1639
- children,
1640
- space = 'xsmall'
1641
- } = _ref2,
1642
- props = _objectWithoutProperties(_ref2, _excluded2$1);
1643
-
1644
- const tabContextValue = React.useContext(TabsContext);
1575
+ user,
1576
+ avatarUrl,
1577
+ size = 'l',
1578
+ className,
1579
+ colorList = AVATAR_COLORS,
1580
+ exceptionallySetClassName
1581
+ } = _ref,
1582
+ props = _objectWithoutProperties(_ref, _excluded$m);
1645
1583
 
1646
- if (!tabContextValue) {
1647
- return null;
1648
- }
1584
+ const userInitials = getInitials(user.name) || getInitials(user.email);
1585
+ const avatarSize = size ? size : 'l';
1586
+ const style = avatarUrl ? {
1587
+ backgroundImage: "url(" + avatarUrl + ")",
1588
+ textIndent: '-9999px' // hide the initials
1649
1589
 
1650
- const {
1651
- tabState,
1652
- variant
1653
- } = tabContextValue;
1654
- return (
1655
- /*#__PURE__*/
1656
- // The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
1657
- // which will render the track with the wrong height
1658
- React.createElement(Box, null, /*#__PURE__*/React.createElement(tab.TabList, _objectSpread2({
1659
- state: tabState,
1660
- as: Box,
1661
- position: "relative",
1662
- width: "maxContent"
1663
- }, props), /*#__PURE__*/React.createElement(Box, {
1664
- className: classNames(modules_40c67f5b.track, modules_40c67f5b["track-" + space], modules_40c67f5b["track-" + variant])
1665
- }), /*#__PURE__*/React.createElement(Inline, {
1666
- space: space
1667
- }, children)))
1668
- );
1590
+ } : {
1591
+ backgroundColor: colorList[emailToIndex(user.email, colorList.length)]
1592
+ };
1593
+ const sizeClassName = getClassNames(modules_08f3eeac, 'size', avatarSize);
1594
+ return /*#__PURE__*/React__default.createElement(Box, _objectSpread2({
1595
+ className: [className, modules_08f3eeac.avatar, sizeClassName, exceptionallySetClassName],
1596
+ style: style
1597
+ }, props), userInitials);
1669
1598
  }
1670
- /**
1671
- * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
1672
- */
1673
-
1674
- const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
1675
- let {
1676
- children,
1677
- id,
1678
- as,
1679
- render = 'always'
1680
- } = _ref3,
1681
- props = _objectWithoutProperties(_ref3, _excluded3);
1682
-
1683
- const tabContextValue = React.useContext(TabsContext);
1684
- const [tabRendered, setTabRendered] = React.useState(false);
1685
- const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
1686
- React.useEffect(function trackTabRenderedState() {
1687
- if (!tabRendered && tabIsActive) {
1688
- setTabRendered(true);
1689
- }
1690
- }, [tabRendered, tabIsActive]);
1691
-
1692
- if (!tabContextValue) {
1693
- return null;
1694
- }
1695
-
1696
- const {
1697
- tabState
1698
- } = tabContextValue;
1699
- const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
1700
- return shouldRender ? /*#__PURE__*/React.createElement(tab.TabPanel, _objectSpread2(_objectSpread2({
1701
- tabId: id
1702
- }, props), {}, {
1703
- state: tabState,
1704
- as: as,
1705
- ref: ref
1706
- }), children) : null;
1707
- });
1708
- /**
1709
- * Allows content to be rendered based on the current tab being selected while outside of the TabPanel
1710
- * component. Can be placed freely within the main `<Tabs>` component.
1711
- */
1712
1599
 
1713
- function TabAwareSlot({
1714
- children
1715
- }) {
1716
- const tabContextValue = React.useContext(TabsContext);
1717
- return tabContextValue ? children({
1718
- selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
1719
- }) : null;
1720
- }
1600
+ Avatar.displayName = 'Avatar';
1721
1601
 
1722
- var modules_8f59d13b = {"reach-portal":"_37bef8d8","fadein":"_77f9687f","fitContent":"bcc4e0a5","container":"d4832c2d","full":"b0c3b021","large":"_573d6aa5","medium":"_8550d996","small":"_43bb18f5","xlarge":"_57b4159d","overlay":"cb63f300","expand":"e741893e","buttonContainer":"bb1ce281","headerContent":"c5ef989c"};
1602
+ var modules_8f59d13b = {"overlay":"_868392ae","fadein":"_63d7ee15","fitContent":"b8548bf2","container":"_31956461","full":"_1007df83","large":"_10c275aa","medium":"_0ac526b4","small":"_30f38fdb","xlarge":"_54868e8b","expand":"c0bc68bc","buttonContainer":"_6527332a","headerContent":"_4750dc1b"};
1723
1603
 
1724
1604
  const _excluded$n = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "autoFocus", "children"],
1725
- _excluded2$2 = ["children", "button", "withDivider", "exceptionallySetClassName"],
1726
- _excluded3$1 = ["exceptionallySetClassName", "children"],
1605
+ _excluded2$1 = ["children", "button", "withDivider", "exceptionallySetClassName"],
1606
+ _excluded3 = ["exceptionallySetClassName", "children"],
1727
1607
  _excluded4 = ["exceptionallySetClassName", "withDivider"],
1728
1608
  _excluded5 = ["children"];
1729
1609
  const ModalContext = /*#__PURE__*/React.createContext({
@@ -1757,23 +1637,65 @@ function Modal(_ref) {
1757
1637
  } = _ref,
1758
1638
  props = _objectWithoutProperties(_ref, _excluded$n);
1759
1639
 
1640
+ const setVisible = React.useCallback(visible => {
1641
+ if (!visible) {
1642
+ onDismiss == null ? void 0 : onDismiss();
1643
+ }
1644
+ }, [onDismiss]);
1645
+ const state = dialog.useDialogState({
1646
+ visible: isOpen,
1647
+ setVisible
1648
+ });
1760
1649
  const contextValue = React.useMemo(() => ({
1761
1650
  onDismiss,
1762
1651
  height
1763
1652
  }), [onDismiss, height]);
1764
- return /*#__PURE__*/React.createElement(dialog.DialogOverlay, {
1765
- isOpen: isOpen,
1766
- onDismiss: onDismiss,
1767
- dangerouslyBypassFocusLock // We're setting up our own focus lock below
1768
- : true,
1653
+ const portalRef = React.useRef(null);
1654
+ const dialogRef = React.useRef(null);
1655
+ const backdropRef = React.useRef(null);
1656
+ const handleBackdropClick = React.useCallback(event => {
1657
+ var _dialogRef$current, _backdropRef$current;
1658
+
1659
+ if ( // The focus lock element takes up the same space as the backdrop and is where the event bubbles up from,
1660
+ // so instead of checking the backdrop as the event target, we need to make sure it's just above the dialog
1661
+ !((_dialogRef$current = dialogRef.current) != null && _dialogRef$current.contains(event.target)) && // Events fired from other portals will bubble up to the backdrop, even if it isn't a child in the DOM
1662
+ (_backdropRef$current = backdropRef.current) != null && _backdropRef$current.contains(event.target)) {
1663
+ event.stopPropagation();
1664
+ onDismiss == null ? void 0 : onDismiss();
1665
+ }
1666
+ }, [onDismiss]);
1667
+ React.useLayoutEffect(function disableAccessibilityTreeOutside() {
1668
+ if (!isOpen || !portalRef.current) {
1669
+ return;
1670
+ }
1671
+
1672
+ return ariaHidden.hideOthers(portalRef.current);
1673
+ }, [isOpen]);
1674
+
1675
+ if (!isOpen) {
1676
+ return null;
1677
+ }
1678
+
1679
+ return /*#__PURE__*/React.createElement(portal.Portal // @ts-expect-error `portalRef` doesn't accept MutableRefObject initialized as null
1680
+ , {
1681
+ // @ts-expect-error `portalRef` doesn't accept MutableRefObject initialized as null
1682
+ portalRef: portalRef
1683
+ }, /*#__PURE__*/React.createElement(Box, {
1684
+ "data-testid": "modal-overlay",
1685
+ "data-overlay": true,
1769
1686
  className: classNames(modules_8f59d13b.overlay, modules_8f59d13b[height], modules_8f59d13b[width]),
1770
- "data-testid": "modal-overlay"
1687
+ onClick: handleBackdropClick,
1688
+ ref: backdropRef
1771
1689
  }, /*#__PURE__*/React.createElement(FocusLock, {
1772
1690
  autoFocus: autoFocus,
1773
1691
  whiteList: isNotInternalFrame,
1774
1692
  returnFocus: true
1775
- }, /*#__PURE__*/React.createElement(dialog.DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
1693
+ }, /*#__PURE__*/React.createElement(dialog.Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
1694
+ ref: dialogRef,
1776
1695
  as: Box,
1696
+ state: state,
1697
+ hideOnEscape: true,
1698
+ preventBodyScroll: true,
1777
1699
  borderRadius: "full",
1778
1700
  background: "default",
1779
1701
  display: "flex",
@@ -1781,10 +1703,19 @@ function Modal(_ref) {
1781
1703
  overflow: "hidden",
1782
1704
  height: height === 'expand' ? 'full' : undefined,
1783
1705
  flexGrow: height === 'expand' ? 1 : 0,
1784
- className: [exceptionallySetClassName, modules_8f59d13b.container]
1706
+ className: [exceptionallySetClassName, modules_8f59d13b.container],
1707
+ // Disable focus lock as we set up our own using ReactFocusLock
1708
+ modal: false,
1709
+ autoFocus: false,
1710
+ autoFocusOnShow: false,
1711
+ autoFocusOnHide: false,
1712
+ // Disable portal and backdrop as we control their markup
1713
+ portal: false,
1714
+ backdrop: false,
1715
+ hideOnInteractOutside: false
1785
1716
  }), /*#__PURE__*/React.createElement(ModalContext.Provider, {
1786
1717
  value: contextValue
1787
- }, children))));
1718
+ }, children)))));
1788
1719
  }
1789
1720
  /**
1790
1721
  * The close button rendered by ModalHeader. Provided independently so that consumers can customize
@@ -1828,7 +1759,7 @@ function ModalHeader(_ref2) {
1828
1759
  withDivider = false,
1829
1760
  exceptionallySetClassName
1830
1761
  } = _ref2,
1831
- props = _objectWithoutProperties(_ref2, _excluded2$2);
1762
+ props = _objectWithoutProperties(_ref2, _excluded2$1);
1832
1763
 
1833
1764
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
1834
1765
  as: "header",
@@ -1870,7 +1801,7 @@ function ModalBody(_ref3) {
1870
1801
  exceptionallySetClassName,
1871
1802
  children
1872
1803
  } = _ref3,
1873
- props = _objectWithoutProperties(_ref3, _excluded3$1);
1804
+ props = _objectWithoutProperties(_ref3, _excluded3);
1874
1805
 
1875
1806
  const {
1876
1807
  height
@@ -1924,66 +1855,188 @@ function ModalActions(_ref5) {
1924
1855
  }, children));
1925
1856
  }
1926
1857
 
1927
- function getInitials(name) {
1928
- var _initials;
1929
-
1930
- if (!name) {
1931
- return '';
1932
- }
1858
+ /**
1859
+ * usePrevious tracks the change of the given value -
1860
+ * when a given value has been changed from a previous call,
1861
+ * it will return the value prior to the change.
1862
+ *
1863
+ * Example:
1864
+ *
1865
+ * const [x, setX] = useState(1)
1866
+ * const prevX = usePrevious(x)
1867
+ *
1868
+ * Suppose `setX(2)` is called, then in the next component render
1869
+ * x = 2 and prevX = 1
1870
+ */
1933
1871
 
1934
- const seed = name.trim().split(' ');
1935
- const firstInitial = seed[0];
1936
- const lastInitial = seed[seed.length - 1];
1937
- let initials = firstInitial == null ? void 0 : firstInitial[0];
1938
-
1939
- if (firstInitial != null && lastInitial != null && initials != null && // Better readable this way.
1940
- // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
1941
- firstInitial[0] !== lastInitial[0]) {
1942
- initials += lastInitial[0];
1943
- }
1944
-
1945
- return (_initials = initials) == null ? void 0 : _initials.toUpperCase();
1872
+ function usePrevious(value) {
1873
+ const ref = React.useRef(null);
1874
+ React.useEffect(() => {
1875
+ ref.current = value;
1876
+ }, [value]);
1877
+ return ref.current;
1946
1878
  }
1947
1879
 
1948
- function emailToIndex(email, maxIndex) {
1949
- const seed = email.split('@')[0];
1950
- const hash = seed ? seed.charCodeAt(0) + seed.charCodeAt(seed.length - 1) || 0 : 0;
1951
- return hash % maxIndex;
1952
- }
1880
+ var modules_40c67f5b = {"tab":"a1064a3b","track":"_06f1b8a1","tab-neutral":"dabbec7d","tab-themed":"e6f5ae4e","track-neutral":"_43913ce5","track-themed":"_39bdfdde","track-xsmall":"_1c148f4e","track-small":"_2a370df5","track-medium":"_77430437","track-large":"_33db5352","track-xlarge":"_60bf9564","track-xxlarge":"_29a35080"};
1953
1881
 
1954
- var modules_08f3eeac = {"avatar":"_38a1be89","size-xxs":"d32e92ae","size-xs":"_0667d719","size-s":"cf529fcf","size-m":"_6e268eab","size-l":"d64c62cf","size-xl":"_44fb77de","size-xxl":"_01f85e0e","size-xxxl":"_41a5fe19","tablet-size-xxs":"_6ab1577d","tablet-size-xs":"b52a4963","tablet-size-s":"_714a8419","tablet-size-m":"_81cd4d51","tablet-size-l":"bf0a4edb","tablet-size-xl":"e4f0dabd","tablet-size-xxl":"_67ea065d","tablet-size-xxxl":"_2af7f76f","desktop-size-xxs":"_759081dc","desktop-size-xs":"_8290d1c1","desktop-size-s":"_48ea172d","desktop-size-m":"_758f6641","desktop-size-l":"f9ada088","desktop-size-xl":"d3bb7470","desktop-size-xxl":"_9a312ee3","desktop-size-xxxl":"a1d30c23"};
1882
+ const _excluded$o = ["as", "children", "id", "exceptionallySetClassName"],
1883
+ _excluded2$2 = ["children", "space"],
1884
+ _excluded3$1 = ["children", "id", "as", "render"];
1885
+ const TabsContext = /*#__PURE__*/React.createContext(null);
1886
+ /**
1887
+ * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.
1888
+ */
1955
1889
 
1956
- const _excluded$o = ["user", "avatarUrl", "size", "className", "colorList", "exceptionallySetClassName"];
1957
- const AVATAR_COLORS = ['#fcc652', '#e9952c', '#e16b2d', '#d84b40', '#e8435a', '#e5198a', '#ad3889', '#86389c', '#a8a8a8', '#98be2f', '#5d9d50', '#5f9f85', '#5bbcb6', '#32a3bf', '#2bafeb', '#2d88c3', '#3863cc', '#5e5e5e'];
1890
+ function Tabs({
1891
+ children,
1892
+ selectedId,
1893
+ defaultSelectedId,
1894
+ variant = 'neutral',
1895
+ onSelectedIdChange
1896
+ }) {
1897
+ const tabState = tab.useTabState({
1898
+ selectedId,
1899
+ setSelectedId: onSelectedIdChange
1900
+ });
1901
+ const previousDefaultSelectedId = usePrevious(defaultSelectedId);
1902
+ const {
1903
+ selectedId: actualSelectedId,
1904
+ select
1905
+ } = tabState;
1906
+ React.useEffect(function selectDefaultTab() {
1907
+ if (!selectedId && defaultSelectedId !== previousDefaultSelectedId && defaultSelectedId !== actualSelectedId && defaultSelectedId !== undefined) {
1908
+ select(defaultSelectedId);
1909
+ }
1910
+ }, [selectedId, defaultSelectedId, actualSelectedId, select, previousDefaultSelectedId]);
1911
+ const memoizedTabState = React.useMemo(function memoizeTabState() {
1912
+ return {
1913
+ tabState,
1914
+ variant
1915
+ };
1916
+ }, [variant, tabState]);
1917
+ return /*#__PURE__*/React.createElement(TabsContext.Provider, {
1918
+ value: memoizedTabState
1919
+ }, children);
1920
+ }
1921
+ /**
1922
+ * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.
1923
+ */
1958
1924
 
1959
- function Avatar(_ref) {
1925
+ const Tab = /*#__PURE__*/polymorphicComponent(function Tab(_ref, ref) {
1960
1926
  let {
1961
- user,
1962
- avatarUrl,
1963
- size = 'l',
1964
- className,
1965
- colorList = AVATAR_COLORS,
1927
+ as,
1928
+ children,
1929
+ id,
1966
1930
  exceptionallySetClassName
1967
1931
  } = _ref,
1968
1932
  props = _objectWithoutProperties(_ref, _excluded$o);
1969
1933
 
1970
- const userInitials = getInitials(user.name) || getInitials(user.email);
1971
- const avatarSize = size ? size : 'l';
1972
- const style = avatarUrl ? {
1973
- backgroundImage: "url(" + avatarUrl + ")",
1974
- textIndent: '-9999px' // hide the initials
1934
+ const tabContextValue = React.useContext(TabsContext);
1975
1935
 
1976
- } : {
1977
- backgroundColor: colorList[emailToIndex(user.email, colorList.length)]
1978
- };
1979
- const sizeClassName = getClassNames(modules_08f3eeac, 'size', avatarSize);
1980
- return /*#__PURE__*/React__default.createElement(Box, _objectSpread2({
1981
- className: [className, modules_08f3eeac.avatar, sizeClassName, exceptionallySetClassName],
1982
- style: style
1983
- }, props), userInitials);
1936
+ if (!tabContextValue) {
1937
+ return null;
1938
+ }
1939
+
1940
+ const {
1941
+ variant,
1942
+ tabState
1943
+ } = tabContextValue;
1944
+ return /*#__PURE__*/React.createElement(tab.Tab, _objectSpread2(_objectSpread2({}, props), {}, {
1945
+ as: as,
1946
+ className: classNames(exceptionallySetClassName, modules_40c67f5b.tab, modules_40c67f5b["tab-" + variant]),
1947
+ id: id,
1948
+ state: tabState,
1949
+ ref: ref
1950
+ }), children);
1951
+ });
1952
+ /**
1953
+ * A component used to group `<Tab>` elements together.
1954
+ */
1955
+
1956
+ function TabList(_ref2) {
1957
+ let {
1958
+ children,
1959
+ space = 'xsmall'
1960
+ } = _ref2,
1961
+ props = _objectWithoutProperties(_ref2, _excluded2$2);
1962
+
1963
+ const tabContextValue = React.useContext(TabsContext);
1964
+
1965
+ if (!tabContextValue) {
1966
+ return null;
1967
+ }
1968
+
1969
+ const {
1970
+ tabState,
1971
+ variant
1972
+ } = tabContextValue;
1973
+ return (
1974
+ /*#__PURE__*/
1975
+ // The extra <Box> prevents <Inline>'s negative margins from collapsing when used in a flex container
1976
+ // which will render the track with the wrong height
1977
+ React.createElement(Box, null, /*#__PURE__*/React.createElement(tab.TabList, _objectSpread2({
1978
+ state: tabState,
1979
+ as: Box,
1980
+ position: "relative",
1981
+ width: "maxContent"
1982
+ }, props), /*#__PURE__*/React.createElement(Box, {
1983
+ className: classNames(modules_40c67f5b.track, modules_40c67f5b["track-" + space], modules_40c67f5b["track-" + variant])
1984
+ }), /*#__PURE__*/React.createElement(Inline, {
1985
+ space: space
1986
+ }, children)))
1987
+ );
1984
1988
  }
1989
+ /**
1990
+ * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
1991
+ */
1985
1992
 
1986
- Avatar.displayName = 'Avatar';
1993
+ const TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref3, ref) {
1994
+ let {
1995
+ children,
1996
+ id,
1997
+ as,
1998
+ render = 'always'
1999
+ } = _ref3,
2000
+ props = _objectWithoutProperties(_ref3, _excluded3$1);
2001
+
2002
+ const tabContextValue = React.useContext(TabsContext);
2003
+ const [tabRendered, setTabRendered] = React.useState(false);
2004
+ const tabIsActive = (tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId) === id;
2005
+ React.useEffect(function trackTabRenderedState() {
2006
+ if (!tabRendered && tabIsActive) {
2007
+ setTabRendered(true);
2008
+ }
2009
+ }, [tabRendered, tabIsActive]);
2010
+
2011
+ if (!tabContextValue) {
2012
+ return null;
2013
+ }
2014
+
2015
+ const {
2016
+ tabState
2017
+ } = tabContextValue;
2018
+ const shouldRender = render === 'always' || render === 'active' && tabIsActive || render === 'lazy' && (tabIsActive || tabRendered);
2019
+ return shouldRender ? /*#__PURE__*/React.createElement(tab.TabPanel, _objectSpread2(_objectSpread2({
2020
+ tabId: id
2021
+ }, props), {}, {
2022
+ state: tabState,
2023
+ as: as,
2024
+ ref: ref
2025
+ }), children) : null;
2026
+ });
2027
+ /**
2028
+ * Allows content to be rendered based on the current tab being selected while outside of the TabPanel
2029
+ * component. Can be placed freely within the main `<Tabs>` component.
2030
+ */
2031
+
2032
+ function TabAwareSlot({
2033
+ children
2034
+ }) {
2035
+ const tabContextValue = React.useContext(TabsContext);
2036
+ return tabContextValue ? children({
2037
+ selectedId: tabContextValue == null ? void 0 : tabContextValue.tabState.selectedId
2038
+ }) : null;
2039
+ }
1987
2040
 
1988
2041
  const _excluded$p = ["type", "variant", "size", "loading", "disabled", "tooltip", "onClick", "children"];
1989
2042
  /**
@@ -2161,7 +2214,8 @@ class Box$1 extends React__default.Component {
2161
2214
  style: {
2162
2215
  display: 'inline-block'
2163
2216
  },
2164
- className: className
2217
+ className: className,
2218
+ "data-testid": "reactist-dropdown-box"
2165
2219
  }, top && this._getBodyComponent(), this._getTriggerComponent(), !top && this._getBodyComponent());
2166
2220
  }
2167
2221
 
@@ -2219,7 +2273,8 @@ function Body({
2219
2273
  ref: setPosition,
2220
2274
  style: style,
2221
2275
  className: "body",
2222
- id: "reactist-dropdown-body"
2276
+ id: "reactist-dropdown-body",
2277
+ "data-testid": "reactist-dropdown-body"
2223
2278
  }, children);
2224
2279
  }
2225
2280
 
@@ -2286,6 +2341,7 @@ function ColorItem({
2286
2341
  tooltip
2287
2342
  }) {
2288
2343
  const item = /*#__PURE__*/React__default.createElement("span", {
2344
+ "data-testid": "reactist-color-item",
2289
2345
  className: 'reactist color_item' + (isActive ? ' active' : ''),
2290
2346
  style: {
2291
2347
  backgroundColor: color
@@ -2940,11 +2996,13 @@ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref3, ref)
2940
2996
  } = React.useContext(MenuContext);
2941
2997
  return state.visible ? /*#__PURE__*/React.createElement(portal.Portal, {
2942
2998
  preserveTabOrder: true
2999
+ }, /*#__PURE__*/React.createElement(FocusLock, {
3000
+ returnFocus: true
2943
3001
  }, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
2944
3002
  state: state,
2945
3003
  ref: ref,
2946
3004
  className: classNames('reactist_menulist', exceptionallySetClassName)
2947
- }))) : null;
3005
+ })))) : null;
2948
3006
  });
2949
3007
  /**
2950
3008
  * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
@@ -3107,6 +3165,212 @@ Select.defaultProps = {
3107
3165
  disabled: false
3108
3166
  };
3109
3167
 
3168
+ var modules_8f59d13b$1 = {"reach-portal":"_37bef8d8","fadein":"_77f9687f","fitContent":"bcc4e0a5","container":"d4832c2d","full":"b0c3b021","large":"_573d6aa5","medium":"_8550d996","small":"_43bb18f5","xlarge":"_57b4159d","overlay":"cb63f300","expand":"e741893e","buttonContainer":"bb1ce281","headerContent":"c5ef989c"};
3169
+
3170
+ const _excluded$v = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "autoFocus", "children"],
3171
+ _excluded2$4 = ["children", "button", "withDivider", "exceptionallySetClassName"],
3172
+ _excluded3$3 = ["exceptionallySetClassName", "children"],
3173
+ _excluded4$2 = ["exceptionallySetClassName", "withDivider"],
3174
+ _excluded5$2 = ["children"];
3175
+ const ModalContext$1 = /*#__PURE__*/React.createContext({
3176
+ onDismiss: undefined,
3177
+ height: 'fitContent'
3178
+ });
3179
+
3180
+ function isNotInternalFrame$1(element) {
3181
+ return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe');
3182
+ }
3183
+ /**
3184
+ * Renders a modal that sits on top of the rest of the content in the entire page.
3185
+ *
3186
+ * Follows the WAI-ARIA Dialog (Modal) Pattern.
3187
+ *
3188
+ * @see DeprecatedModalHeader
3189
+ * @see DeprecatedModalFooter
3190
+ * @see DeprecatedModalBody
3191
+ * @deprecated
3192
+ */
3193
+
3194
+
3195
+ function DeprecatedModal(_ref) {
3196
+ let {
3197
+ isOpen,
3198
+ onDismiss,
3199
+ height = 'fitContent',
3200
+ width = 'medium',
3201
+ exceptionallySetClassName,
3202
+ autoFocus = true,
3203
+ children
3204
+ } = _ref,
3205
+ props = _objectWithoutProperties(_ref, _excluded$v);
3206
+
3207
+ const contextValue = React.useMemo(() => ({
3208
+ onDismiss,
3209
+ height
3210
+ }), [onDismiss, height]);
3211
+ return /*#__PURE__*/React.createElement(dialog$1.DialogOverlay, {
3212
+ isOpen: isOpen,
3213
+ onDismiss: onDismiss,
3214
+ dangerouslyBypassFocusLock // We're setting up our own focus lock below
3215
+ : true,
3216
+ className: classNames(modules_8f59d13b$1.overlay, modules_8f59d13b$1[height], modules_8f59d13b$1[width]),
3217
+ "data-testid": "modal-overlay"
3218
+ }, /*#__PURE__*/React.createElement(FocusLock, {
3219
+ autoFocus: autoFocus,
3220
+ whiteList: isNotInternalFrame$1,
3221
+ returnFocus: true
3222
+ }, /*#__PURE__*/React.createElement(dialog$1.DialogContent, _objectSpread2(_objectSpread2({}, props), {}, {
3223
+ as: Box,
3224
+ borderRadius: "full",
3225
+ background: "default",
3226
+ display: "flex",
3227
+ flexDirection: "column",
3228
+ overflow: "hidden",
3229
+ height: height === 'expand' ? 'full' : undefined,
3230
+ flexGrow: height === 'expand' ? 1 : 0,
3231
+ className: [exceptionallySetClassName, modules_8f59d13b$1.container]
3232
+ }), /*#__PURE__*/React.createElement(ModalContext$1.Provider, {
3233
+ value: contextValue
3234
+ }, children))));
3235
+ }
3236
+ /**
3237
+ * The close button rendered by ModalHeader. Provided independently so that consumers can customize
3238
+ * the button's label.
3239
+ *
3240
+ * @see DeprecatedModalHeader
3241
+ */
3242
+
3243
+ function DeprecatedModalCloseButton(props) {
3244
+ const {
3245
+ onDismiss
3246
+ } = React.useContext(ModalContext$1);
3247
+ const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false);
3248
+ const [isMounted, setIsMounted] = React.useState(false);
3249
+ React.useEffect(function skipAutoFocus() {
3250
+ if (isMounted) {
3251
+ setIncludeInTabOrder(true);
3252
+ } else {
3253
+ setIsMounted(true);
3254
+ }
3255
+ }, [isMounted]);
3256
+ return /*#__PURE__*/React.createElement(Button, _objectSpread2(_objectSpread2({}, props), {}, {
3257
+ variant: "quaternary",
3258
+ onClick: onDismiss,
3259
+ icon: /*#__PURE__*/React.createElement(CloseIcon, null),
3260
+ tabIndex: includeInTabOrder ? 0 : -1
3261
+ }));
3262
+ }
3263
+ /**
3264
+ * Renders a standard modal header area with an optional close button.
3265
+ *
3266
+ * @see DeprecatedModal
3267
+ * @see DeprecatedModalFooter
3268
+ * @see DeprecatedModalBody
3269
+ */
3270
+
3271
+ function DeprecatedModalHeader(_ref2) {
3272
+ let {
3273
+ children,
3274
+ button = true,
3275
+ withDivider = false,
3276
+ exceptionallySetClassName
3277
+ } = _ref2,
3278
+ props = _objectWithoutProperties(_ref2, _excluded2$4);
3279
+
3280
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
3281
+ as: "header",
3282
+ paddingLeft: "large",
3283
+ paddingRight: button === false || button === null ? 'large' : 'small',
3284
+ paddingY: "small",
3285
+ className: exceptionallySetClassName
3286
+ }), /*#__PURE__*/React.createElement(Columns, {
3287
+ space: "large",
3288
+ alignY: "center"
3289
+ }, /*#__PURE__*/React.createElement(Column, {
3290
+ width: "auto"
3291
+ }, children), button === false || button === null ? /*#__PURE__*/React.createElement("div", {
3292
+ className: modules_8f59d13b$1.headerContent
3293
+ }) : /*#__PURE__*/React.createElement(Column, {
3294
+ width: "content",
3295
+ exceptionallySetClassName: modules_8f59d13b$1.buttonContainer,
3296
+ "data-testid": "button-container"
3297
+ }, typeof button === 'boolean' ? /*#__PURE__*/React.createElement(DeprecatedModalCloseButton, {
3298
+ "aria-label": "Close modal",
3299
+ autoFocus: false
3300
+ }) : button))), withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null);
3301
+ }
3302
+ /**
3303
+ * Renders the body of a modal.
3304
+ *
3305
+ * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other
3306
+ * things, that the contet of the modal body expands or contracts depending on the modal height
3307
+ * setting or the size of the content. The body content also automatically scrolls when it's too
3308
+ * large to fit the available space.
3309
+ *
3310
+ * @see DeprecatedModal
3311
+ * @see DeprecatedModalHeader
3312
+ * @see DeprecatedModalFooter
3313
+ */
3314
+
3315
+ function DeprecatedModalBody(_ref3) {
3316
+ let {
3317
+ exceptionallySetClassName,
3318
+ children
3319
+ } = _ref3,
3320
+ props = _objectWithoutProperties(_ref3, _excluded3$3);
3321
+
3322
+ const {
3323
+ height
3324
+ } = React.useContext(ModalContext$1);
3325
+ return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
3326
+ className: exceptionallySetClassName,
3327
+ flexGrow: height === 'expand' ? 1 : 0,
3328
+ height: height === 'expand' ? 'full' : undefined,
3329
+ overflow: "auto"
3330
+ }), /*#__PURE__*/React.createElement(Box, {
3331
+ padding: "large",
3332
+ paddingBottom: "xxlarge"
3333
+ }, children));
3334
+ }
3335
+ /**
3336
+ * Renders a standard modal footer area.
3337
+ *
3338
+ * @see DeprecatedModal
3339
+ * @see DeprecatedModalHeader
3340
+ * @see DeprecatedModalBody
3341
+ */
3342
+
3343
+ function DeprecatedModalFooter(_ref4) {
3344
+ let {
3345
+ exceptionallySetClassName,
3346
+ withDivider = false
3347
+ } = _ref4,
3348
+ props = _objectWithoutProperties(_ref4, _excluded4$2);
3349
+
3350
+ return /*#__PURE__*/React.createElement(React.Fragment, null, withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({
3351
+ as: "footer"
3352
+ }, props), {}, {
3353
+ className: exceptionallySetClassName,
3354
+ padding: "large"
3355
+ })));
3356
+ }
3357
+ /**
3358
+ * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).
3359
+ * @see DeprecatedModalFooter
3360
+ */
3361
+
3362
+ function DeprecatedModalActions(_ref5) {
3363
+ let {
3364
+ children
3365
+ } = _ref5,
3366
+ props = _objectWithoutProperties(_ref5, _excluded5$2);
3367
+
3368
+ return /*#__PURE__*/React.createElement(DeprecatedModalFooter, _objectSpread2({}, props), /*#__PURE__*/React.createElement(Inline, {
3369
+ align: "right",
3370
+ space: "large"
3371
+ }, children));
3372
+ }
3373
+
3110
3374
  exports.Alert = Alert;
3111
3375
  exports.Avatar = Avatar;
3112
3376
  exports.Box = Box;
@@ -3120,6 +3384,12 @@ exports.Columns = Columns;
3120
3384
  exports.DeprecatedButton = Button$1;
3121
3385
  exports.DeprecatedDropdown = Dropdown;
3122
3386
  exports.DeprecatedInput = Input;
3387
+ exports.DeprecatedModal = DeprecatedModal;
3388
+ exports.DeprecatedModalActions = DeprecatedModalActions;
3389
+ exports.DeprecatedModalBody = DeprecatedModalBody;
3390
+ exports.DeprecatedModalCloseButton = DeprecatedModalCloseButton;
3391
+ exports.DeprecatedModalFooter = DeprecatedModalFooter;
3392
+ exports.DeprecatedModalHeader = DeprecatedModalHeader;
3123
3393
  exports.DeprecatedSelect = Select;
3124
3394
  exports.Divider = Divider;
3125
3395
  exports.Heading = Heading;