@regardio/react 0.5.5 → 0.6.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 (182) hide show
  1. package/dist/background-slideshow/index.d.mts +36 -0
  2. package/dist/background-slideshow/index.mjs +110 -0
  3. package/dist/blurry-gradient/index.d.mts +17 -0
  4. package/dist/blurry-gradient/index.mjs +93 -0
  5. package/dist/button/index.d.mts +2 -0
  6. package/dist/button/index.mjs +3 -0
  7. package/dist/button-BiSQpBbc.mjs +129 -0
  8. package/dist/carousel/index.d.mts +40 -0
  9. package/dist/carousel/index.mjs +141 -0
  10. package/dist/checkbox/index.d.mts +37 -0
  11. package/dist/checkbox/index.mjs +70 -0
  12. package/dist/checkbox-group/index.d.mts +17 -0
  13. package/dist/checkbox-group/index.mjs +29 -0
  14. package/dist/chunk-BTpB_u-K.mjs +18 -0
  15. package/dist/countdown/index.d.mts +6 -0
  16. package/dist/countdown/index.mjs +58 -0
  17. package/dist/field/index.d.mts +66 -0
  18. package/dist/field/index.mjs +115 -0
  19. package/dist/fieldset/index.d.mts +33 -0
  20. package/dist/fieldset/index.mjs +61 -0
  21. package/dist/form/index.d.mts +22 -0
  22. package/dist/form/index.mjs +31 -0
  23. package/dist/generic-error/{index.d.ts → index.d.mts} +22 -18
  24. package/dist/generic-error/index.mjs +57 -0
  25. package/dist/grid/index.d.mts +1197 -0
  26. package/dist/grid/index.mjs +221 -0
  27. package/dist/heading/index.d.mts +31 -0
  28. package/dist/heading/index.mjs +29 -0
  29. package/dist/highlight/index.d.mts +18 -0
  30. package/dist/highlight/index.mjs +35 -0
  31. package/dist/hooks/{use-current-route-data.d.ts → use-current-route-data.d.mts} +3 -2
  32. package/dist/hooks/use-current-route-data.mjs +20 -0
  33. package/dist/hooks/{use-focus-search.d.ts → use-focus-search.d.mts} +4 -3
  34. package/dist/hooks/use-focus-search.mjs +21 -0
  35. package/dist/hooks/{use-matches-data.d.ts → use-matches-data.d.mts} +3 -2
  36. package/dist/hooks/use-matches-data.mjs +21 -0
  37. package/dist/hooks/{use-media-query.d.ts → use-media-query.d.mts} +3 -2
  38. package/dist/hooks/use-media-query.mjs +26 -0
  39. package/dist/hooks/use-mobile.d.mts +4 -0
  40. package/dist/hooks/use-mobile.mjs +20 -0
  41. package/dist/hooks/use-nonce.d.mts +8 -0
  42. package/dist/hooks/use-nonce.mjs +13 -0
  43. package/dist/hooks/{use-orientation.d.ts → use-orientation.d.mts} +3 -2
  44. package/dist/hooks/use-orientation.mjs +30 -0
  45. package/dist/hooks/use-user.d.mts +55 -0
  46. package/dist/hooks/use-user.mjs +39 -0
  47. package/dist/icon-button/index.d.mts +29 -0
  48. package/dist/icon-button/index.mjs +36 -0
  49. package/dist/if/index.d.mts +15 -0
  50. package/dist/if/index.mjs +21 -0
  51. package/dist/iframe/index.d.mts +11 -0
  52. package/dist/iframe/index.mjs +15 -0
  53. package/dist/index-Bm-tWhsb.d.mts +30 -0
  54. package/dist/index-YT2CkvL6.d.mts +36 -0
  55. package/dist/input/index.d.mts +2 -0
  56. package/dist/input/index.mjs +3 -0
  57. package/dist/input-CtR6aRVi.mjs +73 -0
  58. package/dist/link/index.d.mts +73 -0
  59. package/dist/link/index.mjs +129 -0
  60. package/dist/list/index.d.mts +71 -0
  61. package/dist/list/index.mjs +54 -0
  62. package/dist/markdown-container/index.d.mts +23 -0
  63. package/dist/markdown-container/index.mjs +71 -0
  64. package/dist/password-input/index.d.mts +24 -0
  65. package/dist/password-input/index.mjs +92 -0
  66. package/dist/picture/{index.d.ts → index.d.mts} +21 -20
  67. package/dist/picture/index.mjs +3 -0
  68. package/dist/picture-DkX3W5zl.mjs +69 -0
  69. package/dist/protected-email/{index.d.ts → index.d.mts} +14 -8
  70. package/dist/protected-email/index.mjs +37 -0
  71. package/dist/radio/index.d.mts +37 -0
  72. package/dist/radio/index.mjs +72 -0
  73. package/dist/radio-group/index.d.mts +17 -0
  74. package/dist/radio-group/index.mjs +29 -0
  75. package/dist/slider/index.d.mts +85 -0
  76. package/dist/slider/index.mjs +133 -0
  77. package/dist/switch/index.d.mts +38 -0
  78. package/dist/switch/index.mjs +87 -0
  79. package/dist/text/index.d.mts +26 -0
  80. package/dist/text/index.mjs +32 -0
  81. package/dist/text-CPlUND-Z.mjs +58 -0
  82. package/dist/toggle/index.d.mts +59 -0
  83. package/dist/toggle/index.mjs +82 -0
  84. package/dist/utils/author/index.d.mts +4 -0
  85. package/dist/utils/author/index.mjs +26 -0
  86. package/dist/utils/text/{index.d.ts → index.d.mts} +4 -3
  87. package/dist/utils/text/index.mjs +3 -0
  88. package/package.json +17 -129
  89. package/src/button/button.stories.tsx +161 -0
  90. package/src/button/button.test.tsx +73 -0
  91. package/src/button/button.tsx +112 -0
  92. package/src/button/index.ts +2 -0
  93. package/src/carousel/carousel-next.tsx +2 -2
  94. package/src/carousel/carousel-previous.tsx +2 -2
  95. package/src/checkbox/checkbox.stories.tsx +118 -0
  96. package/src/checkbox/checkbox.tsx +91 -0
  97. package/src/checkbox/index.ts +2 -0
  98. package/src/checkbox-group/checkbox-group.tsx +40 -0
  99. package/src/checkbox-group/index.ts +2 -0
  100. package/src/field/field.stories.tsx +105 -0
  101. package/src/field/field.test.tsx +61 -0
  102. package/src/field/field.tsx +165 -0
  103. package/src/field/index.ts +12 -0
  104. package/src/fieldset/fieldset.stories.tsx +204 -0
  105. package/src/fieldset/fieldset.test.tsx +63 -0
  106. package/src/fieldset/fieldset.tsx +75 -0
  107. package/src/fieldset/index.ts +7 -0
  108. package/src/form/form.stories.tsx +230 -0
  109. package/src/form/form.test.tsx +68 -0
  110. package/src/form/form.tsx +38 -0
  111. package/src/form/index.ts +2 -0
  112. package/src/icon-button/icon-button.stories.tsx +128 -7
  113. package/src/icon-button/icon-button.test.tsx +152 -0
  114. package/src/icon-button/icon-button.tsx +43 -9
  115. package/src/input/index.ts +2 -0
  116. package/src/input/input.stories.tsx +151 -0
  117. package/src/input/input.test.tsx +65 -0
  118. package/src/input/input.tsx +113 -0
  119. package/src/link/link.test.tsx +169 -0
  120. package/src/password-input/index.ts +1 -1
  121. package/src/password-input/password-input.tsx +104 -27
  122. package/src/radio/index.ts +2 -0
  123. package/src/radio/radio.tsx +92 -0
  124. package/src/radio-group/index.ts +2 -0
  125. package/src/radio-group/radio-group.tsx +36 -0
  126. package/src/slider/index.ts +18 -0
  127. package/src/slider/slider.tsx +179 -0
  128. package/src/switch/index.ts +2 -0
  129. package/src/switch/switch.stories.tsx +118 -0
  130. package/src/switch/switch.tsx +101 -0
  131. package/src/toggle/index.ts +2 -0
  132. package/src/toggle/toggle.stories.tsx +232 -0
  133. package/src/toggle/toggle.test.tsx +149 -0
  134. package/src/toggle/toggle.tsx +88 -0
  135. package/src/utils/text/text.test.tsx +110 -0
  136. package/dist/background-slideshow/index.d.ts +0 -24
  137. package/dist/background-slideshow/index.js +0 -165
  138. package/dist/blurry-gradient/index.d.ts +0 -16
  139. package/dist/blurry-gradient/index.js +0 -128
  140. package/dist/carousel/index.d.ts +0 -36
  141. package/dist/carousel/index.js +0 -171
  142. package/dist/countdown/index.d.ts +0 -5
  143. package/dist/countdown/index.js +0 -73
  144. package/dist/generic-error/index.js +0 -47
  145. package/dist/grid/index.d.ts +0 -1196
  146. package/dist/grid/index.js +0 -239
  147. package/dist/heading/index.d.ts +0 -24
  148. package/dist/heading/index.js +0 -99
  149. package/dist/highlight/index.d.ts +0 -13
  150. package/dist/highlight/index.js +0 -59
  151. package/dist/hooks/use-current-route-data.js +0 -16
  152. package/dist/hooks/use-focus-search.js +0 -19
  153. package/dist/hooks/use-matches-data.js +0 -15
  154. package/dist/hooks/use-media-query.js +0 -20
  155. package/dist/hooks/use-mobile.d.ts +0 -3
  156. package/dist/hooks/use-mobile.js +0 -19
  157. package/dist/hooks/use-nonce.d.ts +0 -7
  158. package/dist/hooks/use-nonce.js +0 -8
  159. package/dist/hooks/use-orientation.js +0 -29
  160. package/dist/hooks/use-user.d.ts +0 -50
  161. package/dist/hooks/use-user.js +0 -25
  162. package/dist/icon-button/index.d.ts +0 -9
  163. package/dist/icon-button/index.js +0 -17
  164. package/dist/if/index.d.ts +0 -10
  165. package/dist/if/index.js +0 -24
  166. package/dist/iframe/index.d.ts +0 -10
  167. package/dist/iframe/index.js +0 -17
  168. package/dist/link/index.d.ts +0 -55
  169. package/dist/link/index.js +0 -195
  170. package/dist/list/index.d.ts +0 -69
  171. package/dist/list/index.js +0 -65
  172. package/dist/markdown-container/index.d.ts +0 -22
  173. package/dist/markdown-container/index.js +0 -128
  174. package/dist/password-input/index.d.ts +0 -11
  175. package/dist/password-input/index.js +0 -46
  176. package/dist/picture/index.js +0 -68
  177. package/dist/protected-email/index.js +0 -30
  178. package/dist/text/index.d.ts +0 -20
  179. package/dist/text/index.js +0 -38
  180. package/dist/utils/author/index.d.ts +0 -3
  181. package/dist/utils/author/index.js +0 -33
  182. package/dist/utils/text/index.js +0 -73
