@koine/react 1.0.104 → 1.1.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 (178) hide show
  1. package/Alert/Alert.d.ts +1 -1
  2. package/Animations/Reveal.d.ts +1 -1
  3. package/Animations/useReveal.d.ts +1 -1
  4. package/Autocomplete/AutocompleteMui.d.ts +4 -4
  5. package/Autocomplete/helpers.d.ts +1 -1
  6. package/Bg/BgColor.d.ts +1 -1
  7. package/Bg/BgPhoto.d.ts +2 -2
  8. package/Bg/BgSvg.d.ts +1 -1
  9. package/Breadcrumbs/Breadcrumbs.d.ts +3 -3
  10. package/Buttons/Button.d.ts +2 -2
  11. package/Buttons/ButtonComposite.d.ts +3 -3
  12. package/Buttons/ButtonFab.d.ts +1 -1
  13. package/Buttons/ButtonLink.d.ts +2 -2
  14. package/Buttons/IconButton.d.ts +2 -2
  15. package/Calendar/CalendarDaygridCell.d.ts +6 -6
  16. package/Calendar/CalendarDaygridNav.d.ts +3 -3
  17. package/Calendar/CalendarDaygridTable.d.ts +4 -4
  18. package/Calendar/CalendarLegend.d.ts +3 -3
  19. package/Calendar/calendar-api-google.d.ts +1 -1
  20. package/Calendar/types.d.ts +13 -13
  21. package/Calendar/useCalendar.d.ts +5 -5
  22. package/Carousel/CarouselCss.d.ts +2 -2
  23. package/Collapsable/CollapsableReach.js +1 -2
  24. package/Debug/Debug.d.ts +1 -1
  25. package/Details/Details.d.ts +6 -6
  26. package/Dialog/DialogMui.d.ts +8 -8
  27. package/Dialog/DialogMui.js +1 -1
  28. package/Dialog/css/bare.d.ts +1 -1
  29. package/Dialog/m/bare.d.ts +1 -1
  30. package/Dialog/m/bare.js +1 -1
  31. package/Dialog/sc/bare.d.ts +1 -1
  32. package/Dialog/sc/framer.d.ts +1 -1
  33. package/Dialog/sc/framerMaterial.d.ts +1 -1
  34. package/Dialog/sc/material.d.ts +1 -1
  35. package/Dialog/tw/bare.d.ts +7 -7
  36. package/Dialog/tw/elegant.d.ts +7 -7
  37. package/Dialog/tw/framer.d.ts +3 -3
  38. package/Dialog/tw/framerMaterial.d.ts +5 -5
  39. package/Dialog/tw/material.d.ts +7 -7
  40. package/Editor/Editor--tiptap.d.ts +2 -2
  41. package/Favicon/FaviconTags.d.ts +1 -1
  42. package/Favicon/FaviconTags.js +1 -1
  43. package/Form/Form.d.ts +7 -7
  44. package/Forms/Checkbox/Checkbox.d.ts +2 -2
  45. package/Forms/Feedback/Feedback.d.ts +1 -1
  46. package/Forms/Field/Field.d.ts +3 -3
  47. package/Forms/Field/FieldControl.d.ts +2 -2
  48. package/Forms/Input/Input.d.ts +2 -2
  49. package/Forms/InputGroup/InputGroup.d.ts +1 -1
  50. package/Forms/Password/Password.d.ts +2 -2
  51. package/Forms/Radio/Radio.d.ts +3 -3
  52. package/Forms/Switch/Switch.d.ts +2 -2
  53. package/Forms/Textarea/Textarea.d.ts +2 -2
  54. package/Forms/Textarea/TextareaRich.d.ts +2 -2
  55. package/Forms/Toggle/Toggle.d.ts +3 -3
  56. package/Forms/Toggle/useToggle.d.ts +1 -1
  57. package/Forms/antispam.d.ts +18 -1
  58. package/Forms/helpers.d.ts +5 -5
  59. package/Gauge/Gauge.d.ts +1 -1
  60. package/Grid/Grid.d.ts +6 -6
  61. package/Hamburger/Hamburger.d.ts +1 -1
  62. package/Header/useHeader.d.ts +5 -5
  63. package/Hidden/Hidden.d.ts +1 -1
  64. package/Img/sc/bare.d.ts +1 -1
  65. package/Img/types.d.ts +2 -2
  66. package/Link/Link.d.ts +1 -1
  67. package/Link/LinkBlank.d.ts +1 -1
  68. package/Menu/MenuMui.d.ts +5 -5
  69. package/Menu/MenuMui.js +1 -1
  70. package/MenuItem/MenuItemMui.d.ts +1 -1
  71. package/Meta/Meta.d.ts +1 -1
  72. package/NoJs/NoJs.d.ts +1 -1
  73. package/Pagination/PaginationNav.d.ts +2 -2
  74. package/Pagination/PaginationResults.d.ts +1 -1
  75. package/Pill/Pill.d.ts +1 -1
  76. package/Progress/ProgressCircular.d.ts +1 -1
  77. package/Progress/ProgressLinear.d.ts +1 -1
  78. package/Progress/ProgressOverlay.d.ts +1 -1
  79. package/Rating/Rating.d.ts +3 -3
  80. package/Select/SelectDownshift.d.ts +1 -1
  81. package/Select/components.d.ts +1 -1
  82. package/Sidebar/Sidebar.d.ts +1 -1
  83. package/Spacing/Spacing.d.ts +6 -6
  84. package/Sticky/Sticky.d.ts +1 -1
  85. package/Sticky/StickyCss.d.ts +1 -1
  86. package/Tabs/TabsMui.d.ts +11 -11
  87. package/Tabs/TabsMui.js +1 -1
  88. package/Tabs/tw/bare.d.ts +4 -4
  89. package/Tabs/tw/material.d.ts +10 -10
  90. package/Typography/ReadMore.d.ts +1 -1
  91. package/Typography/TextLoop.d.ts +2 -2
  92. package/Typography/TypeStairs.d.ts +1 -1
  93. package/helpers/classed.d.ts +3 -3
  94. package/helpers/classed.js +1 -0
  95. package/helpers/createUseMediaQueryWidth.d.ts +3 -3
  96. package/helpers/extend-component.d.ts +4 -4
  97. package/helpers/extend-component.js +1 -0
  98. package/hooks/index.d.ts +4 -1
  99. package/hooks/index.js +4 -1
  100. package/hooks/types.d.ts +2 -2
  101. package/hooks/useAsyncFn.d.ts +4 -4
  102. package/hooks/useAsyncFn.js +1 -0
  103. package/hooks/useDateLocale.d.ts +1 -0
  104. package/hooks/useDateLocale.js +1 -0
  105. package/hooks/useEffectOnce.d.ts +1 -0
  106. package/hooks/useEffectOnce.js +1 -0
  107. package/hooks/useFirstMountState.d.ts +1 -0
  108. package/hooks/useFirstMountState.js +1 -0
  109. package/hooks/useFocus.d.ts +1 -0
  110. package/hooks/useFocus.js +1 -0
  111. package/hooks/useId.d.ts +1 -0
  112. package/hooks/useId.js +1 -0
  113. package/hooks/useInterval.d.ts +7 -0
  114. package/hooks/useInterval.js +28 -0
  115. package/hooks/useIsomorphicLayoutEffect.d.ts +1 -0
  116. package/hooks/useIsomorphicLayoutEffect.js +1 -0
  117. package/hooks/useKeyUp.d.ts +2 -0
  118. package/hooks/useKeyUp.js +23 -0
  119. package/hooks/useMeasure.d.ts +3 -3
  120. package/hooks/useMount.d.ts +1 -0
  121. package/hooks/useMount.js +1 -0
  122. package/hooks/useMountedState.d.ts +1 -0
  123. package/hooks/useMountedState.js +1 -0
  124. package/hooks/useNavigateAway.d.ts +32 -0
  125. package/hooks/useNavigateAway.js +68 -0
  126. package/hooks/usePrevious.d.ts +5 -1
  127. package/hooks/usePrevious.js +11 -7
  128. package/hooks/usePreviousRef.d.ts +2 -0
  129. package/hooks/usePreviousRef.js +9 -0
  130. package/hooks/useScrollPosition.d.ts +3 -3
  131. package/hooks/useScrollPosition.js +1 -0
  132. package/hooks/useScrollTo.d.ts +1 -0
  133. package/hooks/useScrollTo.js +1 -0
  134. package/hooks/useTraceUpdate.d.ts +1 -0
  135. package/hooks/useTraceUpdate.js +1 -0
  136. package/hooks/useUpdateEffect.d.ts +1 -0
  137. package/hooks/useUpdateEffect.js +1 -0
  138. package/hooks/useWindowSize.d.ts +1 -0
  139. package/hooks/useWindowSize.js +4 -2
  140. package/m/MotionProvider.d.ts +2 -2
  141. package/node/Collapsable/CollapsableReach.js +1 -2
  142. package/node/Dialog/DialogMui.js +1 -1
  143. package/node/Dialog/m/bare.js +1 -1
  144. package/node/Favicon/FaviconTags.js +1 -1
  145. package/node/Menu/MenuMui.js +1 -1
  146. package/node/Tabs/TabsMui.js +1 -1
  147. package/node/helpers/classed.js +1 -0
  148. package/node/helpers/extend-component.js +1 -0
  149. package/node/hooks/index.js +4 -1
  150. package/node/hooks/useAsyncFn.js +1 -0
  151. package/node/hooks/useDateLocale.js +4 -2
  152. package/node/hooks/useEffectOnce.js +1 -0
  153. package/node/hooks/useFirstMountState.js +1 -0
  154. package/node/hooks/useFocus.js +1 -0
  155. package/node/hooks/useInterval.js +32 -0
  156. package/node/hooks/useIsomorphicLayoutEffect.js +1 -0
  157. package/node/hooks/useKeyUp.js +27 -0
  158. package/node/hooks/useMount.js +1 -0
  159. package/node/hooks/useMountedState.js +1 -0
  160. package/node/hooks/useNavigateAway.js +72 -0
  161. package/node/hooks/usePrevious.js +10 -6
  162. package/node/hooks/usePreviousRef.js +13 -0
  163. package/node/hooks/useScrollPosition.js +1 -0
  164. package/node/hooks/useScrollTo.js +1 -0
  165. package/node/hooks/useTraceUpdate.js +1 -0
  166. package/node/hooks/useUpdateEffect.js +1 -0
  167. package/node/hooks/useWindowSize.js +4 -2
  168. package/package.json +35 -23
  169. package/styles/media.d.ts +3 -3
  170. package/styles/spacing.d.ts +7 -7
  171. package/styles/theme--vanilla.d.ts +4 -4
  172. package/styles/theme.d.ts +4 -4
  173. package/types.d.ts +4 -4
  174. package/hooks/useMediaQueryWidthCreator.d.ts +0 -6
  175. package/hooks/useMediaQueryWidthCreator.js +0 -169
  176. package/hooks/useMqWidthCreator.d.ts +0 -3
  177. package/hooks/useMqWidthCreator.js +0 -225
  178. package/node/hooks/useId.js +0 -12
