@koine/react 2.0.0-beta.10 → 2.0.0-beta.12

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 (216) hide show
  1. package/package.json +11 -11
  2. package/Alert/Alert.js +0 -33
  3. package/Alert/Alert.stories.js +0 -39
  4. package/Alert/index.js +0 -6
  5. package/Animations/Reveal.js +0 -53
  6. package/Animations/Underline.js +0 -26
  7. package/Animations/index.js +0 -8
  8. package/Animations/useReveal.js +0 -83
  9. package/Autocomplete/AutocompleteDownshift.js +0 -167
  10. package/Autocomplete/AutocompleteDownshiftMultiselect.js +0 -362
  11. package/Autocomplete/AutocompleteMui.js +0 -183
  12. package/Autocomplete/AutocompleteReach.js +0 -121
  13. package/Autocomplete/components.js +0 -132
  14. package/Autocomplete/helpers.js +0 -34
  15. package/Autocomplete/index.js +0 -15
  16. package/Bg/BgColor.js +0 -64
  17. package/Bg/BgPhoto.js +0 -82
  18. package/Bg/BgSvg.js +0 -31
  19. package/Bg/index.js +0 -8
  20. package/Breadcrumbs/Breadcrumbs.js +0 -103
  21. package/Breadcrumbs/index.js +0 -6
  22. package/Buttons/Button.js +0 -106
  23. package/Buttons/ButtonComposite.js +0 -116
  24. package/Buttons/ButtonFab.js +0 -27
  25. package/Buttons/ButtonLink.js +0 -29
  26. package/Buttons/IconButton.js +0 -41
  27. package/Buttons/index.js +0 -10
  28. package/Calendar/CalendarDaygridCell.js +0 -105
  29. package/Calendar/CalendarDaygridNav.js +0 -63
  30. package/Calendar/CalendarDaygridTable.js +0 -126
  31. package/Calendar/CalendarLegend.js +0 -39
  32. package/Calendar/calendar-api-google.js +0 -110
  33. package/Calendar/index.js +0 -11
  34. package/Calendar/types.js +0 -4
  35. package/Calendar/useCalendar.js +0 -235
  36. package/Calendar/utils.js +0 -252
  37. package/Carousel/Carousel.js +0 -387
  38. package/Carousel/CarouselCss.js +0 -64
  39. package/Carousel/index.js +0 -6
  40. package/Collapsable/Collapsable.js +0 -11
  41. package/Collapsable/CollapsableReach.js +0 -251
  42. package/Collapsable/index.js +0 -7
  43. package/Debug/Debug.js +0 -34
  44. package/Debug/index.js +0 -6
  45. package/Details/Details.js +0 -117
  46. package/Details/Details.stories.js +0 -39
  47. package/Details/index.js +0 -6
  48. package/Dialog/DialogMui.js +0 -143
  49. package/Dialog/DialogMui.stories.js +0 -38
  50. package/Dialog/css/bare.js +0 -55
  51. package/Dialog/css/index.stories.js +0 -93
  52. package/Dialog/index.js +0 -11
  53. package/Dialog/m/bare.js +0 -125
  54. package/Dialog/m/basic.js +0 -50
  55. package/Dialog/m/index.js +0 -14
  56. package/Dialog/sc/bare.js +0 -83
  57. package/Dialog/sc/framer.js +0 -26
  58. package/Dialog/sc/framerMaterial.js +0 -26
  59. package/Dialog/sc/index.stories.js +0 -75
  60. package/Dialog/sc/material.js +0 -78
  61. package/Dialog/tw/bare.js +0 -55
  62. package/Dialog/tw/elegant.js +0 -54
  63. package/Dialog/tw/framer.js +0 -26
  64. package/Dialog/tw/framerMaterial.js +0 -26
  65. package/Dialog/tw/index.stories.js +0 -113
  66. package/Dialog/tw/material.js +0 -54
  67. package/Editor/Editor--tiptap.js +0 -72
  68. package/Editor/components.js +0 -59
  69. package/Editor/index.js +0 -6
  70. package/FaviconTags.js +0 -73
  71. package/Form/Form.js +0 -130
  72. package/Form/index.js +0 -6
  73. package/Form/sc/bare.js +0 -55
  74. package/Forms/Checkbox/Checkbox.js +0 -62
  75. package/Forms/Checkbox/index.js +0 -6
  76. package/Forms/Feedback/Feedback.js +0 -25
  77. package/Forms/Feedback/index.js +0 -6
  78. package/Forms/Field/Field.js +0 -75
  79. package/Forms/Field/FieldControl.js +0 -69
  80. package/Forms/Field/FieldHint.js +0 -17
  81. package/Forms/Field/index.js +0 -7
  82. package/Forms/Input/Input.js +0 -67
  83. package/Forms/Input/index.js +0 -6
  84. package/Forms/InputGroup/InputGroup.js +0 -85
  85. package/Forms/InputGroup/index.js +0 -6
  86. package/Forms/Label/Label.js +0 -46
  87. package/Forms/Label/index.js +0 -6
  88. package/Forms/Password/Password.js +0 -72
  89. package/Forms/Password/index.js +0 -6
  90. package/Forms/Radio/Radio.js +0 -68
  91. package/Forms/Radio/index.js +0 -6
  92. package/Forms/Switch/Switch.js +0 -80
  93. package/Forms/Switch/index.js +0 -6
  94. package/Forms/Textarea/Textarea.js +0 -45
  95. package/Forms/Textarea/TextareaRich.js +0 -58
  96. package/Forms/Textarea/index.js +0 -7
  97. package/Forms/Toggle/Toggle-tailwind.js +0 -99
  98. package/Forms/Toggle/Toggle.js +0 -175
  99. package/Forms/Toggle/index.js +0 -6
  100. package/Forms/Toggle/useToggle-tailwind.js +0 -202
  101. package/Forms/Toggle/useToggle.js +0 -145
  102. package/Forms/antispam.js +0 -59
  103. package/Forms/helpers.js +0 -72
  104. package/Forms/index.js +0 -19
  105. package/Forms/styles.js +0 -94
  106. package/Gauge/Gauge.js +0 -111
  107. package/Grid/Grid.js +0 -106
  108. package/Grid/index.js +0 -6
  109. package/Hamburger/Hamburger.js +0 -90
  110. package/Hamburger/index.js +0 -6
  111. package/Header/index.js +0 -6
  112. package/Header/useHeader.js +0 -54
  113. package/Hidden/Hidden.js +0 -21
  114. package/Hidden/index.js +0 -6
  115. package/Img/index.js +0 -6
  116. package/Img/sc/bare.js +0 -43
  117. package/Img/types.js +0 -6
  118. package/Link/Link.js +0 -13
  119. package/Link/LinkBlank.js +0 -52
  120. package/Link/index.js +0 -7
  121. package/Menu/Menu.js +0 -22
  122. package/Menu/MenuMui.js +0 -165
  123. package/Menu/index.js +0 -6
  124. package/MenuItem/MenuItem.js +0 -31
  125. package/MenuItem/MenuItemMui.js +0 -32
  126. package/MenuItem/index.js +0 -6
  127. package/MenuItem/useMenuItem.js +0 -96
  128. package/Meta/Meta.js +0 -26
  129. package/Meta/index.js +0 -12
  130. package/NoJs/NoJs.js +0 -28
  131. package/NoJs/index.js +0 -12
  132. package/Pagination/PaginationNav.js +0 -126
  133. package/Pagination/PaginationResults.js +0 -45
  134. package/Pagination/index.js +0 -7
  135. package/Pill/Pill.js +0 -62
  136. package/Pill/index.js +0 -6
  137. package/Progress/ProgressCircular.js +0 -62
  138. package/Progress/ProgressLinear.js +0 -53
  139. package/Progress/ProgressOverlay.js +0 -75
  140. package/Progress/index.js +0 -8
  141. package/Rating/Rating.js +0 -188
  142. package/Rating/index.js +0 -85
  143. package/Select/SelectDownshift.js +0 -47
  144. package/Select/components.js +0 -44
  145. package/Select/index.js +0 -13
  146. package/Sidebar/Sidebar.js +0 -74
  147. package/Sidebar/index.js +0 -6
  148. package/Spacing/Spacing.js +0 -55
  149. package/Spacing/index.js +0 -6
  150. package/Sticky/Sticky.js +0 -228
  151. package/Sticky/StickyCss.js +0 -20
  152. package/Sticky/index.js +0 -19
  153. package/Tabs/TabsMui.js +0 -91
  154. package/Tabs/TabsMui.stories.js +0 -38
  155. package/Tabs/index.js +0 -6
  156. package/Tabs/sc/bare.js +0 -86
  157. package/Tabs/sc/index.stories.js +0 -1
  158. package/Tabs/tw/bare.js +0 -45
  159. package/Tabs/tw/index.stories.js +0 -46
  160. package/Tabs/tw/material.js +0 -44
  161. package/Tabs/useTabs.js +0 -66
  162. package/Typography/CopyPasteVisible.js +0 -17
  163. package/Typography/Native.js +0 -90
  164. package/Typography/ReadMore.js +0 -125
  165. package/Typography/TextLoop.js +0 -108
  166. package/Typography/TypeStairs.js +0 -71
  167. package/Typography/index.js +0 -10
  168. package/css/index.js +0 -33
  169. package/helpers/classed.js +0 -66
  170. package/helpers/classed.stories.js +0 -140
  171. package/helpers/createUseMediaQueryWidth.js +0 -193
  172. package/helpers/extend-component.js +0 -32
  173. package/helpers/index.js +0 -9
  174. package/helpers/mergeRefs.js +0 -30
  175. package/hooks/index.js +0 -92
  176. package/hooks/types.js +0 -6
  177. package/hooks/useAsyncFn.js +0 -56
  178. package/hooks/useDateLocale.js +0 -51
  179. package/hooks/useFirstMountState.js +0 -28
  180. package/hooks/useFixedOffset.js +0 -67
  181. package/hooks/useFocus.js +0 -30
  182. package/hooks/useInterval.js +0 -44
  183. package/hooks/useIsomorphicLayoutEffect.js +0 -23
  184. package/hooks/useKeyUp.js +0 -40
  185. package/hooks/useMeasure.js +0 -189
  186. package/hooks/useMountedState.js +0 -31
  187. package/hooks/useNavigateAway.js +0 -69
  188. package/hooks/usePrevious.js +0 -33
  189. package/hooks/usePreviousRef.js +0 -27
  190. package/hooks/useScrollPosition.js +0 -83
  191. package/hooks/useScrollThreshold.js +0 -52
  192. package/hooks/useScrollTo.js +0 -39
  193. package/hooks/useSmoothScroll.js +0 -49
  194. package/hooks/useSpinDelay.js +0 -59
  195. package/hooks/useTraceUpdate.js +0 -39
  196. package/hooks/useUpdateEffect.js +0 -30
  197. package/hooks/useWindowSize.js +0 -43
  198. package/index.js +0 -10
  199. package/m/MotionProvider.js +0 -27
  200. package/m/index.js +0 -10
  201. package/m/lite.js +0 -12
  202. package/m/max.js +0 -12
  203. package/sc/index.js +0 -49
  204. package/scm/index.js +0 -40
  205. package/shared/index.js +0 -13
  206. package/styles/Body.js +0 -28
  207. package/styles/Global.js +0 -55
  208. package/styles/index.js +0 -142
  209. package/styles/media.js +0 -139
  210. package/styles/spacing.js +0 -70
  211. package/styles/styled.js +0 -58
  212. package/styles/theme--vanilla.js +0 -82
  213. package/styles/theme.js +0 -49
  214. package/tw/index.js +0 -33
  215. package/twm/index.js +0 -33
  216. package/types.js +0 -4
