@levo-so/react 0.0.1-alpha → 0.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 (211) hide show
  1. package/dist/Checbox-sq-atGlJ.js +28 -0
  2. package/dist/CheckboxWidget-CD4lv7B4.js +118 -0
  3. package/dist/CollectionFormBuilder-a0pzMkWL.js +734 -0
  4. package/dist/CurrencyWidget-DRMqUgbP.js +60 -0
  5. package/dist/DateTimeWidget-FmBvE_lk.js +103 -0
  6. package/dist/DefaultFormVariant-BzHB74Ie.js +80 -0
  7. package/dist/DropdownWidget-CW0GSjwE.js +115 -0
  8. package/dist/EmailWidget-Nyc76pT8.js +42 -0
  9. package/dist/GeocoderWidget-Ib15NJcx.js +309 -0
  10. package/dist/Input-2CvZ90f8.js +54 -0
  11. package/dist/LevoProvider-DNbYyEaf.js +21 -0
  12. package/dist/MultiGeocoderWidget-BuW8i48_.js +49 -0
  13. package/dist/PhoneWidget-COo3SBNU.js +47 -0
  14. package/dist/RadioWidget-C8syq1dO.js +109 -0
  15. package/dist/RichTextWidget-B5qxi5OE.js +309 -0
  16. package/dist/Sonner-t6JVKA0a.js +39 -0
  17. package/dist/Spinner-CuUosd-S.js +297 -0
  18. package/dist/StepsFormVariant-NSTSIoVV.js +137 -0
  19. package/dist/SwitchWidget-C-p7lICr.js +53 -0
  20. package/dist/TextWidget-BtZp3DRk.js +34 -0
  21. package/dist/TextareaWidget-D0TbFUjX.js +30 -0
  22. package/dist/ToggleCheckboxWidget-BbVq_dAC.js +44 -0
  23. package/dist/Tooltip-CI4i4mYr.js +144 -0
  24. package/dist/URLWidget-00u8Svwt.js +14 -0
  25. package/dist/UploadWidget-Dim2TEFc.js +503 -0
  26. package/dist/audience/{block.d.ts → components/block.d.ts} +1 -1
  27. package/dist/audience/components/block.d.ts.map +1 -0
  28. package/dist/audience/{component.d.ts → components/component.d.ts} +1 -1
  29. package/dist/audience/components/component.d.ts.map +1 -0
  30. package/dist/audience/{page.d.ts → components/page.d.ts} +1 -1
  31. package/dist/audience/components/page.d.ts.map +1 -0
  32. package/dist/audience/components/useScrollDepth.d.ts.map +1 -0
  33. package/dist/audience/index.d.ts +3 -3
  34. package/dist/audience/index.d.ts.map +1 -0
  35. package/dist/audience/index.js +4 -2303
  36. package/dist/byteToSize-BFKZSBu1.js +8 -0
  37. package/dist/cn-C9QoOYNG.js +6 -0
  38. package/dist/collection/components/CollectionFormBuilder.d.ts +12 -0
  39. package/dist/collection/components/CollectionFormBuilder.d.ts.map +1 -0
  40. package/dist/collection/components/FieldRenderer.d.ts +9 -0
  41. package/dist/collection/components/FieldRenderer.d.ts.map +1 -0
  42. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts +5 -0
  43. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -0
  44. package/dist/collection/components/core/Checkbox/Checbox.d.ts +5 -0
  45. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -0
  46. package/dist/collection/components/core/Input/Input.d.ts +11 -0
  47. package/dist/collection/components/core/Input/Input.d.ts.map +1 -0
  48. package/dist/collection/components/core/Switch/Switch.d.ts +5 -0
  49. package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -0
  50. package/dist/collection/components/renderer/RenderArrayWidget.d.ts +5 -0
  51. package/dist/collection/components/renderer/RenderArrayWidget.d.ts.map +1 -0
  52. package/dist/collection/components/renderer/RenderCommonField.d.ts +5 -0
  53. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -0
  54. package/dist/collection/components/renderer/RenderRecordWidget.d.ts +4 -0
  55. package/dist/collection/components/renderer/RenderRecordWidget.d.ts.map +1 -0
  56. package/dist/collection/components/widgets/ErrorMessage.d.ts +6 -0
  57. package/dist/collection/components/widgets/ErrorMessage.d.ts.map +1 -0
  58. package/dist/collection/components/widgets/FieldWrapper.d.ts +14 -0
  59. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -0
  60. package/dist/collection/components/widgets/FormHelperText.d.ts +6 -0
  61. package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -0
  62. package/dist/collection/components/widgets/FormLabel.d.ts +8 -0
  63. package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -0
  64. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +8 -0
  65. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -0
  66. package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts +7 -0
  67. package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +1 -0
  68. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts +9 -0
  69. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -0
  70. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts +10 -0
  71. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -0
  72. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts +9 -0
  73. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -0
  74. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts +9 -0
  75. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts.map +1 -0
  76. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts +8 -0
  77. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -0
  78. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts +8 -0
  79. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -0
  80. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts +8 -0
  81. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -0
  82. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts +11 -0
  83. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -0
  84. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts +12 -0
  85. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -0
  86. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts +8 -0
  87. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts.map +1 -0
  88. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts +10 -0
  89. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -0
  90. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts +8 -0
  91. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -0
  92. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts +8 -0
  93. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts.map +1 -0
  94. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts +10 -0
  95. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -0
  96. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts +13 -0
  97. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -0
  98. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts +11 -0
  99. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -0
  100. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts +19 -0
  101. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -0
  102. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts +5 -0
  103. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts.map +1 -0
  104. package/dist/collection/index.d.ts +5 -0
  105. package/dist/collection/index.d.ts.map +1 -0
  106. package/dist/collection/index.js +19 -0
  107. package/dist/collection/lib/FormBuilder.d.ts +8 -0
  108. package/dist/collection/lib/FormBuilder.d.ts.map +1 -0
  109. package/dist/collection/lib/SaveDraftValues.d.ts +7 -0
  110. package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -0
  111. package/dist/collection/lib/hooks/useLevoForm.d.ts +18 -0
  112. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -0
  113. package/dist/collection/lib/provider/LevoFormProvider.d.ts +9 -0
  114. package/dist/collection/lib/provider/LevoFormProvider.d.ts.map +1 -0
  115. package/dist/collection/lib/variants/DefaultFormVariant.d.ts +3 -0
  116. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -0
  117. package/dist/collection/lib/variants/StepsFormVariant.d.ts +4 -0
  118. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -0
  119. package/dist/collection/types/context.d.ts +34 -0
  120. package/dist/collection/types/context.d.ts.map +1 -0
  121. package/dist/collection/types/errors.d.ts +7 -0
  122. package/dist/collection/types/errors.d.ts.map +1 -0
  123. package/dist/collection/types/formVariant.d.ts +18 -0
  124. package/dist/collection/types/formVariant.d.ts.map +1 -0
  125. package/dist/collection/types/forms.d.ts +31 -0
  126. package/dist/collection/types/forms.d.ts.map +1 -0
  127. package/dist/collection/types/index.d.ts +4 -0
  128. package/dist/collection/types/index.d.ts.map +1 -0
  129. package/dist/collection/types/renderer.d.ts +6 -0
  130. package/dist/collection/types/renderer.d.ts.map +1 -0
  131. package/dist/collection/utils/formHelpers.d.ts +47 -0
  132. package/dist/collection/utils/formHelpers.d.ts.map +1 -0
  133. package/dist/collection/utils/getFieldValidations.d.ts +6 -0
  134. package/dist/collection/utils/getFieldValidations.d.ts.map +1 -0
  135. package/dist/collection/utils/index.d.ts +4 -0
  136. package/dist/collection/utils/index.d.ts.map +1 -0
  137. package/dist/collection/utils/schema.d.ts +3 -0
  138. package/dist/collection/utils/schema.d.ts.map +1 -0
  139. package/dist/collection/utils/setFormErrors.d.ts +4 -0
  140. package/dist/collection/utils/setFormErrors.d.ts.map +1 -0
  141. package/dist/collection/utils/storage.d.ts +11 -0
  142. package/dist/collection/utils/storage.d.ts.map +1 -0
  143. package/dist/components/Dialog.d.ts +21 -0
  144. package/dist/components/Dialog.d.ts.map +1 -0
  145. package/dist/components/DialogWrapper.d.ts +11 -0
  146. package/dist/components/DialogWrapper.d.ts.map +1 -0
  147. package/dist/components/Sonner.d.ts +7 -0
  148. package/dist/components/Sonner.d.ts.map +1 -0
  149. package/dist/components/Spinner.d.ts +5 -0
  150. package/dist/components/Spinner.d.ts.map +1 -0
  151. package/dist/components/Tabs.d.ts +8 -0
  152. package/dist/components/Tabs.d.ts.map +1 -0
  153. package/dist/components/Tooltip.d.ts +16 -0
  154. package/dist/components/Tooltip.d.ts.map +1 -0
  155. package/dist/components/button/Button.d.ts +12 -0
  156. package/dist/components/button/Button.d.ts.map +1 -0
  157. package/dist/components/button/buttonVariants.d.ts +6 -0
  158. package/dist/components/button/buttonVariants.d.ts.map +1 -0
  159. package/dist/components/button/index.d.ts +3 -0
  160. package/dist/components/button/index.d.ts.map +1 -0
  161. package/dist/components/index.d.ts +8 -0
  162. package/dist/components/index.d.ts.map +1 -0
  163. package/dist/components/index.js +33 -0
  164. package/dist/constants/fileUploadPresets.d.ts +34 -0
  165. package/dist/constants/fileUploadPresets.d.ts.map +1 -0
  166. package/dist/constants/index.d.ts +2 -0
  167. package/dist/constants/index.d.ts.map +1 -0
  168. package/dist/errorHandler-BJcFS2qV.js +26 -0
  169. package/dist/fileUploadPresets-2raQmHT0.js +74 -0
  170. package/dist/index-wTf_TtOG.js +131 -0
  171. package/dist/index.d.ts +8 -0
  172. package/dist/index.js +84 -0
  173. package/dist/isEmptyObject-C5s4GzLE.js +8 -0
  174. package/dist/jsx-runtime-B6kdoens.js +634 -0
  175. package/dist/membership/components/OAuth/Button.d.ts +8 -0
  176. package/dist/membership/components/OAuth/Button.d.ts.map +1 -0
  177. package/dist/membership/components/OAuth/Container.d.ts +24 -0
  178. package/dist/membership/components/OAuth/Container.d.ts.map +1 -0
  179. package/dist/membership/components/OAuth/Core.d.ts +17 -0
  180. package/dist/membership/components/OAuth/Core.d.ts.map +1 -0
  181. package/dist/membership/components/OAuth/Popup.d.ts +15 -0
  182. package/dist/membership/components/OAuth/Popup.d.ts.map +1 -0
  183. package/dist/membership/components/index.d.ts +8 -0
  184. package/dist/membership/components/index.d.ts.map +1 -0
  185. package/dist/membership/index.d.ts +2 -0
  186. package/dist/membership/index.d.ts.map +1 -0
  187. package/dist/membership/index.js +4 -0
  188. package/dist/page-CxaKoH22.js +205 -0
  189. package/dist/providers/LevoProvider.d.ts +25 -0
  190. package/dist/providers/LevoProvider.d.ts.map +1 -0
  191. package/dist/style.css +1 -0
  192. package/dist/useLevoForm-CR3q-L5Z.js +166 -0
  193. package/dist/utils/byteToSize.d.ts +3 -0
  194. package/dist/utils/byteToSize.d.ts.map +1 -0
  195. package/dist/utils/cn.d.ts +4 -0
  196. package/dist/utils/cn.d.ts.map +1 -0
  197. package/dist/utils/errorHandler.d.ts +2 -0
  198. package/dist/utils/errorHandler.d.ts.map +1 -0
  199. package/dist/utils/index.d.ts +8 -0
  200. package/dist/utils/index.d.ts.map +1 -0
  201. package/dist/utils/index.js +14 -0
  202. package/dist/utils/isDateObject.d.ts +2 -0
  203. package/dist/utils/isDateObject.d.ts.map +1 -0
  204. package/dist/utils/isEmptyObject.d.ts +5 -0
  205. package/dist/utils/isEmptyObject.d.ts.map +1 -0
  206. package/dist/utils/isNullOrUndefined.d.ts +2 -0
  207. package/dist/utils/isNullOrUndefined.d.ts.map +1 -0
  208. package/dist/utils/isObject.d.ts +3 -0
  209. package/dist/utils/isObject.d.ts.map +1 -0
  210. package/package.json +96 -16
  211. /package/dist/audience/{useScrollDepth.d.ts → components/useScrollDepth.d.ts} +0 -0
