@sprawlify/react 0.0.6 → 0.0.8

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 (171) hide show
  1. package/dist/chunk-BYnRvbsk.cjs +53 -0
  2. package/dist/{collapsible-DYgHs1_i.mjs → collapsible-Nbt3Sequ.mjs} +7 -4
  3. package/dist/{collapsible-D_cXuaRy.cjs → collapsible-aFKYmVbP.cjs} +13 -9
  4. package/dist/collection-DGEUORi5.cjs +230 -0
  5. package/dist/collection-DQWWySNV.mjs +187 -0
  6. package/dist/components/accordion/index.cjs +21 -24
  7. package/dist/components/accordion/index.d.cts +11 -9
  8. package/dist/components/accordion/index.d.mts +11 -9
  9. package/dist/components/accordion/index.mjs +10 -14
  10. package/dist/components/angle-slider/index.cjs +14 -9
  11. package/dist/components/angle-slider/index.d.cts +13 -11
  12. package/dist/components/angle-slider/index.d.mts +13 -11
  13. package/dist/components/angle-slider/index.mjs +8 -4
  14. package/dist/components/avatar/index.cjs +14 -9
  15. package/dist/components/avatar/index.d.cts +8 -6
  16. package/dist/components/avatar/index.d.mts +8 -6
  17. package/dist/components/avatar/index.mjs +8 -4
  18. package/dist/components/bottom-sheet/index.cjs +216 -0
  19. package/dist/components/bottom-sheet/index.d.cts +80 -0
  20. package/dist/components/bottom-sheet/index.d.mts +81 -0
  21. package/dist/components/bottom-sheet/index.mjs +192 -0
  22. package/dist/components/carousel/index.cjs +265 -0
  23. package/dist/components/carousel/index.d.cts +95 -0
  24. package/dist/components/carousel/index.d.mts +95 -0
  25. package/dist/components/carousel/index.mjs +243 -0
  26. package/dist/components/checkbox/index.cjs +311 -0
  27. package/dist/components/checkbox/index.d.cts +115 -0
  28. package/dist/components/checkbox/index.d.mts +115 -0
  29. package/dist/components/checkbox/index.mjs +291 -0
  30. package/dist/components/client-only/index.cjs +14 -0
  31. package/dist/components/client-only/index.d.cts +8 -0
  32. package/dist/components/client-only/index.d.mts +8 -0
  33. package/dist/components/client-only/index.mjs +13 -0
  34. package/dist/components/clipboard/index.cjs +186 -0
  35. package/dist/components/clipboard/index.d.cts +71 -0
  36. package/dist/components/clipboard/index.d.mts +71 -0
  37. package/dist/components/clipboard/index.mjs +163 -0
  38. package/dist/components/collapsible/index.cjs +8 -3
  39. package/dist/components/collapsible/index.d.cts +10 -8
  40. package/dist/components/collapsible/index.d.mts +10 -8
  41. package/dist/components/collapsible/index.mjs +7 -3
  42. package/dist/components/collection/index.cjs +11 -0
  43. package/dist/components/collection/index.d.cts +2 -0
  44. package/dist/components/collection/index.d.mts +2 -0
  45. package/dist/components/collection/index.mjs +5 -0
  46. package/dist/components/color-picker/index.cjs +617 -0
  47. package/dist/components/color-picker/index.d.cts +181 -0
  48. package/dist/components/color-picker/index.d.mts +182 -0
  49. package/dist/components/color-picker/index.mjs +573 -0
  50. package/dist/components/combobox/index.cjs +420 -0
  51. package/dist/components/combobox/index.d.cts +132 -0
  52. package/dist/components/combobox/index.d.mts +133 -0
  53. package/dist/components/combobox/index.mjs +390 -0
  54. package/dist/components/date-picker/index.cjs +567 -0
  55. package/dist/components/date-picker/index.d.cts +164 -0
  56. package/dist/components/date-picker/index.d.mts +165 -0
  57. package/dist/components/date-picker/index.mjs +526 -0
  58. package/dist/components/dialog/index.cjs +211 -0
  59. package/dist/components/dialog/index.d.cts +80 -0
  60. package/dist/components/dialog/index.d.mts +81 -0
  61. package/dist/components/dialog/index.mjs +187 -0
  62. package/dist/components/download-trigger/index.cjs +43 -0
  63. package/dist/components/download-trigger/index.d.cts +16 -0
  64. package/dist/components/download-trigger/index.d.mts +16 -0
  65. package/dist/components/download-trigger/index.mjs +42 -0
  66. package/dist/components/editable/index.cjs +246 -0
  67. package/dist/components/editable/index.d.cts +79 -0
  68. package/dist/components/editable/index.d.mts +79 -0
  69. package/dist/components/editable/index.mjs +221 -0
  70. package/dist/components/field/index.cjs +29 -0
  71. package/dist/components/field/index.d.cts +116 -0
  72. package/dist/components/field/index.d.mts +116 -0
  73. package/dist/components/field/index.mjs +11 -0
  74. package/dist/components/fieldset/index.cjs +25 -0
  75. package/dist/components/fieldset/index.d.cts +73 -0
  76. package/dist/components/fieldset/index.d.mts +73 -0
  77. package/dist/components/fieldset/index.mjs +11 -0
  78. package/dist/components/file-upload/index.cjs +351 -0
  79. package/dist/components/file-upload/index.d.cts +102 -0
  80. package/dist/components/file-upload/index.d.mts +102 -0
  81. package/dist/components/file-upload/index.mjs +322 -0
  82. package/dist/components/floating-panel/index.cjs +287 -0
  83. package/dist/components/floating-panel/index.d.cts +100 -0
  84. package/dist/components/floating-panel/index.d.mts +101 -0
  85. package/dist/components/floating-panel/index.mjs +259 -0
  86. package/dist/components/focus-trap/index.cjs +36 -0
  87. package/dist/components/focus-trap/index.d.cts +14 -0
  88. package/dist/components/focus-trap/index.d.mts +14 -0
  89. package/dist/components/focus-trap/index.mjs +35 -0
  90. package/dist/components/format/index.cjs +57 -0
  91. package/dist/components/format/index.d.cts +36 -0
  92. package/dist/components/format/index.d.mts +36 -0
  93. package/dist/components/format/index.mjs +49 -0
  94. package/dist/components/frame/index.cjs +90 -0
  95. package/dist/components/frame/index.d.cts +13 -0
  96. package/dist/components/frame/index.d.mts +13 -0
  97. package/dist/components/frame/index.mjs +89 -0
  98. package/dist/components/highlight/index.cjs +32 -0
  99. package/dist/components/highlight/index.d.cts +14 -0
  100. package/dist/components/highlight/index.d.mts +14 -0
  101. package/dist/components/highlight/index.mjs +30 -0
  102. package/dist/components/portal/index.cjs +33 -0
  103. package/dist/components/portal/index.d.cts +11 -0
  104. package/dist/components/portal/index.d.mts +11 -0
  105. package/dist/components/portal/index.mjs +32 -0
  106. package/dist/components/presence/index.cjs +11 -0
  107. package/dist/components/presence/index.d.cts +2 -0
  108. package/dist/components/presence/index.d.mts +4 -0
  109. package/dist/components/presence/index.mjs +7 -0
  110. package/dist/components/select/index.cjs +423 -0
  111. package/dist/components/select/index.d.cts +132 -0
  112. package/dist/components/select/index.d.mts +133 -0
  113. package/dist/components/select/index.mjs +387 -0
  114. package/dist/compose-refs-BEptPEkE.mjs +16 -0
  115. package/dist/compose-refs-C5QNDywq.cjs +22 -0
  116. package/dist/{factory-DN0EdT7u.mjs → core-Ba4IEjhK.mjs} +4 -154
  117. package/dist/{factory-CfqPG186.cjs → core-DCWyxy9D.cjs} +2 -251
  118. package/dist/{create-context-DCEySQ7J.cjs → create-context-CQ4U0lLj.cjs} +1 -1
  119. package/dist/environment-CvilmfQt.cjs +58 -0
  120. package/dist/environment-Ded7DkGr.mjs +46 -0
  121. package/dist/factory-Bi8oEg8i.mjs +49 -0
  122. package/dist/factory-C-EBNsCW.d.mts +15 -0
  123. package/dist/factory-C166evrS.cjs +61 -0
  124. package/dist/factory-C4cfTHs7.d.cts +15 -0
  125. package/dist/field-B-6qoKdn.mjs +324 -0
  126. package/dist/field-C-57Gj2E.cjs +406 -0
  127. package/dist/fieldset-B-MkM2Ms.cjs +239 -0
  128. package/dist/fieldset-gaVneDYh.mjs +186 -0
  129. package/dist/index-BJvW7OpY.d.mts +25 -0
  130. package/dist/index-BhGgEHWc.d.cts +34 -0
  131. package/dist/index-ByIsf4E7.d.mts +74 -0
  132. package/dist/index-Cp1i1zbg.d.mts +34 -0
  133. package/dist/index-CumJbg8V.d.cts +74 -0
  134. package/dist/index.cjs +17 -12
  135. package/dist/index.d.cts +7 -5
  136. package/dist/index.d.mts +7 -5
  137. package/dist/index.mjs +7 -3
  138. package/dist/locale-BcnWD1Hf.cjs +78 -0
  139. package/dist/locale-Coin-d7R.mjs +54 -0
  140. package/dist/normalize-props-skGwa8Dk.d.cts +13 -0
  141. package/dist/presence-Bc6Bxe5i.mjs +72 -0
  142. package/dist/presence-CPov8wyU.cjs +103 -0
  143. package/dist/providers-BNAArubQ.cjs +0 -0
  144. package/dist/providers-Dm2P3F2_.mjs +1 -0
  145. package/dist/render-strategy-BywM_IvB.cjs +30 -0
  146. package/dist/render-strategy-FiPgAp1U.mjs +13 -0
  147. package/dist/types-B4tvWlDb.d.cts +6 -0
  148. package/dist/types-BmBABPZb.d.mts +6 -0
  149. package/dist/use-event-4J5QFFqK.mjs +19 -0
  150. package/dist/use-event-CLH8zHoJ.cjs +25 -0
  151. package/dist/use-fieldset-context-CCQLmNLL.cjs +23 -0
  152. package/dist/use-fieldset-context-LwveT1OS.mjs +12 -0
  153. package/dist/use-safe-layout-effect-C2GgvNT3.cjs +13 -0
  154. package/dist/use-safe-layout-effect-CLjnuJFb.mjs +7 -0
  155. package/dist/utils/index.cjs +3 -3
  156. package/dist/utils/index.d.cts +1 -1
  157. package/dist/utils/index.d.mts +1 -1
  158. package/dist/utils/index.mjs +2 -2
  159. package/package.json +232 -2
  160. package/dist/factory-BZBSaT-0.d.cts +0 -29
  161. package/dist/factory-DaVMAttY.d.mts +0 -41
  162. /package/dist/{chunk-CYMnug_4.mjs → chunk-BXPHTOwk.mjs} +0 -0
  163. /package/dist/{create-context-DGYD_HQt.mjs → create-context-CCXzjEv8.mjs} +0 -0
  164. /package/dist/{create-split-props-BFscidWy.mjs → create-split-props-CBL0m-GX.mjs} +0 -0
  165. /package/dist/{create-split-props-CSaOnJRj.cjs → create-split-props-Dp4TWOyM.cjs} +0 -0
  166. /package/dist/{index-OOf7QNG5.d.mts → index-CureNJdc.d.mts} +0 -0
  167. /package/dist/{index-DiYk6N_L.d.cts → index-dbTyAXLy.d.cts} +0 -0
  168. /package/dist/{render-strategy--1FNKx5x.d.mts → render-strategy-C8IyLw0O.d.mts} +0 -0
  169. /package/dist/{render-strategy-RT-KvAqO.d.cts → render-strategy-rA4C5NUX.d.cts} +0 -0
  170. /package/dist/{utils-Cb5K29pi.cjs → utils-B_Ojepvp.cjs} +0 -0
  171. /package/dist/{utils-nfWHwVIS.mjs → utils-C-m3mZWI.mjs} +0 -0