@@ -0,0 +1,221 @@
1
+ import { t as __exportAll } from "../chunk-BTpB_u-K.mjs";
2
+ import { createContext, forwardRef, useContext } from "react";
3
+ import { tv } from "@regardio/tailwind/utils";
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/grid/grid-item.tsx
7
+ const gridItem = tv({
8
+ defaultVariants: { span: 12 },
9
+ slots: { root: ["relative"] },
10
+ variants: {
11
+ end: {
12
+ 1: { root: "col-end-1" },
13
+ 2: { root: "col-end-2" },
14
+ 3: { root: "col-end-3" },
15
+ 4: { root: "col-end-4" },
16
+ 5: { root: "col-end-5" },
17
+ 6: { root: "col-end-6" },
18
+ 7: { root: "col-end-7" },
19
+ 8: { root: "col-end-8" },
20
+ 9: { root: "col-end-9" },
21
+ 10: { root: "col-end-10" },
22
+ 11: { root: "col-end-11" },
23
+ 12: { root: "col-end-12" },
24
+ 13: { root: "col-end-13" },
25
+ auto: { root: "col-end-auto" }
26
+ },
27
+ rowSpan: {
28
+ 1: { root: "row-span-1" },
29
+ 2: { root: "row-span-2" },
30
+ 3: { root: "row-span-3" },
31
+ 4: { root: "row-span-4" },
32
+ 5: { root: "row-span-5" },
33
+ 6: { root: "row-span-6" },
34
+ full: { root: "row-span-full" }
35
+ },
36
+ span: {
37
+ 1: { root: "col-span-1" },
38
+ 2: { root: "col-span-2" },
39
+ 3: { root: "col-span-3" },
40
+ 4: { root: "col-span-4" },
41
+ 5: { root: "col-span-5" },
42
+ 6: { root: "col-span-6" },
43
+ 7: { root: "col-span-7" },
44
+ 8: { root: "col-span-8" },
45
+ 9: { root: "col-span-9" },
46
+ 10: { root: "col-span-10" },
47
+ 11: { root: "col-span-11" },
48
+ 12: { root: "col-span-12" },
49
+ full: { root: "col-span-full" }
50
+ },
51
+ spanLg: {
52
+ 1: { root: "@lg:col-span-1" },
53
+ 2: { root: "@lg:col-span-2" },
54
+ 3: { root: "@lg:col-span-3" },
55
+ 4: { root: "@lg:col-span-4" },
56
+ 5: { root: "@lg:col-span-5" },
57
+ 6: { root: "@lg:col-span-6" },
58
+ 7: { root: "@lg:col-span-7" },
59
+ 8: { root: "@lg:col-span-8" },
60
+ 9: { root: "@lg:col-span-9" },
61
+ 10: { root: "@lg:col-span-10" },
62
+ 11: { root: "@lg:col-span-11" },
63
+ 12: { root: "@lg:col-span-12" },
64
+ full: { root: "@lg:col-span-full" }
65
+ },
66
+ spanMd: {
67
+ 1: { root: "@md:col-span-1" },
68
+ 2: { root: "@md:col-span-2" },
69
+ 3: { root: "@md:col-span-3" },
70
+ 4: { root: "@md:col-span-4" },
71
+ 5: { root: "@md:col-span-5" },
72
+ 6: { root: "@md:col-span-6" },
73
+ 7: { root: "@md:col-span-7" },
74
+ 8: { root: "@md:col-span-8" },
75
+ 9: { root: "@md:col-span-9" },
76
+ 10: { root: "@md:col-span-10" },
77
+ 11: { root: "@md:col-span-11" },
78
+ 12: { root: "@md:col-span-12" },
79
+ full: { root: "@md:col-span-full" }
80
+ },
81
+ spanSm: {
82
+ 1: { root: "@sm:col-span-1" },
83
+ 2: { root: "@sm:col-span-2" },
84
+ 3: { root: "@sm:col-span-3" },
85
+ 4: { root: "@sm:col-span-4" },
86
+ 5: { root: "@sm:col-span-5" },
87
+ 6: { root: "@sm:col-span-6" },
88
+ 7: { root: "@sm:col-span-7" },
89
+ 8: { root: "@sm:col-span-8" },
90
+ 9: { root: "@sm:col-span-9" },
91
+ 10: { root: "@sm:col-span-10" },
92
+ 11: { root: "@sm:col-span-11" },
93
+ 12: { root: "@sm:col-span-12" },
94
+ full: { root: "@sm:col-span-full" }
95
+ },
96
+ spanXl: {
97
+ 1: { root: "@xl:col-span-1" },
98
+ 2: { root: "@xl:col-span-2" },
99
+ 3: { root: "@xl:col-span-3" },
100
+ 4: { root: "@xl:col-span-4" },
101
+ 5: { root: "@xl:col-span-5" },
102
+ 6: { root: "@xl:col-span-6" },
103
+ 7: { root: "@xl:col-span-7" },
104
+ 8: { root: "@xl:col-span-8" },
105
+ 9: { root: "@xl:col-span-9" },
106
+ 10: { root: "@xl:col-span-10" },
107
+ 11: { root: "@xl:col-span-11" },
108
+ 12: { root: "@xl:col-span-12" },
109
+ full: { root: "@xl:col-span-full" }
110
+ },
111
+ spanXs: {
112
+ 1: { root: "@xs:col-span-1" },
113
+ 2: { root: "@xs:col-span-2" },
114
+ 3: { root: "@xs:col-span-3" },
115
+ 4: { root: "@xs:col-span-4" },
116
+ 5: { root: "@xs:col-span-5" },
117
+ 6: { root: "@xs:col-span-6" },
118
+ 7: { root: "@xs:col-span-7" },
119
+ 8: { root: "@xs:col-span-8" },
120
+ 9: { root: "@xs:col-span-9" },
121
+ 10: { root: "@xs:col-span-10" },
122
+ 11: { root: "@xs:col-span-11" },
123
+ 12: { root: "@xs:col-span-12" },
124
+ full: { root: "@xs:col-span-full" }
125
+ },
126
+ start: {
127
+ 1: { root: "col-start-1" },
128
+ 2: { root: "col-start-2" },
129
+ 3: { root: "col-start-3" },
130
+ 4: { root: "col-start-4" },
131
+ 5: { root: "col-start-5" },
132
+ 6: { root: "col-start-6" },
133
+ 7: { root: "col-start-7" },
134
+ 8: { root: "col-start-8" },
135
+ 9: { root: "col-start-9" },
136
+ 10: { root: "col-start-10" },
137
+ 11: { root: "col-start-11" },
138
+ 12: { root: "col-start-12" },
139
+ 13: { root: "col-start-13" },
140
+ auto: { root: "col-start-auto" }
141
+ }
142
+ }
143
+ });
144
+ const GridItem = forwardRef(({ children, className, classNames, span, spanXs, spanSm, spanMd, spanLg, spanXl, start, end, rowSpan, ...props }, ref) => {
145
+ return /* @__PURE__ */ jsx("div", {
146
+ className: gridItem({
147
+ end,
148
+ rowSpan,
149
+ span,
150
+ spanLg,
151
+ spanMd,
152
+ spanSm,
153
+ spanXl,
154
+ spanXs,
155
+ start
156
+ }).root({ className: classNames?.root ?? className }),
157
+ ref,
158
+ ...props,
159
+ children
160
+ });
161
+ });
162
+ GridItem.displayName = "GridItem";
163
+
164
+ //#endregion
165
+ //#region src/grid/grid-root.tsx
166
+ const grid = tv({
167
+ defaultVariants: { flow: "dense" },
168
+ slots: { root: [
169
+ "u-grid",
170
+ "grid",
171
+ "grid-cols-12",
172
+ "gap-[var(--spacing-grid-gutter)]",
173
+ "w-full",
174
+ "container-[grid]/inline-size"
175
+ ] },
176
+ variants: {
177
+ align: {
178
+ center: { root: "content-center" },
179
+ end: { root: "content-end" },
180
+ start: { root: "content-start" },
181
+ stretch: { root: "content-stretch" }
182
+ },
183
+ flow: {
184
+ column: { root: "grid-auto-flow-col" },
185
+ dense: { root: "grid-auto-flow-dense" },
186
+ row: { root: "grid-auto-flow-row" }
187
+ }
188
+ }
189
+ });
190
+ const GridContext = createContext(null);
191
+ function useGrid() {
192
+ const context = useContext(GridContext);
193
+ if (!context) throw new Error("useGrid must be used within a <Grid.Root />");
194
+ return context;
195
+ }
196
+ const GridRoot = forwardRef(({ children, className, classNames, flow, align, ...props }, ref) => {
197
+ const styles = grid({
198
+ align,
199
+ flow
200
+ });
201
+ return /* @__PURE__ */ jsx(GridContext.Provider, {
202
+ value: { styles },
203
+ children: /* @__PURE__ */ jsx("div", {
204
+ className: styles.root({ className: classNames?.root ?? className }),
205
+ ref,
206
+ ...props,
207
+ children
208
+ })
209
+ });
210
+ });
211
+ GridRoot.displayName = "GridRoot";
212
+
213
+ //#endregion
214
+ //#region src/grid/index.parts.ts
215
+ var index_parts_exports = /* @__PURE__ */ __exportAll({
216
+ Item: () => GridItem,
217
+ Root: () => GridRoot
218
+ });
219
+
220
+ //#endregion
221
+ export { index_parts_exports as Grid, gridItem, useGrid };
@@ -0,0 +1,31 @@
1
+ import { ElementType, HTMLAttributes } from "react";
2
+ import * as react_jsx_runtime52 from "react/jsx-runtime";
3
+
4
+ //#region src/heading/heading.d.ts
5
+ declare const levelVariants: {
6
+ readonly 1: readonly ["text-2xl"];
7
+ readonly 2: readonly ["text-xl"];
8
+ readonly 3: readonly ["text-lg"];
9
+ readonly 4: readonly ["text-md"];
10
+ readonly 5: readonly ["text-sm"];
11
+ readonly 6: readonly ["text-xs"];
12
+ };
13
+ type HeadingLevel = keyof typeof levelVariants;
14
+ interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
15
+ as?: ElementType;
16
+ className?: string;
17
+ level?: HeadingLevel;
18
+ locale?: string;
19
+ }
20
+ declare const Heading: {
21
+ ({
22
+ as,
23
+ children,
24
+ className,
25
+ level,
26
+ ...props
27
+ }: HeadingProps): react_jsx_runtime52.JSX.Element;
28
+ displayName: string;
29
+ };
30
+ //#endregion
31
+ export { Heading, type HeadingLevel, type HeadingProps };
@@ -0,0 +1,29 @@
1
+ import { r as shy, t as lowerCaseSzett } from "../text-CPlUND-Z.mjs";
2
+ import { cn, tv } from "@regardio/tailwind/utils";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/heading/heading.tsx
6
+ const heading = tv({
7
+ base: [],
8
+ defaultVariants: { level: 3 },
9
+ variants: { level: {
10
+ 1: ["text-2xl"],
11
+ 2: ["text-xl"],
12
+ 3: ["text-lg"],
13
+ 4: ["text-md"],
14
+ 5: ["text-sm"],
15
+ 6: ["text-xs"]
16
+ } }
17
+ });
18
+ const Heading = ({ as, children, className, level = 2, ...props }) => {
19
+ const word = lowerCaseSzett(shy(children));
20
+ return /* @__PURE__ */ jsx(as || `h${level}`, {
21
+ className: cn(heading({ level }), className),
22
+ ...props,
23
+ children: word
24
+ });
25
+ };
26
+ Heading.displayName = "Heading";
27
+
28
+ //#endregion
29
+ export { Heading };
@@ -0,0 +1,18 @@
1
+ import { ComponentProps } from "react";
2
+ import * as react_jsx_runtime49 from "react/jsx-runtime";
3
+
4
+ //#region src/highlight/highlight.d.ts
5
+ declare const highlightVariants: {
6
+ readonly primary: readonly ["highlight"];
7
+ };
8
+ type HighlightVariant = keyof typeof highlightVariants;
9
+ interface HighlightProps extends ComponentProps<'mark'> {
10
+ variant?: HighlightVariant;
11
+ }
12
+ declare const Highlight: ({
13
+ children,
14
+ className,
15
+ variant
16
+ }: HighlightProps) => react_jsx_runtime49.JSX.Element;
17
+ //#endregion
18
+ export { Highlight, type HighlightProps };
@@ -0,0 +1,35 @@
1
+ import { tv } from "@regardio/tailwind/utils";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+
4
+ //#region src/highlight/highlight.tsx
5
+ const highlight = tv({
6
+ defaultVariants: { variant: "primary" },
7
+ variants: { variant: { primary: ["highlight"] } }
8
+ });
9
+ const Highlight = ({ children, className, variant }) => {
10
+ return /* @__PURE__ */ jsxs("mark", {
11
+ className: highlight({
12
+ className,
13
+ variant
14
+ }),
15
+ children: [children, /* @__PURE__ */ jsx("svg", {
16
+ "aria-label": "!",
17
+ role: "img",
18
+ children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", { children: [/* @__PURE__ */ jsx("feTurbulence", {
19
+ baseFrequency: "0 0.2",
20
+ numOctaves: "5",
21
+ result: "warp",
22
+ type: "fractalNoise"
23
+ }), /* @__PURE__ */ jsx("feDisplacementMap", {
24
+ in: "SourceGraphic",
25
+ in2: "warp",
26
+ scale: "30",
27
+ xChannelSelector: "R",
28
+ yChannelSelector: "G"
29
+ })] }) })
30
+ })]
31
+ });
32
+ };
33
+
34
+ //#endregion
35
+ export { Highlight };
@@ -1,7 +1,8 @@
1
+ //#region src/hooks/use-current-route-data.d.ts
1
2
  /**
2
3
  * This base hook is used to access data related to the current route
3
4
  * @returns {JSON|undefined} The router data or undefined if not found
4
5
  */
