convex-cms 0.0.1 → 0.0.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/LICENSE +190 -0
- package/README.md +99 -0
- package/admin-dist/nitro.json +15 -0
- package/admin-dist/public/assets/CmsEmptyState-CRswfTzk.js +5 -0
- package/admin-dist/public/assets/CmsPageHeader-CirpXndm.js +1 -0
- package/admin-dist/public/assets/CmsStatusBadge-CbEUpQu-.js +1 -0
- package/admin-dist/public/assets/CmsToolbar-BI2nZOXp.js +1 -0
- package/admin-dist/public/assets/ContentEntryEditor-CBeCyK_m.js +4 -0
- package/admin-dist/public/assets/ErrorState-BIVaWmom.js +1 -0
- package/admin-dist/public/assets/TaxonomyFilter-ChaY6Y_x.js +1 -0
- package/admin-dist/public/assets/_contentTypeId-DQ8k_Rvw.js +1 -0
- package/admin-dist/public/assets/_entryId-CKU_glsK.js +1 -0
- package/admin-dist/public/assets/alert-BXjTqrwQ.js +1 -0
- package/admin-dist/public/assets/badge-hvUOzpVZ.js +1 -0
- package/admin-dist/public/assets/circle-check-big-CF_pR17r.js +1 -0
- package/admin-dist/public/assets/command-DU82cJlt.js +1 -0
- package/admin-dist/public/assets/content-_LXl3pp7.js +1 -0
- package/admin-dist/public/assets/content-types-KjxaXGxY.js +2 -0
- package/admin-dist/public/assets/globals-CS6BZ0zp.css +1 -0
- package/admin-dist/public/assets/index-DNGIZHL-.js +1 -0
- package/admin-dist/public/assets/label-KNtpL71g.js +1 -0
- package/admin-dist/public/assets/link-2-Bw2aI4V4.js +1 -0
- package/admin-dist/public/assets/list-sYepHjt_.js +1 -0
- package/admin-dist/public/assets/main-CKj5yfEi.js +97 -0
- package/admin-dist/public/assets/media-Bkrkffm7.js +1 -0
- package/admin-dist/public/assets/new._contentTypeId-C3LstjNs.js +1 -0
- package/admin-dist/public/assets/plus-DUn8v_Xf.js +1 -0
- package/admin-dist/public/assets/rotate-ccw-DJEoHcRI.js +1 -0
- package/admin-dist/public/assets/scroll-area-DfIlT0in.js +1 -0
- package/admin-dist/public/assets/search-MuAUDJKR.js +1 -0
- package/admin-dist/public/assets/select-BD29IXCI.js +1 -0
- package/admin-dist/public/assets/settings-DmMyn_6A.js +1 -0
- package/admin-dist/public/assets/switch-h3Rrnl5i.js +1 -0
- package/admin-dist/public/assets/tabs-imc8h-Dp.js +1 -0
- package/admin-dist/public/assets/taxonomies-dAsrT65H.js +1 -0
- package/admin-dist/public/assets/textarea-BTy7nwzR.js +1 -0
- package/admin-dist/public/assets/trash-SAWKZZHv.js +1 -0
- package/admin-dist/public/assets/triangle-alert-E52Vfeuh.js +1 -0
- package/admin-dist/public/assets/useBreadcrumbLabel-BECBMCzM.js +1 -0
- package/admin-dist/public/assets/usePermissions-Basjs9BT.js +1 -0
- package/admin-dist/public/favicon.ico +0 -0
- package/admin-dist/server/_chunks/_libs/@date-fns/tz.mjs +217 -0
- package/admin-dist/server/_chunks/_libs/@floating-ui/core.mjs +719 -0
- package/admin-dist/server/_chunks/_libs/@floating-ui/dom.mjs +622 -0
- package/admin-dist/server/_chunks/_libs/@floating-ui/react-dom.mjs +292 -0
- package/admin-dist/server/_chunks/_libs/@floating-ui/utils.mjs +320 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/number.mjs +6 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/primitive.mjs +11 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-arrow.mjs +23 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-avatar.mjs +119 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-checkbox.mjs +270 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-collection.mjs +69 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-compose-refs.mjs +39 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-context.mjs +137 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-dialog.mjs +325 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-direction.mjs +9 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-dismissable-layer.mjs +210 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-dropdown-menu.mjs +253 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-guards.mjs +29 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-scope.mjs +206 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-id.mjs +14 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-label.mjs +23 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-menu.mjs +812 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-popover.mjs +300 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-popper.mjs +286 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-portal.mjs +16 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-presence.mjs +128 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-primitive.mjs +141 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-roving-focus.mjs +224 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-scroll-area.mjs +721 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-select.mjs +1163 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-separator.mjs +28 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-slot.mjs +601 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-switch.mjs +152 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-tabs.mjs +189 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-callback-ref.mjs +11 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-controllable-state.mjs +69 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-effect-event.mjs +1 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-escape-keydown.mjs +17 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-is-hydrated.mjs +15 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-layout-effect.mjs +6 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-previous.mjs +14 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-size.mjs +39 -0
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-visually-hidden.mjs +33 -0
- package/admin-dist/server/_chunks/_libs/@tanstack/history.mjs +409 -0
- package/admin-dist/server/_chunks/_libs/@tanstack/react-router.mjs +1711 -0
- package/admin-dist/server/_chunks/_libs/@tanstack/react-store.mjs +56 -0
- package/admin-dist/server/_chunks/_libs/@tanstack/router-core.mjs +4829 -0
- package/admin-dist/server/_chunks/_libs/@tanstack/store.mjs +134 -0
- package/admin-dist/server/_chunks/_libs/react-dom.mjs +10781 -0
- package/admin-dist/server/_chunks/_libs/react.mjs +513 -0
- package/admin-dist/server/_libs/aria-hidden.mjs +122 -0
- package/admin-dist/server/_libs/class-variance-authority.mjs +44 -0
- package/admin-dist/server/_libs/clsx.mjs +16 -0
- package/admin-dist/server/_libs/cmdk.mjs +315 -0
- package/admin-dist/server/_libs/convex.mjs +4841 -0
- package/admin-dist/server/_libs/cookie-es.mjs +58 -0
- package/admin-dist/server/_libs/croner.mjs +1 -0
- package/admin-dist/server/_libs/crossws.mjs +1 -0
- package/admin-dist/server/_libs/date-fns.mjs +1716 -0
- package/admin-dist/server/_libs/detect-node-es.mjs +1 -0
- package/admin-dist/server/_libs/get-nonce.mjs +9 -0
- package/admin-dist/server/_libs/h3-v2.mjs +277 -0
- package/admin-dist/server/_libs/h3.mjs +401 -0
- package/admin-dist/server/_libs/hookable.mjs +1 -0
- package/admin-dist/server/_libs/isbot.mjs +20 -0
- package/admin-dist/server/_libs/lucide-react.mjs +850 -0
- package/admin-dist/server/_libs/ohash.mjs +1 -0
- package/admin-dist/server/_libs/react-day-picker.mjs +2201 -0
- package/admin-dist/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/admin-dist/server/_libs/react-remove-scroll.mjs +328 -0
- package/admin-dist/server/_libs/react-style-singleton.mjs +69 -0
- package/admin-dist/server/_libs/rou3.mjs +8 -0
- package/admin-dist/server/_libs/seroval-plugins.mjs +58 -0
- package/admin-dist/server/_libs/seroval.mjs +1765 -0
- package/admin-dist/server/_libs/srvx.mjs +719 -0
- package/admin-dist/server/_libs/tailwind-merge.mjs +3010 -0
- package/admin-dist/server/_libs/tiny-invariant.mjs +12 -0
- package/admin-dist/server/_libs/tiny-warning.mjs +5 -0
- package/admin-dist/server/_libs/tslib.mjs +39 -0
- package/admin-dist/server/_libs/ufo.mjs +54 -0
- package/admin-dist/server/_libs/unctx.mjs +1 -0
- package/admin-dist/server/_libs/unstorage.mjs +1 -0
- package/admin-dist/server/_libs/use-callback-ref.mjs +66 -0
- package/admin-dist/server/_libs/use-sidecar.mjs +106 -0
- package/admin-dist/server/_libs/use-sync-external-store.mjs +139 -0
- package/admin-dist/server/_libs/zod.mjs +4223 -0
- package/admin-dist/server/_ssr/CmsEmptyState-DU7-7-mV.mjs +290 -0
- package/admin-dist/server/_ssr/CmsPageHeader-CseW0AHm.mjs +24 -0
- package/admin-dist/server/_ssr/CmsStatusBadge-B_pi4KCp.mjs +127 -0
- package/admin-dist/server/_ssr/CmsToolbar-X75ex6ek.mjs +49 -0
- package/admin-dist/server/_ssr/ContentEntryEditor-CepusRsA.mjs +3720 -0
- package/admin-dist/server/_ssr/ErrorState-cI-bKLez.mjs +89 -0
- package/admin-dist/server/_ssr/TaxonomyFilter-Bwrq0-cz.mjs +188 -0
- package/admin-dist/server/_ssr/_contentTypeId-BqYKEcLr.mjs +379 -0
- package/admin-dist/server/_ssr/_entryId-CRfnqeDf.mjs +161 -0
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BwDlABVk.mjs +4 -0
- package/admin-dist/server/_ssr/alert-CVt45UUP.mjs +92 -0
- package/admin-dist/server/_ssr/badge-6BsP37vG.mjs +125 -0
- package/admin-dist/server/_ssr/command-fy8epIKf.mjs +128 -0
- package/admin-dist/server/_ssr/config.server-D7JHDcDv.mjs +117 -0
- package/admin-dist/server/_ssr/content-B5RhL7uW.mjs +532 -0
- package/admin-dist/server/_ssr/content-types-BIOqCQYN.mjs +1166 -0
- package/admin-dist/server/_ssr/index-DHSHDPt1.mjs +193 -0
- package/admin-dist/server/_ssr/index.mjs +1275 -0
- package/admin-dist/server/_ssr/label-C8Dko1j7.mjs +22 -0
- package/admin-dist/server/_ssr/media-CSx3XttC.mjs +1832 -0
- package/admin-dist/server/_ssr/new._contentTypeId-DzanEZQM.mjs +144 -0
- package/admin-dist/server/_ssr/router-DDWcF-kt.mjs +1556 -0
- package/admin-dist/server/_ssr/scroll-area-bjPYwhXN.mjs +59 -0
- package/admin-dist/server/_ssr/select-BUhDDf4T.mjs +142 -0
- package/admin-dist/server/_ssr/settings-DAsxnw2q.mjs +348 -0
- package/admin-dist/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/admin-dist/server/_ssr/switch-BgyRtQ1Z.mjs +31 -0
- package/admin-dist/server/_ssr/tabs-DzMdRB1A.mjs +628 -0
- package/admin-dist/server/_ssr/taxonomies-C8j8g5Q5.mjs +915 -0
- package/admin-dist/server/_ssr/textarea-9jNeYJSc.mjs +18 -0
- package/admin-dist/server/_ssr/trash-DYMxwhZB.mjs +291 -0
- package/admin-dist/server/_ssr/useBreadcrumbLabel-FNSAr2Ha.mjs +16 -0
- package/admin-dist/server/_ssr/usePermissions-BJGGahrJ.mjs +68 -0
- package/admin-dist/server/favicon.ico +0 -0
- package/admin-dist/server/index.mjs +627 -0
- package/dist/cli/index.js +0 -0
- package/dist/client/admin-config.d.ts +0 -1
- package/dist/client/admin-config.d.ts.map +1 -1
- package/dist/client/admin-config.js +0 -1
- package/dist/client/admin-config.js.map +1 -1
- package/dist/client/adminApi.d.ts.map +1 -1
- package/dist/client/agentTools.d.ts +1237 -135
- package/dist/client/agentTools.d.ts.map +1 -1
- package/dist/client/agentTools.js +33 -9
- package/dist/client/agentTools.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +9 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/mediaAssets.d.ts +35 -0
- package/dist/component/mediaAssets.d.ts.map +1 -1
- package/dist/component/mediaAssets.js +81 -0
- package/dist/component/mediaAssets.js.map +1 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +2 -1
- package/dist/test.js.map +1 -1
- package/package.json +24 -9
- package/dist/component/auditLog.d.ts +0 -410
- package/dist/component/auditLog.d.ts.map +0 -1
- package/dist/component/auditLog.js +0 -607
- package/dist/component/auditLog.js.map +0 -1
- package/dist/component/types.d.ts +0 -4
- package/dist/component/types.d.ts.map +0 -1
- package/dist/component/types.js +0 -2
- package/dist/component/types.js.map +0 -1
- package/src/cli/commands/admin.ts +0 -104
- package/src/cli/index.ts +0 -21
- package/src/cli/utils/detectConvexUrl.ts +0 -54
- package/src/cli/utils/openBrowser.ts +0 -16
- package/src/client/admin-config.ts +0 -138
- package/src/client/adminApi.ts +0 -942
- package/src/client/agentTools.ts +0 -1311
- package/src/client/argTypes.ts +0 -316
- package/src/client/field-types.ts +0 -187
- package/src/client/index.ts +0 -1301
- package/src/client/queryBuilder.ts +0 -1100
- package/src/client/schema/codegen.ts +0 -500
- package/src/client/schema/defineContentType.ts +0 -501
- package/src/client/schema/index.ts +0 -169
- package/src/client/schema/schemaDrift.ts +0 -574
- package/src/client/schema/typedClient.ts +0 -688
- package/src/client/schema/types.ts +0 -666
- package/src/client/types.ts +0 -723
- package/src/client/workflows.ts +0 -141
- package/src/client/wrapper.ts +0 -4304
- package/src/component/_generated/api.ts +0 -140
- package/src/component/_generated/component.ts +0 -5029
- package/src/component/_generated/dataModel.ts +0 -60
- package/src/component/_generated/server.ts +0 -156
- package/src/component/authorization.ts +0 -647
- package/src/component/authorizationHooks.ts +0 -668
- package/src/component/bulkOperations.ts +0 -687
- package/src/component/contentEntries.ts +0 -1976
- package/src/component/contentEntryMutations.ts +0 -1223
- package/src/component/contentEntryValidation.ts +0 -707
- package/src/component/contentLock.ts +0 -550
- package/src/component/contentTypeMigration.ts +0 -1064
- package/src/component/contentTypeMutations.ts +0 -969
- package/src/component/contentTypes.ts +0 -346
- package/src/component/convex.config.ts +0 -44
- package/src/component/documentTypes.ts +0 -240
- package/src/component/eventEmitter.ts +0 -485
- package/src/component/exportImport.ts +0 -1169
- package/src/component/index.ts +0 -491
- package/src/component/lib/deepReferenceResolver.ts +0 -999
- package/src/component/lib/errors.ts +0 -816
- package/src/component/lib/index.ts +0 -145
- package/src/component/lib/mediaReferenceResolver.ts +0 -495
- package/src/component/lib/metadataExtractor.ts +0 -792
- package/src/component/lib/mutationAuth.ts +0 -199
- package/src/component/lib/queries.ts +0 -79
- package/src/component/lib/ragContentChunker.ts +0 -1371
- package/src/component/lib/referenceResolver.ts +0 -430
- package/src/component/lib/slugGenerator.ts +0 -262
- package/src/component/lib/slugUniqueness.ts +0 -333
- package/src/component/lib/softDelete.ts +0 -44
- package/src/component/localeFallbackChain.ts +0 -673
- package/src/component/localeFields.ts +0 -896
- package/src/component/mediaAssetMutations.ts +0 -725
- package/src/component/mediaAssets.ts +0 -932
- package/src/component/mediaFolderMutations.ts +0 -1046
- package/src/component/mediaUploadMutations.ts +0 -224
- package/src/component/mediaVariantMutations.ts +0 -900
- package/src/component/mediaVariants.ts +0 -793
- package/src/component/ragContentIndexer.ts +0 -1067
- package/src/component/rateLimitHooks.ts +0 -572
- package/src/component/roles.ts +0 -1360
- package/src/component/scheduledPublish.ts +0 -358
- package/src/component/schema.ts +0 -617
- package/src/component/taxonomies.ts +0 -949
- package/src/component/taxonomyMutations.ts +0 -1210
- package/src/component/trash.ts +0 -724
- package/src/component/userContext.ts +0 -898
- package/src/component/validation.ts +0 -1388
- package/src/component/validators.ts +0 -949
- package/src/component/versionMutations.ts +0 -392
- package/src/component/webhookTrigger.ts +0 -1922
- package/src/react/index.ts +0 -898
- package/src/test.ts +0 -1580
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../_chunks/_libs/react.mjs";
|
|
2
|
+
import { L as Link } from "../_chunks/_libs/@tanstack/react-router.mjs";
|
|
3
|
+
import { a as api, c as cn } from "./router-DDWcF-kt.mjs";
|
|
4
|
+
import { I as Input, a as Checkbox, C as CmsEmptyState, c as CmsDialog } from "./CmsEmptyState-DU7-7-mV.mjs";
|
|
5
|
+
import { C as CmsButton, B as Badge } from "./badge-6BsP37vG.mjs";
|
|
6
|
+
import { L as Label } from "./label-C8Dko1j7.mjs";
|
|
7
|
+
import { T as Textarea } from "./textarea-9jNeYJSc.mjs";
|
|
8
|
+
import { S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem } from "./select-BUhDDf4T.mjs";
|
|
9
|
+
import { E as ErrorState, a as ErrorAlert } from "./ErrorState-cI-bKLez.mjs";
|
|
10
|
+
import { C as CmsPageHeader } from "./CmsPageHeader-CseW0AHm.mjs";
|
|
11
|
+
import { C as CmsToolbar } from "./CmsToolbar-X75ex6ek.mjs";
|
|
12
|
+
import { u as useQuery, d as useMutation } from "../_libs/convex.mjs";
|
|
13
|
+
import { ad as Grid3x3, ae as List, Q as Plus, N as Search, af as FileType, W as Pencil, ag as TextAlignStart, ah as FolderOpen, V as Tag, d as ChevronDown, p as Braces, I as Image, a8 as Link2, u as Calendar, T as ToggleLeft, r as Hash, ai as ChevronUp, X, O as TriangleAlert } from "../_libs/lucide-react.mjs";
|
|
14
|
+
import "../_libs/tiny-warning.mjs";
|
|
15
|
+
import "../_chunks/_libs/@tanstack/router-core.mjs";
|
|
16
|
+
import "../_libs/cookie-es.mjs";
|
|
17
|
+
import "../_chunks/_libs/@tanstack/store.mjs";
|
|
18
|
+
import "../_chunks/_libs/@tanstack/history.mjs";
|
|
19
|
+
import "../_libs/tiny-invariant.mjs";
|
|
20
|
+
import "../_libs/seroval.mjs";
|
|
21
|
+
import "../_libs/seroval-plugins.mjs";
|
|
22
|
+
import "node:stream/web";
|
|
23
|
+
import "node:stream";
|
|
24
|
+
import "../_chunks/_libs/react-dom.mjs";
|
|
25
|
+
import "util";
|
|
26
|
+
import "crypto";
|
|
27
|
+
import "async_hooks";
|
|
28
|
+
import "stream";
|
|
29
|
+
import "../_libs/isbot.mjs";
|
|
30
|
+
import "../_chunks/_libs/@tanstack/react-store.mjs";
|
|
31
|
+
import "../_libs/use-sync-external-store.mjs";
|
|
32
|
+
import "../_libs/clsx.mjs";
|
|
33
|
+
import "../_libs/tailwind-merge.mjs";
|
|
34
|
+
import "../_chunks/_libs/@radix-ui/react-slot.mjs";
|
|
35
|
+
import "../_chunks/_libs/@radix-ui/react-compose-refs.mjs";
|
|
36
|
+
import "../_chunks/_libs/@radix-ui/react-dropdown-menu.mjs";
|
|
37
|
+
import "../_chunks/_libs/@radix-ui/primitive.mjs";
|
|
38
|
+
import "../_chunks/_libs/@radix-ui/react-context.mjs";
|
|
39
|
+
import "../_chunks/_libs/@radix-ui/react-use-controllable-state.mjs";
|
|
40
|
+
import "../_chunks/_libs/@radix-ui/react-use-layout-effect.mjs";
|
|
41
|
+
import "../_chunks/_libs/@radix-ui/react-primitive.mjs";
|
|
42
|
+
import "../_chunks/_libs/@radix-ui/react-menu.mjs";
|
|
43
|
+
import "../_chunks/_libs/@radix-ui/react-collection.mjs";
|
|
44
|
+
import "../_chunks/_libs/@radix-ui/react-direction.mjs";
|
|
45
|
+
import "../_chunks/_libs/@radix-ui/react-dismissable-layer.mjs";
|
|
46
|
+
import "../_chunks/_libs/@radix-ui/react-use-callback-ref.mjs";
|
|
47
|
+
import "../_chunks/_libs/@radix-ui/react-use-escape-keydown.mjs";
|
|
48
|
+
import "../_chunks/_libs/@radix-ui/react-focus-guards.mjs";
|
|
49
|
+
import "../_chunks/_libs/@radix-ui/react-focus-scope.mjs";
|
|
50
|
+
import "../_chunks/_libs/@radix-ui/react-popper.mjs";
|
|
51
|
+
import "../_chunks/_libs/@floating-ui/react-dom.mjs";
|
|
52
|
+
import "../_chunks/_libs/@floating-ui/dom.mjs";
|
|
53
|
+
import "../_chunks/_libs/@floating-ui/core.mjs";
|
|
54
|
+
import "../_chunks/_libs/@floating-ui/utils.mjs";
|
|
55
|
+
import "../_chunks/_libs/@radix-ui/react-arrow.mjs";
|
|
56
|
+
import "../_chunks/_libs/@radix-ui/react-use-size.mjs";
|
|
57
|
+
import "../_chunks/_libs/@radix-ui/react-portal.mjs";
|
|
58
|
+
import "../_chunks/_libs/@radix-ui/react-presence.mjs";
|
|
59
|
+
import "../_chunks/_libs/@radix-ui/react-roving-focus.mjs";
|
|
60
|
+
import "../_chunks/_libs/@radix-ui/react-id.mjs";
|
|
61
|
+
import "../_libs/aria-hidden.mjs";
|
|
62
|
+
import "../_libs/react-remove-scroll.mjs";
|
|
63
|
+
import "../_libs/tslib.mjs";
|
|
64
|
+
import "../_libs/react-remove-scroll-bar.mjs";
|
|
65
|
+
import "../_libs/react-style-singleton.mjs";
|
|
66
|
+
import "../_libs/get-nonce.mjs";
|
|
67
|
+
import "../_libs/use-sidecar.mjs";
|
|
68
|
+
import "../_libs/use-callback-ref.mjs";
|
|
69
|
+
import "../_chunks/_libs/@radix-ui/react-avatar.mjs";
|
|
70
|
+
import "../_chunks/_libs/@radix-ui/react-use-is-hydrated.mjs";
|
|
71
|
+
import "../_libs/class-variance-authority.mjs";
|
|
72
|
+
import "../_chunks/_libs/@radix-ui/react-popover.mjs";
|
|
73
|
+
import "./index.mjs";
|
|
74
|
+
import "node:async_hooks";
|
|
75
|
+
import "../_libs/h3-v2.mjs";
|
|
76
|
+
import "../_libs/rou3.mjs";
|
|
77
|
+
import "../_libs/srvx.mjs";
|
|
78
|
+
import "node:http";
|
|
79
|
+
import "node:https";
|
|
80
|
+
import "node:http2";
|
|
81
|
+
import "../_libs/zod.mjs";
|
|
82
|
+
import "../_chunks/_libs/@radix-ui/react-dialog.mjs";
|
|
83
|
+
import "../_chunks/_libs/@radix-ui/react-checkbox.mjs";
|
|
84
|
+
import "../_chunks/_libs/@radix-ui/react-use-previous.mjs";
|
|
85
|
+
import "../_chunks/_libs/@radix-ui/react-label.mjs";
|
|
86
|
+
import "../_chunks/_libs/@radix-ui/react-select.mjs";
|
|
87
|
+
import "../_chunks/_libs/@radix-ui/number.mjs";
|
|
88
|
+
import "../_chunks/_libs/@radix-ui/react-visually-hidden.mjs";
|
|
89
|
+
function BreakingChangesWarningDialog({
|
|
90
|
+
isOpen,
|
|
91
|
+
onClose,
|
|
92
|
+
breakingChanges,
|
|
93
|
+
onForceUpdate,
|
|
94
|
+
onCancel,
|
|
95
|
+
isLoading
|
|
96
|
+
}) {
|
|
97
|
+
const handleCancel = () => {
|
|
98
|
+
onCancel();
|
|
99
|
+
onClose();
|
|
100
|
+
};
|
|
101
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
102
|
+
CmsDialog,
|
|
103
|
+
{
|
|
104
|
+
open: isOpen,
|
|
105
|
+
onOpenChange: (open) => !open && !isLoading && handleCancel(),
|
|
106
|
+
title: "Breaking Changes Detected",
|
|
107
|
+
size: "lg",
|
|
108
|
+
footer: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "outline", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
|
|
110
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "danger", onClick: onForceUpdate, loading: isLoading, children: "Force Update" })
|
|
111
|
+
] }),
|
|
112
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 p-3", children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TriangleAlert, { className: "mt-0.5 size-5 shrink-0 text-amber-600" }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
|
|
116
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-amber-800", children: "These changes may affect existing content" }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-amber-700", children: "The following changes could cause data loss or validation errors for existing entries. Review carefully before proceeding." })
|
|
118
|
+
] })
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
121
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-sm font-medium text-foreground", children: [
|
|
122
|
+
breakingChanges.length,
|
|
123
|
+
" breaking change",
|
|
124
|
+
breakingChanges.length !== 1 ? "s" : "",
|
|
125
|
+
" detected:"
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "space-y-2", children: breakingChanges.map((change, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
128
|
+
"li",
|
|
129
|
+
{
|
|
130
|
+
className: "flex items-start gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mt-0.5 size-1.5 shrink-0 rounded-full bg-amber-500" }),
|
|
133
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: change })
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
index
|
|
137
|
+
)) })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: 'Click "Force Update" to apply these changes anyway, or "Cancel" to go back and modify your changes.' })
|
|
140
|
+
] })
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
const FIELD_TYPE_INFO = {
|
|
145
|
+
text: {
|
|
146
|
+
label: "Text",
|
|
147
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(TextAlignStart, { className: "size-4" }),
|
|
148
|
+
description: "Single line text input"
|
|
149
|
+
},
|
|
150
|
+
richText: {
|
|
151
|
+
label: "Rich Text",
|
|
152
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FileType, { className: "size-4" }),
|
|
153
|
+
description: "Multi-line formatted text"
|
|
154
|
+
},
|
|
155
|
+
number: {
|
|
156
|
+
label: "Number",
|
|
157
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Hash, { className: "size-4" }),
|
|
158
|
+
description: "Numeric value"
|
|
159
|
+
},
|
|
160
|
+
boolean: {
|
|
161
|
+
label: "Boolean",
|
|
162
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(ToggleLeft, { className: "size-4" }),
|
|
163
|
+
description: "True/false toggle"
|
|
164
|
+
},
|
|
165
|
+
date: {
|
|
166
|
+
label: "Date",
|
|
167
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "size-4" }),
|
|
168
|
+
description: "Date picker"
|
|
169
|
+
},
|
|
170
|
+
datetime: {
|
|
171
|
+
label: "Date & Time",
|
|
172
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "size-4" }),
|
|
173
|
+
description: "Date and time picker"
|
|
174
|
+
},
|
|
175
|
+
reference: {
|
|
176
|
+
label: "Reference",
|
|
177
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Link2, { className: "size-4" }),
|
|
178
|
+
description: "Link to another content entry"
|
|
179
|
+
},
|
|
180
|
+
media: {
|
|
181
|
+
label: "Media",
|
|
182
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "size-4" }),
|
|
183
|
+
description: "Image, video, or file"
|
|
184
|
+
},
|
|
185
|
+
json: {
|
|
186
|
+
label: "JSON",
|
|
187
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Braces, { className: "size-4" }),
|
|
188
|
+
description: "Custom JSON data"
|
|
189
|
+
},
|
|
190
|
+
select: {
|
|
191
|
+
label: "Select",
|
|
192
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "size-4" }),
|
|
193
|
+
description: "Dropdown selection"
|
|
194
|
+
},
|
|
195
|
+
multiSelect: {
|
|
196
|
+
label: "Multi-Select",
|
|
197
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "size-4" }),
|
|
198
|
+
description: "Multiple selections"
|
|
199
|
+
},
|
|
200
|
+
tags: {
|
|
201
|
+
label: "Tags",
|
|
202
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { className: "size-4" }),
|
|
203
|
+
description: "Free-form tag list"
|
|
204
|
+
},
|
|
205
|
+
category: {
|
|
206
|
+
label: "Category",
|
|
207
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FolderOpen, { className: "size-4" }),
|
|
208
|
+
description: "Taxonomy category selection"
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
function generateMachineName(displayName) {
|
|
212
|
+
return displayName.toLowerCase().trim().replace(/[^a-z0-9\s]/g, "").replace(/\s+/g, "_").replace(/^[0-9]/, "_$&").slice(0, 64);
|
|
213
|
+
}
|
|
214
|
+
function isValidMachineName(name) {
|
|
215
|
+
return /^[a-z][a-z0-9_]{0,63}$/.test(name);
|
|
216
|
+
}
|
|
217
|
+
function ContentTypeFormModal({
|
|
218
|
+
isOpen,
|
|
219
|
+
onClose,
|
|
220
|
+
onCreated,
|
|
221
|
+
onUpdated,
|
|
222
|
+
contentType
|
|
223
|
+
}) {
|
|
224
|
+
const isEditing = !!contentType;
|
|
225
|
+
const [displayName, setDisplayName] = reactExports.useState("");
|
|
226
|
+
const [machineName, setMachineName] = reactExports.useState("");
|
|
227
|
+
const [machineNameManuallyEdited, setMachineNameManuallyEdited] = reactExports.useState(
|
|
228
|
+
false
|
|
229
|
+
);
|
|
230
|
+
const [description, setDescription] = reactExports.useState("");
|
|
231
|
+
const [singleton, setSingleton] = reactExports.useState(false);
|
|
232
|
+
const [fields, setFields] = reactExports.useState([
|
|
233
|
+
{ name: "title", label: "Title", type: "text", required: true }
|
|
234
|
+
]);
|
|
235
|
+
const [titleField, setTitleField] = reactExports.useState("title");
|
|
236
|
+
const [slugField, setSlugField] = reactExports.useState("title");
|
|
237
|
+
const [isSubmitting, setIsSubmitting] = reactExports.useState(false);
|
|
238
|
+
const [submitError, setSubmitError] = reactExports.useState(null);
|
|
239
|
+
const [activeFieldIndex, setActiveFieldIndex] = reactExports.useState(null);
|
|
240
|
+
const [showFieldEditor, setShowFieldEditor] = reactExports.useState(false);
|
|
241
|
+
const [breakingChanges, setBreakingChanges] = reactExports.useState([]);
|
|
242
|
+
const [showBreakingWarning, setShowBreakingWarning] = reactExports.useState(false);
|
|
243
|
+
const [isForceUpdating, setIsForceUpdating] = reactExports.useState(false);
|
|
244
|
+
const createContentType = useMutation(api.contentTypes.create);
|
|
245
|
+
const updateContentType = useMutation(api.contentTypes.update);
|
|
246
|
+
reactExports.useEffect(() => {
|
|
247
|
+
if (contentType && isOpen) {
|
|
248
|
+
setDisplayName(contentType.displayName);
|
|
249
|
+
setMachineName(contentType.name);
|
|
250
|
+
setMachineNameManuallyEdited(true);
|
|
251
|
+
setDescription(contentType.description || "");
|
|
252
|
+
setSingleton(contentType.singleton || false);
|
|
253
|
+
setFields(contentType.fields);
|
|
254
|
+
setTitleField(contentType.titleField || "");
|
|
255
|
+
setSlugField(contentType.slugField || "");
|
|
256
|
+
}
|
|
257
|
+
}, [contentType, isOpen]);
|
|
258
|
+
const resetForm = reactExports.useCallback(() => {
|
|
259
|
+
setDisplayName("");
|
|
260
|
+
setMachineName("");
|
|
261
|
+
setMachineNameManuallyEdited(false);
|
|
262
|
+
setDescription("");
|
|
263
|
+
setSingleton(false);
|
|
264
|
+
setFields([
|
|
265
|
+
{ name: "title", label: "Title", type: "text", required: true }
|
|
266
|
+
]);
|
|
267
|
+
setTitleField("title");
|
|
268
|
+
setSlugField("title");
|
|
269
|
+
setIsSubmitting(false);
|
|
270
|
+
setSubmitError(null);
|
|
271
|
+
setActiveFieldIndex(null);
|
|
272
|
+
setShowFieldEditor(false);
|
|
273
|
+
setBreakingChanges([]);
|
|
274
|
+
setShowBreakingWarning(false);
|
|
275
|
+
setIsForceUpdating(false);
|
|
276
|
+
}, []);
|
|
277
|
+
const handleDisplayNameChange = reactExports.useCallback(
|
|
278
|
+
(value) => {
|
|
279
|
+
setDisplayName(value);
|
|
280
|
+
if (!machineNameManuallyEdited) {
|
|
281
|
+
setMachineName(generateMachineName(value));
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
[machineNameManuallyEdited]
|
|
285
|
+
);
|
|
286
|
+
const handleMachineNameChange = reactExports.useCallback((value) => {
|
|
287
|
+
setMachineNameManuallyEdited(true);
|
|
288
|
+
setMachineName(value.toLowerCase().replace(/[^a-z0-9_]/g, ""));
|
|
289
|
+
}, []);
|
|
290
|
+
const addField = reactExports.useCallback(() => {
|
|
291
|
+
const newFieldName = `field_${fields.length + 1}`;
|
|
292
|
+
setFields((prev) => [
|
|
293
|
+
...prev,
|
|
294
|
+
{
|
|
295
|
+
name: newFieldName,
|
|
296
|
+
label: `Field ${prev.length + 1}`,
|
|
297
|
+
type: "text",
|
|
298
|
+
required: false
|
|
299
|
+
}
|
|
300
|
+
]);
|
|
301
|
+
setActiveFieldIndex(fields.length);
|
|
302
|
+
setShowFieldEditor(true);
|
|
303
|
+
}, [fields.length]);
|
|
304
|
+
const removeField = reactExports.useCallback(
|
|
305
|
+
(index) => {
|
|
306
|
+
const fieldToRemove = fields[index];
|
|
307
|
+
setFields((prev) => prev.filter((_, i) => i !== index));
|
|
308
|
+
if (titleField === fieldToRemove.name) {
|
|
309
|
+
const firstTextField = fields.find(
|
|
310
|
+
(f, i) => i !== index && f.type === "text"
|
|
311
|
+
);
|
|
312
|
+
setTitleField(firstTextField?.name || "");
|
|
313
|
+
}
|
|
314
|
+
if (slugField === fieldToRemove.name) {
|
|
315
|
+
const firstTextField = fields.find(
|
|
316
|
+
(f, i) => i !== index && f.type === "text"
|
|
317
|
+
);
|
|
318
|
+
setSlugField(firstTextField?.name || "");
|
|
319
|
+
}
|
|
320
|
+
if (activeFieldIndex === index) {
|
|
321
|
+
setActiveFieldIndex(null);
|
|
322
|
+
setShowFieldEditor(false);
|
|
323
|
+
} else if (activeFieldIndex !== null && activeFieldIndex > index) {
|
|
324
|
+
setActiveFieldIndex(activeFieldIndex - 1);
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
[fields, activeFieldIndex, titleField, slugField]
|
|
328
|
+
);
|
|
329
|
+
const updateField = reactExports.useCallback(
|
|
330
|
+
(index, updates) => {
|
|
331
|
+
setFields(
|
|
332
|
+
(prev) => prev.map(
|
|
333
|
+
(field, i) => i === index ? { ...field, ...updates } : field
|
|
334
|
+
)
|
|
335
|
+
);
|
|
336
|
+
},
|
|
337
|
+
[]
|
|
338
|
+
);
|
|
339
|
+
const moveField = reactExports.useCallback((fromIndex, toIndex) => {
|
|
340
|
+
setFields((prev) => {
|
|
341
|
+
const newFields = [...prev];
|
|
342
|
+
const [movedField] = newFields.splice(fromIndex, 1);
|
|
343
|
+
newFields.splice(toIndex, 0, movedField);
|
|
344
|
+
return newFields;
|
|
345
|
+
});
|
|
346
|
+
setActiveFieldIndex(toIndex);
|
|
347
|
+
}, []);
|
|
348
|
+
const validationErrors = reactExports.useMemo(() => {
|
|
349
|
+
const errors = [];
|
|
350
|
+
if (!displayName.trim()) {
|
|
351
|
+
errors.push("Display name is required");
|
|
352
|
+
}
|
|
353
|
+
if (!machineName.trim()) {
|
|
354
|
+
errors.push("System Name is required");
|
|
355
|
+
} else if (!isValidMachineName(machineName)) {
|
|
356
|
+
errors.push(
|
|
357
|
+
"System Name must start with a letter and contain only lowercase letters, numbers, and underscores"
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (fields.length === 0) {
|
|
361
|
+
errors.push("At least one field is required");
|
|
362
|
+
}
|
|
363
|
+
const fieldNames = fields.map((f) => f.name);
|
|
364
|
+
const duplicates = fieldNames.filter(
|
|
365
|
+
(name, index) => fieldNames.indexOf(name) !== index
|
|
366
|
+
);
|
|
367
|
+
if (duplicates.length > 0) {
|
|
368
|
+
errors.push(
|
|
369
|
+
`Duplicate field names: ${[...new Set(duplicates)].join(", ")}`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
for (const field of fields) {
|
|
373
|
+
if (!field.name.trim()) {
|
|
374
|
+
errors.push(`Field "${field.label}" has an empty name`);
|
|
375
|
+
} else if (!/^[a-z][a-z0-9_]{0,63}$/.test(field.name)) {
|
|
376
|
+
errors.push(`Field "${field.name}" has an invalid name format`);
|
|
377
|
+
}
|
|
378
|
+
if (!field.label.trim()) {
|
|
379
|
+
errors.push(`Field with name "${field.name}" has an empty label`);
|
|
380
|
+
}
|
|
381
|
+
if ((field.type === "select" || field.type === "multiSelect") && (!field.options?.options || field.options.options.length === 0)) {
|
|
382
|
+
errors.push(
|
|
383
|
+
`${field.type} field "${field.label}" requires at least one option`
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return errors;
|
|
388
|
+
}, [displayName, machineName, fields]);
|
|
389
|
+
const textFields = reactExports.useMemo(() => fields.filter((f) => f.type === "text"), [
|
|
390
|
+
fields
|
|
391
|
+
]);
|
|
392
|
+
const parseBreakingChanges = (errorMessage) => {
|
|
393
|
+
const lines = errorMessage.split("\n");
|
|
394
|
+
return lines.filter((line) => line.trim().startsWith("-")).map((line) => line.trim().substring(2));
|
|
395
|
+
};
|
|
396
|
+
const handleSubmit = reactExports.useCallback(
|
|
397
|
+
async (e, force = false) => {
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
if (validationErrors.length > 0) {
|
|
400
|
+
setSubmitError(validationErrors.join(". "));
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
setIsSubmitting(true);
|
|
404
|
+
setSubmitError(null);
|
|
405
|
+
try {
|
|
406
|
+
if (isEditing && contentType) {
|
|
407
|
+
const result = await updateContentType({
|
|
408
|
+
id: contentType._id,
|
|
409
|
+
displayName: displayName.trim(),
|
|
410
|
+
description: description.trim() || void 0,
|
|
411
|
+
fields,
|
|
412
|
+
singleton,
|
|
413
|
+
titleField: titleField || void 0,
|
|
414
|
+
slugField: slugField || void 0,
|
|
415
|
+
force
|
|
416
|
+
});
|
|
417
|
+
onUpdated?.(result);
|
|
418
|
+
resetForm();
|
|
419
|
+
onClose();
|
|
420
|
+
} else {
|
|
421
|
+
const result = await createContentType({
|
|
422
|
+
name: machineName,
|
|
423
|
+
displayName: displayName.trim(),
|
|
424
|
+
description: description.trim() || void 0,
|
|
425
|
+
fields,
|
|
426
|
+
singleton,
|
|
427
|
+
titleField: titleField || void 0,
|
|
428
|
+
slugField: slugField || void 0
|
|
429
|
+
});
|
|
430
|
+
onCreated?.(result);
|
|
431
|
+
resetForm();
|
|
432
|
+
onClose();
|
|
433
|
+
}
|
|
434
|
+
} catch (error) {
|
|
435
|
+
const message = error instanceof Error ? error.message : isEditing ? "Failed to update content type" : "Failed to create content type";
|
|
436
|
+
if (isEditing && !force && message.includes("breaking change")) {
|
|
437
|
+
const changes = parseBreakingChanges(message);
|
|
438
|
+
setBreakingChanges(changes);
|
|
439
|
+
setShowBreakingWarning(true);
|
|
440
|
+
} else {
|
|
441
|
+
setSubmitError(message);
|
|
442
|
+
}
|
|
443
|
+
} finally {
|
|
444
|
+
setIsSubmitting(false);
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
[
|
|
448
|
+
validationErrors,
|
|
449
|
+
isEditing,
|
|
450
|
+
contentType,
|
|
451
|
+
createContentType,
|
|
452
|
+
updateContentType,
|
|
453
|
+
machineName,
|
|
454
|
+
displayName,
|
|
455
|
+
description,
|
|
456
|
+
fields,
|
|
457
|
+
singleton,
|
|
458
|
+
titleField,
|
|
459
|
+
slugField,
|
|
460
|
+
onCreated,
|
|
461
|
+
onUpdated,
|
|
462
|
+
resetForm,
|
|
463
|
+
onClose
|
|
464
|
+
]
|
|
465
|
+
);
|
|
466
|
+
const handleForceUpdate = reactExports.useCallback(async () => {
|
|
467
|
+
setIsForceUpdating(true);
|
|
468
|
+
try {
|
|
469
|
+
if (contentType) {
|
|
470
|
+
const result = await updateContentType({
|
|
471
|
+
id: contentType._id,
|
|
472
|
+
displayName: displayName.trim(),
|
|
473
|
+
description: description.trim() || void 0,
|
|
474
|
+
fields,
|
|
475
|
+
singleton,
|
|
476
|
+
titleField: titleField || void 0,
|
|
477
|
+
slugField: slugField || void 0,
|
|
478
|
+
force: true
|
|
479
|
+
});
|
|
480
|
+
onUpdated?.(result);
|
|
481
|
+
resetForm();
|
|
482
|
+
setShowBreakingWarning(false);
|
|
483
|
+
onClose();
|
|
484
|
+
}
|
|
485
|
+
} catch (error) {
|
|
486
|
+
const message = error instanceof Error ? error.message : "Failed to update content type";
|
|
487
|
+
setSubmitError(message);
|
|
488
|
+
setShowBreakingWarning(false);
|
|
489
|
+
} finally {
|
|
490
|
+
setIsForceUpdating(false);
|
|
491
|
+
}
|
|
492
|
+
}, [
|
|
493
|
+
contentType,
|
|
494
|
+
updateContentType,
|
|
495
|
+
displayName,
|
|
496
|
+
description,
|
|
497
|
+
fields,
|
|
498
|
+
singleton,
|
|
499
|
+
titleField,
|
|
500
|
+
slugField,
|
|
501
|
+
onUpdated,
|
|
502
|
+
resetForm,
|
|
503
|
+
onClose
|
|
504
|
+
]);
|
|
505
|
+
const handleClose = reactExports.useCallback(() => {
|
|
506
|
+
if (isSubmitting) return;
|
|
507
|
+
resetForm();
|
|
508
|
+
onClose();
|
|
509
|
+
}, [isSubmitting, resetForm, onClose]);
|
|
510
|
+
if (!isOpen) return null;
|
|
511
|
+
const activeField = activeFieldIndex !== null ? fields[activeFieldIndex] : null;
|
|
512
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
513
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
514
|
+
CmsDialog,
|
|
515
|
+
{
|
|
516
|
+
open: isOpen,
|
|
517
|
+
onOpenChange: (open) => !open && handleClose(),
|
|
518
|
+
title: isEditing ? "Edit Content Type" : "Create Content Type",
|
|
519
|
+
size: "2xl",
|
|
520
|
+
footer: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
521
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
522
|
+
CmsButton,
|
|
523
|
+
{
|
|
524
|
+
variant: "outline",
|
|
525
|
+
onClick: handleClose,
|
|
526
|
+
disabled: isSubmitting,
|
|
527
|
+
children: "Cancel"
|
|
528
|
+
}
|
|
529
|
+
),
|
|
530
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
531
|
+
CmsButton,
|
|
532
|
+
{
|
|
533
|
+
variant: "primary",
|
|
534
|
+
onClick: handleSubmit,
|
|
535
|
+
disabled: validationErrors.length > 0,
|
|
536
|
+
loading: isSubmitting,
|
|
537
|
+
"data-testid": isEditing ? "update-content-type-submit" : "create-content-type-submit",
|
|
538
|
+
children: isEditing ? "Save Changes" : "Create Content Type"
|
|
539
|
+
}
|
|
540
|
+
)
|
|
541
|
+
] }),
|
|
542
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [
|
|
543
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
544
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-foreground", children: "Basic Information" }),
|
|
545
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
546
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "displayName", children: [
|
|
547
|
+
"Display Name ",
|
|
548
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
549
|
+
] }),
|
|
550
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
551
|
+
Input,
|
|
552
|
+
{
|
|
553
|
+
id: "displayName",
|
|
554
|
+
value: displayName,
|
|
555
|
+
onChange: (e) => handleDisplayNameChange(e.target.value),
|
|
556
|
+
placeholder: "e.g., Blog Post",
|
|
557
|
+
disabled: isSubmitting,
|
|
558
|
+
autoFocus: true,
|
|
559
|
+
"data-testid": "display-name-input"
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
] }),
|
|
563
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
564
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "machineName", children: [
|
|
565
|
+
"System Name ",
|
|
566
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
567
|
+
] }),
|
|
568
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
569
|
+
Input,
|
|
570
|
+
{
|
|
571
|
+
id: "machineName",
|
|
572
|
+
value: machineName,
|
|
573
|
+
onChange: (e) => handleMachineNameChange(e.target.value),
|
|
574
|
+
placeholder: "e.g., blog_post",
|
|
575
|
+
disabled: isSubmitting || isEditing,
|
|
576
|
+
className: cn(
|
|
577
|
+
!isValidMachineName(machineName) && machineName && "border-destructive"
|
|
578
|
+
),
|
|
579
|
+
"data-testid": "machine-name-input"
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: isEditing ? "System name cannot be changed after creation" : "Lowercase letters, numbers, and underscores only. Used in API queries." })
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
585
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "description", children: "Description" }),
|
|
586
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
587
|
+
Textarea,
|
|
588
|
+
{
|
|
589
|
+
id: "description",
|
|
590
|
+
value: description,
|
|
591
|
+
onChange: (e) => setDescription(e.target.value),
|
|
592
|
+
placeholder: "Optional description of this content type",
|
|
593
|
+
disabled: isSubmitting,
|
|
594
|
+
rows: 2
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
] }),
|
|
598
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
599
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
600
|
+
Checkbox,
|
|
601
|
+
{
|
|
602
|
+
id: "singleton",
|
|
603
|
+
checked: singleton,
|
|
604
|
+
onCheckedChange: (checked) => setSingleton(checked),
|
|
605
|
+
disabled: isSubmitting
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "singleton", className: "cursor-pointer", children: "Singleton (only one entry allowed)" })
|
|
609
|
+
] })
|
|
610
|
+
] }),
|
|
611
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
612
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-foreground", children: "Fields" }),
|
|
614
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
615
|
+
CmsButton,
|
|
616
|
+
{
|
|
617
|
+
type: "button",
|
|
618
|
+
variant: "secondary",
|
|
619
|
+
size: "sm",
|
|
620
|
+
onClick: addField,
|
|
621
|
+
disabled: isSubmitting,
|
|
622
|
+
"data-testid": "add-field-button",
|
|
623
|
+
children: [
|
|
624
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-3.5" }),
|
|
625
|
+
"Add Field"
|
|
626
|
+
]
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
] }),
|
|
630
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: fields.map((field, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
631
|
+
"div",
|
|
632
|
+
{
|
|
633
|
+
className: cn(
|
|
634
|
+
"flex cursor-pointer items-center gap-2 rounded-lg border p-2 transition-colors hover:bg-muted/50",
|
|
635
|
+
activeFieldIndex === index && "border-primary bg-primary/5"
|
|
636
|
+
),
|
|
637
|
+
onClick: () => {
|
|
638
|
+
setActiveFieldIndex(index);
|
|
639
|
+
setShowFieldEditor(true);
|
|
640
|
+
},
|
|
641
|
+
"data-testid": `field-item-${index}`,
|
|
642
|
+
children: [
|
|
643
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
644
|
+
index > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
645
|
+
"button",
|
|
646
|
+
{
|
|
647
|
+
type: "button",
|
|
648
|
+
onClick: (e) => {
|
|
649
|
+
e.stopPropagation();
|
|
650
|
+
moveField(index, index - 1);
|
|
651
|
+
},
|
|
652
|
+
className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
653
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronUp, { className: "size-3" })
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
index < fields.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
657
|
+
"button",
|
|
658
|
+
{
|
|
659
|
+
type: "button",
|
|
660
|
+
onClick: (e) => {
|
|
661
|
+
e.stopPropagation();
|
|
662
|
+
moveField(index, index + 1);
|
|
663
|
+
},
|
|
664
|
+
className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
665
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "size-3" })
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
] }),
|
|
669
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex size-8 items-center justify-center rounded bg-muted text-muted-foreground", children: FIELD_TYPE_INFO[field.type].icon }),
|
|
670
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
671
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-sm font-medium", children: field.label }),
|
|
672
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
673
|
+
FIELD_TYPE_INFO[field.type].label,
|
|
674
|
+
field.required && " *"
|
|
675
|
+
] })
|
|
676
|
+
] }),
|
|
677
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
678
|
+
"button",
|
|
679
|
+
{
|
|
680
|
+
type: "button",
|
|
681
|
+
onClick: (e) => {
|
|
682
|
+
e.stopPropagation();
|
|
683
|
+
removeField(index);
|
|
684
|
+
},
|
|
685
|
+
disabled: isSubmitting || fields.length === 1,
|
|
686
|
+
className: "rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-50",
|
|
687
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "size-4" })
|
|
688
|
+
}
|
|
689
|
+
)
|
|
690
|
+
]
|
|
691
|
+
},
|
|
692
|
+
index
|
|
693
|
+
)) }),
|
|
694
|
+
showFieldEditor && activeField && activeFieldIndex !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: "rounded-lg border bg-muted/30 p-4",
|
|
698
|
+
"data-testid": "field-editor",
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 flex items-center justify-between", children: [
|
|
701
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("h5", { className: "font-medium", children: [
|
|
702
|
+
"Edit Field: ",
|
|
703
|
+
activeField.label
|
|
704
|
+
] }),
|
|
705
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
706
|
+
"button",
|
|
707
|
+
{
|
|
708
|
+
type: "button",
|
|
709
|
+
onClick: () => {
|
|
710
|
+
setShowFieldEditor(false);
|
|
711
|
+
setActiveFieldIndex(null);
|
|
712
|
+
},
|
|
713
|
+
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
714
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "size-4" })
|
|
715
|
+
}
|
|
716
|
+
)
|
|
717
|
+
] }),
|
|
718
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
719
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
720
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "fieldLabel", children: [
|
|
721
|
+
"Label ",
|
|
722
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
723
|
+
] }),
|
|
724
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
725
|
+
Input,
|
|
726
|
+
{
|
|
727
|
+
id: "fieldLabel",
|
|
728
|
+
value: activeField.label,
|
|
729
|
+
onChange: (e) => updateField(activeFieldIndex, {
|
|
730
|
+
label: e.target.value,
|
|
731
|
+
name: machineNameManuallyEdited ? activeField.name : generateMachineName(e.target.value) || activeField.name
|
|
732
|
+
}),
|
|
733
|
+
disabled: isSubmitting,
|
|
734
|
+
"data-testid": "field-label-input"
|
|
735
|
+
}
|
|
736
|
+
)
|
|
737
|
+
] }),
|
|
738
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
739
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "fieldName", children: [
|
|
740
|
+
"Name ",
|
|
741
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
742
|
+
] }),
|
|
743
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
744
|
+
Input,
|
|
745
|
+
{
|
|
746
|
+
id: "fieldName",
|
|
747
|
+
value: activeField.name,
|
|
748
|
+
onChange: (e) => updateField(activeFieldIndex, {
|
|
749
|
+
name: e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, "")
|
|
750
|
+
}),
|
|
751
|
+
disabled: isSubmitting,
|
|
752
|
+
"data-testid": "field-name-input"
|
|
753
|
+
}
|
|
754
|
+
)
|
|
755
|
+
] }),
|
|
756
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
757
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "fieldType", children: [
|
|
758
|
+
"Type ",
|
|
759
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
760
|
+
] }),
|
|
761
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
762
|
+
Select,
|
|
763
|
+
{
|
|
764
|
+
value: activeField.type,
|
|
765
|
+
onValueChange: (value) => updateField(activeFieldIndex, {
|
|
766
|
+
type: value,
|
|
767
|
+
options: void 0
|
|
768
|
+
}),
|
|
769
|
+
disabled: isSubmitting,
|
|
770
|
+
children: [
|
|
771
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { "data-testid": "field-type-select", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
|
|
772
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { children: Object.entries(FIELD_TYPE_INFO).map(([type, info]) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: type, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
773
|
+
info.icon,
|
|
774
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: info.label }),
|
|
775
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground", children: [
|
|
776
|
+
"- ",
|
|
777
|
+
info.description
|
|
778
|
+
] })
|
|
779
|
+
] }) }, type)) })
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
786
|
+
Checkbox,
|
|
787
|
+
{
|
|
788
|
+
id: "fieldRequired",
|
|
789
|
+
checked: activeField.required,
|
|
790
|
+
onCheckedChange: (checked) => updateField(activeFieldIndex, {
|
|
791
|
+
required: checked
|
|
792
|
+
}),
|
|
793
|
+
disabled: isSubmitting
|
|
794
|
+
}
|
|
795
|
+
),
|
|
796
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "fieldRequired", className: "cursor-pointer", children: "Required" })
|
|
797
|
+
] }),
|
|
798
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
799
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "fieldDescription", children: "Help Text" }),
|
|
800
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
801
|
+
Input,
|
|
802
|
+
{
|
|
803
|
+
id: "fieldDescription",
|
|
804
|
+
value: activeField.description || "",
|
|
805
|
+
onChange: (e) => updateField(activeFieldIndex, {
|
|
806
|
+
description: e.target.value || void 0
|
|
807
|
+
}),
|
|
808
|
+
placeholder: "Help text shown below the field",
|
|
809
|
+
disabled: isSubmitting
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] }),
|
|
813
|
+
(activeField.type === "select" || activeField.type === "multiSelect") && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
814
|
+
SelectOptionsEditor,
|
|
815
|
+
{
|
|
816
|
+
options: activeField.options?.options || [],
|
|
817
|
+
onChange: (options) => updateField(activeFieldIndex, {
|
|
818
|
+
options: { ...activeField.options, options }
|
|
819
|
+
}),
|
|
820
|
+
disabled: isSubmitting
|
|
821
|
+
}
|
|
822
|
+
)
|
|
823
|
+
] })
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
)
|
|
827
|
+
] }),
|
|
828
|
+
textFields.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
829
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-semibold text-foreground", children: "Display Settings" }),
|
|
830
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
831
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "titleField", children: "Title Field" }),
|
|
832
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
833
|
+
Select,
|
|
834
|
+
{
|
|
835
|
+
value: titleField || "none",
|
|
836
|
+
onValueChange: (v) => setTitleField(v === "none" ? "" : v),
|
|
837
|
+
disabled: isSubmitting,
|
|
838
|
+
children: [
|
|
839
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: "None" }) }),
|
|
840
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
|
|
841
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }),
|
|
842
|
+
textFields.map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: field.name, children: field.label }, field.name))
|
|
843
|
+
] })
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Field to display as the entry title in lists" })
|
|
848
|
+
] }),
|
|
849
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
850
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "slugField", children: "Slug Field" }),
|
|
851
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
852
|
+
Select,
|
|
853
|
+
{
|
|
854
|
+
value: slugField || "none",
|
|
855
|
+
onValueChange: (v) => setSlugField(v === "none" ? "" : v),
|
|
856
|
+
disabled: isSubmitting,
|
|
857
|
+
children: [
|
|
858
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: "None (auto-generate)" }) }),
|
|
859
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
|
|
860
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None (auto-generate)" }),
|
|
861
|
+
textFields.map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: field.name, children: field.label }, field.name))
|
|
862
|
+
] })
|
|
863
|
+
]
|
|
864
|
+
}
|
|
865
|
+
),
|
|
866
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Field to use for generating URL-friendly slugs" })
|
|
867
|
+
] })
|
|
868
|
+
] }),
|
|
869
|
+
submitError && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
870
|
+
"div",
|
|
871
|
+
{
|
|
872
|
+
className: "rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",
|
|
873
|
+
role: "alert",
|
|
874
|
+
"data-testid": "submit-error",
|
|
875
|
+
children: submitError
|
|
876
|
+
}
|
|
877
|
+
)
|
|
878
|
+
] })
|
|
879
|
+
}
|
|
880
|
+
),
|
|
881
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
882
|
+
BreakingChangesWarningDialog,
|
|
883
|
+
{
|
|
884
|
+
isOpen: showBreakingWarning,
|
|
885
|
+
onClose: () => setShowBreakingWarning(false),
|
|
886
|
+
breakingChanges,
|
|
887
|
+
onForceUpdate: handleForceUpdate,
|
|
888
|
+
onCancel: () => {
|
|
889
|
+
setShowBreakingWarning(false);
|
|
890
|
+
setBreakingChanges([]);
|
|
891
|
+
},
|
|
892
|
+
isLoading: isForceUpdating
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
] });
|
|
896
|
+
}
|
|
897
|
+
function SelectOptionsEditor({
|
|
898
|
+
options,
|
|
899
|
+
onChange,
|
|
900
|
+
disabled
|
|
901
|
+
}) {
|
|
902
|
+
const addOption = () => {
|
|
903
|
+
onChange([
|
|
904
|
+
...options,
|
|
905
|
+
{ value: `option_${options.length + 1}`, label: "" }
|
|
906
|
+
]);
|
|
907
|
+
};
|
|
908
|
+
const removeOption = (index) => {
|
|
909
|
+
onChange(options.filter((_, i) => i !== index));
|
|
910
|
+
};
|
|
911
|
+
const updateOption = (index, updates) => {
|
|
912
|
+
onChange(
|
|
913
|
+
options.map((opt, i) => i === index ? { ...opt, ...updates } : opt)
|
|
914
|
+
);
|
|
915
|
+
};
|
|
916
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
917
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { children: [
|
|
918
|
+
"Options ",
|
|
919
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
920
|
+
] }),
|
|
921
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: options.map((option, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
922
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
923
|
+
Input,
|
|
924
|
+
{
|
|
925
|
+
value: option.label,
|
|
926
|
+
onChange: (e) => {
|
|
927
|
+
const label = e.target.value;
|
|
928
|
+
const value = label.toLowerCase().replace(/[^a-z0-9]/g, "_").replace(/^_+|_+$/g, "");
|
|
929
|
+
updateOption(index, { label, value });
|
|
930
|
+
},
|
|
931
|
+
placeholder: "Option label",
|
|
932
|
+
disabled,
|
|
933
|
+
className: "flex-1"
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
937
|
+
Input,
|
|
938
|
+
{
|
|
939
|
+
value: option.value,
|
|
940
|
+
onChange: (e) => updateOption(index, {
|
|
941
|
+
value: e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, "")
|
|
942
|
+
}),
|
|
943
|
+
placeholder: "value",
|
|
944
|
+
disabled,
|
|
945
|
+
className: "w-32"
|
|
946
|
+
}
|
|
947
|
+
),
|
|
948
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
949
|
+
"button",
|
|
950
|
+
{
|
|
951
|
+
type: "button",
|
|
952
|
+
onClick: () => removeOption(index),
|
|
953
|
+
disabled,
|
|
954
|
+
className: "rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",
|
|
955
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "size-4" })
|
|
956
|
+
}
|
|
957
|
+
)
|
|
958
|
+
] }, index)) }),
|
|
959
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
960
|
+
CmsButton,
|
|
961
|
+
{
|
|
962
|
+
type: "button",
|
|
963
|
+
variant: "secondary",
|
|
964
|
+
size: "sm",
|
|
965
|
+
onClick: addOption,
|
|
966
|
+
disabled,
|
|
967
|
+
children: [
|
|
968
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-3.5" }),
|
|
969
|
+
"Add Option"
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
)
|
|
973
|
+
] });
|
|
974
|
+
}
|
|
975
|
+
const FIELD_ICONS = {
|
|
976
|
+
text: /* @__PURE__ */ jsxRuntimeExports.jsx(TextAlignStart, { className: "size-3" }),
|
|
977
|
+
richText: /* @__PURE__ */ jsxRuntimeExports.jsx(FileType, { className: "size-3" }),
|
|
978
|
+
number: /* @__PURE__ */ jsxRuntimeExports.jsx(Hash, { className: "size-3" }),
|
|
979
|
+
boolean: /* @__PURE__ */ jsxRuntimeExports.jsx(ToggleLeft, { className: "size-3" }),
|
|
980
|
+
date: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "size-3" }),
|
|
981
|
+
datetime: /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "size-3" }),
|
|
982
|
+
reference: /* @__PURE__ */ jsxRuntimeExports.jsx(Link2, { className: "size-3" }),
|
|
983
|
+
media: /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "size-3" }),
|
|
984
|
+
json: /* @__PURE__ */ jsxRuntimeExports.jsx(Braces, { className: "size-3" }),
|
|
985
|
+
select: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "size-3" }),
|
|
986
|
+
multiSelect: /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "size-3" }),
|
|
987
|
+
tags: /* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { className: "size-3" }),
|
|
988
|
+
category: /* @__PURE__ */ jsxRuntimeExports.jsx(FolderOpen, { className: "size-3" })
|
|
989
|
+
};
|
|
990
|
+
function ContentTypesPage() {
|
|
991
|
+
const [searchQuery, setSearchQuery] = reactExports.useState("");
|
|
992
|
+
const [viewMode, setViewMode] = reactExports.useState("grid");
|
|
993
|
+
const [showActiveOnly, setShowActiveOnly] = reactExports.useState(true);
|
|
994
|
+
const [showCreateModal, setShowCreateModal] = reactExports.useState(false);
|
|
995
|
+
const [editingContentType, setEditingContentType] = reactExports.useState(null);
|
|
996
|
+
const [dismissedError, setDismissedError] = reactExports.useState(false);
|
|
997
|
+
const handleContentTypeCreated = reactExports.useCallback(() => {
|
|
998
|
+
setShowCreateModal(false);
|
|
999
|
+
}, []);
|
|
1000
|
+
const handleContentTypeUpdated = reactExports.useCallback(() => {
|
|
1001
|
+
setEditingContentType(null);
|
|
1002
|
+
}, []);
|
|
1003
|
+
const contentTypesResult = useQuery(api.contentTypes.list, {
|
|
1004
|
+
isActive: showActiveOnly ? true : void 0,
|
|
1005
|
+
includeEntryCounts: true
|
|
1006
|
+
});
|
|
1007
|
+
const contentTypes = contentTypesResult?.page ?? [];
|
|
1008
|
+
const isLoading = contentTypesResult === void 0;
|
|
1009
|
+
const error = contentTypesResult?.error;
|
|
1010
|
+
const handleRetry = reactExports.useCallback(() => {
|
|
1011
|
+
setDismissedError(false);
|
|
1012
|
+
window.location.reload();
|
|
1013
|
+
}, []);
|
|
1014
|
+
const filteredContentTypes = reactExports.useMemo(() => {
|
|
1015
|
+
if (!searchQuery.trim()) {
|
|
1016
|
+
return contentTypes;
|
|
1017
|
+
}
|
|
1018
|
+
const query = searchQuery.toLowerCase();
|
|
1019
|
+
return contentTypes.filter((type) => type.name.toLowerCase().includes(query) || type.displayName.toLowerCase().includes(query));
|
|
1020
|
+
}, [contentTypes, searchQuery]);
|
|
1021
|
+
const formatDate = (timestamp) => {
|
|
1022
|
+
return new Date(timestamp).toLocaleDateString("en-US", {
|
|
1023
|
+
year: "numeric",
|
|
1024
|
+
month: "short",
|
|
1025
|
+
day: "numeric"
|
|
1026
|
+
});
|
|
1027
|
+
};
|
|
1028
|
+
const getRelativeTime = (timestamp) => {
|
|
1029
|
+
const now = Date.now();
|
|
1030
|
+
const diff = now - timestamp;
|
|
1031
|
+
const seconds = Math.floor(diff / 1e3);
|
|
1032
|
+
const minutes = Math.floor(seconds / 60);
|
|
1033
|
+
const hours = Math.floor(minutes / 60);
|
|
1034
|
+
const days = Math.floor(hours / 24);
|
|
1035
|
+
if (days > 30) {
|
|
1036
|
+
return formatDate(timestamp);
|
|
1037
|
+
} else if (days > 0) {
|
|
1038
|
+
return `${days}d ago`;
|
|
1039
|
+
} else if (hours > 0) {
|
|
1040
|
+
return `${hours}h ago`;
|
|
1041
|
+
} else if (minutes > 0) {
|
|
1042
|
+
return `${minutes}m ago`;
|
|
1043
|
+
} else {
|
|
1044
|
+
return "Just now";
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
if (error && !isLoading) {
|
|
1048
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6 p-6", children: [
|
|
1049
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsPageHeader, { title: "Content Types", description: "Define the structure of your content with custom fields and validation rules." }),
|
|
1050
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ErrorState, { error, title: "Failed to load content types", onRetry: handleRetry })
|
|
1051
|
+
] });
|
|
1052
|
+
}
|
|
1053
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6 p-6", children: [
|
|
1054
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsPageHeader, { title: "Content Types", description: "Define the structure of your content with custom fields and validation rules." }),
|
|
1055
|
+
error && !dismissedError && /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorAlert, { error, onDismiss: () => setDismissedError(true), onRetry: handleRetry }),
|
|
1056
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsToolbar, { left: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1057
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
|
|
1058
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Search, { className: "absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
1059
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Input, { type: "search", placeholder: "Search content types...", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), className: "w-64 pl-9" })
|
|
1060
|
+
] }),
|
|
1061
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex cursor-pointer items-center gap-2 text-sm", children: [
|
|
1062
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: showActiveOnly, onCheckedChange: (checked) => setShowActiveOnly(checked) }),
|
|
1063
|
+
"Active only"
|
|
1064
|
+
] })
|
|
1065
|
+
] }), right: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1066
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex rounded-md border bg-muted/30", children: [
|
|
1067
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: cn("rounded-l-md p-2 transition-colors", viewMode === "grid" ? "bg-background shadow-sm" : "hover:bg-muted/50"), onClick: () => setViewMode("grid"), title: "Grid view", "aria-label": "Grid view", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grid3x3, { className: "size-4" }) }),
|
|
1068
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: cn("rounded-r-md p-2 transition-colors", viewMode === "list" ? "bg-background shadow-sm" : "hover:bg-muted/50"), onClick: () => setViewMode("list"), title: "List view", "aria-label": "List view", children: /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "size-4" }) })
|
|
1069
|
+
] }),
|
|
1070
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CmsButton, { onClick: () => setShowCreateModal(true), "data-testid": "create-content-type-button", children: [
|
|
1071
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
|
|
1072
|
+
"Create Content Type"
|
|
1073
|
+
] })
|
|
1074
|
+
] }) }),
|
|
1075
|
+
isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-12", children: [
|
|
1076
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "size-8 animate-spin rounded-full border-2 border-muted border-t-primary" }),
|
|
1077
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-4 text-sm text-muted-foreground", children: "Loading content types..." })
|
|
1078
|
+
] }) : filteredContentTypes.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(CmsEmptyState, { icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FileType, { className: "size-6" }), title: searchQuery ? "No content types match your search" : "No content types defined", description: searchQuery ? "Try adjusting your search query or filters." : "Content types define the schema for your content. Create one to get started." }) : viewMode === "grid" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", children: filteredContentTypes.map((contentType) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-col rounded-lg border bg-card p-4 transition-all hover:border-primary/50 hover:shadow-md", children: [
|
|
1079
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
1080
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FileType, { className: "size-5" }) }),
|
|
1081
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1082
|
+
!contentType.isActive && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "secondary", className: "text-xs font-normal", children: "Inactive" }),
|
|
1083
|
+
contentType.singleton && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "secondary", className: "border-amber-200 bg-amber-50 text-xs font-normal text-amber-700", children: "Singleton" }),
|
|
1084
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setEditingContentType(contentType), className: "rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100", title: "Edit content type", "aria-label": "Edit content type", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pencil, { className: "size-4" }) })
|
|
1085
|
+
] })
|
|
1086
|
+
] }),
|
|
1087
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Link, { to: "/entries/type/$contentTypeId", params: {
|
|
1088
|
+
contentTypeId: contentType._id
|
|
1089
|
+
}, className: "flex flex-1 flex-col", children: [
|
|
1090
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-base font-semibold text-foreground", children: contentType.displayName }),
|
|
1091
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: contentType.name }),
|
|
1092
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 flex items-center gap-4", children: [
|
|
1093
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
|
|
1094
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-semibold text-foreground", children: contentType.fields.length }),
|
|
1095
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: contentType.fields.length === 1 ? "Field" : "Fields" })
|
|
1096
|
+
] }),
|
|
1097
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
|
|
1098
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-semibold text-foreground", children: contentType.entryCount ?? 0 }),
|
|
1099
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: contentType.entryCount === 1 ? "Entry" : "Entries" })
|
|
1100
|
+
] })
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 flex flex-wrap gap-1.5", children: [
|
|
1103
|
+
contentType.fields.slice(0, 4).map((field) => /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground", title: field.label, children: [
|
|
1104
|
+
FIELD_ICONS[field.type] || /* @__PURE__ */ jsxRuntimeExports.jsx(TextAlignStart, { className: "size-3" }),
|
|
1105
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate", children: field.label })
|
|
1106
|
+
] }, field.name)),
|
|
1107
|
+
contentType.fields.length > 4 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground", children: [
|
|
1108
|
+
"+",
|
|
1109
|
+
contentType.fields.length - 4,
|
|
1110
|
+
" more"
|
|
1111
|
+
] })
|
|
1112
|
+
] }),
|
|
1113
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "mt-auto pt-3 text-xs text-muted-foreground", children: [
|
|
1114
|
+
"Updated ",
|
|
1115
|
+
getRelativeTime(contentType._creationTime)
|
|
1116
|
+
] })
|
|
1117
|
+
] })
|
|
1118
|
+
] }, contentType._id)) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border bg-card", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full", children: [
|
|
1119
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b", children: [
|
|
1120
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Name" }),
|
|
1121
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Fields" }),
|
|
1122
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Entries" }),
|
|
1123
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Status" }),
|
|
1124
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Last Updated" }),
|
|
1125
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "p-3 text-left text-sm font-medium text-muted-foreground", children: "Actions" })
|
|
1126
|
+
] }) }),
|
|
1127
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: filteredContentTypes.map((contentType) => /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b last:border-0 transition-colors hover:bg-muted/50", children: [
|
|
1128
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: "p-3", children: [
|
|
1129
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-medium text-foreground", children: contentType.displayName }),
|
|
1130
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: contentType.name })
|
|
1131
|
+
] }),
|
|
1132
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "p-3 text-sm text-muted-foreground", children: contentType.fields.length }),
|
|
1133
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "p-3 text-sm text-muted-foreground", children: contentType.entryCount ?? 0 }),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: contentType.isActive ? "default" : "secondary", className: cn("text-xs font-normal", contentType.isActive && "border-emerald-200 bg-emerald-50 text-emerald-700"), children: contentType.isActive ? "Active" : "Inactive" }),
|
|
1136
|
+
contentType.singleton && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "secondary", className: "border-amber-200 bg-amber-50 text-xs font-normal text-amber-700", children: "Singleton" })
|
|
1137
|
+
] }) }),
|
|
1138
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "p-3 text-sm text-muted-foreground", children: formatDate(contentType._creationTime) }),
|
|
1139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1140
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CmsButton, { variant: "outline", size: "sm", onClick: () => setEditingContentType(contentType), children: [
|
|
1141
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Pencil, { className: "size-3.5" }),
|
|
1142
|
+
"Edit"
|
|
1143
|
+
] }),
|
|
1144
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "outline", size: "sm", asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/entries/type/$contentTypeId", params: {
|
|
1145
|
+
contentTypeId: contentType._id
|
|
1146
|
+
}, children: "View Entries" }) })
|
|
1147
|
+
] }) })
|
|
1148
|
+
] }, contentType._id)) })
|
|
1149
|
+
] }) }),
|
|
1150
|
+
!isLoading && filteredContentTypes.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
1151
|
+
"Showing ",
|
|
1152
|
+
filteredContentTypes.length,
|
|
1153
|
+
" of ",
|
|
1154
|
+
contentTypes.length,
|
|
1155
|
+
" content type",
|
|
1156
|
+
contentTypes.length !== 1 ? "s" : ""
|
|
1157
|
+
] }),
|
|
1158
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ContentTypeFormModal, { isOpen: showCreateModal || !!editingContentType, onClose: () => {
|
|
1159
|
+
setShowCreateModal(false);
|
|
1160
|
+
setEditingContentType(null);
|
|
1161
|
+
}, contentType: editingContentType, onCreated: handleContentTypeCreated, onUpdated: handleContentTypeUpdated })
|
|
1162
|
+
] });
|
|
1163
|
+
}
|
|
1164
|
+
export {
|
|
1165
|
+
ContentTypesPage as component
|
|
1166
|
+
};
|