@jbpark/live-editor 1.1.0 → 1.3.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/index.mjs CHANGED
@@ -1,18 +1,19 @@
1
- import { S as __toESM, _ as findEditableChildren, b as require_lib$1, c as extract, d as createNodeFromValue, f as extractNodeValue, g as generateCode, h as parseValue, i as replaceIds, l as nanoid, m as parseArrayExpression, n as clone, o as update, p as extractObjectProperties, r as fillIds, t as validateBindingValue, u as arrayExpressionToCode, v as getCurrentValue, x as require_lib, y as parseBinding } from "./ast-UXy9dqvD.mjs";
1
+ import { S as __toESM, _ as parseArrayExpression, b as require_lib$1, 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, x as require_lib, y as generateCode } from "./ast-fX6Whrjc.mjs";
2
2
  import { a as DRAGGABLE_ITEMS, i as DEFAULT_TEMPLATE, t as BINDING_PROP } from "./enums-3yleLgqV.mjs";
3
3
  import { a as detectTypeScript, c as getCachedScriptBlob, i as compile, l as preloadScripts, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as replaceSections } from "./utils-INSWI9h0.mjs";
4
4
  import { generateTailwindCSS } from "./utils/tailwind/index.mjs";
5
5
  import "@jbpark/ui-kit/style.css";
6
6
  import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
7
- import { Button, Card, Checkbox, ColorPicker, DatePicker, Input, Select, Space, Typography, Upload } from "@jbpark/ui-kit";
7
+ import { Button, Card, Checkbox, ColorPicker, DatePicker, Drawer, Input, Select, Space, 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";
10
10
  import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
11
11
  import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
12
+ import { useDebounce, useMultiSelect, useResponsiveSize } from "@jbpark/use-hooks";
13
+ import { AlertCircle, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bell, Bookmark, Calendar, Camera, Check, ChevronDown, ChevronRight, Clock, Copy, Download, Edit, Eye, Filter, Heart, Home, Image, Info, LayoutGrid, Link, Mail, Map as Map$1, Menu, MessageCircle, Phone, Plus, Search, Settings, Share, ShoppingCart, Star, Trash, Upload as Upload$1, User, X } from "lucide-react";
12
14
  import { v4 } from "uuid";
13
15
  import { createPortal } from "react-dom";
14
16
  import { CSS } from "@dnd-kit/utilities";
15
- import { AlertCircle, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bell, Bookmark, Calendar, Camera, Check, ChevronDown, ChevronRight, Clock, Copy, Download, Edit, Eye, Filter, Heart, Home, Image, Info, Link, Mail, Map as Map$1, Menu, MessageCircle, Phone, Plus, Search, Settings, Share, ShoppingCart, Star, Trash, Upload as Upload$1, User, X } from "lucide-react";
16
17
  import { javascript } from "@codemirror/lang-javascript";
17
18
  import { vscodeLight } from "@uiw/codemirror-theme-vscode";
18
19
  import CodeMirror from "@uiw/react-codemirror";
@@ -23,7 +24,6 @@ import prettierPluginTypeScript from "prettier/plugins/typescript";
23
24
  import Placeholder from "@tiptap/extension-placeholder";
24
25
  import { EditorContent, useEditor } from "@tiptap/react";
25
26
  import StarterKit from "@tiptap/starter-kit";
26
- import { useDebounce, useMultiSelect } from "@jbpark/use-hooks";
27
27
 
28
28
  //#region src/components/context/states.ts
29
29
  const PreviewContext = createContext({
@@ -12571,6 +12571,9 @@ const conditionalModifiers = (args) => {
12571
12571
  };
12572
12572
  const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, className, items = [], frame, provider, ...restProps }) => {
12573
12573
  const [selectedId, setSelectedId] = useState(null);
12574
+ const [mobilePaletteOpen, setMobilePaletteOpen] = useState(false);
12575
+ const { breakpoint } = useResponsiveSize();
12576
+ const isMobile = breakpoint.current === "xs" || breakpoint.current === "sm";
12574
12577
  const { setCode } = usePreview();
12575
12578
  const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 10 } }));
12576
12579
  const value = _value || DEFAULT_TEMPLATE;