5
6
  declare function useCurrentRouteData<HeaderData>(): {} | HeaderData;
6
-
7
- export { useCurrentRouteData };
7
+ //#endregion
8
+ export { useCurrentRouteData };
@@ -0,0 +1,20 @@
1
+ import { useMemo } from "react";
2
+ import { useLocation, useMatches } from "react-router";
3
+
4
+ //#region src/hooks/use-current-route-data.ts
5
+ /**
6
+ * This base hook is used to access data related to the current route
7
+ * @returns {JSON|undefined} The router data or undefined if not found
8
+ */
9
+ function useCurrentRouteData() {
10
+ const location = useLocation();
11
+ const matchingRoutes = useMatches();
12
+ return useMemo(() => {
13
+ return matchingRoutes.find((route) => {
14
+ return route.pathname === location.pathname;
15
+ });
16
+ }, [matchingRoutes, location])?.data || void 0;
17
+ }
18
+
19
+ //#endregion
20
+ export { useCurrentRouteData };
@@ -1,6 +1,7 @@
1
- import { RefObject } from 'react';
1
+ import { RefObject } from "react";
2
2
 
3
+ //#region src/hooks/use-focus-search.d.ts
3
4
  /** Focuses on the field when user clicks cmd + k or ctrl + k */
4
5
  declare function useFocusSearch(ref: RefObject<HTMLInputElement>): void;