@@ -20,10 +20,11 @@ function useDateLocale(locale, defaultLocale) {
20
20
  var importLocaleFile = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
21
21
  var localeToSet;
22
22
  return tslib_1.__generator(this, function (_a) {
23
+ var _b;
23
24
  switch (_a.label) {
24
- case 0: return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require(
25
+ case 0: return [4 /*yield*/, (_b =
25
26
  /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
26
- "date-fns/locale/".concat(locale, "/index.js"))); })];
27
+ "date-fns/locale/".concat(locale, "/index.js"), Promise.resolve().then(function () { return tslib_1.__importStar(require(_b)); }))];
27
28
  case 1:
28
29
  localeToSet = _a.sent();
29
30
  setCurrent(locale || current);
@@ -40,3 +41,4 @@ function useDateLocale(locale, defaultLocale) {
40
41
  return data;
41
42
  }
42
43
  exports.useDateLocale = useDateLocale;
44
+ exports.default = useDateLocale;
@@ -10,3 +10,4 @@ var useEffectOnce = function (effect) {
10
10
  (0, react_1.useEffect)(effect, []);
11
11
  };
12
12
  exports.useEffectOnce = useEffectOnce;
13
+ exports.default = exports.useEffectOnce;
@@ -14,3 +14,4 @@ function useFirstMountState() {
14
14
  return isFirst.current;
15
15
  }
