@rxdrag/website-studio 0.0.5 → 0.0.7

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.
@@ -1,6 +1,7 @@
1
1
  export declare const FRAME_CONTENT = "#frameContent#";
2
2
  export declare const FRAME_IMPORTS = "#frameImports#";
3
3
  export declare const FRAME_404 = "#frame404#";
4
+ export declare const CSS_CONTENT = "#cssContent#";
4
5
  export declare const PAGE_CONTENT = "#content#";
5
6
  export declare const PAGE_IMPORTS = "#imports#";
6
7
  export declare const APP_NAME = "#appName#";
package/dist/index.mjs CHANGED
@@ -4,14 +4,14 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
8
8
  import * as React from "react";
9
9
  import React__default, { createContext, useContext, useMemo, memo, Fragment, useCallback, useState, useEffect, forwardRef as forwardRef$1, useRef, useImperativeHandle, isValidElement, cloneElement } from "react";
10
10
  import { useFilterMeta, useDesignerEngine, ComponentDesignersRoot, useComponentDesigners, useNode, Designer, useDocument, useDocumentChangedState, useCurrentNode, useGetNode, useChangeNodeMeta, useNodeMeta, useUndo, useRedo, useLanguage, useSetters, useResourceNode, useActiveIdState, useActions, useCurrentTree, useSelectedNodeIds, ComponentTreeWidget, useSelect, DocumentRoot } from "@rxdrag/react-core-pro";
11
11
  import { RXID_ATTR_NAME, TOOLBAR_HEIGHT, CanvasScrollEvent, CanvasResizeEvent, numbToPx, getMaxZIndex, HistoryableActionType, MARGIN_DECORATOR_NAME, LINE_DECORTOR_NAME, LineDecorator, MarginDecorator, IFrameCanvasImpl, KeyboardDriver, DragDropDriver, DragOverDriver, MouseClickDriver, MouseMoveDriver, MouseOverOutDriver, CanvasResizeDriver, CanvasScrollDriver, MouseUpDriver, ContainerImpl } from "@rxdrag/core-pro";
12
12
  import { TextNodeName } from "@rxdrag/schema-pro";
13
13
  import { propSetters, Input, Textarea, ImageSelect, TargetSetter, DeviceBreakpoints, DeviceContext } from "@rxdrag/schema-setters";