@@ -12665,6 +12668,14 @@ const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, classNam
12665
12668
  useEffect(() => {
12666
12669
  if (frame?.scripts?.length) preloadScripts(frame.scripts);
12667
12670
  }, [frame?.scripts]);
12671
+ const renderPaletteItems = (onAdd) => /* @__PURE__ */ jsx(Space, {
12672
+ orientation: "vertical",
12673
+ align: "start",
12674
+ children: (items?.length ? items : DRAGGABLE_ITEMS).map((item) => /* @__PURE__ */ jsx(Draggable, {
12675
+ item,
12676
+ onAdd
12677
+ }, item.id))
12678
+ });
12668
12679
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DndContext, {
12669
12680
  sensors,
12670
12681
  collisionDetection: closestCenter,
@@ -12673,25 +12684,18 @@ const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, classNam
12673
12684
  onDragOver,
12674
12685
  onDragEnd,
12675
12686
  children: [/* @__PURE__ */ jsxs("div", {
12676
- className: cn("flex w-full", className),
12687
+ className: cn("relative flex w-full", className),
12677
12688
  ...restProps,
12678
12689
  children: [
12679
12690
  /* @__PURE__ */ jsx("div", {
12680
- className: "w-1/5 overflow-y-auto",
12691
+ className: "hidden w-1/5 overflow-y-auto md:block",
12681
12692
  children: /* @__PURE__ */ jsx("div", {
12682
12693
  className: "h-full bg-gray-50 p-4",
12683
- children: /* @__PURE__ */ jsx(Space, {
12684
- orientation: "vertical",
12685
- align: "start",
12686
- children: (items?.length ? items : DRAGGABLE_ITEMS).map((item) => /* @__PURE__ */ jsx(Draggable, {
12687
- item,
12688
- onAdd: addItem
12689
- }, item.id))
12690
- })
12694
+ children: renderPaletteItems(addItem)
12691
12695
  })
12692
12696
  }),
12693
12697
  /* @__PURE__ */ jsx("div", {
12694
- className: cn("relative", "h-full w-3/5", "overflow-y-auto"),
12698
+ className: cn("relative", "h-full w-full md:w-3/5", "overflow-y-auto"),
12695
12699
  "data-frame-container": true,
12696
12700
  style: {
12697
12701
  isolation: "isolate",
@@ -12730,7 +12734,37 @@ const Dnd = ({ value: _value, props, modules = {}, onChange: _onChange, classNam
12730
12734
  })
12731
12735
  }),
12732
12736
  /* @__PURE__ */ jsx("div", {
12733
- className: "w-1/5",
12737
+ className: "hidden w-1/5 md:block",
12738
+ children: /* @__PURE__ */ jsx(Panel, {
12739
+ item: sections.find((s) => s.id === selectedId),
12740
+ onChange
12741
+ })
12742
+ }),
12743
+ /* @__PURE__ */ jsx(Button, {
12744
+ type: "primary",
12745
+ shape: "circle",
12746
+ icon: /* @__PURE__ */ jsx(LayoutGrid, {}),
12747
+ "aria-label": "Components",
12748
+ className: "fixed right-4 bottom-4 z-20 md:hidden",
12749
+ onClick: () => setMobilePaletteOpen(true)
12750
+ }),
12751
+ /* @__PURE__ */ jsx(Drawer, {
12752
+ open: isMobile && mobilePaletteOpen,
12753
+ onClose: () => setMobilePaletteOpen(false),
12754
+ direction: "bottom",
12755
+ size: "large",
12756
+ title: "Components",
12757
+ children: renderPaletteItems((item) => {
12758
+ addItem(item);
12759
+ setMobilePaletteOpen(false);
12760
+ })
12761
+ }),
12762
+ /* @__PURE__ */ jsx(Drawer, {
12763
+ open: isMobile && Boolean(selectedId),
12764
+ onClose: () => setSelectedId(null),
12765
+ direction: "bottom",
12766
+ size: "large",
12767
+ title: "Properties",
12734
12768
  children: /* @__PURE__ */ jsx(Panel, {
12735
12769
  item: sections.find((s) => s.id === selectedId),
12736
12770
  onChange