@jbpark/live-editor 3.2.1 → 4.0.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 (49) hide show
  1. package/dist/ast-CZwpVrJv.js +851 -0
  2. package/dist/ast-CZwpVrJv.js.map +1 -0
  3. package/dist/{boundary-BTP1nfG6.js → boundary-C90q3YsT.js} +8 -7
  4. package/dist/boundary-C90q3YsT.js.map +1 -0
  5. package/dist/{context-649REFsj.js → context-Y-M9fViD.js} +4 -8
  6. package/dist/context-Y-M9fViD.js.map +1 -0
  7. package/dist/{core-D3q5rpuz.js → core-Co8Nlq16.js} +2 -2
  8. package/dist/{core-D3q5rpuz.js.map → core-Co8Nlq16.js.map} +1 -1
  9. package/dist/dnd/index.d.ts +2 -2
  10. package/dist/dnd/index.js +2 -2
  11. package/dist/{dnd-D90jLjLH.js → dnd-ClnGRNaY.js} +353 -319
  12. package/dist/dnd-ClnGRNaY.js.map +1 -0
  13. package/dist/editor/index.js +2 -2
  14. package/dist/{editor-LzqHe_-F.js → editor-COKGtmfE.js} +3 -3
  15. package/dist/{editor-LzqHe_-F.js.map → editor-COKGtmfE.js.map} +1 -1
  16. package/dist/error/index.d.ts +1 -1
  17. package/dist/error/index.js +2 -2
  18. package/dist/{error-CO0EbMlA.js → error-o0SBwtTv.js} +2 -2
  19. package/dist/{error-CO0EbMlA.js.map → error-o0SBwtTv.js.map} +1 -1
  20. package/dist/{document-C6bNHl7l.js → extract-abHYmNsu.js} +927 -42
  21. package/dist/extract-abHYmNsu.js.map +1 -0
  22. package/dist/{index-DxbG789f.d.ts → index-B_p74BRM.d.ts} +29 -14
  23. package/dist/{index-CCynrS6c.d.ts → index-DNNj_0ba.d.ts} +3 -2
  24. package/dist/{index-lgHdCda5.d.ts → index-DQkL37eL.d.ts} +10 -2
  25. package/dist/{index-DswWDEXZ.d.ts → index-Doh4VTXr.d.ts} +65 -35
  26. package/dist/index.d.ts +6 -6
  27. package/dist/index.js +5 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/preview/index.d.ts +2 -2
  30. package/dist/preview/index.js +3 -2
  31. package/dist/{preview-CWT0lgwq.js → preview-DKyKKcu7.js} +4 -4
  32. package/dist/{preview-CWT0lgwq.js.map → preview-DKyKKcu7.js.map} +1 -1
  33. package/dist/provider/index.js +1 -1
  34. package/dist/{use-dynamic-tailwind-DAhKGsY4.js → use-dynamic-tailwind-BF8TQ3Yy.js} +83 -27
  35. package/dist/use-dynamic-tailwind-BF8TQ3Yy.js.map +1 -0
  36. package/dist/utils/ast/index.d.ts +2 -2
  37. package/dist/utils/ast/index.js +3 -3
  38. package/dist/utils/index.d.ts +4 -7
  39. package/dist/utils/index.js +3 -3
  40. package/dist/{utils-WyxPYZGh.js → utils-BQ7WL7Jh.js} +33 -16
  41. package/dist/{utils-WyxPYZGh.js.map → utils-BQ7WL7Jh.js.map} +1 -1
  42. package/package.json +3 -1
  43. package/dist/ast-Bx2Avo4d.js +0 -1530
  44. package/dist/ast-Bx2Avo4d.js.map +0 -1
  45. package/dist/boundary-BTP1nfG6.js.map +0 -1
  46. package/dist/context-649REFsj.js.map +0 -1
  47. package/dist/dnd-D90jLjLH.js.map +0 -1
  48. package/dist/document-C6bNHl7l.js.map +0 -1
  49. package/dist/use-dynamic-tailwind-DAhKGsY4.js.map +0 -1
@@ -31,21 +31,17 @@ interface BindingOption {
31
31
  label: string;
32
32
  value: string;
33
33
  }
34
- declare const BINDING_TYPES: readonly ["array", "object", "string", "number", "boolean", "color", "jsx", "richtext", "date", "url", "icon-picker", "asset-picker"];
34
+ declare const BINDING_TYPES: readonly ["array", "object", "string", "number", "boolean", "color", "jsx", "richtext", "date", "url"];
35
35
  type BindingType = (typeof BINDING_TYPES)[number];
