@baseplate-dev/project-builder-web 0.3.4 → 0.3.5
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-DvXqIwvq.js → -constants-BYERQCO8.js} +2 -2
- package/dist/assets/{-constants-DvXqIwvq.js.map → -constants-BYERQCO8.js.map} +1 -1
- package/dist/assets/{admin-B4N6MLKM.js → admin-Dy1xMuLp.js} +2 -2
- package/dist/assets/{admin-B4N6MLKM.js.map → admin-Dy1xMuLp.js.map} +1 -1
- package/dist/assets/{backend-DcOfqunA.js → backend-SevlkhOM.js} +2 -2
- package/dist/assets/{backend-DcOfqunA.js.map → backend-SevlkhOM.js.map} +1 -1
- package/dist/assets/{edit._key-B6XrJtx8.js → edit._key-BgnflZIL.js} +2 -2
- package/dist/assets/{edit._key-B6XrJtx8.js.map → edit._key-BgnflZIL.js.map} +1 -1
- package/dist/assets/edit._sectionKey-D4mTSUhO.js +3 -0
- package/dist/assets/edit._sectionKey-D4mTSUhO.js.map +1 -0
- package/dist/assets/{graphql-Bf0DkZpf.js → graphql-C37jbnTG.js} +2 -2
- package/dist/assets/{graphql-Bf0DkZpf.js.map → graphql-C37jbnTG.js.map} +1 -1
- package/dist/assets/{hierarchy-DJ_1-p8i.js → hierarchy-CNBHjTAJ.js} +2 -2
- package/dist/assets/{hierarchy-DJ_1-p8i.js.map → hierarchy-CNBHjTAJ.js.map} +1 -1
- package/dist/assets/{index-CSR0XEd6.js → index-2EwzbJik.js} +2 -2
- package/dist/assets/{index-CSR0XEd6.js.map → index-2EwzbJik.js.map} +1 -1
- package/dist/assets/{index-Bd-VIuBI.js → index-B2l1e3vi.js} +2 -2
- package/dist/assets/{index-Bd-VIuBI.js.map → index-B2l1e3vi.js.map} +1 -1
- package/dist/assets/{index-BbhEKLV8.js → index-B3A5IWAQ.js} +2 -2
- package/dist/assets/{index-BbhEKLV8.js.map → index-B3A5IWAQ.js.map} +1 -1
- package/dist/assets/{index-BXLDYWo4.js → index-CAFf3K5-.js} +2 -2
- package/dist/assets/{index-BXLDYWo4.js.map → index-CAFf3K5-.js.map} +1 -1
- package/dist/assets/{index-CKO5J-yn.js → index-CDx3IfgN.js} +2 -2
- package/dist/assets/{index-CKO5J-yn.js.map → index-CDx3IfgN.js.map} +1 -1
- package/dist/assets/{index-BKgjTc--.js → index-CFlVUowS.js} +2 -2
- package/dist/assets/{index-BKgjTc--.js.map → index-CFlVUowS.js.map} +1 -1
- package/dist/assets/{index-Ce0DmLOw.js → index-Ckh17o1U.js} +2 -2
- package/dist/assets/{index-Ce0DmLOw.js.map → index-Ckh17o1U.js.map} +1 -1
- package/dist/assets/{index-oa_Oxkrg.js → index-D48MR3bL.js} +2 -2
- package/dist/assets/{index-oa_Oxkrg.js.map → index-D48MR3bL.js.map} +1 -1
- package/dist/assets/{index-BekC6gsX.js → index-DEKFCy0H.js} +3 -3
- package/dist/assets/{index-BekC6gsX.js.map → index-DEKFCy0H.js.map} +1 -1
- package/dist/assets/{index-CloYSKtQ.js → index-mFxKl9yz.js} +2 -2
- package/dist/assets/{index-CloYSKtQ.js.map → index-mFxKl9yz.js.map} +1 -1
- package/dist/assets/{new-admin-section-dialog-YeMy0G96.js → new-admin-section-dialog-4X2fxo7a.js} +2 -2
- package/dist/assets/{new-admin-section-dialog-YeMy0G96.js.map → new-admin-section-dialog-4X2fxo7a.js.map} +1 -1
- package/dist/assets/{new-app-dialog-nUBoX5fs.js → new-app-dialog-CCI4q4Mt.js} +2 -2
- package/dist/assets/{new-app-dialog-nUBoX5fs.js.map → new-app-dialog-CCI4q4Mt.js.map} +1 -1
- package/dist/assets/{new-enum-dialog-8Ba41lUU.js → new-enum-dialog-B5zvBxhT.js} +2 -2
- package/dist/assets/{new-enum-dialog-8Ba41lUU.js.map → new-enum-dialog-B5zvBxhT.js.map} +1 -1
- package/dist/assets/{new-model-dialog-CWgmV0pB.js → new-model-dialog-CiwTpKcZ.js} +2 -2
- package/dist/assets/{new-model-dialog-CWgmV0pB.js.map → new-model-dialog-CiwTpKcZ.js.map} +1 -1
- package/dist/assets/{route-DM37J86t.js → route-6ErXC2Qt.js} +2 -2
- package/dist/assets/{route-DM37J86t.js.map → route-6ErXC2Qt.js.map} +1 -1
- package/dist/assets/{route-DuhBcukV.js → route-C3eBLQEr.js} +2 -2
- package/dist/assets/{route-DuhBcukV.js.map → route-C3eBLQEr.js.map} +1 -1
- package/dist/assets/{route-CSbr85FB.js → route-C6wCPwVj.js} +2 -2
- package/dist/assets/{route-CSbr85FB.js.map → route-C6wCPwVj.js.map} +1 -1
- package/dist/assets/{route-DYxDmtHP.js → route-CZgTuGeJ.js} +2 -2
- package/dist/assets/{route-DYxDmtHP.js.map → route-CZgTuGeJ.js.map} +1 -1
- package/dist/assets/route-DLz_DL5S.js +2 -0
- package/dist/assets/{route-DHu7qE-k.js.map → route-DLz_DL5S.js.map} +1 -1
- package/dist/assets/{route-DDbjYROk.js → route-DluQ5e3_.js} +2 -2
- package/dist/assets/{route-DDbjYROk.js.map → route-DluQ5e3_.js.map} +1 -1
- package/dist/assets/{route-CTv4dICL.js → route-DzYT3FNA.js} +2 -2
- package/dist/assets/{route-CTv4dICL.js.map → route-DzYT3FNA.js.map} +1 -1
- package/dist/assets/{route-CrSpNRRy.js → route-PmxQsBVj.js} +2 -2
- package/dist/assets/{route-CrSpNRRy.js.map → route-PmxQsBVj.js.map} +1 -1
- package/dist/assets/{route-Ch1y-64Q.js → route-gYB7kkkm.js} +2 -2
- package/dist/assets/{route-Ch1y-64Q.js.map → route-gYB7kkkm.js.map} +1 -1
- package/dist/assets/{route-CbVppiIk.js → route-gzD4oiAl.js} +2 -2
- package/dist/assets/{route-CbVppiIk.js.map → route-gzD4oiAl.js.map} +1 -1
- package/dist/assets/{service-fvQlhwg4.js → service--2LVz4Ht.js} +2 -2
- package/dist/assets/{service-fvQlhwg4.js.map → service--2LVz4Ht.js.map} +1 -1
- package/dist/assets/{template-extractor-ChZnhGEF.js → template-extractor-D33LuEZ8.js} +2 -2
- package/dist/assets/{template-extractor-ChZnhGEF.js.map → template-extractor-D33LuEZ8.js.map} +1 -1
- package/dist/assets/{theme-builder-Y6jNiAJ3.js → theme-builder-CWetoMuo.js} +2 -2
- package/dist/assets/{theme-builder-Y6jNiAJ3.js.map → theme-builder-CWetoMuo.js.map} +1 -1
- package/dist/assets/{use-enum-form-D7XmblPC.js → use-enum-form-BRBAlWJc.js} +2 -2
- package/dist/assets/{use-enum-form-D7XmblPC.js.map → use-enum-form-BRBAlWJc.js.map} +1 -1
- package/dist/assets/{use-model-form-dwW5mcmn.js → use-model-form-psj-JlE9.js} +2 -2
- package/dist/assets/{use-model-form-dwW5mcmn.js.map → use-model-form-psj-JlE9.js.map} +1 -1
- package/dist/index.html +1 -1
- package/package.json +6 -6
- package/dist/assets/edit._sectionKey-BHWbqvR0.js +0 -3
- package/dist/assets/edit._sectionKey-BHWbqvR0.js.map +0 -1
- package/dist/assets/route-DHu7qE-k.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as l}from"./_virtual___federation_fn_import-D3sI42Ph.js";import{j as m}from"./jsx-runtime-D_zvdyIk.js";import{h as S,i as I,e as M}from"./index.esm-CdP29Ssb.js";import{q as j}from"./index-
|
|
1
|
+
import{i as l}from"./_virtual___federation_fn_import-D3sI42Ph.js";import{j as m}from"./jsx-runtime-D_zvdyIk.js";import{h as S,i as I,e as M}from"./index.esm-CdP29Ssb.js";import{q as j}from"./index-DEKFCy0H.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-BYERQCO8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-constants-DvXqIwvq.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,E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AA2B,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-BYERQCO8.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,CAAI,EACrBF,EAAK,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M,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-D3sI42Ph.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-D3sI42Ph.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{z as v,s as y}from"./index-DEKFCy0H.js";import{K as R}from"./index-tflukq04.js";import{u as F}from"./use-definition-schema-BuO4pbji.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-Dy1xMuLp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-
|
|
1
|
+
{"version":3,"file":"admin-Dy1xMuLp.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,CAAAA,EAAUP,EAE1CQ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A,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-D3sI42Ph.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-D3sI42Ph.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{g as k,s as g}from"./index-DEKFCy0H.js";import{u as v}from"./use-definition-schema-BuO4pbji.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-SevlkhOM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-
|
|
1
|
+
{"version":3,"file":"backend-SevlkhOM.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,8BAAA,EAc0Ea,EAAA,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,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-D3sI42Ph.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-D3sI42Ph.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-DEKFCy0H.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-BgnflZIL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit._key-
|
|
1
|
+
{"version":3,"file":"edit._key-BgnflZIL.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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P,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"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DEKFCy0H.js","assets/_virtual___federation_fn_import-D3sI42Ph.js","assets/jsx-runtime-D_zvdyIk.js","assets/index-c0qeY2gs.js","assets/index-DqHVrEeL.js","assets/_commonjsHelpers-CqkleIqs.js","assets/index-tflukq04.js","assets/index.esm-CdP29Ssb.js","assets/sortBy-C9bvycg5.js","assets/immer-B7fdkLVi.js","assets/index-DPK1IfNZ.css","assets/index-BPClqgn_.js","assets/index-tHURiz2C.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as c}from"./_virtual___federation_fn_import-D3sI42Ph.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{s as N,S as q,l as je,h as Fe,_ as L,i as M}from"./index-DEKFCy0H.js";import{u as De}from"./use-definition-schema-BuO4pbji.js";import{g as ee,s as te,b as V,e as I,f as Y}from"./index.esm-CdP29Ssb.js";import{H as J,L as Q,c as X,A as Z}from"./index-tflukq04.js";var Ie=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,l,s,a,u;const d=t.toString(),p=this.path?`${this.path}.${d}`:d,b=(i=this.cache)==null?void 0:i.get(p,this.reflectedKey);if(b)return b;if(Array.isArray(this.override)){const[h]=this.override,f=new S(this.control,p,this.cache);return f.isArrayItemReflection=!0,f.override=h,(n=this.cache)==null||n.set(f,p),f}else if(this.override){const h=ee(this.override,d);if(!h){const f=new S(this.control,p,this.cache);return(l=this.cache)==null||l.set(f,p),f}if(this.isArrayItemReflection){const f=`${this.path}.${h.path}`,x=new S(this.control,f,this.cache);return(s=this.cache)==null||s.set(x,f),x}else return(a=this.cache)==null||a.set(h,p),h}const j=new S(this.control,p,this.cache);return(u=this.cache)==null||u.set(j,p),j}reflect(t){var i,n,l;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),u=new Proxy({},{get:(p,b)=>typeof b=="string"?a.focus(b):p}),d=t(u,a);if(Array.isArray(d)){const p=new S(this.control,this.path,this.cache);return a.path="",p.override=t(u,a),p.reflectedKey=t,(n=this.cache)==null||n.set(p,this.path,t),p}else return a.override=d,a.path=this.path,a.reflectedKey=t,(l=this.cache)==null||l.set(a,this.path,t),a}map(t,i){return t.map((n,l,s)=>{const a=this.focus(l.toString());return i(n,a,l,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(([l,s])=>{const a=s;if(!a)return;const u=ee(t,a.path);te(n,l,u)}),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(([l,s])=>{const a=i[l];a&&te(n,a.path,s)}),n}},Se=class{constructor(o){this.cache=new Map,o._subscribe({formState:{values:!0},exact:!0,callback:()=>{o._names.unMount.forEach(t=>{this.delete(t)})}})}get(o,t){const i=this.cache.get(o);if(i)return t?i.complex.get(t):i.plain}set(o,t,i){let n=this.cache.get(t);n||(n={complex:new WeakMap},this.cache.set(t,n)),i?n.complex.set(i,o):n.plain=o}has(o,t){var i,n;return t?(n=(i=this.cache.get(o))==null?void 0:i.complex.has(t))!=null?n:!1:this.cache.has(o)}delete(o){for(const t of this.cache.keys())t.startsWith(o)&&this.cache.delete(t)}clear(){this.cache.clear()}};const{useMemo:Ae}=await c("react");function Ce(o,t=[]){return Ae(()=>{const i=new Se(o.control);return Ie.create(o.control,i)},[o.control,...t])}const{ModelUtils:$e}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudInputWebConfig:Te,useProjectDefinition:Ee}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:ne}=await c("@baseplate-dev/ui-components");function Re({formProps:o,name:t,model:i,embeddedFormOptions:n}){const{definition:l}=Ee(),s=$e.getRelationsToModel(l,i.id).map(d=>({label:`${d.relation.foreignRelationName} (${d.model.name})`,value:d.relation.foreignId})),a=t,u=o.control;return e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"Relation Name",control:u,name:`${a}.modelRelationRef`,options:s}),e.jsx(ne,{label:"Embedded Form",control:u,name:`${a}.embeddedFormRef`,options:n})]})}const Ne=Te({name:"embedded",pluginKey:void 0,label:"Embedded",getNewInput:()=>({label:"",type:"embedded",modelRelationRef:"",embeddedFormRef:""}),Form:Re}),{createAdminCrudInputWebConfig:Le,useProjectDefinition:_e}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:ie}=await c("@baseplate-dev/ui-components");function We({formProps:o,name:t,model:i,embeddedFormOptions:n}){const{definitionContainer:l}=_e(),s=i.model.relations?.map(d=>({label:`${d.name} (${l.nameFromId(d.modelRef)})`,value:d.id}))??[],a=t,u=o.control;return e.jsxs(e.Fragment,{children:[e.jsx(ie,{label:"Relation Name",control:u,name:`${a}.localRelationRef`,options:s}),e.jsx(ie,{label:"Embedded Form",control:u,name:`${a}.embeddedFormRef`,options:n})]})}const Pe=Le({name:"embeddedLocal",pluginKey:void 0,label:"Embedded Local",getNewInput:()=>({label:"",type:"embeddedLocal",embeddedFormRef:"",localRelationRef:""}),Form:We}),{createAdminCrudInputWebConfig:Ve}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:Me}=await c("@baseplate-dev/ui-components");function Oe({formProps:o,name:t,model:i}){const n=i.model.fields.filter(a=>a.type==="enum").map(a=>({label:a.name,value:a.id})),l=t,s=o.control;return e.jsx(Me,{label:"Enum Field",control:s,name:`${l}.modelFieldRef`,options:n})}const ke=Ve({name:"enum",pluginKey:void 0,label:"Enum",getNewInput:()=>({label:"",type:"enum",modelFieldRef:""}),Form:Oe}),{createAdminCrudInputWebConfig:Ue,useProjectDefinition:Be}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:_,SelectFieldController:Ke}=await c("@baseplate-dev/ui-components");function ze({formProps:o,name:t,model:i}){const{definitionContainer:n}=Be(),l=i.model.relations?.map(u=>({label:`${u.name} (${n.nameFromId(u.modelRef)})`,value:u.id}))??[],s=t,a=o.control;return e.jsxs(e.Fragment,{children:[e.jsx(Ke,{label:"Local Relation Name",control:a,name:`${s}.localRelationRef`,options:l}),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 He=Ue({name:"foreign",pluginKey:void 0,label:"Foreign",getNewInput:()=>({label:"",type:"foreign",localRelationRef:"",labelExpression:"",valueExpression:"",defaultLabel:"",nullLabel:""}),Form:ze}),{createAdminCrudInputWebConfig:Ge}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:qe,SelectFieldController:Ye}=await c("@baseplate-dev/ui-components");function Je({formProps:o,name:t,model:i}){const n=i.model.fields.map(a=>({label:a.name,value:a.id})),l=t,s=o.control;return e.jsxs(e.Fragment,{children:[e.jsx(Ye,{label:"Field",control:s,name:`${l}.modelFieldRef`,options:n}),e.jsx(qe,{label:"Validation (zod), e.g. z.string().min(1) (optional)",control:s,name:`${l}.validation`})]})}const Qe=Ge({name:"text",pluginKey:void 0,label:"Text",getNewInput:()=>({label:"",type:"text",modelFieldRef:""}),Form:Je}),oe=[Ne,Pe,ke,He,Qe],{createAdminCrudInputSchema:Xe,ModelUtils:Ze}=await c("@baseplate-dev/project-builder-lib"),{adminCrudInputWebSpec:et,useDefinitionSchema:tt,useProjectDefinition:nt}=await c("@baseplate-dev/project-builder-lib/web"),{Button:le,Dialog:it,DialogContent:ot,DialogDescription:lt,DialogFooter:st,DialogHeader:at,DialogTitle:rt,InputFieldController:ct,SelectFieldController:dt}=await c("@baseplate-dev/ui-components"),{useEffect:mt,useId:ut}=await c("react");function pt({open:o,onOpenChange:t,field:i,modelRef:n,embeddedFormOptions:l,isNew:s=!1,onSave:a}){const{definition:u,pluginContainer:d}=nt(),p=tt(Xe),b=n?Ze.byIdOrThrow(u,n):void 0,j=d.getPluginSpec(et),h=j.getInputWebConfigs(oe).map(C=>({label:C.label,value:C.name})),f=V({resolver:N(p),values:i??{type:"text",label:""}}),{control:x,handleSubmit:F,formState:{isDirty:w},reset:g}=f;mt(()=>{o&&!i&&g({type:"text",label:""})},[o,i,g]);const v=I({control:x,name:"type"}),y=v?j.getInputWebConfig(v,oe):void 0,D=y?.Form,m=F(C=>{a(C),t(!1)}),r=ut();return e.jsx(it,{open:o,onOpenChange:t,children:e.jsx(ot,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:r,onSubmit:C=>(C.stopPropagation(),m(C)),children:[e.jsxs(at,{children:[e.jsx(rt,{children:s?"Add Field":"Edit Field"}),e.jsx(lt,{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(dt,{label:"Type",control:x,options:h,name:"type"}),e.jsx(ct,{label:"Label",control:x,name:"label",placeholder:"Enter field label"}),D&&b&&e.jsx(D,{formProps:f,name:"",model:b,embeddedFormOptions:l,pluginKey:y.pluginKey})]}),e.jsxs(st,{children:[e.jsx(le,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(le,{form:r,type:"submit",disabled:!w,children:[s?"Add":"Update"," Field"]})]})]})})})}const{Button:O,RecordView:ft,RecordViewActions:bt,RecordViewItem:se,RecordViewItemList:ht,useConfirmDialog:xt}=await c("@baseplate-dev/ui-components"),{useState:k}=await c("react");function ge({className:o,formProps:t,embeddedFormOptions:i}){const{control:n}=t,{requestConfirm:l}=xt(),{fields:s,append:a,remove:u,update:d,move:p}=Y({control:n,name:"form.fields"}),[b,j]=k(void 0),[h,f]=k(!1),[x,F]=k(!1),w=I({control:n,name:"form.fields"});function g(r){const C=w[r];l({title:"Delete Field",content:`Are you sure you want to delete the field "${C.label||"Untitled"}"?`,onConfirm:()=>{u(r)}})}function v(r){j(w[r]),f(!0)}function y(){j(void 0),F(!0)}function D(r){if(b){const C=w.findIndex(we=>we.id===b.id);C!==-1&&d(C,r)}else a(r)}const m=s.map((r,C)=>({id:r.id,element:e.jsxs(ft,{children:[e.jsxs(ht,{children:[e.jsx(se,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:r.label})}),e.jsx(se,{title:"Type",children:r.type})]}),e.jsxs(bt,{children:[e.jsx(O,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit field",onClick:()=>{v(C)},children:e.jsx(J,{})}),e.jsx(O,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete field",onClick:()=>{g(C)},children:e.jsx(Q,{})})]})]},r.id)}));return e.jsxs("div",{className:X("space-y-4",o),children:[s.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"No fields configured. Add fields to create your form."}):e.jsx("div",{className:"flex w-full flex-col gap-2",children:e.jsx(q,{listItems:m,sortItems:p})}),e.jsx(pt,{open:h||x,onOpenChange:r=>{r||(f(!1),F(!1),j(void 0))},field:b,modelRef:I({control:n,name:"modelRef"})||"",embeddedFormOptions:i,isNew:x,onSave:D}),e.jsxs(O,{variant:"secondary",size:"sm",onClick:y,children:[e.jsx(Z,{}),"Add Field"]})]})}const{useMemo:jt}=await c("react");function Ct(o){const t=Y(o);return{fields:jt(()=>o.getTransformer?t.fields.map(o.getTransformer):t.fields,[t.fields,o.getTransformer]),move:t.move,remove:t.remove,swap:t.swap,prepend:(n,l)=>{if(!o.setTransformer)return t.prepend(n,l);const s=Array.isArray(n)?n.map(o.setTransformer):o.setTransformer(n);t.prepend(s,l)},append:(n,l)=>{if(!o.setTransformer)return t.append(n,l);const s=Array.isArray(n)?n.map(o.setTransformer):o.setTransformer(n);t.append(s,l)},insert:(n,l,s)=>{if(!o.setTransformer)return t.insert(n,l,s);const a=Array.isArray(l)?l.map(o.setTransformer):o.setTransformer(l);t.insert(n,a,s)},update:(n,l)=>{if(!o.setTransformer)return t.update(n,l);const s=o.setTransformer(l);t.update(n,s)},replace:n=>{if(!o.setTransformer)return t.replace(n);const l=o.setTransformer(n);t.replace(l)}}}const{adminCrudColumnEntityType:gt}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:vt,useProjectDefinition:yt}=await c("@baseplate-dev/project-builder-lib/web"),{InputFieldController:ae,SelectFieldController:wt}=await c("@baseplate-dev/ui-components");function Ft({formProps:o,model:t}){const{control:i}=o,{definitionContainer:n}=yt(),l=t.model.relations?.map(s=>({label:`${s.name} (${n.nameFromId(s.modelRef)})`,value:s.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsx(wt,{label:"Local Relation",control:i,name:"localRelationRef",options:l,placeholder:"Select a relation"}),e.jsx(ae,{label:"Label Expression",control:i,name:"labelExpression",placeholder:"e.g. name",description:"Field to display from the related model"}),e.jsx(ae,{label:"Value Expression",control:i,name:"valueExpression",placeholder:"e.g. id",description:"Field to use for matching the relation"})]})}const Dt=vt({name:"foreign",pluginKey:void 0,label:"Foreign Column",isAvailableForModel:(o,t)=>(o.models.find(n=>n.id===t)?.model.relations?.length??0)>0,Form:Ft,getNewColumn:()=>({id:gt.generateNewId(),type:"foreign",label:"",localRelationRef:"",labelExpression:"",valueExpression:""})}),{adminCrudColumnEntityType:It}=await c("@baseplate-dev/project-builder-lib"),{createAdminCrudColumnWebConfig:St}=await c("@baseplate-dev/project-builder-lib/web"),{SelectFieldController:At}=await c("@baseplate-dev/ui-components");function $t({formProps:o,model:t}){const{control:i}=o,n=t.model.fields.map(l=>({label:l.name,value:l.id}));return e.jsx(At,{label:"Field",control:i,name:"modelFieldRef",options:n,placeholder:"Select a field"})}const Tt=St({name:"text",pluginKey:void 0,label:"Text Column",Form:$t,isAvailableForModel:()=>!0,getNewColumn:()=>({id:It.generateNewId(),type:"text",label:"",modelFieldRef:""})}),re=[Dt,Tt],{createAdminCrudColumnSchema:Et,ModelUtils:Rt}=await c("@baseplate-dev/project-builder-lib"),{adminCrudColumnWebSpec:Nt,useDefinitionSchema:Lt,useProjectDefinition:_t}=await c("@baseplate-dev/project-builder-lib/web"),{Button:ce,Dialog:Wt,DialogContent:Pt,DialogDescription:Vt,DialogFooter:Mt,DialogHeader:Ot,DialogTitle:kt,InputFieldController:Ut,SelectFieldController:Bt}=await c("@baseplate-dev/ui-components"),{useEffect:Kt,useId:zt}=await c("react");function Ht({open:o,onOpenChange:t,column:i,modelRef:n,isNew:l=!1,onSave:s}){const{definition:a,pluginContainer:u}=_t(),d=Lt(Et),p=n?Rt.byIdOrThrow(a,n):void 0,b=u.getPluginSpec(Nt),j=b.getColumnWebConfigs(re).filter(r=>n&&r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),h=V({resolver:N(d),values:i??{type:"text",label:""}}),{control:f,handleSubmit:x,formState:{isDirty:F},reset:w}=h;Kt(()=>{o&&!i&&w({type:"text",label:""})},[o,i,w]);const g=I({control:f,name:"type"}),v=g?b.getColumnWebConfig(g,re):void 0,y=v?.Form,D=x(r=>{s(r),t(!1)}),m=zt();return e.jsx(Wt,{open:o,onOpenChange:t,children:e.jsx(Pt,{className:"sm:max-w-[425px]",children:e.jsxs("form",{id:m,onSubmit:r=>(r.stopPropagation(),D(r)),children:[e.jsxs(Ot,{children:[e.jsx(kt,{children:l?"Add Column":"Edit Column"}),e.jsx(Vt,{children:l?"Configure the new table column settings.":"Update the column settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(Bt,{label:"Type",control:f,options:j,name:"type"}),e.jsx(Ut,{label:"Label",control:f,name:"label",placeholder:"Enter column label"}),y&&p&&e.jsx(y,{formProps:h,model:p,pluginKey:v.pluginKey})]}),e.jsxs(Mt,{children:[e.jsx(ce,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(ce,{form:m,type:"submit",disabled:!F,children:[l?"Add":"Update"," Column"]})]})]})})})}const{Button:U,RecordView:Gt,RecordViewActions:qt,RecordViewItem:de,RecordViewItemList:Yt,useConfirmDialog:Jt}=await c("@baseplate-dev/ui-components"),{useState:B}=await c("react");function ve({className:o,lens:t,modelRef:i}){const{requestConfirm:n}=Jt(),{fields:l,append:s,remove:a,update:u,move:d}=Ct(t.interop()),[p,b]=B(void 0),[j,h]=B(!1),[f,x]=B(!1);function F(m){const r=l[m];n({title:"Delete Column",content:`Are you sure you want to delete the column "${r.label||"Untitled"}"?`,onConfirm:()=>{a(m)}})}const w=I(t.interop());function g(m){b(w[m]),h(!0)}function v(){b(void 0),x(!0)}function y(m){if(p){const r=w.findIndex(C=>C.id===p.id);r!==-1&&u(r,m)}else s(m)}const D=l.map((m,r)=>({id:m.id,element:e.jsxs(Gt,{children:[e.jsxs(Yt,{children:[e.jsx(de,{title:"Label",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:m.label||e.jsx("span",{className:"text-muted-foreground",children:"Untitled Column"})})})}),e.jsx(de,{title:"Type",children:m.type})]}),e.jsxs(qt,{children:[e.jsx(U,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit column",onClick:()=>{g(r)},children:e.jsx(J,{})}),e.jsx(U,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete column",onClick:()=>{F(r)},children:e.jsx(Q,{})})]})]},m.id)}));return e.jsxs("div",{className:X("space-y-4",o),children:[l.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(q,{listItems:D,sortItems:d})}),e.jsx(Ht,{open:j||f,onOpenChange:m=>{m||(h(!1),x(!1),b(void 0))},column:p,modelRef:i,isNew:f,onSave:y}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(Z,{}),"Add Column"]})]})}const{createAdminCrudEmbeddedFormSchema:Qt}=await c("@baseplate-dev/project-builder-lib"),{useDefinitionSchema:Xt,useProjectDefinition:ye}=await c("@baseplate-dev/project-builder-lib/web"),{Button:G,CheckboxFieldController:Zt,InputFieldController:en,SelectFieldController:me,Table:tn,TableBody:nn,TableCell:W,TableHead:P,TableHeader:on,TableRow:ue,toast:ln}=await c("@baseplate-dev/ui-components"),{useId:sn}=await c("react");function an({items:o,edit:t,remove:i}){const{definitionContainer:n}=ye();return e.jsxs(tn,{className:"max-w-6xl",children:[e.jsx(on,{children:e.jsxs(ue,{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(nn,{children:o.map((l,s)=>e.jsxs(ue,{children:[e.jsx(W,{children:l.name}),e.jsx(W,{children:n.nameFromId(l.modelRef)}),e.jsx(W,{children:l.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"})]})]},l.id))})]})}const rn=[{label:"Object",value:"object"},{label:"List",value:"list"}];function cn({initialData:o,onSubmit:t,embeddedFormOptions:i}){const{definition:n}=ye(),l=Xt(Qt),s=V({resolver:N(l),defaultValues:o}),{handleSubmit:a,control:u,watch:d}=s,p=n.models.map(x=>({label:x.name,value:x.id})),b=d("type"),j=d("modelRef"),h=Ce({control:u}),f=sn();return e.jsxs("form",{onSubmit:x=>{x.stopPropagation(),a(t)(x).catch(F=>{ln.error(je(F))})},id:f,className:"space-y-4",children:[e.jsx(en,{label:"Name",control:u,name:"name"}),e.jsx(me,{label:"Type",control:u,name:"type",options:rn}),e.jsx(Zt,{label:"Include ID Field? (useful for list types)",control:u,name:"includeIdField"}),e.jsx(me,{label:"Model",control:u,options:p,name:"modelRef"}),b==="list"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Table"}),e.jsx(ve,{lens:h.focus("table.columns"),modelRef:j})]}),e.jsx("h2",{children:"Form"}),e.jsx(ge,{formProps:s,embeddedFormOptions:i}),e.jsx(G,{type:"submit",form:f,children:"Save"})]})}const{createAdminCrudActionWebConfig:dn}=await c("@baseplate-dev/project-builder-lib/web"),mn=dn({name:"delete",pluginKey:void 0,label:"Delete",isAvailableForModel:()=>!0,getNewAction:()=>({type:"delete",position:"dropdown"})}),{createAdminCrudActionWebConfig:un}=await c("@baseplate-dev/project-builder-lib/web"),pn=un({name:"edit",pluginKey:void 0,label:"Edit",isAvailableForModel:()=>!0,getNewAction:()=>({type:"edit",position:"inline"})}),pe=[pn,mn],{createAdminCrudActionSchema:fn,ModelUtils:bn}=await c("@baseplate-dev/project-builder-lib"),{adminCrudActionWebSpec:hn,useDefinitionSchema:xn,useProjectDefinition:jn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:fe,Dialog:Cn,DialogContent:gn,DialogDescription:vn,DialogFooter:yn,DialogHeader:wn,DialogTitle:Fn,SelectFieldController:be}=await c("@baseplate-dev/ui-components"),{useEffect:Dn,useId:In}=await c("react");function Sn({open:o,onOpenChange:t,action:i,modelRef:n,isNew:l=!1,onSave:s}){const{definition:a,pluginContainer:u}=jn(),d=xn(fn),p=n?bn.byIdOrThrow(a,n):void 0,b=u.getPluginSpec(hn),j=b.getActionWebConfigs(pe).filter(r=>n&&r.isAvailableForModel(a,n)).map(r=>({label:r.label,value:r.name})),h=V({resolver:N(d),values:i??{type:"edit",position:"inline"}}),{control:f,handleSubmit:x,formState:{isDirty:F},reset:w}=h;Dn(()=>{o&&!i&&w({type:"edit",position:"inline"})},[o,i,w]);const g=I({control:f,name:"type"}),v=g?b.getActionWebConfig(g,pe):void 0,y=v?.Form,D=x(r=>{s(r),t(!1)}),m=In();return e.jsx(Cn,{open:o,onOpenChange:t,children:e.jsx(gn,{className:"sm:max-w-[500px]",children:e.jsxs("form",{id:m,onSubmit:r=>(r.stopPropagation(),D(r)),children:[e.jsxs(wn,{children:[e.jsx(Fn,{children:l?"Add Action":"Edit Action"}),e.jsx(vn,{children:l?"Configure the new table action settings.":"Update the action settings below."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx(be,{label:"Type",control:f,options:j,name:"type"}),e.jsx(be,{label:"Position",control:f,options:[{label:"Inline",value:"inline"},{label:"Dropdown",value:"dropdown"}],name:"position"}),y&&p&&e.jsx(y,{formProps:h,model:p,pluginKey:v.pluginKey})]}),e.jsxs(yn,{children:[e.jsx(fe,{type:"button",variant:"outline",onClick:()=>{t(!1)},children:"Cancel"}),e.jsxs(fe,{form:m,type:"submit",disabled:!F,children:[l?"Add":"Update"," Action"]})]})]})})})}const{Button:K,RecordView:An,RecordViewActions:$n,RecordViewItem:he,RecordViewItemList:Tn,useConfirmDialog:En}=await c("@baseplate-dev/ui-components"),{useState:z}=await c("react");function Rn({className:o,control:t,modelRef:i}){const{requestConfirm:n}=En(),{fields:l,append:s,remove:a,update:u,move:d}=Y({control:t,name:"table.actions"}),[p,b]=z(void 0),[j,h]=z(!1),[f,x]=z(!1);function F(m){const r=l[m];n({title:"Delete Action",content:`Are you sure you want to delete the "${r.type}" action?`,onConfirm:()=>{a(m)}})}const w=I({control:t,name:"table.actions"});function g(m){b(w?.[m]),h(!0)}function v(){b(void 0),x(!0)}function y(m){if(p){const r=(w??[]).findIndex(C=>C.id===p.id);r!==-1&&u(r,m)}else s(m)}const D=l.map((m,r)=>({id:m.id,element:e.jsxs(An,{children:[e.jsxs(Tn,{children:[e.jsx(he,{title:"Type",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"capitalize",children:m.type})})}),e.jsx(he,{title:"Position",children:m.position})]}),e.jsxs($n,{children:[e.jsx(K,{variant:"ghost",size:"icon",title:"Edit","aria-label":"Edit action",onClick:()=>{g(r)},children:e.jsx(J,{})}),e.jsx(K,{variant:"ghostDestructive",size:"icon",title:"Delete","aria-label":"Delete action",onClick:()=>{F(r)},children:e.jsx(Q,{})})]})]},m.id)}));return e.jsxs("div",{className:X("space-y-4",o),children:[l.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(q,{listItems:D,sortItems:d})}),e.jsx(Sn,{open:j||f,onOpenChange:m=>{m||(h(!1),x(!1),b(void 0))},action:p,modelRef:i??"",isNew:f,onSave:y}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(Z,{}),"Add Action"]})]})}const{useProjectDefinition:Nn}=await c("@baseplate-dev/project-builder-lib/web"),{CheckboxFieldController:Ln,ComboboxFieldController:xe,SectionListSection:A,SectionListSectionContent:$,SectionListSectionDescription:T,SectionListSectionHeader:E,SectionListSectionTitle:R}=await c("@baseplate-dev/ui-components");function _n({formProps:o}){const{control:t}=o,{definition:i}=Nn(),n=Ce({control:t}),l=i.models.map(d=>({label:d.name,value:d.id})),s=I({control:t,name:"modelRef"}),a=i.models.find(d=>d.id===s)?.model.fields.map(d=>({label:d.name,value:d.id}))??[],u=I({control:t,name:"embeddedForms"})?.map(d=>({label:d.name,value:d.id}))??[];return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(R,{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(xe,{label:"Model",control:t,options:l,name:"modelRef"}),e.jsx(xe,{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(Ln,{label:"Disable Create?",control:t,name:"disableCreate"})]})]}),e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(R,{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(E,{children:[e.jsx(R,{children:"Table Actions"}),e.jsx(T,{children:"Configure actions available for each row in the table. Drag to reorder."})]}),e.jsx($,{children:e.jsx(Rn,{control:t,modelRef:s})})]}),e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(R,{children:"Form Configuration"}),e.jsx(T,{children:"Configure the form fields for creating and editing records."})]}),e.jsx($,{children:e.jsx(ge,{formProps:o,embeddedFormOptions:u})})]}),e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(R,{children:"Embedded Forms"}),e.jsx(T,{children:"Configure embedded forms for related data objects."})]}),e.jsx($,{children:e.jsx(Fe.LabelledController,{control:t,name:"embeddedForms",renderForm:d=>e.jsx(cn,{...d,embeddedFormOptions:u}),renderTable:d=>e.jsx(an,{...d}),defaultValue:{type:"object"}})})]})]})}const{AsyncComboboxField:Wn,useControllerMerged:Pn}=await c("@baseplate-dev/ui-components");async function Vn(){const o=await L(()=>import("./index-DEKFCy0H.js").then(s=>s.A),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),t=await L(()=>import("./index-BPClqgn_.js"),__vite__mapDeps([11,6,1])),i=await L(()=>import("./index-tflukq04.js").then(s=>s.R),__vite__mapDeps([6,1])),n=await L(()=>import("./index-tHURiz2C.js"),__vite__mapDeps([12,6,1]));return[o,t,i,n].map(s=>Object.entries(s).filter(([,a])=>typeof a=="function").map(([a,u])=>({label:a,value:a,icon:u}))).flat()}function Mn({...o}){return e.jsx(Wn,{placeholder:"Select an icon",...o,loadOptions:t=>Vn().then(i=>i.filter(n=>!t||n.label.toLowerCase().includes(t.toLowerCase())).sort((n,l)=>n.label.localeCompare(l.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 On({name:o,control:t,...i}){const{field:n,fieldState:{error:l}}=Pn({name:o,control:t},i),s=i;return e.jsx(Mn,{error:l?.message,...s,...n,value:n.value??null})}const{adminSectionEntityType:kn,createWebAdminSectionSchema:Un}=await c("@baseplate-dev/project-builder-lib"),{useBlockUnsavedChangesNavigate:Bn,useProjectDefinition:Kn,useResettableForm:zn}=await c("@baseplate-dev/project-builder-lib/web"),{Button:H,ComboboxFieldController:Hn,Dialog:Gn,DialogClose:qn,DialogContent:Yn,DialogDescription:Jn,DialogFooter:Qn,DialogHeader:Xn,DialogTitle:Zn,DialogTrigger:ei,FormActionBar:ti,InputFieldController:ni,SectionList:ii,SectionListSection:oi,SectionListSectionContent:li,SectionListSectionDescription:si,SectionListSectionHeader:ai,SectionListSectionTitle:ri}=await c("@baseplate-dev/ui-components"),{useNavigate:ci}=await c("@tanstack/react-router"),hi=function(){const{app:t,section:i}=M.useLoaderData(),{appKey:n,sectionKey:l}=M.useParams(),s=ci({from:M.fullPath}),{definition:a,saveDefinitionWithFeedback:u,isSavingDefinition:d}=Kn(),p=De(Un),b=a.features.map(g=>({label:g.name,value:g.id})),j=zn({resolver:N(p),values:i,defaultValues:{type:"crud"}}),{control:h,handleSubmit:f,reset:x}=j,F=f(g=>{const{id:v,...y}=g;return u(D=>{const m=D.apps.find(C=>C.id===t.id);if(m?.type!=="web"||!m.adminApp)return;const r=m.adminApp.sections?.findIndex(C=>C.id===kn.idFromKey(l));r!==void 0&&r>=0&&m.adminApp.sections&&(m.adminApp.sections[r]={...y,id:i.id})})}),w=()=>{u(g=>{const v=g.apps.find(y=>y.id===t.id);v?.type!=="web"||!v.adminApp||(v.adminApp.sections=v.adminApp.sections?.filter(y=>y.id!==i.id))},{successMessage:`Successfully deleted section "${i.name}"!`,onSuccess:()=>{s({to:"/admin-sections/$appKey",params:{appKey:n}}).catch(je)}})};return Bn({control:h,reset:x,onSubmit:F}),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(Gn,{children:[e.jsx(ei,{asChild:!0,children:e.jsx(H,{variant:"secondary",children:"Delete"})}),e.jsxs(Yn,{children:[e.jsxs(Xn,{children:[e.jsxs(Zn,{children:["Delete ",i.name]}),e.jsxs(Jn,{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(Qn,{children:[e.jsx(qn,{asChild:!0,children:e.jsx(H,{variant:"secondary",children:"Cancel"})}),e.jsx(H,{variant:"destructive",onClick:w,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:F,className:"w-full max-w-7xl space-y-4 p-4",children:[e.jsxs(ii,{children:[e.jsxs(oi,{children:[e.jsxs(ai,{children:[e.jsx(ri,{children:"General"}),e.jsx(si,{children:"Basic configuration for your admin section."})]}),e.jsxs(li,{className:"space-y-6",children:[e.jsx(ni,{label:"Name",control:h,name:"name",autoComplete:"off"}),e.jsx(Hn,{label:"Feature",control:h,options:b,name:"featureRef"}),e.jsx(On,{label:"Icon",control:h,name:"icon",description:"Choose an icon to represent this section"})]})]}),e.jsx(_n,{formProps:j})]}),e.jsx(ti,{form:j})]})})]},i.id)};export{hi as component};
|
|
3
|
+
//# sourceMappingURL=edit._sectionKey-D4mTSUhO.js.map
|