5
-
6
- export { useFocusSearch };
6
+ //#endregion
7
+ export { useFocusSearch };
@@ -0,0 +1,21 @@
1
+ import { useEffect } from "react";
2
+
3
+ //#region src/hooks/use-focus-search.ts
4
+ /** Focuses on the field when user clicks cmd + k or ctrl + k */
5
+ function useFocusSearch(ref) {
6
+ useEffect(() => {
7
+ function handleKeyDown(event) {
8
+ if ((event.metaKey || event.ctrlKey) && event.key === "k") {
9
+ event.preventDefault();
10
+ ref?.current?.focus();
11
+ }
12
+ }
13
+ document.addEventListener("keydown", handleKeyDown);
14
+ return () => {
15
+ document.removeEventListener("keydown", handleKeyDown);
16
+ };
17
+ }, [ref]);
18
+ }
19
+
20
+ //#endregion
21
+ export { useFocusSearch };
@@ -1,3 +1,4 @@
1
+ //#region src/hooks/use-matches-data.d.ts
1
2
  /**
2
3
  * This base hook is used in other hooks to quickly search for specific data
3
4
  * across all loader data using useMatches.
@@ -5,5 +6,5 @@
5
6
  * @returns {JSON|undefined} The router data or undefined if not found
6
7
  */
