@helpdice/theme 1.0.0 → 1.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import useTheme from './use-theme';
2
1
  export { default as UiProvider } from './ui-provider';
3
2
  export type { UiProviderProps } from './ui-provider';
4
3
  export { default as Themes } from './themes';
@@ -6,7 +5,18 @@ export type { HUIThemes, HUserTheme } from './themes';
6
5
  export { default as useAllThemes } from './use-all-themes';
7
6
  export type { AllThemesConfig } from './use-all-themes';
8
7
  export { default as CssBaseline } from './css-baseline';
9
- export { default as useTheme } from './use-theme';
10
8
  export { useRect } from './utils/layouts';
11
9
  export type { ReactiveDomReact } from './utils/layouts';
12
- export default useTheme;
10
+ export { default as useCurrentState } from './use-current-state';
11
+ export { default as useTheme } from './use-theme';
12
+ export { default as useClasses } from './use-classes';
13
+ export { default as useToasts } from './use-toasts';
14
+ export type { Toast, ToastInput, ToastAction, ToastLayout } from './use-toasts';
15
+ export { default as useMediaQuery } from './use-media-query';
16
+ export type { ResponsiveOptions, ResponsiveBreakpoint } from './use-media-query';
17
+ export { default as Highlight } from './shared/highlight';
18
+ export type { HighlightProps } from './shared/highlight';
19
+ export { default as Ellipsis } from './shared/ellipsis';
20
+ export { default as Expand } from './shared/expand';
21
+ export { default as Dropdown } from './shared/dropdown';
22
+ export { default as Backdrop } from './shared/backdrop';
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var React = require('react');
6
4
  var reactDom = require('react-dom');
7
5
 
@@ -13,6 +11,9 @@ function _arrayLikeToArray(r, a) {
13
11
  function _arrayWithHoles(r) {
14
12
  if (Array.isArray(r)) return r;
15
13
  }
14
+ function _arrayWithoutHoles(r) {
15
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
16
+ }
16
17
  function _defineProperty(e, r, t) {
17
18
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
18
19
  value: t,
@@ -21,6 +22,18 @@ function _defineProperty(e, r, t) {
21
22
  writable: true
22
23
  }) : e[r] = t, e;
23
24
  }
