@makeswift/runtime 0.9.2 → 0.9.3

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 (153) hide show
  1. package/dist/Box.cjs.js +0 -2
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +0 -2
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +0 -2
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +0 -2
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +0 -2
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +0 -2
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +0 -2
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +0 -2
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +0 -2
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +0 -2
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Form.cjs.js +0 -2
  22. package/dist/Form.cjs.js.map +1 -1
  23. package/dist/Form.es.js +0 -2
  24. package/dist/Form.es.js.map +1 -1
  25. package/dist/Image.cjs.js +0 -2
  26. package/dist/Image.cjs.js.map +1 -1
  27. package/dist/Image.es.js +0 -2
  28. package/dist/Image.es.js.map +1 -1
  29. package/dist/LiveProvider.cjs.js +0 -2
  30. package/dist/LiveProvider.cjs.js.map +1 -1
  31. package/dist/LiveProvider.es.js +1 -3
  32. package/dist/LiveProvider.es.js.map +1 -1
  33. package/dist/Navigation.cjs.js +0 -2
  34. package/dist/Navigation.cjs.js.map +1 -1
  35. package/dist/Navigation.es.js +0 -2
  36. package/dist/Navigation.es.js.map +1 -1
  37. package/dist/PreviewProvider.cjs.js +2 -4
  38. package/dist/PreviewProvider.cjs.js.map +1 -1
  39. package/dist/PreviewProvider.es.js +1 -3
  40. package/dist/PreviewProvider.es.js.map +1 -1
  41. package/dist/ReadOnlyText.cjs.js +1 -3
  42. package/dist/ReadOnlyText.cjs.js.map +1 -1
  43. package/dist/ReadOnlyText.es.js +2 -4
  44. package/dist/ReadOnlyText.es.js.map +1 -1
  45. package/dist/ReadOnlyTextV2.cjs.js +1 -3
  46. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  47. package/dist/ReadOnlyTextV2.es.js +2 -4
  48. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  49. package/dist/Root.cjs.js +0 -2
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +0 -2
  52. package/dist/Root.es.js.map +1 -1
  53. package/dist/SocialLinks.cjs.js +0 -2
  54. package/dist/SocialLinks.cjs.js.map +1 -1
  55. package/dist/SocialLinks.es.js +0 -2
  56. package/dist/SocialLinks.es.js.map +1 -1
  57. package/dist/Text.cjs.js +1 -3
  58. package/dist/Text.cjs.js.map +1 -1
  59. package/dist/Text.es.js +1 -3
  60. package/dist/Text.es.js.map +1 -1
  61. package/dist/components.cjs.js +0 -2
  62. package/dist/components.cjs.js.map +1 -1
  63. package/dist/components.es.js +0 -2
  64. package/dist/components.es.js.map +1 -1
  65. package/dist/controls.cjs.js +5 -6
  66. package/dist/controls.cjs.js.map +1 -1
  67. package/dist/controls.es.js +1 -2
  68. package/dist/controls.es.js.map +1 -1
  69. package/dist/index.cjs.js +49 -13
  70. package/dist/index.cjs.js.map +1 -1
  71. package/dist/index.cjs10.js +248 -171
  72. package/dist/index.cjs10.js.map +1 -1
  73. package/dist/index.cjs6.js +23 -700
  74. package/dist/index.cjs6.js.map +1 -1
  75. package/dist/index.cjs7.js +13 -37
  76. package/dist/index.cjs7.js.map +1 -1
  77. package/dist/index.cjs8.js +39 -17
  78. package/dist/index.cjs8.js.map +1 -1
  79. package/dist/index.cjs9.js +268 -15
  80. package/dist/index.cjs9.js.map +1 -1
  81. package/dist/index.es.js +42 -7
  82. package/dist/index.es.js.map +1 -1
  83. package/dist/index.es10.js +249 -172
  84. package/dist/index.es10.js.map +1 -1
  85. package/dist/index.es6.js +23 -695
  86. package/dist/index.es6.js.map +1 -1
  87. package/dist/index.es7.js +14 -33
  88. package/dist/index.es7.js.map +1 -1
  89. package/dist/index.es8.js +37 -17
  90. package/dist/index.es8.js.map +1 -1
  91. package/dist/index.es9.js +263 -14
  92. package/dist/index.es9.js.map +1 -1
  93. package/dist/leaf.es.js +1 -1
  94. package/dist/next.cjs.js +0 -2
  95. package/dist/next.cjs.js.map +1 -1
  96. package/dist/next.es.js +1 -3
  97. package/dist/next.es.js.map +1 -1
  98. package/dist/react-page.cjs.js +0 -1
  99. package/dist/react-page.cjs.js.map +1 -1
  100. package/dist/react-page.es.js +1 -2
  101. package/dist/react-page.es.js.map +1 -1
  102. package/dist/react.cjs.js +0 -2
  103. package/dist/react.cjs.js.map +1 -1
  104. package/dist/react.es.js +0 -2
  105. package/dist/react.es.js.map +1 -1
  106. package/dist/slate.cjs.js +257 -41
  107. package/dist/slate.cjs.js.map +1 -1
  108. package/dist/slate.es.js +249 -38
  109. package/dist/slate.es.js.map +1 -1
  110. package/dist/text-input.cjs.js +22 -0
  111. package/dist/text-input.cjs.js.map +1 -1
  112. package/dist/text-input.es.js +18 -1
  113. package/dist/text-input.es.js.map +1 -1
  114. package/dist/types/src/controls/icon-radio-group.d.ts +5 -2
  115. package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -1
  116. package/dist/types/src/controls/style-v2.d.ts.map +1 -1
  117. package/dist/types/src/slate/InlinePlugin/getValue.d.ts +5 -0
  118. package/dist/types/src/slate/InlinePlugin/getValue.d.ts.map +1 -0
  119. package/dist/types/src/slate/InlinePlugin/index.d.ts +16 -0
  120. package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -0
  121. package/dist/types/src/slate/InlinePlugin/onChange.d.ts +4 -0
  122. package/dist/types/src/slate/InlinePlugin/onChange.d.ts.map +1 -0
  123. package/dist/types/src/slate/InlinePlugin/types.d.ts +9 -0
  124. package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -0
  125. package/dist/types/src/slate/LinkPlugin/getValue.d.ts +5 -0
  126. package/dist/types/src/slate/LinkPlugin/getValue.d.ts.map +1 -0
  127. package/dist/types/src/slate/LinkPlugin/index.d.ts +15 -0
  128. package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -0
  129. package/dist/types/src/slate/LinkPlugin/onChange.d.ts +4 -0
  130. package/dist/types/src/slate/LinkPlugin/onChange.d.ts.map +1 -0
  131. package/dist/types/src/slate/LinkPlugin/types.d.ts +5 -0
  132. package/dist/types/src/slate/LinkPlugin/types.d.ts.map +1 -0
  133. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +2 -0
  134. package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
  135. package/dist/types/src/slate/index.d.ts +2 -0
  136. package/dist/types/src/slate/index.d.ts.map +1 -1
  137. package/dist/types.cjs2.js +753 -0
  138. package/dist/types.cjs2.js.map +1 -0
  139. package/dist/types.es2.js +736 -0
  140. package/dist/types.es2.js.map +1 -0
  141. package/package.json +1 -1
  142. package/dist/deepEqual.cjs.js +0 -40
  143. package/dist/deepEqual.cjs.js.map +0 -1
  144. package/dist/deepEqual.es.js +0 -39
  145. package/dist/deepEqual.es.js.map +0 -1
  146. package/dist/index.cjs11.js +0 -375
  147. package/dist/index.cjs11.js.map +0 -1
  148. package/dist/index.es11.js +0 -368
  149. package/dist/index.es11.js.map +0 -1
  150. package/dist/select.cjs.js +0 -21
  151. package/dist/select.cjs.js.map +0 -1
  152. package/dist/select.es.js +0 -16
  153. package/dist/select.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewProvider.es.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport Router from 'next/router'\n\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state).locales\n const defaultLocale = ReactPage.getLocales(state).defaultLocale\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null) messageChannel.port1.postMessage(setLocale(routerLocale))\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname, asPath, query } = Router\n\n Router.replace({ pathname, query }, asPath, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","ReactPage.getDocumentKeysSortedByDepth","BoxModels.isMeasurable","ReactPage.getBreakpoints","ReactPage.getLocales","ReactPage.getElementPropControllerDescriptors","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropControllersHandle","PropControllerHandles.getPropController","ReactPage.createDocument","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,2BAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOA,kBAAkC,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,aAAwD;AAChG,SAAOC,cAA8B,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEwB,mBAAA,QAAeC,kBAAgB,GAAG,QAAuB;;AAC/E,QAAM,YAAYC,UAA0B,OAAO,MAAM;AAEzD,UAAQ,OAAO;AAAA,SACR,YAAY,iBAAiB;AAChC,YAAM,qBAAqB,kBAAY,WAAW,OAAO,QAAQ,WAAW,MAAjD,mBAAoD;AAE/E,UAAI,sBAAsB;AAAa,eAAA;AAEvC,YAAM,kBAAkB,MAAM,oBAAoB,OAAO,QAAQ,SAAS;AAE1E,aAAO,uBAAuB,kBAC1B,YACA,IAAI,IAAI,SAAS,EAAE,IACjB,OAAO,QAAQ,aACfC,eAAiC,OAAO,QAAQ,aAAa,eAAe,CAC9E;AAAA,IACN;AAAA;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,YAAR,CAXM;AAcP,SAAAqB,oBAAC,aAAa,UAAd;AAAA,IAAuB,OAAOnB;AAAAA,IAA9B,8BACG,mBAAD;AAAA,MAAmB;AAAA,MAAiBH;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
1
+ {"version":3,"file":"PreviewProvider.es.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/modules/pointer.ts","../src/state/modules/element-imperative-handles.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import { Action, ActionTypes } from '../actions'\n\nexport type Point = { x: number; y: number }\n\ntype State = {\n pointer: Point | null\n}\n\nfunction getInitialState(): State {\n return { pointer: null }\n}\n\nexport function getPointer(state: State): Point | null {\n return state.pointer\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.BUILDER_POINTER_MOVE:\n return { ...state, pointer: action.payload.pointer }\n\n default:\n return state\n }\n}\n","import { ElementImperativeHandle } from '../../runtimes/react/element-imperative-handle'\nimport { Action, ActionTypes } from '../actions'\n\ntype State = Map<string, Map<string, ElementImperativeHandle>>\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return state\n}\n\nfunction getInitialState(): State {\n return new Map()\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE:\n return new Map(state).set(\n action.payload.documentKey,\n new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const byElementKey = new Map(state.get(action.payload.documentKey) ?? [])\n\n const deleted = byElementKey.delete(action.payload.elementKey)\n\n if (!deleted) return state\n\n return new Map(state).set(action.payload.documentKey, byElementKey)\n }\n\n default:\n return state\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport Router from 'next/router'\n\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsPreview from './modules/is-preview'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Pointer from './modules/pointer'\nimport * as ElementImperativeHandles from './modules/element-imperative-handles'\nimport * as Breakpoints from './modules/breakpoints'\nimport * as Locales from './modules/locales'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n handlePointerMove,\n changePathnameStart,\n changePathnameComplete,\n elementFromPointChange,\n setBreakpoints,\n setLocales,\n setLocale,\n setDefaultLocale,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController } from '../prop-controllers/instances'\nimport { PropController } from '../prop-controllers/base'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n isPreview: IsPreview.reducer,\n builderEditMode: BuilderEditMode.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n breakpoints: Breakpoints.reducer,\n locales: Locales.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nfunction getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nfunction getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): ThunkAction<() => void, State, unknown, Action> {\n return (_dispatch, getState) => {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {\n return\n }\n\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nfunction elementKeysFromElementFromPoint(\n elementFromPoint: Element | null,\n): ThunkAction<{ documentKey: string; elementKey: string } | null, State, unknown, Action> {\n return (_dispatch, getState) => {\n if (elementFromPoint == null) return null\n\n const elementImperativeHandles = getElementImperativeHandlesContainingElement(\n getState(),\n elementFromPoint,\n )\n const acendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState())\n const descendingDepthDocumentKeys = acendingDepthDocumentKeys.slice().reverse()\n\n let currentElement: Element | null = elementFromPoint\n let keys = null\n\n while (currentElement != null) {\n for (const documentKey of descendingDepthDocumentKeys) {\n const byElementKey = elementImperativeHandles.get(documentKey)\n\n if (byElementKey == null) continue\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n if (elementImperativeHandle.getDomNode() === currentElement) {\n return { documentKey, elementKey }\n }\n }\n }\n\n currentElement = currentElement.parentElement\n }\n\n return keys\n }\n}\n\nfunction startPollingElementFromPoint(): ThunkAction<() => void, State, unknown, Action> {\n return (dispatch, getState) => {\n let lastElementFromPoint: Element | null = null\n let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameRequestId)\n }\n\n function handleAnimationFrameRequest() {\n const pointer = getPointer(getState())\n const elementFromPoint =\n pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y)\n\n if (elementFromPoint !== lastElementFromPoint) {\n lastElementFromPoint = elementFromPoint\n\n const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint))\n\n dispatch(elementFromPointChange(keys))\n }\n\n animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = dispatch(startHandlingFocusEvents())\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n stopPollingElementFromPoint()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n const breakpoints = ReactPage.getBreakpoints(state)\n messageChannel.port1.postMessage(setBreakpoints(breakpoints))\n\n const locales = ReactPage.getLocales(state).locales\n const defaultLocale = ReactPage.getLocales(state).defaultLocale\n const routerLocale = Router.locale\n if (locales.length > 0) messageChannel.port1.postMessage(setLocales(locales))\n if (defaultLocale != null) messageChannel.port1.postMessage(setDefaultLocale(defaultLocale))\n if (routerLocale != null) messageChannel.port1.postMessage(setLocale(routerLocale))\n\n Router.events.on('routeChangeStart', () => {\n messageChannel.port1.postMessage(changePathnameStart())\n })\n\n Router.events.on('routeChangeComplete', () => {\n messageChannel.port1.postMessage(changePathnameComplete())\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n case ActionTypes.HANDLE_POINTER_MOVE:\n case ActionTypes.ELEMENT_FROM_POINT_CHANGE:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.SET_BUILDER_EDIT_MODE:\n messageChannel.port1.postMessage(action)\n window.getSelection()?.removeAllRanges()\n break\n\n case ActionTypes.SET_LOCALE: {\n const { pathname, asPath, query } = Router\n\n Router.replace({ pathname, query }, asPath, { locale: action.payload.locale })\n break\n }\n\n case ActionTypes.CHANGE_PATHNAME: {\n const pathname = action.payload.pathname.replace(/^\\//, '/')\n const currentPathname = Router.asPath.replace(/^\\//, '/')\n\n if (pathname !== currentPathname) Router.push(pathname)\n break\n }\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, ReactRuntime } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n runtime?: ReactRuntime\n}\n\nexport default function PreviewProvider({\n client,\n children,\n rootElements,\n runtime,\n}: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime ? runtime.store.getState() : ReactRuntime.store.getState(),\n rootElements,\n client,\n }),\n [client, rootElements, runtime],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","getInitialState","ReadOnlyDocuments.reducer","ReadOnlyDocuments.createDocument","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BuilderEditMode.reducer","Pointer.reducer","ElementImperativeHandles.reducer","Breakpoints.reducer","Locales.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","Pointer.getPointer","ElementImperativeHandles.getElementImperativeHandles","BoxModels.measure","ReactPage.getBuilderEditMode","BuilderEditMode.BuilderEditMode","ReactPage.getDocumentKeysSortedByDepth","BoxModels.isMeasurable","ReactPage.getBreakpoints","ReactPage.getLocales","ReactPage.getElementPropControllerDescriptors","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","PropControllerHandles.getPropControllersHandle","PropControllerHandles.getPropController","ReactPage.createDocument","Documents.getInitialState","IsPreview.getInitialState","client","children","rootElements","runtime","store","useMemo","ReactBuilderPreview","preloadedState","getState","ReactRuntime","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAU,MAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,2BAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOA,kBAAkC,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,aAAwD;AAChG,SAAOC,cAA8B,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEwB,mBAAA,QAAeC,kBAAgB,GAAG,QAAuB;;AAC/E,QAAM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F,CAAA,GAKF,CAACA,QAAQE,cAAcC,OAAvB,CAPmB;AAUrBO,YAAU,MAAM;;AACRC,UAAAA,sBAAsBC,MAAMC,KAAKX,mDAAcY,cAAdZ,YAA2B,CAAA,CAAtC,EAA0Ca,IACpE,CAAC,CAACC,aAAaC,iBACbb,MAAMc,SAASC,uBAAuBC,eAAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOF,YAAR,CAXM;AAcP,SAAAqB,oBAAC,aAAa,UAAd;AAAA,IAAuB,OAAOnB;AAAAA,IAA9B,8BACG,mBAAD;AAAA,MAAmB;AAAA,MAAiBH;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
@@ -7,7 +7,7 @@ var index = require("./index.cjs3.js");
7
7
  var next = require("./index.cjs.js");
8
8
  require("slate");
9
9
  require("./state/breakpoints.cjs.js");
10
- require("./index.cjs6.js");
10
+ require("./types.cjs2.js");
11
11
  require("is-hotkey");
12
12
  require("slate-react");
13
13
  var jsxRuntime = require("react/jsx-runtime");
@@ -23,10 +23,8 @@ require("use-sync-external-store/shim/with-selector");
23
23
  require("next/dynamic");
24
24
  require("./text-input.cjs.js");
25
25
  require("./combobox.cjs.js");
26
- require("./select.cjs.js");
27
26
  require("use-sync-external-store/shim");
28
27
  require("./types.cjs.js");
29
- require("./deepEqual.cjs.js");
30
28
  require("./box-models.cjs.js");
31
29
  require("css-box-model");
32
30
  require("color");
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,UAAAA,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,IAAAA,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,2BAAA,IAAC,aAAD,EAAA,IAAkBA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAZ8B;AAgB/B,qBAAqB;AAAA,EAAET,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWU,UAAAA,SAAS;AAAA,MAClBC,SAAS;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ADxC,EAEG6C,KAAK7C,WAAWW,SAASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
1
+ {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,I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AAWW,SAAS8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CAAzD,EAAuE6C,KAAK,EAA5E,MAAA7C,YAAmF;AAAA,SACvFwB,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUS;AAAAA,SACVT,UAAAA,UAAUE;AAAAA,SACVF,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUY;AAAAA,SACVZ,UAAAA,UAAUa;AAAAA,SACVb,UAAUc,UAAAA;AAEXtC,aAAAA,iBAAWW,SACR8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CADxC,EAEG6C,KAAK7C,WAAWW,SAASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
@@ -1,11 +1,11 @@
1
1
  import { cx } from "@emotion/css";
2
2
  import { forwardRef } from "react";
3
- import { b2 as richTextDTOtoDAO, Z as useStyle, bb as BlockType, bc as InlineType } from "./react-page.es.js";
3
+ import { b2 as richTextDTOtoDAO, Z as useStyle, bc as BlockType, ba as InlineType } from "./react-page.es.js";
4
4
  import { L as Link } from "./index.es3.js";
5
5
  import { n as useResponsiveStyle } from "./index.es.js";
6
6
  import "slate";
7
7
  import "./state/breakpoints.es.js";
8
- import "./index.es6.js";
8
+ import "./types.es2.js";
9
9
  import "is-hotkey";
10
10
  import "slate-react";
11
11
  import { jsx, Fragment } from "react/jsx-runtime";
@@ -21,10 +21,8 @@ import "use-sync-external-store/shim/with-selector";
21
21
  import "next/dynamic";
22
22
  import "./text-input.es.js";
23
23
  import "./combobox.es.js";
24
- import "./select.es.js";
25
24
  import "use-sync-external-store/shim";
26
25
  import "./types.es.js";
27
- import "./deepEqual.es.js";
28
26
  import "./box-models.es.js";
29
27
  import "css-box-model";
30
28
  import "color";
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.es.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAA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x } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,oBAAC,aAAD,EAAA,IAAkBA,oBAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAZ8B;AAgB/B,qBAAqB;AAAA,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A,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUS;AAAAA,SACVT,UAAUE;AAAAA,SACVF,UAAUU;AAAAA,SACVV,UAAUY;AAAAA,SACVZ,UAAUa;AAAAA,SACVb,UAAUc;AACN,aAAA;AAAA;AAGA,aAAA;AAAA;AAEZ;AAED,6BAA6BtC,YAAgC;;AACvD,MAAA,UAAUA,YAAY;AACxB,WAAOA,iBAAWhB,SAAXgB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,WAAWK;AAAAA,SACXL,WAAWC;AAAAA,SACXD,WAAWI;AAAAA,SACXJ,WAAWG;AACPZ,aAAAA,iBAAWW,SAAS8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CAAzD,EAAuE6C,KAAK,EAA5E,MAAA7C,YAAmF;AAAA,SACvFwB,UAAUG;AAAAA,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUS;AAAAA,SACVT,UAAUE;AAAAA,SACVF,UAAUU;AAAAA,SACVV,UAAUY;AAAAA,SACVZ,UAAUa;AAAAA,SACVb,UAAUc;AAEXtC,aAAAA,iBAAWW,SACR8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CADxC,EAEG6C,KAAK7C,WAAWW,SAASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
@@ -6,7 +6,7 @@ var reactPage = require("./react-page.cjs.js");
6
6
  var next = require("./index.cjs.js");
7
7
  require("slate");
8
8
  require("./state/breakpoints.cjs.js");
9
- require("./index.cjs6.js");
9
+ require("./types.cjs2.js");
10
10
  require("is-hotkey");
11
11
  require("slate-react");
12
12
  var jsxRuntime = require("react/jsx-runtime");
@@ -21,10 +21,8 @@ require("use-sync-external-store/shim/with-selector");
21
21
  require("next/dynamic");
22
22
  require("./text-input.cjs.js");
23
23
  require("./combobox.cjs.js");
24
- require("./select.cjs.js");
25
24
  require("use-sync-external-store/shim");
26
25
  require("./types.cjs.js");
27
- require("./deepEqual.cjs.js");
28
26
  require("./box-models.cjs.js");
29
27
  require("css-box-model");
30
28
  require("color");
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,UAAeC,eAAAA;AAG7D,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,IAAA,CAAvC;AAAA,EAAA,CALN;AASD,CAjBgC;AAqBjC,qBAAqB;AAAA,EAAEX,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWY,UAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBlB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEmB;AAAAA,GAAyB;AAC/CC,QAAAA,qBAAqBC,KAAAA,sBAAsBF,WAAWG,UAAZ;AAC1CC,QAAAA,sBAAsBC,4BAAuBJ,kBAAD;AAGhD,wCAAA,QAAA;AAAA,IAAM,WAAWG;AAAAA,IACdJ,UAAAA,WAAWnB,SAAS,KAAK,WAAWmB,WAAWnB;AAAAA,EAAAA,CAFpD;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AAA,SACVN,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUa;AAAAA,SACVb,UAAAA,UAAUc;AAAAA,SACVd,UAAUe,UAAAA;AAEXxC,aAAAA,iBAAWW,SACRiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CADxC,EAEGgD,KAAKhD,WAAWW,SAASsC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAlD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW4C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
1
+ {"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,UAAeC,eAAAA;AAG7D,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,IAAA,CAAvC;AAAA,EAAA,CALN;AASD,CAjBgC;AAqBjC,qBAAqB;AAAA,EAAEX,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWY,UAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBlB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEmB;AAAAA,GAAyB;AAC/CC,QAAA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;AACPZ,aAAAA,iBAAWW,SAASiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CAAzD,EAAuEgD,KAAK,EAA5E,MAAAhD,YAAmF;AAAA,SACvFyB,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUM;AAAAA,SACVN,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUa;AAAAA,SACVb,UAAAA,UAAUc;AAAAA,SACVd,UAAUe,UAAAA;AAEXxC,aAAAA,iBAAWW,SACRiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CADxC,EAEGgD,KAAKhD,WAAWW,SAASsC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAlD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW4C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { cx } from "@emotion/css";
2
2
  import { forwardRef } from "react";
3
- import { b5 as RichTextV2Mode, Z as useStyle, bb as BlockType, bc as InlineType } from "./react-page.es.js";
3
+ import { b5 as RichTextV2Mode, Z as useStyle, bc as BlockType, ba as InlineType } from "./react-page.es.js";
4
4
  import { n as useResponsiveStyle } from "./index.es.js";
5
5
  import "slate";
6
6
  import "./state/breakpoints.es.js";
7
- import "./index.es6.js";
7
+ import "./types.es2.js";
8
8
  import "is-hotkey";
9
9
  import "slate-react";
10
10
  import { jsx, Fragment } from "react/jsx-runtime";
@@ -19,10 +19,8 @@ import "use-sync-external-store/shim/with-selector";
19
19
  import "next/dynamic";
20
20
  import "./text-input.es.js";
21
21
  import "./combobox.es.js";
22
- import "./select.es.js";
23
22
  import "use-sync-external-store/shim";
24
23
  import "./types.es.js";
25
- import "./deepEqual.es.js";
26
24
  import "./box-models.es.js";
27
25
  import "css-box-model";
28
26
  import "color";