7
8
  declare function useMatchesData<T>(id: string): T | undefined;
8
-
9
- export { useMatchesData };
9
+ //#endregion
10
+ export { useMatchesData };
@@ -0,0 +1,21 @@
1
+ import { useMemo } from "react";
2
+ import { useMatches } from "react-router";
3
+
4
+ //#region src/hooks/use-matches-data.ts
5
+ /**
6
+ * This base hook is used in other hooks to quickly search for specific data
7
+ * across all loader data using useMatches.
8
+ * @param {string} id The route id
9
+ * @returns {JSON|undefined} The router data or undefined if not found
10
+ */
11
+ function useMatchesData(id) {
12
+ const matchingRoutes = useMatches();
13
+ return useMemo(() => {
14
+ return matchingRoutes.find((route) => {
15
+ return route.id === id;
16
+ });
17
+ }, [matchingRoutes, id])?.data || void 0;
18
+ }
19
+
20
+ //#endregion
21
+ export { useMatchesData };
@@ -1,8 +1,9 @@
1
+ //#region src/hooks/use-media-query.d.ts
1
2
  /**
2
3
  * A hook that returns a boolean indicating whether the current viewport matches the provided media query
3
4
  * @param query The media query to check against (e.g. '(min-width: 768px)')
4
5
  * @returns A boolean indicating whether the media query matches
5
6
  */