16
16
  exports.useFirstMountState = useFirstMountState;
17
+ exports.default = useFirstMountState;
@@ -13,3 +13,4 @@ var useFocus = function () {
13
13
  return [element, setFocus];
14
14
  };
15
15
  exports.useFocus = useFocus;
16
+ exports.default = exports.useFocus;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useInterval = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var utils_1 = require("@koine/utils");
7
+ /**
8
+ * @borrows [dan abramov](https://overreacted.io/making-setinterval-declarative-with-react-hooks/)
9
+ *
10
+ * We just add `deps` array argument and typescript support
11
+ */
12
+ function useInterval(callback, delay, deps) {
13
+ if (deps === void 0) { deps = []; }
14
+ var savedCallback = (0, react_1.useRef)();
15
+ (0, react_1.useEffect)(function () {
16
+ savedCallback.current = callback;
17
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18
+ }, tslib_1.__spreadArray([callback], deps, true));
19
+ (0, react_1.useEffect)(function () {
20
+ function tick() {
21
+ if (savedCallback.current)
22
+ savedCallback.current();
23
+ }
24
+ if (delay !== null) {
25
+ var id_1 = setInterval(tick, delay);
26
+ return function () { return clearInterval(id_1); };
27
+ }
28
+ return utils_1.noop;
29
+ }, [delay]);
30
+ }
31
+ exports.useInterval = useInterval;
32
+ exports.default = useInterval;
@@ -9,3 +9,4 @@ var utils_1 = require("@koine/utils");
9
9
  exports.useIsomorphicLayoutEffect = utils_1.isBrowser
10
10
  ? react_1.useLayoutEffect
11
11
  : react_1.useEffect;
