@jbpark/live-editor 1.5.0 → 1.7.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.
- package/dist/{ast-DyDLUN5F.mjs → ast-DxgO-X_f.mjs} +122 -93
- package/dist/ast-DxgO-X_f.mjs.map +1 -0
- package/dist/{document-BGG0pNR2.mjs → document-kU_tXfS_.mjs} +73 -76
- package/dist/document-kU_tXfS_.mjs.map +1 -0
- package/dist/index.mjs +23 -19
- package/dist/index.mjs.map +1 -1
- package/dist/utils/ast/index.d.mts +3 -1
- package/dist/utils/ast/index.mjs +3 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/index.mjs +3 -3
- package/dist/{utils-UTqUJaVs.mjs → utils-qt78kxvP.mjs} +6 -3
- package/dist/{utils-UTqUJaVs.mjs.map → utils-qt78kxvP.mjs.map} +1 -1
- package/package.json +2 -1
- package/dist/ast-DyDLUN5F.mjs.map +0 -1
- package/dist/document-BGG0pNR2.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as detectTypeScript, c as
|
|
3
|
-
import { _ as parseArrayExpression, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, l as nanoid, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, t as validateBindingValue, u as findEditableChildren, v as parseValue } from "./ast-
|
|
1
|
+
import { _ as DRAGGABLE_ITEMS, b as __toESM, d as require_lib$1, f as require_lib, g as DEFAULT_TEMPLATE, p as BINDING_PROP } from "./document-kU_tXfS_.mjs";
|
|
2
|
+
import { a as detectTypeScript, c as generateSections, d as replaceSections, i as compile, l as getCachedScriptBlob, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as preloadScripts } from "./utils-qt78kxvP.mjs";
|
|
3
|
+
import { _ as parseArrayExpression, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, l as nanoid, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, t as validateBindingValue, u as findEditableChildren, v as parseValue, y as generateCode } from "./ast-DxgO-X_f.mjs";
|
|
4
4
|
import { generateTailwindCSS } from "./utils/tailwind/index.mjs";
|
|
5
5
|
import "@jbpark/ui-kit/style.css";
|
|
6
|
-
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import React, { createContext, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { Button, Card, Checkbox, ColorPicker, DatePicker, Drawer, Input, Select, Space, Toast, Typography, Upload } from "@jbpark/ui-kit";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { DndContext, DragOverlay, PointerSensor, closestCenter, useDndContext, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -397,13 +397,12 @@ const Droppable = ({ children, className }) => {
|
|
|
397
397
|
|
|
398
398
|
//#endregion
|
|
399
399
|
//#region src/components/dnd/renderer.tsx
|
|
400
|
-
const Renderer = ({
|
|
400
|
+
const Renderer = ({ preview, headers, modules, frame, provider }) => {
|
|
401
401
|
const memoizedModules = useMemo(() => ({
|
|
402
402
|
...baseModules,
|
|
403
403
|
...modules
|
|
404
404
|
}), [modules]);
|
|
405
|
-
const
|
|
406
|
-
const module = useMemo(() => compile(memoizedSection, memoizedModules), [memoizedSection, memoizedModules]);
|
|
405
|
+
const module = useMemo(() => compile(preview, memoizedModules), [preview, memoizedModules]);
|
|
407
406
|
const renderProvider = (component) => {
|
|
408
407
|
return provider ? provider(component) : component;
|
|
409
408
|
};
|
|
@@ -422,6 +421,7 @@ const Renderer = ({ fullCode, code, headers, modules, frame, provider }) => {
|
|
|
422
421
|
})
|
|
423
422
|
});
|
|
424
423
|
};
|
|
424
|
+
var renderer_default = memo(Renderer);
|
|
425
425
|
|
|
426
426
|
//#endregion
|
|
427
427
|
//#region src/components/dnd/sortable.tsx
|
|
@@ -477,14 +477,18 @@ const Overlay = ({ sections, renderProps }) => {
|
|
|
477
477
|
return /* @__PURE__ */ jsx(Draggable, { item });
|
|
478
478
|
}
|
|
479
479
|
const section = sections.find((s) => s.id === active.id);
|
|
480
|
-
if (section)
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
480
|
+
if (section) {
|
|
481
|
+
const preview = generateSection(section.code, renderProps.fullCode);
|
|
482
|
+
return /* @__PURE__ */ jsx(Sortable, {
|
|
483
|
+
id: section.id,
|
|
484
|
+
name: section.name,
|
|
485
|
+
children: /* @__PURE__ */ jsx(renderer_default, {
|
|
486
|
+
preview,
|
|
487
|
+
modules: renderProps.modules,
|
|
488
|
+
frame: renderProps.frame
|
|
489
|
+
})
|
|
490
|
+
});
|
|
491
|
+
}
|
|
488
492
|
return null;
|
|
489
493
|
};
|
|
490
494
|
|
|
@@ -12624,6 +12628,7 @@ const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, classNam
|
|
|
12624
12628
|
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 10 } }));
|
|
12625
12629
|
const value = _value || DEFAULT_TEMPLATE;
|
|
12626
12630
|
const sections = useMemo(() => extractSections(value), [value]);
|
|
12631
|
+
const previews = useMemo(() => generateSections(sections.map((s) => s.code), value), [sections, value]);
|
|
12627
12632
|
const onDragStart = (_) => {};
|
|
12628
12633
|
const onDragOver = (_e) => {};
|
|
12629
12634
|
const onDragEnd = (event) => {
|
|
@@ -12760,16 +12765,15 @@ const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, classNam
|
|
|
12760
12765
|
}) : /* @__PURE__ */ jsx(SortableContext, {
|
|
12761
12766
|
items: sections.map((s) => s.id),
|
|
12762
12767
|
strategy: verticalListSortingStrategy,
|
|
12763
|
-
children: sections.map((section) => /* @__PURE__ */ jsx(Sortable, {
|
|
12768
|
+
children: sections.map((section, index) => /* @__PURE__ */ jsx(Sortable, {
|
|
12764
12769
|
id: section.id,
|
|
12765
12770
|
name: section.name,
|
|
12766
12771
|
selected: selectedId === section.id,
|
|
12767
12772
|
onClick: () => onSelect(section.id),
|
|
12768
12773
|
onDelete,
|
|
12769
12774
|
onCopy,
|
|
12770
|
-
children: /* @__PURE__ */ jsx(
|
|
12771
|
-
|
|
12772
|
-
code: section.code,
|
|
12775
|
+
children: /* @__PURE__ */ jsx(renderer_default, {
|
|
12776
|
+
preview: previews[index],
|
|
12773
12777
|
modules,
|
|
12774
12778
|
frame,
|
|
12775
12779
|
provider,
|