@simple-builder/react 1.3.9 → 1.4.1

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 (112) hide show
  1. package/dist/{build-container-client-THZHNQ5S.mjs → build-container-client-6S55GQVT.mjs} +81 -41
  2. package/dist/{build-container-client-NXIMV3RF.js → build-container-client-EQBL556Y.js} +148 -115
  3. package/dist/{build-container-client-ZXO66OL5.js → build-container-client-JAITVVDD.js} +176 -136
  4. package/dist/{build-container-client-5QC5KVS3.mjs → build-container-client-LMZUWEUI.mjs} +53 -20
  5. package/dist/{builder-content-3HENFCB5.js → builder-content-7ZRYWXPN.js} +7 -7
  6. package/dist/{builder-content-2J424EME.mjs → builder-content-H75SR7I7.mjs} +2 -2
  7. package/dist/{builder-content-4ZNXUE7D.mjs → builder-content-OR2VTIUY.mjs} +2 -2
  8. package/dist/{builder-content-2MA6BKJ5.js → builder-content-XNIM2YVG.js} +7 -7
  9. package/dist/{chunk-BCPLNZMY.js → chunk-4SFXTFFU.js} +5 -5
  10. package/dist/{chunk-2CPAROZB.js → chunk-63LNKQZD.js} +1 -1
  11. package/dist/{chunk-3QWMKMTN.js → chunk-7FWFM2TR.js} +5 -5
  12. package/dist/{chunk-4TVSMCQU.js → chunk-7I4RGF45.js} +3 -3
  13. package/dist/{chunk-7X5S5JRE.js → chunk-JFWIO2AR.js} +3 -3
  14. package/dist/{chunk-5OV6KPTF.mjs → chunk-MXIMMIPT.mjs} +1 -1
  15. package/dist/{chunk-B5R6QY7N.mjs → chunk-QSAIF4GO.mjs} +1 -1
  16. package/dist/{chunk-5Q4KJW4A.mjs → chunk-UA2CNH3R.mjs} +2 -2
  17. package/dist/{chunk-6GCMYFBT.mjs → chunk-X5MZZBYC.mjs} +2 -2
  18. package/dist/{chunk-DZLUIOVD.js → chunk-YFRFNRKR.js} +1 -1
  19. package/dist/{chunk-CJGHP5Q7.mjs → chunk-ZJYB6LEV.mjs} +1 -1
  20. package/dist/{chunk-2GOYHVMW.mjs → chunk-ZQBKKI2S.mjs} +1 -1
  21. package/dist/index.css +0 -3
  22. package/dist/index.d.mts +6 -12
  23. package/dist/index.d.ts +6 -12
  24. package/dist/index.js +6 -6
  25. package/dist/index.mjs +2 -2
  26. package/package.json +2 -2
  27. package/dist/build-container-client-7Z6WZVBX.js +0 -2295
  28. package/dist/build-container-client-DWKVE65B.mjs +0 -2262
  29. package/dist/build-container-client-FN3PZMM7.mjs +0 -2257
  30. package/dist/build-container-client-FVDRMOZ7.mjs +0 -2255
  31. package/dist/build-container-client-GV52F5RP.js +0 -2298
  32. package/dist/build-container-client-J56NWFBF.mjs +0 -2261
  33. package/dist/build-container-client-L3WD4CG7.mjs +0 -2259
  34. package/dist/build-container-client-RSJ4H3SB.js +0 -2290
  35. package/dist/build-container-client-WGVIYK47.css +0 -1968
  36. package/dist/build-container-client-WHIUDBOZ.mjs +0 -2263
  37. package/dist/build-container-client-WIGFVNOW.css +0 -1971
  38. package/dist/build-container-client-WN35X6JD.js +0 -2291
  39. package/dist/build-container-client-WYIHRPSW.js +0 -2299
  40. package/dist/build-container-client-XAQDWWKB.mjs +0 -2254
  41. package/dist/build-container-client-XOHYMPBB.js +0 -2293
  42. package/dist/build-container-client-YDRPPWCU.js +0 -2297
  43. package/dist/build-container-client-YWNDWXO2.css +0 -1967
  44. package/dist/build-container-client-ZP3O6EGC.mjs +0 -2253
  45. package/dist/build-container-client-ZXAAYUTL.js +0 -2289
  46. package/dist/builder-content-2ZXIEMS3.js +0 -42
  47. package/dist/builder-content-3H7GF3KF.mjs +0 -20
  48. package/dist/builder-content-6PIBXDPE.mjs +0 -20
  49. package/dist/builder-content-73ZKCEIT.mjs +0 -20
  50. package/dist/builder-content-BIVYFWCC.js +0 -42
  51. package/dist/builder-content-BKE4JZ75.js +0 -42
  52. package/dist/builder-content-BU4BXER7.mjs +0 -20
  53. package/dist/builder-content-CP5VLMVD.mjs +0 -20
  54. package/dist/builder-content-CY43LFAA.js +0 -42
  55. package/dist/builder-content-FMTTH7R2.js +0 -42
  56. package/dist/builder-content-GBSIY2Z7.js +0 -42
  57. package/dist/builder-content-GJ4HYIOA.mjs +0 -20
  58. package/dist/builder-content-HQXSXBFZ.mjs +0 -20
  59. package/dist/builder-content-L7NHKCKD.js +0 -42
  60. package/dist/builder-content-MI55X5HA.css +0 -1971
  61. package/dist/builder-content-PWV6LNFT.mjs +0 -20
  62. package/dist/builder-content-RROSPBT4.css +0 -1968
  63. package/dist/builder-content-RV3DPWFH.js +0 -42
  64. package/dist/builder-content-V2MDRHJI.css +0 -1967
  65. package/dist/chunk-2OHBCAZQ.mjs +0 -244
  66. package/dist/chunk-2OYBZSJQ.mjs +0 -123
  67. package/dist/chunk-454D7NIH.js +0 -153
  68. package/dist/chunk-6GCUWI4L.mjs +0 -135
  69. package/dist/chunk-6KNCX5O5.mjs +0 -123
  70. package/dist/chunk-6VINC5E2.mjs +0 -244
  71. package/dist/chunk-C5GHD62W.mjs +0 -20
  72. package/dist/chunk-CARNMQP6.mjs +0 -20
  73. package/dist/chunk-CJNSRJNF.js +0 -42
  74. package/dist/chunk-EVMN5SX2.js +0 -269
  75. package/dist/chunk-EZFQOJHG.mjs +0 -244
  76. package/dist/chunk-F5JWY4CM.mjs +0 -20
  77. package/dist/chunk-H357GPTV.mjs +0 -244
  78. package/dist/chunk-H6OM2V2U.mjs +0 -20
  79. package/dist/chunk-HCM5NR6G.js +0 -269
  80. package/dist/chunk-IJJTQQQN.mjs +0 -135
  81. package/dist/chunk-IQX5LONG.js +0 -153
  82. package/dist/chunk-LEIASP7E.js +0 -153
  83. package/dist/chunk-MBISMJDL.js +0 -269
  84. package/dist/chunk-NDE4WSBA.js +0 -269
  85. package/dist/chunk-NUDE6YTK.js +0 -165
  86. package/dist/chunk-NZ4ZQMIS.js +0 -42
  87. package/dist/chunk-OWZPAOR6.mjs +0 -244
  88. package/dist/chunk-PADTJYXB.mjs +0 -20
  89. package/dist/chunk-QZQRUNAY.js +0 -153
  90. package/dist/chunk-RGBUK5SR.js +0 -269
  91. package/dist/chunk-RNGHWAPZ.js +0 -269
  92. package/dist/chunk-RYW5OXNX.mjs +0 -244
  93. package/dist/chunk-RZFAIM2Q.mjs +0 -123
  94. package/dist/chunk-SFYJAJOD.js +0 -42
  95. package/dist/chunk-SLWJHIVH.mjs +0 -123
  96. package/dist/chunk-TMDKQB2L.js +0 -153
  97. package/dist/chunk-TQQ4WVQU.mjs +0 -123
  98. package/dist/chunk-VCXFPTGD.js +0 -42
  99. package/dist/chunk-VNNNLYSW.js +0 -42
  100. package/dist/chunk-VO7KUMAO.js +0 -165
  101. package/dist/chunk-W4OP4EHX.mjs +0 -20
  102. package/dist/chunk-WA7TKN6M.js +0 -42
  103. package/dist/chunk-WI3YU7TV.js +0 -42
  104. package/dist/chunk-WPBR7BJZ.js +0 -269
  105. package/dist/chunk-X5A4S44V.mjs +0 -244
  106. package/dist/chunk-X5GVLHI2.mjs +0 -20
  107. package/dist/chunk-XLE7GSYM.mjs +0 -244
  108. package/dist/chunk-XSG7W73Z.mjs +0 -20
  109. package/dist/chunk-XZNO7DXS.js +0 -153
  110. package/dist/chunk-YKPZPQ5D.js +0 -269
  111. package/dist/chunk-ZGHPPTOO.js +0 -42
  112. package/dist/chunk-ZZT7HGAM.mjs +0 -123