14
- import { createSchema as createSchema$1, staticMaterials, attachmentNameResource, XAttachmentIconMaterial, attachmentLinkResource, websiteSettingsContactResource, websiteSettingsAvatarResource, websiteSettingsAddressResource, webisteSettingsEmailResource, webisteSettingsTelResource, webisteSettingsFaxResource, webisteSettingMobileResource, userNameResource, userAvatarResource, userPositionResource, userProfileResource, userEmailResource, userTelResource, userMobileResource, userLinkedInResource, userTwitterResource, userFacebookResource, userInstagramResource, userLinkResource, productCategoryNameResource, productCategoryMediaResource, productCategoryDescriptionResource, productCategoryCreatedAtResource, productCategoryUpdatedAtResource, productCategoryProductsResource, proudctCategoryLinkResource, postCategoryNameResource, postCategoryDescriptionResource, postCategoryCreatedAtResource, postCategoryUpdatedAtResource, postCategoryPostsResource, postCategoryLinkResource, productTitleResource, productShortTitleResource, productCoverResource, productMediasResource, productDescriptionResource, productFeaturesResource, productContentResource, productContent2Resource, productContent3Resource, productPublishedAtResource, productCreatedAtResource, productUpdatedAtResource, productAssociationCategoryResource, productAttachmentsResource, productRelatedResource, productLinkResource, postCoverResource, postAuthorResource, postTitleResource, postDescriptionResource, postContentResource, postPublishedAtResource, postCreatedAtResource, postUpdatedAtResource, postAssociationCategoryResource, postOutlineResource, postLinkResource, productResource, productListResource, postResource, postListResource, productCategoryResource, productCategoryListResource, postCategoryResource, postCategoryListResource, searchListResource, featuredProductsResource, latestPostsResource, XPaginationMaterial, XPaginationPrevButtonMaterial, XPaginationNextButtonMaterial, XPaginationPagesMaterial, XPaginationPageIndexMaterial, XPaginationTotalMaterial, pageTitleResource, XBreadcrumbsMaterial, xHeading1Resource, xHeading2Resource, xHeading3Resource, xHeading4Resource, XParagraphMaterial, XDateMaterial, ImgMaterial, XIconMaterial, XMenuMaterial, XModalMaterial, XModalCloseMaterial, RouteLinkMaterial, XSearchMaterial, XShareMaterial, XToTopMaterial, XAnimationNumberMaterial, XSectionMaterial, XBoxMaterial, xRowName, xColName, XPageOutletMaterial, XTabsMaterial, XTabsNavTitleMaterial, XTabPanelMaterial, XFormMaterial, XFormEmailMaterial, XFormNameMaterial, XFormCompanyMaterial, XFormTelMaterial, XFormMessageMaterial, XSubmitMaterial, AMaterial, creatHtmlMaterial } from "@rxdrag/website-materials";
14
+ import { createSchema as createSchema$1, staticMaterials, attachmentNameResource, XAttachmentIconMaterial, attachmentLinkResource, websiteSettingsContactResource, websiteSettingsAvatarResource, websiteSettingsAddressResource, webisteSettingsEmailResource, webisteSettingsTelResource, webisteSettingsFaxResource, webisteSettingMobileResource, userNameResource, userAvatarResource, userPositionResource, userProfileResource, userEmailResource, userTelResource, userMobileResource, userLinkedInResource, userTwitterResource, userFacebookResource, userInstagramResource, userLinkResource, productCategoryNameResource, productCategoryMediaResource, productCategoryDescriptionResource, productCategoryCreatedAtResource, productCategoryUpdatedAtResource, productCategoryProductsResource, proudctCategoryLinkResource, postCategoryNameResource, postCategoryDescriptionResource, postCategoryCreatedAtResource, postCategoryUpdatedAtResource, postCategoryPostsResource, postCategoryLinkResource, productTitleResource, productShortTitleResource, productCoverResource, productMediasResource, productDescriptionResource, productFeaturesResource, productContentResource, productContent2Resource, productContent3Resource, productPublishedAtResource, productCreatedAtResource, productUpdatedAtResource, productAssociationCategoryResource, productAttachmentsResource, productRelatedResource, productLinkResource, postCoverResource, postAuthorResource, postTitleResource, postDescriptionResource, postContentResource, postPublishedAtResource, postCreatedAtResource, postUpdatedAtResource, postAssociationCategoryResource, postOutlineResource, postLinkResource, productResource, productListResource, postResource, postListResource, productCategoryResource, productCategoryListResource, postCategoryResource, postCategoryListResource, searchListResource, featuredProductsResource, latestPostsResource, XPaginationMaterial, XPaginationPrevButtonMaterial, XPaginationNextButtonMaterial, XPaginationPagesMaterial, XPaginationPageIndexMaterial, XPaginationTotalMaterial, pageTitleResource, XBreadcrumbsMaterial, xHeading1Resource, xHeading2Resource, xHeading3Resource, xHeading4Resource, XParagraphMaterial, XDateMaterial, ImgMaterial, XIconMaterial, XMenuMaterial, XModalMaterial, XModalCloseMaterial, RouteLinkMaterial, XSearchMaterial, XShareMaterial, XToTopMaterial, XAnimationNumberMaterial, XSectionMaterial, XBoxMaterial, xRowName, xColName, XPageOutletMaterial, XTabsMaterial, XTabsNavTitleMaterial, XTabPanelMaterial, XFormMaterial, formEmailResource, formNameResource, formCompanyResource, formTelResource, formMessageResource, XSubmitMaterial, AMaterial, creatHtmlMaterial } from "@rxdrag/website-materials";
15
15
  import { ThemeQueryOptions, ThemeFields, WebsiteFrameQueryOptions, WebsiteFrameFields, TemplateQueryOptions, TemplateFields, TemplateCategoryFields, PageQueryOptions, PageFields, PageAssciations, MediaQueryOptions, FrontComponentQueryOptions, FrontComponentFields, ComponentCategoryFields, MediaFields, WebsiteSettingsFields, ProductCategoryAssciations, ProductCategoryFields, ProductFields, PostFields, PostAssciations, UserFields, UserAssciations, ComponentType, FrontComponentEntityName, TemplateEntityName, mediaToInput, templateToInput, TemplateCategoryQueryOptions, frontComponentToInput, ComponentCategoryQueryOptions, ExtendFieldType, PageEntityName, PageType, pageToInput, ComponentCategoryEntityName, componentCategoryToInput, TemplateCategoryEntityName, templateCategoryToInput, MediaType, ProductAssciations, PostCategoryAssciations } from "@rxdrag/rxcms-models";