@@ -0,0 +1,36 @@
1
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
2
+
3
+ //#region src/components/format/format-byte.d.ts
4
+ interface FormatByteProps {
5
+ unit?: "bit" | "byte" | undefined;
6
+ unitDisplay?: "long" | "short" | "narrow" | undefined;
7
+ unitSystem?: "decimal" | "binary" | undefined;
8
+ value: number;
9
+ }
10
+ declare const FormatByte: {
11
+ (props: FormatByteProps): react_jsx_runtime7.JSX.Element;
12
+ displayName: string;
13
+ };
14
+ //#endregion
15
+ //#region src/components/format/format-number.d.ts
16
+ interface FormatNumberProps extends Intl.NumberFormatOptions {
17
+ value: number;
18
+ }
19
+ declare const FormatNumber: {
20
+ (props: FormatNumberProps): react_jsx_runtime7.JSX.Element;
21
+ displayName: string;
22
+ };
23
+ //#endregion
24
+ //#region src/components/format/format-relative-time.d.ts
25
+ interface FormatRelativeTimeProps extends Intl.RelativeTimeFormatOptions {
26
+ value: Date;
27
+ }
28
+ declare const FormatRelativeTime: {
29
+ (props: FormatRelativeTimeProps): react_jsx_runtime7.JSX.Element;
30
+ displayName: string;
31
+ };
32
+ declare namespace format_d_exports {
33
+ export { FormatByte as Byte, FormatByteProps as ByteProps, FormatNumber as Number, FormatNumberProps as NumberProps, FormatRelativeTime as RelativeTime, FormatRelativeTimeProps as RelativeTimeProps };
34
+ }
35
+ //#endregion
36
+ export { format_d_exports as Format, FormatByte, type FormatByteProps, FormatNumber, type FormatNumberProps, FormatRelativeTime, type FormatRelativeTimeProps };
@@ -0,0 +1,36 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+
3
+ //#region src/components/format/format-byte.d.ts
4
+ interface FormatByteProps {
5
+ unit?: "bit" | "byte" | undefined;
6
+ unitDisplay?: "long" | "short" | "narrow" | undefined;
7
+ unitSystem?: "decimal" | "binary" | undefined;
8
+ value: number;
9
+ }
10
+ declare const FormatByte: {
11
+ (props: FormatByteProps): react_jsx_runtime0.JSX.Element;
12
+ displayName: string;
13
+ };
14
+ //#endregion
15
+ //#region src/components/format/format-number.d.ts
16
+ interface FormatNumberProps extends Intl.NumberFormatOptions {
17
+ value: number;
18
+ }
19
+ declare const FormatNumber: {
20
+ (props: FormatNumberProps): react_jsx_runtime0.JSX.Element;
21
+ displayName: string;
22
+ };
23
+ //#endregion
24
+ //#region src/components/format/format-relative-time.d.ts
25
+ interface FormatRelativeTimeProps extends Intl.RelativeTimeFormatOptions {
26
+ value: Date;
27
+ }
28
+ declare const FormatRelativeTime: {
29
+ (props: FormatRelativeTimeProps): react_jsx_runtime0.JSX.Element;
30
+ displayName: string;
31
+ };
32
+ declare namespace format_d_exports {
33
+ export { FormatByte as Byte, FormatByteProps as ByteProps, FormatNumber as Number, FormatNumberProps as NumberProps, FormatRelativeTime as RelativeTime, FormatRelativeTimeProps as RelativeTimeProps };
34
+ }
35
+ //#endregion
36
+ export { format_d_exports as Format, FormatByte, type FormatByteProps, FormatNumber, type FormatNumberProps, FormatRelativeTime, type FormatRelativeTimeProps };
@@ -0,0 +1,49 @@
1
+ import { t as __export } from "../../chunk-BXPHTOwk.mjs";
2
+ import "../../create-context-CCXzjEv8.mjs";
3
+ import { i as useLocaleContext } from "../../locale-Coin-d7R.mjs";
4
+ import { useMemo } from "react";
5
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
6
+ import { formatBytes, formatNumber, formatRelativeTime } from "@sprawlify/primitives/i18n-utils";
7
+
8
+ //#region src/components/format/format-byte.tsx
9
+ const FormatByte = (props) => {
10
+ const { locale } = useLocaleContext();
11
+ return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => {
12
+ const { value, ...intlOptions } = props;
13
+ return formatBytes(value, locale, intlOptions);
14
+ }, [props, locale]) });
15
+ };
16
+ FormatByte.displayName = "FormatByte";
17
+
18
+ //#endregion
19
+ //#region src/components/format/format-number.tsx
20
+ const FormatNumber = (props) => {
21
+ const { locale } = useLocaleContext();
22
+ return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => {
23
+ const { value, ...intlOptions } = props;
24
+ return formatNumber(value, locale, intlOptions);
25
+ }, [props, locale]) });
26
+ };
27
+ FormatNumber.displayName = "FormatNumber";
28
+
29
+ //#endregion
30
+ //#region src/components/format/format-relative-time.tsx
31
+ const FormatRelativeTime = (props) => {
32
+ const { locale } = useLocaleContext();
33
+ return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => {
34
+ const { value, ...intlOptions } = props;
35
+ return formatRelativeTime(value, locale, intlOptions);
36
+ }, [props, locale]) });
37
+ };
38
+ FormatRelativeTime.displayName = "FormatRelativeTime";
39
+
40
+ //#endregion
41
+ //#region src/components/format/format.ts
42
+ var format_exports = /* @__PURE__ */ __export({
43
+ Byte: () => FormatByte,
44
+ Number: () => FormatNumber,
45
+ RelativeTime: () => FormatRelativeTime
46
+ });
47
+
48
+ //#endregion
49
+ export { format_exports as Format, FormatByte, FormatNumber, FormatRelativeTime };
@@ -0,0 +1,90 @@
1
+ const require_chunk = require('../../chunk-BYnRvbsk.cjs');
2
+ require('../../create-context-CQ4U0lLj.cjs');
3
+ const require_environment = require('../../environment-CvilmfQt.cjs');
4
+ require('../../locale-BcnWD1Hf.cjs');
5
+ require('../../providers-BNAArubQ.cjs');
6
+ const require_compose_refs = require('../../compose-refs-C5QNDywq.cjs');
7
+ const require_use_safe_layout_effect = require('../../use-safe-layout-effect-C2GgvNT3.cjs');
8
+ let react = require("react");
9
+ let react_dom = require("react-dom");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+
12
+ //#region src/components/frame/frame-content.tsx
13
+ const FrameContent = (props) => {
14
+ const { onMount, onUnmount, children } = props;
15
+ const mountedRef = (0, react.useRef)(false);
16
+ const calledRef = (0, react.useRef)(false);
17
+ (0, react.useEffect)(() => {
18
+ if (!mountedRef.current && !calledRef.current) {
19
+ onMount?.();
20
+ mountedRef.current = true;
21
+ calledRef.current = true;
22
+ }
23
+ return () => {
24
+ if (mountedRef.current) {
25
+ onUnmount?.();
26
+ mountedRef.current = false;
27
+ }
28
+ };
29
+ }, []);
30
+ return children;
31
+ };
32
+
33
+ //#endregion
34
+ //#region src/components/frame/frame.tsx
35
+ const initialSrcDoc = `<html><head><style>*,*::before,*::after { margin: 0; padding: 0; box-sizing: border-box; }</style></head><body><div class="frame-root"></div></body></html>`;
36
+ function getMountNode(frame) {
37
+ const doc = frame.contentWindow?.document;
38
+ if (!doc) return null;
39
+ return doc.body.querySelector(".frame-root") || doc.body;
40
+ }
41
+ const Frame = (0, react.forwardRef)((props, ref) => {
42
+ const { children, head, onMount, onUnmount, srcDoc = initialSrcDoc, ...rest } = props;
43
+ const [frameRef, setFrameRef] = (0, react.useState)(null);
44
+ const [mountNode, setMountNode] = (0, react.useState)(null);
45
+ require_use_safe_layout_effect.useSafeLayoutEffect(() => {
46
+ if (!frameRef) return;
47
+ const doc = frameRef.contentWindow?.document;
48
+ if (!doc) return;
49
+ doc.open();
50
+ doc.write(srcDoc);
51
+ doc.close();
52
+ setMountNode(getMountNode(frameRef));
53
+ }, [frameRef, srcDoc]);
54
+ (0, react.useEffect)(() => {
55
+ if (!frameRef || !frameRef.contentDocument) return;
56
+ const win = frameRef.contentWindow;
57
+ if (!win) return;
58
+ const mountNode$1 = getMountNode(frameRef);
59
+ if (!mountNode$1) return;
60
+ const exec = () => {
61
+ win.requestAnimationFrame(() => {
62
+ if (!frameRef.contentDocument?.documentElement) return;
63
+ frameRef.style.setProperty("--width", `${mountNode$1.scrollWidth}px`);
64
+ frameRef.style.setProperty("--height", `${mountNode$1.scrollHeight}px`);
65
+ });
66
+ };
67
+ const resizeObserver = new win.ResizeObserver(exec);
68
+ exec();
69
+ if (frameRef.contentDocument) resizeObserver.observe(mountNode$1);
70
+ return () => {
71
+ resizeObserver.disconnect();
72
+ };
73
+ }, [frameRef]);
74
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_environment.EnvironmentProvider, {
75
+ value: () => frameRef?.contentDocument ?? document,
76
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("iframe", {
77
+ title: `frame:${(0, react.useId)()}`,
78
+ ref: require_compose_refs.composeRefs(ref, setFrameRef),
79
+ ...rest,
80
+ children: [mountNode ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FrameContent, {
81
+ onMount,
82
+ onUnmount,
83
+ children
84
+ }), mountNode) : null, head && frameRef ? (0, react_dom.createPortal)(head, frameRef.contentDocument.head) : null]
85
+ })
86
+ });
87
+ });
88
+
89
+ //#endregion
90
+ exports.Frame = Frame;
@@ -0,0 +1,13 @@
1
+ import { t as Assign } from "../../types-B4tvWlDb.cjs";
2
+ import * as react28 from "react";
3
+
4
+ //#region src/components/frame/frame.d.ts
5
+ interface FrameBaseProps {
6
+ head?: React.ReactNode | undefined;
7
+ onMount?: (() => void) | undefined;
8
+ onUnmount?: (() => void) | undefined;
9
+ }
10
+ interface FrameProps extends Assign<React.IframeHTMLAttributes<HTMLIFrameElement>, FrameBaseProps> {}
11
+ declare const Frame: react28.ForwardRefExoticComponent<FrameProps & react28.RefAttributes<HTMLIFrameElement>>;
12
+ //#endregion
13
+ export { Frame, type FrameBaseProps, type FrameProps };
@@ -0,0 +1,13 @@
1
+ import { t as Assign } from "../../types-BmBABPZb.mjs";
2
+ import * as react78 from "react";
3
+
4
+ //#region src/components/frame/frame.d.ts
5
+ interface FrameBaseProps {
6
+ head?: React.ReactNode | undefined;
7
+ onMount?: (() => void) | undefined;
8
+ onUnmount?: (() => void) | undefined;
9
+ }
10
+ interface FrameProps extends Assign<React.IframeHTMLAttributes<HTMLIFrameElement>, FrameBaseProps> {}
11
+ declare const Frame: react78.ForwardRefExoticComponent<FrameProps & react78.RefAttributes<HTMLIFrameElement>>;
12
+ //#endregion
13
+ export { Frame, type FrameBaseProps, type FrameProps };
@@ -0,0 +1,89 @@
1
+ import "../../create-context-CCXzjEv8.mjs";
2
+ import { t as EnvironmentProvider } from "../../environment-Ded7DkGr.mjs";
3
+ import "../../locale-Coin-d7R.mjs";
4
+ import "../../providers-Dm2P3F2_.mjs";
5
+ import { t as composeRefs } from "../../compose-refs-BEptPEkE.mjs";
6
+ import { t as useSafeLayoutEffect } from "../../use-safe-layout-effect-CLjnuJFb.mjs";
7
+ import { forwardRef, useEffect, useId, useRef, useState } from "react";
8
+ import { createPortal } from "react-dom";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+
11
+ //#region src/components/frame/frame-content.tsx
12
+ const FrameContent = (props) => {
13
+ const { onMount, onUnmount, children } = props;
14
+ const mountedRef = useRef(false);
15
+ const calledRef = useRef(false);
16
+ useEffect(() => {
17
+ if (!mountedRef.current && !calledRef.current) {
18
+ onMount?.();
19
+ mountedRef.current = true;
20
+ calledRef.current = true;
21
+ }
22
+ return () => {
23
+ if (mountedRef.current) {
24
+ onUnmount?.();
25
+ mountedRef.current = false;
26
+ }
27
+ };
28
+ }, []);
29
+ return children;
30
+ };
31
+
32
+ //#endregion
33
+ //#region src/components/frame/frame.tsx
34
+ const initialSrcDoc = `<html><head><style>*,*::before,*::after { margin: 0; padding: 0; box-sizing: border-box; }</style></head><body><div class="frame-root"></div></body></html>`;
35
+ function getMountNode(frame) {
36
+ const doc = frame.contentWindow?.document;
37
+ if (!doc) return null;
38
+ return doc.body.querySelector(".frame-root") || doc.body;
39
+ }
40
+ const Frame = forwardRef((props, ref) => {
41
+ const { children, head, onMount, onUnmount, srcDoc = initialSrcDoc, ...rest } = props;
42
+ const [frameRef, setFrameRef] = useState(null);
43
+ const [mountNode, setMountNode] = useState(null);
44
+ useSafeLayoutEffect(() => {
45
+ if (!frameRef) return;
46
+ const doc = frameRef.contentWindow?.document;
47
+ if (!doc) return;
48
+ doc.open();
49
+ doc.write(srcDoc);
50
+ doc.close();
51
+ setMountNode(getMountNode(frameRef));
52
+ }, [frameRef, srcDoc]);
53
+ useEffect(() => {
54
+ if (!frameRef || !frameRef.contentDocument) return;
55
+ const win = frameRef.contentWindow;
56
+ if (!win) return;
57
+ const mountNode$1 = getMountNode(frameRef);
58
+ if (!mountNode$1) return;
59
+ const exec = () => {
60
+ win.requestAnimationFrame(() => {
61
+ if (!frameRef.contentDocument?.documentElement) return;
62
+ frameRef.style.setProperty("--width", `${mountNode$1.scrollWidth}px`);
63
+ frameRef.style.setProperty("--height", `${mountNode$1.scrollHeight}px`);
64
+ });
65
+ };
66
+ const resizeObserver = new win.ResizeObserver(exec);
67
+ exec();
68
+ if (frameRef.contentDocument) resizeObserver.observe(mountNode$1);
69
+ return () => {
70
+ resizeObserver.disconnect();
71
+ };
72
+ }, [frameRef]);
73
+ return /* @__PURE__ */ jsx(EnvironmentProvider, {
74
+ value: () => frameRef?.contentDocument ?? document,
75
+ children: /* @__PURE__ */ jsxs("iframe", {
76
+ title: `frame:${useId()}`,
77
+ ref: composeRefs(ref, setFrameRef),
78
+ ...rest,
79
+ children: [mountNode ? createPortal(/* @__PURE__ */ jsx(FrameContent, {
80
+ onMount,
81
+ onUnmount,
82
+ children
83
+ }), mountNode) : null, head && frameRef ? createPortal(head, frameRef.contentDocument.head) : null]
84
+ })
85
+ });
86
+ });
87
+
88
+ //#endregion
89
+ export { Frame };
@@ -0,0 +1,32 @@
1
+ const require_chunk = require('../../chunk-BYnRvbsk.cjs');
2
+ const require_create_split_props = require('../../create-split-props-Dp4TWOyM.cjs');
3
+ let react = require("react");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ let __sprawlify_primitives_highlight_word = require("@sprawlify/primitives/highlight-word");
6
+
7
+ //#region src/components/highlight/use-highlight.ts
8
+ const useHighlight = (props) => {
9
+ return (0, react.useMemo)(() => (0, __sprawlify_primitives_highlight_word.highlightWord)(props), [props]);
10
+ };
11
+
12
+ //#endregion
13
+ //#region src/components/highlight/highlight.tsx
14
+ const splitHighlightBaseProps = require_create_split_props.createSplitProps();
15
+ const Highlight = (props) => {
16
+ if (typeof props.text !== "string") throw new Error("[sprawlify/highlight] text must be a string");
17
+ const [highlightProps, localProps] = splitHighlightBaseProps(props, [
18
+ "query",
19
+ "text",
20
+ "ignoreCase",
21
+ "matchAll",
22
+ "exactMatch"
23
+ ]);
24
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: useHighlight(highlightProps).map(({ text, match }, i) => match ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("mark", {
25
+ ...localProps,
26
+ children: text
27
+ }, i) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: text }, i)) });
28
+ };
29
+
30
+ //#endregion
31
+ exports.Highlight = Highlight;
32
+ exports.useHighlight = useHighlight;
@@ -0,0 +1,14 @@
1
+ import { t as Assign } from "../../types-B4tvWlDb.cjs";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
+ import { HighlightChunk, HighlightWordProps } from "@sprawlify/primitives/highlight-word";
4
+
5
+ //#region src/components/highlight/use-highlight.d.ts
6
+ interface UseHighlightProps extends HighlightWordProps {}
7
+ declare const useHighlight: (props: UseHighlightProps) => HighlightChunk[];
8
+ //#endregion
9
+ //#region src/components/highlight/highlight.d.ts
10
+ interface HighlightBaseProps extends UseHighlightProps {}
11
+ interface HighlightProps extends Assign<React.ComponentProps<"mark">, HighlightBaseProps> {}
12
+ declare const Highlight: (props: HighlightProps) => react_jsx_runtime2.JSX.Element;
13
+ //#endregion
14
+ export { Highlight, type HighlightChunk, type HighlightProps, type UseHighlightProps, useHighlight };
@@ -0,0 +1,14 @@
1
+ import { t as Assign } from "../../types-BmBABPZb.mjs";
2
+ import * as react_jsx_runtime4 from "react/jsx-runtime";
3
+ import { HighlightChunk, HighlightWordProps } from "@sprawlify/primitives/highlight-word";
4
+
5
+ //#region src/components/highlight/use-highlight.d.ts
6
+ interface UseHighlightProps extends HighlightWordProps {}
7
+ declare const useHighlight: (props: UseHighlightProps) => HighlightChunk[];
8
+ //#endregion
9
+ //#region src/components/highlight/highlight.d.ts
10
+ interface HighlightBaseProps extends UseHighlightProps {}
11
+ interface HighlightProps extends Assign<React.ComponentProps<"mark">, HighlightBaseProps> {}
12
+ declare const Highlight: (props: HighlightProps) => react_jsx_runtime4.JSX.Element;
13
+ //#endregion
14
+ export { Highlight, type HighlightChunk, type HighlightProps, type UseHighlightProps, useHighlight };
@@ -0,0 +1,30 @@
1
+ import { t as createSplitProps } from "../../create-split-props-CBL0m-GX.mjs";
2
+ import { Fragment, useMemo } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { highlightWord } from "@sprawlify/primitives/highlight-word";
5
+
6
+ //#region src/components/highlight/use-highlight.ts
7
+ const useHighlight = (props) => {
8
+ return useMemo(() => highlightWord(props), [props]);
9
+ };
10
+
11
+ //#endregion
12
+ //#region src/components/highlight/highlight.tsx
13
+ const splitHighlightBaseProps = createSplitProps();
14
+ const Highlight = (props) => {
15
+ if (typeof props.text !== "string") throw new Error("[sprawlify/highlight] text must be a string");
16
+ const [highlightProps, localProps] = splitHighlightBaseProps(props, [
17
+ "query",
18
+ "text",
19
+ "ignoreCase",
20
+ "matchAll",
21
+ "exactMatch"
22
+ ]);
23
+ return /* @__PURE__ */ jsx(Fragment, { children: useHighlight(highlightProps).map(({ text, match }, i) => match ? /* @__PURE__ */ jsx("mark", {
24
+ ...localProps,
25
+ children: text
26
+ }, i) : /* @__PURE__ */ jsx(Fragment, { children: text }, i)) });
27
+ };
28
+
29
+ //#endregion
30
+ export { Highlight, useHighlight };
@@ -0,0 +1,33 @@
1
+ const require_chunk = require('../../chunk-BYnRvbsk.cjs');
2
+ require('../../create-context-CQ4U0lLj.cjs');
3
+ const require_environment = require('../../environment-CvilmfQt.cjs');
4
+ require('../../locale-BcnWD1Hf.cjs');
5
+ require('../../providers-BNAArubQ.cjs');
6
+ let react = require("react");
7
+ let react_dom = require("react-dom");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let __sprawlify_primitives_dom_query = require("@sprawlify/primitives/dom-query");
10
+
11
+ //#region src/components/portal/portal.tsx
12
+ const Portal = (props) => {
13
+ const { children, disabled } = props;
14
+ const [container, setContainer] = (0, react.useState)(props.container?.current);
15
+ const isServer = (0, react.useSyncExternalStore)(subscribe, () => false, () => true);
16
+ const { getRootNode } = require_environment.useEnvironmentContext();
17
+ (0, react.useEffect)(() => {
18
+ setContainer(() => props.container?.current);
19
+ }, [props.container]);
20
+ if (isServer || disabled) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
21
+ const mountNode = container ?? getPortalNode(getRootNode);
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: react.Children.map(children, (child) => (0, react_dom.createPortal)(child, mountNode)) });
23
+ };
24
+ const getPortalNode = (cb) => {
25
+ const node = cb?.();
26
+ const rootNode = node.getRootNode();
27
+ if ((0, __sprawlify_primitives_dom_query.isShadowRoot)(rootNode)) return rootNode;
28
+ return (0, __sprawlify_primitives_dom_query.getDocument)(node).body;
29
+ };
30
+ const subscribe = () => () => {};
31
+
32
+ //#endregion
33
+ exports.Portal = Portal;
@@ -0,0 +1,11 @@
1
+ import { PropsWithChildren, RefObject } from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/components/portal/portal.d.ts
5
+ interface PortalProps {
6
+ disabled?: boolean | undefined;
7
+ container?: RefObject<HTMLElement | null> | undefined;
8
+ }
9
+ declare const Portal: (props: PropsWithChildren<PortalProps>) => react_jsx_runtime0.JSX.Element;
10
+ //#endregion
11
+ export { Portal, type PortalProps };
@@ -0,0 +1,11 @@
1
+ import { PropsWithChildren, RefObject } from "react";
2
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
3
+
4
+ //#region src/components/portal/portal.d.ts
5
+ interface PortalProps {
6
+ disabled?: boolean | undefined;
7
+ container?: RefObject<HTMLElement | null> | undefined;
8
+ }
9
+ declare const Portal: (props: PropsWithChildren<PortalProps>) => react_jsx_runtime5.JSX.Element;
10
+ //#endregion
11
+ export { Portal, type PortalProps };
@@ -0,0 +1,32 @@
1
+ import "../../create-context-CCXzjEv8.mjs";
2
+ import { n as useEnvironmentContext } from "../../environment-Ded7DkGr.mjs";
3
+ import "../../locale-Coin-d7R.mjs";
4
+ import "../../providers-Dm2P3F2_.mjs";
5
+ import { Children, useEffect, useState, useSyncExternalStore } from "react";
6
+ import { createPortal } from "react-dom";
7
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
8
+ import { getDocument, isShadowRoot } from "@sprawlify/primitives/dom-query";
9
+
10
+ //#region src/components/portal/portal.tsx
11
+ const Portal = (props) => {
12
+ const { children, disabled } = props;
13
+ const [container, setContainer] = useState(props.container?.current);
14
+ const isServer = useSyncExternalStore(subscribe, () => false, () => true);
15
+ const { getRootNode } = useEnvironmentContext();
16
+ useEffect(() => {
17
+ setContainer(() => props.container?.current);
18
+ }, [props.container]);
19
+ if (isServer || disabled) return /* @__PURE__ */ jsx(Fragment$1, { children });
20
+ const mountNode = container ?? getPortalNode(getRootNode);
21
+ return /* @__PURE__ */ jsx(Fragment$1, { children: Children.map(children, (child) => createPortal(child, mountNode)) });
22
+ };
23
+ const getPortalNode = (cb) => {
24
+ const node = cb?.();
25
+ const rootNode = node.getRootNode();
26
+ if (isShadowRoot(rootNode)) return rootNode;
27
+ return getDocument(node).body;
28
+ };
29
+ const subscribe = () => () => {};
30
+
31
+ //#endregion
32
+ export { Portal };
@@ -0,0 +1,11 @@
1
+ require('../../core-DCWyxy9D.cjs');
2
+ require('../../create-context-CQ4U0lLj.cjs');
3
+ require('../../factory-C166evrS.cjs');
4
+ const require_presence = require('../../presence-CPov8wyU.cjs');
5
+ require('../../use-event-CLH8zHoJ.cjs');
6
+
7
+ exports.Presence = require_presence.Presence;
8
+ exports.PresenceProvider = require_presence.PresenceProvider;
9
+ exports.splitPresenceProps = require_presence.splitPresenceProps;
10
+ exports.usePresence = require_presence.usePresence;
11
+ exports.usePresenceContext = require_presence.usePresenceContext;
@@ -0,0 +1,2 @@
1
+ import { a as Presence, c as UsePresenceProps, i as splitPresenceProps, l as UsePresenceReturn, n as UsePresenceContext, o as PresenceBaseProps, r as usePresenceContext, s as PresenceProps, t as PresenceProvider, u as usePresence } from "../../index-BhGgEHWc.cjs";
2
+ export { Presence, PresenceBaseProps, PresenceProps, PresenceProvider, UsePresenceContext, UsePresenceProps, UsePresenceReturn, splitPresenceProps, usePresence, usePresenceContext };
@@ -0,0 +1,4 @@
1
+ import "../../factory-C-EBNsCW.mjs";
2
+ import "../../render-strategy-C8IyLw0O.mjs";
3
+ import { a as Presence, c as UsePresenceProps, i as splitPresenceProps, l as UsePresenceReturn, n as UsePresenceContext, o as PresenceBaseProps, r as usePresenceContext, s as PresenceProps, t as PresenceProvider, u as usePresence } from "../../index-Cp1i1zbg.mjs";
4
+ export { Presence, PresenceBaseProps, PresenceProps, PresenceProvider, UsePresenceContext, UsePresenceProps, UsePresenceReturn, splitPresenceProps, usePresence, usePresenceContext };
@@ -0,0 +1,7 @@
1
+ import "../../core-Ba4IEjhK.mjs";
2
+ import "../../create-context-CCXzjEv8.mjs";
3
+ import "../../factory-Bi8oEg8i.mjs";
4
+ import { a as splitPresenceProps, i as usePresence, n as usePresenceContext, r as Presence, t as PresenceProvider } from "../../presence-Bc6Bxe5i.mjs";
5
+ import "../../use-event-4J5QFFqK.mjs";
6
+
7
+ export { Presence, PresenceProvider, splitPresenceProps, usePresence, usePresenceContext };