@koine/react 1.0.14 → 1.0.17

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 (197) hide show
  1. package/Details/Details.d.ts +6 -12
  2. package/hooks/useScrollPosition.d.ts +1 -1
  3. package/node/Alert/Alert.js +14 -0
  4. package/node/Alert/index.js +4 -0
  5. package/node/Animations/Reveal.js +21 -0
  6. package/node/Animations/Underline.js +8 -0
  7. package/node/Animations/index.js +6 -0
  8. package/node/Animations/useReveal.js +75 -0
  9. package/node/Autocomplete/AutocompleteDownshift.js +161 -0
  10. package/node/Autocomplete/AutocompleteDownshiftMultiselect.js +356 -0
  11. package/node/Autocomplete/AutocompleteMui.js +180 -0
  12. package/node/Autocomplete/AutocompleteReach.js +115 -0
  13. package/node/Autocomplete/components.js +37 -0
  14. package/node/Autocomplete/helpers.js +32 -0
  15. package/node/Autocomplete/index.js +7 -0
  16. package/node/Bg/BgColor.js +25 -0
  17. package/node/Bg/BgPhoto.js +20 -0
  18. package/node/Bg/BgSvg.js +16 -0
  19. package/node/Bg/index.js +6 -0
  20. package/node/Breadcrumbs/Breadcrumbs.js +31 -0
  21. package/node/Breadcrumbs/index.js +4 -0
  22. package/node/Buttons/Button.js +17 -0
  23. package/node/Buttons/ButtonComposite.js +32 -0
  24. package/node/Buttons/ButtonFab.js +9 -0
  25. package/node/Buttons/ButtonLink.js +15 -0
  26. package/node/Buttons/IconButton.js +10 -0
  27. package/node/Buttons/index.js +8 -0
  28. package/node/Calendar/CalendarDaygridCell.js +61 -0
  29. package/node/Calendar/CalendarDaygridNav.js +28 -0
  30. package/node/Calendar/CalendarDaygridTable.js +61 -0
  31. package/node/Calendar/CalendarLegend.js +20 -0
  32. package/node/Calendar/calendar-api-google.js +131 -0
  33. package/node/Calendar/index.js +9 -0
  34. package/node/Calendar/types.js +2 -0
  35. package/node/Calendar/useCalendar.js +187 -0
  36. package/node/Calendar/utils.js +215 -0
  37. package/node/Carousel/Carousel.js +381 -0
  38. package/node/Carousel/CarouselCss.js +27 -0
  39. package/node/Carousel/index.js +4 -0
  40. package/node/Collapsable/Collapsable.js +4 -0
  41. package/node/Collapsable/CollapsableReach.js +253 -0
  42. package/node/Collapsable/index.js +5 -0
  43. package/node/Debug/Debug.js +13 -0
  44. package/node/Debug/index.js +4 -0
  45. package/node/Details/Details.js +67 -0
  46. package/node/Details/index.js +4 -0
  47. package/node/Dialog/DialogMui.js +83 -0
  48. package/node/Dialog/css/bare.js +24 -0
  49. package/node/Dialog/index.js +5 -0
  50. package/node/Dialog/m/bare.js +55 -0
  51. package/node/Dialog/m/basic.js +35 -0
  52. package/node/Dialog/m/index.js +8 -0
  53. package/node/Dialog/sc/bare.js +46 -0
  54. package/node/Dialog/sc/framer.js +19 -0
  55. package/node/Dialog/sc/framerMaterial.js +19 -0
  56. package/node/Dialog/sc/material.js +24 -0
  57. package/node/Dialog/tw/bare.js +45 -0
  58. package/node/Dialog/tw/elegant.js +23 -0
  59. package/node/Dialog/tw/framer.js +19 -0
  60. package/node/Dialog/tw/framerMaterial.js +19 -0
  61. package/node/Dialog/tw/material.js +23 -0
  62. package/node/Editor/Editor--tiptap.js +31 -0
  63. package/node/Editor/components.js +15 -0
  64. package/node/Editor/index.js +4 -0
  65. package/node/Favicon/FaviconTags.js +19 -0
  66. package/node/Favicon/index.js +4 -0
  67. package/node/Form/Form.js +65 -0
  68. package/node/Form/index.js +4 -0
  69. package/node/Form/sc/bare.js +23 -0
  70. package/node/Forms/Checkbox/Checkbox.js +21 -0
  71. package/node/Forms/Checkbox/index.js +4 -0
  72. package/node/Forms/Feedback/Feedback.js +13 -0
  73. package/node/Forms/Feedback/index.js +4 -0
  74. package/node/Forms/Field/Field.js +52 -0
  75. package/node/Forms/Field/FieldControl.js +51 -0
  76. package/node/Forms/Field/FieldHint.js +7 -0
  77. package/node/Forms/Field/index.js +5 -0
  78. package/node/Forms/Input/Input.js +20 -0
  79. package/node/Forms/Input/index.js +4 -0
  80. package/node/Forms/InputGroup/InputGroup.js +19 -0
  81. package/node/Forms/InputGroup/index.js +4 -0
  82. package/node/Forms/Label/Label.js +9 -0
  83. package/node/Forms/Label/index.js +4 -0
  84. package/node/Forms/Password/Password.js +20 -0
  85. package/node/Forms/Password/index.js +4 -0
  86. package/node/Forms/Radio/Radio.js +28 -0
  87. package/node/Forms/Radio/index.js +4 -0
  88. package/node/Forms/Switch/Switch.js +23 -0
  89. package/node/Forms/Switch/index.js +4 -0
  90. package/node/Forms/Textarea/Textarea.js +15 -0
  91. package/node/Forms/Textarea/TextareaRich.js +31 -0
  92. package/node/Forms/Textarea/index.js +5 -0
  93. package/node/Forms/Toggle/Toggle.js +37 -0
  94. package/node/Forms/Toggle/index.js +4 -0
  95. package/node/Forms/Toggle/useToggle.js +149 -0
  96. package/node/Forms/antispam.js +61 -0
  97. package/node/Forms/helpers.js +52 -0
  98. package/node/Forms/index.js +19 -0
  99. package/node/Forms/styles.js +32 -0
  100. package/node/Gauge/Gauge.js +106 -0
  101. package/node/Grid/Grid.js +56 -0
  102. package/node/Grid/index.js +4 -0
  103. package/node/Hamburger/Hamburger.js +56 -0
  104. package/node/Hamburger/index.js +4 -0
  105. package/node/Header/index.js +4 -0
  106. package/node/Header/useHeader.js +34 -0
  107. package/node/Hidden/Hidden.js +13 -0
  108. package/node/Hidden/index.js +4 -0
  109. package/node/Img/index.js +4 -0
  110. package/node/Img/sc/bare.js +42 -0
  111. package/node/Img/types.js +2 -0
  112. package/node/Link/Link.js +7 -0
  113. package/node/Link/LinkBlank.js +21 -0
  114. package/node/Link/index.js +5 -0
  115. package/node/Menu/Menu.js +7 -0
  116. package/node/Menu/index.js +4 -0
  117. package/node/MenuItem/MenuItem.js +7 -0
  118. package/node/MenuItem/index.js +4 -0
  119. package/node/Meta/Meta.js +9 -0
  120. package/node/Meta/index.js +4 -0
  121. package/node/NoJs/NoJs.js +10 -0
  122. package/node/NoJs/index.js +4 -0
  123. package/node/Pagination/PaginationNav.js +65 -0
  124. package/node/Pagination/PaginationResults.js +15 -0
  125. package/node/Pagination/index.js +5 -0
  126. package/node/Pill/Pill.js +10 -0
  127. package/node/Pill/index.js +4 -0
  128. package/node/Progress/ProgressCircular.js +19 -0
  129. package/node/Progress/ProgressLinear.js +28 -0
  130. package/node/Progress/ProgressOverlay.js +28 -0
  131. package/node/Progress/index.js +6 -0
  132. package/node/Rating/Rating.js +76 -0
  133. package/node/Rating/index.js +57 -0
  134. package/node/Select/SelectDownshift.js +41 -0
  135. package/node/Select/components.js +15 -0
  136. package/node/Select/index.js +7 -0
  137. package/node/Sidebar/Sidebar.js +27 -0
  138. package/node/Sidebar/index.js +4 -0
  139. package/node/Spacing/Spacing.js +49 -0
  140. package/node/Spacing/index.js +4 -0
  141. package/node/Sticky/Sticky.js +222 -0
  142. package/node/Sticky/StickyCss.js +10 -0
  143. package/node/Sticky/index.js +4 -0
  144. package/node/Tabs/TabsMui.js +49 -0
  145. package/node/Tabs/index.js +4 -0
  146. package/node/Tabs/sc/bare.js +87 -0
  147. package/node/Tabs/tw/bare.js +20 -0
  148. package/node/Tabs/tw/material.js +21 -0
  149. package/node/Tabs/useTabs.js +48 -0
  150. package/node/Typography/CopyPasteVisible.js +7 -0
  151. package/node/Typography/Native.js +17 -0
  152. package/node/Typography/ReadMore.js +47 -0
  153. package/node/Typography/TextLoop.js +51 -0
  154. package/node/Typography/TypeStairs.js +53 -0
  155. package/node/Typography/index.js +8 -0
  156. package/node/css/index.js +36 -0
  157. package/node/helpers/classed.js +72 -0
  158. package/node/helpers/extend-component.js +16 -0
  159. package/node/helpers/index.js +5 -0
  160. package/node/hooks/index.js +18 -0
  161. package/node/hooks/types.js +2 -0
  162. package/node/hooks/useAsyncFn.js +40 -0
  163. package/node/hooks/useDateLocale.js +42 -0
  164. package/node/hooks/useEffectOnce.js +12 -0
  165. package/node/hooks/useFirstMountState.js +16 -0
  166. package/node/hooks/useFocus.js +15 -0
  167. package/node/hooks/useId.js +12 -0
  168. package/node/hooks/useIsomorphicLayoutEffect.js +11 -0
  169. package/node/hooks/useMount.js +13 -0
  170. package/node/hooks/useMountedState.js +19 -0
  171. package/node/hooks/usePrevious.js +12 -0
  172. package/node/hooks/useScrollPosition.js +84 -0
  173. package/node/hooks/useScrollTo.js +25 -0
  174. package/node/hooks/useTraceUpdate.js +25 -0
  175. package/node/hooks/useUpdateEffect.js +18 -0
  176. package/node/hooks/useWindowSize.js +17 -0
  177. package/node/index.js +8 -0
  178. package/node/m/MotionProvider.js +43 -0
  179. package/node/m/index.js +9 -0
  180. package/node/m/lite.js +4 -0
  181. package/node/m/max.js +4 -0
  182. package/node/sc/index.js +37 -0
  183. package/node/scm/index.js +36 -0
  184. package/node/shared/index.js +11 -0
  185. package/node/styles/Body.js +16 -0
  186. package/node/styles/Global.js +21 -0
  187. package/node/styles/index.js +10 -0
  188. package/node/styles/media.js +160 -0
  189. package/node/styles/spacing.js +52 -0
  190. package/node/styles/styled.js +17 -0
  191. package/node/styles/theme--vanilla.js +61 -0
  192. package/node/styles/theme.js +45 -0
  193. package/node/tw/index.js +36 -0
  194. package/node/twm/index.js +36 -0
  195. package/node/types.js +2 -0
  196. package/package.json +3 -3
  197. package/styles/theme--vanilla.d.ts +1 -1
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeStairs = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var react_1 = require("react");
7
+ exports.TypeStairs = (0, react_1.forwardRef)(function (_a, ref) {
8
+ var children = _a.children, limit = _a.limit;
9
+ // split in rows or just use one row if there is no limit
10
+ var rows = limit ? splitTextIntoRows(children, limit) : [children];
11
+ return rows.length > 1 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: rows.map(function (row, rowIndex) {
12
+ return ((0, jsx_runtime_1.jsxs)("span", { children: [renderRow(row, rowIndex, ref), rowIndex !== rows.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, "row-".concat(rowIndex)));
13
+ }) })) : (renderRow(rows[0], 0, ref));
14
+ });
15
+ /**
16
+ * every number chars find a space and break, then restart the gradient weight
17
+ * @see https://stackoverflow.com/a/25770787
18
+ */
19
+ function splitTextIntoRows(input, limit) {
20
+ if (input === void 0) { input = ""; }
21
+ if (limit === void 0) { limit = 18; }
22
+ var rows = [];
23
+ var arr = input.split(" ");
24
+ var currow = arr[0];
25
+ var rowlen = currow.length;
26
+ for (var i = 1; i < arr.length; i++) {
27
+ var word = arr[i];
28
+ rowlen += word.length + 1;
29
+ if (rowlen <= limit) {
30
+ currow += " " + word;
31
+ }
32
+ else {
33
+ rows.push(currow);
34
+ currow = word;
35
+ rowlen = word.length;
36
+ }
37
+ }
38
+ rows.push(currow);
39
+ return rows;
40
+ }
41
+ function renderRow(row, rowIndex, ref) {
42
+ var letters = row.split("");
43
+ var fontWeightIdx = 1;
44
+ // const fontWeight = Math.min(fontWeightIdx * 100, 800);
45
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: letters.map(function (letter, letterIndex) {
46
+ var fontWeight = Math.min(fontWeightIdx * 100, 800);
47
+ // don't waste a fontWeight for a white space
48
+ if (letter !== " ") {
49
+ fontWeightIdx++;
50
+ }
51
+ return ((0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ style: { fontWeight: fontWeight }, ref: ref }, { children: letter }), "letter-".concat(rowIndex, "-").concat(letterIndex)));
52
+ }) }));
53
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./CopyPasteVisible"), exports);
5
+ tslib_1.__exportStar(require("./Native"), exports);
6
+ tslib_1.__exportStar(require("./ReadMore"), exports);
7
+ tslib_1.__exportStar(require("./TextLoop"), exports);
8
+ tslib_1.__exportStar(require("./TypeStairs"), exports);
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KoineDialog = void 0;
4
+ var tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("../shared"), exports);
6
+ // export * from "../Alert";
7
+ // export * from "../Animations";
8
+ // export * from "../Autocomplete";
9
+ // export * from "../Bg";
10
+ // export * from "../Breadcrumbs";
11
+ // export * from "../Buttons";
12
+ // export * from "../Carousel";
13
+ // export * from "../Collapsable";
14
+ // export * from "../Debug";
15
+ var bare_1 = require("../Dialog/css/bare");
16
+ Object.defineProperty(exports, "KoineDialog", { enumerable: true, get: function () { return bare_1.KoineDialog; } });
17
+ // export * from "../Form";
18
+ // export * from "../Forms";
19
+ // export * from "../Grid";
20
+ // export * from "../Hamburger";
21
+ // export * from "../Header";
22
+ // export * from "../Hidden";
23
+ // export * from "../Img";
24
+ // export * from "../Link";
25
+ // export * from "../MenuItem";
26
+ // export * from "../Pagination";
27
+ // export * from "../Pill";
28
+ // export * from "../Progress";
29
+ // export * from "../Rating";
30
+ // // export * from "../Select";
31
+ // export * from "../Sidebar";
32
+ // export * from "../Spacing";
33
+ // export * from "../Sticky";
34
+ // export * from "../styles";
35
+ // export * from "../Tabs";
36
+ // export * from "../Typography";
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classed = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ /**
7
+ * This utility allows to extend a component a là `styled-components` but for
8
+ * a className based styling solution like Tailwind,
9
+ *
10
+ * It also plays nicely with tailwind intellisense @see:
11
+ *
12
+ * - https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
13
+ *
14
+ * For references about tagged functions:
15
+ * - https://javascript.plainenglish.io/how-css-in-js-libraries-work-da4145b1b6c7
16
+ * - https://makersden.io/blog/reverse-engineering-styled-components
17
+ * - https://typesafe.blog/article/the-logic-behind-javascript-tag-functions
18
+ * - https://flaming.codes/posts/typescript-and-javascript-tagged-template-strings
19
+ */
20
+ function classed(component) {
21
+ // @ts-expect-error nevermind for now...
22
+ var type = component.type || component;
23
+ return function (strings) {
24
+ var args = [];
25
+ for (var _i = 1; _i < arguments.length; _i++) {
26
+ args[_i - 1] = arguments[_i];
27
+ }
28
+ var WrappedComponent = (0, react_1.forwardRef)(function (props, ref) {
29
+ var _a;
30
+ var argResolved = args
31
+ .map(function (arg, index) {
32
+ var result = "";
33
+ if (typeof arg === "function") {
34
+ result = arg(props);
35
+ }
36
+ else if (typeof arg !== "undefined") {
37
+ result = arg.toString();
38
+ }
39
+ return strings[index] + result;
40
+ })
41
+ .join("");
42
+ var isNativeHtmlElement = typeof type === "string";
43
+ var propsToForward = isNativeHtmlElement
44
+ ? {}
45
+ : props;
46
+ if (isNativeHtmlElement) {
47
+ for (var key in props) {
48
+ // like styled-components `transient` props
49
+ if (!key.startsWith("$")) {
50
+ // FIXME: for react 18 we need: @ts-expect-error
51
+ propsToForward[key] = props[key];
52
+ }
53
+ }
54
+ }
55
+ // get the tagged function string outcome
56
+ var className = argResolved || strings[0];
57
+ // check if we need to clean it or not from the optional structure `< class="..."`
58
+ className = ((_a = className.match(/class="([^"]*)/)) === null || _a === void 0 ? void 0 : _a[1]) || className;
59
+ // add the custom classes from props
60
+ className += (props === null || props === void 0 ? void 0 : props.className) ? " " + (props === null || props === void 0 ? void 0 : props.className) : "";
61
+ return (0, react_1.createElement)(type, tslib_1.__assign(tslib_1.__assign({}, propsToForward), {
62
+ // only add ot props if it is not an empty string
63
+ className: className || undefined,
64
+ // add ref to props
65
+ ref: ref }));
66
+ });
67
+ // FIXME: not sure if this is needed
68
+ // WrappedComponent.displayName = type.toString();
69
+ return WrappedComponent; // as unknown as React.ReactElement<typeof props>;
70
+ };
71
+ }
72
+ exports.classed = classed;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendComponent = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var extendComponent = function (component, defaultProps) {
7
+ // FIXME: check if we need to forwardRef or not
8
+ var NewComponent = function (props) {
9
+ return (0, react_1.createElement)(component, props);
10
+ };
11
+ // const NewComponent = forwardRef<React.ComponentProps<Component>, Component>(
12
+ // (props, ref) => createElement(component, { ...props, ref })
13
+ // );
14
+ return Object.assign(NewComponent, tslib_1.__assign(tslib_1.__assign({}, defaultProps), { defaultProps: defaultProps }));
15
+ };
16
+ exports.extendComponent = extendComponent;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./classed"), exports);
5
+ tslib_1.__exportStar(require("./extend-component"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./useAsyncFn"), exports);
5
+ tslib_1.__exportStar(require("./useDateLocale"), exports);
6
+ tslib_1.__exportStar(require("./useEffectOnce"), exports);
7
+ tslib_1.__exportStar(require("./useFirstMountState"), exports);
8
+ tslib_1.__exportStar(require("./useFocus"), exports);
9
+ tslib_1.__exportStar(require("./useId"), exports);
10
+ tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
11
+ tslib_1.__exportStar(require("./useMount"), exports);
12
+ tslib_1.__exportStar(require("./useMountedState"), exports);
13
+ tslib_1.__exportStar(require("./usePrevious"), exports);
14
+ tslib_1.__exportStar(require("./useScrollPosition"), exports);
15
+ // export * from "./useScrollTo";
16
+ tslib_1.__exportStar(require("./useTraceUpdate"), exports);
17
+ tslib_1.__exportStar(require("./useUpdateEffect"), exports);
18
+ tslib_1.__exportStar(require("./useWindowSize"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAsyncFn = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ var useMountedState_1 = require("./useMountedState");
7
+ /**
8
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
9
+ */
10
+ function useAsyncFn(fn, deps, initialState) {
11
+ if (deps === void 0) { deps = []; }
12
+ if (initialState === void 0) { initialState = { loading: false }; }
13
+ var lastCallId = (0, react_1.useRef)(0);
14
+ var isMounted = (0, useMountedState_1.useMountedState)();
15
+ var _a = (0, react_1.useState)(initialState), state = _a[0], set = _a[1];
16
+ var callback = (0, react_1.useCallback)(function () {
17
+ var args = [];
18
+ for (var _i = 0; _i < arguments.length; _i++) {
19
+ args[_i] = arguments[_i];
20
+ }
21
+ var callId = ++lastCallId.current;
22
+ if (!state.loading) {
23
+ set(function (prevState) { return (tslib_1.__assign(tslib_1.__assign({}, prevState), { loading: true })); });
24
+ }
25
+ return fn.apply(void 0, args).then(function (value) {
26
+ isMounted() &&
27
+ callId === lastCallId.current &&
28
+ set({ value: value, loading: false });
29
+ return value;
30
+ }, function (error) {
31
+ isMounted() &&
32
+ callId === lastCallId.current &&
33
+ set({ error: error, loading: false });
34
+ return error;
35
+ });
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, deps);
38
+ return [state, callback];
39
+ }
40
+ exports.useAsyncFn = useAsyncFn;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDateLocale = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = require("react");
6
+ /**
7
+ * Dynamically import the date-fns correct locale
8
+ *
9
+ * Inspired by:
10
+ * @see https://robertmarshall.dev/blog/dynamically-import-datefns-locale-mui-datepicker-localization/
11
+ */
12
+ function useDateLocale(locale, defaultLocale) {
13
+ var _this = this;
14
+ if (defaultLocale === void 0) { defaultLocale = "en"; }
15
+ var _a = (0, react_1.useState)(), data = _a[0], setData = _a[1];
16
+ var _b = (0, react_1.useState)(defaultLocale), current = _b[0], setCurrent = _b[1];
17
+ // const [ready, setReady] = useState(false);
18
+ // If the user changes the locale listen to the change and import the locale that is now required.
19
+ (0, react_1.useEffect)(function () {
20
+ var importLocaleFile = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
21
+ var localeToSet;
22
+ return tslib_1.__generator(this, function (_a) {
23
+ switch (_a.label) {
24
+ case 0: return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require(
25
+ /* webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
26
+ "date-fns/locale/".concat(locale, "/index.js"))); })];
27
+ case 1:
28
+ localeToSet = _a.sent();
29
+ setCurrent(locale || current);
30
+ setData(localeToSet.default);
31
+ return [2 /*return*/];
32
+ }
33
+ });
34
+ }); };
35
+ // If the locale has not yet been loaded.
36
+ if (locale !== current) {
37
+ importLocaleFile();
38
+ }
39
+ }, [locale, current]);
40
+ return data;
41
+ }
42
+ exports.useDateLocale = useDateLocale;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEffectOnce = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts)
7
+ */
8
+ var useEffectOnce = function (effect) {
9
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10
+ (0, react_1.useEffect)(effect, []);
11
+ };
12
+ exports.useEffectOnce = useEffectOnce;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFirstMountState = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
7
+ */
8
+ function useFirstMountState() {
9
+ var isFirst = (0, react_1.useRef)(true);
10
+ if (isFirst.current) {
11
+ isFirst.current = false;
12
+ return true;
13
+ }
14
+ return isFirst.current;
15
+ }
16
+ exports.useFirstMountState = useFirstMountState;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFocus = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @see https://stackoverflow.com/a/54159564/1938970
7
+ */
8
+ var useFocus = function () {
9
+ var element = (0, react_1.useRef)(null);
10
+ var setFocus = function () {
11
+ element.current && element.current.focus();
12
+ };
13
+ return [element, setFocus];
14
+ };
15
+ exports.useFocus = useFocus;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useId = void 0;
4
+ var utils_1 = require("@koine/utils");
5
+ /**
6
+ * FIXME: once we can move to react 18 just replace this import with `{ useId } from "react";`
7
+ */
8
+ function useId(prefix) {
9
+ if (prefix === void 0) { prefix = "uid"; }
10
+ return "".concat(prefix, "-").concat((0, utils_1.uid)());
11
+ }
12
+ exports.useId = useId;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsomorphicLayoutEffect = void 0;
4
+ var react_1 = require("react");
5
+ var utils_1 = require("@koine/utils");
6
+ /**
7
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useFirstMountState.ts)
8
+ */
9
+ exports.useIsomorphicLayoutEffect = utils_1.isBrowser
10
+ ? react_1.useLayoutEffect
11
+ : react_1.useEffect;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMount = void 0;
4
+ var useEffectOnce_1 = require("./useEffectOnce");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMount.ts)
7
+ */
8
+ var useMount = function (fn) {
9
+ (0, useEffectOnce_1.useEffectOnce)(function () {
10
+ fn();
11
+ });
12
+ };
13
+ exports.useMount = useMount;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMountedState = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts)
7
+ */
8
+ function useMountedState() {
9
+ var mountedRef = (0, react_1.useRef)(false);
10
+ var get = (0, react_1.useCallback)(function () { return mountedRef.current; }, []);
11
+ (0, react_1.useEffect)(function () {
12
+ mountedRef.current = true;
13
+ return function () {
14
+ mountedRef.current = false;
15
+ };
16
+ }, []);
17
+ return get;
18
+ }
19
+ exports.useMountedState = useMountedState;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePrevious = void 0;
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;
11
+ }
12
+ exports.usePrevious = usePrevious;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useScrollPosition = void 0;
4
+ var react_1 = require("react");
5
+ var utils_1 = require("@koine/utils");
6
+ var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
7
+ var zeroPosition = { x: 0, y: 0 };
8
+ var getClientRect = function (element) {
9
+ return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
10
+ };
11
+ var getScrollPosition = function (element, useWindow, boundingElement) {
12
+ if (!utils_1.isBrowser) {
13
+ return zeroPosition;
14
+ }
15
+ if (useWindow) {
16
+ return { x: window.scrollX, y: window.scrollY };
17
+ }
18
+ var targetPosition = getClientRect((element === null || element === void 0 ? void 0 : element.current) || document.body);
19
+ var containerPosition = getClientRect(boundingElement === null || boundingElement === void 0 ? void 0 : boundingElement.current);
20
+ if (!targetPosition) {
21
+ return zeroPosition;
22
+ }
23
+ return containerPosition
24
+ ? {
25
+ x: (containerPosition.x || 0) - (targetPosition.x || 0),
26
+ y: (containerPosition.y || 0) - (targetPosition.y || 0),
27
+ }
28
+ : { x: targetPosition.left, y: targetPosition.top };
29
+ };
30
+ /**
31
+ * @borrows [@n8tb1t/use-scroll-position@2.0.3](https://github.com/n8tb1t/use-scroll-position) by `n8tb1t <n8tb1t@gmail.com>`
32
+ *
33
+ * We've just:
34
+ * - reused internal helper functions
35
+ * - compacted object arguments in functions as plain argument list to improve compression
36
+ */
37
+ var useScrollPosition = function (effect, deps, element, useWindow, wait, boundingElement) {
38
+ if (deps === void 0) { deps = []; }
39
+ var position = (0, react_1.useRef)(getScrollPosition(null, useWindow, boundingElement));
40
+ var throttleTimeout = null;
41
+ var callBack = function () {
42
+ var current = getScrollPosition(element, useWindow, boundingElement);
43
+ effect(current, position.current);
44
+ position.current = current;
45
+ throttleTimeout = null;
46
+ };
47
+ (0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
48
+ var _a;
49
+ if (!utils_1.isBrowser) {
50
+ return undefined;
51
+ }
52
+ var handleScroll = function () {
53
+ if (wait) {
54
+ if (throttleTimeout === null) {
55
+ throttleTimeout = window.setTimeout(callBack, wait);
56
+ }
57
+ }
58
+ else {
59
+ callBack();
60
+ }
61
+ };
62
+ if (boundingElement) {
63
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", handleScroll, {
64
+ passive: true,
65
+ });
66
+ }
67
+ else {
68
+ window.addEventListener("scroll", handleScroll, { passive: true });
69
+ }
70
+ return function () {
71
+ var _a;
72
+ if (boundingElement) {
73
+ (_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", handleScroll);
74
+ }
75
+ else {
76
+ window.removeEventListener("scroll", handleScroll);
77
+ }
78
+ if (throttleTimeout) {
79
+ clearTimeout(throttleTimeout);
80
+ }
81
+ };
82
+ }, deps);
83
+ };
84
+ exports.useScrollPosition = useScrollPosition;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useScrollTo = void 0;
4
+ var utils_1 = require("@koine/utils");
5
+ var useHeader_1 = require("../Header/useHeader");
6
+ function useScrollTo(id, offset) {
7
+ if (id === void 0) { id = ""; }
8
+ if (offset === void 0) { offset = 0; }
9
+ var _a = (0, useHeader_1.useHeader)(), headerHeight = _a[2];
10
+ if (!utils_1.isBrowser) {
11
+ return;
12
+ }
13
+ var headerOffset = headerHeight || 0;
14
+ var element = document.getElementById(id);
15
+ var top = 0;
16
+ if (element && element.offsetParent) {
17
+ do {
18
+ top += element.offsetTop;
19
+ } while ((element = element.offsetParent));
20
+ }
21
+ top -= offset;
22
+ top -= headerOffset;
23
+ window.scroll(0, top);
24
+ }
25
+ exports.useScrollTo = useScrollTo;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTraceUpdate = void 0;
4
+ var react_1 = require("react");
5
+ /**
6
+ * @see https://stackoverflow.com/a/51082563/9122820
7
+ */
8
+ function useTraceUpdate(props) {
9
+ var prev = (0, react_1.useRef)(props);
10
+ (0, react_1.useEffect)(function () {
11
+ var changedProps = Object.entries(props).reduce(function (ps, _a) {
12
+ var k = _a[0], v = _a[1];
13
+ if (prev.current[k] !== v) {
14
+ // @ts-expect-error Does not matter here...
15
+ ps[k] = [prev.current[k], v];
16
+ }
17
+ return ps;
18
+ }, {});
19
+ if (Object.keys(changedProps).length > 0) {
20
+ console.log("Changed props:", changedProps);
21
+ }
22
+ prev.current = props;
23
+ });
24
+ }
25
+ exports.useTraceUpdate = useTraceUpdate;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useUpdateEffect = void 0;
4
+ var react_1 = require("react");
5
+ var useFirstMountState_1 = require("./useFirstMountState");
6
+ /**
7
+ * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts)
8
+ */
9
+ var useUpdateEffect = function (effect, deps) {
10
+ var isFirstMount = (0, useFirstMountState_1.useFirstMountState)();
11
+ (0, react_1.useEffect)(function () {
12
+ if (!isFirstMount) {
13
+ return effect();
14
+ }
15
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
+ }, deps);
17
+ };
18
+ exports.useUpdateEffect = useUpdateEffect;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowSize = void 0;
4
+ var react_1 = require("react");
5
+ function useWindowSize() {
6
+ var _a = (0, react_1.useState)([0, 0]), size = _a[0], setSize = _a[1];
7
+ (0, react_1.useEffect)(function () {
8
+ function updateSize() {
9
+ setSize([window.innerWidth, window.innerHeight]);
10
+ }
11
+ window.addEventListener("resize", updateSize);
12
+ updateSize();
13
+ return function () { return window.removeEventListener("resize", updateSize); };
14
+ }, []);
15
+ return size;
16
+ }
17
+ exports.useWindowSize = useWindowSize;
package/node/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./shared"), exports);
5
+ // we need to alias the star export otherwise the named exports would collide
6
+ // export * as css from "./css";
7
+ // export * as sc from "./sc";
8
+ // export * as tw from "./tw";
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MotionProvider = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var framer_motion_1 = require("framer-motion");
7
+ /**
8
+ * `<LazyMotion />` provider wrapper from `framer-motion`
9
+ *
10
+ * @see https://www.framer.com/docs/guide-reduce-bundle-size/
11
+ *
12
+ * About the difference between `lite` and `max`
13
+ * @see https://www.framer.com/docs/guide-reduce-bundle-size/#available-features
14
+ *
15
+ * @example
16
+ *
17
+ * `lite` version:
18
+ * ```tsx
19
+ * import { MotionProvider } from "@koine/react/m";
20
+ *
21
+ * const features = () => import("@koine/react/m/lite").then((m) => m.default);
22
+ *
23
+ * <MotionProvider features={features}>
24
+ * <App />
25
+ * </MotionProvider>
26
+ * ```
27
+ *
28
+ * ### `max` version
29
+ * ```tsx
30
+ * import { MotionProvider } from "@koine/react/m";
31
+ *
32
+ * const features = () => import("@koine/react/m/max").then((m) => m.default);
33
+ *
34
+ * <MotionProvider features={features}>
35
+ * <App />
36
+ * </MotionProvider>
37
+ * ```
38
+ */
39
+ var MotionProvider = function (_a) {
40
+ var features = _a.features, children = _a.children;
41
+ return (0, jsx_runtime_1.jsx)(framer_motion_1.LazyMotion, tslib_1.__assign({ features: features }, { children: children }));
42
+ };
43
+ exports.MotionProvider = MotionProvider;