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,915 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../_chunks/_libs/react.mjs";
|
|
2
|
+
import { a as api, c as cn } from "./router-DDWcF-kt.mjs";
|
|
3
|
+
import { C as CmsEmptyState, b as CmsConfirmDialog, c as CmsDialog, I as Input, a as Checkbox } from "./CmsEmptyState-DU7-7-mV.mjs";
|
|
4
|
+
import { C as CmsButton, B as Badge } from "./badge-6BsP37vG.mjs";
|
|
5
|
+
import { L as Label } from "./label-C8Dko1j7.mjs";
|
|
6
|
+
import { T as Textarea } from "./textarea-9jNeYJSc.mjs";
|
|
7
|
+
import { C as CmsPageHeader } from "./CmsPageHeader-CseW0AHm.mjs";
|
|
8
|
+
import { C as CmsSurface, A as Alert, a as AlertDescription } from "./alert-CVt45UUP.mjs";
|
|
9
|
+
import { S as ScrollArea } from "./scroll-area-bjPYwhXN.mjs";
|
|
10
|
+
import { u as useQuery, d as useMutation } from "../_libs/convex.mjs";
|
|
11
|
+
import { Q as Plus, V as Tag, W as Pencil, w as Trash2, O as TriangleAlert, Y as FolderTree, z as Tags, d as ChevronDown, f as ChevronRight } from "../_libs/lucide-react.mjs";
|
|
12
|
+
import "../_chunks/_libs/@tanstack/react-router.mjs";
|
|
13
|
+
import "../_libs/tiny-warning.mjs";
|
|
14
|
+
import "../_chunks/_libs/@tanstack/router-core.mjs";
|
|
15
|
+
import "../_libs/cookie-es.mjs";
|
|
16
|
+
import "../_chunks/_libs/@tanstack/store.mjs";
|
|
17
|
+
import "../_chunks/_libs/@tanstack/history.mjs";
|
|
18
|
+
import "../_libs/tiny-invariant.mjs";
|
|
19
|
+
import "../_libs/seroval.mjs";
|
|
20
|
+
import "../_libs/seroval-plugins.mjs";
|
|
21
|
+
import "node:stream/web";
|
|
22
|
+
import "node:stream";
|
|
23
|
+
import "../_chunks/_libs/react-dom.mjs";
|
|
24
|
+
import "util";
|
|
25
|
+
import "crypto";
|
|
26
|
+
import "async_hooks";
|
|
27
|
+
import "stream";
|
|
28
|
+
import "../_libs/isbot.mjs";
|
|
29
|
+
import "../_chunks/_libs/@tanstack/react-store.mjs";
|
|
30
|
+
import "../_libs/use-sync-external-store.mjs";
|
|
31
|
+
import "../_libs/clsx.mjs";
|
|
32
|
+
import "../_libs/tailwind-merge.mjs";
|
|
33
|
+
import "../_chunks/_libs/@radix-ui/react-slot.mjs";
|
|
34
|
+
import "../_chunks/_libs/@radix-ui/react-compose-refs.mjs";
|
|
35
|
+
import "../_chunks/_libs/@radix-ui/react-dropdown-menu.mjs";
|
|
36
|
+
import "../_chunks/_libs/@radix-ui/primitive.mjs";
|
|
37
|
+
import "../_chunks/_libs/@radix-ui/react-context.mjs";
|
|
38
|
+
import "../_chunks/_libs/@radix-ui/react-use-controllable-state.mjs";
|
|
39
|
+
import "../_chunks/_libs/@radix-ui/react-use-layout-effect.mjs";
|
|
40
|
+
import "../_chunks/_libs/@radix-ui/react-primitive.mjs";
|
|
41
|
+
import "../_chunks/_libs/@radix-ui/react-menu.mjs";
|
|
42
|
+
import "../_chunks/_libs/@radix-ui/react-collection.mjs";
|
|
43
|
+
import "../_chunks/_libs/@radix-ui/react-direction.mjs";
|
|
44
|
+
import "../_chunks/_libs/@radix-ui/react-dismissable-layer.mjs";
|
|
45
|
+
import "../_chunks/_libs/@radix-ui/react-use-callback-ref.mjs";
|
|
46
|
+
import "../_chunks/_libs/@radix-ui/react-use-escape-keydown.mjs";
|
|
47
|
+
import "../_chunks/_libs/@radix-ui/react-focus-guards.mjs";
|
|
48
|
+
import "../_chunks/_libs/@radix-ui/react-focus-scope.mjs";
|
|
49
|
+
import "../_chunks/_libs/@radix-ui/react-popper.mjs";
|
|
50
|
+
import "../_chunks/_libs/@floating-ui/react-dom.mjs";
|
|
51
|
+
import "../_chunks/_libs/@floating-ui/dom.mjs";
|
|
52
|
+
import "../_chunks/_libs/@floating-ui/core.mjs";
|
|
53
|
+
import "../_chunks/_libs/@floating-ui/utils.mjs";
|
|
54
|
+
import "../_chunks/_libs/@radix-ui/react-arrow.mjs";
|
|
55
|
+
import "../_chunks/_libs/@radix-ui/react-use-size.mjs";
|
|
56
|
+
import "../_chunks/_libs/@radix-ui/react-portal.mjs";
|
|
57
|
+
import "../_chunks/_libs/@radix-ui/react-presence.mjs";
|
|
58
|
+
import "../_chunks/_libs/@radix-ui/react-roving-focus.mjs";
|
|
59
|
+
import "../_chunks/_libs/@radix-ui/react-id.mjs";
|
|
60
|
+
import "../_libs/aria-hidden.mjs";
|
|
61
|
+
import "../_libs/react-remove-scroll.mjs";
|
|
62
|
+
import "../_libs/tslib.mjs";
|
|
63
|
+
import "../_libs/react-remove-scroll-bar.mjs";
|
|
64
|
+
import "../_libs/react-style-singleton.mjs";
|
|
65
|
+
import "../_libs/get-nonce.mjs";
|
|
66
|
+
import "../_libs/use-sidecar.mjs";
|
|
67
|
+
import "../_libs/use-callback-ref.mjs";
|
|
68
|
+
import "../_chunks/_libs/@radix-ui/react-avatar.mjs";
|
|
69
|
+
import "../_chunks/_libs/@radix-ui/react-use-is-hydrated.mjs";
|
|
70
|
+
import "../_libs/class-variance-authority.mjs";
|
|
71
|
+
import "../_chunks/_libs/@radix-ui/react-popover.mjs";
|
|
72
|
+
import "./index.mjs";
|
|
73
|
+
import "node:async_hooks";
|
|
74
|
+
import "../_libs/h3-v2.mjs";
|
|
75
|
+
import "../_libs/rou3.mjs";
|
|
76
|
+
import "../_libs/srvx.mjs";
|
|
77
|
+
import "node:http";
|
|
78
|
+
import "node:https";
|
|
79
|
+
import "node:http2";
|
|
80
|
+
import "../_libs/zod.mjs";
|
|
81
|
+
import "../_chunks/_libs/@radix-ui/react-dialog.mjs";
|
|
82
|
+
import "../_chunks/_libs/@radix-ui/react-checkbox.mjs";
|
|
83
|
+
import "../_chunks/_libs/@radix-ui/react-use-previous.mjs";
|
|
84
|
+
import "../_chunks/_libs/@radix-ui/react-label.mjs";
|
|
85
|
+
import "../_chunks/_libs/@radix-ui/react-scroll-area.mjs";
|
|
86
|
+
import "../_chunks/_libs/@radix-ui/number.mjs";
|
|
87
|
+
function TaxonomyEditor({
|
|
88
|
+
taxonomy,
|
|
89
|
+
onSave,
|
|
90
|
+
onCancel
|
|
91
|
+
}) {
|
|
92
|
+
const isEditing = !!taxonomy;
|
|
93
|
+
const [formData, setFormData] = reactExports.useState({
|
|
94
|
+
name: taxonomy?.name ?? "",
|
|
95
|
+
displayName: taxonomy?.displayName ?? "",
|
|
96
|
+
description: taxonomy?.description ?? "",
|
|
97
|
+
isHierarchical: taxonomy?.isHierarchical ?? false,
|
|
98
|
+
allowInlineCreation: taxonomy?.allowInlineCreation ?? true,
|
|
99
|
+
isActive: taxonomy?.isActive ?? true,
|
|
100
|
+
icon: taxonomy?.icon ?? "",
|
|
101
|
+
sortOrder: taxonomy?.sortOrder ?? 0
|
|
102
|
+
});
|
|
103
|
+
const [errors, setErrors] = reactExports.useState({});
|
|
104
|
+
const [isSubmitting, setIsSubmitting] = reactExports.useState(false);
|
|
105
|
+
const [submitError, setSubmitError] = reactExports.useState(null);
|
|
106
|
+
const [slugManuallyEdited, setSlugManuallyEdited] = reactExports.useState(false);
|
|
107
|
+
const createTaxonomy = useMutation(api.taxonomies.createTaxonomy);
|
|
108
|
+
const updateTaxonomy = useMutation(api.taxonomies.updateTaxonomy);
|
|
109
|
+
reactExports.useEffect(() => {
|
|
110
|
+
if (taxonomy) {
|
|
111
|
+
setFormData({
|
|
112
|
+
name: taxonomy.name,
|
|
113
|
+
displayName: taxonomy.displayName,
|
|
114
|
+
description: taxonomy.description ?? "",
|
|
115
|
+
isHierarchical: taxonomy.isHierarchical,
|
|
116
|
+
allowInlineCreation: taxonomy.allowInlineCreation,
|
|
117
|
+
isActive: taxonomy.isActive,
|
|
118
|
+
icon: taxonomy.icon ?? "",
|
|
119
|
+
sortOrder: taxonomy.sortOrder ?? 0
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, [taxonomy]);
|
|
123
|
+
const handleChange = reactExports.useCallback(
|
|
124
|
+
(field, value) => {
|
|
125
|
+
setFormData((prev) => ({ ...prev, [field]: value }));
|
|
126
|
+
setErrors((prev) => {
|
|
127
|
+
const { [field]: _, ...rest } = prev;
|
|
128
|
+
return rest;
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
[]
|
|
132
|
+
);
|
|
133
|
+
const generateSlug = reactExports.useCallback((name) => {
|
|
134
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
135
|
+
}, []);
|
|
136
|
+
const handleDisplayNameChange = reactExports.useCallback(
|
|
137
|
+
(value) => {
|
|
138
|
+
handleChange("displayName", value);
|
|
139
|
+
if (!isEditing && !slugManuallyEdited) {
|
|
140
|
+
handleChange("name", generateSlug(value));
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[handleChange, isEditing, slugManuallyEdited, generateSlug]
|
|
144
|
+
);
|
|
145
|
+
const validate = reactExports.useCallback(() => {
|
|
146
|
+
const newErrors = {};
|
|
147
|
+
if (!formData.name.trim()) {
|
|
148
|
+
newErrors.name = "Slug is required";
|
|
149
|
+
} else if (!/^[a-z][a-z0-9-]*$/.test(formData.name)) {
|
|
150
|
+
newErrors.name = "Slug must start with a letter and contain only lowercase letters, numbers, and hyphens";
|
|
151
|
+
}
|
|
152
|
+
if (!formData.displayName.trim()) {
|
|
153
|
+
newErrors.displayName = "Display name is required";
|
|
154
|
+
}
|
|
155
|
+
setErrors(newErrors);
|
|
156
|
+
return Object.keys(newErrors).length === 0;
|
|
157
|
+
}, [formData]);
|
|
158
|
+
const handleSubmit = reactExports.useCallback(
|
|
159
|
+
async (e) => {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
if (!validate()) return;
|
|
162
|
+
setIsSubmitting(true);
|
|
163
|
+
setSubmitError(null);
|
|
164
|
+
try {
|
|
165
|
+
if (isEditing && taxonomy) {
|
|
166
|
+
await updateTaxonomy({
|
|
167
|
+
id: taxonomy._id,
|
|
168
|
+
displayName: formData.displayName,
|
|
169
|
+
description: formData.description || void 0,
|
|
170
|
+
allowInlineCreation: formData.allowInlineCreation,
|
|
171
|
+
icon: formData.icon || void 0,
|
|
172
|
+
sortOrder: formData.sortOrder,
|
|
173
|
+
isActive: formData.isActive
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
await createTaxonomy({
|
|
177
|
+
name: formData.name,
|
|
178
|
+
displayName: formData.displayName,
|
|
179
|
+
description: formData.description || void 0,
|
|
180
|
+
isHierarchical: formData.isHierarchical,
|
|
181
|
+
allowInlineCreation: formData.allowInlineCreation,
|
|
182
|
+
icon: formData.icon || void 0,
|
|
183
|
+
sortOrder: formData.sortOrder
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
onSave();
|
|
187
|
+
} catch (error) {
|
|
188
|
+
const message = error instanceof Error ? error.message : "Failed to save taxonomy";
|
|
189
|
+
setSubmitError(message);
|
|
190
|
+
} finally {
|
|
191
|
+
setIsSubmitting(false);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
[
|
|
195
|
+
validate,
|
|
196
|
+
isEditing,
|
|
197
|
+
taxonomy,
|
|
198
|
+
formData,
|
|
199
|
+
createTaxonomy,
|
|
200
|
+
updateTaxonomy,
|
|
201
|
+
onSave
|
|
202
|
+
]
|
|
203
|
+
);
|
|
204
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
205
|
+
CmsDialog,
|
|
206
|
+
{
|
|
207
|
+
open: true,
|
|
208
|
+
onOpenChange: (open) => !open && !isSubmitting && onCancel(),
|
|
209
|
+
title: isEditing ? "Edit Taxonomy" : "Create Taxonomy",
|
|
210
|
+
size: "lg",
|
|
211
|
+
footer: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
212
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "outline", onClick: onCancel, disabled: isSubmitting, children: "Cancel" }),
|
|
213
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
214
|
+
CmsButton,
|
|
215
|
+
{
|
|
216
|
+
variant: "primary",
|
|
217
|
+
onClick: handleSubmit,
|
|
218
|
+
loading: isSubmitting,
|
|
219
|
+
children: isEditing ? "Save Changes" : "Create Taxonomy"
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }),
|
|
223
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
224
|
+
submitError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800", children: submitError }),
|
|
225
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
226
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "displayName", children: [
|
|
227
|
+
"Display Name ",
|
|
228
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
229
|
+
] }),
|
|
230
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
231
|
+
Input,
|
|
232
|
+
{
|
|
233
|
+
id: "displayName",
|
|
234
|
+
value: formData.displayName,
|
|
235
|
+
onChange: (e) => handleDisplayNameChange(e.target.value),
|
|
236
|
+
placeholder: "e.g., Categories, Tags",
|
|
237
|
+
disabled: isSubmitting,
|
|
238
|
+
className: errors.displayName ? "border-destructive" : ""
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
errors.displayName && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-destructive", children: errors.displayName })
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
244
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "name", children: [
|
|
245
|
+
"Slug ",
|
|
246
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
247
|
+
] }),
|
|
248
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
249
|
+
Input,
|
|
250
|
+
{
|
|
251
|
+
id: "name",
|
|
252
|
+
value: formData.name,
|
|
253
|
+
onChange: (e) => {
|
|
254
|
+
handleChange("name", e.target.value.toLowerCase());
|
|
255
|
+
setSlugManuallyEdited(true);
|
|
256
|
+
},
|
|
257
|
+
placeholder: "e.g., categories, tags",
|
|
258
|
+
disabled: isSubmitting || isEditing,
|
|
259
|
+
className: errors.name ? "border-destructive" : ""
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
errors.name && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-destructive", children: errors.name }),
|
|
263
|
+
isEditing && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Slug cannot be changed after creation" })
|
|
264
|
+
] }),
|
|
265
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
266
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "description", children: "Description" }),
|
|
267
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
268
|
+
Textarea,
|
|
269
|
+
{
|
|
270
|
+
id: "description",
|
|
271
|
+
value: formData.description,
|
|
272
|
+
onChange: (e) => handleChange("description", e.target.value),
|
|
273
|
+
placeholder: "Optional description",
|
|
274
|
+
rows: 2,
|
|
275
|
+
disabled: isSubmitting
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] }),
|
|
279
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
280
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
281
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "icon", children: "Icon" }),
|
|
282
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
283
|
+
Input,
|
|
284
|
+
{
|
|
285
|
+
id: "icon",
|
|
286
|
+
value: formData.icon,
|
|
287
|
+
onChange: (e) => handleChange("icon", e.target.value),
|
|
288
|
+
placeholder: "e.g., 🏷️ or folder",
|
|
289
|
+
disabled: isSubmitting
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Emoji or icon name" })
|
|
293
|
+
] }),
|
|
294
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
295
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "sortOrder", children: "Sort Order" }),
|
|
296
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
297
|
+
Input,
|
|
298
|
+
{
|
|
299
|
+
id: "sortOrder",
|
|
300
|
+
type: "number",
|
|
301
|
+
value: formData.sortOrder,
|
|
302
|
+
onChange: (e) => handleChange("sortOrder", parseInt(e.target.value) || 0),
|
|
303
|
+
disabled: isSubmitting
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4 pt-2", children: [
|
|
309
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
310
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
311
|
+
Checkbox,
|
|
312
|
+
{
|
|
313
|
+
id: "isHierarchical",
|
|
314
|
+
checked: formData.isHierarchical,
|
|
315
|
+
onCheckedChange: (checked) => handleChange("isHierarchical", checked),
|
|
316
|
+
disabled: isSubmitting || isEditing
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-0.5", children: [
|
|
320
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
321
|
+
Label,
|
|
322
|
+
{
|
|
323
|
+
htmlFor: "isHierarchical",
|
|
324
|
+
className: "cursor-pointer font-medium",
|
|
325
|
+
children: "Hierarchical"
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Terms can have parent-child relationships (like categories)" }),
|
|
329
|
+
isEditing && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-amber-600", children: "Hierarchy type cannot be changed after creation" })
|
|
330
|
+
] })
|
|
331
|
+
] }),
|
|
332
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
333
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
334
|
+
Checkbox,
|
|
335
|
+
{
|
|
336
|
+
id: "allowInlineCreation",
|
|
337
|
+
checked: formData.allowInlineCreation,
|
|
338
|
+
onCheckedChange: (checked) => handleChange("allowInlineCreation", checked),
|
|
339
|
+
disabled: isSubmitting
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-0.5", children: [
|
|
343
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
344
|
+
Label,
|
|
345
|
+
{
|
|
346
|
+
htmlFor: "allowInlineCreation",
|
|
347
|
+
className: "cursor-pointer font-medium",
|
|
348
|
+
children: "Allow inline creation"
|
|
349
|
+
}
|
|
350
|
+
),
|
|
351
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Users can create new terms while editing content" })
|
|
352
|
+
] })
|
|
353
|
+
] }),
|
|
354
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
355
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
356
|
+
Checkbox,
|
|
357
|
+
{
|
|
358
|
+
id: "isActive",
|
|
359
|
+
checked: formData.isActive,
|
|
360
|
+
onCheckedChange: (checked) => handleChange("isActive", checked),
|
|
361
|
+
disabled: isSubmitting
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-0.5", children: [
|
|
365
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "isActive", className: "cursor-pointer font-medium", children: "Active" }),
|
|
366
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "Inactive taxonomies are hidden from content editors" })
|
|
367
|
+
] })
|
|
368
|
+
] })
|
|
369
|
+
] })
|
|
370
|
+
] })
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
function TermTree({
|
|
375
|
+
taxonomyId,
|
|
376
|
+
isHierarchical,
|
|
377
|
+
allowInlineCreation
|
|
378
|
+
}) {
|
|
379
|
+
const [expandedTerms, setExpandedTerms] = reactExports.useState(/* @__PURE__ */ new Set());
|
|
380
|
+
const [editingTerm, setEditingTerm] = reactExports.useState(null);
|
|
381
|
+
const [showCreateModal, setShowCreateModal] = reactExports.useState(false);
|
|
382
|
+
const [parentForNew, setParentForNew] = reactExports.useState();
|
|
383
|
+
const [deleteConfirm, setDeleteConfirm] = reactExports.useState(null);
|
|
384
|
+
const [error, setError] = reactExports.useState(null);
|
|
385
|
+
const termsQuery = isHierarchical ? useQuery(api.taxonomies.getTermsHierarchy, { taxonomyId }) : useQuery(api.taxonomies.listTerms, { taxonomyId });
|
|
386
|
+
const deleteTerm = useMutation(api.taxonomies.deleteTerm);
|
|
387
|
+
const terms = isHierarchical ? termsQuery : termsQuery?.page;
|
|
388
|
+
const isLoading = terms === void 0;
|
|
389
|
+
const toggleExpand = reactExports.useCallback((termId) => {
|
|
390
|
+
setExpandedTerms((prev) => {
|
|
391
|
+
const next = new Set(prev);
|
|
392
|
+
if (next.has(termId)) {
|
|
393
|
+
next.delete(termId);
|
|
394
|
+
} else {
|
|
395
|
+
next.add(termId);
|
|
396
|
+
}
|
|
397
|
+
return next;
|
|
398
|
+
});
|
|
399
|
+
}, []);
|
|
400
|
+
const handleCreateTerm = reactExports.useCallback((parentId) => {
|
|
401
|
+
setParentForNew(parentId);
|
|
402
|
+
setEditingTerm(null);
|
|
403
|
+
setShowCreateModal(true);
|
|
404
|
+
}, []);
|
|
405
|
+
const handleEditTerm = reactExports.useCallback((term) => {
|
|
406
|
+
setEditingTerm(term);
|
|
407
|
+
setShowCreateModal(true);
|
|
408
|
+
}, []);
|
|
409
|
+
const handleDeleteTerm = reactExports.useCallback(
|
|
410
|
+
async (termId) => {
|
|
411
|
+
setError(null);
|
|
412
|
+
try {
|
|
413
|
+
await deleteTerm({ id: termId, cascade: true });
|
|
414
|
+
setDeleteConfirm(null);
|
|
415
|
+
} catch (err) {
|
|
416
|
+
const message = err instanceof Error ? err.message : "Failed to delete term";
|
|
417
|
+
setError(message);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
[deleteTerm]
|
|
421
|
+
);
|
|
422
|
+
const renderTerm = (term, depth = 0) => {
|
|
423
|
+
const hasChildren = term.children && term.children.length > 0;
|
|
424
|
+
const isExpanded = expandedTerms.has(term._id);
|
|
425
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-b border-border/50 last:border-0", children: [
|
|
426
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
427
|
+
"div",
|
|
428
|
+
{
|
|
429
|
+
className: cn(
|
|
430
|
+
"group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",
|
|
431
|
+
depth > 0 && "border-l-2 border-muted"
|
|
432
|
+
),
|
|
433
|
+
style: { paddingLeft: `${depth * 24 + 8}px` },
|
|
434
|
+
children: [
|
|
435
|
+
isHierarchical && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
436
|
+
"button",
|
|
437
|
+
{
|
|
438
|
+
type: "button",
|
|
439
|
+
onClick: () => toggleExpand(term._id),
|
|
440
|
+
disabled: !hasChildren,
|
|
441
|
+
className: cn(
|
|
442
|
+
"flex size-5 items-center justify-center rounded transition-colors",
|
|
443
|
+
hasChildren ? "text-muted-foreground hover:bg-muted hover:text-foreground" : "invisible"
|
|
444
|
+
),
|
|
445
|
+
"aria-expanded": isExpanded,
|
|
446
|
+
children: hasChildren && (isExpanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "size-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "size-4" }))
|
|
447
|
+
}
|
|
448
|
+
),
|
|
449
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
450
|
+
term.color && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
451
|
+
"span",
|
|
452
|
+
{
|
|
453
|
+
className: "size-3 shrink-0 rounded-full",
|
|
454
|
+
style: { backgroundColor: term.color }
|
|
455
|
+
}
|
|
456
|
+
),
|
|
457
|
+
term.icon && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 text-sm", children: term.icon }),
|
|
458
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-medium text-foreground", children: term.name }),
|
|
459
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
|
|
460
|
+
"(",
|
|
461
|
+
term.slug,
|
|
462
|
+
")"
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground", children: [
|
|
465
|
+
term.usageCount,
|
|
466
|
+
" ",
|
|
467
|
+
term.usageCount === 1 ? "use" : "uses"
|
|
468
|
+
] })
|
|
469
|
+
] }),
|
|
470
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100", children: [
|
|
471
|
+
isHierarchical && allowInlineCreation && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
472
|
+
CmsButton,
|
|
473
|
+
{
|
|
474
|
+
variant: "ghost",
|
|
475
|
+
size: "sm",
|
|
476
|
+
onClick: () => handleCreateTerm(term._id),
|
|
477
|
+
title: "Add child term",
|
|
478
|
+
className: "size-7 p-0",
|
|
479
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-3.5" })
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
483
|
+
CmsButton,
|
|
484
|
+
{
|
|
485
|
+
variant: "ghost",
|
|
486
|
+
size: "sm",
|
|
487
|
+
onClick: () => handleEditTerm(term),
|
|
488
|
+
title: "Edit term",
|
|
489
|
+
className: "size-7 p-0",
|
|
490
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pencil, { className: "size-3.5" })
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
494
|
+
CmsButton,
|
|
495
|
+
{
|
|
496
|
+
variant: "ghost",
|
|
497
|
+
size: "sm",
|
|
498
|
+
onClick: () => setDeleteConfirm(term._id),
|
|
499
|
+
title: "Delete term",
|
|
500
|
+
className: "size-7 p-0 text-destructive hover:text-destructive",
|
|
501
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "size-3.5" })
|
|
502
|
+
}
|
|
503
|
+
)
|
|
504
|
+
] })
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
isHierarchical && hasChildren && isExpanded && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: term.children.map((child) => renderTerm(child, depth + 1)) })
|
|
509
|
+
] }, term._id);
|
|
510
|
+
};
|
|
511
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
|
|
512
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
513
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium text-foreground", children: "Terms" }),
|
|
514
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CmsButton, { variant: "secondary", size: "sm", onClick: () => handleCreateTerm(), children: [
|
|
515
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-3.5" }),
|
|
516
|
+
"Add Term"
|
|
517
|
+
] })
|
|
518
|
+
] }),
|
|
519
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800", children: [
|
|
520
|
+
error,
|
|
521
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
522
|
+
"button",
|
|
523
|
+
{
|
|
524
|
+
type: "button",
|
|
525
|
+
onClick: () => setError(null),
|
|
526
|
+
className: "text-red-600 hover:text-red-800",
|
|
527
|
+
children: "×"
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
] }),
|
|
531
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border bg-card", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "size-6 animate-spin rounded-full border-2 border-muted border-t-primary" }) }) : !terms || terms.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
532
|
+
CmsEmptyState,
|
|
533
|
+
{
|
|
534
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Tags, { className: "size-8" }),
|
|
535
|
+
title: "No terms yet",
|
|
536
|
+
description: "Add your first term to start organizing content.",
|
|
537
|
+
action: allowInlineCreation && /* @__PURE__ */ jsxRuntimeExports.jsxs(CmsButton, { variant: "secondary", onClick: () => handleCreateTerm(), children: [
|
|
538
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
|
|
539
|
+
"Add your first term"
|
|
540
|
+
] })
|
|
541
|
+
}
|
|
542
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "divide-y divide-border/50", children: terms.map((term) => renderTerm(term)) }) }),
|
|
543
|
+
showCreateModal && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
544
|
+
TermEditModal,
|
|
545
|
+
{
|
|
546
|
+
taxonomyId,
|
|
547
|
+
term: editingTerm,
|
|
548
|
+
parentId: parentForNew,
|
|
549
|
+
isHierarchical,
|
|
550
|
+
onSave: () => {
|
|
551
|
+
setShowCreateModal(false);
|
|
552
|
+
setEditingTerm(null);
|
|
553
|
+
setParentForNew(void 0);
|
|
554
|
+
},
|
|
555
|
+
onCancel: () => {
|
|
556
|
+
setShowCreateModal(false);
|
|
557
|
+
setEditingTerm(null);
|
|
558
|
+
setParentForNew(void 0);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
),
|
|
562
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
563
|
+
CmsConfirmDialog,
|
|
564
|
+
{
|
|
565
|
+
open: !!deleteConfirm,
|
|
566
|
+
onOpenChange: (open) => !open && setDeleteConfirm(null),
|
|
567
|
+
title: "Delete Term",
|
|
568
|
+
description: isHierarchical ? "Are you sure you want to delete this term? All child terms will also be deleted." : "Are you sure you want to delete this term?",
|
|
569
|
+
confirmLabel: "Delete",
|
|
570
|
+
variant: "danger",
|
|
571
|
+
onConfirm: () => deleteConfirm && handleDeleteTerm(deleteConfirm)
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
] });
|
|
575
|
+
}
|
|
576
|
+
function TermEditModal({
|
|
577
|
+
taxonomyId,
|
|
578
|
+
term,
|
|
579
|
+
parentId,
|
|
580
|
+
isHierarchical,
|
|
581
|
+
onSave,
|
|
582
|
+
onCancel
|
|
583
|
+
}) {
|
|
584
|
+
const isEditing = !!term;
|
|
585
|
+
const [formData, setFormData] = reactExports.useState({
|
|
586
|
+
name: term?.name ?? "",
|
|
587
|
+
slug: term?.slug ?? "",
|
|
588
|
+
description: term?.description ?? "",
|
|
589
|
+
color: term?.color ?? "",
|
|
590
|
+
icon: term?.icon ?? "",
|
|
591
|
+
sortOrder: term?.sortOrder ?? 0
|
|
592
|
+
});
|
|
593
|
+
const [errors, setErrors] = reactExports.useState({});
|
|
594
|
+
const [isSubmitting, setIsSubmitting] = reactExports.useState(false);
|
|
595
|
+
const [submitError, setSubmitError] = reactExports.useState(null);
|
|
596
|
+
const [slugManuallyEdited, setSlugManuallyEdited] = reactExports.useState(false);
|
|
597
|
+
const createTerm = useMutation(api.taxonomies.createTerm);
|
|
598
|
+
const updateTerm = useMutation(api.taxonomies.updateTerm);
|
|
599
|
+
const handleChange = reactExports.useCallback(
|
|
600
|
+
(field, value) => {
|
|
601
|
+
setFormData((prev) => ({ ...prev, [field]: value }));
|
|
602
|
+
setErrors((prev) => {
|
|
603
|
+
const { [field]: _, ...rest } = prev;
|
|
604
|
+
return rest;
|
|
605
|
+
});
|
|
606
|
+
},
|
|
607
|
+
[]
|
|
608
|
+
);
|
|
609
|
+
const generateSlug = reactExports.useCallback((name) => {
|
|
610
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
611
|
+
}, []);
|
|
612
|
+
const handleNameChange = reactExports.useCallback(
|
|
613
|
+
(value) => {
|
|
614
|
+
handleChange("name", value);
|
|
615
|
+
if (!isEditing && !slugManuallyEdited) {
|
|
616
|
+
handleChange("slug", generateSlug(value));
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
[handleChange, isEditing, slugManuallyEdited, generateSlug]
|
|
620
|
+
);
|
|
621
|
+
const validate = reactExports.useCallback(() => {
|
|
622
|
+
const newErrors = {};
|
|
623
|
+
if (!formData.name.trim()) {
|
|
624
|
+
newErrors.name = "Name is required";
|
|
625
|
+
}
|
|
626
|
+
if (!formData.slug.trim()) {
|
|
627
|
+
newErrors.slug = "Slug is required";
|
|
628
|
+
} else if (!/^[a-z0-9-]+$/.test(formData.slug)) {
|
|
629
|
+
newErrors.slug = "Slug must contain only lowercase letters, numbers, and hyphens";
|
|
630
|
+
}
|
|
631
|
+
setErrors(newErrors);
|
|
632
|
+
return Object.keys(newErrors).length === 0;
|
|
633
|
+
}, [formData]);
|
|
634
|
+
const handleSubmit = reactExports.useCallback(
|
|
635
|
+
async (e) => {
|
|
636
|
+
e.preventDefault();
|
|
637
|
+
if (!validate()) return;
|
|
638
|
+
setIsSubmitting(true);
|
|
639
|
+
setSubmitError(null);
|
|
640
|
+
try {
|
|
641
|
+
if (isEditing && term) {
|
|
642
|
+
await updateTerm({
|
|
643
|
+
id: term._id,
|
|
644
|
+
name: formData.name,
|
|
645
|
+
slug: formData.slug,
|
|
646
|
+
description: formData.description || void 0,
|
|
647
|
+
color: formData.color || void 0,
|
|
648
|
+
icon: formData.icon || void 0,
|
|
649
|
+
sortOrder: formData.sortOrder
|
|
650
|
+
});
|
|
651
|
+
} else {
|
|
652
|
+
await createTerm({
|
|
653
|
+
taxonomyId,
|
|
654
|
+
name: formData.name,
|
|
655
|
+
slug: formData.slug,
|
|
656
|
+
description: formData.description || void 0,
|
|
657
|
+
parentId,
|
|
658
|
+
color: formData.color || void 0,
|
|
659
|
+
icon: formData.icon || void 0,
|
|
660
|
+
sortOrder: formData.sortOrder
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
onSave();
|
|
664
|
+
} catch (error) {
|
|
665
|
+
const message = error instanceof Error ? error.message : "Failed to save term";
|
|
666
|
+
setSubmitError(message);
|
|
667
|
+
} finally {
|
|
668
|
+
setIsSubmitting(false);
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
[
|
|
672
|
+
validate,
|
|
673
|
+
isEditing,
|
|
674
|
+
term,
|
|
675
|
+
formData,
|
|
676
|
+
taxonomyId,
|
|
677
|
+
parentId,
|
|
678
|
+
createTerm,
|
|
679
|
+
updateTerm,
|
|
680
|
+
onSave
|
|
681
|
+
]
|
|
682
|
+
);
|
|
683
|
+
const title = isEditing ? "Edit Term" : parentId ? "Create Child Term" : "Create Term";
|
|
684
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
685
|
+
CmsDialog,
|
|
686
|
+
{
|
|
687
|
+
open: true,
|
|
688
|
+
onOpenChange: (open) => !open && !isSubmitting && onCancel(),
|
|
689
|
+
title,
|
|
690
|
+
size: "md",
|
|
691
|
+
footer: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
692
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "outline", onClick: onCancel, disabled: isSubmitting, children: "Cancel" }),
|
|
693
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
694
|
+
CmsButton,
|
|
695
|
+
{
|
|
696
|
+
variant: "primary",
|
|
697
|
+
onClick: handleSubmit,
|
|
698
|
+
loading: isSubmitting,
|
|
699
|
+
children: isEditing ? "Save Changes" : "Create Term"
|
|
700
|
+
}
|
|
701
|
+
)
|
|
702
|
+
] }),
|
|
703
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
704
|
+
submitError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800", children: submitError }),
|
|
705
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
706
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "termName", children: [
|
|
707
|
+
"Name ",
|
|
708
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
709
|
+
] }),
|
|
710
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
711
|
+
Input,
|
|
712
|
+
{
|
|
713
|
+
id: "termName",
|
|
714
|
+
value: formData.name,
|
|
715
|
+
onChange: (e) => handleNameChange(e.target.value),
|
|
716
|
+
placeholder: "e.g., Technology",
|
|
717
|
+
disabled: isSubmitting,
|
|
718
|
+
className: errors.name ? "border-destructive" : ""
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
errors.name && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-destructive", children: errors.name })
|
|
722
|
+
] }),
|
|
723
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
724
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Label, { htmlFor: "termSlug", children: [
|
|
725
|
+
"Slug ",
|
|
726
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive", children: "*" })
|
|
727
|
+
] }),
|
|
728
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
729
|
+
Input,
|
|
730
|
+
{
|
|
731
|
+
id: "termSlug",
|
|
732
|
+
value: formData.slug,
|
|
733
|
+
onChange: (e) => {
|
|
734
|
+
handleChange("slug", e.target.value.toLowerCase());
|
|
735
|
+
setSlugManuallyEdited(true);
|
|
736
|
+
},
|
|
737
|
+
placeholder: "e.g., technology",
|
|
738
|
+
disabled: isSubmitting,
|
|
739
|
+
className: errors.slug ? "border-destructive" : ""
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
errors.slug && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-destructive", children: errors.slug })
|
|
743
|
+
] }),
|
|
744
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
745
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "termDescription", children: "Description" }),
|
|
746
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
747
|
+
Textarea,
|
|
748
|
+
{
|
|
749
|
+
id: "termDescription",
|
|
750
|
+
value: formData.description,
|
|
751
|
+
onChange: (e) => handleChange("description", e.target.value),
|
|
752
|
+
placeholder: "Optional description",
|
|
753
|
+
rows: 2,
|
|
754
|
+
disabled: isSubmitting
|
|
755
|
+
}
|
|
756
|
+
)
|
|
757
|
+
] }),
|
|
758
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
759
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
760
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "termColor", children: "Color" }),
|
|
761
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
762
|
+
Input,
|
|
763
|
+
{
|
|
764
|
+
id: "termColor",
|
|
765
|
+
type: "color",
|
|
766
|
+
value: formData.color || "#6b7280",
|
|
767
|
+
onChange: (e) => handleChange("color", e.target.value),
|
|
768
|
+
disabled: isSubmitting,
|
|
769
|
+
className: "h-9 p-1"
|
|
770
|
+
}
|
|
771
|
+
)
|
|
772
|
+
] }),
|
|
773
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
774
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "termIcon", children: "Icon" }),
|
|
775
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
776
|
+
Input,
|
|
777
|
+
{
|
|
778
|
+
id: "termIcon",
|
|
779
|
+
value: formData.icon,
|
|
780
|
+
onChange: (e) => handleChange("icon", e.target.value),
|
|
781
|
+
placeholder: "e.g., 💻",
|
|
782
|
+
disabled: isSubmitting
|
|
783
|
+
}
|
|
784
|
+
)
|
|
785
|
+
] }),
|
|
786
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
787
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "termSortOrder", children: "Sort Order" }),
|
|
788
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
789
|
+
Input,
|
|
790
|
+
{
|
|
791
|
+
id: "termSortOrder",
|
|
792
|
+
type: "number",
|
|
793
|
+
value: formData.sortOrder,
|
|
794
|
+
onChange: (e) => handleChange("sortOrder", parseInt(e.target.value) || 0),
|
|
795
|
+
disabled: isSubmitting
|
|
796
|
+
}
|
|
797
|
+
)
|
|
798
|
+
] })
|
|
799
|
+
] })
|
|
800
|
+
] })
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
function TaxonomiesPage() {
|
|
805
|
+
const [selectedTaxonomy, setSelectedTaxonomy] = reactExports.useState(null);
|
|
806
|
+
const [showCreateModal, setShowCreateModal] = reactExports.useState(false);
|
|
807
|
+
const [editingTaxonomy, setEditingTaxonomy] = reactExports.useState(null);
|
|
808
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = reactExports.useState(null);
|
|
809
|
+
const [deleteError, setDeleteError] = reactExports.useState(null);
|
|
810
|
+
const taxonomiesQuery = useQuery(api.taxonomies.list, {
|
|
811
|
+
isActive: void 0,
|
|
812
|
+
includeDeleted: false
|
|
813
|
+
});
|
|
814
|
+
const deleteTaxonomy = useMutation(api.taxonomies.deleteTaxonomy);
|
|
815
|
+
const taxonomies = taxonomiesQuery?.page ?? [];
|
|
816
|
+
const isLoading = taxonomiesQuery === void 0;
|
|
817
|
+
const handleCreate = reactExports.useCallback(() => {
|
|
818
|
+
setEditingTaxonomy(null);
|
|
819
|
+
setShowCreateModal(true);
|
|
820
|
+
}, []);
|
|
821
|
+
const handleEdit = reactExports.useCallback((taxonomy) => {
|
|
822
|
+
setEditingTaxonomy(taxonomy);
|
|
823
|
+
setShowCreateModal(true);
|
|
824
|
+
}, []);
|
|
825
|
+
const handleDelete = reactExports.useCallback(async (taxonomyId) => {
|
|
826
|
+
setDeleteError(null);
|
|
827
|
+
try {
|
|
828
|
+
await deleteTaxonomy({
|
|
829
|
+
id: taxonomyId
|
|
830
|
+
});
|
|
831
|
+
setShowDeleteConfirm(null);
|
|
832
|
+
if (selectedTaxonomy?._id === taxonomyId) {
|
|
833
|
+
setSelectedTaxonomy(null);
|
|
834
|
+
}
|
|
835
|
+
} catch (error) {
|
|
836
|
+
const message = error instanceof Error ? error.message : "Failed to delete taxonomy";
|
|
837
|
+
setDeleteError(message);
|
|
838
|
+
}
|
|
839
|
+
}, [deleteTaxonomy, selectedTaxonomy]);
|
|
840
|
+
const handleSaveComplete = reactExports.useCallback(() => {
|
|
841
|
+
setShowCreateModal(false);
|
|
842
|
+
setEditingTaxonomy(null);
|
|
843
|
+
}, []);
|
|
844
|
+
const getTypeIcon = (taxonomy) => {
|
|
845
|
+
return taxonomy.isHierarchical ? /* @__PURE__ */ jsxRuntimeExports.jsx(FolderTree, { className: "size-5" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { className: "size-5" });
|
|
846
|
+
};
|
|
847
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-[calc(100vh-4rem)] flex-col p-6", children: [
|
|
848
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 flex items-start justify-between", children: [
|
|
849
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsPageHeader, { title: "Taxonomies", description: "Manage tags, categories, and other classification systems" }),
|
|
850
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CmsButton, { onClick: handleCreate, children: [
|
|
851
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
|
|
852
|
+
"Create Taxonomy"
|
|
853
|
+
] })
|
|
854
|
+
] }),
|
|
855
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex min-h-0 flex-1 gap-6", children: [
|
|
856
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsSurface, { elevation: "base", className: "w-80 shrink-0 overflow-hidden", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-12", children: [
|
|
857
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "size-6 animate-spin rounded-full border-2 border-muted border-t-primary" }),
|
|
858
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: "Loading taxonomies..." })
|
|
859
|
+
] }) : taxonomies.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center p-6 text-center", children: [
|
|
860
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { className: "mb-3 size-8 text-muted-foreground" }),
|
|
861
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "No taxonomies created yet." }),
|
|
862
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "secondary", className: "mt-4", onClick: handleCreate, children: "Create your first taxonomy" })
|
|
863
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "divide-y", children: taxonomies.map((taxonomy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50", selectedTaxonomy?._id === taxonomy._id && "bg-primary/5", !taxonomy.isActive && "opacity-60"), onClick: () => setSelectedTaxonomy(taxonomy), children: [
|
|
864
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground", children: getTypeIcon(taxonomy) }),
|
|
865
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
866
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-sm font-medium text-foreground", children: taxonomy.displayName }),
|
|
867
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs text-muted-foreground", children: taxonomy.name })
|
|
868
|
+
] }),
|
|
869
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
870
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "secondary", className: "text-xs font-normal", children: taxonomy.isHierarchical ? "Hierarchical" : "Flat" }),
|
|
871
|
+
!taxonomy.isActive && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "outline", className: "text-xs font-normal", children: "Inactive" })
|
|
872
|
+
] }),
|
|
873
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100", children: [
|
|
874
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "ghost", size: "icon-sm", onClick: (e) => {
|
|
875
|
+
e.stopPropagation();
|
|
876
|
+
handleEdit(taxonomy);
|
|
877
|
+
}, title: "Edit taxonomy", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pencil, { className: "size-4" }) }),
|
|
878
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "ghost", size: "icon-sm", onClick: (e) => {
|
|
879
|
+
e.stopPropagation();
|
|
880
|
+
setShowDeleteConfirm(taxonomy._id);
|
|
881
|
+
}, title: "Delete taxonomy", className: "text-destructive hover:bg-destructive/10 hover:text-destructive", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "size-4" }) })
|
|
882
|
+
] })
|
|
883
|
+
] }, taxonomy._id)) }) }) }),
|
|
884
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsSurface, { elevation: "base", className: "min-w-0 flex-1 overflow-hidden", children: selectedTaxonomy ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col", children: [
|
|
885
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between border-b p-4", children: [
|
|
886
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
887
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground", children: getTypeIcon(selectedTaxonomy) }),
|
|
888
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
889
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-lg font-semibold text-foreground", children: selectedTaxonomy.displayName }),
|
|
890
|
+
selectedTaxonomy.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: selectedTaxonomy.description })
|
|
891
|
+
] })
|
|
892
|
+
] }),
|
|
893
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsButton, { variant: "secondary", onClick: () => handleEdit(selectedTaxonomy), children: "Edit Taxonomy" })
|
|
894
|
+
] }),
|
|
895
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TermTree, { taxonomyId: selectedTaxonomy._id, isHierarchical: selectedTaxonomy.isHierarchical, allowInlineCreation: selectedTaxonomy.allowInlineCreation }) })
|
|
896
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CmsEmptyState, { icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { className: "size-6" }), title: "Select a taxonomy", description: "Select a taxonomy to view and manage its terms", className: "h-full" }) })
|
|
897
|
+
] }),
|
|
898
|
+
showCreateModal && /* @__PURE__ */ jsxRuntimeExports.jsx(TaxonomyEditor, { taxonomy: editingTaxonomy, onSave: handleSaveComplete, onCancel: () => {
|
|
899
|
+
setShowCreateModal(false);
|
|
900
|
+
setEditingTaxonomy(null);
|
|
901
|
+
} }),
|
|
902
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CmsConfirmDialog, { open: showDeleteConfirm !== null, onOpenChange: (open) => {
|
|
903
|
+
if (!open) {
|
|
904
|
+
setShowDeleteConfirm(null);
|
|
905
|
+
setDeleteError(null);
|
|
906
|
+
}
|
|
907
|
+
}, title: "Delete Taxonomy", description: "Are you sure you want to delete this taxonomy? All associated terms will also be deleted.", confirmLabel: "Delete", onConfirm: () => showDeleteConfirm && handleDelete(showDeleteConfirm), variant: "danger", children: deleteError && /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "mt-4", children: [
|
|
908
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TriangleAlert, { className: "size-4" }),
|
|
909
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: deleteError })
|
|
910
|
+
] }) })
|
|
911
|
+
] });
|
|
912
|
+
}
|
|
913
|
+
export {
|
|
914
|
+
TaxonomiesPage as component
|
|
915
|
+
};
|