25
+ function _extends() {
26
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
27
+ for (var e = 1; e < arguments.length; e++) {
28
+ var t = arguments[e];
29
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
30
+ }
31
+ return n;
32
+ }, _extends.apply(null, arguments);
33
+ }
34
+ function _iterableToArray(r) {
35
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
36
+ }
24
37
  function _iterableToArrayLimit(r, l) {
25
38
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
26
39
  if (null != t) {
@@ -51,6 +64,9 @@ function _iterableToArrayLimit(r, l) {
51
64
  function _nonIterableRest() {
52
65
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53
66
  }
67
+ function _nonIterableSpread() {
68
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
69
+ }
54
70
  function ownKeys(e, r) {
55
71
  var t = Object.keys(e);
56
72
  if (Object.getOwnPropertySymbols) {
@@ -95,6 +111,9 @@ function _objectWithoutPropertiesLoose(r, e) {
95
111
  function _slicedToArray(r, e) {
96
112
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
97
113
  }
114
+ function _toConsumableArray(r) {
115
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
116
+ }
98
117
  function _toPrimitive(t, r) {
99
118
  if ("object" != typeof t || !t) return t;
100
119
  var e = t[Symbol.toPrimitive];
@@ -126,6 +145,33 @@ function _unsupportedIterableToArray(r, a) {
126
145
  }
127
146
  }
128
147
 
148
+ var defaultToastLayout = {
149
+ padding: '12px 16px',
150
+ margin: '8px 0',
151
+ width: '420px',
152
+ maxWidth: '90vw',
153
+ maxHeight: '75px',
154
+ placement: 'bottomRight'
155
+ };
156
+ var defaultParams = {
157
+ toasts: [],
158
+ toastLayout: defaultToastLayout,
159
+ updateToastLayout: function updateToastLayout(t) {
160
+ return t;
161
+ },
162
+ updateToasts: function updateToasts(t) {
163
+ return t;
164
+ },
165
+ lastUpdateToastId: null,
166
+ updateLastToastId: function updateLastToastId() {
167
+ return null;
168
+ }
169
+ };
170
+ var HUIContent = /*#__PURE__*/React.createContext(defaultParams);
171
+ var useHUIContext = function useHUIContext() {
172
+ return React.useContext(HUIContent);
173
+ };
174
+
129
175
  var defaultFont = {
130
176
  sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
131
177
  mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
@@ -375,33 +421,6 @@ var useTheme = function useTheme() {
375
421
  return React.useContext(ThemeContext);
376
422
  };
377
423
 
378
- var defaultToastLayout = {
379
- padding: '12px 16px',
380
- margin: '8px 0',
381
- width: '420px',
382
- maxWidth: '90vw',
383
- maxHeight: '75px',
384
- placement: 'bottomRight'
385
- };
386
- var defaultParams = {
387
- toasts: [],
388
- toastLayout: defaultToastLayout,
389
- updateToastLayout: function updateToastLayout(t) {
390
- return t;
391
- },
392
- updateToasts: function updateToasts(t) {
393
- return t;
394
- },
395
- lastUpdateToastId: null,
396
- updateLastToastId: function updateLastToastId() {
397
- return null;
398
- }
399
- };
400
- var HUIContent = /*#__PURE__*/React.createContext(defaultParams);
401
- var useHUIContext = function useHUIContext() {
402
- return React.useContext(HUIContent);
403
- };
404
-
405
424
  /* "use client" */
406
425
 
407
426
  var defaultAllThemesConfig = {
@@ -1062,7 +1081,7 @@ var usePortal = function usePortal() {
1062
1081
  return elSnapshot;
1063
1082
  };
1064
1083
 
1065
- var _excluded = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
1084
+ var _excluded$2 = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
1066
1085
  var CssTransition = function CssTransition(_ref) {
1067
1086
  var children = _ref.children,
1068
1087
  _ref$className = _ref.className,
@@ -1077,7 +1096,7 @@ var CssTransition = function CssTransition(_ref) {
1077
1096
  clearTime = _ref$clearTime === void 0 ? 60 : _ref$clearTime,
1078
1097
  _ref$name = _ref.name,
1079
1098
  name = _ref$name === void 0 ? 'transition' : _ref$name,
1080
- props = _objectWithoutProperties(_ref, _excluded);
1099
+ props = _objectWithoutProperties(_ref, _excluded$2);
1081
1100
  var _useState = React.useState(''),
1082
1101
  _useState2 = _slicedToArray(_useState, 2),
1083
1102
  classes = _useState2[0],
@@ -1452,7 +1471,7 @@ var getElementOffset = function getElementOffset(el) {
1452
1471
  left: left
1453
1472
  };
1454
1473
  };
1455
- var defaultRect = {
1474
+ var defaultRect$1 = {
1456
1475
  top: -1e3,
1457
1476
  left: -1e3,
1458
1477
  right: -1e3,
@@ -1461,7 +1480,7 @@ var defaultRect = {
1461
1480
  elementTop: -1e3
1462
1481
  };
1463
1482
  var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect, getContainer) {
1464
- if (!domRect) return defaultRect;
1483
+ if (!domRect) return defaultRect$1;
1465
1484
  var container = getContainer ? getContainer() : null;
1466
1485
  var scrollElement = container || document.documentElement;
1467
1486
  var _getElementOffset = getElementOffset(container),
@@ -1475,22 +1494,26 @@ var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect,
1475
1494
  elementTop: domRect.top + scrollElement.scrollTop - offsetTop
1476
1495
  });
1477
1496
  };
1497
+ var isUnplacedRect = function isUnplacedRect(rect) {
1498
+ if (!rect) return true;
1499
+ return rect.top === defaultRect$1.top && rect.left === defaultRect$1.left;
1500
+ };
1478
1501
  var getRefRect = function getRefRect(ref, getContainer) {
1479
- if (!ref || !ref.current) return defaultRect;
1502
+ if (!ref || !ref.current) return defaultRect$1;
1480
1503
  var rect = ref.current.getBoundingClientRect();
1481
1504
  return getRectFromDOMWithContainer(rect, getContainer);
1482
1505
  };
1483
1506
  var getEventRect = function getEventRect(event, getContainer) {
1484
1507
  var _event$target;
1485
1508
  var rect = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getBoundingClientRect();
1486
- if (!rect) return defaultRect;
1509
+ if (!rect) return defaultRect$1;
1487
1510
  return getRectFromDOMWithContainer(rect, getContainer);
1488
1511
  };
1489
1512
  var isRefTarget = function isRefTarget(eventOrRef) {
1490
1513
  return typeof (eventOrRef === null || eventOrRef === void 0 ? void 0 : eventOrRef.target) === 'undefined';
1491
1514
  };
1492
1515
  var useRect = function useRect(initialState) {
1493
- var _useState = React.useState(initialState || defaultRect),
1516
+ var _useState = React.useState(initialState || defaultRect$1),
1494
1517
  _useState2 = _slicedToArray(_useState, 2),
1495
1518
  rect = _useState2[0],
1496
1519
  setRect = _useState2[1];
@@ -1504,13 +1527,581 @@ var useRect = function useRect(initialState) {
1504
1527
  };
1505
1528
  };
1506
1529
 
1507
- // @ts-ignore
1508
- /// <reference types="styled-jsx" />
1530
+ var defaultToast = {
1531
+ delay: 2000,
1532
+ type: 'default'
1533
+ };
1534
+ var useToasts = function useToasts(layout) {
1535
+ var _useHUIContext = useHUIContext(),
1536
+ updateToasts = _useHUIContext.updateToasts,
1537
+ toasts = _useHUIContext.toasts,
1538
+ updateToastLayout = _useHUIContext.updateToastLayout,
1539
+ updateLastToastId = _useHUIContext.updateLastToastId;
1540
+ React.useEffect(function () {
1541
+ if (!layout) return;
1542
+ updateToastLayout(function () {
1543
+ return layout ? _objectSpread2(_objectSpread2({}, defaultToastLayout), layout) : defaultToastLayout;
1544
+ });
1545
+ }, []);
1546
+ var _cancel = function cancel(internalId) {
1547
+ updateToasts(function (currentToasts) {
1548
+ return currentToasts.map(function (item) {
1549
+ if (item._internalIdent !== internalId) return item;
1550
+ return _objectSpread2(_objectSpread2({}, item), {}, {
1551
+ visible: false
1552
+ });
1553
+ });
1554
+ });
1555
+ updateLastToastId(function () {
1556
+ return internalId;
1557
+ });
1558
+ };
1559
+ var removeAll = function removeAll() {
1560
+ updateToasts(function (last) {
1561
+ return last.map(function (toast) {
1562
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
1563
+ visible: false
1564
+ });
1565
+ });
1566
+ });
1567
+ };
1568
+ var findToastOneByID = function findToastOneByID(id) {
1569
+ return toasts.find(function (t) {
1570
+ return t.id === id;
1571
+ });
1572
+ };
1573
+ var removeToastOneByID = function removeToastOneByID(id) {
1574
+ updateToasts(function (last) {
1575
+ return last.map(function (toast) {
1576
+ if (toast.id !== id) return toast;
1577
+ return _objectSpread2(_objectSpread2({}, toast), {}, {
1578
+ visible: false
1579
+ });
1580
+ });
1581
+ });
1582
+ };
1583
+ var setToast = function setToast(toast) {
1584
+ var internalIdent = "toast-".concat(getId());
1585
+ var delay = toast.delay || defaultToast.delay;
1586
+ if (toast.id) {
1587
+ var hasIdent = toasts.find(function (t) {
1588
+ return t.id === toast.id;
1589
+ });
1590
+ if (hasIdent) {
1591
+ throw new Error('Toast: Already have the same key: "ident"');
1592
+ }
1593
+ }
1594
+ updateToasts(function (last) {
1595
+ var newToast = {
1596
+ delay: delay,
1597
+ text: toast.text,
1598
+ visible: true,
1599
+ type: toast.type || defaultToast.type,
1600
+ id: toast.id || internalIdent,
1601
+ actions: toast.actions || [],
1602
+ _internalIdent: internalIdent,
1603
+ _timeout: window.setTimeout(function () {
1604
+ _cancel(internalIdent);
1605
+ if (newToast._timeout) {
1606
+ window.clearTimeout(newToast._timeout);
1607
+ newToast._timeout = null;
1608
+ }
1609
+ }, delay),
1610
+ cancel: function cancel() {
1611
+ return _cancel(internalIdent);
1612
+ }
1613
+ };
1614
+ return [].concat(_toConsumableArray(last), [newToast]);
1615
+ });
1616
+ };
1617
+ return {
1618
+ toasts: toasts,
1619
+ setToast: setToast,
1620
+ removeAll: removeAll,
1621
+ findToastOneByID: findToastOneByID,
1622
+ removeToastOneByID: removeToastOneByID
1623
+ };
1624
+ };
1625
+
1626
+ tuple('xs', 'sm', 'md', 'lg', 'xl', 'mobile');
1627
+ tuple('up', 'down', 'default');
1628
+ var defaultResponsiveOptions = {
1629
+ match: 'default'
1630
+ };
1631
+ var makeQueries = function makeQueries(bp, up, down) {
1632
+ var queryString = function queryString(item) {
1633
+ var upQuery = "(min-width: ".concat(item.min, ")");
1634
+ var downQuery = "(max-width: ".concat(item.max, ")");
1635
+ return up ? upQuery : down ? downQuery : "".concat(upQuery, " and ").concat(downQuery);
1636
+ };
1637
+ var xs = queryString(bp.xs);
1638
+ return {
1639
+ xs: xs,
1640
+ mobile: xs,
1641
+ sm: queryString(bp.sm),
1642
+ md: queryString(bp.md),
1643
+ lg: queryString(bp.lg),
1644
+ xl: queryString(bp.xl)
1645
+ };
1646
+ };
1647
+ var useMediaQuery = function useMediaQuery(breakpoint) {
1648
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultResponsiveOptions;
1649
+ var _options$match = options.match,
1650
+ matchType = _options$match === void 0 ? 'default' : _options$match,
1651
+ _options$ssrMatchMedi = options.ssrMatchMedia,
1652
+ ssrMatchMedia = _options$ssrMatchMedi === void 0 ? null : _options$ssrMatchMedi;
1653
+ var supportMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
1654
+ var theme = useTheme();
1655
+ var mediaQueries = React.useMemo(function () {
1656
+ var up = matchType === 'up';
1657
+ var down = matchType === 'down';
1658
+ return makeQueries(theme.breakpoints, up, down);
1659
+ }, [theme.breakpoints, options]);
1660
+ var query = React.useMemo(function () {
1661
+ return mediaQueries[breakpoint];
1662
+ }, [mediaQueries, breakpoint]);
1663
+ var matchQuery = function matchQuery(q) {
1664
+ return window.matchMedia(q);
1665
+ };
1666
+
1667
+ /**
1668
+ * Do nothing in the server-side rendering.
1669
+ * If server match query fucntion is simulated, return user-defined value first.
1670
+ */
1671
+ var _useState = React.useState(function () {
1672
+ if (supportMedia) return matchQuery(query).matches;
1673
+ if (ssrMatchMedia && typeof ssrMatchMedia === 'function') {
1674
+ return ssrMatchMedia(query).matches;
1675
+ }
1676
+ return false;
1677
+ }),
1678
+ _useState2 = _slicedToArray(_useState, 2),
1679
+ state = _useState2[0],
1680
+ setState = _useState2[1];
1681
+ React.useEffect(function () {
1682
+ if (!supportMedia) return;
1683
+ var queryList = matchQuery(query);
1684
+ var update = function update() {
1685
+ return setState(matchQuery(query).matches);
1686
+ };
1687
+ update();
1688
+
1689
+ /**
1690
+ * addListener is deprecated. EventTarget.addEventListener is recommended.
1691
+ * But in some old browsers, MediaQueryList does not inherit from EventTarget.
1692
+ */
1693
+ queryList.addListener(update);
1694
+ return function () {
1695
+ queryList.removeListener(update);
1696
+ };
1697
+ }, [supportMedia]);
1698
+ return state;
1699
+ };
1700
+
1701
+ /* "use client" */
1702
+
1703
+ var usePrevious = function usePrevious(state) {
1704
+ var ref = React.useRef(null);
1705
+ React.useEffect(function () {
1706
+ ref.current = state;
1707
+ });
1708
+ return ref ? ref.current : null;
1709
+ };
1710
+
1711
+ var _excluded$1 = ["rect", "visible", "hoverHeightRatio", "hoverWidthRatio", "activeOpacity", "className"];
1712
+ var Highlight = function Highlight(_ref) {
1713
+ var rect = _ref.rect,
1714
+ visible = _ref.visible,
1715
+ _ref$hoverHeightRatio = _ref.hoverHeightRatio,
1716
+ hoverHeightRatio = _ref$hoverHeightRatio === void 0 ? 1 : _ref$hoverHeightRatio,
1717
+ _ref$hoverWidthRatio = _ref.hoverWidthRatio,
1718
+ hoverWidthRatio = _ref$hoverWidthRatio === void 0 ? 1 : _ref$hoverWidthRatio,
1719
+ _ref$activeOpacity = _ref.activeOpacity,
1720
+ activeOpacity = _ref$activeOpacity === void 0 ? 0.8 : _ref$activeOpacity,
1721
+ className = _ref.className,
1722
+ props = _objectWithoutProperties(_ref, _excluded$1);
1723
+ var theme = useTheme();
1724
+ var ref = React.useRef(null);
1725
+ var isFirstVisible = usePrevious(isUnplacedRect(rect));
1726
+ var position = React.useMemo(function () {
1727
+ var width = rect.width * hoverWidthRatio;
1728
+ var height = rect.height * hoverHeightRatio;
1729
+ return {
1730
+ width: "".concat(width, "px"),
1731
+ left: "".concat(rect.left + (rect.width - width) / 2, "px"),
1732
+ height: "".concat(height, "px"),
1733
+ top: "".concat(rect.elementTop + (rect.height - height) / 2, "px"),
1734
+ transition: isFirstVisible ? 'opacity' : 'opacity, width, left, top'
1735
+ };
1736
+ }, [rect, hoverWidthRatio, hoverHeightRatio]);
1737
+ return /*#__PURE__*/React.createElement("div", _extends({
1738
+ ref: ref
1739
+ }, props, {
1740
+ className: _JSXStyle.dynamic([["603024321", [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]]]) + " " + (props && props.className != null && props.className || useClasses('highlight', className) || "")
1741
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
1742
+ id: "603024321",
1743
+ dynamic: [theme.palette.accents_2, position.width, position.left, position.height, position.top, visible ? activeOpacity : 0, position.transition]
1744
+ }, ".highlight.__jsx-style-dynamic-selector{background:".concat(theme.palette.accents_2, ";position:absolute;border-radius:5px;width:").concat(position.width, ";left:").concat(position.left, ";height:").concat(position.height, ";top:").concat(position.top, ";opacity:").concat(visible ? activeOpacity : 0, ";-webkit-transition:0.15s ease;transition:0.15s ease;-webkit-transition-property:").concat(position.transition, ";transition-property:").concat(position.transition, ";}")));
1745
+ };
1746
+
1747
+ var Ellipsis = function Ellipsis(_ref) {
1748
+ var children = _ref.children,
1749
+ height = _ref.height;
1750
+ return /*#__PURE__*/React.createElement("span", {
1751
+ className: _JSXStyle.dynamic([["822089635", [height]]])
1752
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
1753
+ id: "822089635",
1754
+ dynamic: [height]
1755
+ }, "span.__jsx-style-dynamic-selector{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:".concat(height, ";min-width:0;}")));
1756
+ };
1757
+ var ellipsis = /*#__PURE__*/React.memo(Ellipsis);
1758
+
1759
+ var getRealShape = function getRealShape(el) {
1760
+ var defaultShape = {
1761
+ width: 0,
1762
+ height: 0
1763
+ };
1764
+ if (!el || typeof window === 'undefined') return defaultShape;
1765
+ var rect = el.getBoundingClientRect();
1766
+ var _window$getComputedSt = window.getComputedStyle(el),
1767
+ width = _window$getComputedSt.width,
1768
+ height = _window$getComputedSt.height;
1769
+ var getCSSStyleVal = function getCSSStyleVal(str, parentNum) {
1770
+ if (!str) return 0;
1771
+ var strVal = str.includes('px') ? +str.split('px')[0] : str.includes('%') ? +str.split('%')[0] * parentNum * 0.01 : str;
1772
+ return Number.isNaN(+strVal) ? 0 : +strVal;
1773
+ };
1774
+ return {
1775
+ width: getCSSStyleVal("".concat(width), rect.width),
1776
+ height: getCSSStyleVal("".concat(height), rect.height)
1777
+ };
1778
+ };
1779
+ var useRealShape = function useRealShape(ref) {
1780
+ var _useState = React.useState({
1781
+ width: 0,
1782
+ height: 0
1783
+ }),
1784
+ _useState2 = _slicedToArray(_useState, 2),
1785
+ state = _useState2[0],
1786
+ setState = _useState2[1];
1787
+ var update = function update() {
1788
+ var _getRealShape = getRealShape(ref.current),
1789
+ width = _getRealShape.width,
1790
+ height = _getRealShape.height;
1791
+ setState({
1792
+ width: width,
1793
+ height: height
1794
+ });
1795
+ };
1796
+ React.useEffect(function () {
1797
+ return update();
1798
+ }, [ref.current]);
1799
+ return [state, update];
1800
+ };
1801
+
1802
+ var Expand = function Expand(_ref) {
1803
+ var _ref$isExpanded = _ref.isExpanded,
1804
+ isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
1805
+ _ref$delay = _ref.delay,
1806
+ delay = _ref$delay === void 0 ? 200 : _ref$delay,
1807
+ children = _ref.children;
1808
+ var _useState = React.useState(isExpanded ? 'auto' : '0'),
1809
+ _useState2 = _slicedToArray(_useState, 2),
1810
+ height = _useState2[0],
1811
+ setHeight = _useState2[1];
1812
+ var _useState3 = React.useState(isExpanded),
1813
+ _useState4 = _slicedToArray(_useState3, 2),
1814
+ selfExpanded = _useState4[0],
1815
+ setSelfExpanded = _useState4[1];
1816
+ var _useState5 = React.useState(isExpanded),
1817
+ _useState6 = _slicedToArray(_useState5, 2),
1818
+ visible = _useState6[0],
1819
+ setVisible = _useState6[1];
1820
+ var contentRef = React.useRef(null);
1821
+ var entryTimer = React.useRef();
1822
+ var leaveTimer = React.useRef();
1823
+ var resetTimer = React.useRef();
1824
+ var _useRealShape = useRealShape(contentRef),
1825
+ _useRealShape2 = _slicedToArray(_useRealShape, 2),
1826
+ state = _useRealShape2[0],
1827
+ updateShape = _useRealShape2[1];
1828
+ var classes = useClasses('container', {
1829
+ expanded: selfExpanded
1830
+ });
1831
+ React.useEffect(function () {
1832
+ return setHeight("".concat(state.height, "px"));
1833
+ }, [state.height]);
1834
+ React.useEffect(function () {
1835
+ // show element or reset height.
1836
+ // force an update once manually, even if the element does not change.
1837
+ // (the height of the element might be "auto")
1838
+ if (isExpanded) {
1839
+ setVisible(isExpanded);
1840
+ } else {
1841
+ updateShape();
1842
+ setHeight("".concat(state.height, "px"));
1843
+ }
1844
+
1845
+ // show expand animation
1846
+ entryTimer.current = window.setTimeout(function () {
1847
+ setSelfExpanded(isExpanded);
1848
+ clearTimeout(entryTimer.current);
1849
+ }, 30);
1850
+
1851
+ // Reset height after animation
1852
+ if (isExpanded) {
1853
+ resetTimer.current = window.setTimeout(function () {
1854
+ setHeight('auto');
1855
+ clearTimeout(resetTimer.current);
1856
+ }, delay);
1857
+ } else {
1858
+ leaveTimer.current = window.setTimeout(function () {
1859
+ setVisible(isExpanded);
1860
+ clearTimeout(leaveTimer.current);
1861
+ }, delay / 2);
1862
+ }
1863
+ return function () {
1864
+ clearTimeout(entryTimer.current);
1865
+ clearTimeout(leaveTimer.current);
1866
+ clearTimeout(resetTimer.current);
1867
+ };
1868
+ }, [isExpanded]);
1869
+ return /*#__PURE__*/React.createElement("div", {
1870
+ className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + (classes || "")
1871
+ }, /*#__PURE__*/React.createElement("div", {
1872
+ ref: contentRef,
1873
+ className: _JSXStyle.dynamic([["1918690829", [visible ? 'visible' : 'hidden', delay, height]]]) + " " + "content"
1874
+ }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
1875
+ id: "1918690829",
1876
+ dynamic: [visible ? 'visible' : 'hidden', delay, height]
1877
+ }, ".container.__jsx-style-dynamic-selector{padding:0;margin:0;height:0;overflow:hidden;visibility:".concat(visible ? 'visible' : 'hidden', ";-webkit-transition:height ").concat(delay, "ms ease;transition:height ").concat(delay, "ms ease;}.expanded.__jsx-style-dynamic-selector{height:").concat(height, ";visibility:visible;}")));
1878
+ };
1879
+ Expand.displayName = 'Expand';
1880
+
1881
+ /* "use client" */
1882
+
1883
+ var useResize = function useResize(callback) {
1884
+ var immediatelyInvoke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1885
+ React.useEffect(function () {
1886
+ var fn = function fn() {
1887
+ return callback();
1888
+ };
1889
+ if (immediatelyInvoke) {
1890
+ fn();
1891
+ }
1892
+ window.addEventListener('resize', fn);
1893
+ return function () {
1894
+ return window.removeEventListener('resize', fn);
1895
+ };
1896
+ }, []);
1897
+ };
1898
+
1899
+ /* "use client" */
1900
+
1901
+ var useClickAnyWhere = function useClickAnyWhere(handler) {
1902
+ React.useEffect(function () {
1903
+ var callback = function callback(event) {
1904
+ return handler(event);
1905
+ };
1906
+ document.addEventListener('click', callback);
1907
+ return function () {
1908
+ return document.removeEventListener('click', callback);
1909
+ };
1910
+ }, [handler]);
1911
+ };
1912
+
1913
+ /* "use client" */
1914
+
1915
+ var useDOMObserver = function useDOMObserver(ref) {
1916
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
1917
+ var config = {
1918
+ attributes: false,
1919
+ childList: true,
1920
+ subtree: true
1921
+ };
1922
+ React.useEffect(function () {
1923
+ if (!ref || !ref.current) return;
1924
+ var unmount = false;
1925
+ var done = function done() {
1926
+ if (unmount) return;
1927
+ callback.apply(void 0, arguments);
1928
+ };
1929
+ var observer = new MutationObserver(done);
1930
+ observer.observe(ref.current, config);
1931
+ return function () {
1932
+ unmount = true;
1933
+ observer.disconnect();
1934
+ };
1935
+ }, [ref]);
1936
+ };
1937
+
1938
+ var warningStack = {};
1939
+ var useWarning = function useWarning(message, component) {
1940
+ var tag = ' ';
1941
+ var log = "[Helpdice UI]".concat(tag, ": ").concat(message);
1942
+ if (typeof console === 'undefined') return;
1943
+ if (warningStack[log]) return;
1944
+ warningStack[log] = true;
1945
+ if (process.env.NODE_ENV !== 'production') {
1946
+ return console.error(log);
1947
+ }
1948
+ console.warn(log);
1949
+ };
1950
+
1951
+ var defaultRect = {
1952
+ top: -1e3,
1953
+ left: -1e3,
1954
+ right: -1e3,
1955
+ width: 0
1956
+ };
1957
+ var Dropdown = /*#__PURE__*/React.memo(function (_ref) {
1958
+ var children = _ref.children,
1959
+ parent = _ref.parent,
1960
+ visible = _ref.visible,
1961
+ disableMatchWidth = _ref.disableMatchWidth,
1962
+ getPopupContainer = _ref.getPopupContainer;
1963
+ var el = usePortal('dropdown', getPopupContainer);
1964
+ var _useState = React.useState(defaultRect),
1965
+ _useState2 = _slicedToArray(_useState, 2),
1966
+ rect = _useState2[0],
1967
+ setRect = _useState2[1];
1968
+ var classes = useClasses('dropdown', disableMatchWidth ? 'disable-match' : 'width-match');
1969
+ if (!parent) return null;
1970
+
1971
+ /* istanbul ignore next */
1972
+ if (process.env.NODE_ENV !== 'production') {
1973
+ if (getPopupContainer && getPopupContainer()) {
1974
+ var _el = getPopupContainer();
1975
+ var style = window.getComputedStyle(_el);
1976
+ if (style.position === 'static') {
1977
+ useWarning('The element specified by "getPopupContainer" must have "position" set.');
1978
+ }
1979
+ }
1980
+ }
1981
+ var updateRect = function updateRect() {
1982
+ var _getRefRect = getRefRect(parent, getPopupContainer),
1983
+ top = _getRefRect.top,
1984
+ left = _getRefRect.left,
1985
+ right = _getRefRect.right,
1986
+ nativeWidth = _getRefRect.width;
1987
+ setRect({
1988
+ top: top,
1989
+ left: left,
1990
+ right: right,
1991
+ width: nativeWidth
1992
+ });
1993
+ };
1994
+ useResize(updateRect);
1995
+ useClickAnyWhere(function () {
1996
+ var _getRefRect2 = getRefRect(parent, getPopupContainer),
1997
+ top = _getRefRect2.top,
1998
+ left = _getRefRect2.left;
1999
+ var shouldUpdatePosition = top !== rect.top || left !== rect.left;
2000
+ if (!shouldUpdatePosition) return;
2001
+ updateRect();
2002
+ });
2003
+ useDOMObserver(parent, function () {
2004
+ updateRect();
2005
+ });
2006
+ React.useEffect(function () {
2007
+ if (!parent || !parent.current) return;
2008
+ parent.current.addEventListener('mouseenter', updateRect);
2009
+ /* istanbul ignore next */
2010
+ return function () {
2011
+ if (!parent || !parent.current) return;
2012
+ parent.current.removeEventListener('mouseenter', updateRect);
2013
+ };
2014
+ }, [parent]);
2015
+ var clickHandler = function clickHandler(event) {
2016
+ event.stopPropagation();
2017
+ event.nativeEvent.stopImmediatePropagation();
2018
+ event.preventDefault();
2019
+ };
2020
+ var mouseDownHandler = function mouseDownHandler(event) {
2021
+ event.preventDefault();
2022
+ };
2023
+ if (!el) return null;
2024
+ return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement(CssTransition, {
2025
+ visible: visible
2026
+ }, /*#__PURE__*/React.createElement("div", {
2027
+ onClick: clickHandler,
2028
+ onMouseDown: mouseDownHandler,
2029
+ className: _JSXStyle.dynamic([["1644673105", [rect.top + 2, rect.left, rect.width, rect.width]]]) + " " + (classes || "")
2030
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
2031
+ id: "1644673105",
2032
+ dynamic: [rect.top + 2, rect.left, rect.width, rect.width]
2033
+ }, ".dropdown.__jsx-style-dynamic-selector{position:absolute;top:".concat(rect.top + 2, "px;left:").concat(rect.left, "px;z-index:1100;}.width-match.__jsx-style-dynamic-selector{width:").concat(rect.width, "px;}.disable-match.__jsx-style-dynamic-selector{min-width:").concat(rect.width, "px;}")))), el);
2034
+ });
2035
+
2036
+ var _excluded = ["children", "onClick", "visible", "width", "onContentClick", "backdropClassName", "positionClassName", "layerClassName"];
2037
+ var Backdrop = /*#__PURE__*/React.memo(function (_ref) {
2038
+ var children = _ref.children,
2039
+ _ref$onClick = _ref.onClick,
2040
+ onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
2041
+ _ref$visible = _ref.visible,
2042
+ visible = _ref$visible === void 0 ? false : _ref$visible,
2043
+ width = _ref.width,
2044
+ _ref$onContentClick = _ref.onContentClick,
2045
+ onContentClick = _ref$onContentClick === void 0 ? function () {} : _ref$onContentClick,
2046
+ _ref$backdropClassNam = _ref.backdropClassName,
2047
+ backdropClassName = _ref$backdropClassNam === void 0 ? '' : _ref$backdropClassNam,
2048
+ _ref$positionClassNam = _ref.positionClassName,
2049
+ positionClassName = _ref$positionClassNam === void 0 ? '' : _ref$positionClassNam,
2050
+ _ref$layerClassName = _ref.layerClassName,
2051
+ layerClassName = _ref$layerClassName === void 0 ? '' : _ref$layerClassName,
2052
+ props = _objectWithoutProperties(_ref, _excluded);
2053
+ var theme = useTheme();
2054
+ var _useCurrentState = useCurrentState(false),
2055
+ _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
2056
+ setIsContentMouseDown = _useCurrentState2[1],
2057
+ IsContentMouseDownRef = _useCurrentState2[2];
2058
+ var clickHandler = function clickHandler(event) {
2059
+ if (IsContentMouseDownRef.current) return;
2060
+ onClick && onClick(event);
2061
+ };
2062
+ var mouseUpHandler = function mouseUpHandler() {
2063
+ if (!IsContentMouseDownRef.current) return;
2064
+ var timer = setTimeout(function () {
2065
+ setIsContentMouseDown(false);
2066
+ clearTimeout(timer);
2067
+ }, 0);
2068
+ };
2069
+ return /*#__PURE__*/React.createElement(CssTransition, {
2070
+ name: "backdrop-wrapper",
2071
+ visible: visible,
2072
+ clearTime: 300
2073
+ }, /*#__PURE__*/React.createElement("div", _extends({
2074
+ onClick: clickHandler,
2075
+ onMouseUp: mouseUpHandler
2076
+ }, props, {
2077
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (props && props.className != null && props.className || useClasses('backdrop', backdropClassName) || "")
2078
+ }), /*#__PURE__*/React.createElement("div", {
2079
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('layer', layerClassName) || "")
2080
+ }), /*#__PURE__*/React.createElement("div", {
2081
+ onClick: onContentClick,
2082
+ onMouseDown: function onMouseDown() {
2083
+ return setIsContentMouseDown(true);
2084
+ },
2085
+ className: _JSXStyle.dynamic([["2021762493", [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]]]) + " " + (useClasses('position', positionClassName) || "")
2086
+ }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
2087
+ id: "2021762493",
2088
+ dynamic: [width, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity, theme.expressiveness.portalOpacity]
2089
+ }, ".backdrop.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;overflow:auto;z-index:1000;-webkit-overflow-scrolling:touch;box-sizing:border-box;text-align:center;}.position.__jsx-style-dynamic-selector{position:relative;z-index:1001;outline:none;max-width:90%;width:".concat(width, ";margin:20px auto;vertical-align:middle;display:inline-block;}.backdrop.__jsx-style-dynamic-selector:before{display:inline-block;width:0;height:100%;vertical-align:middle;content:'';}.layer.__jsx-style-dynamic-selector{position:fixed;top:0;left:0;right:0;bottom:0;width:100%;height:100%;opacity:").concat(theme.expressiveness.portalOpacity, ";background-color:black;-webkit-transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);transition:opacity 0.35s cubic-bezier(0.4,0,0.2,1);pointer-events:none;z-index:1000;}.backdrop-wrapper-enter.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}.backdrop-wrapper-enter-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:").concat(theme.expressiveness.portalOpacity, ";}.backdrop-wrapper-leave-active.__jsx-style-dynamic-selector .layer.__jsx-style-dynamic-selector{opacity:0;}"))));
2090
+ });
2091
+ Backdrop.displayName = 'Backdrop';
1509
2092
 