@@ -1,18 +1,7 @@
1
1
  'use client';
2
- 'use client';
3
- 'use client';
4
- 'use client';
5
- 'use client';
6
- 'use client';
7
- 'use client';
8
- 'use client';
9
- 'use client';
10
- 'use client';
11
- 'use client';
12
- 'use client';
13
- import './chunk-5Q4KJW4A.mjs';
14
- import { buttonVariants, Button, useBuilder } from './chunk-2OHBCAZQ.mjs';
15
- import { cn, tv, DesignWrapper, builder, Image } from './chunk-ZZT7HGAM.mjs';
2
+ import './chunk-X5MZZBYC.mjs';
3
+ import { buttonVariants, Button, useBuilder } from './chunk-ZJYB6LEV.mjs';
4
+ import { cn, tv, DesignWrapper, builder, Image } from './chunk-QSAIF4GO.mjs';
16
5
  import * as React25 from 'react';
17
6
  import { useCallback } from 'react';
18
7
  import { ChevronRight, Check, Circle, X, ChevronDown, ChevronUp, PlusIcon, ArrowUp, ArrowDown, Edit2Icon, Trash2Icon, ImageIcon, XIcon, PlusCircleIcon, CalendarIcon, MonitorIcon, SmartphoneIcon, ChevronLeftIcon, ChevronRightIcon, PaintbrushIcon, Loader2Icon, AlignHorizontalSpaceAroundIcon, AlignHorizontalJustifyStartIcon, ScanIcon } from 'lucide-react';
