@baseplate-dev/project-builder-web 0.3.2 → 0.3.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.
- package/dist/assets/{-constants-PTFWy9Gi.js → -constants-Bo-HMfkg.js} +2 -2
- package/dist/assets/{-constants-PTFWy9Gi.js.map → -constants-Bo-HMfkg.js.map} +1 -1
- package/dist/assets/{admin-kAGVS9JZ.js → admin-BfRT8oJm.js} +2 -2
- package/dist/assets/{admin-kAGVS9JZ.js.map → admin-BfRT8oJm.js.map} +1 -1
- package/dist/assets/{backend-SutzTn7D.js → backend-DrT1hDB6.js} +2 -2
- package/dist/assets/{backend-SutzTn7D.js.map → backend-DrT1hDB6.js.map} +1 -1
- package/dist/assets/{edit._key-D8cMXeo4.js → edit._key-CbUXCYlN.js} +2 -2
- package/dist/assets/{edit._key-D8cMXeo4.js.map → edit._key-CbUXCYlN.js.map} +1 -1
- package/dist/assets/{edit._sectionKey-CzUa0VJQ.js → edit._sectionKey-BMO2TE-N.js} +3 -3
- package/dist/assets/edit._sectionKey-BMO2TE-N.js.map +1 -0
- package/dist/assets/{graphql-DdfXEHeY.js → graphql-CmbxpGwL.js} +2 -2
- package/dist/assets/{graphql-DdfXEHeY.js.map → graphql-CmbxpGwL.js.map} +1 -1
- package/dist/assets/{hierarchy-CDzI93co.js → hierarchy-Bpe_B9GF.js} +2 -2
- package/dist/assets/{hierarchy-CDzI93co.js.map → hierarchy-Bpe_B9GF.js.map} +1 -1
- package/dist/assets/{index-B4FH7LFi.js → index-BHnPEV23.js} +2 -2
- package/dist/assets/{index-B4FH7LFi.js.map → index-BHnPEV23.js.map} +1 -1
- package/dist/assets/{index-CY44kpDb.js → index-BVQyr3Nx.js} +2 -2
- package/dist/assets/{index-CY44kpDb.js.map → index-BVQyr3Nx.js.map} +1 -1
- package/dist/assets/{index-CrqdIwuI.js → index-BWWtHwOB.js} +2 -2
- package/dist/assets/{index-CrqdIwuI.js.map → index-BWWtHwOB.js.map} +1 -1
- package/dist/assets/{index-Dqz6Um4q.js → index-Bzqwlp87.js} +2 -2
- package/dist/assets/{index-Dqz6Um4q.js.map → index-Bzqwlp87.js.map} +1 -1
- package/dist/assets/{index-J647aRqJ.js → index-CcwjSjSF.js} +2 -2
- package/dist/assets/{index-J647aRqJ.js.map → index-CcwjSjSF.js.map} +1 -1
- package/dist/assets/{index-DPSszaVo.js → index-DGB_wag0.js} +2 -2
- package/dist/assets/{index-DPSszaVo.js.map → index-DGB_wag0.js.map} +1 -1
- package/dist/assets/{index-BX3bI2pu.js → index-DYXfePdM.js} +2 -2
- package/dist/assets/{index-BX3bI2pu.js.map → index-DYXfePdM.js.map} +1 -1
- package/dist/assets/{index-CbWKfUJC.js → index-D_oO4W9-.js} +3 -3
- package/dist/assets/{index-CbWKfUJC.js.map → index-D_oO4W9-.js.map} +1 -1
- package/dist/assets/{index-CnjpKwrb.js → index-Dy6-62Gh.js} +2 -2
- package/dist/assets/{index-CnjpKwrb.js.map → index-Dy6-62Gh.js.map} +1 -1
- package/dist/assets/{index-Du_dKa1V.js → index-se7yDVhq.js} +2 -2
- package/dist/assets/{index-Du_dKa1V.js.map → index-se7yDVhq.js.map} +1 -1
- package/dist/assets/new-admin-section-dialog-CSdEVfng.js +2 -0
- package/dist/assets/new-admin-section-dialog-CSdEVfng.js.map +1 -0
- package/dist/assets/{new-app-dialog-Cq8PNS8v.js → new-app-dialog-BbdhVL-K.js} +2 -2
- package/dist/assets/{new-app-dialog-Cq8PNS8v.js.map → new-app-dialog-BbdhVL-K.js.map} +1 -1
- package/dist/assets/{new-enum-dialog-BWIaNTlE.js → new-enum-dialog-DBsZ31Qk.js} +2 -2
- package/dist/assets/{new-enum-dialog-BWIaNTlE.js.map → new-enum-dialog-DBsZ31Qk.js.map} +1 -1
- package/dist/assets/{new-model-dialog-Dmjtg093.js → new-model-dialog-D7GR7RYc.js} +2 -2
- package/dist/assets/{new-model-dialog-Dmjtg093.js.map → new-model-dialog-D7GR7RYc.js.map} +1 -1
- package/dist/assets/{route-CHzFreT1.js → route-BAWVfLAO.js} +2 -2
- package/dist/assets/{route-CHzFreT1.js.map → route-BAWVfLAO.js.map} +1 -1
- package/dist/assets/{route-CJt9Kcj2.js → route-C-Q8OXV_.js} +2 -2
- package/dist/assets/{route-CJt9Kcj2.js.map → route-C-Q8OXV_.js.map} +1 -1
- package/dist/assets/{route-CcnDgWSF.js → route-C4bxAHlh.js} +2 -2
- package/dist/assets/{route-CcnDgWSF.js.map → route-C4bxAHlh.js.map} +1 -1
- package/dist/assets/{route-BtOjnFqC.js → route-C50RIYiW.js} +2 -2
- package/dist/assets/{route-BtOjnFqC.js.map → route-C50RIYiW.js.map} +1 -1
- package/dist/assets/{route-0OUHvfVW.js → route-CQL0eFxq.js} +2 -2
- package/dist/assets/{route-0OUHvfVW.js.map → route-CQL0eFxq.js.map} +1 -1
- package/dist/assets/{route-DCltd14u.js → route-CbQuaf1D.js} +2 -2
- package/dist/assets/{route-DCltd14u.js.map → route-CbQuaf1D.js.map} +1 -1
- package/dist/assets/{route-Ba6FCjmw.js → route-CxZgbEF9.js} +2 -2
- package/dist/assets/{route-Ba6FCjmw.js.map → route-CxZgbEF9.js.map} +1 -1
- package/dist/assets/{route-Dtm2QvWW.js → route-D3d4wtgj.js} +2 -2
- package/dist/assets/{route-Dtm2QvWW.js.map → route-D3d4wtgj.js.map} +1 -1
- package/dist/assets/{route-DPE1Borc.js → route-QaYF1pZz.js} +2 -2
- package/dist/assets/{route-DPE1Borc.js.map → route-QaYF1pZz.js.map} +1 -1
- package/dist/assets/route-aXTz8_pd.js +2 -0
- package/dist/assets/{route-Fld55OGo.js.map → route-aXTz8_pd.js.map} +1 -1
- package/dist/assets/{service-Coa_-vZM.js → service-Dm83TP3v.js} +2 -2
- package/dist/assets/{service-Coa_-vZM.js.map → service-Dm83TP3v.js.map} +1 -1
- package/dist/assets/{template-extractor-CBtzqlLB.js → template-extractor-CNC2N5ui.js} +2 -2
- package/dist/assets/{template-extractor-CBtzqlLB.js.map → template-extractor-CNC2N5ui.js.map} +1 -1
- package/dist/assets/{theme-builder-CaB_l2dA.js → theme-builder-DkvYEnNa.js} +2 -2
- package/dist/assets/{theme-builder-CaB_l2dA.js.map → theme-builder-DkvYEnNa.js.map} +1 -1
- package/dist/assets/{use-enum-form-noNDSWbe.js → use-enum-form-JpYvWXon.js} +2 -2
- package/dist/assets/{use-enum-form-noNDSWbe.js.map → use-enum-form-JpYvWXon.js.map} +1 -1
- package/dist/assets/{use-model-form-B32BYlq7.js → use-model-form-DMJkeWdJ.js} +2 -2
- package/dist/assets/{use-model-form-B32BYlq7.js.map → use-model-form-DMJkeWdJ.js.map} +1 -1
- package/dist/index.html +1 -1
- package/package.json +6 -6
- package/dist/assets/edit._sectionKey-CzUa0VJQ.js.map +0 -1
- package/dist/assets/new-admin-section-dialog-Ct76iG3g.js +0 -2
- package/dist/assets/new-admin-section-dialog-Ct76iG3g.js.map +0 -1
- package/dist/assets/route-Fld55OGo.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as l}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as m}from"./jsx-runtime-D_zvdyIk.js";import{h as S,i as I,e as M}from"./index.esm-B0dGSilx.js";import{q as j}from"./index-
|
|
1
|
+
import{i as l}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as m}from"./jsx-runtime-D_zvdyIk.js";import{h as S,i as I,e as M}from"./index.esm-B0dGSilx.js";import{q as j}from"./index-D_oO4W9-.js";import{i as F}from"./isEqual-C420KeG-.js";const{useRef:D}=await l("react");function P(r){const o=D(void 0);return e=>{const n=r(e);return F(o.current,n)?o.current:(o.current=n,n)}}const{jsonDeepClone:O}=await l("@baseplate-dev/utils"),{createContext:U,useContext:$,useEffect:_,useMemo:W}=await l("react"),w=U(void 0);function ee({originalModel:r,children:o,watch:e,getValues:n}){const a=W(()=>S(i=>({model:{...r,...n()},setModel:s=>{i({model:{...r,...s}})},getValues:n})),[r,n]);return _(()=>{const{unsubscribe:i}=e(s=>{a.getState().setModel(O(s))});return i},[e,a]),m.jsx(w.Provider,{value:a,children:o})}function A(r){const o=$(w);if(!o)throw new Error("useEditedModelConfig must be used within a EditedModelContextProvider");return I(o,P(e=>r(e.model)))}const{modelTransformerEntityType:B,ModelTransformerUtils:L,ModelUtils:E}=await l("@baseplate-dev/project-builder-lib"),{useProjectDefinition:q}=await l("@baseplate-dev/project-builder-lib/web"),{MultiComboboxFieldController:T,SelectFieldController:H}=await l("@baseplate-dev/ui-components"),{useEffect:J}=await l("react");function K({formProps:r,name:o}){const e=o,n=r,{control:a,setValue:i}=n,{definition:s,definitionContainer:N,pluginContainer:y}=q(),u=M({control:a,name:e}),p=A(t=>{const R=E.getRelationsToModel(s,t.id),x=t.service?.transformers?.filter(f=>f.type==="embeddedRelation"&&f.id!==u.id);return R.filter(({relation:f})=>!x?.some(C=>C.foreignRelationRef===f.foreignId))}),h=p.map(t=>({label:`${t.relation.foreignRelationName} (${t.model.name})`,value:t.relation.foreignId})),c=u.type==="embeddedRelation"?u:null,d=p.find(t=>t.relation.foreignId===c?.foreignRelationRef),b=j(c?.foreignRelationRef);J(()=>{b!==void 0&&b!==c?.foreignRelationRef&&(i(`${e}.embeddedFieldNames`,[]),d?.model.id&&i(`${e}.modelRef`,d.model.id))},[e,i,d,c?.foreignRelationRef,b,p]);const v=d?.model.model.fields.filter(t=>!d.relation.references.some(R=>R.localRef===t.id)).map(t=>({label:t.name,value:t.id}))??[],g=d?.model.service.transformers.map(t=>({label:L.getTransformName(N,t,y),value:t.id}))??[];return m.jsxs("div",{className:"space-y-4",children:[m.jsx(H,{control:a,name:`${e}.foreignRelationRef`,options:h,label:"Relation",placeholder:"Select relation"}),m.jsx(T,{control:a,disabled:v.length===0,options:v,name:`${e}.embeddedFieldNames`,label:"Embedded Field Names"}),g.length>0&&m.jsx(T,{control:a,options:g,name:`${e}.embeddedTransformerNames`,label:"Embedded Transformers"})]})}const G={name:"embeddedRelation",label:"Embedded Relation",description:"Upsert records to a related model table",instructions:`This transformer allows you to upsert related records to a related model's table
|
|
2
2
|
e.g. UserRole records for a User. It will create, update, delete related records to fit the provided
|
|
3
3
|
input.`,getSummary(r,o){return[{label:"Embedded Relation",description:o.nameFromId(r.foreignRelationRef)}]},allowNewTransformer(r,o){const{definition:e}=r,n=E.getRelationsToModel(e,o.id),a=o.service?.transformers?.filter(i=>i.type==="embeddedRelation");return n.some(({relation:i})=>!a?.some(s=>s.foreignRelationRef===i.foreignId))},getNewTransformer:()=>({id:B.generateNewId(),foreignRelationRef:"",type:"embeddedRelation",embeddedFieldNames:[],modelRef:""}),Form:K,pluginKey:void 0},{modelTransformerEntityType:Y}=await l("@baseplate-dev/project-builder-lib"),{createNewModelTransformerWebConfig:k}=await l("@baseplate-dev/project-builder-lib/web"),oe=[G,k({name:"password",label:"Password",description:"Hashes the input value of value 'password' using Argon2id",getNewTransformer:()=>({id:Y.generateNewId(),type:"password"}),allowNewTransformer(r,o){return!o.service?.transformers?.some(e=>e.type==="password")&&o.model.fields.some(e=>e.name==="passwordHash")},getSummary:()=>[],pluginKey:void 0})],te={string:{label:"String",value:"string",description:"Variable length text"},int:{label:"Integer",value:"int",description:"Whole number"},float:{label:"Float",value:"float",description:"Decimal number"},decimal:{label:"Decimal",value:"decimal",description:"Precise decimal number"},boolean:{label:"Boolean",value:"boolean",description:"True or false value"},json:{label:"JSON",value:"json",description:"JSON data"},uuid:{label:"UUID",value:"uuid",description:"Unique identifier"},dateTime:{label:"DateTime",value:"dateTime",description:"Date and time"},date:{label:"Date",value:"date",description:"Calendar date"},enum:{label:"Enum",value:"enum",description:"List of values"}};export{oe as B,ee as E,te as S,A as u};
|
|
4
|
-
//# sourceMappingURL=-constants-
|
|
4
|
+
//# sourceMappingURL=-constants-Bo-HMfkg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-constants-PTFWy9Gi.js","sources":["../../src/hooks/use-deep.ts","../../src/routes/data/models/-hooks/use-edited-model-config.tsx","../../src/routes/data/models/edit.$key/-components/service/service-embedded-relation-form.tsx","../../src/routes/data/models/-constants.tsx"],"sourcesContent":["import { isEqual } from 'es-toolkit';\nimport { useRef } from 'react';\n\n/**\n * A hook that returns a deeply memoized value of a selector function.\n *\n * @param selector - The selector function to deeply memoize.\n */\nexport function useDeep<S, U>(selector: (state: S) => U): (state: S) => U {\n const prev = useRef<U>(undefined);\n\n return (state) => {\n const next = selector(state);\n if (isEqual(prev.current, next)) {\n return prev.current as U;\n }\n prev.current = next;\n return next;\n };\n}\n","import type {\n ModelConfig,\n ModelConfigInput,\n} from '@baseplate-dev/project-builder-lib';\nimport type React from 'react';\nimport type { UseFormGetValues, UseFormWatch } from 'react-hook-form';\nimport type { StoreApi } from 'zustand';\n\nimport { jsonDeepClone } from '@baseplate-dev/utils';\nimport { createContext, useContext, useEffect, useMemo } from 'react';\nimport { createStore, useStore } from 'zustand';\n\nimport { useDeep } from '#src/hooks/use-deep.js';\n\ninterface ModelConfigStore {\n model: ModelConfigInput;\n setModel: (model: ModelConfigInput) => void;\n getValues: UseFormGetValues<ModelConfigInput>;\n}\n\nconst EditedModelContext = createContext<\n StoreApi<ModelConfigStore> | undefined\n>(undefined);\n\nexport function EditedModelContextProvider({\n originalModel,\n children,\n watch,\n getValues,\n}: {\n originalModel: ModelConfig;\n children: React.ReactNode;\n watch: UseFormWatch<ModelConfigInput>;\n getValues: UseFormGetValues<ModelConfigInput>;\n}): React.JSX.Element {\n const store = useMemo(\n () =>\n createStore<ModelConfigStore>((set) => ({\n model: {\n ...originalModel,\n ...getValues(),\n },\n setModel: (model) => {\n set({\n model: {\n ...originalModel,\n ...model,\n },\n });\n },\n getValues,\n })),\n [originalModel, getValues],\n );\n\n useEffect(() => {\n const { unsubscribe } = watch((data) => {\n // We need to clone the data since React hook form data store is not immutable\n store.getState().setModel(jsonDeepClone(data as ModelConfigInput));\n });\n return unsubscribe;\n }, [watch, store]);\n\n return (\n <EditedModelContext.Provider value={store}>\n {children}\n </EditedModelContext.Provider>\n );\n}\n\nexport function useEditedModelConfig<T>(\n selector: (model: ModelConfigInput) => T,\n): T {\n const store = useContext(EditedModelContext);\n if (!store) {\n throw new Error(\n 'useEditedModelConfig must be used within a EditedModelContextProvider',\n );\n }\n return useStore(\n store,\n useDeep((state) => selector(state.model)),\n );\n}\n","import type { EmbeddedRelationTransformerConfig } from '@baseplate-dev/project-builder-lib';\nimport type {\n ModelTransformerWebConfig,\n ModelTransformerWebFormProps,\n} from '@baseplate-dev/project-builder-lib/web';\nimport type React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\n\nimport {\n modelTransformerEntityType,\n ModelTransformerUtils,\n ModelUtils,\n} from '@baseplate-dev/project-builder-lib';\nimport { useProjectDefinition } from '@baseplate-dev/project-builder-lib/web';\nimport {\n MultiComboboxFieldController,\n SelectFieldController,\n} from '@baseplate-dev/ui-components';\nimport { useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\n\nimport { usePrevious } from '#src/hooks/use-previous.js';\n\nimport { useEditedModelConfig } from '../../../-hooks/use-edited-model-config.js';\n\nfunction ServiceEmbeddedRelationForm({\n formProps,\n name,\n}: ModelTransformerWebFormProps): React.JSX.Element {\n // force type cast to avoid TS error\n const prefix = name as 'prefix';\n const formPropsTyped = formProps as unknown as UseFormReturn<{\n prefix: EmbeddedRelationTransformerConfig;\n }>;\n const { control, setValue } = formPropsTyped;\n\n const { definition, definitionContainer, pluginContainer } =\n useProjectDefinition();\n\n const transformer = useWatch({\n control,\n name: prefix,\n });\n\n const availableRelations = useEditedModelConfig((model) => {\n const relationsToModel = ModelUtils.getRelationsToModel(\n definition,\n model.id,\n );\n const otherEmbeddedRelations = model.service?.transformers?.filter(\n (t): t is EmbeddedRelationTransformerConfig =>\n t.type === 'embeddedRelation' && t.id !== transformer.id,\n );\n return relationsToModel.filter(\n ({ relation }) =>\n !otherEmbeddedRelations?.some(\n (o) => o.foreignRelationRef === relation.foreignId,\n ),\n );\n });\n\n const relationOptions = availableRelations.map((relation) => ({\n label: `${relation.relation.foreignRelationName} (${relation.model.name})`,\n value: relation.relation.foreignId,\n }));\n\n const embeddedTransformer =\n (transformer.type as string) === 'embeddedRelation' ? transformer : null;\n const relation = availableRelations.find(\n (r) => r.relation.foreignId === embeddedTransformer?.foreignRelationRef,\n );\n\n const previousForeignModelId = usePrevious(\n embeddedTransformer?.foreignRelationRef,\n );\n useEffect(() => {\n if (\n previousForeignModelId !== undefined &&\n previousForeignModelId !== embeddedTransformer?.foreignRelationRef\n ) {\n setValue(`${prefix}.embeddedFieldNames`, []);\n if (relation?.model.id) {\n setValue(`${prefix}.modelRef`, relation.model.id);\n }\n }\n }, [\n prefix,\n setValue,\n relation,\n embeddedTransformer?.foreignRelationRef,\n previousForeignModelId,\n availableRelations,\n ]);\n\n const foreignFieldOptions =\n relation?.model.model.fields\n .filter(\n (field) =>\n !relation.relation.references.some(\n (reference) => reference.localRef === field.id,\n ),\n )\n .map((field) => ({\n label: field.name,\n value: field.id,\n })) ?? [];\n\n const foreignTransformerOptions =\n relation?.model.service.transformers.map((transformer) => ({\n label: ModelTransformerUtils.getTransformName(\n definitionContainer,\n transformer,\n pluginContainer,\n ),\n value: transformer.id,\n })) ?? [];\n\n return (\n <div className={'space-y-4'}>\n <SelectFieldController\n control={control}\n name={`${prefix}.foreignRelationRef`}\n options={relationOptions}\n label=\"Relation\"\n placeholder=\"Select relation\"\n />\n <MultiComboboxFieldController\n control={control}\n disabled={foreignFieldOptions.length === 0}\n options={foreignFieldOptions}\n name={`${prefix}.embeddedFieldNames`}\n label=\"Embedded Field Names\"\n />\n {foreignTransformerOptions.length > 0 && (\n <MultiComboboxFieldController\n control={control}\n options={foreignTransformerOptions}\n name={`${prefix}.embeddedTransformerNames`}\n label=\"Embedded Transformers\"\n />\n )}\n </div>\n );\n}\n\nexport const embeddedRelationTransformerWebConfig: ModelTransformerWebConfig<EmbeddedRelationTransformerConfig> =\n {\n name: 'embeddedRelation',\n label: 'Embedded Relation',\n description: 'Upsert records to a related model table',\n instructions: `This transformer allows you to upsert related records to a related model's table\n e.g. UserRole records for a User. It will create, update, delete related records to fit the provided\n input.`,\n getSummary(definition, container) {\n return [\n {\n label: 'Embedded Relation',\n description: container.nameFromId(definition.foreignRelationRef),\n },\n ];\n },\n allowNewTransformer(projectContainer, model) {\n const { definition } = projectContainer;\n const relationsToModel = ModelUtils.getRelationsToModel(\n definition,\n model.id,\n );\n const otherEmbeddedRelations = model.service?.transformers?.filter(\n (t): t is EmbeddedRelationTransformerConfig =>\n t.type === 'embeddedRelation',\n );\n return relationsToModel.some(\n ({ relation }) =>\n !otherEmbeddedRelations?.some(\n (o) => o.foreignRelationRef === relation.foreignId,\n ),\n );\n },\n getNewTransformer: () => ({\n id: modelTransformerEntityType.generateNewId(),\n foreignRelationRef: '',\n type: 'embeddedRelation',\n embeddedFieldNames: [],\n modelRef: '',\n }),\n Form: ServiceEmbeddedRelationForm,\n pluginKey: undefined,\n };\n","import type { ScalarFieldType } from '@baseplate-dev/project-builder-lib';\n\nimport { modelTransformerEntityType } from '@baseplate-dev/project-builder-lib';\nimport { createNewModelTransformerWebConfig } from '@baseplate-dev/project-builder-lib/web';\n\nimport { embeddedRelationTransformerWebConfig } from './edit.$key/-components/service/service-embedded-relation-form.js';\n\nexport const BUILT_IN_TRANSFORMER_WEB_CONFIGS = [\n embeddedRelationTransformerWebConfig,\n createNewModelTransformerWebConfig({\n name: 'password',\n label: 'Password',\n description: \"Hashes the input value of value 'password' using Argon2id\",\n getNewTransformer: () => ({\n id: modelTransformerEntityType.generateNewId(),\n type: 'password',\n }),\n allowNewTransformer(_, modelConfig) {\n return (\n !modelConfig.service?.transformers?.some(\n (t) => t.type === 'password',\n ) && modelConfig.model.fields.some((f) => f.name === 'passwordHash')\n );\n },\n getSummary: () => [],\n pluginKey: undefined,\n }),\n];\n\nexport interface ScalarFieldTypeOption {\n label: string;\n value: string;\n description: string;\n}\n\nexport const SCALAR_FIELD_TYPE_OPTIONS: Record<\n ScalarFieldType,\n ScalarFieldTypeOption\n> = {\n string: {\n label: 'String',\n value: 'string',\n description: 'Variable length text',\n },\n int: {\n label: 'Integer',\n value: 'int',\n description: 'Whole number',\n },\n float: {\n label: 'Float',\n value: 'float',\n description: 'Decimal number',\n },\n decimal: {\n label: 'Decimal',\n value: 'decimal',\n description: 'Precise decimal number',\n },\n boolean: {\n label: 'Boolean',\n value: 'boolean',\n description: 'True or false value',\n },\n json: {\n label: 'JSON',\n value: 'json',\n description: 'JSON data',\n },\n uuid: {\n label: 'UUID',\n value: 'uuid',\n description: 'Unique identifier',\n },\n dateTime: {\n label: 'DateTime',\n value: 'dateTime',\n description: 'Date and time',\n },\n date: {\n label: 'Date',\n value: 'date',\n description: 'Calendar date',\n },\n enum: {\n label: 'Enum',\n value: 'enum',\n description: 'List of values',\n },\n};\n"],"names":["useRef","importShared","useDeep","selector","prev","state","next","isEqual","jsonDeepClone","createContext","useContext","useEffect","useMemo","EditedModelContext","EditedModelContextProvider","originalModel","children","watch","getValues","store","createStore","set","model","unsubscribe","data","useEditedModelConfig","useStore","modelTransformerEntityType","ModelTransformerUtils","ModelUtils","useProjectDefinition","MultiComboboxFieldController","SelectFieldController","ServiceEmbeddedRelationForm","formProps","name","prefix","formPropsTyped","control","setValue","definition","definitionContainer","pluginContainer","transformer","useWatch","availableRelations","relationsToModel","otherEmbeddedRelations","t","relation","o","relationOptions","embeddedTransformer","r","previousForeignModelId","usePrevious","foreignFieldOptions","field","reference","foreignTransformerOptions","jsxs","jsx","embeddedRelationTransformerWebConfig","container","projectContainer","createNewModelTransformerWebConfig","BUILT_IN_TRANSFORMER_WEB_CONFIGS","_","modelConfig","f","SCALAR_FIELD_TYPE_OPTIONS"],"mappings":"4PACA,KAAA,CAAA,OAAAA,CAAA,EAAA,MAAAC,EAAA,OAAA,EAOO,SAASC,EAAcC,EAA4C,CAClE,MAAAC,EAAOJ,EAAU,MAAS,EAEhC,OAAQK,GAAU,CACV,MAAAC,EAAOH,EAASE,CAAK,EA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ACxB,GAAItB,EAA2B,cAAc,EAC7C,mBAAoB,GACpB,KAAM,mBACN,mBAAoB,CAAC,EACrB,SAAU,EAAA,GAEZ,KAAMM,EACN,UAAW,MACb,ECzLF,CAAA,2BAAAN,CAAA,EAAA,MAAA1B,EAAA,oCAAA,EACA,CAAA,mCAAAgE,CAAA,EAAA,MAAAhE,EAAA,wCAAA,EAIaiE,GAAmC,CAC9CJ,EACAG,EAAmC,CACjC,KAAM,WACN,MAAO,WACP,YAAa,4DACb,kBAAmB,KAAO,CACxB,GAAItC,EAA2B,cAAc,EAC7C,KAAM,UAAA,GAER,oBAAoBwC,EAAGC,EAAa,CAEhC,MAAA,CAACA,EAAY,SAAS,cAAc,KACjCpB,GAAMA,EAAE,OAAS,UAAA,GACfoB,EAAY,MAAM,OAAO,KAAMC,GAAMA,EAAE,OAAS,cAAc,CAEvE,EACA,WAAY,IAAM,CAAC,EACnB,UAAW,MACZ,CAAA,CACH,EAQaC,GAGT,CACF,OAAQ,CACN,MAAO,SACP,MAAO,SACP,YAAa,sBACf,EACA,IAAK,CACH,MAAO,UACP,MAAO,MACP,YAAa,cACf,EACA,MAAO,CACL,MAAO,QACP,MAAO,QACP,YAAa,gBACf,EACA,QAAS,CACP,MAAO,UACP,MAAO,UACP,YAAa,wBACf,EACA,QAAS,CACP,MAAO,UACP,MAAO,UACP,YAAa,qBACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,WACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,mBACf,EACA,SAAU,CACR,MAAO,WACP,MAAO,WACP,YAAa,eACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,eACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,gBAAA,CAEjB"}
|
|
1
|
+
{"version":3,"file":"-constants-Bo-HMfkg.js","sources":["../../src/hooks/use-deep.ts","../../src/routes/data/models/-hooks/use-edited-model-config.tsx","../../src/routes/data/models/edit.$key/-components/service/service-embedded-relation-form.tsx","../../src/routes/data/models/-constants.tsx"],"sourcesContent":["import { isEqual } from 'es-toolkit';\nimport { useRef } from 'react';\n\n/**\n * A hook that returns a deeply memoized value of a selector function.\n *\n * @param selector - The selector function to deeply memoize.\n */\nexport function useDeep<S, U>(selector: (state: S) => U): (state: S) => U {\n const prev = useRef<U>(undefined);\n\n return (state) => {\n const next = selector(state);\n if (isEqual(prev.current, next)) {\n return prev.current as U;\n }\n prev.current = next;\n return next;\n };\n}\n","import type {\n ModelConfig,\n ModelConfigInput,\n} from '@baseplate-dev/project-builder-lib';\nimport type React from 'react';\nimport type { UseFormGetValues, UseFormWatch } from 'react-hook-form';\nimport type { StoreApi } from 'zustand';\n\nimport { jsonDeepClone } from '@baseplate-dev/utils';\nimport { createContext, useContext, useEffect, useMemo } from 'react';\nimport { createStore, useStore } from 'zustand';\n\nimport { useDeep } from '#src/hooks/use-deep.js';\n\ninterface ModelConfigStore {\n model: ModelConfigInput;\n setModel: (model: ModelConfigInput) => void;\n getValues: UseFormGetValues<ModelConfigInput>;\n}\n\nconst EditedModelContext = createContext<\n StoreApi<ModelConfigStore> | undefined\n>(undefined);\n\nexport function EditedModelContextProvider({\n originalModel,\n children,\n watch,\n getValues,\n}: {\n originalModel: ModelConfig;\n children: React.ReactNode;\n watch: UseFormWatch<ModelConfigInput>;\n getValues: UseFormGetValues<ModelConfigInput>;\n}): React.JSX.Element {\n const store = useMemo(\n () =>\n createStore<ModelConfigStore>((set) => ({\n model: {\n ...originalModel,\n ...getValues(),\n },\n setModel: (model) => {\n set({\n model: {\n ...originalModel,\n ...model,\n },\n });\n },\n getValues,\n })),\n [originalModel, getValues],\n );\n\n useEffect(() => {\n const { unsubscribe } = watch((data) => {\n // We need to clone the data since React hook form data store is not immutable\n store.getState().setModel(jsonDeepClone(data as ModelConfigInput));\n });\n return unsubscribe;\n }, [watch, store]);\n\n return (\n <EditedModelContext.Provider value={store}>\n {children}\n </EditedModelContext.Provider>\n );\n}\n\nexport function useEditedModelConfig<T>(\n selector: (model: ModelConfigInput) => T,\n): T {\n const store = useContext(EditedModelContext);\n if (!store) {\n throw new Error(\n 'useEditedModelConfig must be used within a EditedModelContextProvider',\n );\n }\n return useStore(\n store,\n useDeep((state) => selector(state.model)),\n );\n}\n","import type { EmbeddedRelationTransformerConfig } from '@baseplate-dev/project-builder-lib';\nimport type {\n ModelTransformerWebConfig,\n ModelTransformerWebFormProps,\n} from '@baseplate-dev/project-builder-lib/web';\nimport type React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\n\nimport {\n modelTransformerEntityType,\n ModelTransformerUtils,\n ModelUtils,\n} from '@baseplate-dev/project-builder-lib';\nimport { useProjectDefinition } from '@baseplate-dev/project-builder-lib/web';\nimport {\n MultiComboboxFieldController,\n SelectFieldController,\n} from '@baseplate-dev/ui-components';\nimport { useEffect } from 'react';\nimport { useWatch } from 'react-hook-form';\n\nimport { usePrevious } from '#src/hooks/use-previous.js';\n\nimport { useEditedModelConfig } from '../../../-hooks/use-edited-model-config.js';\n\nfunction ServiceEmbeddedRelationForm({\n formProps,\n name,\n}: ModelTransformerWebFormProps): React.JSX.Element {\n // force type cast to avoid TS error\n const prefix = name as 'prefix';\n const formPropsTyped = formProps as unknown as UseFormReturn<{\n prefix: EmbeddedRelationTransformerConfig;\n }>;\n const { control, setValue } = formPropsTyped;\n\n const { definition, definitionContainer, pluginContainer } =\n useProjectDefinition();\n\n const transformer = useWatch({\n control,\n name: prefix,\n });\n\n const availableRelations = useEditedModelConfig((model) => {\n const relationsToModel = ModelUtils.getRelationsToModel(\n definition,\n model.id,\n );\n const otherEmbeddedRelations = model.service?.transformers?.filter(\n (t): t is EmbeddedRelationTransformerConfig =>\n t.type === 'embeddedRelation' && t.id !== transformer.id,\n );\n return relationsToModel.filter(\n ({ relation }) =>\n !otherEmbeddedRelations?.some(\n (o) => o.foreignRelationRef === relation.foreignId,\n ),\n );\n });\n\n const relationOptions = availableRelations.map((relation) => ({\n label: `${relation.relation.foreignRelationName} (${relation.model.name})`,\n value: relation.relation.foreignId,\n }));\n\n const embeddedTransformer =\n (transformer.type as string) === 'embeddedRelation' ? transformer : null;\n const relation = availableRelations.find(\n (r) => r.relation.foreignId === embeddedTransformer?.foreignRelationRef,\n );\n\n const previousForeignModelId = usePrevious(\n embeddedTransformer?.foreignRelationRef,\n );\n useEffect(() => {\n if (\n previousForeignModelId !== undefined &&\n previousForeignModelId !== embeddedTransformer?.foreignRelationRef\n ) {\n setValue(`${prefix}.embeddedFieldNames`, []);\n if (relation?.model.id) {\n setValue(`${prefix}.modelRef`, relation.model.id);\n }\n }\n }, [\n prefix,\n setValue,\n relation,\n embeddedTransformer?.foreignRelationRef,\n previousForeignModelId,\n availableRelations,\n ]);\n\n const foreignFieldOptions =\n relation?.model.model.fields\n .filter(\n (field) =>\n !relation.relation.references.some(\n (reference) => reference.localRef === field.id,\n ),\n )\n .map((field) => ({\n label: field.name,\n value: field.id,\n })) ?? [];\n\n const foreignTransformerOptions =\n relation?.model.service.transformers.map((transformer) => ({\n label: ModelTransformerUtils.getTransformName(\n definitionContainer,\n transformer,\n pluginContainer,\n ),\n value: transformer.id,\n })) ?? [];\n\n return (\n <div className={'space-y-4'}>\n <SelectFieldController\n control={control}\n name={`${prefix}.foreignRelationRef`}\n options={relationOptions}\n label=\"Relation\"\n placeholder=\"Select relation\"\n />\n <MultiComboboxFieldController\n control={control}\n disabled={foreignFieldOptions.length === 0}\n options={foreignFieldOptions}\n name={`${prefix}.embeddedFieldNames`}\n label=\"Embedded Field Names\"\n />\n {foreignTransformerOptions.length > 0 && (\n <MultiComboboxFieldController\n control={control}\n options={foreignTransformerOptions}\n name={`${prefix}.embeddedTransformerNames`}\n label=\"Embedded Transformers\"\n />\n )}\n </div>\n );\n}\n\nexport const embeddedRelationTransformerWebConfig: ModelTransformerWebConfig<EmbeddedRelationTransformerConfig> =\n {\n name: 'embeddedRelation',\n label: 'Embedded Relation',\n description: 'Upsert records to a related model table',\n instructions: `This transformer allows you to upsert related records to a related model's table\n e.g. UserRole records for a User. It will create, update, delete related records to fit the provided\n input.`,\n getSummary(definition, container) {\n return [\n {\n label: 'Embedded Relation',\n description: container.nameFromId(definition.foreignRelationRef),\n },\n ];\n },\n allowNewTransformer(projectContainer, model) {\n const { definition } = projectContainer;\n const relationsToModel = ModelUtils.getRelationsToModel(\n definition,\n model.id,\n );\n const otherEmbeddedRelations = model.service?.transformers?.filter(\n (t): t is EmbeddedRelationTransformerConfig =>\n t.type === 'embeddedRelation',\n );\n return relationsToModel.some(\n ({ relation }) =>\n !otherEmbeddedRelations?.some(\n (o) => o.foreignRelationRef === relation.foreignId,\n ),\n );\n },\n getNewTransformer: () => ({\n id: modelTransformerEntityType.generateNewId(),\n foreignRelationRef: '',\n type: 'embeddedRelation',\n embeddedFieldNames: [],\n modelRef: '',\n }),\n Form: ServiceEmbeddedRelationForm,\n pluginKey: undefined,\n };\n","import type { ScalarFieldType } from '@baseplate-dev/project-builder-lib';\n\nimport { modelTransformerEntityType } from '@baseplate-dev/project-builder-lib';\nimport { createNewModelTransformerWebConfig } from '@baseplate-dev/project-builder-lib/web';\n\nimport { embeddedRelationTransformerWebConfig } from './edit.$key/-components/service/service-embedded-relation-form.js';\n\nexport const BUILT_IN_TRANSFORMER_WEB_CONFIGS = [\n embeddedRelationTransformerWebConfig,\n createNewModelTransformerWebConfig({\n name: 'password',\n label: 'Password',\n description: \"Hashes the input value of value 'password' using Argon2id\",\n getNewTransformer: () => ({\n id: modelTransformerEntityType.generateNewId(),\n type: 'password',\n }),\n allowNewTransformer(_, modelConfig) {\n return (\n !modelConfig.service?.transformers?.some(\n (t) => t.type === 'password',\n ) && modelConfig.model.fields.some((f) => f.name === 'passwordHash')\n );\n },\n getSummary: () => [],\n pluginKey: undefined,\n }),\n];\n\nexport interface ScalarFieldTypeOption {\n label: string;\n value: string;\n description: string;\n}\n\nexport const SCALAR_FIELD_TYPE_OPTIONS: Record<\n ScalarFieldType,\n ScalarFieldTypeOption\n> = {\n string: {\n label: 'String',\n value: 'string',\n description: 'Variable length text',\n },\n int: {\n label: 'Integer',\n value: 'int',\n description: 'Whole number',\n },\n float: {\n label: 'Float',\n value: 'float',\n description: 'Decimal number',\n },\n decimal: {\n label: 'Decimal',\n value: 'decimal',\n description: 'Precise decimal number',\n },\n boolean: {\n label: 'Boolean',\n value: 'boolean',\n description: 'True or false value',\n },\n json: {\n label: 'JSON',\n value: 'json',\n description: 'JSON data',\n },\n uuid: {\n label: 'UUID',\n value: 'uuid',\n description: 'Unique identifier',\n },\n dateTime: {\n label: 'DateTime',\n value: 'dateTime',\n description: 'Date and time',\n },\n date: {\n label: 'Date',\n value: 'date',\n description: 'Calendar date',\n },\n enum: {\n label: 'Enum',\n value: 'enum',\n description: 'List of values',\n },\n};\n"],"names":["useRef","importShared","useDeep","selector","prev","state","next","isEqual","jsonDeepClone","createContext","useContext","useEffect","useMemo","EditedModelContext","EditedModelContextProvider","originalModel","children","watch","getValues","store","createStore","set","model","unsubscribe","data","useEditedModelConfig","useStore","modelTransformerEntityType","ModelTransformerUtils","ModelUtils","useProjectDefinition","MultiComboboxFieldController","SelectFieldController","ServiceEmbeddedRelationForm","formProps","name","prefix","formPropsTyped","control","setValue","definition","definitionContainer","pluginContainer","transformer","useWatch","availableRelations","relationsToModel","otherEmbeddedRelations","t","relation","o","relationOptions","embeddedTransformer","r","previousForeignModelId","usePrevious","foreignFieldOptions","field","reference","foreignTransformerOptions","jsxs","jsx","embeddedRelationTransformerWebConfig","container","projectContainer","createNewModelTransformerWebConfig","BUILT_IN_TRANSFORMER_WEB_CONFIGS","_","modelConfig","f","SCALAR_FIELD_TYPE_OPTIONS"],"mappings":"4PACA,KAAA,CAAA,OAAAA,CAAA,EAAA,MAAAC,EAAA,OAAA,EAOO,SAASC,EAAcC,EAA4C,CAClE,MAAAC,EAAOJ,EAAU,MAAS,EAEhC,OAAQK,GAAU,CACV,MAAAC,EAAOH,EAASE,CAAK,EAC3B,OAAIE,EAAQH,EAAK,QAASE,CAA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AAoB,GACpB,KAAM,mBACN,mBAAoB,CAAC,EACrB,SAAU,EAAA,GAEZ,KAAMM,EACN,UAAW,MACb,ECzLF,CAAA,2BAAAN,CAAA,EAAA,MAAA1B,EAAA,oCAAA,EACA,CAAA,mCAAAgE,CAAA,EAAA,MAAAhE,EAAA,wCAAA,EAIaiE,GAAmC,CAC9CJ,EACAG,EAAmC,CACjC,KAAM,WACN,MAAO,WACP,YAAa,4DACb,kBAAmB,KAAO,CACxB,GAAItC,EAA2B,cAAc,EAC7C,KAAM,UAAA,GAER,oBAAoBwC,EAAGC,EAAa,CAEhC,MAAA,CAACA,EAAY,SAAS,cAAc,KACjCpB,GAAMA,EAAE,OAAS,UAAA,GACfoB,EAAY,MAAM,OAAO,KAAMC,GAAMA,EAAE,OAAS,cAAc,CAEvE,EACA,WAAY,IAAM,CAAC,EACnB,UAAW,MACZ,CAAA,CACH,EAQaC,GAGT,CACF,OAAQ,CACN,MAAO,SACP,MAAO,SACP,YAAa,sBACf,EACA,IAAK,CACH,MAAO,UACP,MAAO,MACP,YAAa,cACf,EACA,MAAO,CACL,MAAO,QACP,MAAO,QACP,YAAa,gBACf,EACA,QAAS,CACP,MAAO,UACP,MAAO,UACP,YAAa,wBACf,EACA,QAAS,CACP,MAAO,UACP,MAAO,UACP,YAAa,qBACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,WACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,mBACf,EACA,SAAU,CACR,MAAO,WACP,MAAO,WACP,YAAa,eACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,eACf,EACA,KAAM,CACJ,MAAO,OACP,MAAO,OACP,YAAa,gBAAA,CAEjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as t}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{z as v,s as y}from"./index-
|
|
2
|
-
//# sourceMappingURL=admin-
|
|
1
|
+
import{i as t}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{z as v,s as y}from"./index-D_oO4W9-.js";import{K as R}from"./index-B6LhSOJ-.js";import{u as F}from"./use-definition-schema-Bxe6QzcW.js";const{appEntityType:L,authConfigSpec:P,createWebAppSchema:D}=await t("@baseplate-dev/project-builder-lib"),{useBlockUnsavedChangesNavigate:k,useProjectDefinition:E,useResettableForm:M}=await t("@baseplate-dev/project-builder-lib/web"),{Button:W,FormActionBar:B,InputFieldController:K,MultiComboboxFieldController:N,SectionList:U,SectionListSection:p,SectionListSectionContent:m,SectionListSectionDescription:u,SectionListSectionHeader:h,SectionListSectionTitle:x,SwitchFieldController:I}=await t("@baseplate-dev/ui-components"),{Link:O}=await t("@tanstack/react-router"),J=function(){const{webDefinition:o}=v.useRouteContext(),{definition:b,saveDefinitionWithFeedback:f,pluginContainer:j}=E(),S=F(D),a=M({resolver:y(S),values:o}),{control:i,handleSubmit:A,reset:g,watch:w}=a,s=A(n=>f(l=>{l.apps=l.apps.map(d=>d.id===o.id?n:d)}));k({control:i,reset:g,onSubmit:s});const r=j.getPluginSpecOptional(P)?.getAuthRoles(b).map(n=>({label:n.name,value:n.id})),c=w("adminApp.enabled"),C=L.keyFromId(o.id);return e.jsxs("form",{className:"w-full max-w-7xl space-y-4 p-4",onSubmit:s,children:[e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsxs(h,{children:[e.jsx(x,{children:"Admin Configuration"}),e.jsx(u,{children:"Configure administrative features for your web application."})]}),e.jsxs(m,{className:"space-y-6",children:[e.jsx(I,{label:"Enable Admin Panel",description:"Add administrative interface to your web application",control:i,name:"adminApp.enabled"}),c&&e.jsxs(e.Fragment,{children:[e.jsx(K,{label:"Admin Path Prefix",placeholder:"/admin",description:"URL prefix for admin routes (e.g. /admin)",control:i,name:"adminApp.pathPrefix"}),r&&e.jsx(N,{label:"Admin Access Roles",description:"Which roles can access the admin panel",control:i,options:r,name:"adminApp.allowedRoles"})]})]})]}),c&&e.jsxs(p,{children:[e.jsxs(h,{children:[e.jsx(x,{children:"Admin Sections"}),e.jsx(u,{children:"Manage CRUD interfaces for your data models."})]}),e.jsx(m,{children:e.jsx(W,{variant:"secondary",asChild:!0,children:e.jsxs(O,{to:"/admin-sections/$appKey",params:{appKey:C},children:[e.jsx(R,{}),"Manage Admin Sections"]})})})]})]}),e.jsx(B,{form:a})]})};export{J as component};
|
|
2
|
+
//# sourceMappingURL=admin-BfRT8oJm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-
|
|
1
|
+
{"version":3,"file":"admin-BfRT8oJm.js","sources":["../../src/routes/apps/edit.$key/web/admin.tsx?tsr-split=component"],"sourcesContent":["import type React from 'react';\n\nimport {\n appEntityType,\n authConfigSpec,\n createWebAppSchema,\n} from '@baseplate-dev/project-builder-lib';\nimport {\n useBlockUnsavedChangesNavigate,\n useProjectDefinition,\n useResettableForm,\n} from '@baseplate-dev/project-builder-lib/web';\nimport {\n Button,\n FormActionBar,\n InputFieldController,\n MultiComboboxFieldController,\n SectionList,\n SectionListSection,\n SectionListSectionContent,\n SectionListSectionDescription,\n SectionListSectionHeader,\n SectionListSectionTitle,\n SwitchFieldController,\n} from '@baseplate-dev/ui-components';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { createFileRoute, Link } from '@tanstack/react-router';\nimport { MdSettings } from 'react-icons/md';\n\nimport { useDefinitionSchema } from '#src/hooks/use-definition-schema.js';\n\nexport const Route = createFileRoute('/apps/edit/$key/web/admin')({\n component: WebAdminPage,\n});\n\nfunction WebAdminPage(): React.JSX.Element {\n const { webDefinition } = Route.useRouteContext();\n const { definition, saveDefinitionWithFeedback, pluginContainer } =\n useProjectDefinition();\n const webAppSchema = useDefinitionSchema(createWebAppSchema);\n\n const formProps = useResettableForm({\n resolver: zodResolver(webAppSchema),\n values: webDefinition,\n });\n const { control, handleSubmit, reset, watch } = formProps;\n\n const onSubmit = handleSubmit((data) =>\n saveDefinitionWithFeedback((draftConfig) => {\n draftConfig.apps = draftConfig.apps.map((app) =>\n app.id === webDefinition.id ? data : app,\n );\n }),\n );\n\n useBlockUnsavedChangesNavigate({ control, reset, onSubmit });\n\n const roleOptions = pluginContainer\n .getPluginSpecOptional(authConfigSpec)\n ?.getAuthRoles(definition)\n .map((role) => ({\n label: role.name,\n value: role.id,\n }));\n\n const adminEnabled = watch('adminApp.enabled');\n\n // Get the app key for navigation\n const appKey = appEntityType.keyFromId(webDefinition.id);\n\n return (\n <form className=\"w-full max-w-7xl space-y-4 p-4\" onSubmit={onSubmit}>\n <SectionList>\n <SectionListSection>\n <SectionListSectionHeader>\n <SectionListSectionTitle>\n Admin Configuration\n </SectionListSectionTitle>\n <SectionListSectionDescription>\n Configure administrative features for your web application.\n </SectionListSectionDescription>\n </SectionListSectionHeader>\n <SectionListSectionContent className=\"space-y-6\">\n <SwitchFieldController\n label=\"Enable Admin Panel\"\n description=\"Add administrative interface to your web application\"\n control={control}\n name=\"adminApp.enabled\"\n />\n\n {adminEnabled && (\n <>\n <InputFieldController\n label=\"Admin Path Prefix\"\n placeholder=\"/admin\"\n description=\"URL prefix for admin routes (e.g. /admin)\"\n control={control}\n name=\"adminApp.pathPrefix\"\n />\n\n {roleOptions && (\n <MultiComboboxFieldController\n label=\"Admin Access Roles\"\n description=\"Which roles can access the admin panel\"\n control={control}\n options={roleOptions}\n name=\"adminApp.allowedRoles\"\n />\n )}\n </>\n )}\n </SectionListSectionContent>\n </SectionListSection>\n\n {adminEnabled && (\n <SectionListSection>\n <SectionListSectionHeader>\n <SectionListSectionTitle>Admin Sections</SectionListSectionTitle>\n <SectionListSectionDescription>\n Manage CRUD interfaces for your data models.\n </SectionListSectionDescription>\n </SectionListSectionHeader>\n <SectionListSectionContent>\n <Button variant=\"secondary\" asChild>\n <Link to=\"/admin-sections/$appKey\" params={{ appKey }}>\n <MdSettings />\n Manage Admin Sections\n </Link>\n </Button>\n </SectionListSectionContent>\n </SectionListSection>\n )}\n </SectionList>\n <FormActionBar form={formProps} />\n </form>\n );\n}\n"],"names":["appEntityType","authConfigSpec","createWebAppSchema","importShared","useBlockUnsavedChangesNavigate","useProjectDefinition","useResettableForm","Button","FormActionBar","InputFieldController","MultiComboboxFieldController","SectionList","SectionListSection","SectionListSectionContent","SectionListSectionDescription","SectionListSectionHeader","SectionListSectionTitle","SwitchFieldController","Link","SplitComponent","webDefinition","Route","useRouteContext","definition","saveDefinitionWithFeedback","pluginContainer","webAppSchema","useDefinitionSchema","formProps","resolver","zodResolver","values","control","handleSubmit","reset","watch","onSubmit","draftConfig","apps","map","app","id","data","roleOptions","getPluginSpecOptional","getAuthRoles","role","label","name","value","adminEnabled","appKey","keyFromId","jsxs","jsx","Fragment","MdSettings"],"mappings":"+PAEA,KAAA,CAAA,cAAAA,EAAA,eAAAC,EAAA,mBAAAC,CAAA,EAAA,MAAAC,EAAA,oCAAA,EAKA,CAAA,+BAAAC,EAAA,qBAAAC,EAAA,kBAAAC,CAAA,EAAA,MAAAH,EAAA,wCAAA,EAKA,CAAA,OAAAI,EAAA,cAAAC,EAAA,qBAAAC,EAAA,6BAAAC,EAAA,YAAAC,EAAA,mBAAAC,EAAA,0BAAAC,EAAA,8BAAAC,EAAA,yBAAAC,EAAA,wBAAAC,EAAA,sBAAAC,CAAA,EAAA,MAAAd,EAAA,8BAAA,EAcA,CAAA,KAAAe,CAAA,EAAA,MAAAf,EAAA,wBAAA,EAG0EgB,EAAA,UAM/B,CACnC,KAAA,CAAEC,cAAAA,CAAAA,EAAkBC,EAAMC,gBAAgB,EAC1C,CAAEC,WAAAA,EAAYC,2BAAAA,EAA4BC,gBAAAA,GAC9CpB,EAAqB,EACjBqB,EAAeC,EAAoBzB,CAAkB,EAErD0B,EAAYtB,EAAkB,CAClCuB,SAAUC,EAAYJ,CAAY,EAClCK,OAAQX,CAAAA,CACT,EACK,CAAEY,QAAAA,EAASC,aAAAA,EAAcC,MAAAA,EAAOC,MAAAA,CAA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AAA,CAAAuC,EAAAA,IAACtC,GAAwB,SAAc,gBAAA,CAAA,EACvCsC,EAAAA,IAACxC,GAA6B,SAE9B,8CAAA,CAAA,CAAA,EACF,EACCwC,EAAA,IAAAzC,EAAA,CACC,SAACyC,EAAA,IAAA/C,EAAA,CAAO,QAAQ,YAAY,QAAO,GACjC,SAAC8C,OAAAnC,EAAA,CAAK,GAAG,0BAA0B,OAAQ,CAAEiC,OAAAA,CAC3C,EAAA,SAAA,CAAAG,EAAA,IAACE,EAAU,EAAA,EAAA,uBAAA,CAEb,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,EAEJ,EACAF,EAAAA,IAAC9C,EAAc,CAAA,KAAMoB,CAAU,CAAA,CAAA,EACjC,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as s}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{g as k,s as g}from"./index-
|
|
2
|
-
//# sourceMappingURL=backend-
|
|
1
|
+
import{i as s}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{g as k,s as g}from"./index-D_oO4W9-.js";import{u as v}from"./use-definition-schema-Bxe6QzcW.js";const{createBackendAppSchema:L}=await s("@baseplate-dev/project-builder-lib"),{useBlockUnsavedChangesNavigate:E,useProjectDefinition:B,useResettableForm:P}=await s("@baseplate-dev/project-builder-lib/web"),{FormActionBar:w,InputFieldController:l,SectionList:y,SectionListSection:p,SectionListSectionContent:d,SectionListSectionDescription:b,SectionListSectionHeader:m,SectionListSectionTitle:u,SwitchFieldController:i}=await s("@baseplate-dev/ui-components"),N=function(){const{saveDefinitionWithFeedback:x}=B(),{backendDefinition:n}=k.useLoaderData(),j=v(L),o=P({resolver:g(j),values:n}),{control:a,handleSubmit:h,reset:S}=o,t=h(f=>x(r=>{r.apps=r.apps.map(c=>c.id===n.id?f:c)}));return E({control:a,reset:S,onSubmit:t}),e.jsxs("form",{className:"w-full max-w-7xl space-y-4 px-4",onSubmit:t,children:[e.jsxs(y,{children:[e.jsxs(p,{children:[e.jsxs(m,{children:[e.jsx(u,{children:"General"}),e.jsx(b,{children:"Basic configuration for your backend application."})]}),e.jsxs(d,{className:"space-y-6",children:[e.jsx(l,{label:"Name",control:a,name:"name"}),e.jsx(l,{label:"Package Location (optional)",placeholder:"e.g. packages/backend",control:a,name:"packageLocation"})]})]}),e.jsxs(p,{children:[e.jsxs(m,{children:[e.jsx(u,{children:"Configuration"}),e.jsx(b,{children:"Enable or disable external services and features for your backend application."})]}),e.jsx(d,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(i,{control:a,name:"enableStripe",label:"Stripe",description:"Enable Stripe for payment processing"}),e.jsx(i,{control:a,name:"enablePostmark",label:"Postmark",description:"Enable Postmark for email delivery"}),e.jsx(i,{control:a,name:"enableRedis",label:"Redis",description:"Enable Redis for caching and session storage"}),e.jsx(i,{control:a,name:"enableBullQueue",label:"Bull Queue",description:"Enable Bull Queue for background job processing"}),e.jsx(i,{control:a,name:"enableSubscriptions",label:"GraphQL Subscriptions",description:"Enable GraphQL Subscriptions for real-time updates"}),e.jsx(i,{control:a,name:"enableAxios",label:"Axios",description:"Enable Axios for HTTP requests"})]})})]})]}),e.jsx(w,{form:o})]})};export{N as component};
|
|
2
|
+
//# sourceMappingURL=backend-DrT1hDB6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-
|
|
1
|
+
{"version":3,"file":"backend-DrT1hDB6.js","sources":["../../src/routes/apps/edit.$key/backend.tsx?tsr-split=component"],"sourcesContent":["import type React from 'react';\n\nimport { createBackendAppSchema } from '@baseplate-dev/project-builder-lib';\nimport {\n useBlockUnsavedChangesNavigate,\n useProjectDefinition,\n useResettableForm,\n} from '@baseplate-dev/project-builder-lib/web';\nimport {\n FormActionBar,\n InputFieldController,\n SectionList,\n SectionListSection,\n SectionListSectionContent,\n SectionListSectionDescription,\n SectionListSectionHeader,\n SectionListSectionTitle,\n SwitchFieldController,\n} from '@baseplate-dev/ui-components';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { createFileRoute, notFound, redirect } from '@tanstack/react-router';\n\nimport { useDefinitionSchema } from '#src/hooks/use-definition-schema.js';\n\nexport const Route = createFileRoute('/apps/edit/$key/backend')({\n component: BackendAppEditPage,\n loader: ({ context: { app }, params: { key } }) => {\n if (!app) throw notFound();\n if (app.type !== 'backend') {\n throw redirect({ to: '/apps/edit/$key', params: { key } });\n }\n return {\n backendDefinition: app,\n };\n },\n});\n\nfunction BackendAppEditPage(): React.JSX.Element {\n const { saveDefinitionWithFeedback } = useProjectDefinition();\n const { backendDefinition } = Route.useLoaderData();\n\n const backendAppSchema = useDefinitionSchema(createBackendAppSchema);\n const formProps = useResettableForm({\n resolver: zodResolver(backendAppSchema),\n values: backendDefinition,\n });\n const { control, handleSubmit, reset } = formProps;\n\n const onSubmit = handleSubmit((data) =>\n saveDefinitionWithFeedback((draftConfig) => {\n draftConfig.apps = draftConfig.apps.map((app) =>\n app.id === backendDefinition.id ? data : app,\n );\n }),\n );\n\n useBlockUnsavedChangesNavigate({ control, reset, onSubmit });\n\n return (\n <form className=\"w-full max-w-7xl space-y-4 px-4\" onSubmit={onSubmit}>\n <SectionList>\n <SectionListSection>\n <SectionListSectionHeader>\n <SectionListSectionTitle>General</SectionListSectionTitle>\n <SectionListSectionDescription>\n Basic configuration for your backend application.\n </SectionListSectionDescription>\n </SectionListSectionHeader>\n <SectionListSectionContent className=\"space-y-6\">\n <InputFieldController label=\"Name\" control={control} name=\"name\" />\n <InputFieldController\n label=\"Package Location (optional)\"\n placeholder=\"e.g. packages/backend\"\n control={control}\n name=\"packageLocation\"\n />\n </SectionListSectionContent>\n </SectionListSection>\n\n <SectionListSection>\n <SectionListSectionHeader>\n <SectionListSectionTitle>Configuration</SectionListSectionTitle>\n <SectionListSectionDescription>\n Enable or disable external services and features for your backend\n application.\n </SectionListSectionDescription>\n </SectionListSectionHeader>\n <SectionListSectionContent>\n <div className=\"space-y-4\">\n <SwitchFieldController\n control={control}\n name=\"enableStripe\"\n label=\"Stripe\"\n description=\"Enable Stripe for payment processing\"\n />\n <SwitchFieldController\n control={control}\n name=\"enablePostmark\"\n label=\"Postmark\"\n description=\"Enable Postmark for email delivery\"\n />\n <SwitchFieldController\n control={control}\n name=\"enableRedis\"\n label=\"Redis\"\n description=\"Enable Redis for caching and session storage\"\n />\n <SwitchFieldController\n control={control}\n name=\"enableBullQueue\"\n label=\"Bull Queue\"\n description=\"Enable Bull Queue for background job processing\"\n />\n <SwitchFieldController\n control={control}\n name=\"enableSubscriptions\"\n label=\"GraphQL Subscriptions\"\n description=\"Enable GraphQL Subscriptions for real-time updates\"\n />\n <SwitchFieldController\n control={control}\n name=\"enableAxios\"\n label=\"Axios\"\n description=\"Enable Axios for HTTP requests\"\n />\n </div>\n </SectionListSectionContent>\n </SectionListSection>\n </SectionList>\n <FormActionBar form={formProps} />\n </form>\n );\n}\n"],"names":["createBackendAppSchema","importShared","useBlockUnsavedChangesNavigate","useProjectDefinition","useResettableForm","FormActionBar","InputFieldController","SectionList","SectionListSection","SectionListSectionContent","SectionListSectionDescription","SectionListSectionHeader","SectionListSectionTitle","SwitchFieldController","SplitComponent","saveDefinitionWithFeedback","backendDefinition","Route","useLoaderData","backendAppSchema","useDefinitionSchema","formProps","resolver","zodResolver","values","control","handleSubmit","reset","onSubmit","draftConfig","apps","map","app","id","data","jsxs","jsx"],"mappings":"uNAEA,KAAA,CAAA,uBAAAA,CAAA,EAAA,MAAAC,EAAA,oCAAA,EACA,CAAA,+BAAAC,EAAA,qBAAAC,EAAA,kBAAAC,CAAA,EAAA,MAAAH,EAAA,wCAAA,EAKA,CAAA,cAAAI,EAAA,qBAAAC,EAAA,YAAAC,EAAA,mBAAAC,EAAA,0BAAAC,EAAA,8BAAAC,EAAA,yBAAAC,EAAA,wBAAAC,EAAA,sBAAAC,CAAA,EAAA,MAAAZ,EAAA,8B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B,EAAA,CACC,SAAC0B,EAAAA,KAAA,MAAA,CAAI,UAAU,YACb,SAAA,CAAAC,MAACvB,GACC,QAAAY,EACA,KAAK,eACL,MAAM,SACN,YAAY,uCAAsC,EAEpDW,MAACvB,GACC,QAAAY,EACA,KAAK,iBACL,MAAM,WACN,YAAY,qCAAoC,EAElDW,MAACvB,GACC,QAAAY,EACA,KAAK,cACL,MAAM,QACN,YAAY,+CAA8C,EAE5DW,MAACvB,GACC,QAAAY,EACA,KAAK,kBACL,MAAM,aACN,YAAY,kDAAiD,EAE/DW,MAACvB,GACC,QAAAY,EACA,KAAK,sBACL,MAAM,wBACN,YAAY,qDAAoD,EAElEW,MAACvB,GACC,QAAAY,EACA,KAAK,cACL,MAAM,QACN,YAAY,gCAAgC,CAAA,CAAA,CAAA,CAEhD,CACF,CAAA,CAAA,CACF,CAAA,CAAA,EACF,EACAW,EAAAA,IAAC/B,EAAc,CAAA,KAAMgB,CAAU,CAAA,CAAA,EACjC,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as t}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{d as l,N as j,e as P,l as g}from"./index-
|
|
2
|
-
//# sourceMappingURL=edit._key-
|
|
1
|
+
import{i as t}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{d as l,N as j,e as P,l as g}from"./index-D_oO4W9-.js";const{createPluginImplementationStoreWithNewPlugins:D,PluginUtils:f,webConfigSpec:m}=await t("@baseplate-dev/project-builder-lib"),{useProjectDefinition:v}=await t("@baseplate-dev/project-builder-lib/web"),{Button:S,DropdownMenu:y,DropdownMenuContent:N,DropdownMenuGroup:M,DropdownMenuItem:k,DropdownMenuTrigger:W,useConfirmDialog:A}=await t("@baseplate-dev/ui-components"),{useNavigate:F}=await t("@tanstack/react-router"),{useMemo:E}=await t("react"),B=function(){const{definitionContainer:o,pluginContainer:r,schemaParserContext:a,saveDefinitionWithFeedbackSync:x,isSavingDefinition:b}=v(),{key:i}=l.useParams(),{requestConfirm:h}=A(),c=F({from:l.fullPath}),{pluginMetadata:n}=l.useLoaderData(),s=f.byKey(o.definition,i),u=E(()=>{if(!i)return;const p=r.getPluginSpec(m).getWebConfigComponent(i);return p||D(a.pluginStore,[n],o.definition).getPluginSpec(m).getWebConfigComponent(i)},[i,a,o,r,n]);if(!u)return e.jsx(j,{});function C(){x(d=>{f.disablePlugin(d,n.key,a)},{successMessage:`Disabled ${n.displayName}!`,onSuccess:()=>{c({to:"/plugins"}).catch(g)}})}function w(){s||c({to:"/plugins"}).catch(g)}return e.jsx("div",{className:"relative flex h-full flex-1 flex-col gap-4 overflow-hidden",children:e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h1",{children:[n.displayName," Plugin"]}),s&&e.jsxs(y,{children:[e.jsx(W,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",children:e.jsx(P,{"aria-label":"More Actions"})})}),e.jsx(N,{children:e.jsx(M,{children:e.jsx(k,{disabled:b,onSelect:()=>{h({title:"Disable Plugin",content:`Are you sure you want to disable the ${n.displayName} plugin?`,onConfirm:C})},children:"Disable Plugin"})})})]})]}),e.jsx(u,{definition:s,metadata:n,onSave:w})]})})};export{B as component};
|
|
2
|
+
//# sourceMappingURL=edit._key-CbUXCYlN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit._key-
|
|
1
|
+
{"version":3,"file":"edit._key-CbUXCYlN.js","sources":["../../src/routes/plugins/edit.$key.tsx?tsr-split=component"],"sourcesContent":["import type React from 'react';\n\nimport {\n createPluginImplementationStoreWithNewPlugins,\n getPluginMetadataByKey,\n PluginUtils,\n webConfigSpec,\n} from '@baseplate-dev/project-builder-lib';\nimport { useProjectDefinition } from '@baseplate-dev/project-builder-lib/web';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuTrigger,\n useConfirmDialog,\n} from '@baseplate-dev/ui-components';\nimport { createFileRoute, notFound, useNavigate } from '@tanstack/react-router';\nimport { useMemo } from 'react';\nimport { HiDotsVertical } from 'react-icons/hi';\n\nimport { NotFoundCard } from '#src/components/index.js';\nimport { logAndFormatError } from '#src/services/error-formatter.js';\n\nexport const Route = createFileRoute('/plugins/edit/$key')({\n component: PluginConfigPage,\n beforeLoad: ({ params: { key }, context: { schemaParserContext } }) => {\n const pluginMetadata = getPluginMetadataByKey(\n schemaParserContext.pluginStore,\n key,\n );\n if (!pluginMetadata) return {};\n return {\n getTitle: () => pluginMetadata.displayName,\n pluginMetadata,\n };\n },\n loader: ({ context: { pluginMetadata } }) => {\n if (!pluginMetadata) throw notFound();\n return { pluginMetadata };\n },\n});\n\nfunction PluginConfigPage(): React.JSX.Element {\n const {\n definitionContainer,\n pluginContainer,\n schemaParserContext,\n saveDefinitionWithFeedbackSync,\n isSavingDefinition,\n } = useProjectDefinition();\n const { key } = Route.useParams();\n const { requestConfirm } = useConfirmDialog();\n const navigate = useNavigate({ from: Route.fullPath });\n const { pluginMetadata } = Route.useLoaderData();\n\n const pluginDefinition = PluginUtils.byKey(\n definitionContainer.definition,\n key,\n );\n\n const Container = useMemo(() => {\n if (!key) {\n return;\n }\n\n const pluginSpec = pluginContainer.getPluginSpec(webConfigSpec);\n const webConfigComponent = pluginSpec.getWebConfigComponent(key);\n if (webConfigComponent) {\n return webConfigComponent;\n }\n const newPluginContainer = createPluginImplementationStoreWithNewPlugins(\n schemaParserContext.pluginStore,\n [pluginMetadata],\n definitionContainer.definition,\n );\n\n return newPluginContainer\n .getPluginSpec(webConfigSpec)\n .getWebConfigComponent(key);\n }, [\n key,\n schemaParserContext,\n definitionContainer,\n pluginContainer,\n pluginMetadata,\n ]);\n\n if (!Container) {\n return <NotFoundCard />;\n }\n\n function onDisablePlugin(): void {\n saveDefinitionWithFeedbackSync(\n (draft) => {\n PluginUtils.disablePlugin(\n draft,\n pluginMetadata.key,\n schemaParserContext,\n );\n },\n {\n successMessage: `Disabled ${pluginMetadata.displayName}!`,\n onSuccess: () => {\n navigate({ to: '/plugins' }).catch(logAndFormatError);\n },\n },\n );\n }\n\n function onSave(): void {\n if (!pluginDefinition) {\n navigate({ to: '/plugins' }).catch(logAndFormatError);\n }\n }\n\n return (\n <div className=\"relative flex h-full flex-1 flex-col gap-4 overflow-hidden\">\n <div className=\"flex flex-1 flex-col gap-4 overflow-y-auto p-4\">\n <div className=\"flex items-center justify-between\">\n <h1>{pluginMetadata.displayName} Plugin</h1>\n {pluginDefinition && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\">\n <HiDotsVertical aria-label=\"More Actions\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuGroup>\n <DropdownMenuItem\n disabled={isSavingDefinition}\n onSelect={() => {\n requestConfirm({\n title: 'Disable Plugin',\n content: `Are you sure you want to disable the ${pluginMetadata.displayName} plugin?`,\n onConfirm: onDisablePlugin,\n });\n }}\n >\n Disable Plugin\n </DropdownMenuItem>\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n <Container\n definition={pluginDefinition}\n metadata={pluginMetadata}\n onSave={onSave}\n />\n </div>\n </div>\n );\n}\n"],"names":["createPluginImplementationStoreWithNewPlugins","PluginUtils","webConfigSpec","importShared","useProjectDefinition","Button","DropdownMenu","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","DropdownMenuTrigger","useConfirmDialog","useNavigate","useMemo","SplitComponent","definitionContainer","pluginContainer","schemaParserContext","saveDefinitionWithFeedbackSync","isSavingDefinition","key","Route","useParams","requestConfirm","navigate","from","fullPath","pluginMetadata","useLoaderData","pluginDefinition","byKey","definition","Container","webConfigComponent","getPluginSpec","getWebConfigComponent","pluginStore","NotFoundCard","onDisablePlugin","draft","disablePlugin","successMessage","displayName","onSuccess","to","catch","logAndFormatError","onSave","jsxs","jsx","HiDotsVertical","title","content","onConfirm"],"mappings":"6KAEA,KAAA,CAAA,8CAAAA,EAAA,YAAAC,EAAA,cAAAC,CAAA,EAAA,MAAAC,EAAA,oCAAA,EAMA,CAAA,qBAAAC,CAAA,EAAA,MAAAD,EAAA,wCAAA,EACA,CAAA,OAAAE,EAAA,aAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,oBAAAC,EAAA,iBAAAC,CAAA,EAAA,MAAAR,EAAA,8BAAA,EASA,CAAA,YAAAS,CAAA,EAAA,MAAAT,EAAA,wBAAA,EACA,CAAA,QAAAU,CAAA,EAAA,MAAAV,EAAA,OAAA,EAIqEW,EAAA,UAqBtB,CACvC,KAAA,CACJC,oBAAAA,EACAC,gBAAAA,EACAC,oBAAAA,EACAC,+BAAAA,EACAC,mBAAAA,GACEf,EAAqB,EACnB,CAAEgB,IAAAA,CAAAA,EAAQC,EAAMC,UAAU,EAC1B,CAAEC,eAAAA,GAAmBZ,EAAiB,EACtCa,EAAWZ,EAAY,CAAEa,KAAMJ,EAAMK,QAAAA,CAAU,EAC/C,CAAEC,eAAAA,CAAAA,EAAmBN,EAAMO,cAAc,EAEzCC,EAAmB5B,EAAY6B,MACnCf,EAAoBgB,WACpBX,CACF,EAEMY,EAAYnB,EAAQ,IAAM,CAC9B,GAAI,CAACO,EACH,OAIIa,MAAAA,EADajB,EAAgBkB,cAAchC,CAAa,EACxBiC,sBAAsBf,CAAG,EAC/D,OAAIa,GAGuBjC,EACzBiB,EAAoBmB,YACpB,CAACT,CAAc,EACfZ,EAAoBgB,UACtB,EAGGG,cAAchC,CAAa,EAC3BiC,sBAAsBf,CAAG,CAAA,EAC3B,CACDA,EACAH,EACAF,EACAC,EACAW,CAAc,CACf,EAED,GAAI,CAACK,EACH,aAAQK,EAAe,EAAA,EAGzB,SAASC,GAAwB,CAC/BpB,EACaqB,GAAA,CACTtC,EAAYuC,cACVD,EACAZ,EAAeP,IACfH,CACF,CAAA,EAEF,CACEwB,eAAgB,YAAYd,EAAee,WAAW,IACtDC,UAAWA,IAAM,CACNnB,EAAA,CAAEoB,GAAI,UAAA,CAAY,EAAEC,MAAMC,CAAiB,CAAA,CACtD,CAEJ,CAAA,CAGF,SAASC,GAAe,CACjBlB,GACML,EAAA,CAAEoB,GAAI,UAAA,CAAY,EAAEC,MAAMC,CAAiB,CACtD,CAGF,aACG,MAAI,CAAA,UAAU,6DACb,SAACE,EAAA,KAAA,MAAA,CAAI,UAAU,iDACb,SAAA,CAACA,EAAAA,KAAA,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAA,OAAC,KAAIrB,CAAAA,SAAAA,CAAee,EAAAA,YAAY,SAAA,EAAO,EACtCb,UACEvB,EACC,CAAA,SAAA,CAAA2C,MAACvC,EAAoB,CAAA,QAAO,GAC1B,SAAAuC,EAAA,IAAC5C,GAAO,QAAQ,QAAQ,KAAK,OAC3B,SAAC4C,EAAAA,IAAAC,EAAA,CAAe,aAAW,cAAA,CAAc,CAC3C,CAAA,EACF,EACAD,EAAAA,IAAC1C,GACC,SAAC0C,EAAAA,IAAAzC,EAAA,CACC,eAACC,EACC,CAAA,SAAUU,EACV,SAAU,IAAM,CACCI,EAAA,CACb4B,MAAO,iBACPC,QAAS,wCAAwCzB,EAAee,WAAW,WAC3EW,UAAWf,CAAAA,CACZ,CACH,EAAE,SAGJ,iBAAA,CAAA,CACF,CACF,CAAA,CAAA,CACF,CAAA,CAAA,EAEJ,QACCN,EACC,CAAA,WAAYH,EACZ,SAAUF,EACV,OAAAoB,CAAe,CAAA,CAAA,CAAA,CAEnB,CACF,CAAA,CAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{i as c}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{s as N,S as xe,l as je,h as we,_ as L,i as M}from"./index-CbWKfUJC.js";import{u as Fe}from"./use-definition-schema-Bxe6QzcW.js";import{g as Z,s as ee,b as V,e as S,f as q}from"./index.esm-B0dGSilx.js";import{c as Y,H as J,L as Q,A as X}from"./index-B6LhSOJ-.js";var Se=class D{constructor(t,i,n){this.control=t,this.path=i,this.cache=n}static create(t,i){return new D(t,"",i)}focus(t){var i,n,o,s,a,m;const d=t.toString(),u=this.path?`${this.path}.${d}`:d,f=(i=this.cache)==null?void 0:i.get(u,this.reflectedKey);if(f)return f;if(Array.isArray(this.override)){const[b]=this.override,p=new D(this.control,u,this.cache);return p.isArrayItemReflection=!0,p.override=b,(n=this.cache)==null||n.set(p,u),p}else if(this.override){const b=Z(this.override,d);if(!b){const p=new D(this.control,u,this.cache);return(o=this.cache)==null||o.set(p,u),p}if(this.isArrayItemReflection){const p=`${this.path}.${b.path}`,x=new D(this.control,p,this.cache);return(s=this.cache)==null||s.set(x,p),x}else return(a=this.cache)==null||a.set(b,u),b}const C=new D(this.control,u,this.cache);return(m=this.cache)==null||m.set(C,u),C}reflect(t){var i,n,o;const s=(i=this.cache)==null?void 0:i.get(this.path,t);if(s)return s;const a=new D(this.control,this.path,this.cache),m=new Proxy({},{get:(u,f)=>typeof f=="string"?a.focus(f):u}),d=t(m,a);if(Array.isArray(d)){const u=new D(this.control,this.path,this.cache);return a.path="",u.override=t(m,a),u.reflectedKey=t,(n=this.cache)==null||n.set(u,this.path,t),u}else return a.override=d,a.path=this.path,a.reflectedKey=t,(o=this.cache)==null||o.set(a,this.path,t),a}map(t,i){return t.map((n,o,s)=>{const a=this.focus(o.toString());return i(n,a,o,s,this)})}interop(t){var i;return t?t(this.control,this.path):((i=this.interopCache)!=null||(this.interopCache={control:this.control,name:this.path||void 0,...this.override?{getTransformer:this.getTransformer.bind(this),setTransformer:this.setTransformer.bind(this)}:{}}),this.interopCache)}narrow(){return this}assert(){return this}defined(){return this}cast(){return this}getTransformer(t){const[i]=Array.isArray(this.override)?this.override:[this.override];if(!t||!i)return t;const n={};return Object.entries(i).forEach(([o,s])=>{const a=s;if(!a)return;const m=Z(t,a.path);ee(n,o,m)}),n}setTransformer(t){const[i]=Array.isArray(this.override)?this.override:[this.override];if(!t||!i)return t;const n={};return Object.entries(t).forEach(([o,s])=>{const a=i[o];a&&ee(n,a.path,s)}),n}},De=class{constructor(l){this.cache=new Map,l._subscribe({formState:{values:!0},exact:!0,callback:()=>{l._names.unMount.forEach(t=>{this.delete(t)})}})}get(l,t){const i=this.cache.get(l);if(i)return t?i.complex.get(t):i.plain}set(l,t,i){let n=this.cache.get(t);n||(n={complex:new WeakMap},this.cache.set(t,n)),i?n.complex.set(i,l):n.plain=l}has(l,t){var i,n;return t?(n=(i=this.cache.get(l))==null?void 0:i.complex.has(t))!=null?n:!1:this.cache.has(l)}delete(l){for(const t of this.cache.keys())t.startsWith(l)&&this.cache.delete(t)}clear(){this.cache.clear()}};const{useMemo:Ie}=await c("react");function Ce(l,t=[]){return Ie(()=>{const i=new De(l.control);return Se.create(l.control,i)},[l.control,...t])}const{ModelUtils:Ae}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudInputWebConfig:$e,useProjectDefinition:Te}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:te}=await c("@baseplate-dev/ui-components");function Re({formProps:l,name:t,model:i,embeddedFormOptions:n}){const{definition:o}=Te(),s=Ae.getRelationsToModel(o,i.id).map(d=>({label:`${d.relation.foreignRelationName} (${d.model.name})`,value:d.relation.foreignId})),a=t,m=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(te,{label:"Relation Name",control:m,name:`${a}.modelRelationRef`,options:s}),e.jsx(te,{label:"Embedded Form",control:m,name:`${a}.embeddedFormRef`,options:n})]})}const Ee=$e({name:"embedded",pluginKey:void 0,label:"Embedded",getNewInput:()=>({label:"",type:"embedded",modelRelationRef:"",embeddedFormRef:""}),Form:Re}),{createAdminCrudInputWebConfig:Ne,useProjectDefinition:Le}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:ne}=await c("@baseplate-dev/ui-components");function _e({formProps:l,name:t,model:i,embeddedFormOptions:n}){const{definitionContainer:o}=Le(),s=i.model.relations?.map(d=>({label:`${d.name} (${o.nameFromId(d.modelRef)})`,value:d.id}))??[],a=t,m=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"Relation Name",control:m,name:`${a}.localRelationRef`,options:s}),e.jsx(ne,{label:"Embedded Form",control:m,name:`${a}.embeddedFormRef`,options:n})]})}const We=Ne({name:"embeddedLocal",pluginKey:void 0,label:"Embedded Local",getNewInput:()=>({label:"",type:"embeddedLocal",embeddedFormRef:"",localRelationRef:""}),Form:_e}),{createAdminCrudInputWebConfig:Pe}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:Ve}=await c("@baseplate-dev/ui-components");function Me({formProps:l,name:t,model:i}){const n=i.model.fields.filter(a=>a.type==="enum").map(a=>({label:a.name,value:a.id})),o=t,s=l.control;return e.jsx(Ve,{label:"Enum Field",control:s,name:`${o}.modelFieldRef`,options:n})}const Oe=Pe({name:"enum",pluginKey:void 0,label:"Enum",getNewInput:()=>({label:"",type:"enum",modelFieldRef:""}),Form:Me}),{createAdminCrudInputWebConfig:ke,useProjectDefinition:Ue}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:_,SelectFieldController:Be}=await c("@baseplate-dev/ui-components");function Ke({formProps:l,name:t,model:i}){const{definitionContainer:n}=Ue(),o=i.model.relations?.map(m=>({label:`${m.name} (${n.nameFromId(m.modelRef)})`,value:m.id}))??[],s=t,a=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(Be,{label:"Local Relation Name",control:a,name:`${s}.localRelationRef`,options:o}),e.jsx(_,{label:"Label Expression (e.g. name)",control:a,name:`${s}.labelExpression`}),e.jsx(_,{label:"Value Expression (e.g. id)",control:a,name:`${s}.valueExpression`}),e.jsx(_,{label:"Default Label (optional)",control:a,name:`${s}.defaultLabel`}),e.jsx(_,{label:"Empty Label (optional) - only if field is nullable",control:a,name:`${s}.nullLabel`})]})}const ze=ke({name:"foreign",pluginKey:void 0,label:"Foreign",getNewInput:()=>({label:"",type:"foreign",localRelationRef:"",labelExpression:"",valueExpression:"",defaultLabel:"",nullLabel:""}),Form:Ke}),{createAdminCrudInputWebConfig:He}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:Ge,SelectFieldController:qe}=await c("@baseplate-dev/ui-components");function Ye({formProps:l,name:t,model:i}){const n=i.model.fields.map(a=>({label:a.name,value:a.id})),o=t,s=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(qe,{label:"Field",control:s,name:`${o}.modelFieldRef`,options:n}),e.jsx(Ge,{label:"Validation (zod), e.g. z.string().min(1) (optional)",control:s,name:`${o}.validation`})]})}const Je=He({name:"text",pluginKey:void 0,label:"Text",getNewInput:()=>({label:"",type:"text",modelFieldRef:""}),Form:Ye}),ie=[Ee,We,Oe,ze,Je],{createAdminCrudInputSchema:Qe,ModelUtils:Xe}=await c("@baseplate-dev/project-builder-lib"),{adminCrudInputWebSpec:Ze,useDefinitionSchema:et,useProjectDefinition:tt}=await c("@baseplate-dev/project-builder-lib/web"),{Button:oe,Dialog:nt,DialogContent:it,DialogDescription:ot,DialogFooter:lt,DialogHeader:st,DialogTitle:at,InputFieldController:rt,SelectFieldController:ct}=await c("@baseplate-dev/ui-components"),{useId:dt}=await c("react");function mt({open:l,onOpenChange:t,field:i,modelRef:n,embeddedFormOptions:o,isNew:s=!1,onSave:a}){const{definition:m,pluginContainer:d}=tt(),u=et(Qe),f=n?Xe.byIdOrThrow(m,n):void 0,C=d.getPluginSpec(Ze),b=C.getInputWebConfigs(ie).map(h=>({label:h.label,value:h.name})),p=V({resolver:N(u),values:i??{type:"text",label:""}}),{control:x,handleSubmit:y,formState:{isDirty:F}}=p,g=S({control:x,name:"type"}),v=g?C.getInputWebConfig(g,ie):void 0,w=v?.Form,j=y(h=>{a(h),t(!1)}),r=dt();return e.jsx(nt,{open:l,onOpenChange:t,children:e.jsx(it,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:r,onSubmit:h=>(h.stopPropagation(),j(h)),children:[e.jsxs(st,{children:[e.jsx(at,{children:s?"Add Field":"Edit Field"}),e.jsx(ot,{children:s?"Configure the new form field settings.":"Update the field settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(ct,{label:"Type",control:x,options:b,name:"type"}),e.jsx(rt,{label:"Label",control:x,name:"label",placeholder:"Enter field label"}),w&&f&&e.jsx(w,{formProps:p,name:"",model:f,embeddedFormOptions:o,pluginKey:v.pluginKey})]}),e.jsxs(lt,{children:[e.jsx(oe,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(oe,{form:r,type:"submit",disabled:!F,children:[s?"Add":"Update"," Field"]})]})]})})})}const{Button:O,RecordView:ut,RecordViewActions:pt,RecordViewItem:le,RecordViewItemList:ft,useConfirmDialog:bt}=await c("@baseplate-dev/ui-components"),{useState:k}=await c("react");function ge({className:l,formProps:t,embeddedFormOptions:i}){const{control:n}=t,{requestConfirm:o}=bt(),{fields:s,append:a,remove:m,update:d}=q({control:n,name:"form.fields"}),[u,f]=k(void 0),[C,b]=k(!1),[p,x]=k(!1),y=S({control:n,name:"form.fields"});function F(j){const r=y[j];o({title:"Delete Field",content:`Are you sure you want to delete the field "${r.label||"Untitled"}"?`,onConfirm:()=>{m(j)}})}function g(j){f(y[j]),b(!0)}function v(){f(void 0),x(!0)}function w(j){if(u){const r=y.findIndex(h=>h.id===u.id);r!==-1&&d(r,j)}else a(j)}return e.jsxs("div",{className:Y("space-y-4",l),children:[s.map((j,r)=>e.jsxs(ut,{children:[e.jsxs(ft,{children:[e.jsx(le,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:j.label})}),e.jsx(le,{title:"Type",children:j.type})]}),e.jsxs(pt,{children:[e.jsx(O,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit field",onClick:()=>{g(r)},children:e.jsx(J,{})}),e.jsx(O,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete field",onClick:()=>{F(r)},children:e.jsx(Q,{})})]})]},j.id)),e.jsx(mt,{open:C||p,onOpenChange:j=>{j||(b(!1),x(!1),f(void 0))},field:u,modelRef:S({control:n,name:"modelRef"})||"",embeddedFormOptions:i,isNew:p,onSave:w}),e.jsxs(O,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Field"]})]})}const{useMemo:ht}=await c("react");function xt(l){const t=q(l);return{fields:ht(()=>l.getTransformer?t.fields.map(l.getTransformer):t.fields,[t.fields,l.getTransformer]),move:t.move,remove:t.remove,swap:t.swap,prepend:(n,o)=>{if(!l.setTransformer)return t.prepend(n,o);const s=Array.isArray(n)?n.map(l.setTransformer):l.setTransformer(n);t.prepend(s,o)},append:(n,o)=>{if(!l.setTransformer)return t.append(n,o);const s=Array.isArray(n)?n.map(l.setTransformer):l.setTransformer(n);t.append(s,o)},insert:(n,o,s)=>{if(!l.setTransformer)return t.insert(n,o,s);const a=Array.isArray(o)?o.map(l.setTransformer):l.setTransformer(o);t.insert(n,a,s)},update:(n,o)=>{if(!l.setTransformer)return t.update(n,o);const s=l.setTransformer(o);t.update(n,s)},replace:n=>{if(!l.setTransformer)return t.replace(n);const o=l.setTransformer(n);t.replace(o)}}}const{adminCrudColumnEntityType:jt}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:Ct,useProjectDefinition:gt}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:se,SelectFieldController:vt}=await c("@baseplate-dev/ui-components");function yt({formProps:l,model:t}){const{control:i}=l,{definitionContainer:n}=gt(),o=t.model.relations?.map(s=>({label:`${s.name} (${n.nameFromId(s.modelRef)})`,value:s.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsx(vt,{label:"Local Relation",control:i,name:"localRelationRef",options:o,placeholder:"Select a relation"}),e.jsx(se,{label:"Label Expression",control:i,name:"labelExpression",placeholder:"e.g. name",description:"Field to display from the related model"}),e.jsx(se,{label:"Value Expression",control:i,name:"valueExpression",placeholder:"e.g. id",description:"Field to use for matching the relation"})]})}const wt=Ct({name:"foreign",pluginKey:void 0,label:"Foreign Column",isAvailableForModel:(l,t)=>(l.models.find(n=>n.id===t)?.model.relations?.length??0)>0,Form:yt,getNewColumn:()=>({id:jt.generateNewId(),type:"foreign",label:"",localRelationRef:"",labelExpression:"",valueExpression:""})}),{adminCrudColumnEntityType:Ft}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:St}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:Dt}=await c("@baseplate-dev/ui-components");function It({formProps:l,model:t}){const{control:i}=l,n=t.model.fields.map(o=>({label:o.name,value:o.id}));return e.jsx(Dt,{label:"Field",control:i,name:"modelFieldRef",options:n,placeholder:"Select a field"})}const At=St({name:"text",pluginKey:void 0,label:"Text Column",Form:It,isAvailableForModel:()=>!0,getNewColumn:()=>({id:Ft.generateNewId(),type:"text",label:"",modelFieldRef:""})}),ae=[wt,At],{createAdminCrudColumnSchema:$t,ModelUtils:Tt}=await c("@baseplate-dev/project-builder-lib"),{adminCrudColumnWebSpec:Rt,useDefinitionSchema:Et,useProjectDefinition:Nt}=await c("@baseplate-dev/project-builder-lib/web"),{Button:re,Dialog:Lt,DialogContent:_t,DialogDescription:Wt,DialogFooter:Pt,DialogHeader:Vt,DialogTitle:Mt,InputFieldController:Ot,SelectFieldController:kt}=await c("@baseplate-dev/ui-components"),{useId:Ut}=await c("react");function Bt({open:l,onOpenChange:t,column:i,modelRef:n,isNew:o=!1,onSave:s}){const{definition:a,pluginContainer:m}=Nt(),d=Et($t),u=n?Tt.byIdOrThrow(a,n):void 0,f=m.getPluginSpec(Rt),C=f.getColumnWebConfigs(ae).filter(r=>r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),b=V({resolver:N(d),values:i??{type:"text",label:""}}),{control:p,handleSubmit:x,formState:{isDirty:y}}=b,F=S({control:p,name:"type"}),g=F?f.getColumnWebConfig(F,ae):void 0,v=g?.Form,w=x(r=>{s(r),t(!1)}),j=Ut();return e.jsx(Lt,{open:l,onOpenChange:t,children:e.jsx(_t,{className:"sm:max-w-[425px]",children:e.jsxs("form",{id:j,onSubmit:r=>(r.stopPropagation(),w(r)),children:[e.jsxs(Vt,{children:[e.jsx(Mt,{children:o?"Add Column":"Edit Column"}),e.jsx(Wt,{children:o?"Configure the new table column settings.":"Update the column settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(kt,{label:"Type",control:p,options:C,name:"type"}),e.jsx(Ot,{label:"Label",control:p,name:"label",placeholder:"Enter column label"}),v&&u&&e.jsx(v,{formProps:b,model:u,pluginKey:g.pluginKey})]}),e.jsxs(Pt,{children:[e.jsx(re,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(re,{form:j,type:"submit",disabled:!y,children:[o?"Add":"Update"," Column"]})]})]})})})}const{Button:U,RecordView:Kt,RecordViewActions:zt,RecordViewItem:ce,RecordViewItemList:Ht,useConfirmDialog:Gt}=await c("@baseplate-dev/ui-components"),{useState:B}=await c("react");function ve({className:l,lens:t,modelRef:i}){const{requestConfirm:n}=Gt(),{fields:o,append:s,remove:a,update:m,move:d}=xt(t.interop()),[u,f]=B(void 0),[C,b]=B(!1),[p,x]=B(!1);function y(r){const h=o[r];n({title:"Delete Column",content:`Are you sure you want to delete the column "${h.label||"Untitled"}"?`,onConfirm:()=>{a(r)}})}const F=S(t.interop());function g(r){f(F[r]),b(!0)}function v(){f(void 0),x(!0)}function w(r){if(u){const h=F.findIndex(I=>I.id===u.id);h!==-1&&m(h,r)}else s(r)}const j=o.map((r,h)=>({id:r.id,element:e.jsxs(Kt,{children:[e.jsxs(Ht,{children:[e.jsx(ce,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:r.label||e.jsx("span",{className:"text-muted-foreground",children:"Untitled Column"})})})}),e.jsx(ce,{title:"Type",children:r.type})]}),e.jsxs(zt,{children:[e.jsx(U,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit column",onClick:()=>{g(h)},children:e.jsx(J,{})}),e.jsx(U,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete column",onClick:()=>{y(h)},children:e.jsx(Q,{})})]})]},r.id)}));return e.jsxs("div",{className:Y("space-y-4",l),children:[o.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"No columns configured. Add columns to display data in your table."}):e.jsx("div",{className:"flex w-full flex-col gap-2",children:e.jsx(xe,{listItems:j,sortItems:d})}),e.jsx(Bt,{open:C||p,onOpenChange:r=>{r||(b(!1),x(!1),f(void 0))},column:u,modelRef:i,isNew:p,onSave:w}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Column"]})]})}const{createAdminCrudEmbeddedFormSchema:qt}=await c("@baseplate-dev/project-builder-lib"),{useDefinitionSchema:Yt,useProjectDefinition:ye}=await c("@baseplate-dev/project-builder-lib/web"),{Button:G,CheckboxFieldController:Jt,InputFieldController:Qt,SelectFieldController:de,Table:Xt,TableBody:Zt,TableCell:W,TableHead:P,TableHeader:en,TableRow:me,toast:tn}=await c("@baseplate-dev/ui-components"),{useId:nn}=await c("react");function on({items:l,edit:t,remove:i}){const{definitionContainer:n}=ye();return e.jsxs(Xt,{className:"max-w-6xl",children:[e.jsx(en,{children:e.jsxs(me,{children:[e.jsx(P,{children:"Form Name"}),e.jsx(P,{children:"Model Name"}),e.jsx(P,{children:"Type"}),e.jsx(P,{children:"Actions"})]})}),e.jsx(Zt,{children:l.map((o,s)=>e.jsxs(me,{children:[e.jsx(W,{children:o.name}),e.jsx(W,{children:n.nameFromId(o.modelRef)}),e.jsx(W,{children:o.type}),e.jsxs(W,{className:"space-x-4",children:[e.jsx(G,{variant:"link",size:"none",onClick:()=>{t(s)},children:"Edit"}),e.jsx(G,{variant:"linkDestructive",size:"none",onClick:()=>{i(s)},children:"Remove"})]})]},o.id))})]})}const ln=[{label:"Object",value:"object"},{label:"List",value:"list"}];function sn({initialData:l,onSubmit:t,embeddedFormOptions:i}){const{definition:n}=ye(),o=Yt(qt),s=V({resolver:N(o),defaultValues:l}),{handleSubmit:a,control:m,watch:d}=s,u=n.models.map(x=>({label:x.name,value:x.id})),f=d("type"),C=d("modelRef"),b=Ce({control:m}),p=nn();return e.jsxs("form",{onSubmit:x=>{x.stopPropagation(),a(t)(x).catch(y=>{tn.error(je(y))})},id:p,className:"space-y-4",children:[e.jsx(Qt,{label:"Name",control:m,name:"name"}),e.jsx(de,{label:"Type",control:m,name:"type",options:ln}),e.jsx(Jt,{label:"Include ID Field? (useful for list types)",control:m,name:"includeIdField"}),e.jsx(de,{label:"Model",control:m,options:u,name:"modelRef"}),f==="list"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Table"}),e.jsx(ve,{lens:b.focus("table.columns"),modelRef:C})]}),e.jsx("h2",{children:"Form"}),e.jsx(ge,{formProps:s,embeddedFormOptions:i}),e.jsx(G,{type:"submit",form:p,children:"Save"})]})}const{createAdminCrudActionWebConfig:an}=await c("@baseplate-dev/project-builder-lib/web"),rn=an({name:"delete",pluginKey:void 0,label:"Delete",isAvailableForModel:()=>!0,getNewAction:()=>({type:"delete",position:"dropdown"})}),{createAdminCrudActionWebConfig:cn}=await c("@baseplate-dev/project-builder-lib/web"),dn=cn({name:"edit",pluginKey:void 0,label:"Edit",isAvailableForModel:()=>!0,getNewAction:()=>({type:"edit",position:"inline"})}),ue=[dn,rn],{createAdminCrudActionSchema:mn,ModelUtils:un}=await c("@baseplate-dev/project-builder-lib"),{adminCrudActionWebSpec:pn,useDefinitionSchema:fn,useProjectDefinition:bn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:pe,Dialog:hn,DialogContent:xn,DialogDescription:jn,DialogFooter:Cn,DialogHeader:gn,DialogTitle:vn,SelectFieldController:fe}=await c("@baseplate-dev/ui-components"),{useId:yn}=await c("react");function wn({open:l,onOpenChange:t,action:i,modelRef:n,isNew:o=!1,onSave:s}){const{definition:a,pluginContainer:m}=bn(),d=fn(mn),u=n?un.byIdOrThrow(a,n):void 0,f=m.getPluginSpec(pn),C=f.getActionWebConfigs(ue).filter(r=>r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),b=V({resolver:N(d),values:i??{type:"edit",position:"inline"}}),{control:p,handleSubmit:x,formState:{isDirty:y}}=b,F=S({control:p,name:"type"}),g=F?f.getActionWebConfig(F,ue):void 0,v=g?.Form,w=x(r=>{s(r),t(!1)}),j=yn();return e.jsx(hn,{open:l,onOpenChange:t,children:e.jsx(xn,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:j,onSubmit:r=>(r.stopPropagation(),w(r)),children:[e.jsxs(gn,{children:[e.jsx(vn,{children:o?"Add Action":"Edit Action"}),e.jsx(jn,{children:o?"Configure the new table action settings.":"Update the action settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(fe,{label:"Type",control:p,options:C,name:"type"}),e.jsx(fe,{label:"Position",control:p,options:[{label:"Inline",value:"inline"},{label:"Dropdown",value:"dropdown"}],name:"position"}),v&&u&&e.jsx(v,{formProps:b,model:u,pluginKey:g.pluginKey})]}),e.jsxs(Cn,{children:[e.jsx(pe,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(pe,{form:j,type:"submit",disabled:!y,children:[o?"Add":"Update"," Action"]})]})]})})})}const{Button:K,RecordView:Fn,RecordViewActions:Sn,RecordViewItem:be,RecordViewItemList:Dn,useConfirmDialog:In}=await c("@baseplate-dev/ui-components"),{useState:z}=await c("react");function An({className:l,control:t,modelRef:i}){const{requestConfirm:n}=In(),{fields:o,append:s,remove:a,update:m,move:d}=q({control:t,name:"table.actions"}),[u,f]=z(void 0),[C,b]=z(!1),[p,x]=z(!1);function y(r){const h=o[r];n({title:"Delete Action",content:`Are you sure you want to delete the "${h.type}" action?`,onConfirm:()=>{a(r)}})}const F=S({control:t,name:"table.actions"});function g(r){f(F?.[r]),b(!0)}function v(){f(void 0),x(!0)}function w(r){if(u){const h=(F??[]).findIndex(I=>I.id===u.id);h!==-1&&m(h,r)}else s(r)}const j=o.map((r,h)=>({id:r.id,element:e.jsxs(Fn,{children:[e.jsxs(Dn,{children:[e.jsx(be,{title:"Type",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"capitalize",children:r.type})})}),e.jsx(be,{title:"Position",children:r.position})]}),e.jsxs(Sn,{children:[e.jsx(K,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit action",onClick:()=>{g(h)},children:e.jsx(J,{})}),e.jsx(K,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete action",onClick:()=>{y(h)},children:e.jsx(Q,{})})]})]},r.id)}));return e.jsxs("div",{className:Y("space-y-4",l),children:[o.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"No actions configured. Add actions to enable row operations."}):e.jsx("div",{className:"flex w-full flex-col gap-2",children:e.jsx(xe,{listItems:j,sortItems:d})}),e.jsx(wn,{open:C||p,onOpenChange:r=>{r||(b(!1),x(!1),f(void 0))},action:u,modelRef:i??"",isNew:p,onSave:w}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Action"]})]})}const{useProjectDefinition:$n}=await c("@baseplate-dev/project-builder-lib/web"),{CheckboxFieldController:Tn,ComboboxFieldController:he,SectionListSection:A,SectionListSectionContent:$,SectionListSectionDescription:T,SectionListSectionHeader:R,SectionListSectionTitle:E}=await c("@baseplate-dev/ui-components");function Rn({formProps:l}){const{control:t}=l,{definition:i}=$n(),n=Ce({control:t}),o=i.models.map(d=>({label:d.name,value:d.id})),s=S({control:t,name:"modelRef"}),a=i.models.find(d=>d.id===s)?.model.fields.map(d=>({label:d.name,value:d.id}))??[],m=S({control:t,name:"embeddedForms"})?.map(d=>({label:d.name,value:d.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Model Configuration"}),e.jsx(T,{children:"Configure the data model and basic settings for this CRUD section."})]}),e.jsxs($,{className:"space-y-6",children:[e.jsx(he,{label:"Model",control:t,options:o,name:"modelRef"}),e.jsx(he,{label:"Name Field",control:t,options:a,description:"The field to use as the name of the record (used in breadcrumbs/title of edit page)",name:"nameFieldRef"}),e.jsx(Tn,{label:"Disable Create?",control:t,name:"disableCreate"})]})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Table Configuration"}),e.jsx(T,{children:"Configure which columns to display in the data table."})]}),e.jsx($,{children:e.jsx(ve,{lens:n.focus("table.columns"),modelRef:s})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Table Actions"}),e.jsx(T,{children:"Configure actions available for each row in the table. Drag to reorder."})]}),e.jsx($,{children:e.jsx(An,{control:t,modelRef:s})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Form Configuration"}),e.jsx(T,{children:"Configure the form fields for creating and editing records."})]}),e.jsx($,{children:e.jsx(ge,{formProps:l,embeddedFormOptions:m})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Embedded Forms"}),e.jsx(T,{children:"Configure embedded forms for related data objects."})]}),e.jsx($,{children:e.jsx(we.LabelledController,{control:t,name:"embeddedForms",renderForm:d=>e.jsx(sn,{...d,embeddedFormOptions:m}),renderTable:d=>e.jsx(on,{...d}),defaultValue:{type:"object"}})})]})]})}const{AsyncComboboxField:En,useControllerMerged:Nn}=await c("@baseplate-dev/ui-components");async function Ln(){const l=await L(()=>import("./index-CbWKfUJC.js").then(s=>s.A),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),t=await L(()=>import("./index-bqrQLiwF.js"),__vite__mapDeps([11,6,1])),i=await L(()=>import("./index-B6LhSOJ-.js").then(s=>s.R),__vite__mapDeps([6,1])),n=await L(()=>import("./index-n58UNslG.js"),__vite__mapDeps([12,6,1]));return[l,t,i,n].map(s=>Object.entries(s).filter(([,a])=>typeof a=="function").map(([a,m])=>({label:a,value:a,icon:m}))).flat()}function _n({...l}){return e.jsx(En,{placeholder:"Select an icon",...l,loadOptions:t=>Ln().then(i=>i.filter(n=>!t||n.label.toLowerCase().includes(t.toLowerCase())).sort((n,o)=>n.label.localeCompare(o.label)).slice(0,20)),renderItemLabel:t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.icon,{className:"size-4"}),t.label]})})}function Wn({name:l,control:t,...i}){const{field:n,fieldState:{error:o}}=Nn({name:l,control:t},i),s=i;return e.jsx(_n,{error:o?.message,...s,...n,value:n.value??null})}const{adminSectionEntityType:Pn,createWebAdminSectionSchema:Vn}=await c("@baseplate-dev/project-builder-lib"),{useBlockUnsavedChangesNavigate:Mn,useProjectDefinition:On,useResettableForm:kn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:H,ComboboxFieldController:Un,Dialog:Bn,DialogClose:Kn,DialogContent:zn,DialogFooter:Hn,DialogHeader:Gn,DialogTitle:qn,DialogTrigger:Yn,FormActionBar:Jn,InputFieldController:Qn,SectionList:Xn,SectionListSection:Zn,SectionListSectionContent:ei,SectionListSectionDescription:ti,SectionListSectionHeader:ni,SectionListSectionTitle:ii}=await c("@baseplate-dev/ui-components"),{useNavigate:oi}=await c("@tanstack/react-router"),mi=function(){const{app:t,section:i}=M.useLoaderData(),{appKey:n,sectionKey:o}=M.useParams(),s=oi({from:M.fullPath}),{definition:a,saveDefinitionWithFeedback:m,isSavingDefinition:d}=On(),u=Fe(Vn),f=a.features.map(g=>({label:g.name,value:g.id})),C=kn({resolver:N(u),values:i,defaultValues:{type:"crud"}}),{control:b,handleSubmit:p,reset:x}=C,y=p(g=>{const{id:v,...w}=g;return m(j=>{const r=j.apps.find(I=>I.id===t.id);if(r?.type!=="web"||!r.adminApp)return;const h=r.adminApp.sections?.findIndex(I=>I.id===Pn.idFromKey(o));h!==void 0&&h>=0&&r.adminApp.sections&&(r.adminApp.sections[h]={...w,id:i.id})})}),F=()=>{m(g=>{const v=g.apps.find(w=>w.id===t.id);v?.type!=="web"||!v.adminApp||(v.adminApp.sections=v.adminApp.sections?.filter(w=>w.id!==i.id))},{successMessage:`Successfully deleted section "${i.name}"!`,onSuccess:()=>{s({to:"/admin-sections/$appKey",params:{appKey:n}}).catch(je)}})};return Mn({control:b,reset:x,onSubmit:y}),e.jsxs("div",{className:"relative flex h-full flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"max-w-7xl space-y-4 border-b p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-4",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.name}),e.jsxs("p",{className:"text-base text-muted-foreground",children:[i.type," section"]})]}),e.jsxs(Bn,{children:[e.jsx(Yn,{asChild:!0,children:e.jsx(H,{variant:"secondary",children:"Delete"})}),e.jsxs(zn,{children:[e.jsx(Gn,{children:e.jsxs(qn,{children:["Delete ",i.name]})}),e.jsxs("p",{children:["Are you sure you want to delete ",e.jsx("strong",{children:i.name}),"?"]}),e.jsx("p",{className:"text-style-muted",children:"This action will permanently remove the admin section from your application. This cannot be undone."}),e.jsxs(Hn,{children:[e.jsx(Kn,{children:e.jsx(H,{variant:"secondary",children:"Cancel"})}),e.jsx(H,{variant:"destructive",onClick:F,disabled:d,children:"Delete Section"})]})]})]})]})}),e.jsx("div",{className:"mb-(--action-bar-height) flex flex-1 overflow-y-auto",style:{"--action-bar-height":"52px"},children:e.jsxs("form",{onSubmit:y,className:"w-full max-w-7xl space-y-4 p-4",children:[e.jsxs(Xn,{children:[e.jsxs(Zn,{children:[e.jsxs(ni,{children:[e.jsx(ii,{children:"General"}),e.jsx(ti,{children:"Basic configuration for your admin section."})]}),e.jsxs(ei,{className:"space-y-6",children:[e.jsx(Qn,{label:"Name",control:b,name:"name",autoComplete:"off"}),e.jsx(Un,{label:"Feature",control:b,options:f,name:"featureRef"}),e.jsx(Wn,{label:"Icon",control:b,name:"icon",description:"Choose an icon to represent this section"})]})]}),e.jsx(Rn,{formProps:C})]}),e.jsx(Jn,{form:C})]})})]},i.id)};export{mi as component};
|
|
3
|
-
//# sourceMappingURL=edit._sectionKey-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D_oO4W9-.js","assets/_virtual___federation_fn_import-o6aKHb82.js","assets/jsx-runtime-D_zvdyIk.js","assets/index-c0qeY2gs.js","assets/index-DqHVrEeL.js","assets/_commonjsHelpers-CqkleIqs.js","assets/index-B6LhSOJ-.js","assets/index.esm-B0dGSilx.js","assets/sortBy-C9bvycg5.js","assets/immer-B7fdkLVi.js","assets/index-DPK1IfNZ.css","assets/index-bqrQLiwF.js","assets/index-n58UNslG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as c}from"./_virtual___federation_fn_import-o6aKHb82.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{s as N,S as xe,l as je,h as we,_ as L,i as M}from"./index-D_oO4W9-.js";import{u as Fe}from"./use-definition-schema-Bxe6QzcW.js";import{g as Z,s as ee,b as V,e as D,f as q}from"./index.esm-B0dGSilx.js";import{c as Y,H as J,L as Q,A as X}from"./index-B6LhSOJ-.js";var De=class S{constructor(t,i,n){this.control=t,this.path=i,this.cache=n}static create(t,i){return new S(t,"",i)}focus(t){var i,n,o,s,a,m;const d=t.toString(),u=this.path?`${this.path}.${d}`:d,f=(i=this.cache)==null?void 0:i.get(u,this.reflectedKey);if(f)return f;if(Array.isArray(this.override)){const[b]=this.override,p=new S(this.control,u,this.cache);return p.isArrayItemReflection=!0,p.override=b,(n=this.cache)==null||n.set(p,u),p}else if(this.override){const b=Z(this.override,d);if(!b){const p=new S(this.control,u,this.cache);return(o=this.cache)==null||o.set(p,u),p}if(this.isArrayItemReflection){const p=`${this.path}.${b.path}`,x=new S(this.control,p,this.cache);return(s=this.cache)==null||s.set(x,p),x}else return(a=this.cache)==null||a.set(b,u),b}const C=new S(this.control,u,this.cache);return(m=this.cache)==null||m.set(C,u),C}reflect(t){var i,n,o;const s=(i=this.cache)==null?void 0:i.get(this.path,t);if(s)return s;const a=new S(this.control,this.path,this.cache),m=new Proxy({},{get:(u,f)=>typeof f=="string"?a.focus(f):u}),d=t(m,a);if(Array.isArray(d)){const u=new S(this.control,this.path,this.cache);return a.path="",u.override=t(m,a),u.reflectedKey=t,(n=this.cache)==null||n.set(u,this.path,t),u}else return a.override=d,a.path=this.path,a.reflectedKey=t,(o=this.cache)==null||o.set(a,this.path,t),a}map(t,i){return t.map((n,o,s)=>{const a=this.focus(o.toString());return i(n,a,o,s,this)})}interop(t){var i;return t?t(this.control,this.path):((i=this.interopCache)!=null||(this.interopCache={control:this.control,name:this.path||void 0,...this.override?{getTransformer:this.getTransformer.bind(this),setTransformer:this.setTransformer.bind(this)}:{}}),this.interopCache)}narrow(){return this}assert(){return this}defined(){return this}cast(){return this}getTransformer(t){const[i]=Array.isArray(this.override)?this.override:[this.override];if(!t||!i)return t;const n={};return Object.entries(i).forEach(([o,s])=>{const a=s;if(!a)return;const m=Z(t,a.path);ee(n,o,m)}),n}setTransformer(t){const[i]=Array.isArray(this.override)?this.override:[this.override];if(!t||!i)return t;const n={};return Object.entries(t).forEach(([o,s])=>{const a=i[o];a&&ee(n,a.path,s)}),n}},Se=class{constructor(l){this.cache=new Map,l._subscribe({formState:{values:!0},exact:!0,callback:()=>{l._names.unMount.forEach(t=>{this.delete(t)})}})}get(l,t){const i=this.cache.get(l);if(i)return t?i.complex.get(t):i.plain}set(l,t,i){let n=this.cache.get(t);n||(n={complex:new WeakMap},this.cache.set(t,n)),i?n.complex.set(i,l):n.plain=l}has(l,t){var i,n;return t?(n=(i=this.cache.get(l))==null?void 0:i.complex.has(t))!=null?n:!1:this.cache.has(l)}delete(l){for(const t of this.cache.keys())t.startsWith(l)&&this.cache.delete(t)}clear(){this.cache.clear()}};const{useMemo:Ie}=await c("react");function Ce(l,t=[]){return Ie(()=>{const i=new Se(l.control);return De.create(l.control,i)},[l.control,...t])}const{ModelUtils:Ae}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudInputWebConfig:$e,useProjectDefinition:Te}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:te}=await c("@baseplate-dev/ui-components");function Re({formProps:l,name:t,model:i,embeddedFormOptions:n}){const{definition:o}=Te(),s=Ae.getRelationsToModel(o,i.id).map(d=>({label:`${d.relation.foreignRelationName} (${d.model.name})`,value:d.relation.foreignId})),a=t,m=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(te,{label:"Relation Name",control:m,name:`${a}.modelRelationRef`,options:s}),e.jsx(te,{label:"Embedded Form",control:m,name:`${a}.embeddedFormRef`,options:n})]})}const Ee=$e({name:"embedded",pluginKey:void 0,label:"Embedded",getNewInput:()=>({label:"",type:"embedded",modelRelationRef:"",embeddedFormRef:""}),Form:Re}),{createAdminCrudInputWebConfig:Ne,useProjectDefinition:Le}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:ne}=await c("@baseplate-dev/ui-components");function _e({formProps:l,name:t,model:i,embeddedFormOptions:n}){const{definitionContainer:o}=Le(),s=i.model.relations?.map(d=>({label:`${d.name} (${o.nameFromId(d.modelRef)})`,value:d.id}))??[],a=t,m=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"Relation Name",control:m,name:`${a}.localRelationRef`,options:s}),e.jsx(ne,{label:"Embedded Form",control:m,name:`${a}.embeddedFormRef`,options:n})]})}const We=Ne({name:"embeddedLocal",pluginKey:void 0,label:"Embedded Local",getNewInput:()=>({label:"",type:"embeddedLocal",embeddedFormRef:"",localRelationRef:""}),Form:_e}),{createAdminCrudInputWebConfig:Pe}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:Ve}=await c("@baseplate-dev/ui-components");function Me({formProps:l,name:t,model:i}){const n=i.model.fields.filter(a=>a.type==="enum").map(a=>({label:a.name,value:a.id})),o=t,s=l.control;return e.jsx(Ve,{label:"Enum Field",control:s,name:`${o}.modelFieldRef`,options:n})}const Oe=Pe({name:"enum",pluginKey:void 0,label:"Enum",getNewInput:()=>({label:"",type:"enum",modelFieldRef:""}),Form:Me}),{createAdminCrudInputWebConfig:ke,useProjectDefinition:Ue}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:_,SelectFieldController:Be}=await c("@baseplate-dev/ui-components");function Ke({formProps:l,name:t,model:i}){const{definitionContainer:n}=Ue(),o=i.model.relations?.map(m=>({label:`${m.name} (${n.nameFromId(m.modelRef)})`,value:m.id}))??[],s=t,a=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(Be,{label:"Local Relation Name",control:a,name:`${s}.localRelationRef`,options:o}),e.jsx(_,{label:"Label Expression (e.g. name)",control:a,name:`${s}.labelExpression`}),e.jsx(_,{label:"Value Expression (e.g. id)",control:a,name:`${s}.valueExpression`}),e.jsx(_,{label:"Default Label (optional)",control:a,name:`${s}.defaultLabel`}),e.jsx(_,{label:"Empty Label (optional) - only if field is nullable",control:a,name:`${s}.nullLabel`})]})}const ze=ke({name:"foreign",pluginKey:void 0,label:"Foreign",getNewInput:()=>({label:"",type:"foreign",localRelationRef:"",labelExpression:"",valueExpression:"",defaultLabel:"",nullLabel:""}),Form:Ke}),{createAdminCrudInputWebConfig:He}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:Ge,SelectFieldController:qe}=await c("@baseplate-dev/ui-components");function Ye({formProps:l,name:t,model:i}){const n=i.model.fields.map(a=>({label:a.name,value:a.id})),o=t,s=l.control;return e.jsxs(e.Fragment,{children:[e.jsx(qe,{label:"Field",control:s,name:`${o}.modelFieldRef`,options:n}),e.jsx(Ge,{label:"Validation (zod), e.g. z.string().min(1) (optional)",control:s,name:`${o}.validation`})]})}const Je=He({name:"text",pluginKey:void 0,label:"Text",getNewInput:()=>({label:"",type:"text",modelFieldRef:""}),Form:Ye}),ie=[Ee,We,Oe,ze,Je],{createAdminCrudInputSchema:Qe,ModelUtils:Xe}=await c("@baseplate-dev/project-builder-lib"),{adminCrudInputWebSpec:Ze,useDefinitionSchema:et,useProjectDefinition:tt}=await c("@baseplate-dev/project-builder-lib/web"),{Button:oe,Dialog:nt,DialogContent:it,DialogDescription:ot,DialogFooter:lt,DialogHeader:st,DialogTitle:at,InputFieldController:rt,SelectFieldController:ct}=await c("@baseplate-dev/ui-components"),{useId:dt}=await c("react");function mt({open:l,onOpenChange:t,field:i,modelRef:n,embeddedFormOptions:o,isNew:s=!1,onSave:a}){const{definition:m,pluginContainer:d}=tt(),u=et(Qe),f=n?Xe.byIdOrThrow(m,n):void 0,C=d.getPluginSpec(Ze),b=C.getInputWebConfigs(ie).map(h=>({label:h.label,value:h.name})),p=V({resolver:N(u),values:i??{type:"text",label:""}}),{control:x,handleSubmit:y,formState:{isDirty:F}}=p,g=D({control:x,name:"type"}),v=g?C.getInputWebConfig(g,ie):void 0,w=v?.Form,j=y(h=>{a(h),t(!1)}),r=dt();return e.jsx(nt,{open:l,onOpenChange:t,children:e.jsx(it,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:r,onSubmit:h=>(h.stopPropagation(),j(h)),children:[e.jsxs(st,{children:[e.jsx(at,{children:s?"Add Field":"Edit Field"}),e.jsx(ot,{children:s?"Configure the new form field settings.":"Update the field settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(ct,{label:"Type",control:x,options:b,name:"type"}),e.jsx(rt,{label:"Label",control:x,name:"label",placeholder:"Enter field label"}),w&&f&&e.jsx(w,{formProps:p,name:"",model:f,embeddedFormOptions:o,pluginKey:v.pluginKey})]}),e.jsxs(lt,{children:[e.jsx(oe,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(oe,{form:r,type:"submit",disabled:!F,children:[s?"Add":"Update"," Field"]})]})]})})})}const{Button:O,RecordView:ut,RecordViewActions:pt,RecordViewItem:le,RecordViewItemList:ft,useConfirmDialog:bt}=await c("@baseplate-dev/ui-components"),{useState:k}=await c("react");function ge({className:l,formProps:t,embeddedFormOptions:i}){const{control:n}=t,{requestConfirm:o}=bt(),{fields:s,append:a,remove:m,update:d}=q({control:n,name:"form.fields"}),[u,f]=k(void 0),[C,b]=k(!1),[p,x]=k(!1),y=D({control:n,name:"form.fields"});function F(j){const r=y[j];o({title:"Delete Field",content:`Are you sure you want to delete the field "${r.label||"Untitled"}"?`,onConfirm:()=>{m(j)}})}function g(j){f(y[j]),b(!0)}function v(){f(void 0),x(!0)}function w(j){if(u){const r=y.findIndex(h=>h.id===u.id);r!==-1&&d(r,j)}else a(j)}return e.jsxs("div",{className:Y("space-y-4",l),children:[s.map((j,r)=>e.jsxs(ut,{children:[e.jsxs(ft,{children:[e.jsx(le,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:j.label})}),e.jsx(le,{title:"Type",children:j.type})]}),e.jsxs(pt,{children:[e.jsx(O,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit field",onClick:()=>{g(r)},children:e.jsx(J,{})}),e.jsx(O,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete field",onClick:()=>{F(r)},children:e.jsx(Q,{})})]})]},j.id)),e.jsx(mt,{open:C||p,onOpenChange:j=>{j||(b(!1),x(!1),f(void 0))},field:u,modelRef:D({control:n,name:"modelRef"})||"",embeddedFormOptions:i,isNew:p,onSave:w}),e.jsxs(O,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Field"]})]})}const{useMemo:ht}=await c("react");function xt(l){const t=q(l);return{fields:ht(()=>l.getTransformer?t.fields.map(l.getTransformer):t.fields,[t.fields,l.getTransformer]),move:t.move,remove:t.remove,swap:t.swap,prepend:(n,o)=>{if(!l.setTransformer)return t.prepend(n,o);const s=Array.isArray(n)?n.map(l.setTransformer):l.setTransformer(n);t.prepend(s,o)},append:(n,o)=>{if(!l.setTransformer)return t.append(n,o);const s=Array.isArray(n)?n.map(l.setTransformer):l.setTransformer(n);t.append(s,o)},insert:(n,o,s)=>{if(!l.setTransformer)return t.insert(n,o,s);const a=Array.isArray(o)?o.map(l.setTransformer):l.setTransformer(o);t.insert(n,a,s)},update:(n,o)=>{if(!l.setTransformer)return t.update(n,o);const s=l.setTransformer(o);t.update(n,s)},replace:n=>{if(!l.setTransformer)return t.replace(n);const o=l.setTransformer(n);t.replace(o)}}}const{adminCrudColumnEntityType:jt}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:Ct,useProjectDefinition:gt}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:se,SelectFieldController:vt}=await c("@baseplate-dev/ui-components");function yt({formProps:l,model:t}){const{control:i}=l,{definitionContainer:n}=gt(),o=t.model.relations?.map(s=>({label:`${s.name} (${n.nameFromId(s.modelRef)})`,value:s.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsx(vt,{label:"Local Relation",control:i,name:"localRelationRef",options:o,placeholder:"Select a relation"}),e.jsx(se,{label:"Label Expression",control:i,name:"labelExpression",placeholder:"e.g. name",description:"Field to display from the related model"}),e.jsx(se,{label:"Value Expression",control:i,name:"valueExpression",placeholder:"e.g. id",description:"Field to use for matching the relation"})]})}const wt=Ct({name:"foreign",pluginKey:void 0,label:"Foreign Column",isAvailableForModel:(l,t)=>(l.models.find(n=>n.id===t)?.model.relations?.length??0)>0,Form:yt,getNewColumn:()=>({id:jt.generateNewId(),type:"foreign",label:"",localRelationRef:"",labelExpression:"",valueExpression:""})}),{adminCrudColumnEntityType:Ft}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:Dt}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:St}=await c("@baseplate-dev/ui-components");function It({formProps:l,model:t}){const{control:i}=l,n=t.model.fields.map(o=>({label:o.name,value:o.id}));return e.jsx(St,{label:"Field",control:i,name:"modelFieldRef",options:n,placeholder:"Select a field"})}const At=Dt({name:"text",pluginKey:void 0,label:"Text Column",Form:It,isAvailableForModel:()=>!0,getNewColumn:()=>({id:Ft.generateNewId(),type:"text",label:"",modelFieldRef:""})}),ae=[wt,At],{createAdminCrudColumnSchema:$t,ModelUtils:Tt}=await c("@baseplate-dev/project-builder-lib"),{adminCrudColumnWebSpec:Rt,useDefinitionSchema:Et,useProjectDefinition:Nt}=await c("@baseplate-dev/project-builder-lib/web"),{Button:re,Dialog:Lt,DialogContent:_t,DialogDescription:Wt,DialogFooter:Pt,DialogHeader:Vt,DialogTitle:Mt,InputFieldController:Ot,SelectFieldController:kt}=await c("@baseplate-dev/ui-components"),{useId:Ut}=await c("react");function Bt({open:l,onOpenChange:t,column:i,modelRef:n,isNew:o=!1,onSave:s}){const{definition:a,pluginContainer:m}=Nt(),d=Et($t),u=n?Tt.byIdOrThrow(a,n):void 0,f=m.getPluginSpec(Rt),C=f.getColumnWebConfigs(ae).filter(r=>r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),b=V({resolver:N(d),values:i??{type:"text",label:""}}),{control:p,handleSubmit:x,formState:{isDirty:y}}=b,F=D({control:p,name:"type"}),g=F?f.getColumnWebConfig(F,ae):void 0,v=g?.Form,w=x(r=>{s(r),t(!1)}),j=Ut();return e.jsx(Lt,{open:l,onOpenChange:t,children:e.jsx(_t,{className:"sm:max-w-[425px]",children:e.jsxs("form",{id:j,onSubmit:r=>(r.stopPropagation(),w(r)),children:[e.jsxs(Vt,{children:[e.jsx(Mt,{children:o?"Add Column":"Edit Column"}),e.jsx(Wt,{children:o?"Configure the new table column settings.":"Update the column settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(kt,{label:"Type",control:p,options:C,name:"type"}),e.jsx(Ot,{label:"Label",control:p,name:"label",placeholder:"Enter column label"}),v&&u&&e.jsx(v,{formProps:b,model:u,pluginKey:g.pluginKey})]}),e.jsxs(Pt,{children:[e.jsx(re,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(re,{form:j,type:"submit",disabled:!y,children:[o?"Add":"Update"," Column"]})]})]})})})}const{Button:U,RecordView:Kt,RecordViewActions:zt,RecordViewItem:ce,RecordViewItemList:Ht,useConfirmDialog:Gt}=await c("@baseplate-dev/ui-components"),{useState:B}=await c("react");function ve({className:l,lens:t,modelRef:i}){const{requestConfirm:n}=Gt(),{fields:o,append:s,remove:a,update:m,move:d}=xt(t.interop()),[u,f]=B(void 0),[C,b]=B(!1),[p,x]=B(!1);function y(r){const h=o[r];n({title:"Delete Column",content:`Are you sure you want to delete the column "${h.label||"Untitled"}"?`,onConfirm:()=>{a(r)}})}const F=D(t.interop());function g(r){f(F[r]),b(!0)}function v(){f(void 0),x(!0)}function w(r){if(u){const h=F.findIndex(I=>I.id===u.id);h!==-1&&m(h,r)}else s(r)}const j=o.map((r,h)=>({id:r.id,element:e.jsxs(Kt,{children:[e.jsxs(Ht,{children:[e.jsx(ce,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:r.label||e.jsx("span",{className:"text-muted-foreground",children:"Untitled Column"})})})}),e.jsx(ce,{title:"Type",children:r.type})]}),e.jsxs(zt,{children:[e.jsx(U,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit column",onClick:()=>{g(h)},children:e.jsx(J,{})}),e.jsx(U,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete column",onClick:()=>{y(h)},children:e.jsx(Q,{})})]})]},r.id)}));return e.jsxs("div",{className:Y("space-y-4",l),children:[o.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"No columns configured. Add columns to display data in your table."}):e.jsx("div",{className:"flex w-full flex-col gap-2",children:e.jsx(xe,{listItems:j,sortItems:d})}),e.jsx(Bt,{open:C||p,onOpenChange:r=>{r||(b(!1),x(!1),f(void 0))},column:u,modelRef:i,isNew:p,onSave:w}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Column"]})]})}const{createAdminCrudEmbeddedFormSchema:qt}=await c("@baseplate-dev/project-builder-lib"),{useDefinitionSchema:Yt,useProjectDefinition:ye}=await c("@baseplate-dev/project-builder-lib/web"),{Button:G,CheckboxFieldController:Jt,InputFieldController:Qt,SelectFieldController:de,Table:Xt,TableBody:Zt,TableCell:W,TableHead:P,TableHeader:en,TableRow:me,toast:tn}=await c("@baseplate-dev/ui-components"),{useId:nn}=await c("react");function on({items:l,edit:t,remove:i}){const{definitionContainer:n}=ye();return e.jsxs(Xt,{className:"max-w-6xl",children:[e.jsx(en,{children:e.jsxs(me,{children:[e.jsx(P,{children:"Form Name"}),e.jsx(P,{children:"Model Name"}),e.jsx(P,{children:"Type"}),e.jsx(P,{children:"Actions"})]})}),e.jsx(Zt,{children:l.map((o,s)=>e.jsxs(me,{children:[e.jsx(W,{children:o.name}),e.jsx(W,{children:n.nameFromId(o.modelRef)}),e.jsx(W,{children:o.type}),e.jsxs(W,{className:"space-x-4",children:[e.jsx(G,{variant:"link",size:"none",onClick:()=>{t(s)},children:"Edit"}),e.jsx(G,{variant:"linkDestructive",size:"none",onClick:()=>{i(s)},children:"Remove"})]})]},o.id))})]})}const ln=[{label:"Object",value:"object"},{label:"List",value:"list"}];function sn({initialData:l,onSubmit:t,embeddedFormOptions:i}){const{definition:n}=ye(),o=Yt(qt),s=V({resolver:N(o),defaultValues:l}),{handleSubmit:a,control:m,watch:d}=s,u=n.models.map(x=>({label:x.name,value:x.id})),f=d("type"),C=d("modelRef"),b=Ce({control:m}),p=nn();return e.jsxs("form",{onSubmit:x=>{x.stopPropagation(),a(t)(x).catch(y=>{tn.error(je(y))})},id:p,className:"space-y-4",children:[e.jsx(Qt,{label:"Name",control:m,name:"name"}),e.jsx(de,{label:"Type",control:m,name:"type",options:ln}),e.jsx(Jt,{label:"Include ID Field? (useful for list types)",control:m,name:"includeIdField"}),e.jsx(de,{label:"Model",control:m,options:u,name:"modelRef"}),f==="list"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Table"}),e.jsx(ve,{lens:b.focus("table.columns"),modelRef:C})]}),e.jsx("h2",{children:"Form"}),e.jsx(ge,{formProps:s,embeddedFormOptions:i}),e.jsx(G,{type:"submit",form:p,children:"Save"})]})}const{createAdminCrudActionWebConfig:an}=await c("@baseplate-dev/project-builder-lib/web"),rn=an({name:"delete",pluginKey:void 0,label:"Delete",isAvailableForModel:()=>!0,getNewAction:()=>({type:"delete",position:"dropdown"})}),{createAdminCrudActionWebConfig:cn}=await c("@baseplate-dev/project-builder-lib/web"),dn=cn({name:"edit",pluginKey:void 0,label:"Edit",isAvailableForModel:()=>!0,getNewAction:()=>({type:"edit",position:"inline"})}),ue=[dn,rn],{createAdminCrudActionSchema:mn,ModelUtils:un}=await c("@baseplate-dev/project-builder-lib"),{adminCrudActionWebSpec:pn,useDefinitionSchema:fn,useProjectDefinition:bn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:pe,Dialog:hn,DialogContent:xn,DialogDescription:jn,DialogFooter:Cn,DialogHeader:gn,DialogTitle:vn,SelectFieldController:fe}=await c("@baseplate-dev/ui-components"),{useId:yn}=await c("react");function wn({open:l,onOpenChange:t,action:i,modelRef:n,isNew:o=!1,onSave:s}){const{definition:a,pluginContainer:m}=bn(),d=fn(mn),u=n?un.byIdOrThrow(a,n):void 0,f=m.getPluginSpec(pn),C=f.getActionWebConfigs(ue).filter(r=>r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),b=V({resolver:N(d),values:i??{type:"edit",position:"inline"}}),{control:p,handleSubmit:x,formState:{isDirty:y}}=b,F=D({control:p,name:"type"}),g=F?f.getActionWebConfig(F,ue):void 0,v=g?.Form,w=x(r=>{s(r),t(!1)}),j=yn();return e.jsx(hn,{open:l,onOpenChange:t,children:e.jsx(xn,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:j,onSubmit:r=>(r.stopPropagation(),w(r)),children:[e.jsxs(gn,{children:[e.jsx(vn,{children:o?"Add Action":"Edit Action"}),e.jsx(jn,{children:o?"Configure the new table action settings.":"Update the action settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(fe,{label:"Type",control:p,options:C,name:"type"}),e.jsx(fe,{label:"Position",control:p,options:[{label:"Inline",value:"inline"},{label:"Dropdown",value:"dropdown"}],name:"position"}),v&&u&&e.jsx(v,{formProps:b,model:u,pluginKey:g.pluginKey})]}),e.jsxs(Cn,{children:[e.jsx(pe,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(pe,{form:j,type:"submit",disabled:!y,children:[o?"Add":"Update"," Action"]})]})]})})})}const{Button:K,RecordView:Fn,RecordViewActions:Dn,RecordViewItem:be,RecordViewItemList:Sn,useConfirmDialog:In}=await c("@baseplate-dev/ui-components"),{useState:z}=await c("react");function An({className:l,control:t,modelRef:i}){const{requestConfirm:n}=In(),{fields:o,append:s,remove:a,update:m,move:d}=q({control:t,name:"table.actions"}),[u,f]=z(void 0),[C,b]=z(!1),[p,x]=z(!1);function y(r){const h=o[r];n({title:"Delete Action",content:`Are you sure you want to delete the "${h.type}" action?`,onConfirm:()=>{a(r)}})}const F=D({control:t,name:"table.actions"});function g(r){f(F?.[r]),b(!0)}function v(){f(void 0),x(!0)}function w(r){if(u){const h=(F??[]).findIndex(I=>I.id===u.id);h!==-1&&m(h,r)}else s(r)}const j=o.map((r,h)=>({id:r.id,element:e.jsxs(Fn,{children:[e.jsxs(Sn,{children:[e.jsx(be,{title:"Type",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"capitalize",children:r.type})})}),e.jsx(be,{title:"Position",children:r.position})]}),e.jsxs(Dn,{children:[e.jsx(K,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit action",onClick:()=>{g(h)},children:e.jsx(J,{})}),e.jsx(K,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete action",onClick:()=>{y(h)},children:e.jsx(Q,{})})]})]},r.id)}));return e.jsxs("div",{className:Y("space-y-4",l),children:[o.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"No actions configured. Add actions to enable row operations."}):e.jsx("div",{className:"flex w-full flex-col gap-2",children:e.jsx(xe,{listItems:j,sortItems:d})}),e.jsx(wn,{open:C||p,onOpenChange:r=>{r||(b(!1),x(!1),f(void 0))},action:u,modelRef:i??"",isNew:p,onSave:w}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(X,{}),"Add Action"]})]})}const{useProjectDefinition:$n}=await c("@baseplate-dev/project-builder-lib/web"),{CheckboxFieldController:Tn,ComboboxFieldController:he,SectionListSection:A,SectionListSectionContent:$,SectionListSectionDescription:T,SectionListSectionHeader:R,SectionListSectionTitle:E}=await c("@baseplate-dev/ui-components");function Rn({formProps:l}){const{control:t}=l,{definition:i}=$n(),n=Ce({control:t}),o=i.models.map(d=>({label:d.name,value:d.id})),s=D({control:t,name:"modelRef"}),a=i.models.find(d=>d.id===s)?.model.fields.map(d=>({label:d.name,value:d.id}))??[],m=D({control:t,name:"embeddedForms"})?.map(d=>({label:d.name,value:d.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Model Configuration"}),e.jsx(T,{children:"Configure the data model and basic settings for this CRUD section."})]}),e.jsxs($,{className:"space-y-6",children:[e.jsx(he,{label:"Model",control:t,options:o,name:"modelRef"}),e.jsx(he,{label:"Name Field",control:t,options:a,description:"The field to use as the name of the record (used in breadcrumbs/title of edit page)",name:"nameFieldRef"}),e.jsx(Tn,{label:"Disable Create?",control:t,name:"disableCreate"})]})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Table Configuration"}),e.jsx(T,{children:"Configure which columns to display in the data table."})]}),e.jsx($,{children:e.jsx(ve,{lens:n.focus("table.columns"),modelRef:s})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Table Actions"}),e.jsx(T,{children:"Configure actions available for each row in the table. Drag to reorder."})]}),e.jsx($,{children:e.jsx(An,{control:t,modelRef:s})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Form Configuration"}),e.jsx(T,{children:"Configure the form fields for creating and editing records."})]}),e.jsx($,{children:e.jsx(ge,{formProps:l,embeddedFormOptions:m})})]}),e.jsxs(A,{children:[e.jsxs(R,{children:[e.jsx(E,{children:"Embedded Forms"}),e.jsx(T,{children:"Configure embedded forms for related data objects."})]}),e.jsx($,{children:e.jsx(we.LabelledController,{control:t,name:"embeddedForms",renderForm:d=>e.jsx(sn,{...d,embeddedFormOptions:m}),renderTable:d=>e.jsx(on,{...d}),defaultValue:{type:"object"}})})]})]})}const{AsyncComboboxField:En,useControllerMerged:Nn}=await c("@baseplate-dev/ui-components");async function Ln(){const l=await L(()=>import("./index-D_oO4W9-.js").then(s=>s.A),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),t=await L(()=>import("./index-bqrQLiwF.js"),__vite__mapDeps([11,6,1])),i=await L(()=>import("./index-B6LhSOJ-.js").then(s=>s.R),__vite__mapDeps([6,1])),n=await L(()=>import("./index-n58UNslG.js"),__vite__mapDeps([12,6,1]));return[l,t,i,n].map(s=>Object.entries(s).filter(([,a])=>typeof a=="function").map(([a,m])=>({label:a,value:a,icon:m}))).flat()}function _n({...l}){return e.jsx(En,{placeholder:"Select an icon",...l,loadOptions:t=>Ln().then(i=>i.filter(n=>!t||n.label.toLowerCase().includes(t.toLowerCase())).sort((n,o)=>n.label.localeCompare(o.label)).slice(0,20)),renderItemLabel:t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.icon,{className:"size-4"}),t.label]})})}function Wn({name:l,control:t,...i}){const{field:n,fieldState:{error:o}}=Nn({name:l,control:t},i),s=i;return e.jsx(_n,{error:o?.message,...s,...n,value:n.value??null})}const{adminSectionEntityType:Pn,createWebAdminSectionSchema:Vn}=await c("@baseplate-dev/project-builder-lib"),{useBlockUnsavedChangesNavigate:Mn,useProjectDefinition:On,useResettableForm:kn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:H,ComboboxFieldController:Un,Dialog:Bn,DialogClose:Kn,DialogContent:zn,DialogDescription:Hn,DialogFooter:Gn,DialogHeader:qn,DialogTitle:Yn,DialogTrigger:Jn,FormActionBar:Qn,InputFieldController:Xn,SectionList:Zn,SectionListSection:ei,SectionListSectionContent:ti,SectionListSectionDescription:ni,SectionListSectionHeader:ii,SectionListSectionTitle:oi}=await c("@baseplate-dev/ui-components"),{useNavigate:li}=await c("@tanstack/react-router"),ui=function(){const{app:t,section:i}=M.useLoaderData(),{appKey:n,sectionKey:o}=M.useParams(),s=li({from:M.fullPath}),{definition:a,saveDefinitionWithFeedback:m,isSavingDefinition:d}=On(),u=Fe(Vn),f=a.features.map(g=>({label:g.name,value:g.id})),C=kn({resolver:N(u),values:i,defaultValues:{type:"crud"}}),{control:b,handleSubmit:p,reset:x}=C,y=p(g=>{const{id:v,...w}=g;return m(j=>{const r=j.apps.find(I=>I.id===t.id);if(r?.type!=="web"||!r.adminApp)return;const h=r.adminApp.sections?.findIndex(I=>I.id===Pn.idFromKey(o));h!==void 0&&h>=0&&r.adminApp.sections&&(r.adminApp.sections[h]={...w,id:i.id})})}),F=()=>{m(g=>{const v=g.apps.find(w=>w.id===t.id);v?.type!=="web"||!v.adminApp||(v.adminApp.sections=v.adminApp.sections?.filter(w=>w.id!==i.id))},{successMessage:`Successfully deleted section "${i.name}"!`,onSuccess:()=>{s({to:"/admin-sections/$appKey",params:{appKey:n}}).catch(je)}})};return Mn({control:b,reset:x,onSubmit:y}),e.jsxs("div",{className:"relative flex h-full flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"max-w-7xl space-y-4 border-b p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-4",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.name}),e.jsxs("p",{className:"text-base text-muted-foreground",children:[i.type," section"]})]}),e.jsxs(Bn,{children:[e.jsx(Jn,{asChild:!0,children:e.jsx(H,{variant:"secondary",children:"Delete"})}),e.jsxs(zn,{children:[e.jsxs(qn,{children:[e.jsxs(Yn,{children:["Delete ",i.name]}),e.jsxs(Hn,{className:"sr-only",children:["Are you sure you want to delete"," ",e.jsx("strong",{children:i.name}),"?"]})]}),e.jsxs("p",{children:["Are you sure you want to delete ",e.jsx("strong",{children:i.name}),"?"]}),e.jsx("p",{className:"text-style-muted",children:"This action will permanently remove the admin section from your application. This cannot be undone."}),e.jsxs(Gn,{children:[e.jsx(Kn,{asChild:!0,children:e.jsx(H,{variant:"secondary",children:"Cancel"})}),e.jsx(H,{variant:"destructive",onClick:F,disabled:d,children:"Delete Section"})]})]})]})]})}),e.jsx("div",{className:"mb-(--action-bar-height) flex flex-1 overflow-y-auto",style:{"--action-bar-height":"52px"},children:e.jsxs("form",{onSubmit:y,className:"w-full max-w-7xl space-y-4 p-4",children:[e.jsxs(Zn,{children:[e.jsxs(ei,{children:[e.jsxs(ii,{children:[e.jsx(oi,{children:"General"}),e.jsx(ni,{children:"Basic configuration for your admin section."})]}),e.jsxs(ti,{className:"space-y-6",children:[e.jsx(Xn,{label:"Name",control:b,name:"name",autoComplete:"off"}),e.jsx(Un,{label:"Feature",control:b,options:f,name:"featureRef"}),e.jsx(Wn,{label:"Icon",control:b,name:"icon",description:"Choose an icon to represent this section"})]})]}),e.jsx(Rn,{formProps:C})]}),e.jsx(Qn,{form:C})]})})]},i.id)};export{ui as component};
|
|
3
|
+
//# sourceMappingURL=edit._sectionKey-BMO2TE-N.js.map
|