2093
+ exports.Backdrop = Backdrop;
1510
2094
  exports.CssBaseline = MemoCssBaseline;
2095
+ exports.Dropdown = Dropdown;
2096
+ exports.Ellipsis = ellipsis;
2097
+ exports.Expand = Expand;
2098
+ exports.Highlight = Highlight;
1511
2099
  exports.Themes = Themes;
1512
2100
  exports.UiProvider = HuiProvider;
1513
- exports.default = useTheme;
1514
2101
  exports.useAllThemes = useAllThemes;
2102
+ exports.useClasses = useClasses;
2103
+ exports.useCurrentState = useCurrentState;
2104
+ exports.useMediaQuery = useMediaQuery;
1515
2105
  exports.useRect = useRect;
1516
2106
  exports.useTheme = useTheme;
2107
+ exports.useToasts = useToasts;
@@ -0,0 +1,14 @@
1
+ import React, { MouseEvent } from 'react';
2
+ interface Props {
3
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
4
+ visible?: boolean;
5
+ width?: string;
6
+ onContentClick?: (event: MouseEvent<HTMLElement>) => void;
7
+ backdropClassName?: string;
8
+ positionClassName?: string;
9
+ layerClassName?: string;
10
+ }
11
+ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>;
12
+ export type BackdropProps = Props & NativeAttrs;
13
+ declare const Backdrop: React.FC<React.PropsWithChildren<BackdropProps>>;
14
+ export default Backdrop;
@@ -0,0 +1,9 @@
1
+ import React, { MutableRefObject } from 'react';
2
+ interface Props {
3
+ parent?: MutableRefObject<HTMLElement | null> | undefined;
4
+ visible: boolean;
5
+ disableMatchWidth?: boolean;
6
+ getPopupContainer?: () => HTMLElement | null;
7
+ }
8
+ declare const Dropdown: React.FC<React.PropsWithChildren<Props>>;
9
+ export default Dropdown;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export type EllipsisProps = {
3
+ height: string;
4
+ };
5
+ declare const _default: React.NamedExoticComponent<React.PropsWithChildren<EllipsisProps>>;
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export type ExpandProps = {
3
+ isExpanded?: boolean;
4
+ delay?: number;
5
+ };
6
+ declare const Expand: React.FC<React.PropsWithChildren<ExpandProps>>;
7
+ export default Expand;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ReactiveDomReact } from '../utils/layouts';
3
+ type Props = {
4
+ rect: ReactiveDomReact;
5
+ visible?: boolean;
6
+ hoverHeightRatio?: number;
7
+ hoverWidthRatio?: number;
8
+ activeOpacity?: number;
9
+ };
10
+ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>;
11
+ export type HighlightProps = Props & NativeAttrs;
12
+ declare const Highlight: React.FC<HighlightProps>;
13
+ export default Highlight;
@@ -0,0 +1,3 @@
1
+ import useMediaQuery from './use-media-query';
2
+ export type { ResponsiveBreakpoint, ResponsiveOptions } from './use-media-query';
3
+ export default useMediaQuery;
@@ -0,0 +1,12 @@
1
+ declare const breakpoints: ["xs", "sm", "md", "lg", "xl", "mobile"];
2
+ export type ResponsiveBreakpoint = typeof breakpoints[number];
3
+ declare const matchType: ["up", "down", "default"];
4
+ export type ResponsiveMatchType = typeof matchType[number];
5
+ export type ResponsiveOptions = {
6
+ match?: ResponsiveMatchType;
7
+ ssrMatchMedia?: (query: string) => {
8
+ matches: boolean;
9
+ };
10
+ };
11
+ declare const useMediaQuery: (breakpoint: ResponsiveBreakpoint, options?: ResponsiveOptions) => boolean;
12
+ export default useMediaQuery;
@@ -0,0 +1,3 @@
1
+ import useToasts from './use-toast';
2
+ export type { ToastAction, Toast, ToastTypes, ToastInput, ToastLayout } from './use-toast';
3
+ export default useToasts;
@@ -0,0 +1,2 @@
1
+ declare const useClickAnyWhere: (handler: (event: Event) => void) => void;
2
+ export default useClickAnyWhere;
@@ -0,0 +1,3 @@
1
+ import { MutableRefObject } from 'react';
2
+ declare const useDOMObserver: (ref: MutableRefObject<HTMLElement | null> | undefined, callback?: MutationCallback) => void;
3
+ export default useDOMObserver;
@@ -0,0 +1,2 @@
1
+ declare const usePrevious: <T>(state: T) => T | undefined | null;
2
+ export default usePrevious;
@@ -0,0 +1,9 @@
1
+ import { MutableRefObject } from 'react';
2
+ export type ShapeType = {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ export declare const getRealShape: (el: HTMLElement | null) => ShapeType;
7
+ export type ShapeResult = [ShapeType, () => void];
8
+ declare const useRealShape: <T extends HTMLElement>(ref: MutableRefObject<T | null>) => ShapeResult;
9
+ export default useRealShape;
@@ -0,0 +1,2 @@
1
+ declare const useResize: (callback: () => unknown, immediatelyInvoke?: boolean) => void;
2
+ export default useResize;
@@ -0,0 +1,2 @@
1
+ declare const useWarning: (message: string, component?: string) => void;
2
+ export default useWarning;
package/esm/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import useTheme from './use-theme';
2
1
  export { default as UiProvider } from './ui-provider';
3
2
  export type { UiProviderProps } from './ui-provider';
4
3
  export { default as Themes } from './themes';
@@ -6,7 +5,18 @@ export type { HUIThemes, HUserTheme } from './themes';
6
5
  export { default as useAllThemes } from './use-all-themes';
7
6
  export type { AllThemesConfig } from './use-all-themes';
8
7
  export { default as CssBaseline } from './css-baseline';
9
- export { default as useTheme } from './use-theme';
10
8
  export { useRect } from './utils/layouts';
11
9
  export type { ReactiveDomReact } from './utils/layouts';
12
- export default useTheme;
10
+ export { default as useCurrentState } from './use-current-state';
11
+ export { default as useTheme } from './use-theme';
12
+ export { default as useClasses } from './use-classes';
13
+ export { default as useToasts } from './use-toasts';
14
+ export type { Toast, ToastInput, ToastAction, ToastLayout } from './use-toasts';
15
+ export { default as useMediaQuery } from './use-media-query';
16
+ export type { ResponsiveOptions, ResponsiveBreakpoint } from './use-media-query';
17
+ export { default as Highlight } from './shared/highlight';
18
+ export type { HighlightProps } from './shared/highlight';
19
+ export { default as Ellipsis } from './shared/ellipsis';
20
+ export { default as Expand } from './shared/expand';
21
+ export { default as Dropdown } from './shared/dropdown';
22
+ export { default as Backdrop } from './shared/backdrop';
package/esm/index.js CHANGED
@@ -1,11 +1,18 @@
1
1
  // @ts-ignore
2
2
  /// <reference types="styled-jsx" />
3
3
 
4
- import useTheme from './use-theme';
5
4
  export { default as UiProvider } from './ui-provider';
6
5
  export { default as Themes } from './themes';
7
6
  export { default as useAllThemes } from './use-all-themes';
8
7
  export { default as CssBaseline } from './css-baseline';
9
- export { default as useTheme } from './use-theme';
10
8
  export { useRect } from './utils/layouts';
11
- export default useTheme;
9
+ export { default as useCurrentState } from './use-current-state';
10
+ export { default as useTheme } from './use-theme';
11
+ export { default as useClasses } from './use-classes';
12
+ export { default as useToasts } from './use-toasts';
13
+ export { default as useMediaQuery } from './use-media-query';
14
+ export { default as Highlight } from './shared/highlight';
15
+ export { default as Ellipsis } from './shared/ellipsis';
16
+ export { default as Expand } from './shared/expand';
17
+ export { default as Dropdown } from './shared/dropdown';
18
+ export { default as Backdrop } from './shared/backdrop';
@@ -0,0 +1,14 @@
1
+ import React, { MouseEvent } from 'react';
2
+ interface Props {
3
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
4
+ visible?: boolean;
5
+ width?: string;
6
+ onContentClick?: (event: MouseEvent<HTMLElement>) => void;
7
+ backdropClassName?: string;
8
+ positionClassName?: string;
9
+ layerClassName?: string;
10
+ }
11
+ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>;
12
+ export type BackdropProps = Props & NativeAttrs;
13
+ declare const Backdrop: React.FC<React.PropsWithChildren<BackdropProps>>;
14
+ export default Backdrop;
@@ -0,0 +1,9 @@
1
+ import React, { MutableRefObject } from 'react';
2
+ interface Props {
3
+ parent?: MutableRefObject<HTMLElement | null> | undefined;
4
+ visible: boolean;
5
+ disableMatchWidth?: boolean;
6
+ getPopupContainer?: () => HTMLElement | null;
7
+ }
8
+ declare const Dropdown: React.FC<React.PropsWithChildren<Props>>;
9
+ export default Dropdown;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export type EllipsisProps = {
3
+ height: string;
4
+ };
5
+ declare const _default: React.NamedExoticComponent<React.PropsWithChildren<EllipsisProps>>;
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export type ExpandProps = {
3
+ isExpanded?: boolean;
4
+ delay?: number;
5
+ };
6
+ declare const Expand: React.FC<React.PropsWithChildren<ExpandProps>>;
7
+ export default Expand;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ReactiveDomReact } from '../utils/layouts';
3
+ type Props = {
4
+ rect: ReactiveDomReact;
5
+ visible?: boolean;
6
+ hoverHeightRatio?: number;
7
+ hoverWidthRatio?: number;
8
+ activeOpacity?: number;
9
+ };
10
+ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>;
11
+ export type HighlightProps = Props & NativeAttrs;
12
+ declare const Highlight: React.FC<HighlightProps>;
13
+ export default Highlight;
@@ -3,7 +3,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
  var _excluded = ["rect", "visible", "hoverHeightRatio", "hoverWidthRatio", "activeOpacity", "className"];