@@ -0,0 +1,503 @@
1
+ "use client";
2
+ import { j as r } from "./jsx-runtime-B6kdoens.js";
3
+ import { createSrcSet as f, MediaKindList as k } from "@levo-so/core";
4
+ import { useMemo as Q, useState as S, useRef as aa, useEffect as D } from "react";
5
+ import { useController as ra } from "react-hook-form";
6
+ import { G as R, B as I, S as W, T as ta, a as sa, c as q, d as G } from "./Spinner-CuUosd-S.js";
7
+ import { X as ea, Upload as M } from "lucide-react";
8
+ import { h as oa, j as ca, k as na } from "./CollectionFormBuilder-a0pzMkWL.js";
9
+ import { I as X } from "./Input-2CvZ90f8.js";
10
+ import { l as la, S as K, i as da } from "./Tooltip-CI4i4mYr.js";
11
+ import { useDropzone as xa } from "react-dropzone";
12
+ import { m as ia, g as F } from "./fileUploadPresets-2raQmHT0.js";
13
+ import { e as O } from "./Sonner-t6JVKA0a.js";
14
+ import { c as P } from "./cn-C9QoOYNG.js";
15
+ import { u as V } from "./LevoProvider-DNbYyEaf.js";
16
+ import { e as J } from "./errorHandler-BJcFS2qV.js";
17
+ import { useDebouncedCallback as pa } from "use-debounce";
18
+ import { C as ma } from "./Checbox-sq-atGlJ.js";
19
+ import { b as ha } from "./byteToSize-BFKZSBu1.js";
20
+ function $(e) {
21
+ return R({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z" }, child: [] }] })(e);
22
+ }
23
+ function ua(e) {
24
+ return R({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z" }, child: [] }] })(e);
25
+ }
26
+ function ga(e) {
27
+ return R({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z" }, child: [] }] })(e);
28
+ }
29
+ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
30
+ const { media: c } = V(), n = Array.isArray(o) ? o : [], _ = Q(() => {
31
+ let t = {};
32
+ return j.forEach((m) => {
33
+ t = {
34
+ ...t,
35
+ ...ia[m]
36
+ };
37
+ }), t;
38
+ }, [j]), g = (t) => {
39
+ e == null || e(t);
40
+ }, y = async (t) => {
41
+ if ((t == null ? void 0 : t.length) === 0) {
42
+ O("No file selected. Please select one file.");
43
+ return;
44
+ }
45
+ const m = new FormData();
46
+ t == null || t.forEach((p) => {
47
+ m.append("media", p);
48
+ }), await (c == null ? void 0 : c.mediaBulkUpload(m).then((p) => {
49
+ var h, E;
50
+ const w = (E = (h = p == null ? void 0 : p.content) == null ? void 0 : h.data) == null ? void 0 : E.map(
51
+ (a) => {
52
+ var l;
53
+ return {
54
+ id: a == null ? void 0 : a.id,
55
+ kind: a == null ? void 0 : a.kind,
56
+ location: a == null ? void 0 : a.location,
57
+ mimetype: (l = a == null ? void 0 : a.metadata) == null ? void 0 : l.mimetype,
58
+ srcset: a == null ? void 0 : a.srcset
59
+ };
60
+ }
61
+ );
62
+ g([...n, ...w]);
63
+ }).catch(J));
64
+ }, { getRootProps: z, getInputProps: i, isDragActive: v } = xa({
65
+ onDrop: y,
66
+ accept: _,
67
+ multiple: d,
68
+ maxSize: 25 * 1024 * 1024,
69
+ onDropRejected: (t) => {
70
+ t.forEach((m) => {
71
+ m.errors.forEach((p) => {
72
+ p.code === "file-too-large" && O(`${m.file.name} is bigger than 25MB`);
73
+ });
74
+ });
75
+ }
76
+ });
77
+ return /* @__PURE__ */ r.jsx(la, { children: /* @__PURE__ */ r.jsx("div", { className: "w-full min-h-[150px]", children: (n == null ? void 0 : n.length) > 0 ? /* @__PURE__ */ r.jsxs("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fit,_minmax(150px,_1fr))]", children: [
78
+ n == null ? void 0 : n.map((t) => {
79
+ var m, p;
80
+ return /* @__PURE__ */ r.jsxs(
81
+ "div",
82
+ {
83
+ className: "group relative w-full overflow-hidden h-auto max-[350px] rounded-md border border-gray-300",
84
+ style: {
85
+ background: "linear-gradient(to top, black -50%, transparent 45%)"
86
+ },
87
+ children: [
88
+ (t == null ? void 0 : t.kind) !== "image" ? /* @__PURE__ */ r.jsx("div", { className: "flex items-center h-[100px]", children: /* @__PURE__ */ r.jsx(
89
+ $,
90
+ {
91
+ size: "60px",
92
+ className: "text-gray-400 p-2"
93
+ }
94
+ ) }) : /* @__PURE__ */ r.jsx(
95
+ "img",
96
+ {
97
+ className: "w-full h-full object-contain",
98
+ src: t == null ? void 0 : t.location
99
+ }
100
+ ),
101
+ /* @__PURE__ */ r.jsx(
102
+ "div",
103
+ {
104
+ className: P(
105
+ "absolute left-0 right-0 bottom-0 h-16 bg-[linear-gradient(to-t,_rgba(0,_0,_10,_0.35),_transparent)]",
106
+ "group-hover:bg-[linear-gradient(to-t,_rgba(0,0,10,0.5),_transparent)] group-hover:h-[70%]"
107
+ )
108
+ }
109
+ ),
110
+ /* @__PURE__ */ r.jsx("p", { className: "absolute left-4 bottom-2 text-base text-white", children: (p = t == null ? void 0 : t.location) == null ? void 0 : p.split("/")[((m = t == null ? void 0 : t.location) == null ? void 0 : m.split("/").length) - 1] }),
111
+ /* @__PURE__ */ r.jsx(
112
+ I,
113
+ {
114
+ className: "absolute right-4 top-4 z-10",
115
+ size: "icon",
116
+ variant: "secondary",
117
+ onClick: () => {
118
+ g(
119
+ n == null ? void 0 : n.filter((w) => (w == null ? void 0 : w.id) !== (t == null ? void 0 : t.id))
120
+ );
121
+ },
122
+ children: /* @__PURE__ */ r.jsx(ea, { className: "text-primary" })
123
+ }
124
+ )
125
+ ]
126
+ },
127
+ t == null ? void 0 : t.id
128
+ );
129
+ }),
130
+ d && /* @__PURE__ */ r.jsxs(
131
+ "div",
132
+ {
133
+ className: "flex items-center justify-center flex-col w-full rounded-md border-dashed border-[2px] border-gray-400 h-[14rem] p-4 gap-2",
134
+ ...z(),
135
+ children: [
136
+ /* @__PURE__ */ r.jsx("p", { className: "text-xl text-center my-2", children: v ? "Drop your files here..." : "Drag & Drop here to upload!" }),
137
+ /* @__PURE__ */ r.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ r.jsx(K, { label: "Upload a file", children: /* @__PURE__ */ r.jsxs(I, { size: "icon", className: "text-md", children: [
138
+ /* @__PURE__ */ r.jsx("input", { ...i() }),
139
+ /* @__PURE__ */ r.jsx(M, { size: 20 })
140
+ ] }) }) })
141
+ ]
142
+ }
143
+ )
144
+ ] }) : /* @__PURE__ */ r.jsxs(
145
+ "div",
146
+ {
147
+ className: "flex items-center justify-center flex-col w-full rounded-md border-dashed border-[2px] border-gray-400 h-[14rem] p-4 gap-2",
148
+ ...z(),
149
+ children: [
150
+ /* @__PURE__ */ r.jsx("p", { className: "text-xl my-2", children: v ? "Drop your files here..." : "Drag & Drop here to upload!" }),
151
+ /* @__PURE__ */ r.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ r.jsx(K, { label: "Upload a file", children: /* @__PURE__ */ r.jsxs(I, { size: "icon", className: "text-md", children: [
152
+ /* @__PURE__ */ r.jsx("input", { ...i() }),
153
+ /* @__PURE__ */ r.jsx(M, { size: 20 })
154
+ ] }) }) })
155
+ ]
156
+ }
157
+ ) }) });
158
+ }, ya = ({
159
+ selectedFiles: e = [],
160
+ onChange: o,
161
+ isMultiple: j = !1,
162
+ kind: d
163
+ }) => {
164
+ const { media: c } = V(), [n, _] = S(1), [g, y] = S([]), [z, i] = S(!1), v = aa(null), [t, m] = S({
165
+ searchText: "",
166
+ currentPage: 1
167
+ }), p = pa(() => {
168
+ i(!0), c == null || c.getAllMedia({
169
+ page: t.currentPage,
170
+ limit: 24,
171
+ sort: {
172
+ created_at: "desc"
173
+ },
174
+ search: t.searchText || void 0
175
+ }).then((a) => {
176
+ var l, A;
177
+ _((A = (l = a == null ? void 0 : a.content) == null ? void 0 : l.meta) == null ? void 0 : A.pages), y((L) => {
178
+ var b;
179
+ return [...L, ...((b = a == null ? void 0 : a.content) == null ? void 0 : b.data) || []];
180
+ });
181
+ }).catch((a) => {
182
+ console.error(a);
183
+ }).finally(() => {
184
+ i(!1);
185
+ });
186
+ }, 500);
187
+ D(() => {
188
+ p();
189
+ }, [t]), D(() => {
190
+ const a = v.current;
191
+ if (a)
192
+ return a.addEventListener("scroll", w), () => a.removeEventListener("scroll", w);
193
+ }, [v, t.currentPage, n]);
194
+ const w = () => {
195
+ const a = v.current;
196
+ a && a.scrollTop + a.clientHeight + 1 >= a.scrollHeight && h();
197
+ }, h = () => {
198
+ t.currentPage < n && m((a) => ({
199
+ searchText: a.searchText,
200
+ currentPage: a.currentPage + 1
201
+ }));
202
+ }, E = (a) => {
203
+ if (!(d != null && d.includes(a == null ? void 0 : a.kind))) {
204
+ O(`Only ${d == null ? void 0 : d.join(", ")}s are allowed.`);
205
+ return;
206
+ }
207
+ j ? (e == null ? void 0 : e.findIndex((l) => (l == null ? void 0 : l.id) === (a == null ? void 0 : a.id))) >= 0 ? o == null || o(e == null ? void 0 : e.filter((l) => (l == null ? void 0 : l.id) !== (a == null ? void 0 : a.id))) : o == null || o([...e || [], a]) : o == null || o([a]);
208
+ };
209
+ return /* @__PURE__ */ r.jsxs("div", { className: "bg-white p-0 rounded-md w-full relative", children: [
210
+ /* @__PURE__ */ r.jsx("div", { className: "py-2 bg-white sticky top-0 z-50 w-full", children: /* @__PURE__ */ r.jsx(
211
+ X,
212
+ {
213
+ name: "searchText",
214
+ type: "text",
215
+ placeholder: "Search...",
216
+ value: t.searchText,
217
+ onChange: (a) => {
218
+ i(!0), m({ currentPage: 1, searchText: a.target.value }), y([]);
219
+ }
220
+ }
221
+ ) }),
222
+ z && !g.length ? /* @__PURE__ */ r.jsx("div", { className: "w-full h-full min-h-[30rem] flex items-center justify-center", children: /* @__PURE__ */ r.jsx(W, {}) }) : /* @__PURE__ */ r.jsxs(
223
+ "div",
224
+ {
225
+ ref: v,
226
+ className: "w-full h-[30rem] overflow-y-auto overflow-x-hidden grid lg:grid-cols-4 gap-6 p-2",
227
+ children: [
228
+ g == null ? void 0 : g.map((a, l) => {
229
+ const A = d == null ? void 0 : d.includes(a == null ? void 0 : a.kind), L = (e == null ? void 0 : e.findIndex((b) => (b == null ? void 0 : b.id) === (a == null ? void 0 : a.id))) >= 0;
230
+ return /* @__PURE__ */ r.jsxs(
231
+ "div",
232
+ {
233
+ className: P(
234
+ "relative w-full",
235
+ A ? "opacity-100" : "opacity-50"
236
+ ),
237
+ children: [
238
+ /* @__PURE__ */ r.jsxs(
239
+ "div",
240
+ {
241
+ className: P(
242
+ "cursor-pointer w-full group rounded-md overflow-hidden h-[130px] border-2 flex items-center justify-center",
243
+ L ? "border-primary" : "border-gray-100"
244
+ ),
245
+ onClick: () => {
246
+ var b;
247
+ return E({
248
+ id: a == null ? void 0 : a.id,
249
+ location: a == null ? void 0 : a.location,
250
+ mimetype: (b = a == null ? void 0 : a.metadata) == null ? void 0 : b.mimetype,
251
+ kind: a == null ? void 0 : a.kind,
252
+ srcset: a == null ? void 0 : a.srcset
253
+ });
254
+ },
255
+ children: [
256
+ /* @__PURE__ */ r.jsx(
257
+ "div",
258
+ {
259
+ className: P(
260
+ "rounded-md opacity-0 absolute left-0 right-0 top-0 w-full h-[42px] bg-[linear-gradient(0deg,_transparent_0%,_#000000_200%)]",
261
+ A ? "group-hover:opacity-100" : ""
262
+ )
263
+ }
264
+ ),
265
+ A && /* @__PURE__ */ r.jsx(
266
+ ma,
267
+ {
268
+ name: "isFileIncluded",
269
+ className: "absolute top-[10px] left-[10px]",
270
+ checked: L
271
+ }
272
+ ),
273
+ (a == null ? void 0 : a.kind) !== "image" ? /* @__PURE__ */ r.jsx($, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ r.jsx(
274
+ "img",
275
+ {
276
+ className: "w-full h-full object-contain",
277
+ srcSet: f(a == null ? void 0 : a.srcset),
278
+ src: a == null ? void 0 : a.location
279
+ }
280
+ )
281
+ ]
282
+ }
283
+ ),
284
+ /* @__PURE__ */ r.jsxs("div", { className: "my-[10px]", children: [
285
+ /* @__PURE__ */ r.jsx("p", { className: "text-sm whitespace-nowrap overflow-hidden text-ellipsis", children: a == null ? void 0 : a.filename }),
286
+ /* @__PURE__ */ r.jsx("p", { className: "text-xs text-gray-500", children: ha(a == null ? void 0 : a.metadata.size) })
287
+ ] })
288
+ ]
289
+ },
290
+ `media-layout-file-${l}`
291
+ );
292
+ }),
293
+ z && /* @__PURE__ */ r.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ r.jsx(W, {}) })
294
+ ]
295
+ }
296
+ )
297
+ ] });
298
+ }, ba = ({
299
+ isOpen: e,
300
+ onClose: o,
301
+ onChange: j,
302
+ value: d,
303
+ kind: c,
304
+ isMultiple: n = !1,
305
+ isExternal: _
306
+ }) => {
307
+ const [g, y] = S([]), z = () => {
308
+ o();
309
+ };
310
+ return D(() => {
311
+ y(d.filter((i) => !!i.location));
312
+ }, [d]), /* @__PURE__ */ r.jsxs(
313
+ da,
314
+ {
315
+ title: (c == null ? void 0 : c.length) > 1 ? "Upload file" : `Upload ${c == null ? void 0 : c[0]}`,
316
+ isOpen: e,
317
+ onClose: () => z(),
318
+ contentClassName: "max-w-[60%]",
319
+ children: [
320
+ /* @__PURE__ */ r.jsxs(ta, { defaultValue: "upload", children: [
321
+ /* @__PURE__ */ r.jsxs(sa, { children: [
322
+ /* @__PURE__ */ r.jsx(q, { value: "upload", children: "Local File" }),
323
+ !_ && /* @__PURE__ */ r.jsx(q, { value: "import", children: "Import from Gallery" })
324
+ ] }),
325
+ /* @__PURE__ */ r.jsx(G, { value: "upload", children: /* @__PURE__ */ r.jsx("div", { className: "mt-[20px] max-h-[70vh] overflow-y-auto", children: /* @__PURE__ */ r.jsx(
326
+ ja,
327
+ {
328
+ kind: c,
329
+ value: g,
330
+ onChange: (i) => y(i),
331
+ isMultiple: n
332
+ }
333
+ ) }) }),
334
+ /* @__PURE__ */ r.jsx(G, { value: "import", children: /* @__PURE__ */ r.jsx(
335
+ ya,
336
+ {
337
+ onChange: (i) => {
338
+ y == null || y(i);
339
+ },
340
+ selectedFiles: g,
341
+ isMultiple: n,
342
+ kind: c
343
+ }
344
+ ) })
345
+ ] }),
346
+ /* @__PURE__ */ r.jsx("div", { className: "flex justify-end mt-[20px]", children: /* @__PURE__ */ r.jsx(
347
+ I,
348
+ {
349
+ variant: "default",
350
+ onClick: () => {
351
+ g && (j == null || j(g)), z();
352
+ },
353
+ children: "Save"
354
+ }
355
+ ) })
356
+ ]
357
+ }
358
+ );
359
+ }, Va = ({
360
+ field: e,
361
+ kind: o = k,
362
+ isMultiple: j,
363
+ isExternal: d = !1
364
+ }) => {
365
+ var H;
366
+ const { media: c } = V(), { key: n = "", label: _ = "", helper_text: g = "", readonly: y = !1 } = e, {
367
+ field: { onBlur: z, onChange: i, value: v, disabled: t, ref: m },
368
+ fieldState: p
369
+ } = ra({
370
+ name: n,
371
+ rules: oa(e)
372
+ }), w = Q(() => {
373
+ const s = [];
374
+ return o.forEach((T) => {
375
+ s.push(...F[T]);
376
+ }), s;
377
+ }, [o]), h = v ? Array.isArray(v) ? v : [v] : [], [E, a] = S(!1), l = () => a(!0), A = () => a(!1), [L, b] = S(!1), U = (s) => {
378
+ i && (j === !0 ? i(s) : j === !1 && i(s == null ? void 0 : s[0]));
379
+ }, Y = async (s) => {
380
+ const T = new FormData();
381
+ let x = [...s];
382
+ j || (x = s == null ? void 0 : s.slice(0, 1)), (x == null ? void 0 : x.length) > 0 && (x == null || x.forEach((u) => {
383
+ var C;
384
+ const N = u.name.split("."), B = (C = N[N.length - 1]) == null ? void 0 : C.toLowerCase();
385
+ o == null || o.forEach((Z) => {
386
+ w.push(...F[Z]);
387
+ }), B && w.includes(B) && T.append("media", u);
388
+ })), b(!0), await (c == null ? void 0 : c.mediaBulkUpload(T).then((u) => {
389
+ var N, B;
390
+ b(!1), (N = u == null ? void 0 : u.content) != null && N.data && U((B = u == null ? void 0 : u.content) == null ? void 0 : B.data);
391
+ }).catch((u) => {
392
+ J(u);
393
+ }).finally(() => {
394
+ b(!1);
395
+ }));
396
+ };
397
+ return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
398
+ /* @__PURE__ */ r.jsx(
399
+ ba,
400
+ {
401
+ isOpen: E,
402
+ onClose: A,
403
+ onChange: (s) => {
404
+ U(s);
405
+ },
406
+ value: h,
407
+ kind: [...o],
408
+ isMultiple: j,
409
+ isExternal: d
410
+ }
411
+ ),
412
+ /* @__PURE__ */ r.jsxs(
413
+ ca,
414
+ {
415
+ error: (H = p == null ? void 0 : p.error) == null ? void 0 : H.message,
416
+ helperText: g,
417
+ readOnly: y,
418
+ children: [
419
+ _ && /* @__PURE__ */ r.jsx(na, { htmlFor: n, isRequired: e == null ? void 0 : e.required, children: _ }),
420
+ /* @__PURE__ */ r.jsxs("div", { className: "flex gap-2", ref: m, children: [
421
+ /* @__PURE__ */ r.jsx(
422
+ I,
423
+ {
424
+ size: "icon-small",
425
+ variant: "outline",
426
+ disabled: t,
427
+ onClick: l,
428
+ children: /* @__PURE__ */ r.jsx(M, { size: 15 })
429
+ }
430
+ ),
431
+ /* @__PURE__ */ r.jsxs("div", { className: "relative flex", children: [
432
+ /* @__PURE__ */ r.jsx(
433
+ X,
434
+ {
435
+ name: "pasteUrl",
436
+ onBlur: () => z(),
437
+ onPaste: (s) => {
438
+ const T = s.clipboardData.items, x = [];
439
+ for (let u = 0; u < T.length; u++) {
440
+ const N = T[u];
441
+ if ((N == null ? void 0 : N.kind) === "file") {
442
+ const B = N == null ? void 0 : N.getAsFile();
443
+ B && x.push(B);
444
+ }
445
+ }
446
+ (x == null ? void 0 : x.length) > 0 && Y(x);
447
+ },
448
+ disabled: t,
449
+ readOnly: y
450
+ }
451
+ ),
452
+ L && /* @__PURE__ */ r.jsxs(
453
+ "div",
454
+ {
455
+ role: "status",
456
+ className: "absolute right-3 top-[50%] translate-y-[-50%]",
457
+ children: [
458
+ /* @__PURE__ */ r.jsx(ua, {}),
459
+ /* @__PURE__ */ r.jsx("span", { className: "sr-only", children: "Loading..." })
460
+ ]
461
+ }
462
+ )
463
+ ] })
464
+ ] }),
465
+ (h == null ? void 0 : h.length) > 0 && /* @__PURE__ */ r.jsx("div", { className: "mt-3 w-full", children: /* @__PURE__ */ r.jsx("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fill,_minmax(100px,_1fr))]", children: h == null ? void 0 : h.map((s, T) => s != null && s.location ? /* @__PURE__ */ r.jsxs(
466
+ "div",
467
+ {
468
+ className: "relative border overflow-hidden group w-full rounded-xl h-[120px] flex items-center justify-center",
469
+ children: [
470
+ (s == null ? void 0 : s.kind) !== "image" ? /* @__PURE__ */ r.jsx($, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ r.jsx(
471
+ "img",
472
+ {
473
+ className: "w-full h-full object-contain",
474
+ src: s == null ? void 0 : s.location,
475
+ alt: s == null ? void 0 : s.id
476
+ }
477
+ ),
478
+ /* @__PURE__ */ r.jsx(
479
+ "button",
480
+ {
481
+ className: "absolute top-1 right-1 bg-white p-1 rounded-full focus:outline-none",
482
+ onClick: () => {
483
+ U(
484
+ h == null ? void 0 : h.filter((x) => (x == null ? void 0 : x.id) !== (s == null ? void 0 : s.id))
485
+ );
486
+ },
487
+ type: "button",
488
+ children: /* @__PURE__ */ r.jsx(ga, { className: "text-sm" })
489
+ }
490
+ )
491
+ ]
492
+ },
493
+ `${s == null ? void 0 : s.location}-${T}`
494
+ ) : null) }) })
495
+ ]
496
+ }
497
+ )
498
+ ] });
499
+ };
500
+ export {
501
+ Va as UploadWidget,
502
+ Va as default
503
+ };
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ILevoAudience } from '@levo-so/audience';
2
+ import { ILevoAudience } from '@levo-so/core';
3
3
  export declare const LevoAudienceBlock: React.FC<{
4
4
  id: string;
5
5
  properties?: ILevoAudience.Properties;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/audience/components/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CAkBA,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ILevoAudience } from '@levo-so/audience';
1
+ import { ILevoAudience } from '@levo-so/core';
2
2
  export declare const LevoAudienceComponent: React.FC<{
3
3
  event: string;
4
4
  properties: ILevoAudience.Properties;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/audience/components/component.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC;CACtC,CAUA,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ILevoAudience } from '@levo-so/audience';
1
+ import { ILevoAudience } from '@levo-so/core';
2
2
  export declare const LevoAudiencePage: React.FC<{
3
3
  workspace_id: string;
4
4
  id?: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CA2FA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollDepth.d.ts","sourceRoot":"","sources":["../../../src/audience/components/useScrollDepth.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,cAAc,cAwC1B,CAAC"}
@@ -1,4 +1,4 @@
1
- export { default as LevoInsightsBlock } from './block';
2
- export { default as LevoInsightsComponent } from './component';
3
- export { default as LevoInsightsPage } from './page';
1
+ export { default as LevoInsightsBlock } from './components/block';
2
+ export { default as LevoInsightsComponent } from './components/component';
3
+ export { default as LevoInsightsPage } from './components/page';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audience/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}