12
+ exports.default = exports.useIsomorphicLayoutEffect;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useKeyUp = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var dom_1 = require("@koine/dom");
7
+ function useKeyUp(callback, deps) {
8
+ if (deps === void 0) { deps = []; }
9
+ (0, react_1.useEffect)(function () {
10
+ var listener = (0, dom_1.on)(window, "keyup", function (event) {
11
+ // const { key } = event;
12
+ // be sure we do not intercept keys combinations maybe used for other
13
+ // actions like native browser navigation shortcuts
14
+ // @see https://stackoverflow.com/a/37559790/1938970
15
+ if (!event.ctrlKey &&
16
+ !event.altKey &&
17
+ !event.shiftKey &&
18
+ !event.metaKey) {
19
+ callback(event);
20
+ }
21
+ });
22
+ return listener;
23
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24
+ }, tslib_1.__spreadArray([callback], deps, true));
25
+ }
26
+ exports.useKeyUp = useKeyUp;
27
+ exports.default = useKeyUp;
@@ -11,3 +11,4 @@ var useMount = function (fn) {
11
11
  });
12
12
  };
13
13
  exports.useMount = useMount;
14
+ exports.default = exports.useMount;
@@ -17,3 +17,4 @@ function useMountedState() {
17
17
  return get;
18
18
  }
19
19
  exports.useMountedState = useMountedState;
20
+ exports.default = useMountedState;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNavigateAway = void 0;
4
+ var react_1 = require("react");
5
+ var dom_1 = require("@koine/dom");
6
+ // type UseNavigateAwayPagehideHandler = (event: PageTransitionEvent) => unknown;
7
+ /**
8
+ * @resources
9
+ *
10
+ * About browser's specs see:
11
+ * - https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
12
+ * - https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
13
+ * - https://stackoverflow.com/questions/58009424/pagehide-event-on-google-chrome
14
+ *
15
+ * About react see:
16
+ * - https://github.com/jacobbuck/react-beforeunload
17
+ * - https://github.com/dioscarey/react-beforeunload-component
18
+ *
19
+ * About next.js see:
20
+ * - https://github.com/vercel/next.js/issues/2476
21
+ * - https://github.com/vercel/next.js/issues/2694
22
+ *
23
+ * For the callback technique see:
24
+ * - https://stackoverflow.com/a/11835394/1938970
25
+ */
26
+ var useNavigateAway = function (handler) {
27
+ var beforeUnloadHandlerRef = (0, react_1.useRef)();
28
+ // const pagehideHandlerRef = useRef<UseNavigateAwayPagehideHandler | undefined>();
29
+ (0, react_1.useEffect)(function () {
30
+ beforeUnloadHandlerRef.current = function (event) {
31
+ var customMessageOrCondition = handler(event);
32
+ if (customMessageOrCondition) {
33
+ event.preventDefault();
34
+ }
35
+ // Handle legacy `event.returnValue` property
36
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
37
+ if (typeof customMessageOrCondition === "string") {
38
+ return (event.returnValue = customMessageOrCondition);
39
+ }
40
+ // Chrome doesn't support `event.preventDefault()` on `BeforeUnloadEvent`,
41
+ // instead it requires `event.returnValue` to be set
42
+ // https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#browser_compatibility
43
+ if (event.defaultPrevented) {
44
+ return (event.returnValue = "");
45
+ }
46
+ return;
47
+ };
48
+ // pagehideHandlerRef.current = (event) => {
49
+ // const returnValue = handler?.(event);
50
+ // if (event.persisted) {
51
+ // // If the event's persisted property is `true` the page is about
52
+ // // to enter the Back-Forward Cache, which is also in the frozen state.
53
+ // } else {
54
+ // // If the event's persisted property is not `true` the page is
55
+ // // about to be unloaded.
56
+ // }
57
+ // };
58
+ }, [handler]);
59
+ (0, react_1.useEffect)(function () {
60
+ var listenerBeforeunload = (0, dom_1.on)(window, "beforeunload", function (event) { var _a; return (_a = beforeUnloadHandlerRef.current) === null || _a === void 0 ? void 0 : _a.call(beforeUnloadHandlerRef, event); });
61
+ // const listenerPagehide = on(window, "pagehide", (event) =>
62
+ // pagehideHandlerRef.current?.(event)
63
+ // );
64
+ return listenerBeforeunload;
65
+ // return () => {
66
+ // listenerBeforeunload();
67
+ // // listenerPagehide();
68
+ // };
69
+ }, []);
70
+ };
71
+ exports.useNavigateAway = useNavigateAway;
72
+ exports.default = exports.useNavigateAway;
@@ -2,11 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePrevious = void 0;
4
4
  var react_1 = require("react");
5
- function usePrevious(value) {
6
- var ref = (0, react_1.useRef)();
7
- (0, react_1.useEffect)(function () {
8
- ref.current = value;
9
- });
10
- return ref.current;
5
+ /**
6
+ * @borrows [samselikoff/animated-carousel](https://github.com/samselikoff/2022-06-02-animated-carousel/blob/main/pages/final.jsx)
7
+ */
8
+ function usePrevious(state, defaulValue) {
9
+ var _a = (0, react_1.useState)([state, defaulValue]), tuple = _a[0], setTuple = _a[1];
10
+ if (tuple[1] !== state) {
11
+ setTuple([tuple[1], state]);
12
+ }
13
+ return tuple[0];
11
14
  }
12
15
  exports.usePrevious = usePrevious;
16
+ exports.default = usePrevious;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePreviousRef = void 0;
4
+ var react_1 = require("react");
5
+ function usePreviousRef(value) {
6
+ var ref = (0, react_1.useRef)();
7
+ (0, react_1.useEffect)(function () {
8
+ ref.current = value;
9
+ });
10
+ return ref.current;
11
+ }
12
+ exports.usePreviousRef = usePreviousRef;
13
+ exports.default = usePreviousRef;
@@ -82,3 +82,4 @@ var useScrollPosition = function (effect, deps, element, useWindow, wait, boundi
82
82
  }, deps);