4
4
  import _JSXStyle from "../styled-jsx.es.js";
5
5
  /* "use client" */
6
-
7
6
  import React, { useMemo, useRef } from 'react';
8
7
  import { isUnplacedRect } from '../utils/layouts';
9
8
  import usePrevious from '../utils/use-previous';
@@ -0,0 +1,3 @@
1
+ import useMediaQuery from './use-media-query';
2
+ export type { ResponsiveBreakpoint, ResponsiveOptions } from './use-media-query';
3
+ export default useMediaQuery;
@@ -0,0 +1,12 @@
1
+ declare const breakpoints: ["xs", "sm", "md", "lg", "xl", "mobile"];
2
+ export type ResponsiveBreakpoint = typeof breakpoints[number];
3
+ declare const matchType: ["up", "down", "default"];
4
+ export type ResponsiveMatchType = typeof matchType[number];
5
+ export type ResponsiveOptions = {
6
+ match?: ResponsiveMatchType;
7
+ ssrMatchMedia?: (query: string) => {
8
+ matches: boolean;
9
+ };
10
+ };
11
+ declare const useMediaQuery: (breakpoint: ResponsiveBreakpoint, options?: ResponsiveOptions) => boolean;
12
+ export default useMediaQuery;
@@ -0,0 +1,3 @@
1
+ import useToasts from './use-toast';
2
+ export type { ToastAction, Toast, ToastTypes, ToastInput, ToastLayout } from './use-toast';
3
+ export default useToasts;
@@ -0,0 +1,2 @@
1
+ declare const useClickAnyWhere: (handler: (event: Event) => void) => void;
2
+ export default useClickAnyWhere;
@@ -0,0 +1,3 @@
1
+ import { MutableRefObject } from 'react';
2
+ declare const useDOMObserver: (ref: MutableRefObject<HTMLElement | null> | undefined, callback?: MutationCallback) => void;
3
+ export default useDOMObserver;
@@ -0,0 +1,2 @@
1
+ declare const usePrevious: <T>(state: T) => T | undefined | null;
2
+ export default usePrevious;
@@ -0,0 +1,9 @@
1
+ import { MutableRefObject } from 'react';
2
+ export type ShapeType = {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ export declare const getRealShape: (el: HTMLElement | null) => ShapeType;
7
+ export type ShapeResult = [ShapeType, () => void];
8
+ declare const useRealShape: <T extends HTMLElement>(ref: MutableRefObject<T | null>) => ShapeResult;
9
+ export default useRealShape;
@@ -0,0 +1,2 @@
1
+ declare const useResize: (callback: () => unknown, immediatelyInvoke?: boolean) => void;
2
+ export default useResize;
@@ -0,0 +1,2 @@
1
+ declare const useWarning: (message: string, component?: string) => void;
2
+ export default useWarning;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpdice/theme",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "unpkg": "dist/index.min.js",