16
16
  import { GlobalLoading, EntityEditModal, EntitySelectField, EditingPopoverScope, useRemoveRow, useEditRow, EntityListScope, EntityRowScope, useListData, QueryListScope, useNewRow, useIsLoading, NewButton } from "@rxdrag/rxcms-models-ui";
17
17
  import { useOneTheme, useOneWebsiteFrame, useTemplateList, usePageList, useFrontComponentList, useUpsertOnePage, useUpsertOneWebsiteFrame, useUpsertOneTheme, useDeletePageById, useDeleteWebsiteFrameById } from "@rxdrag/rxcms-model-hooks";
@@ -12415,27 +12415,27 @@ const resourceTreeNodes = [
12415
12415
  },
12416
12416
  {
12417
12417
  title: "邮箱",
12418
- resource: (_C = XFormEmailMaterial.resource) == null ? void 0 : _C.name
12418
+ resource: formEmailResource
12419
12419
  },
12420
12420
  {
12421
12421
  title: "姓名",
12422
- resource: (_D = XFormNameMaterial.resource) == null ? void 0 : _D.name
12422
+ resource: formNameResource
12423
12423
  },
12424
12424
  {
12425
12425
  title: "公司",
12426
- resource: (_E = XFormCompanyMaterial.resource) == null ? void 0 : _E.name
12426
+ resource: formCompanyResource
12427
12427
  },
12428
12428
  {
12429
12429
  title: "电话",
12430
- resource: (_F = XFormTelMaterial.resource) == null ? void 0 : _F.name
12430
+ resource: formTelResource
12431
12431
  },
12432
12432
  {
12433
12433
  title: "内容",
12434
- resource: (_G = XFormMessageMaterial.resource) == null ? void 0 : _G.name
12434
+ resource: formMessageResource
12435
12435
  },
12436
12436
  {
12437
12437
  title: "提交",
12438
- resource: (_H = XSubmitMaterial.resource) == null ? void 0 : _H.name
12438
+ resource: (_C = XSubmitMaterial.resource) == null ? void 0 : _C.name
12439
12439
  }
12440
12440
  ]
12441
12441
  },