83
83
  };
84
84
  exports.useScrollPosition = useScrollPosition;
85
+ exports.default = exports.useScrollPosition;
@@ -23,3 +23,4 @@ function useScrollTo(id, offset) {
23
23
  window.scroll(0, top);
24
24
  }
25
25
  exports.useScrollTo = useScrollTo;
26
+ exports.default = useScrollTo;
@@ -23,3 +23,4 @@ function useTraceUpdate(props) {
23
23
  });
24
24
  }
25
25
  exports.useTraceUpdate = useTraceUpdate;
26
+ exports.default = useTraceUpdate;
@@ -16,3 +16,4 @@ var useUpdateEffect = function (effect, deps) {
16
16
  }, deps);
17
17
  };
18
18
  exports.useUpdateEffect = useUpdateEffect;
19
+ exports.default = exports.useUpdateEffect;
@@ -2,16 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useWindowSize = void 0;
4
4
  var react_1 = require("react");
5
+ var dom_1 = require("@koine/dom");
5
6
  function useWindowSize() {
6
7
  var _a = (0, react_1.useState)([0, 0]), size = _a[0], setSize = _a[1];
7
8
  (0, react_1.useEffect)(function () {
8
9
  function updateSize() {
9
10
  setSize([window.innerWidth, window.innerHeight]);
10
11
  }
11
- window.addEventListener("resize", updateSize);
12
+ var listener = (0, dom_1.on)(window, "resize", updateSize);
12
13
  updateSize();
13
- return function () { return window.removeEventListener("resize", updateSize); };
14
+ return listener;
14
15
  }, []);
15
16
  return size;
16
17
  }
17
18
  exports.useWindowSize = useWindowSize;
19
+ exports.default = useWindowSize;
package/package.json CHANGED
@@ -1,28 +1,40 @@
1
1
  {
2
2
  "name": "@koine/react",
3
3
  "sideEffects": false,
4
- "main": "./node/index.js",
5
- "typings": "./index.d.ts",
6
- "dependencies": {
7
- "styled-components": "^5.3.6",
8
- "framer-motion": "^7.5.3",
9
- "react": "^18.2.0",
10
- "@mui/base": "^5.0.0-alpha.101",
11
- "@koine/utils": "1.0.104",
12
- "ts-debounce": "^4.0.0",
13
- "react-icons": "^4.4.0",
14
- "date-fns": "^2.29.3",
15
- "react-swipeable": "^7.0.0",
16
- "@tiptap/react": "^2.0.0-beta.199",
17
- "@tiptap/starter-kit": "^2.0.0-beta.199",
18
- "@kuus/yup": "^1.0.0-beta.4",
19
- "react-hook-form": "^7.37.0",
20
- "@koine/dom": "1.0.104",
21
- "react-popper": "^2.3.0",
22
- "tslib": "^2.4.0"
4
+ "peerDependenciesMeta": {
5
+ "@mui/base": {
6
+ "optional": true
7
+ },
8
+ "@tiptap/react": {
9
+ "optional": true
10
+ },
11
+ "@tiptap/starter-kit": {
12
+ "optional": true
13
+ },
14
+ "framer-motion": {
15
+ "optional": true
16
+ },
17
+ "react-hook-form": {
18
+ "optional": true
19
+ },
20
+ "react-icons": {
21
+ "optional": true
22
+ },
23
+ "react-is": {
24
+ "optional": true
25
+ },
26
+ "react-popper": {
27
+ "optional": true
28
+ },
29
+ "react-swipeable": {
30
+ "optional": true
31
+ },
32
+ "styled-components": {
33
+ "optional": true
34
+ }
23
35
  },
24
- "peerDependencies": {},
25
- "version": "1.0.104",
26
- "module": "./index.js",
27
- "types": "./index.d.ts"
36
+ "main": "./node/index.js",
37
+ "types": "./index.d.ts",
38
+ "version": "1.1.0",
39
+ "module": "./index.js"
28
40
  }
package/styles/media.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Breakpoint, Breakpoints } from "./theme";
2
2
  export declare const min: MediaQueryFunction, max: MediaQueryFunction, up: MediaQueryFunction, down: (br: Breakpoint) => string, between: (br1: Breakpoint, br2: Breakpoint) => string, only: (br: Breakpoint) => string;
