@koine/react 1.0.105 → 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
@@ -1,225 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { useState, useEffect, useMemo } from "react";
3
- import { isBrowser } from "@koine/utils";
4
- export function useMqWidthCreator(customBreakpoints) {
5
- var breakpoints = __assign({ xs: 0 }, customBreakpoints);
6
- var sortedBreakpointsNames = Object.keys(breakpoints).map(function (key) {
7
- var br = key;
8
- return [br, breakpoints[br]];
9
- })
10
- .sort(function (a, b) { return a[1] - b[1]; })
11
- .map(function (item) { return item[0]; });
12
- var getNextBreakpoint = function (breakpoint) {
13
- var index = sortedBreakpointsNames.indexOf(breakpoint);
14
- return sortedBreakpointsNames[index + 1];
15
- };
16
- /**
17
- * It behaves the same as `(min-width: ${value}px)`
18
- * where value is the given breakpoint value.
19
- * For ease of use this can be used both as a function `min("md")` and as an
20
- * object literal `min.md`.
21
- */
22
- var min = function (br) { return "(min-width: ".concat(breakpoints[br], "px)"); };
23
- /**
24
- * It behaves the same as `(max-width: ${value}px)`
25
- * where value is the given breakpoint value.
26
- * For ease of use this can be used both as a function `max("md")` and as an
27
- * object literal `max.md`.
28
- */
29
- var max = function (br) { return "(max-width: ".concat(breakpoints[br] - 0.02, "px)"); };
30
- /**
31
- * It behaves the same as `min`
32
- * @inheritdoc {max}
33
- */
34
- var up = min;
35
- /**
36
- * It behaves similarly to `max` but you will use the "next" breakpoint,
37
- * specifying CSS that will apply from the given breakpoint and down.
38
- */
39
- var down = function (br) {
40
- var brNext = getNextBreakpoint(br);
41
- // TODO: if br does not exists otherwise throw Error
42
- return brNext && "(max-width: ".concat(breakpoints[brNext] - 0.02, "px)");
43
- };
44
- /**
45
- * Media query between the two given breakpoints
46
- */
47
- var between = function (br1, br2) {
48
- return br2
49
- ? "(min-width: ".concat(breakpoints[br1], "px) and (max-width: ").concat(breakpoints[br2] - 0.02, "px)")
50
- : min(br1);
51
- };
52
- /**
53
- * Media query to apply from the given breakpoint until the next, just for its
54
- * full range
55
- */
56
- var only = function (br) {
57
- var brNext = getNextBreakpoint(br);
58
- return brNext ? between(br, brNext) : min(br);
59
- };
60
- var queryResolvers = {
61
- max: max,
62
- min: min,
63
- down: down,
64
- up: up,
65
- between: between,
66
- only: only,
67
- };
68
- return function useMqWidth(media) {
69
- var _a = media.split(":"), _b = _a[0], rule = _b === void 0 ? "min" : _b, ruleBreakpoint = _a[1];
70
- // with the hook creator approach these breakpoint types cannot be deduced
71
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
72
- // typeof ruleBreakpoint,
73
- // "-"
74
- // >;
75
- var _c = ruleBreakpoint.split("-"), br1 = _c[0], br2 = _c[1];
76
- var query = queryResolvers[rule](br1, br2);
77
- var mq = useMemo(function () { return (isBrowser ? window.matchMedia(query) : { matches: false }); }, [query]);
78
- var _d = useState(mq.matches), matches = _d[0], setMatches = _d[1];
79
- useEffect(function () {
80
- var mq = window.matchMedia(query);
81
- var handleChange = function (event) {
82
- setMatches(event.matches);
83
- };
84
- setMatches(mq.matches);
85
- // Safari < 14 can't use addEventListener on a MediaQueryList
86
- // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
87
- if (!mq.addEventListener) {
88
- // Update the state whenever the media query match state changes
89
- mq.addListener(handleChange);
90
- // Clean up on unmount and if the query changes
91
- return function () {
92
- mq.removeListener(handleChange);
93
- };
94
- }
95
- mq.addEventListener("change", handleChange);
96
- return function () {
97
- mq.removeEventListener("change", handleChange);
98
- };
99
- }, [query]);
100
- return matches;
101
- };
102
- }
103
- export default useMqWidthCreator;
104
- //// without creator it would be:
105
- //// ---------------------------------------------------------------------------
106
- // import { useState, useEffect, useMemo } from "react";
107
- // import { isBrowser, type Split } from "@koine/utils";
108
- // import { breakpoints as themeBreakpoints } from "@/config/theme/breakpoints";
109
- // type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl";
110
- // type Breakpoints = Record<Breakpoint, number>;
111
- // type MediaQuery =
112
- // | `max:${Breakpoint}`
113
- // | `min:${Breakpoint}`
114
- // | `down:${Breakpoint}`
115
- // | `up:${Breakpoint}`
116
- // | `between:${Breakpoint}-${Breakpoint}`
117
- // | `only:${Breakpoint}`;
118
- // const breakpoints: Breakpoints = {
119
- // xs: 0,
120
- // ...themeBreakpoints,
121
- // };
122
- // const sortedBreakpointsNames = (
123
- // Object.keys(breakpoints).map((key) => {
124
- // const br = key as keyof typeof breakpoints;
125
- // return [br, breakpoints[br]];
126
- // }) as [Breakpoint, number][]
127
- // )
128
- // .sort((a, b) => a[1] - b[1])
129
- // .map((item) => item[0]);
130
- // const getNextBreakpoint = (breakpoint: Breakpoint) => {
131
- // const index = sortedBreakpointsNames.indexOf(breakpoint);
132
- // return sortedBreakpointsNames[index + 1];
133
- // };
134
- // /**
135
- // * It behaves the same as `(min-width: ${value}px)`
136
- // * where value is the given breakpoint value.
137
- // * For ease of use this can be used both as a function `min("md")` and as an
138
- // * object literal `min.md`.
139
- // */
140
- // const min = (br: Breakpoint) => `(min-width: ${breakpoints[br]}px)`;
141
- // /**
142
- // * It behaves the same as `(max-width: ${value}px)`
143
- // * where value is the given breakpoint value.
144
- // * For ease of use this can be used both as a function `max("md")` and as an
145
- // * object literal `max.md`.
146
- // */
147
- // const max = (br: Breakpoint) => `(max-width: ${breakpoints[br] - 0.02}px)`;
148
- // /**
149
- // * It behaves the same as `min`
150
- // * @inheritdoc {max}
151
- // */
152
- // const up = min;
153
- // /**
154
- // * It behaves similarly to `max` but you will use the "next" breakpoint,
155
- // * specifying CSS that will apply from the given breakpoint and down.
156
- // */
157
- // const down = (br: Breakpoint) => {
158
- // const brNext = getNextBreakpoint(br);
159
- // // TODO: if br does not exists otherwise throw Error
160
- // return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
161
- // };
162
- // /**
163
- // * Media query between the two given breakpoints
164
- // */
165
- // const between = (br1: Breakpoint, br2?: Breakpoint) => {
166
- // return br2
167
- // ? `(min-width: ${breakpoints[br1]}px) and (max-width: ${
168
- // breakpoints[br2] - 0.02
169
- // }px)`
170
- // : min(br1);
171
- // };
172
- // /**
173
- // * Media query to apply from the given breakpoint until the next, just for its
174
- // * full range
175
- // */
176
- // const only = (br: Breakpoint) => {
177
- // const brNext = getNextBreakpoint(br);
178
- // return brNext ? between(br, brNext) : min(br);
179
- // };
180
- // const queryResolvers = {
181
- // max,
182
- // min,
183
- // down,
184
- // up,
185
- // between,
186
- // only,
187
- // };
188
- // export function useMqWidth(media: MediaQuery) {
189
- // const [rule = "min", ruleBreakpoint] = media.split(":") as Split<
190
- // MediaQuery,
191
- // ":"
192
- // >;
193
- // const [br1, br2] = ruleBreakpoint.split("-") as Split<
194
- // typeof ruleBreakpoint,
195
- // "-"
196
- // >;
197
- // const query = queryResolvers[rule](br1, br2);
198
- // const mq = useMemo(
199
- // () => (isBrowser ? window.matchMedia(query) : { matches: false }),
200
- // [query]
201
- // );
202
- // const [matches, setMatches] = useState(mq.matches);
203
- // useEffect(() => {
204
- // const mq = window.matchMedia(query);
205
- // const handleChange = (event: MediaQueryListEvent) => {
206
- // setMatches(event.matches);
207
- // };
208
- // setMatches(mq.matches);
209
- // // Safari < 14 can't use addEventListener on a MediaQueryList
210
- // // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#Browser_compatibility
211
- // if (!mq.addEventListener) {
212
- // // Update the state whenever the media query match state changes
213
- // mq.addListener(handleChange);
214
- // // Clean up on unmount and if the query changes
215
- // return () => {
216
- // mq.removeListener(handleChange);
217
- // };
218
- // }
219
- // mq.addEventListener("change", handleChange);
220
- // return () => {
221
- // mq.removeEventListener("change", handleChange);
222
- // };
223
- // }, [query]);
224
- // return matches;
225
- // }
@@ -1,12 +0,0 @@
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;