36
- interface BindingRenderLeaf {
37
- type?: BindingType;
38
- property?: string;
39
- render?: BindingRenderMap;
40
- }
41
- interface BindingRenderMap {
42
- [key: string]: BindingRenderLeaf | BindingRenderMap;
36
+ interface BindingWidget {
37
+ type: string;
38
+ step?: number;
39
+ unit?: string;
40
+ [key: string]: unknown;
43
41
  }
44
- interface BindingItem {
45
- label: string;
46
- property: string;
42
+ interface BindingFieldSpec {
47
43
  type?: BindingType;
48
- widget?: string;
44
+ widget?: BindingWidget;
49
45
  options?: BindingOption[];
50
46
  render?: BindingRenderMap;
51
47
  min?: number;
@@ -54,6 +50,17 @@ interface BindingItem {
54
50
  required?: boolean;
55
51
  meta?: Record<string, unknown>;
56
52
  }
53
+ interface BindingRenderLeaf extends BindingFieldSpec {
54
+ label?: string;
55
+ property?: string;
56
+ }
57
+ interface BindingRenderMap {
58
+ [key: string]: BindingRenderLeaf | BindingRenderMap;
59
+ }
60
+ interface BindingItem extends BindingFieldSpec {
61
+ label: string;
62
+ property: string;
63
+ }
57
64
  type NodeValueType = 'boolean' | 'number' | 'string' | 'null' | 'array' | 'object' | 'unknown';
58
65
  type EditableNodeValueType = 'boolean' | 'number' | 'string' | 'null';
59
66
  interface ExtractedNodeValue {
@@ -69,6 +76,7 @@ declare const getStructuredValue: (node: DataAttrNode, property: string, type?:
69
76
  declare const findEditableChildren: (node: DataAttrNode) => DataAttrNode[];
70
77
  //#endregion
71
78
  //#region src/utils/ast/value.d.ts
79
+ declare const canLosslesslyEvaluateSource: (source: string) => boolean;
72
80
  declare const parseValue: (value: unknown) => unknown;
73
81
  type EditablePathSegment = string | number;
74
82
  type EditablePrimitive = string | number | boolean;
@@ -134,6 +142,10 @@ type UpdateFailure = {
134
142
  reason: 'attribute-not-found';
135
143
  dataId: string;
136
144
  property: string;
145
+ } | {
146
+ reason: 'unsupported-syntax';
147
+ dataId: string;
148
+ property: string;
137
149
  } | {
138
150
  reason: 'parse-error';
139
151
  error: unknown;
@@ -174,6 +186,9 @@ interface ChildrenEdit {
174
186
  }
175
187
  declare const getChildrenSignatures: (nodes: DataAttrNode[]) => string[];
176
188
  //#endregion
189
+ //#region src/utils/ast/array-source.d.ts
190
+ declare const canStructurallyEditArray: (source: string) => boolean;
191
+ //#endregion
177
192
  //#region node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser/typings/babel-parser.d.ts
178
193
  declare class Position {
179
194
  line: number;
@@ -212,5 +227,5 @@ interface ValidationResult {
212
227
  }
213
228
  declare const validateBindingValue: (binding: BindingItem, value: unknown) => ValidationResult;
214
229
  //#endregion
215
- export { createNodeFromValue as A, parseBinding as B, updateArrayItemProperty as C, EditablePrimitive as D, EditablePathSegment as E, parseValue as F, BindingRenderMap as G, BindingItem as H, setEditableValue as I, EditableNodeValueType as J, BindingType as K, findEditableChildren as L, extractObjectProperties as M, flattenEditableValue as N, EditableValueEntry as O, parseArrayExpression as P, getCurrentValue as R, removeArrayItems as S, generateCode as T, BindingOption as U, parseBindingExpression as V, BindingRenderLeaf as W, NodeValueType as X, ExtractedNodeValue as Y, appendArrayItem as _, replaceIds as a, moveArrayItems as b, getChildrenSignatures as c, bulkUpdate as d, update as f, ItemKind as g, ArrayItem as h, fillIds as i, extractNodeValue as j, arrayExpressionToCode as k, UpdateFailure as l, extract as m, validateBindingValue as n, ChildrenAction as o, clearExtractCache as p, DataAttrNode as q, clone as r, ChildrenEdit as s, ValidationResult as t, UpdateResult as u, duplicateArrayItems as v, updateArrayItemValue as w, parseItems as x, moveArrayItem as y, getStructuredValue as z };
216
- //# sourceMappingURL=index-DxbG789f.d.ts.map
230
+ export { ExtractedNodeValue as $, arrayExpressionToCode as A, getCurrentValue as B, removeArrayItems as C, EditablePathSegment as D, generateCode as E, flattenEditableValue as F, BindingItem as G, parseBinding as H, parseArrayExpression as I, BindingRenderMap as J, BindingOption as K, parseValue as L, createNodeFromValue as M, extractNodeValue as N, EditablePrimitive as O, extractObjectProperties as P, EditableNodeValueType as Q, setEditableValue as R, parseItems as S, updateArrayItemValue as T, parseBindingExpression as U, getStructuredValue as V, BindingFieldSpec as W, BindingWidget as X, BindingType as Y, DataAttrNode as Z, ItemKind as _, replaceIds as a, moveArrayItem as b, ChildrenEdit as c, UpdateResult as d, NodeValueType as et, bulkUpdate as f, ArrayItem as g, extract as h, fillIds as i, canLosslesslyEvaluateSource as j, EditableValueEntry as k, getChildrenSignatures as l, clearExtractCache as m, validateBindingValue as n, canStructurallyEditArray as o, update as p, BindingRenderLeaf as q, clone as r, ChildrenAction as s, ValidationResult as t, UpdateFailure as u, appendArrayItem as v, updateArrayItemProperty as w, moveArrayItems as x, duplicateArrayItems as y, findEditableChildren as z };
231
+ //# sourceMappingURL=index-B_p74BRM.d.ts.map
@@ -2,7 +2,7 @@ import React$1 from "react";
2
2
  //#region src/components/error/boundary.d.ts
3
3
  interface Props$3 {
4
4
  children: React$1.ReactNode;
5
- fallback?: (message?: string) => React$1.ReactNode;
5
+ fallback?: (message?: string, reset?: () => void) => React$1.ReactNode;
6
6
  onError?: (e: Error, info: React$1.ErrorInfo) => void;
7
7
  resetKeys?: readonly unknown[];
8
8
  }
@@ -15,6 +15,7 @@ declare class ErrorBoundary extends React$1.Component<Props$3, State> {
15
15
  static getDerivedStateFromError(error: Error): State;
16
16
  componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
17
17
  componentDidUpdate(prevProps: Props$3): void;
18
+ reset: () => void;
18
19
  render(): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | React$1.JSX.Element | null | undefined;
19
20
  }
20
21
  //#endregion
@@ -49,4 +50,4 @@ type ErrorComponent = typeof Error$2 & {
49
50
  declare const Error$1: ErrorComponent;
50
51
  //#endregion
51
52
  export { Props$1 as a, Guard as i, Props as n, Props$2 as o, Runtime as r, ErrorBoundary as s, Error$1 as t };
52
- //# sourceMappingURL=index-CCynrS6c.d.ts.map
53
+ //# sourceMappingURL=index-DNNj_0ba.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import { t as FrameProps } from "./index-DpDU1IAw.js";
2
2
  import React from "react";
3
+ import * as ui from "@jbpark/ui-kit";
4
+ import * as utils from "@jbpark/ui-kit/utils";
3
5
  //#region src/components/preview/preview.d.ts
4
6
  interface Props extends React.ComponentPropsWithRef<'div'> {
5
7
  code?: string;
@@ -13,5 +15,11 @@ interface Props extends React.ComponentPropsWithRef<'div'> {
13
15
  }
14
16
  declare const Preview: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props) => React.JSX.Element;
15
17
  //#endregion
16
- export { Props as n, Preview as t };
17
- //# sourceMappingURL=index-lgHdCda5.d.ts.map
18
+ //#region src/components/preview/base-modules.d.ts
19
+ declare const baseModules: {
20
+ 'ui-kit': typeof ui;
21
+ 'ui-kit/utils': typeof utils;
22
+ };
23
+ //#endregion
24
+ export { Preview as n, Props as r, baseModules as t };
25
+ //# sourceMappingURL=index-DQkL37eL.d.ts.map
@@ -1,13 +1,37 @@
1
1
  import { v as Section } from "./document-J9Lo9p81.js";
2
- import { G as BindingRenderMap, K as BindingType, U as BindingOption, q as DataAttrNode } from "./index-DxbG789f.js";
3
2
  import { t as FrameProps } from "./index-DpDU1IAw.js";
3
+ import { J as BindingRenderMap, K as BindingOption, X as BindingWidget, Y as BindingType, Z as DataAttrNode, u as UpdateFailure } from "./index-B_p74BRM.js";
4
4
  import { useMultiSelect } from "@jbpark/use-hooks";
5
- import { LucideIcon } from "lucide-react";
6
- //#region src/components/dnd/dnd.d.ts
7
- interface DndPalette {
8
- items: Section[];
9
- onAdd: (item: Section) => void;
5
+ //#region src/components/dnd/panel/field.d.ts
6
+ interface FieldProps {
7
+ binding: PanelBinding;
8
+ onNodeChange?: PanelNodeChange;
10
9
  }
10
+ declare const Field: (props: FieldProps) => import("react").JSX.Element;
11
+ //#endregion
12
+ //#region src/components/dnd/edit-options.d.ts
13
+ type DndEditError = {
14
+ type: 'update';
15
+ id: string;
16
+ label: string;
17
+ property: string;
18
+ failure: UpdateFailure | undefined;
19
+ title: string;
20
+ description?: string;
21
+ } | {
22
+ type: 'parse';
23
+ target: 'section' | 'items';
24
+ error?: unknown;
25
+ title: string;
26
+ description?: string;
27
+ } | {
28
+ type: 'items';
29
+ title: string;
30
+ description?: string;
31
+ };
32
+ type DndRenderField = (props: FieldProps, builtin: React.ReactElement) => React.ReactNode | undefined;
33
+ //#endregion
34
+ //#region src/components/dnd/panel-binding.d.ts
11
35
  interface PanelNodeChange {
12
36
  (params: {
13
37
  id: string;
@@ -16,23 +40,12 @@ interface PanelNodeChange {
16
40
  value: unknown;
17
41
  }): void;
18
42
  }
19
- interface DndPanel {
20
- item?: Section;
21
- onChange: (next: Partial<Section>) => void;
22
- onDelete: (id: string) => void;
23
- onMoveUp: () => void;
24
- onMoveDown: () => void;
25
- canMoveUp: boolean;
26
- canMoveDown: boolean;
27
- bindings: PanelBinding[];
28
- onNodeChange: PanelNodeChange;
29
- }
30
43
  interface PanelBinding {
31
44
  id: string;
32
45
  label: string;
33
46
  property: string;
34
47
  type?: BindingType;
35
- widget?: string;
48
+ widget?: BindingWidget;
36
49
  options?: BindingOption[];
37
50
  render?: BindingRenderMap;
38
51
  min?: number;
@@ -42,8 +55,34 @@ interface PanelBinding {
42
55
  meta?: Record<string, unknown>;
43
56
  value: unknown;
44
57
  rawValue: string;
58
+ canEditValue?: boolean;
45
59
  onChange: (value: unknown) => void;
46
60
  }
61
+ //#endregion
62
+ //#region src/components/dnd/section-fallback-context.d.ts
63
+ interface DndSectionFallbackArgs {
64
+ section: Section;
65
+ reason: 'compile' | 'runtime' | 'forced';
66
+ message?: string;
67
+ }
68
+ type DndRenderSectionFallback = (args: DndSectionFallbackArgs) => React.ReactNode | undefined;
69
+ //#endregion
70
+ //#region src/components/dnd/dnd.d.ts
71
+ interface DndPalette {
72
+ items: Section[];
73
+ onAdd: (item: Section) => void;
74
+ }
75
+ interface DndPanel {
76
+ item?: Section;
77
+ onChange: (next: Partial<Section>) => void;
78
+ onDelete: (id: string) => void;
79
+ onMoveUp: () => void;
80
+ onMoveDown: () => void;
81
+ canMoveUp: boolean;
82
+ canMoveDown: boolean;
83
+ bindings: PanelBinding[];
84
+ onNodeChange: PanelNodeChange;
85
+ }
47
86
  interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
48
87
  value?: string;
49
88
  props?: Record<string, unknown>;
@@ -53,9 +92,13 @@ interface Props extends Omit<React.ComponentPropsWithRef<'div'>, 'onChange'> {
53
92
  dynamicTailwind?: boolean;
54
93
  provider?: (children: React.ReactNode) => React.ReactNode;
55
94
  onChange?: (value: string) => void;
95
+ renderField?: DndRenderField;
96
+ onEditError?: (error: DndEditError) => void;
97
+ renderSectionFallback?: DndRenderSectionFallback;
98
+ shouldForceSectionFallback?: (section: Section) => boolean;
56
99
  children?: React.ReactNode;
57
100
  }
58
- declare const Dnd$1: ({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, children, ...restProps }: Props) => import("react").JSX.Element;
101
+ declare const Dnd$1: ({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, children, ...restProps }: Props) => import("react").JSX.Element;
59
102
  //#endregion
60
103
  //#region src/components/dnd/draggable.d.ts
61
104
  interface DraggableItemDragState {
@@ -92,20 +135,6 @@ declare const useDndPalette: () => DndPalette;
92
135
  declare const useDndPanel: () => DndPanel;
93
136
  declare const useDndLayout: () => DndLayout;
94
137
  //#endregion
95
- //#region src/components/dnd/panel/field.d.ts
96
- interface FieldProps {
97
- binding: PanelBinding;
98
- onNodeChange?: PanelNodeChange;
99
- }
100
- declare const Field: ({ binding, onNodeChange }: FieldProps) => import("react").JSX.Element;
101
- //#endregion
102
- //#region src/components/dnd/panel/icon-map.d.ts
103
- declare const ICON_MAP: Record<string, LucideIcon>;
104
- declare const ICON_OPTIONS: {
105
- label: import("react").JSX.Element;
106
- value: string;
107
- }[];
108
- //#endregion
109
138
  //#region src/components/dnd/panel/use-items-editor.d.ts
110
139
  interface ItemsEditorNestedElement {
111
140
  id: string;
@@ -138,6 +167,7 @@ interface ItemsEditor {
138
167
  items: ItemsEditorItem[];
139
168
  selection: ReturnType<typeof useMultiSelect>;
140
169
  actions: ItemsEditorActions;
170
+ canEditStructure: boolean;
141
171
  parseError: boolean;
142
172
  }
143
173
  interface ItemsEditorOptions {
@@ -182,5 +212,5 @@ type DndComponent = typeof Dnd$1 & {
182
212
  };
183
213
  declare const Dnd: DndComponent;
184
214
  //#endregion
185
- export { DndPanel as A, Layout as C, DraggableItemDragState as D, DraggableItem as E, PanelNodeChange as M, Props as N, DraggableItemProps as O, DndRegionProps as S, Panel as T, useDndLayout as _, ItemsEditor as a, Canvas as b, ItemsEditorNestedElement as c, useItemsEditor as d, ICON_MAP as f, DndLayout as g, FieldProps as h, useChildrenEditor as i, PanelBinding as j, DndPalette as k, ItemsEditorNestedGroup as l, Field as m, ChildrenEditor as n, ItemsEditorActions as o, ICON_OPTIONS as p, ChildrenEditorOptions as r, ItemsEditorItem as s, Dnd as t, ItemsEditorOptions as u, useDndPalette as v, Palette as w, DndLayoutProps as x, useDndPanel as y };
186
- //# sourceMappingURL=index-DswWDEXZ.d.ts.map
215
+ export { PanelBinding as A, DraggableItemDragState as C, Props as D, DndPanel as E, FieldProps as F, DndEditError as M, DndRenderField as N, DndRenderSectionFallback as O, Field as P, DraggableItem as S, DndPalette as T, DndLayoutProps as _, ItemsEditor as a, Palette as b, ItemsEditorNestedElement as c, useItemsEditor as d, DndLayout as f, Canvas as g, useDndPanel as h, useChildrenEditor as i, PanelNodeChange as j, DndSectionFallbackArgs as k, ItemsEditorNestedGroup as l, useDndPalette as m, ChildrenEditor as n, ItemsEditorActions as o, useDndLayout as p, ChildrenEditorOptions as r, ItemsEditorItem as s, Dnd as t, ItemsEditorOptions as u, DndRegionProps as v, DraggableItemProps as w, Panel as x, Layout as y };
216
+ //# sourceMappingURL=index-Doh4VTXr.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { v as Section } from "./document-J9Lo9p81.js";
2
2
  import { t as FrameProps } from "./index-DpDU1IAw.js";
3
- import { A as DndPanel, C as Layout, M as PanelNodeChange, N as Props, O as DraggableItemProps, T as Panel, a as ItemsEditor, b as Canvas, g as DndLayout, h as FieldProps, j as PanelBinding, k as DndPalette, s as ItemsEditorItem, t as Dnd, u as ItemsEditorOptions, w as Palette } from "./index-DswWDEXZ.js";
3
+ import { A as PanelBinding, D as Props, E as DndPanel, F as FieldProps, M as DndEditError, N as DndRenderField, O as DndRenderSectionFallback, T as DndPalette, a as ItemsEditor, b as Palette, f as DndLayout, g as Canvas, j as PanelNodeChange, k as DndSectionFallbackArgs, s as ItemsEditorItem, t as Dnd, u as ItemsEditorOptions, w as DraggableItemProps, x as Panel, y as Layout } from "./index-Doh4VTXr.js";
4
4
  import { a as Props$2, n as EditorRenderData, r as Props$1, t as Editor } from "./index-BQdZ6LrR.js";
5
- import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-CCynrS6c.js";
6
- import { n as Props$6, t as Preview } from "./index-lgHdCda5.js";
5
+ import { a as Props$5, n as Props$4, o as Props$3, s as ErrorBoundary, t as Error } from "./index-DNNj_0ba.js";
6
+ import { n as Preview, r as Props$6 } from "./index-DQkL37eL.js";
7
7
  //#region src/index.d.ts
8
8
  declare const App: {
9
9
  ({ children }: {
@@ -19,9 +19,9 @@ declare const App: {
19
19
  Editor: (({ defaultValue, value: _value, debounce, onChange: _onChange, renderEditor, fragment, prettierOptions, ...props }: Props$1) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined) & {
20
20
  Core: ({ value, theme, height, className, prettierOptions, fragment, raw, onChange, onSave, onError, ...props }: Props$2) => import("react").JSX.Element;
21
21
  };
22
- Dnd: (({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, children, ...restProps }: Props) => import("react").JSX.Element) & {
22
+ Dnd: (({ value: _value, props, modules, onChange: _onChange, className, items, frame, dynamicTailwind, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, children, ...restProps }: Props) => import("react").JSX.Element) & {
23
23
  DraggableItem: ({ item, children }: DraggableItemProps) => import("react").ReactNode;
24
- Field: ({ binding, onNodeChange }: FieldProps) => import("react").JSX.Element;
24
+ Field: (props: FieldProps) => import("react").JSX.Element;
25
25
  Palette: typeof Palette;
26
26
  Canvas: typeof Canvas;
27
27
  Panel: typeof Panel;
@@ -30,5 +30,5 @@ declare const App: {
30
30
  };
31
31
  declare const LiveRenderer: ({ code, props, modules, dynamicTailwind, provider, ...restProps }: Props$6) => import("react").JSX.Element;
32
32
  //#endregion
33
- export { type DndLayout, type DndPalette, type DndPanel, type EditorRenderData, type FieldProps, type FrameProps, type ItemsEditor, type ItemsEditorItem, type ItemsEditorOptions, Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, type PanelBinding, type PanelNodeChange, type Section };
33
+ export { type DndEditError, type DndLayout, type DndPalette, type DndPanel, type DndRenderField, type DndRenderSectionFallback, type DndSectionFallbackArgs, type EditorRenderData, type FieldProps, type FrameProps, type ItemsEditor, type ItemsEditorItem, type ItemsEditorOptions, Dnd as LiveDnd, Editor as LiveEditor, Error as LiveError, Preview as LivePreview, App as LiveProvider, App as default, LiveRenderer, type PanelBinding, type PanelNodeChange, type Section };
34
34
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { t as ContextProvider } from "./context-649REFsj.js";
2
- import { t as Dnd } from "./dnd-D90jLjLH.js";
3
- import { t as Editor } from "./editor-LzqHe_-F.js";
4
- import { t as Error } from "./error-CO0EbMlA.js";
5
- import { t as Preview } from "./preview-CWT0lgwq.js";
1
+ import { t as ContextProvider } from "./context-Y-M9fViD.js";
2
+ import { t as Dnd } from "./dnd-ClnGRNaY.js";
3
+ import { t as Editor } from "./editor-COKGtmfE.js";
4
+ import { t as Error } from "./error-o0SBwtTv.js";
5
+ import { t as Preview } from "./preview-DKyKKcu7.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  //#region src/index.tsx
8
8
  const App = ({ children }) => {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Context","LivePreview","LiveError","LiveEditor","LiveDnd"],"sources":["../src/index.tsx"],"sourcesContent":["import './index.css';\n\nimport Context from './components/context';\nimport LiveDnd, {\n type DndLayout,\n type DndPalette,\n type DndPanel,\n type FieldProps,\n type ItemsEditor,\n type ItemsEditorItem,\n type ItemsEditorOptions,\n type PanelBinding,\n type PanelNodeChange,\n} from './components/dnd';\nimport LiveEditor, { type EditorRenderData } from './components/editor';\nimport LiveError from './components/error';\nimport { type FrameProps } from './components/frame';\nimport LivePreview from './components/preview';\nimport type { Section } from './types';\n\nconst App = ({ children }: { children?: React.ReactNode }) => {\n return <Context>{children}</Context>;\n};\n\nconst LiveRenderer = LivePreview;\n\nexport {\n LivePreview,\n LiveError,\n LiveEditor,\n LiveDnd,\n LiveRenderer,\n App as LiveProvider,\n //\n};\n\nexport type {\n DndPalette,\n DndPanel,\n DndLayout,\n PanelBinding,\n PanelNodeChange,\n FieldProps,\n ItemsEditor,\n ItemsEditorItem,\n ItemsEditorOptions,\n EditorRenderData,\n FrameProps,\n Section,\n};\n\nApp.Preview = LivePreview;\nApp.Renderer = LiveRenderer;\nApp.Error = LiveError;\nApp.Editor = LiveEditor;\nApp.Dnd = LiveDnd;\n\nexport default App;\n"],"mappings":";;;;;;;AAoBA,MAAM,OAAO,EAAE,eAA+C;CAC5D,OAAO,oBAACA,iBAAD,EAAU,SAAkB,CAAA;AACrC;AAEA,MAAM,eAAeC;AA2BrB,IAAI,UAAUA;AACd,IAAI,WAAW;AACf,IAAI,QAAQC;AACZ,IAAI,SAASC;AACb,IAAI,MAAMC"}
1
+ {"version":3,"file":"index.js","names":["Context","LivePreview","LiveError","LiveEditor","LiveDnd"],"sources":["../src/index.tsx"],"sourcesContent":["import './index.css';\n\nimport Context from './components/context';\nimport LiveDnd, {\n type DndEditError,\n type DndLayout,\n type DndPalette,\n type DndPanel,\n type DndRenderField,\n type DndRenderSectionFallback,\n type DndSectionFallbackArgs,\n type FieldProps,\n type ItemsEditor,\n type ItemsEditorItem,\n type ItemsEditorOptions,\n type PanelBinding,\n type PanelNodeChange,\n} from './components/dnd';\nimport LiveEditor, { type EditorRenderData } from './components/editor';\nimport LiveError from './components/error';\nimport { type FrameProps } from './components/frame';\nimport LivePreview from './components/preview';\nimport type { Section } from './types';\n\nconst App = ({ children }: { children?: React.ReactNode }) => {\n return <Context>{children}</Context>;\n};\n\nconst LiveRenderer = LivePreview;\n\nexport {\n LivePreview,\n LiveError,\n LiveEditor,\n LiveDnd,\n LiveRenderer,\n App as LiveProvider,\n //\n};\n\nexport type {\n DndEditError,\n DndRenderField,\n DndRenderSectionFallback,\n DndSectionFallbackArgs,\n DndPalette,\n DndPanel,\n DndLayout,\n PanelBinding,\n PanelNodeChange,\n FieldProps,\n ItemsEditor,\n ItemsEditorItem,\n ItemsEditorOptions,\n EditorRenderData,\n FrameProps,\n Section,\n};\n\nApp.Preview = LivePreview;\nApp.Renderer = LiveRenderer;\nApp.Error = LiveError;\nApp.Editor = LiveEditor;\nApp.Dnd = LiveDnd;\n\nexport default App;\n"],"mappings":";;;;;;;AAwBA,MAAM,OAAO,EAAE,eAA+C;CAC5D,OAAO,oBAACA,iBAAD,EAAU,SAAkB,CAAA;AACrC;AAEA,MAAM,eAAeC;AA+BrB,IAAI,UAAUA;AACd,IAAI,WAAW;AACf,IAAI,QAAQC;AACZ,IAAI,SAASC;AACb,IAAI,MAAMC"}
@@ -1,2 +1,2 @@
1
- import { n as Props, t as Preview } from "../index-lgHdCda5.js";
2
- export { type Props, Preview as default };
1
+ import { n as Preview, r as Props, t as baseModules } from "../index-DQkL37eL.js";
2
+ export { type Props, baseModules, Preview as default };
@@ -1,2 +1,3 @@
1
- import { t as Preview } from "../preview-CWT0lgwq.js";
2
- export { Preview as default };
1
+ import { r as baseModules } from "../use-dynamic-tailwind-BF8TQ3Yy.js";
2
+ import { t as Preview } from "../preview-DKyKKcu7.js";
3
+ export { baseModules, Preview as default };
@@ -1,7 +1,7 @@
1
- import { r as cn } from "./utils-WyxPYZGh.js";
1
+ import { i as cn } from "./utils-BQ7WL7Jh.js";
2
2
  import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
3
- import { n as useCompiledModule, r as Frame, t as useDynamicTailwind } from "./use-dynamic-tailwind-DAhKGsY4.js";
4
- import { t as Error } from "./error-CO0EbMlA.js";
3
+ import { i as Frame, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-BF8TQ3Yy.js";
4
+ import { t as Error } from "./error-o0SBwtTv.js";
5
5
  import { useMemo } from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  //#region src/components/preview/client.tsx
@@ -79,4 +79,4 @@ const Preview = ({ code, props = {}, modules = {}, dynamicTailwind = false, prov
79
79
  //#endregion
80
80
  export { Preview as t };
81
81
 
82
- //# sourceMappingURL=preview-CWT0lgwq.js.map
82
+ //# sourceMappingURL=preview-DKyKKcu7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-CWT0lgwq.js","names":["LiveError"],"sources":["../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { useError, usePreview } from '~/components/context/states';\nimport LiveError from '~/components/error';\nimport Frame, { type FrameProps } from '~/components/frame';\nimport { cn } from '~/utils';\n\nimport { type Props } from './preview';\nimport { useCompiledModule } from './use-compiled-module';\nimport { useDynamicTailwind } from './use-dynamic-tailwind';\n\nconst Client = ({\n code: _code,\n className,\n showError,\n props = {},\n modules = {},\n frame,\n dynamicTailwind = false,\n provider,\n}: Props) => {\n const { code } = usePreview();\n const { error, setError } = useError();\n const isError = !!showError && !!error;\n\n const classNames = cn(isError && 'hidden', className);\n\n const effectiveCode = _code === undefined ? code : _code;\n\n const module = useCompiledModule(effectiveCode, modules);\n\n // Attached to the wrapper below; scans the rendered DOM so classes coming\n // from an imported component are picked up too. See the hook for details.\n const { ref: contentRef, css: dynamicCSS } = useDynamicTailwind(\n effectiveCode,\n dynamicTailwind,\n );\n\n const componentProps = useMemo(\n () => ({\n ...props,\n }),\n [props],\n );\n\n const renderProvider = (component: React.ReactNode) => {\n return provider ? provider(component) : component;\n };\n\n if (module && module.error) {\n return (\n <>\n <div className={cn('relative h-full w-full', classNames)}>\n <LiveError message={module.error} title=\"Compile Error\" />\n </div>\n <LiveError.Runtime open={isError} />\n </>\n );\n }\n\n const Component = module?.exports?.default;\n\n if (!Component) {\n return null;\n }\n\n return (\n <>\n {frame ? (\n <div className={cn('h-full w-full', classNames)}>\n <Frame {...(frame as FrameProps)}>\n {container => (\n <div ref={contentRef} style={{ display: 'contents' }}>\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={(e: Error) => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} container={container} />\n {dynamicTailwind && dynamicCSS && (\n <style>{dynamicCSS}</style>\n )}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n </Frame>\n </div>\n ) : (\n <div\n ref={contentRef}\n className={cn(\n 'relative h-full w-full overflow-x-hidden overflow-y-auto',\n classNames,\n )}\n style={{\n isolation: 'isolate',\n transform: 'translateZ(0)',\n containerType: 'inline-size',\n }}\n >\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={e => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} />\n {dynamicTailwind && dynamicCSS && <style>{dynamicCSS}</style>}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n <LiveError.Runtime open={isError} />\n </>\n );\n};\n\nexport default Client;\n","import type React from 'react';\n\nimport type { FrameProps } from '../frame';\nimport Client from './client';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n code?: string;\n showError?: boolean;\n props?: Record<string, unknown>;\n container?: HTMLElement | null;\n frame?: boolean | FrameProps;\n modules?: Record<string, unknown>;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n}\n\n// A thin wrapper around Client, which does the actual compiling, error\n// handling, and frame wrapping. This used to have its own duplicate\n// compile-and-render branch for the `code` prop that never wrapped its\n// output in <Frame>, so `frame` was silently ignored whenever `code` was\n// passed — see #187. Client already handles `code` (falling back to\n// context when absent) and `frame`, so there is only one render path now.\nconst Preview = ({\n code,\n props = {},\n modules = {},\n dynamicTailwind = false,\n provider,\n ...restProps\n}: Props) => {\n return (\n <Client\n code={code}\n props={props}\n modules={modules}\n dynamicTailwind={dynamicTailwind}\n provider={provider}\n {...restProps}\n />\n );\n};\n\nexport default Preview;\n"],"mappings":";;;;;;;AAaA,MAAM,UAAU,EACd,MAAM,OACN,WACA,WACA,QAAQ,CAAC,GACT,UAAU,CAAC,GACX,OACA,kBAAkB,OAClB,eACW;CACX,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,EAAE,OAAO,aAAa,SAAS;CACrC,MAAM,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CAEjC,MAAM,aAAa,GAAG,WAAW,UAAU,SAAS;CAEpD,MAAM,gBAAgB,UAAU,KAAA,IAAY,OAAO;CAEnD,MAAM,SAAS,kBAAkB,eAAe,OAAO;CAIvD,MAAM,EAAE,KAAK,YAAY,KAAK,eAAe,mBAC3C,eACA,eACF;CAEA,MAAM,iBAAiB,eACd,EACL,GAAG,MACL,IACA,CAAC,KAAK,CACR;CAEA,MAAM,kBAAkB,cAA+B;EACrD,OAAO,WAAW,SAAS,SAAS,IAAI;CAC1C;CAEA,IAAI,UAAU,OAAO,OACnB,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAW,GAAG,0BAA0B,UAAU;EACrD,UAAA,oBAACA,OAAD;GAAW,SAAS,OAAO;GAAO,OAAM;EAAiB,CAAA;CACtD,CAAA,GACL,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;CAIN,MAAM,YAAY,QAAQ,SAAS;CAEnC,IAAI,CAAC,WACH,OAAO;CAGT,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,QACC,oBAAC,OAAD;EAAK,WAAW,GAAG,iBAAiB,UAAU;EAC5C,UAAA,oBAAC,OAAD;GAAO,GAAK;GACT,WAAA,cACC,oBAAC,OAAD;IAAK,KAAK;IAAY,OAAO,EAAE,SAAS,WAAW;IACjD,UAAA,oBAACA,MAAU,UAAX;KACE,WAAW,CAAC,aAAa;KACzB,UAAU,MAAa,SAAS,EAAE,OAAO;KAExC,UAAA,eACC,qBAACA,MAAU,OAAX;MAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;MAAjD,UAAA,CACE,oBAAC,WAAD;OAAW,GAAI;OAA2B;MAAY,CAAA,GACrD,mBAAmB,cAClB,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAEb;KACnB,CAAA,CAAA;IACkB,CAAA;GACjB,CAAA;EAEF,CAAA;CACJ,CAAA,IAEL,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,4DACA,UACF;EACA,OAAO;GACL,WAAW;GACX,WAAW;GACX,eAAe;EACjB;EAEA,UAAA,oBAACA,MAAU,UAAX;GACE,WAAW,CAAC,aAAa;GACzB,UAAS,MAAK,SAAS,EAAE,OAAO;GAE/B,UAAA,eACC,qBAACA,MAAU,OAAX;IAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;IAAjD,UAAA,CACE,oBAAC,WAAD,EAAW,GAAI,eAAiB,CAAA,GAC/B,mBAAmB,cAAc,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAC7C;GACnB,CAAA,CAAA;EACkB,CAAA;CACjB,CAAA,GAEP,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;AAEN;;;ACnGA,MAAM,WAAW,EACf,MACA,QAAQ,CAAC,GACT,UAAU,CAAC,GACX,kBAAkB,OAClB,UACA,GAAG,gBACQ;CACX,OACE,oBAAC,QAAD;EACQ;EACC;EACE;EACQ;EACP;EACV,GAAI;CACL,CAAA;AAEL"}
1
+ {"version":3,"file":"preview-DKyKKcu7.js","names":["LiveError"],"sources":["../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { useError, usePreview } from '~/components/context/states';\nimport LiveError from '~/components/error';\nimport Frame, { type FrameProps } from '~/components/frame';\nimport { cn } from '~/utils';\n\nimport { type Props } from './preview';\nimport { useCompiledModule } from './use-compiled-module';\nimport { useDynamicTailwind } from './use-dynamic-tailwind';\n\nconst Client = ({\n code: _code,\n className,\n showError,\n props = {},\n modules = {},\n frame,\n dynamicTailwind = false,\n provider,\n}: Props) => {\n const { code } = usePreview();\n const { error, setError } = useError();\n const isError = !!showError && !!error;\n\n const classNames = cn(isError && 'hidden', className);\n\n const effectiveCode = _code === undefined ? code : _code;\n\n const module = useCompiledModule(effectiveCode, modules);\n\n // Attached to the wrapper below; scans the rendered DOM so classes coming\n // from an imported component are picked up too. See the hook for details.\n const { ref: contentRef, css: dynamicCSS } = useDynamicTailwind(\n effectiveCode,\n dynamicTailwind,\n );\n\n const componentProps = useMemo(\n () => ({\n ...props,\n }),\n [props],\n );\n\n const renderProvider = (component: React.ReactNode) => {\n return provider ? provider(component) : component;\n };\n\n if (module && module.error) {\n return (\n <>\n <div className={cn('relative h-full w-full', classNames)}>\n <LiveError message={module.error} title=\"Compile Error\" />\n </div>\n <LiveError.Runtime open={isError} />\n </>\n );\n }\n\n const Component = module?.exports?.default;\n\n if (!Component) {\n return null;\n }\n\n return (\n <>\n {frame ? (\n <div className={cn('h-full w-full', classNames)}>\n <Frame {...(frame as FrameProps)}>\n {container => (\n <div ref={contentRef} style={{ display: 'contents' }}>\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={(e: Error) => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} container={container} />\n {dynamicTailwind && dynamicCSS && (\n <style>{dynamicCSS}</style>\n )}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n </Frame>\n </div>\n ) : (\n <div\n ref={contentRef}\n className={cn(\n 'relative h-full w-full overflow-x-hidden overflow-y-auto',\n classNames,\n )}\n style={{\n isolation: 'isolate',\n transform: 'translateZ(0)',\n containerType: 'inline-size',\n }}\n >\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={e => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} />\n {dynamicTailwind && dynamicCSS && <style>{dynamicCSS}</style>}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n <LiveError.Runtime open={isError} />\n </>\n );\n};\n\nexport default Client;\n","import type React from 'react';\n\nimport type { FrameProps } from '../frame';\nimport Client from './client';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n code?: string;\n showError?: boolean;\n props?: Record<string, unknown>;\n container?: HTMLElement | null;\n frame?: boolean | FrameProps;\n modules?: Record<string, unknown>;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n}\n\n// A thin wrapper around Client, which does the actual compiling, error\n// handling, and frame wrapping. This used to have its own duplicate\n// compile-and-render branch for the `code` prop that never wrapped its\n// output in <Frame>, so `frame` was silently ignored whenever `code` was\n// passed — see #187. Client already handles `code` (falling back to\n// context when absent) and `frame`, so there is only one render path now.\nconst Preview = ({\n code,\n props = {},\n modules = {},\n dynamicTailwind = false,\n provider,\n ...restProps\n}: Props) => {\n return (\n <Client\n code={code}\n props={props}\n modules={modules}\n dynamicTailwind={dynamicTailwind}\n provider={provider}\n {...restProps}\n />\n );\n};\n\nexport default Preview;\n"],"mappings":";;;;;;;AAaA,MAAM,UAAU,EACd,MAAM,OACN,WACA,WACA,QAAQ,CAAC,GACT,UAAU,CAAC,GACX,OACA,kBAAkB,OAClB,eACW;CACX,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,EAAE,OAAO,aAAa,SAAS;CACrC,MAAM,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CAEjC,MAAM,aAAa,GAAG,WAAW,UAAU,SAAS;CAEpD,MAAM,gBAAgB,UAAU,KAAA,IAAY,OAAO;CAEnD,MAAM,SAAS,kBAAkB,eAAe,OAAO;CAIvD,MAAM,EAAE,KAAK,YAAY,KAAK,eAAe,mBAC3C,eACA,eACF;CAEA,MAAM,iBAAiB,eACd,EACL,GAAG,MACL,IACA,CAAC,KAAK,CACR;CAEA,MAAM,kBAAkB,cAA+B;EACrD,OAAO,WAAW,SAAS,SAAS,IAAI;CAC1C;CAEA,IAAI,UAAU,OAAO,OACnB,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAW,GAAG,0BAA0B,UAAU;EACrD,UAAA,oBAACA,OAAD;GAAW,SAAS,OAAO;GAAO,OAAM;EAAiB,CAAA;CACtD,CAAA,GACL,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;CAIN,MAAM,YAAY,QAAQ,SAAS;CAEnC,IAAI,CAAC,WACH,OAAO;CAGT,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,QACC,oBAAC,OAAD;EAAK,WAAW,GAAG,iBAAiB,UAAU;EAC5C,UAAA,oBAAC,OAAD;GAAO,GAAK;GACT,WAAA,cACC,oBAAC,OAAD;IAAK,KAAK;IAAY,OAAO,EAAE,SAAS,WAAW;IACjD,UAAA,oBAACA,MAAU,UAAX;KACE,WAAW,CAAC,aAAa;KACzB,UAAU,MAAa,SAAS,EAAE,OAAO;KAExC,UAAA,eACC,qBAACA,MAAU,OAAX;MAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;MAAjD,UAAA,CACE,oBAAC,WAAD;OAAW,GAAI;OAA2B;MAAY,CAAA,GACrD,mBAAmB,cAClB,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAEb;KACnB,CAAA,CAAA;IACkB,CAAA;GACjB,CAAA;EAEF,CAAA;CACJ,CAAA,IAEL,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,4DACA,UACF;EACA,OAAO;GACL,WAAW;GACX,WAAW;GACX,eAAe;EACjB;EAEA,UAAA,oBAACA,MAAU,UAAX;GACE,WAAW,CAAC,aAAa;GACzB,UAAS,MAAK,SAAS,EAAE,OAAO;GAE/B,UAAA,eACC,qBAACA,MAAU,OAAX;IAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;IAAjD,UAAA,CACE,oBAAC,WAAD,EAAW,GAAI,eAAiB,CAAA,GAC/B,mBAAmB,cAAc,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAC7C;GACnB,CAAA,CAAA;EACkB,CAAA;CACjB,CAAA,GAEP,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;AAEN;;;ACnGA,MAAM,WAAW,EACf,MACA,QAAQ,CAAC,GACT,UAAU,CAAC,GACX,kBAAkB,OAClB,UACA,GAAG,gBACQ;CACX,OACE,oBAAC,QAAD;EACQ;EACC;EACE;EACQ;EACP;EACV,GAAI;CACL,CAAA;AAEL"}
@@ -1,2 +1,2 @@
1
- import { t as ContextProvider } from "../context-649REFsj.js";
1
+ import { t as ContextProvider } from "../context-Y-M9fViD.js";
2
2
  export { ContextProvider as default };
@@ -1,15 +1,18 @@
1
- import { i as compile, l as getCachedScriptBlob, t as baseModules } from "./utils-WyxPYZGh.js";
1
+ import { a as compile, u as getCachedScriptBlob } from "./utils-BQ7WL7Jh.js";
2
2
  import { t as generateTailwindCSSFromDOM } from "./tailwind-CbjdLyVX.js";
3
3
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { useMutationObserver, useResizeObserver } from "@jbpark/use-hooks";
5
+ import * as ui from "@jbpark/ui-kit";
6
+ import { useEventListener, useMutationObserver, useResizeObserver } from "@jbpark/use-hooks";
6
7
  import { createPortal } from "react-dom";
8
+ import * as utils from "@jbpark/ui-kit/utils";
7
9
  //#region src/components/frame/measure.ts
8
10
  const computeProbeHeight = (scrollContainerClientHeight, wrapperInsets) => {
9
11
  const usable = scrollContainerClientHeight - wrapperInsets;
10
12
  return usable > 0 ? usable : null;
11
13
  };
12
- const isVisuallyHidden = (computed) => computed.visibility === "hidden" || computed.opacity === "0";
14
+ const isVisuallyHidden = (computed, isAnimating = false) => computed.visibility === "hidden" || computed.opacity === "0" && !isAnimating;
15
+ const isAnimationActive = (playState) => playState === "running" || playState === "paused";
13
16
  const parseTranslateY = (transform) => {
14
17
  if (!transform || transform === "none") return 0;
15
18
  const translateYMatch = transform.match(/translateY\(\s*([+-]?\d*\.?\d+)/);
@@ -110,12 +113,39 @@ const rewriteInlineViewportUnits = (root) => {
110
113
  //#endregion
111
114
  //#region src/components/frame/iframe.tsx
112
115
  const EMPTY_STRING_ARRAY = [];
116
+ const isCssAnimation = (win, animation) => typeof win.CSSAnimation === "function" && animation instanceof win.CSSAnimation;
117
+ const isCssTransition = (win, animation) => typeof win.CSSTransition === "function" && animation instanceof win.CSSTransition;
118
+ const hasActiveAnimation = (el) => typeof el.getAnimations === "function" && el.getAnimations().some((animation) => isAnimationActive(animation.playState));
119
+ const neverFinishes = (animation) => {
120
+ const timing = animation.effect?.getComputedTiming();
121
+ return timing?.iterations === Infinity || timing?.duration === Infinity;
122
+ };
123
+ const MEASUREMENT_OVERRIDE_STYLE_ID = "autoheight-measurement-overrides";
124
+ const SCROLLBAR_OVERRIDE_RULES = ["html, body { scrollbar-width: none !important; }", "html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important; }"];
125
+ const FREEZE_TRANSITIONS_RULE = "*, *::before, *::after { transition: none !important; }";
126
+ const withMeasurementOverrides = (doc, freezeTransitions, measure) => {
127
+ let styleEl = doc.getElementById(MEASUREMENT_OVERRIDE_STYLE_ID);
128
+ if (!styleEl) {
129
+ styleEl = doc.createElement("style");
130
+ styleEl.id = MEASUREMENT_OVERRIDE_STYLE_ID;
131
+ styleEl.media = "not all";
132
+ doc.head?.appendChild(styleEl);
133
+ }
134
+ const text = (freezeTransitions ? [FREEZE_TRANSITIONS_RULE, ...SCROLLBAR_OVERRIDE_RULES] : SCROLLBAR_OVERRIDE_RULES).join("\n");
135
+ if (styleEl.textContent !== text) styleEl.textContent = text;
136
+ styleEl.media = "all";
137
+ measure();
138
+ styleEl.media = "not all";
139
+ };
113
140
  const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_STRING_ARRAY, styles = EMPTY_STRING_ARRAY, stylesheets = EMPTY_STRING_ARRAY, autoHeight = false, syncStyle = false, children, onLoaded, ...props }) => {
114
141
  const iframeRef = useRef(null);
115
142
  const [mountNode, setMountNode] = useState(null);
116
143
  const loadedScriptsRef = useRef(/* @__PURE__ */ new Set());
117
144
  const prevStyleCountRef = useRef(0);
118
145
  const prevStylesheetCountRef = useRef(0);
146
+ const trackedAnimationsRef = useRef(/* @__PURE__ */ new WeakSet());
147
+ const updateHeightRef = useRef(null);
148
+ const lastProbeHeightRef = useRef(void 0);
119
149
  const shouldAutoHeight = autoHeight && style.height == null;
120
150
  const styleManagerRef = useRef(createStyleSyncManager());
121
151
  const applyStyle = useCallback(() => {
@@ -218,26 +248,17 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
218
248
  styleEl.id = CONTAINER_STYLE_ID;
219
249
  doc.head?.appendChild(styleEl);
220
250
  }
221
- styleEl.textContent = `html { container-type: size !important; height: ${probeHeight}px !important; }`;
222
- };
223
- const MEASUREMENT_OVERRIDE_STYLE_ID = "autoheight-measurement-overrides";
224
- const withMeasurementOverrides = (doc, measure) => {
225
- let styleEl = doc.getElementById(MEASUREMENT_OVERRIDE_STYLE_ID);
226
- if (!styleEl) {
227
- styleEl = doc.createElement("style");
228
- styleEl.id = MEASUREMENT_OVERRIDE_STYLE_ID;
229
- styleEl.media = "not all";
230
- styleEl.textContent = [
231
- "*, *::before, *::after { transition: none !important; }",
232
- "html, body { scrollbar-width: none !important; }",
233
- "html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important; }"
234
- ].join("\n");
235
- doc.head?.appendChild(styleEl);
236
- }
237
- styleEl.media = "all";
238
- measure();
239
- styleEl.media = "not all";
251
+ const text = `html { container-type: size !important; height: ${probeHeight}px !important; }`;
252
+ if (styleEl.textContent !== text) styleEl.textContent = text;
240
253
  };
254
+ const trackScriptAnimations = useCallback((doc, win) => {
255
+ if (typeof doc.getAnimations !== "function") return;
256
+ doc.getAnimations().forEach((animation) => {
257
+ if (trackedAnimationsRef.current.has(animation) || !isAnimationActive(animation.playState) || isCssAnimation(win, animation) || isCssTransition(win, animation) || neverFinishes(animation)) return;
258
+ trackedAnimationsRef.current.add(animation);
259
+ animation.finished.catch(() => void 0).then(() => updateHeightRef.current?.());
260
+ });
261
+ }, []);
241
262
  const updateHeight = useCallback(() => {
242
263
  if (!shouldAutoHeight || !mountNode || !iframeRef.current) return;
243
264
  const iframe = iframeRef.current;
@@ -260,13 +281,16 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
260
281
  probeHeight = computed;
261
282
  }
262
283
  let contentHeight = 0;
263
- withMeasurementOverrides(doc, () => {
284
+ const freezeTransitions = probeHeight !== lastProbeHeightRef.current;
285
+ lastProbeHeightRef.current = probeHeight;
286
+ withMeasurementOverrides(doc, freezeTransitions, () => {
264
287
  ensureContainerStyle(doc, probeHeight);
265
288
  rewriteInlineViewportUnits(mountNode);
266
289
  contentHeight = mountNode.scrollHeight;
267
290
  mountNode.querySelectorAll("*").forEach((el) => {
268
291
  const style = win.getComputedStyle(el);
269
- if (isVisuallyHidden(style)) return;
292
+ const isAnimating = style.opacity === "0" && hasActiveAnimation(el);
293
+ if (isVisuallyHidden(style, isAnimating)) return;
270
294
  if ((style.position === "fixed" || style.position === "absolute") && el.offsetHeight > 0) {
271
295
  const estimatedHeight = estimatePositionedElementHeight(el.offsetHeight, style.transform, probeHeight);
272
296
  contentHeight = Math.max(contentHeight, estimatedHeight);
@@ -274,7 +298,15 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
274
298
  });
275
299
  });
276
300
  if (contentHeight > 0) iframe.style.height = `${Math.ceil(contentHeight)}px`;
277
- }, [shouldAutoHeight, mountNode]);
301
+ trackScriptAnimations(doc, win);
302
+ }, [
303
+ shouldAutoHeight,
304
+ mountNode,
305
+ trackScriptAnimations
306
+ ]);
307
+ useEffect(() => {
308
+ updateHeightRef.current = updateHeight;
309
+ }, [updateHeight]);
278
310
  useEffect(() => {
279
311
  if (shouldAutoHeight) return;
280
312
  iframeRef.current?.contentDocument?.getElementById(CONTAINER_STYLE_ID)?.remove();
@@ -316,6 +348,24 @@ const IFrame = ({ title = "Live Preview", sandbox, style = {}, scripts = EMPTY_S
316
348
  attributes: true,
317
349
  characterData: true
318
350
  });
351
+ const mountNodeRef = useMemo(() => ({ current: mountNode }), [mountNode]);
352
+ const settleListenerEnabled = shouldAutoHeight && mountNode !== null;
353
+ useEventListener("animationend", updateHeight, {
354
+ target: mountNodeRef,
355
+ enabled: settleListenerEnabled
356
+ });
357
+ useEventListener("animationcancel", updateHeight, {
358
+ target: mountNodeRef,
359
+ enabled: settleListenerEnabled
360
+ });
361
+ useEventListener("transitionend", updateHeight, {
362
+ target: mountNodeRef,
363
+ enabled: settleListenerEnabled
364
+ });
365
+ useEventListener("transitioncancel", updateHeight, {
366
+ target: mountNodeRef,
367
+ enabled: settleListenerEnabled
368
+ });
319
369
  const content = mountNode ? createPortal(children(mountNode), mountNode) : null;
320
370
  return /* @__PURE__ */ jsx("iframe", {
321
371
  ref: iframeRef,
@@ -400,6 +450,12 @@ const Frame = ({ mode, children, ...restProps }) => {
400
450
  });
401
451
  };
402
452
  //#endregion
453
+ //#region src/components/preview/base-modules.ts
454
+ const baseModules = {
455
+ "ui-kit": ui,
456
+ "ui-kit/utils": utils
457
+ };
458
+ //#endregion
403
459
  //#region src/components/preview/use-compiled-module.ts
404
460
  const useCompiledModule = (code, modules) => {
405
461
  const mergedModules = useMemo(() => ({
@@ -446,6 +502,6 @@ const useDynamicTailwind = (code, enabled) => {
446
502
  };
447
503
  };
448
504
  //#endregion
449
- export { useCompiledModule as n, Frame as r, useDynamicTailwind as t };
505
+ export { Frame as i, useCompiledModule as n, baseModules as r, useDynamicTailwind as t };
450
506
 
451
- //# sourceMappingURL=use-dynamic-tailwind-DAhKGsY4.js.map
507
+ //# sourceMappingURL=use-dynamic-tailwind-BF8TQ3Yy.js.map