3
- export declare type MediaDirection = "min" | "max";
4
- export declare type MediaQuery = `${MediaDirection}:${Breakpoint}`;
5
- export declare type MediaQueryFunction = {
3
+ export type MediaDirection = "min" | "max";
4
+ export type MediaQuery = `${MediaDirection}:${Breakpoint}`;
5
+ export type MediaQueryFunction = {
6
6
  [Breakpoint in keyof Breakpoints]: string;
7
7
  } & {
8
8
  (breakpoint: Breakpoint): string;
@@ -1,12 +1,12 @@
1
1
  import type { Theme } from "./theme";
2
- export declare type SpacingSize = "sm" | "md" | "lg";
3
- export declare type SpacingProperty = "padding" | "margin";
2
+ export type SpacingSize = "sm" | "md" | "lg";
3
+ export type SpacingProperty = "padding" | "margin";
4
4
  /** @default 1 */
5
- export declare type SpacingFactor = number;
6
- export declare type SpacingDirection = "top" | "bottom";
7
- export declare type SpacingDirectionAxis = "vertical" | SpacingDirection;
8
- export declare type SpacingDevices = keyof Theme["devices"];
9
- export declare type SpacingArgs = Parameters<typeof spacing>;
5
+ export type SpacingFactor = number;
6
+ export type SpacingDirection = "top" | "bottom";
7
+ export type SpacingDirectionAxis = "vertical" | SpacingDirection;
8
+ export type SpacingDevices = keyof Theme["devices"];
9
+ export type SpacingArgs = Parameters<typeof spacing>;
10
10
  export declare function spacing(this: Theme, size?: SpacingSize, factor?: SpacingFactor, property?: SpacingProperty, direction?: SpacingDirectionAxis, devices?: SpacingDevices[]): string;
11
11
  export declare function spacingTop(this: Theme, size?: SpacingSize, factor?: SpacingFactor, property?: SpacingProperty, devices?: SpacingDevices[]): string;
12
12
  export declare function spacingBottom(this: Theme, size?: SpacingSize, factor?: SpacingFactor, property?: SpacingProperty, devices?: SpacingDevices[]): string;
@@ -3,16 +3,16 @@ export declare const THEME_KEY = "theme";
3
3
  export declare const THEME_DEFAULT: ThemeVanillaValue;
4
4
  export declare const getInitialThemeFromRequest: (cookie?: string) => ThemeVanillaValue;
5
5
  export declare const getInitialThemeFromClient: () => ThemeVanillaValue;
6
- export declare type ThemeCookie = {
6
+ export type ThemeCookie = {
7
7
  [THEME_KEY]: ThemeVanillaValue;
8
8
  };
9
- export declare type ThemeVanillaValue = "light" | "dark";
10
- export declare type ThemeVanillaContextType = {
9
+ export type ThemeVanillaValue = "light" | "dark";
10
+ export type ThemeVanillaContextType = {
11
11
  theme: ThemeVanillaValue;
12
12
  setTheme?: React.Dispatch<React.SetStateAction<ThemeVanillaValue>>;
13
13
  };
14
14
  export declare const ThemeVanillaContext: import("react").Context<ThemeVanillaContextType>;
15
- export declare type ThemeVanillaProviderProps = React.PropsWithChildren<{
15
+ export type ThemeVanillaProviderProps = React.PropsWithChildren<{
16
16
  initialTheme: ThemeVanillaValue;
17
17
  }>;
18
18
  export declare const ThemeVanillaProvider: ({ initialTheme, children, }: ThemeVanillaProviderProps) => JSX.Element;
package/styles/theme.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export declare type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
2
- export declare type Breakpoints = Record<Breakpoint, number>;
1
+ export type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
2
+ export type Breakpoints = Record<Breakpoint, number>;
3
3
  /**
4
4
  * You can override the default breakpoints through the .env variable
5
5
  *
@@ -14,7 +14,7 @@ export declare type Breakpoints = Record<Breakpoint, number>;
14
14
  export declare const breakpoints: Breakpoints;
15
15
  export declare const createTheme: (options: ThemeOptions) => Theme;
16
16
  export declare const useTheme: () => Theme;
17
- export declare type Theme = {
17
+ export type Theme = {
18
18
  maxWidth: number;
19
19
  gutter: {
20
20
  quarter: number;
@@ -73,7 +73,7 @@ export declare type Theme = {
73
73
  logoWidthSticky: [number, number];
74
74
  };
75
75
  };
76
- export declare type ThemeOptions = {
76
+ export type ThemeOptions = {
77
77
  maxWidth?: number;
78
78
  gutter: NonNullable<Theme["gutter"]>;
79
79
  devices?: Theme["devices"];
package/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  export type { KoineImgSmartWrapProps, KoineImgSmartProps } from "./Img/types";
3
- export declare type Translate = (i18nKey: any, query?: any, options?: any) => string;
4
- export declare type Option = {
3
+ export type Translate = (i18nKey: any, query?: any, options?: any) => string;
4
+ export type Option = {
5
5
  value: string;
6
6
  Label?: NonNullable<import("react").ReactNode>;
7
7
  label: NonNullable<import("react").ReactChild | import("react").ReactFragment>;
8
8
  };
9
- export declare type KoineComponentProps<BaseComponentProps, ExtendableProps> = BaseComponentProps & ExtendableProps;
10
- export declare type KoineComponent<Props = any> = string | React.ForwardRefExoticComponent<Props> | React.ExoticComponent<Props> | React.FC<Props> | ((props: Props) => JSX.Element);
9
+ export type KoineComponentProps<BaseComponentProps, ExtendableProps> = BaseComponentProps & ExtendableProps;
10
+ export type KoineComponent<Props = any> = string | React.ForwardRefExoticComponent<Props> | React.ExoticComponent<Props> | React.FC<Props> | ((props: Props) => JSX.Element);
@@ -1,6 +0,0 @@
1
- import { type GetMediaQueryWidthResolversBreakpoints } from "@koine/utils";
2
- declare type _MediaQuerWidthDefExplicit<TBreakpoint extends string> = `min-${TBreakpoint}` | `max-${TBreakpoint}` | `up-${TBreakpoint}` | `down-${TBreakpoint}` | `between-${TBreakpoint}_${TBreakpoint}` | `only-${TBreakpoint}`;
3
- export declare type MediaQuerWidthDef<TBreakpoint extends string> = `${TBreakpoint}` | _MediaQuerWidthDefExplicit<TBreakpoint>;
4
- export declare type MediaQueryWidth<TBreakpoint extends string> = `@${MediaQuerWidthDef<TBreakpoint>}`;
5
- export declare function useMediaQueryWidthCreator<TBreakpointsConfig extends GetMediaQueryWidthResolversBreakpoints>(customBreakpoints: TBreakpointsConfig): <TBreakpoints extends Extract<keyof TBreakpointsConfig, string>>(media: `@${TBreakpoints}` | `@min-${TBreakpoints}` | `@max-${TBreakpoints}` | `@up-${TBreakpoints}` | `@down-${TBreakpoints}` | `@between-${TBreakpoints}_${TBreakpoints}` | `@only-${TBreakpoints}`) => boolean;
6
- export default useMediaQueryWidthCreator;
@@ -1,169 +0,0 @@
1
- import { useState, useEffect, useMemo } from "react";
2
- import { isBrowser, isUndefined, getMediaQueryWidthResolvers, } from "@koine/utils";
3
- export function useMediaQueryWidthCreator(customBreakpoints) {
4
- var queryResolvers = getMediaQueryWidthResolvers(customBreakpoints);
5
- return function useMediaQueryWidth(media) {
6
- var definition = media.substring(1);
7
- var _a = definition.split("-"), rule = _a[0], ruleBreakpoint = _a[1];
8
- if (isUndefined(ruleBreakpoint)) {
9
- ruleBreakpoint = rule;
10
- }
11
- if (isUndefined(rule)) {
12
- rule = "min";
13
- }
14
- // with the hook creator approach these breakpoint types cannot be deduced
15
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
16
- // typeof ruleBreakpoint,
17
- // "-"
18
- // >;
19
- var _b = ruleBreakpoint.split("_"), br1 = _b[0], br2 = _b[1];
20
- var query = queryResolvers[rule](br1, br2);
21
- var mq = useMemo(function () { return (isBrowser ? window.matchMedia(query) : { matches: false }); }, [query]);
22
- var _c = useState(mq.matches), matches = _c[0], setMatches = _c[1];
23
- useEffect(function () {
24
- var mq = window.matchMedia(query);
25
- var handleChange = function (event) {
26
- setMatches(event.matches);
27
- };
28
- setMatches(mq.matches);
29
- // Safari < 14 can't use addEventListener on a MediaQueryList
30
- // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
31
- if (!mq.addEventListener) {
32
- // Update the state whenever the media query match state changes
33
- mq.addListener(handleChange);
34
- // Clean up on unmount and if the query changes
35
- return function () {
36
- mq.removeListener(handleChange);
37
- };
38
- }
39
- mq.addEventListener("change", handleChange);
40
- return function () {
41
- mq.removeEventListener("change", handleChange);
42
- };
43
- }, [query]);
44
- return matches;
45
- };
46
- }
47
- export default useMediaQueryWidthCreator;
48
- //// without creator it would be:
49
- //// ---------------------------------------------------------------------------
50
- // import { useState, useEffect, useMemo } from "react";
51
- // import { isBrowser, type Split } from "@koine/utils";
52
- // import { breakpoints as themeBreakpoints } from "@/config/theme/breakpoints";
53
- // type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl";
54
- // type Breakpoints = Record<Breakpoint, number>;
55
- // type MediaQuery =
56
- // | `max:${Breakpoint}`
57
- // | `min:${Breakpoint}`
58
- // | `down:${Breakpoint}`
59
- // | `up:${Breakpoint}`
60
- // | `between:${Breakpoint}-${Breakpoint}`
61
- // | `only:${Breakpoint}`;
62
- // const breakpoints: Breakpoints = {
63
- // xs: 0,
64
- // ...themeBreakpoints,
65
- // };
66
- // const sortedBreakpointsNames = (
67
- // Object.keys(breakpoints).map((key) => {
68
- // const br = key as keyof typeof breakpoints;
69
- // return [br, breakpoints[br]];
70
- // }) as [Breakpoint, number][]
71
- // )
72
- // .sort((a, b) => a[1] - b[1])
73
- // .map((item) => item[0]);
74
- // const getNextBreakpoint = (breakpoint: Breakpoint) => {
75
- // const index = sortedBreakpointsNames.indexOf(breakpoint);
76
- // return sortedBreakpointsNames[index + 1];
77
- // };
78
- // /**
79
- // * It behaves the same as `(min-width: ${value}px)`
80
- // * where value is the given breakpoint value.
81
- // * For ease of use this can be used both as a function `min("md")` and as an
82
- // * object literal `min.md`.
83
- // */
84
- // const min = (br: Breakpoint) => `(min-width: ${breakpoints[br]}px)`;
85
- // /**
86
- // * It behaves the same as `(max-width: ${value}px)`
87
- // * where value is the given breakpoint value.
88
- // * For ease of use this can be used both as a function `max("md")` and as an
89
- // * object literal `max.md`.
90
- // */
91
- // const max = (br: Breakpoint) => `(max-width: ${breakpoints[br] - 0.02}px)`;
92
- // /**
93
- // * It behaves the same as `min`
94
- // * @inheritdoc {max}
95
- // */
96
- // const up = min;
97
- // /**
98
- // * It behaves similarly to `max` but you will use the "next" breakpoint,
99
- // * specifying CSS that will apply from the given breakpoint and down.
100
- // */
101
- // const down = (br: Breakpoint) => {
102
- // const brNext = getNextBreakpoint(br);
103
- // // TODO: if br does not exists otherwise throw Error
104
- // return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
105
- // };
106
- // /**
107
- // * Media query between the two given breakpoints
108
- // */
109
- // const between = (br1: Breakpoint, br2?: Breakpoint) => {
110
- // return br2
111
- // ? `(min-width: ${breakpoints[br1]}px) and (max-width: ${
112
- // breakpoints[br2] - 0.02
113
- // }px)`
114
- // : min(br1);
115
- // };
116
- // /**
117
- // * Media query to apply from the given breakpoint until the next, just for its
118
- // * full range
119
- // */
120
- // const only = (br: Breakpoint) => {
121
- // const brNext = getNextBreakpoint(br);
122
- // return brNext ? between(br, brNext) : min(br);
123
- // };
124
- // const queryResolvers = {
125
- // max,
126
- // min,
127
- // down,
128
- // up,
129
- // between,
130
- // only,
131
- // };
132
- // export function useMqWidth(media: MediaQuery) {
133
- // const [rule = "min", ruleBreakpoint] = media.split(":") as Split<
134
- // MediaQuery,
135
- // ":"
136
- // >;
137
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
138
- // typeof ruleBreakpoint,
139
- // "-"
140
- // >;
141
- // const query = queryResolvers[rule](br1, br2);
142
- // const mq = useMemo(
143
- // () => (isBrowser ? window.matchMedia(query) : { matches: false }),
144
- // [query]
145
- // );
146
- // const [matches, setMatches] = useState(mq.matches);
147
- // useEffect(() => {
148
- // const mq = window.matchMedia(query);
149
- // const handleChange = (event: MediaQueryListEvent) => {
150
- // setMatches(event.matches);
151
- // };
152
- // setMatches(mq.matches);
153
- // // Safari < 14 can't use addEventListener on a MediaQueryList
154
- // // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
155
- // if (!mq.addEventListener) {
156
- // // Update the state whenever the media query match state changes
157
- // mq.addListener(handleChange);
158
- // // Clean up on unmount and if the query changes
159
- // return () => {
160
- // mq.removeListener(handleChange);
161
- // };
162
- // }
163
- // mq.addEventListener("change", handleChange);
164
- // return () => {
165
- // mq.removeEventListener("change", handleChange);
166
- // };
167
- // }, [query]);
168
- // return matches;
169
- // }
@@ -1,3 +0,0 @@
1
- declare type MediaQuery<TBreakpoint extends string> = `max:${TBreakpoint}` | `min:${TBreakpoint}` | `down:${TBreakpoint}` | `up:${TBreakpoint}` | `between:${TBreakpoint}-${TBreakpoint}` | `only:${TBreakpoint}`;
2
- export declare function useMqWidthCreator<TBreakpointsConfig extends Record<string, number>>(customBreakpoints: TBreakpointsConfig): <TBreakpoints extends Extract<keyof TBreakpointsConfig, string>>(media: MediaQuery<TBreakpoints>) => boolean;
3
- export default useMqWidthCreator;