@@ -12452,15 +12452,15 @@ const resourceTreeNodes = [
12452
12452
  children: [
12453
12453
  {
12454
12454
  title: "a",
12455
- resource: (_I = AMaterial.resource) == null ? void 0 : _I.name
12455
+ resource: (_D = AMaterial.resource) == null ? void 0 : _D.name
12456
12456
  },
12457
12457
  {
12458
12458
  title: "div",
12459
- resource: (_J = creatHtmlMaterial("div").resource) == null ? void 0 : _J.name
12459
+ resource: (_E = creatHtmlMaterial("div").resource) == null ? void 0 : _E.name
12460
12460
  },
12461
12461
  {
12462
12462
  title: "span",
12463
- resource: (_K = creatHtmlMaterial("span").resource) == null ? void 0 : _K.name
12463
+ resource: (_F = creatHtmlMaterial("span").resource) == null ? void 0 : _F.name
12464
12464
  },
12465
12465
  {
12466
12466
  title: "button"
@@ -15415,6 +15415,7 @@ const MenuContent = memo((props) => {
15415
15415
  const FRAME_CONTENT = "#frameContent#";
15416
15416
  const FRAME_IMPORTS = "#frameImports#";
15417
15417
  const FRAME_404 = "#frame404#";
15418
+ const CSS_CONTENT = "#cssContent#";
15418
15419
  const APP_NAME = "#appName#";
15419
15420
  const APP_VERSION = "#appVersion#";
15420
15421
  const APP_PPACKAGES = "#appPackages#";
@@ -15853,6 +15854,7 @@ const tailwindCssTemplate = {
15853
15854
  @tailwind components;
15854
15855
  @tailwind utilities;
15855
15856
 
15857
+ ${CSS_CONTENT}
15856
15858
  `
15857
15859
  };
15858
15860
  const slugTemplate = {
@@ -15883,8 +15885,7 @@ export const loader: LoaderFunction = async (args: LoaderFunctionArgs) => {
15883
15885
  envVariables
15884
15886
  )
15885
15887
  if (webisteSettings?.map301) {
15886
- for (const line of webisteSettings.map301?.split('
15887
- ')) {
15888
+ for (const line of webisteSettings.map301?.split('\\n')) {
15888
15889
  const [from, to] = line.split(',');
15889
15890
  if (slug === from) {
15890
15891
  return redirect(to, 301);
@@ -16043,7 +16044,7 @@ class Coder {
16043
16044
  }
16044
16045
  }
16045
16046
  jsonToTsx(node, spaces = 0, hasRootClassName) {
16046
- var _a2, _b2;
16047
+ var _a2, _b2, _c2, _d2, _e2, _f2;
16047
16048
  const spacesStr = " ".repeat(spaces);
16048
16049
  if (node.componentName === TextNodeName) {
16049
16050
  return spacesStr + (node.text || "");
@@ -16090,9 +16091,18 @@ class Coder {
16090
16091
  spaceAddon = 2;
16091
16092
  str += ` ${spacesStr}{(datas) => (
16092
16093
  `;
16094
+ if (((_b2 = node.children) == null ? void 0 : _b2.length) && ((_c2 = node.children) == null ? void 0 : _c2.length) > 1) {
16095
+ str += ` ${spacesStr}<>
16096
+ `;
16097
+ spaceAddon = 4;
16098
+ }
16093
16099
  }
16094
- str += ((_b2 = node.children) == null ? void 0 : _b2.map((child) => this.jsonToTsx(child, spaces + 2 + spaceAddon)).join("\n")) + "\n";
16100
+ str += ((_d2 = node.children) == null ? void 0 : _d2.map((child) => this.jsonToTsx(child, spaces + 2 + spaceAddon)).join("\n")) + "\n";
16095
16101
  if (this.needAddDatas(xdata)) {
16102
+ if (((_e2 = node.children) == null ? void 0 : _e2.length) && ((_f2 = node.children) == null ? void 0 : _f2.length) > 1) {
16103
+ str += ` ${spacesStr}</>
16104
+ `;
16105
+ }
16096
16106
  str += ` ${spacesStr})}`;
16097
16107
  }
16098
16108
  str += `
@@ -16242,7 +16252,6 @@ const rootTemplate = {
16242
16252
  import { entify } from "@rxdrag/model-remix-lib";
16243
16253
  import { useAppInit, XDataScope, HtmlDocument } from "@rxdrag/website-components";
16244
16254
  import "./tailwind.css";
16245
- import './frontend.css'
16246
16255
  ${FRAME_IMPORTS}
16247
16256
 
16248
16257
  ${LOADER_FUNCTION}
@@ -16360,7 +16369,7 @@ class ComponentCoder extends Coder {
16360
16369
  let code = "\n";
16361
16370
  code += this.getPropsTypeCode();
16362
16371
  const xdatas = this.getXDataSchemas();
16363
- code += `export default function ${this.component.name}(props: ${this.component.name}Props) {
16372
+ code += `export function ${this.component.name}(props: ${this.component.name}Props) {
16364
16373
  `;
16365
16374
  const childrenCode = this.component.droppable ? `, children` : "";
16366
16375
  const propsStr = (_b2 = (_a2 = this.component.props) == null ? void 0 : _a2.items) == null ? void 0 : _b2.map((field) => field.name).join(", ");
@@ -16390,18 +16399,23 @@ class ComponentCoder extends Coder {
16390
16399
  return code;
16391
16400
  }
16392
16401
  getPropsTypeCode() {
16393
- var _a2;
16402
+ var _a2, _b2;
16394
16403
  let code = `export type ${this.component.name}Props = {
16395
16404
  `;
16396
16405
  code += ` className?: string
16397
16406
  `;
16398
16407
  if (this.getXDataSchemas().length) {
16399
- code += ` datas: TDatas
16408
+ code += ` datas?: TDatas
16400
16409
  `;
16401
16410
  }
16402
16411
  for (const field of ((_a2 = this.component.props) == null ? void 0 : _a2.items) || []) {
16403
- code += ` ${field.name}: ${field.type}
16412
+ if (field.type === ExtendFieldType.Json) {
16413
+ code += ` ${field.name}?: any
16414
+ `;
16415
+ } else {
16416
+ code += ` ${field.name}: ${(_b2 = field.type) == null ? void 0 : _b2.toLowerCase()}
16404
16417
  `;
16418
+ }
16405
16419
  }
16406
16420
  if (this.component.droppable) {
16407
16421
  code += ` children: React.ReactNode
@@ -16716,6 +16730,7 @@ class WebsiteGenerator {
16716
16730
  return this.studioProps.frame;
16717
16731
  }
16718
16732
  async generate() {
16733
+ var _a2, _b2, _c2;
16719
16734
  const zip = new JSZip();
16720
16735
  const pages = this.getPages();
16721
16736
  const frame = this.getFrame();
@@ -16742,7 +16757,7 @@ class WebsiteGenerator {
16742
16757
  );
16743
16758
  usedMaterials.push(...frameCoder.getUsedMaterials());
16744
16759
  appFolder.file(frameCoder.getFileName(), frameCoder.getFileCode());
16745
- appFolder.file(tailwindCssTemplate.name, tailwindCssTemplate.content);
16760
+ appFolder.file(tailwindCssTemplate.name, tailwindCssTemplate.content.replace(CSS_CONTENT, ((_a2 = this.studioProps.theme) == null ? void 0 : _a2.css) || ""));
16746
16761
  const deplyFolder = appFolder.folder("deploy");
16747
16762
  if (deplyFolder) {
16748
16763
  deplyFolder.file(deployEnvTemplate.name, deployEnvTemplate.content);
@@ -16753,9 +16768,11 @@ class WebsiteGenerator {
16753
16768
  if (routesFolder) {
16754
16769
  routesFolder.file(slugTemplate.name, slugTemplate.content);
16755
16770
  for (const page of pages || []) {
16756
- const pageCoder = new PageCoder(comsStore, page);
16757
- routesFolder.file(pageCoder.getFileName(), pageCoder.getFileCode());
16758
- usedMaterials.push(...pageCoder.getUsedMaterials());
16771
+ if ((_c2 = (_b2 = page.content) == null ? void 0 : _b2.elements) == null ? void 0 : _c2.length) {
16772
+ const pageCoder = new PageCoder(comsStore, page);
16773
+ routesFolder.file(pageCoder.getFileName(), pageCoder.getFileCode());
16774
+ usedMaterials.push(...pageCoder.getUsedMaterials());
16775
+ }
16759
16776
  }
16760
16777
  }
16761
16778
  const componentsFolder = appFolder == null ? void 0 : appFolder.folder("components");
@@ -16765,7 +16782,7 @@ class WebsiteGenerator {
16765
16782
  componentsFolder.file(comCoder.getFileName(), comCoder.getFileCode());
16766
16783
  usedMaterials.push(...comCoder.getUsedMaterials());
16767
16784
  }
16768
- componentsFolder.file("index.ts", coders.map((coder) => `export { ${coder.getComponent().name} } from "./components/${coder.getComponent().name}"`).join("\n"));
16785
+ componentsFolder.file("index.ts", coders.map((coder) => `export { ${coder.getComponent().name} } from "./${coder.getComponent().name}"`).join("\n"));
16769
16786
  }
16770
16787
  }
16771
16788
  const packages = {};