6
7
  declare function useMediaQuery(query: string): boolean;
7
-
8
- export { useMediaQuery };
8
+ //#endregion
9
+ export { useMediaQuery };
@@ -0,0 +1,26 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ //#region src/hooks/use-media-query.ts
4
+ /**
5
+ * A hook that returns a boolean indicating whether the current viewport matches the provided media query
6
+ * @param query The media query to check against (e.g. '(min-width: 768px)')
7
+ * @returns A boolean indicating whether the media query matches
8
+ */
9
+ function useMediaQuery(query) {
10
+ const [matches, setMatches] = useState(false);
11
+ useEffect(() => {
12
+ const mediaQuery = window.matchMedia(query);
13
+ setMatches(mediaQuery.matches);
14
+ const handleChange = (event) => {
15
+ setMatches(event.matches);
16
+ };
17
+ mediaQuery.addEventListener("change", handleChange);
18
+ return () => {
19
+ mediaQuery.removeEventListener("change", handleChange);
20
+ };
21
+ }, [query]);
22
+ return matches;
23
+ }
24
+
25
+ //#endregion
26
+ export { useMediaQuery };
@@ -0,0 +1,4 @@
1
+ //#region src/hooks/use-mobile.d.ts
2
+ declare function useIsMobile(): boolean;
3
+ //#endregion
4
+ export { useIsMobile };
@@ -0,0 +1,20 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ //#region src/hooks/use-mobile.ts
4
+ const MOBILE_BREAKPOINT = 768;
5
+ function useIsMobile() {
6
+ const [isMobile, setIsMobile] = useState(void 0);
7
+ useEffect(() => {
8
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
9
+ const onChange = () => {
10
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
11
+ };
12
+ mql.addEventListener("change", onChange);
13
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
14
+ return () => mql.removeEventListener("change", onChange);
15
+ }, []);
16
+ return !!isMobile;
17
+ }
18
+
19
+ //#endregion
20
+ export { useIsMobile };
@@ -0,0 +1,8 @@
1
+ import * as react0 from "react";
2
+
3
+ //#region src/hooks/use-nonce.d.ts
4
+ declare const NonceContext: react0.Context<string>;
5
+ declare const NonceProvider: react0.Provider<string>;
6
+ declare const useNonce: () => string;
7
+ //#endregion
8
+ export { NonceContext, NonceProvider, useNonce };
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ //#region src/hooks/use-nonce.ts
4
+ /**
5
+ * Nonce Provider.
6
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
7
+ */
8
+ const NonceContext = createContext("");
9
+ const NonceProvider = NonceContext.Provider;
10
+ const useNonce = () => useContext(NonceContext);
11
+
12
+ //#endregion
13
+ export { NonceContext, NonceProvider, useNonce };
@@ -1,3 +1,4 @@
1
+ //#region src/hooks/use-orientation.d.ts
1
2
  /**
2
3
  * Orientation type representing device orientation
3
4
  */