@@ -1,140 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck These are just wip experiments, we stick to just `./classed.tsx`
3
- "use strict";
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- function _export(target, all) {
8
- for(var name in all)Object.defineProperty(target, name, {
9
- enumerable: true,
10
- get: all[name]
11
- });
12
- }
13
- _export(exports, {
14
- default: function() {
15
- return _default;
16
- },
17
- Playground: function() {
18
- return Playground;
19
- }
20
- });
21
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
22
- const _jsxruntime = require("react/jsx-runtime");
23
- const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
24
- const _classed = require("./classed");
25
- const Classed = (0, _classed.classed)("div")`< class="bg-red-400 ${(p)=>p.test === "0a" ? "py-3" : "px-3"}`;
26
- /**
27
- * Adapted (removed `classnames` dependency) from:
28
- * @see https://daily.dev/blog/my-tailwind-css-utility-function-for-creating-reusable-react-components-typescript-support
29
- *
30
- * See also [classname-hoc](https://www.npmjs.com/package/classname-hoc)
31
- */ function classedOriginal(type, ...className) {
32
- return function(props) {
33
- return /*#__PURE__*/ (0, _react.createElement)(type, {
34
- ...props,
35
- className: [
36
- props?.className || ""
37
- ].concat(className).join(" ")
38
- });
39
- };
40
- }
41
- const ClassedOriginal = classedOriginal("div", "bg-slate-800");
42
- function classedBind(props) {
43
- // @ts-expect-error no time now
44
- const classNameImpl = props.className ? " " + props.className : "";
45
- // return <this className={this.props.className + classNameImpl} {...props} />;
46
- return /*#__PURE__*/ (0, _react.createElement)(this.props.as || this.type, {
47
- ...props,
48
- className: this.props.className + classNameImpl
49
- }, // @ts-expect-error no time now
50
- props.children);
51
- }
52
- const ClassedBind = classedBind.bind(/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
53
- as: "h2",
54
- className: "bg-slate-800"
55
- }));
56
- function classedDynamic(ComponentFn) {
57
- return function(propsImplementation) {
58
- const { props, type } = ComponentFn(propsImplementation);
59
- const classNameDefault = props.className ? " " + props.className : "";
60
- return /*#__PURE__*/ (0, _react.createElement)(props.as || type, {
61
- ...props,
62
- ...propsImplementation,
63
- className: propsImplementation?.className + classNameDefault
64
- });
65
- };
66
- }
67
- const ClassedDynamicIgnoringProps = classedDynamic(()=>/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
68
- as: "h2",
69
- className: "bg-slate-800"
70
- }));
71
- const ClassedDynamicUsingProps = classedDynamic((p)=>{
72
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
73
- as: "h2",
74
- className: `bg-slate-800 ${p?.test === "3" ? "py-3" : "px-3"}`
75
- });
76
- });
77
- // type ExtractComponent<ComponentString extends string> =
78
- // ComponentString extends `<${infer ComponentName} class="${infer ClassNames}`
79
- // ? { name: ComponentName; className: ClassNames }
80
- // : { error: "Cannot parse Component string" };
81
- // type ExtractedComponent<T extends string> = ExtractComponent<T>;
82
- function classedTaggedStatic(value = "") {
83
- // @ts-expect-error we rely on correct implementation and assume it always matches
84
- const componentName = value.match(/<(.*?)\s/)[1];
85
- // @ts-expect-error we rely on correct implementation and assume it always matches
86
- const classDefault = value.match(/class="(.+)/)[1];
87
- return function(props) {
88
- // @ts-expect-error no time now
89
- const classCustom = props?.className ? " " + props?.className : "";
90
- return /*#__PURE__*/ (0, _react.createElement)(componentName, {
91
- ...props,
92
- className: classDefault + classCustom
93
- });
94
- }; /* as Component; */
95
- }
96
- const ClassedTaggedStatic = classedTaggedStatic(`<div class="bg-teal-400`);
97
- const _default = {
98
- // component: KoineDialog,
99
- title: "Helpers/classed"
100
- };
101
- const Template = (args)=>{
102
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
103
- children: [
104
- /*#__PURE__*/ (0, _jsxruntime.jsx)(Classed, {
105
- className: "text-yellow-200",
106
- test: "0a",
107
- children: "Classed taller"
108
- }),
109
- /*#__PURE__*/ (0, _jsxruntime.jsx)(Classed, {
110
- className: "text-yellow-200",
111
- test: "0b",
112
- children: "Classed wider"
113
- }),
114
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ClassedOriginal, {
115
- className: "text-white",
116
- children: "ClassedOriginal"
117
- }),
118
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ClassedBind, {
119
- className: "text-white",
120
- children: "ClassedBind"
121
- }),
122
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ClassedDynamicIgnoringProps, {
123
- className: "text-gray-300",
124
- test: "2",
125
- children: "ClassedDynamicIgnoringProps"
126
- }),
127
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ClassedDynamicUsingProps, {
128
- className: "text-gray-600",
129
- test: "3",
130
- children: "ClassedDynamicUsingProps"
131
- }),
132
- /*#__PURE__*/ (0, _jsxruntime.jsx)(ClassedTaggedStatic, {
133
- className: "text-gray-600",
134
- children: "ClassedTaggedStatic"
135
- })
136
- ]
137
- });
138
- };
139
- const Playground = Template.bind({});
140
- Playground.args = {};
@@ -1,193 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- createUseMediaQueryWidth: function() {
13
- return createUseMediaQueryWidth;
14
- },
15
- default: function() {
16
- return _default //// without creator it would be:
17
- //// ---------------------------------------------------------------------------
18
- // import { useState, useIsomorphicLayoutEffect, useMemo } from "react";
19
- // import type { Split } from "@koine/utils";
20
- // import isBrowser from "@koine/utils/isBrowser";
21
- // import { breakpoints as themeBreakpoints } from "@/config/theme/breakpoints";
22
- // import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect"
23
- // type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl";
24
- // type Breakpoints = Record<Breakpoint, number>;
25
- // type MediaQuery =
26
- // | `max:${Breakpoint}`
27
- // | `min:${Breakpoint}`
28
- // | `down:${Breakpoint}`
29
- // | `up:${Breakpoint}`
30
- // | `between:${Breakpoint}-${Breakpoint}`
31
- // | `only:${Breakpoint}`;
32
- // const breakpoints: Breakpoints = {
33
- // xs: 0,
34
- // ...themeBreakpoints,
35
- // };
36
- // const sortedBreakpointsNames = (
37
- // Object.keys(breakpoints).map((key) => {
38
- // const br = key as keyof typeof breakpoints;
39
- // return [br, breakpoints[br]];
40
- // }) as [Breakpoint, number][]
41
- // )
42
- // .sort((a, b) => a[1] - b[1])
43
- // .map((item) => item[0]);
44
- // const getNextBreakpoint = (breakpoint: Breakpoint) => {
45
- // const index = sortedBreakpointsNames.indexOf(breakpoint);
46
- // return sortedBreakpointsNames[index + 1];
47
- // };
48
- // /**
49
- // * It behaves the same as `(min-width: ${value}px)`
50
- // * where value is the given breakpoint value.
51
- // * For ease of use this can be used both as a function `min("md")` and as an
52
- // * object literal `min.md`.
53
- // */
54
- // const min = (br: Breakpoint) => `(min-width: ${breakpoints[br]}px)`;
55
- // /**
56
- // * It behaves the same as `(max-width: ${value}px)`
57
- // * where value is the given breakpoint value.
58
- // * For ease of use this can be used both as a function `max("md")` and as an
59
- // * object literal `max.md`.
60
- // */
61
- // const max = (br: Breakpoint) => `(max-width: ${breakpoints[br] - 0.02}px)`;
62
- // /**
63
- // * It behaves the same as `min`
64
- // * @inheritdoc {max}
65
- // */
66
- // const up = min;
67
- // /**
68
- // * It behaves similarly to `max` but you will use the "next" breakpoint,
69
- // * specifying CSS that will apply from the given breakpoint and down.
70
- // */
71
- // const down = (br: Breakpoint) => {
72
- // const brNext = getNextBreakpoint(br);
73
- // // TODO: if br does not exists otherwise throw Error
74
- // return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
75
- // };
76
- // /**
77
- // * Media query between the two given breakpoints
78
- // */
79
- // const between = (br1: Breakpoint, br2?: Breakpoint) => {
80
- // return br2
81
- // ? `(min-width: ${breakpoints[br1]}px) and (max-width: ${
82
- // breakpoints[br2] - 0.02
83
- // }px)`
84
- // : min(br1);
85
- // };
86
- // /**
87
- // * Media query to apply from the given breakpoint until the next, just for its
88
- // * full range
89
- // */
90
- // const only = (br: Breakpoint) => {
91
- // const brNext = getNextBreakpoint(br);
92
- // return brNext ? between(br, brNext) : min(br);
93
- // };
94
- // const queryResolvers = {
95
- // max,
96
- // min,
97
- // down,
98
- // up,
99
- // between,
100
- // only,
101
- // };
102
- // export function useMqWidth(media: MediaQuery) {
103
- // const [rule = "min", ruleBreakpoint] = media.split(":") as Split<
104
- // MediaQuery,
105
- // ":"
106
- // >;
107
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
108
- // typeof ruleBreakpoint,
109
- // "-"
110
- // >;
111
- // const query = queryResolvers[rule](br1, br2);
112
- // const mq = useMemo(
113
- // () => (isBrowser ? window.matchMedia(query) : { matches: false }),
114
- // [query]
115
- // );
116
- // const [matches, setMatches] = useState(mq.matches);
117
- // useIsomorphicLayoutEffect(() => {
118
- // const mq = window.matchMedia(query);
119
- // const handleChange = (event: MediaQueryListEvent) => {
120
- // setMatches(event.matches);
121
- // };
122
- // setMatches(mq.matches);
123
- // // Safari < 14 can't use addEventListener on a MediaQueryList
124
- // // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
125
- // if (!mq.addEventListener) {
126
- // // Update the state whenever the media query match state changes
127
- // mq.addListener(handleChange);
128
- // // Clean up on unmount and if the query changes
129
- // return () => {
130
- // mq.removeListener(handleChange);
131
- // };
132
- // }
133
- // mq.addEventListener("change", handleChange);
134
- // return () => {
135
- // mq.removeEventListener("change", handleChange);
136
- // };
137
- // }, [query]);
138
- // return matches;
139
- // }
140
- ;
141
- }
142
- });
143
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
144
- const _react = require("react");
145
- const _getMediaQueryWidthResolvers = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/getMediaQueryWidthResolvers"));
146
- const _isUndefined = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isUndefined"));
147
- const _useIsomorphicLayoutEffect = /*#__PURE__*/ _interop_require_default._(require("../hooks/useIsomorphicLayoutEffect"));
148
- function createUseMediaQueryWidth(customBreakpoints) {
149
- const queryResolvers = (0, _getMediaQueryWidthResolvers.default)(customBreakpoints);
150
- return function useMediaQueryWidth(media, serverValue) {
151
- const definition = media.substring(1);
152
- let [rule, ruleBreakpoint] = definition.split("-");
153
- if ((0, _isUndefined.default)(ruleBreakpoint)) {
154
- ruleBreakpoint = rule;
155
- }
156
- if ((0, _isUndefined.default)(rule)) {
157
- rule = "min";
158
- }
159
- // with the hook creator approach these breakpoint types cannot be deduced
160
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
161
- // typeof ruleBreakpoint,
162
- // "-"
163
- // >;
164
- const [br1, br2] = ruleBreakpoint.split("_");
165
- const query = queryResolvers[rule](br1, br2);
166
- const [matches, setMatches] = (0, _react.useState)((0, _isUndefined.default)(serverValue) ? null : serverValue);
167
- (0, _useIsomorphicLayoutEffect.default)(()=>{
168
- const mq = window.matchMedia(query);
169
- const handleChange = (event)=>{
170
- setMatches(event.matches);
171
- };
172
- setMatches(mq.matches);
173
- // Safari < 14 can't use addEventListener on a MediaQueryList
174
- // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
175
- if (!mq.addEventListener) {
176
- // Update the state whenever the media query match state changes
177
- mq.addListener(handleChange);
178
- // Clean up on unmount and if the query changes
179
- return ()=>{
180
- mq.removeListener(handleChange);
181
- };
182
- }
183
- mq.addEventListener("change", handleChange);
184
- return ()=>{
185
- mq.removeEventListener("change", handleChange);
186
- };
187
- }, [
188
- query
189
- ]);
190
- return matches;
191
- };
192
- }
193
- const _default = createUseMediaQueryWidth;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- extendComponent: function() {
13
- return extendComponent;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
- const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
21
- const extendComponent = (component, defaultProps)=>{
22
- // FIXME: check if we need to forwardRef or not
23
- const NewComponent = (props)=>(0, _react.createElement)(component, props);
24
- // const NewComponent = forwardRef<React.ComponentProps<Component>, Component>(
25
- // (props, ref) => createElement(component, { ...props, ref })
26
- // );
27
- return Object.assign(NewComponent, {
28
- ...defaultProps,
29
- defaultProps
30
- });
31
- };
32
- const _default = extendComponent;
package/helpers/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./classed"), exports);
7
- _export_star._(require("./createUseMediaQueryWidth"), exports);
8
- _export_star._(require("./extend-component"), exports);
9
- _export_star._(require("./mergeRefs"), exports);
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- mergeRefs: function() {
13
- return mergeRefs;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- function mergeRefs(refs) {
20
- return (value)=>{
21
- refs.forEach((ref)=>{
22
- if (typeof ref === "function") {
23
- ref(value);
24
- } else if (ref != null) {
25
- ref.current = value;
26
- }
27
- });
28
- };
29
- }
30
- const _default = mergeRefs;
package/hooks/index.js DELETED
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- useAsyncFn: function() {
13
- return _useAsyncFn.useAsyncFn;
14
- },
15
- useDateLocale: function() {
16
- return _useDateLocale.useDateLocale;
17
- },
18
- useFirstMountState: function() {
19
- return _useFirstMountState.useFirstMountState;
20
- },
21
- useFixedOffset: function() {
22
- return _useFixedOffset.useFixedOffset;
23
- },
24
- useFocus: function() {
25
- return _useFocus.useFocus;
26
- },
27
- useInterval: function() {
28
- return _useInterval.useInterval;
29
- },
30
- useIsomorphicLayoutEffect: function() {
31
- return _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect;
32
- },
33
- useKeyUp: function() {
34
- return _useKeyUp.useKeyUp;
35
- },
36
- useMeasure: function() {
37
- return _useMeasure.useMeasure;
38
- },
39
- useMountedState: function() {
40
- return _useMountedState.useMountedState;
41
- },
42
- useNavigateAway: function() {
43
- return _useNavigateAway.useNavigateAway;
44
- },
45
- usePrevious: function() {
46
- return _usePrevious.usePrevious;
47
- },
48
- usePreviousRef: function() {
49
- return _usePreviousRef.usePreviousRef;
50
- },
51
- useScrollPosition: function() {
52
- return _useScrollPosition.useScrollPosition;
53
- },
54
- useScrollThreshold: function() {
55
- return _useScrollThreshold.useScrollThreshold;
56
- },
57
- useSmoothScroll: function() {
58
- return _useSmoothScroll.useSmoothScroll;
59
- },
60
- useSpinDelay: function() {
61
- return _useSpinDelay.useSpinDelay;
62
- },
63
- useTraceUpdate: function() {
64
- return _useTraceUpdate.useTraceUpdate;
65
- },
66
- useUpdateEffect: function() {
67
- return _useUpdateEffect.useUpdateEffect;
68
- },
69
- useWindowSize: function() {
70
- return _useWindowSize.useWindowSize;
71
- }
72
- });
73
- const _useAsyncFn = require("./useAsyncFn");
74
- const _useDateLocale = require("./useDateLocale");
75
- const _useFirstMountState = require("./useFirstMountState");
76
- const _useFixedOffset = require("./useFixedOffset");
77
- const _useFocus = require("./useFocus");
78
- const _useInterval = require("./useInterval");
79
- const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
80
- const _useKeyUp = require("./useKeyUp");
81
- const _useMeasure = require("./useMeasure");
82
- const _useMountedState = require("./useMountedState");
83
- const _useNavigateAway = require("./useNavigateAway");
84
- const _usePrevious = require("./usePrevious");
85
- const _usePreviousRef = require("./usePreviousRef");
86
- const _useScrollPosition = require("./useScrollPosition");
87
- const _useScrollThreshold = require("./useScrollThreshold");
88
- const _useSmoothScroll = require("./useSmoothScroll");
89
- const _useSpinDelay = require("./useSpinDelay");
90
- const _useTraceUpdate = require("./useTraceUpdate");
91
- const _useUpdateEffect = require("./useUpdateEffect");
92
- const _useWindowSize = require("./useWindowSize");
package/hooks/types.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/misc/types.ts)
3
- */ "use strict";
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- useAsyncFn: function() {
13
- return useAsyncFn;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
- const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
21
- const _useMountedState = require("./useMountedState");
22
- function useAsyncFn(fn, deps = [], initialState = {
23
- loading: false
24
- }) {
25
- const lastCallId = (0, _react.useRef)(0);
26
- const isMounted = (0, _useMountedState.useMountedState)();
27
- const [state, set] = (0, _react.useState)(initialState);
28
- const callback = (0, _react.useCallback)((...args)=>{
29
- const callId = ++lastCallId.current;
30
- if (!state.loading) {
31
- set((prevState)=>({
32
- ...prevState,
33
- loading: true
34
- }));
35
- }
36
- return fn(...args).then((value)=>{
37
- isMounted() && callId === lastCallId.current && set({
38
- value,
39
- loading: false
40
- });
41
- return value;
42
- }, (error)=>{
43
- isMounted() && callId === lastCallId.current && set({
44
- error,
45
- loading: false
46
- });
47
- return error;
48
- });
49
- // eslint-disable-next-line react-hooks/exhaustive-deps
50
- }, deps);
51
- return [
52
- state,
53
- callback
54
- ];
55
- }
56
- const _default = useAsyncFn;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- useDateLocale: function() {
13
- return useDateLocale;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
- const _react = require("react");
21
- function useDateLocale(locale, defaultLocale = "en") {
22
- const [data, setData] = (0, _react.useState)();
23
- const [current, setCurrent] = (0, _react.useState)(defaultLocale);
24
- // const [ready, setReady] = useState(false);
25
- // If the user changes the locale listen to the change and import the locale that is now required.
26
- (0, _react.useEffect)(()=>{
27
- const importLocaleFile = async ()=>{
28
- // This webpack option stops all of the date-fns files being imported and chunked.
29
- // NB: this makes unnecessary numerous webpack chunks in applications
30
- // that do not even use this hook, so we comment out the webpack dynamic
31
- // import and its magic comment
32
- // const localeToSet = await import(
33
- // /FIXME: * webpackMode: "lazy", webpackChunkName: "df-[index]", webpackExclude: /_lib/ */
34
- // `date-fns/locale/${locale}/index.js`,
35
- // );
36
- const localeToSet = await Promise.resolve(`date-fns/locale/en-US/index.js`).then((p)=>/*#__PURE__*/ _interop_require_wildcard._(require(p)));
37
- setCurrent(locale || current);
38
- setData(localeToSet.default);
39
- // setReady(true);
40
- };
41
- // If the locale has not yet been loaded.
42
- if (locale !== current) {
43
- importLocaleFile();
44
- }
45
- }, [
46
- locale,
47
- current
48
- ]);
49
- return data;
50
- }
51
- const _default = useDateLocale;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- useFirstMountState: function() {
13
- return useFirstMountState;
14
- },
15
- default: function() {
16
- return _default;
17
- }
18
- });
19
- const _react = require("react");
20
- function useFirstMountState() {
21
- const isFirst = (0, _react.useRef)(true);
22
- if (isFirst.current) {
23
- isFirst.current = false;
24
- return true;
25
- }
26
- return isFirst.current;
27
- }
28
- const _default = useFirstMountState;