@@ -184,13 +173,16 @@ var Link = TiptapLink.extend({
184
173
  }
185
174
  });
186
175
 
176
+ // src/features/rich-text-editor/utils/normalize-rich-text-colors.ts
177
+ var normalizeRichTextColors = (html) => html.replaceAll(/hsl\(var\((--[A-Za-z0-9-]+)\)\)/g, "var($1)");
178
+
187
179
  // src/features/rich-text-editor/utils/get-output.ts
188
180
  var getOutput = (editor, format2) => {
189
181
  switch (format2) {
190
182
  case "json":
191
183
  return editor.getJSON();
192
184
  case "html":
193
- return editor.isEmpty ? "" : editor.getHTML();
185
+ return editor.isEmpty ? "" : normalizeRichTextColors(editor.getHTML());
194
186
  default:
195
187
  return editor.getText();
196
188
  }
@@ -209,7 +201,9 @@ var useRichTextEditor = ({
209
201
  (editor2) => {
210
202
  console.count("useRichTextEditor:handleCreate");
211
203
  if (value && editor2.isEmpty) {
212
- editor2.commands.setContent(value);
204
+ editor2.commands.setContent(
205
+ typeof value === "string" ? normalizeRichTextColors(value) : value
206
+ );
213
207
  }
214
208
  },
215
209
  [value]
@@ -434,32 +428,34 @@ var ToggleGroupItem = React25.forwardRef(({ className, children, variant, size,
434
428
  ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
435
429
  var PALETTES = [
436
430
  {
437
- inverse: "hsl(var(--background))",
431
+ inverse: "var(--background)",
438
432
  colors: [
439
- { cssVar: "hsl(var(--foreground))" },
440
- { cssVar: "hsl(var(--primary-foreground))" },
441
- { cssVar: "hsl(var(--secondary-foreground))" },
442
- { cssVar: "hsl(var(--tertiary-foreground))" },
443
- { cssVar: "hsl(var(--muted-foreground))" },
444
- { cssVar: "hsl(var(--accent-foreground))" },
445
- { cssVar: "hsl(var(--destructive-foreground))" }
433
+ { cssVar: "var(--foreground)" },
434
+ { cssVar: "var(--primary-foreground)" },
435
+ { cssVar: "var(--secondary-foreground)" },
436
+ { cssVar: "var(--tertiary-foreground)" },
437
+ { cssVar: "var(--muted-foreground)" },
438
+ { cssVar: "var(--accent-foreground)" },
439
+ { cssVar: "var(--destructive-foreground)" }
446
440
  ]
447
441
  },
448
442
  {
449
- inverse: "hsl(var(--foreground))",
443
+ inverse: "var(--foreground)",
450
444
  colors: [
451
- { cssVar: "hsl(var(--background))" },
452
- { cssVar: "hsl(var(--primary))" },
453
- { cssVar: "hsl(var(--secondary))" },
454
- { cssVar: "hsl(var(--tertiary))" },
455
- { cssVar: "hsl(var(--muted))" },
456
- { cssVar: "hsl(var(--accent))" },
457
- { cssVar: "hsl(var(--destructive))" }
445
+ { cssVar: "var(--background)" },
446
+ { cssVar: "var(--primary)" },
447
+ { cssVar: "var(--secondary)" },
448
+ { cssVar: "var(--tertiary)" },
449
+ { cssVar: "var(--muted)" },
450
+ { cssVar: "var(--accent)" },
451
+ { cssVar: "var(--destructive)" }
458
452
  ]
459
453
  }
460
454
  ];
461
455
  var ColorTool = ({ editor }) => {
462
- const color = editor.getAttributes("textStyle")?.color || "hsl(var(--foreground))";
456
+ const color = normalizeRichTextColors(
457
+ editor.getAttributes("textStyle")?.color || "var(--foreground)"
458
+ );
463
459
  const [selectedColor, setSelectedColor] = React25.useState(color);
464
460
  React25.useEffect(() => {
465
461
  setSelectedColor(color);
@@ -506,7 +502,7 @@ var ColorTool = ({ editor }) => {
506
502
  value: color2.cssVar,
507
503
  style: { backgroundColor: color2.cssVar }
508
504
  },
509
- selectedColor === color2.cssVar && /* @__PURE__ */ React25.createElement(
505
+ normalizeRichTextColors(selectedColor) === color2.cssVar && /* @__PURE__ */ React25.createElement(
510
506
  LuCheck,
511
507
  {
512
508
  className: "sb:absolute sb:inset-0 sb:m-auto sb:size-6",
@@ -1174,11 +1170,26 @@ var ColorPicker = (props) => {
1174
1170
  }
1175
1171
  ))));
1176
1172
  };
1173
+ var IMAGE_FILE_ACCEPT = ".png,.jpg,.jpeg,.webp,.gif,.svg";
1174
+ var MEDIA_FILE_ACCEPT = `${IMAGE_FILE_ACCEPT},.mp4,.webm,.mov,.ogg,.ogv,.m4v,video/*`;
1175
+ var VIDEO_EXTENSIONS = [".mp4", ".webm", ".mov", ".ogg", ".ogv", ".m4v"];
1176
+ var isVideoUrl = (src) => {
1177
+ const path = src.split("?")[0].split("#")[0].toLowerCase();
1178
+ return VIDEO_EXTENSIONS.some((ext) => path.endsWith(ext));
1179
+ };
1180
+ var isVideoFile = (file) => file.type.startsWith("video/") || isVideoUrl(file.name);
1177
1181
  var MediaInput = (props) => {
1178
- const { onFilesChange, limit = 32, multiple = false, onError } = props;
1182
+ const {
1183
+ onFilesChange,
1184
+ limit = 32,
1185
+ multiple = false,
1186
+ onError,
1187
+ accept = MEDIA_FILE_ACCEPT
1188
+ } = props;
1179
1189
  const id = React25.useId();
1180
1190
  const [queue, setQueue] = React25.useState([]);
1181
1191
  const [sources, setSources] = React25.useState(props.files ?? []);
1192
+ const [videoUrls, setVideoUrls] = React25.useState({});
1182
1193
  const maxConcurrentUploads = 3;
1183
1194
  const uploadingCountRef = React25.useRef(0);
1184
1195
  const handleFilesAdd = async (e) => {
@@ -1228,6 +1239,9 @@ var MediaInput = (props) => {
1228
1239
  );
1229
1240
  continue;
1230
1241
  }
1242
+ if (isVideoFile(file)) {
1243
+ setVideoUrls((prev) => ({ ...prev, [url]: true }));
1244
+ }
1231
1245
  setSources((prev) => [...prev, url]);
1232
1246
  onFilesChange?.([...sources, url]);
1233
1247
  } catch (e2) {
@@ -1252,12 +1266,10 @@ var MediaInput = (props) => {
1252
1266
  });
1253
1267
  };
1254
1268
  return /* @__PURE__ */ React25.createElement("div", { className: cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React25.createElement(MediaInputItem, { key: src, className: cn("group", props.itemClassName) }, /* @__PURE__ */ React25.createElement(
1255
- Image,
1269
+ MediaPreview,
1256
1270
  {
1257
1271
  src,
1258
- alt: "",
1259
- fill: true,
1260
- className: "sb:absolute sb:inset-0 sb:object-cover sb:pointer-events-none"
1272
+ isVideo: !!videoUrls[src] || isVideoUrl(src)
1261
1273
  }
1262
1274
  ), /* @__PURE__ */ React25.createElement("div", { className: "sb:absolute sb:right-1 sb:top-1 sb:z-30 sb:flex sb:items-center sb:justify-end sb:gap-3 sb:opacity-0 sb:transition-opacity sb:group-hover:opacity-100" }, /* @__PURE__ */ React25.createElement(
1263
1275
  "button",
@@ -1293,7 +1305,7 @@ var MediaInput = (props) => {
1293
1305
  type: "file",
1294
1306
  onChange: handleFilesAdd,
1295
1307
  multiple,
1296
- accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
1308
+ accept,
1297
1309
  className: "sb:hidden"
1298
1310
  }
1299
1311
  )
@@ -1311,6 +1323,33 @@ var MediaInputItem = (props) => {
1311
1323
  props.children
1312
1324
  );
1313
1325
  };
1326
+ var MediaPreview = (props) => {
1327
+ const [kind, setKind] = React25.useState(
1328
+ props.isVideo ? "video" : "image"
1329
+ );
1330
+ if (kind === "video") {
1331
+ return /* @__PURE__ */ React25.createElement(
1332
+ "video",
1333
+ {
1334
+ src: props.src,
1335
+ muted: true,
1336
+ playsInline: true,
1337
+ preload: "metadata",
1338
+ className: "sb:absolute sb:inset-0 sb:h-full sb:w-full sb:object-cover sb:pointer-events-none"
1339
+ }
1340
+ );
1341
+ }
1342
+ return /* @__PURE__ */ React25.createElement(
1343
+ Image,
1344
+ {
1345
+ src: props.src,
1346
+ alt: "",
1347
+ fill: true,
1348
+ className: "sb:absolute sb:inset-0 sb:object-cover sb:pointer-events-none",
1349
+ onError: () => setKind("video")
1350
+ }
1351
+ );
1352
+ };
1314
1353
  var MediaInputError = class extends Error {
1315
1354
  title;
1316
1355
  description;
@@ -1782,6 +1821,7 @@ var BackgroundPicker = (props) => {
1782
1821
  className: "sb:grid sb:grid-cols-2 sb:gap-1",
1783
1822
  itemClassName: "sb:aspect-video sb:h-auto sb:w-full",
1784
1823
  multiple: false,
1824
+ accept: IMAGE_FILE_ACCEPT,
1785
1825
  onFilesChange: (files) => {
1786
1826
  if (!files.length)
1787
1827
  return;
@@ -2225,7 +2265,7 @@ var build_container_client_default = BuildContainerInner;
2225
2265
  var AddContentButton = (props) => {
2226
2266
  const components = builder.getComponents();
2227
2267
  const { addContent } = useBuilder();
2228
- return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb:p-1 sb:w-full sb:max-w-xl" }, /* @__PURE__ */ React25.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:gap-2" }, components.map((component) => {
2268
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb:p-1" }, /* @__PURE__ */ React25.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:gap-2" }, components.map((component) => {
2229
2269
  const Icon2 = component.icon ?? ImageIcon;
2230
2270
  return /* @__PURE__ */ React25.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25.createElement(
2231
2271
  Button,