@@ -7,5 +8,5 @@ type Orientation = 'portrait' | 'landscape';
7
8
  * @returns The current orientation ('portrait' or 'landscape')
8
9
  */
9
10
  declare function useOrientation(): Orientation;
10
-
11
- export { type Orientation, useOrientation };
11
+ //#endregion
12
+ export { Orientation, useOrientation };
@@ -0,0 +1,30 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ //#region src/hooks/use-orientation.ts
4
+ /**
5
+ * Hook that tracks the current device orientation
6
+ * @returns The current orientation ('portrait' or 'landscape')
7
+ */
8
+ function useOrientation() {
9
+ const [orientation, setOrientation] = useState(() => {
10
+ if (typeof window !== "undefined") return window.innerHeight > window.innerWidth ? "portrait" : "landscape";
11
+ return "portrait";
12
+ });
13
+ useEffect(() => {
14
+ if (typeof window === "undefined") return;
15
+ const handleResize = () => {
16
+ setOrientation(window.innerHeight > window.innerWidth ? "portrait" : "landscape");
17
+ };
18
+ window.addEventListener("resize", handleResize);
19
+ window.addEventListener("orientationchange", handleResize);
20
+ handleResize();
21
+ return () => {
22
+ window.removeEventListener("resize", handleResize);
23
+ window.removeEventListener("orientationchange", handleResize);
24
+ };
25
+ }, []);
26
+ return orientation;
27
+ }
28
+
29
+ //#endregion
30
+ export { useOrientation };
@@ -0,0 +1,55 @@
1
+ import * as react1 from "react";
2
+ import { ReactNode } from "react";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
+ import { User } from "@supabase/supabase-js";
5
+
6
+ //#region src/hooks/use-user.d.ts
7
+ /**
8
+ * Context for storing and accessing the current authenticated user
9
+ */
10
+ interface UserContextType {
11
+ /**
12
+ * The current authenticated user, or null if not authenticated
13
+ */
14
+ user: User | null;
15
+ /**
16
+ * Whether the user data is currently loading
17
+ */
18
+ isLoading: boolean;
19
+ }
20
+ /**
21
+ * Context for storing and accessing the current authenticated user
22
+ */
23
+ declare const UserContext: react1.Context<UserContextType>;
24
+ /**
25
+ * Props for the UserContextProvider component
26
+ */
27
+ interface UserContextProviderProps {
28
+ /**
29
+ * The current authenticated user, or null if not authenticated
30
+ */
31
+ user: User | null;
32
+ /**
33
+ * Whether the user data is currently loading
34
+ */
35
+ isLoading?: boolean;
36
+ /**
37
+ * Child components that will have access to the user context
38
+ */
39
+ children: ReactNode;
40
+ }
41
+ /**
42
+ * Provider component for the UserContext
43
+ */
44
+ declare function UserContextProvider({
45
+ user,
46
+ isLoading,
47
+ children
48
+ }: UserContextProviderProps): react_jsx_runtime0.JSX.Element;
49
+ /**
50
+ * Hook to access the current authenticated user from the UserContext
51
+ * @returns The current user context containing the user object and loading state
52
+ */
53
+ declare function useUser(): UserContextType;
54
+ //#endregion
55
+ export { UserContext, UserContextProvider, UserContextProviderProps, UserContextType, useUser };
@@ -0,0 +1,39 @@
1
+ import { createContext, useContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/hooks/use-user.tsx
5
+ /**
6
+ * Default context value when no provider is present
7
+ */
8
+ const defaultContextValue = {
9
+ isLoading: false,
10
+ user: null
11
+ };
12
+ /**
13
+ * Context for storing and accessing the current authenticated user
14
+ */
15
+ const UserContext = createContext(defaultContextValue);
16
+ /**
17
+ * Provider component for the UserContext
18
+ */
19
+ function UserContextProvider({ user, isLoading = false, children }) {
20
+ return /* @__PURE__ */ jsx(UserContext.Provider, {
21
+ value: {
22
+ isLoading,
23
+ user
24
+ },
25
+ children
26
+ });
27
+ }
28
+ /**
29
+ * Hook to access the current authenticated user from the UserContext
30
+ * @returns The current user context containing the user object and loading state
31
+ */
32
+ function useUser() {
33
+ const context = useContext(UserContext);
34
+ if (context === void 0) throw new Error("useUser must be used within a UserContextProvider");
35
+ return context;
36
+ }
37
+
38
+ //#endregion
39
+ export { UserContext, UserContextProvider, useUser };