@questpie/admin 0.0.1 → 1.0.0
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/README.md +439 -424
- package/dist/auth-layout-M8K8_q5R.mjs +181 -0
- package/dist/auth-layout-M8K8_q5R.mjs.map +1 -0
- package/dist/bulk-upload-dialog-h7zXD78Y.mjs +274 -0
- package/dist/bulk-upload-dialog-h7zXD78Y.mjs.map +1 -0
- package/dist/{components/ui/card.mjs → card-BKHjBQfw.mjs} +8 -8
- package/dist/card-BKHjBQfw.mjs.map +1 -0
- package/dist/client/styles/index.css +434 -0
- package/dist/client-BCGpkAz6.mjs +22635 -0
- package/dist/client-BCGpkAz6.mjs.map +1 -0
- package/dist/client-CcWZbkBP.d.mts +13585 -0
- package/dist/client-CcWZbkBP.d.mts.map +1 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.mjs +14 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs +1650 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs.map +1 -0
- package/dist/dashboard-page-B4PGEdc2.mjs +2500 -0
- package/dist/dashboard-page-B4PGEdc2.mjs.map +1 -0
- package/dist/dashboard-page-CVlyR40m.mjs +6 -0
- package/dist/dropzone-Do3awXKd.mjs +634 -0
- package/dist/dropzone-Do3awXKd.mjs.map +1 -0
- package/dist/{views/auth/forgot-password-form.mjs → forgot-password-page-Bcp-An4Y.mjs} +87 -14
- package/dist/forgot-password-page-Bcp-An4Y.mjs.map +1 -0
- package/dist/forgot-password-page-CIILVhfo.mjs +7 -0
- package/dist/index-B9Xwk4hi.d.mts +2753 -0
- package/dist/index-B9Xwk4hi.d.mts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +14 -0
- package/dist/login-page-8K7fo0qK.mjs +7 -0
- package/dist/login-page-CP4gA-dl.mjs +298 -0
- package/dist/login-page-CP4gA-dl.mjs.map +1 -0
- package/dist/preview-utils-BKQ9-TMa.mjs +65 -0
- package/dist/preview-utils-BKQ9-TMa.mjs.map +1 -0
- package/dist/{views/auth/reset-password-form.mjs → reset-password-page-BqfDmLxA.mjs} +111 -14
- package/dist/reset-password-page-BqfDmLxA.mjs.map +1 -0
- package/dist/reset-password-page-DLATv0xQ.mjs +7 -0
- package/dist/runtime-6VZM878K.mjs +69 -0
- package/dist/runtime-6VZM878K.mjs.map +1 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts +42 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts.map +1 -0
- package/dist/server.d.mts +250 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +832 -0
- package/dist/server.mjs.map +1 -0
- package/dist/setup-page-CMZ5P_OE.mjs +6 -0
- package/dist/setup-page-YAP_fzqh.mjs +264 -0
- package/dist/setup-page-YAP_fzqh.mjs.map +1 -0
- package/dist/shared.d.mts +57 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +3 -0
- package/dist/{hooks/use-auth.mjs → use-auth-BoLmWtmU.mjs} +42 -30
- package/dist/use-auth-BoLmWtmU.mjs.map +1 -0
- package/package.json +48 -197
- package/.turbo/turbo-build.log +0 -108
- package/CHANGELOG.md +0 -10
- package/STATUS.md +0 -917
- package/VALIDATION.md +0 -602
- package/components.json +0 -24
- package/dist/__tests__/setup.mjs +0 -38
- package/dist/__tests__/test-utils.mjs +0 -45
- package/dist/__tests__/vitest.d.mjs +0 -3
- package/dist/components/admin-app.mjs +0 -69
- package/dist/components/fields/array-field.mjs +0 -190
- package/dist/components/fields/checkbox-field.mjs +0 -34
- package/dist/components/fields/custom-field.mjs +0 -32
- package/dist/components/fields/date-field.mjs +0 -41
- package/dist/components/fields/datetime-field.mjs +0 -42
- package/dist/components/fields/email-field.mjs +0 -37
- package/dist/components/fields/embedded-collection.mjs +0 -253
- package/dist/components/fields/field-types.mjs +0 -1
- package/dist/components/fields/field-utils.mjs +0 -10
- package/dist/components/fields/field-wrapper.mjs +0 -34
- package/dist/components/fields/index.mjs +0 -23
- package/dist/components/fields/json-field.mjs +0 -243
- package/dist/components/fields/locale-badge.mjs +0 -16
- package/dist/components/fields/number-field.mjs +0 -39
- package/dist/components/fields/password-field.mjs +0 -37
- package/dist/components/fields/relation-field.mjs +0 -104
- package/dist/components/fields/relation-picker.mjs +0 -229
- package/dist/components/fields/relation-select.mjs +0 -188
- package/dist/components/fields/rich-text-editor/index.mjs +0 -897
- package/dist/components/fields/select-field.mjs +0 -41
- package/dist/components/fields/switch-field.mjs +0 -34
- package/dist/components/fields/text-field.mjs +0 -38
- package/dist/components/fields/textarea-field.mjs +0 -38
- package/dist/components/index.mjs +0 -59
- package/dist/components/primitives/checkbox-input.mjs +0 -127
- package/dist/components/primitives/date-input.mjs +0 -303
- package/dist/components/primitives/index.mjs +0 -12
- package/dist/components/primitives/number-input.mjs +0 -104
- package/dist/components/primitives/select-input.mjs +0 -177
- package/dist/components/primitives/tag-input.mjs +0 -135
- package/dist/components/primitives/text-input.mjs +0 -39
- package/dist/components/primitives/textarea-input.mjs +0 -37
- package/dist/components/primitives/toggle-input.mjs +0 -31
- package/dist/components/primitives/types.mjs +0 -12
- package/dist/components/ui/accordion.mjs +0 -55
- package/dist/components/ui/avatar.mjs +0 -54
- package/dist/components/ui/badge.mjs +0 -34
- package/dist/components/ui/button.mjs +0 -48
- package/dist/components/ui/checkbox.mjs +0 -21
- package/dist/components/ui/combobox.mjs +0 -163
- package/dist/components/ui/dialog.mjs +0 -95
- package/dist/components/ui/dropdown-menu.mjs +0 -138
- package/dist/components/ui/field.mjs +0 -113
- package/dist/components/ui/input-group.mjs +0 -82
- package/dist/components/ui/input.mjs +0 -17
- package/dist/components/ui/label.mjs +0 -15
- package/dist/components/ui/popover.mjs +0 -56
- package/dist/components/ui/scroll-area.mjs +0 -38
- package/dist/components/ui/select.mjs +0 -100
- package/dist/components/ui/separator.mjs +0 -16
- package/dist/components/ui/sheet.mjs +0 -90
- package/dist/components/ui/sidebar.mjs +0 -387
- package/dist/components/ui/skeleton.mjs +0 -14
- package/dist/components/ui/spinner.mjs +0 -16
- package/dist/components/ui/switch.mjs +0 -22
- package/dist/components/ui/table.mjs +0 -68
- package/dist/components/ui/tabs.mjs +0 -48
- package/dist/components/ui/textarea.mjs +0 -15
- package/dist/components/ui/tooltip.mjs +0 -44
- package/dist/config/component-registry.mjs +0 -38
- package/dist/config/index.mjs +0 -129
- package/dist/hooks/admin-provider.mjs +0 -70
- package/dist/hooks/index.mjs +0 -7
- package/dist/hooks/store.mjs +0 -178
- package/dist/hooks/use-collection-db.mjs +0 -146
- package/dist/hooks/use-collection.mjs +0 -112
- package/dist/hooks/use-global.mjs +0 -46
- package/dist/hooks/use-mobile.mjs +0 -20
- package/dist/lib/utils.mjs +0 -10
- package/dist/styles/index.css +0 -336
- package/dist/styles/index.mjs +0 -1
- package/dist/utils/index.mjs +0 -9
- package/dist/views/auth/auth-layout.mjs +0 -52
- package/dist/views/auth/index.mjs +0 -6
- package/dist/views/auth/login-form.mjs +0 -156
- package/dist/views/collection/auto-form-fields.mjs +0 -525
- package/dist/views/collection/collection-form.mjs +0 -91
- package/dist/views/collection/collection-list.mjs +0 -76
- package/dist/views/collection/form-field.mjs +0 -42
- package/dist/views/collection/index.mjs +0 -6
- package/dist/views/common/index.mjs +0 -4
- package/dist/views/common/locale-switcher.mjs +0 -39
- package/dist/views/common/version-history.mjs +0 -272
- package/dist/views/index.mjs +0 -9
- package/dist/views/layout/admin-layout.mjs +0 -40
- package/dist/views/layout/admin-router.mjs +0 -95
- package/dist/views/layout/admin-sidebar.mjs +0 -63
- package/dist/views/layout/index.mjs +0 -5
- package/src/__tests__/setup.ts +0 -44
- package/src/__tests__/test-utils.tsx +0 -49
- package/src/__tests__/vitest.d.ts +0 -9
- package/src/components/admin-app.tsx +0 -221
- package/src/components/fields/array-field.tsx +0 -237
- package/src/components/fields/checkbox-field.tsx +0 -47
- package/src/components/fields/custom-field.tsx +0 -50
- package/src/components/fields/date-field.tsx +0 -65
- package/src/components/fields/datetime-field.tsx +0 -67
- package/src/components/fields/email-field.tsx +0 -51
- package/src/components/fields/embedded-collection.tsx +0 -315
- package/src/components/fields/field-types.ts +0 -162
- package/src/components/fields/field-utils.ts +0 -6
- package/src/components/fields/field-wrapper.tsx +0 -52
- package/src/components/fields/index.ts +0 -66
- package/src/components/fields/json-field.tsx +0 -440
- package/src/components/fields/locale-badge.tsx +0 -15
- package/src/components/fields/number-field.tsx +0 -57
- package/src/components/fields/password-field.tsx +0 -51
- package/src/components/fields/relation-field.tsx +0 -243
- package/src/components/fields/relation-picker.tsx +0 -402
- package/src/components/fields/relation-select.tsx +0 -327
- package/src/components/fields/rich-text-editor/index.tsx +0 -1337
- package/src/components/fields/select-field.tsx +0 -61
- package/src/components/fields/switch-field.tsx +0 -47
- package/src/components/fields/text-field.tsx +0 -55
- package/src/components/fields/textarea-field.tsx +0 -55
- package/src/components/index.ts +0 -40
- package/src/components/primitives/checkbox-input.tsx +0 -193
- package/src/components/primitives/date-input.tsx +0 -401
- package/src/components/primitives/index.ts +0 -24
- package/src/components/primitives/number-input.tsx +0 -132
- package/src/components/primitives/select-input.tsx +0 -296
- package/src/components/primitives/tag-input.tsx +0 -200
- package/src/components/primitives/text-input.tsx +0 -49
- package/src/components/primitives/textarea-input.tsx +0 -46
- package/src/components/primitives/toggle-input.tsx +0 -36
- package/src/components/primitives/types.ts +0 -235
- package/src/components/ui/accordion.tsx +0 -72
- package/src/components/ui/avatar.tsx +0 -106
- package/src/components/ui/badge.tsx +0 -48
- package/src/components/ui/button.tsx +0 -53
- package/src/components/ui/card.tsx +0 -94
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/combobox.tsx +0 -290
- package/src/components/ui/dialog.tsx +0 -151
- package/src/components/ui/dropdown-menu.tsx +0 -254
- package/src/components/ui/field.tsx +0 -227
- package/src/components/ui/input-group.tsx +0 -149
- package/src/components/ui/input.tsx +0 -20
- package/src/components/ui/label.tsx +0 -18
- package/src/components/ui/popover.tsx +0 -88
- package/src/components/ui/scroll-area.tsx +0 -53
- package/src/components/ui/select.tsx +0 -192
- package/src/components/ui/separator.tsx +0 -23
- package/src/components/ui/sheet.tsx +0 -127
- package/src/components/ui/sidebar.tsx +0 -723
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/spinner.tsx +0 -10
- package/src/components/ui/switch.tsx +0 -32
- package/src/components/ui/table.tsx +0 -99
- package/src/components/ui/tabs.tsx +0 -82
- package/src/components/ui/textarea.tsx +0 -18
- package/src/components/ui/tooltip.tsx +0 -70
- package/src/config/component-registry.ts +0 -190
- package/src/config/index.ts +0 -1099
- package/src/hooks/README.md +0 -269
- package/src/hooks/admin-provider.tsx +0 -110
- package/src/hooks/index.ts +0 -41
- package/src/hooks/store.ts +0 -248
- package/src/hooks/use-auth.ts +0 -168
- package/src/hooks/use-collection-db.ts +0 -209
- package/src/hooks/use-collection.ts +0 -156
- package/src/hooks/use-global.ts +0 -69
- package/src/hooks/use-mobile.ts +0 -21
- package/src/lib/utils.ts +0 -6
- package/src/styles/index.css +0 -340
- package/src/utils/index.ts +0 -6
- package/src/views/auth/auth-layout.tsx +0 -77
- package/src/views/auth/forgot-password-form.tsx +0 -192
- package/src/views/auth/index.ts +0 -21
- package/src/views/auth/login-form.tsx +0 -229
- package/src/views/auth/reset-password-form.tsx +0 -232
- package/src/views/collection/auto-form-fields.tsx +0 -982
- package/src/views/collection/collection-form.tsx +0 -186
- package/src/views/collection/collection-list.tsx +0 -223
- package/src/views/collection/form-field.tsx +0 -52
- package/src/views/collection/index.ts +0 -15
- package/src/views/common/index.ts +0 -8
- package/src/views/common/locale-switcher.tsx +0 -45
- package/src/views/common/version-history.tsx +0 -406
- package/src/views/index.ts +0 -25
- package/src/views/layout/admin-layout.tsx +0 -117
- package/src/views/layout/admin-router.tsx +0 -206
- package/src/views/layout/admin-sidebar.tsx +0 -185
- package/src/views/layout/index.ts +0 -12
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- package/tsdown.config.ts +0 -13
- package/vitest.config.ts +0 -29
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B9Xwk4hi.d.mts","names":[],"sources":["../src/server/auth-helpers.ts","../src/server/modules/admin-preferences/collections/saved-views.collection.ts","../src/server/modules/admin/functions/preview.ts","../src/server/modules/admin/functions/setup.ts","../src/server/modules/admin/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AA2LA;;AAEE,UAjKe,WAAA,CAiKf;EACC,IAAA,EAAA;IAAiC,EAAA,EAAA,MAAA;IAAR,KAAA,EAAA,MAAA;IAAO,IAAA,CAAA,EAAA,MAAA,GAAA,IAAA;IAiCb,IAAA,CAAA,EAAA,MAAW,GAAA,IAAA;IAC/B,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;EACA,CAAA;EACA,OAAA,EAAA;IACC,EAAA,EAAA,MAAA;IAAqD,MAAA,EAAA,MAAA;IAAO,SAAA,EA5LhD,IA4LgD;;;;AC9L/D;;;UDUiB,uBAAA,CCVgB;EAAA;;;WDctB;;;;OAKJ;;;;;;;;;;;;;AEQP;AAiBA;EAgIgB,aAAA,CAAA,EAAA,MAAA;AAuDhB;;;;ACrMa,UHaI,sBAAA,CGbW;EAoCf;AA2Eb;;WH9FW;;;;OAKJ;;AIsBP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBJcsB,gBAAA;;;;;;GAMnB,0BAA0B,QAAQ;;;;;;;;;;;;;;;;iBAwDf,eAAA;;;GAGnB,yBAAyB,QAAQ;;;;;;;;;;;;iBAiCd,WAAA;;;;GAInB;;IAAqD;;;;;;;;;;;;AAvMxD;AAmBA;AAiCA;AA6CA;;;;;;;;;;AA8DA;;;AAGG,cCzJU,oBDyJV,ECzJ8B,WAAA,CAAA,iBDyJ9B,CCzJ8B,WAAA,CAAA,WDyJ9B,aCzJ8B,SDyJ9B,aCzJ8B,aDyJ9B,CCrIC,WAAA,CApB6B,sBAAA,GDyJ9B;EAAiC,IAAA,EAAA,mBAAA;E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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAdv+6V,WAAA,CAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { $ as BlockRenderer, $n as LoginForm, $r as BlockDefinition, $t as SectionBuilderState, A as BlockScopeContextValue, Ai as BaseFieldProps, An as selectAuthClient, Ar as DashboardWidgetConfig, At as useShallow, B as StandalonePreviewField, Bn as AdminLayout, Br as PageBuilder, Bt as global, C as PreviewReadyMessage, Ci as RelationFieldConfig, Cn as AdminRouter, Cr as SidebarLinkItem, Ct as useCollectionItem, D as SelectBlockMessage, Di as TabConfig, Dn as AdminState, Dr as BaseWidgetConfig, Dt as useAuthClient, E as RefreshCompleteMessage, Ei as SelectOption, En as AdminProviderProps, Er as AnyWidgetConfig, Et as createAdminAuthClient, F as PreviewBanner, Fn as selectNavigate, Fr as StatsWidgetConfig, Ft as CoreAdminModule, G as PreviewToggleButton, Gn as FormView, Gr as GlobalConfig, Gt as AdminTypeRegistry, H as PreviewPane, Hn as TableView, Hr as PageDefinition, Ht as Admin, I as PreviewBannerProps, In as selectNavigation, Ir as WidgetAction, It as coreAdminModule, J as BlockPrefetchError, Jn as SetupForm, Jr as CollectionConfig, Jt as RegisteredCMS, K as PreviewToggleButtonProps, Kn as FormViewProps, Kr as AutoSaveConfig, Kt as IsRegistered, L as PreviewField, Ln as selectSetContentLocale, Lr as WidgetComponentProps, Lt as qa, M as BlockScopeProviderProps, Mi as MaybeLazyComponent, Mn as selectBrandName, Mr as KnownWidgetType, Mt as adminMessagesEN, N as useBlockScope, Ni as I18nContext, Nn as selectClient, Nr as QuickActionsWidgetConfig, Nt as AdminModule, O as isAdminToPreviewMessage, Oi as TabsLayout, On as AdminStore, Or as ChartWidgetConfig, Ot as TypedHooks, P as useResolveFieldPath, Pi as I18nText, Pn as selectContentLocale, Pr as RecentItemsWidgetConfig, Pt as adminModule, Q as prefetchBlockData, Qn as ForgotPasswordForm, Qr as BlockBuilderState, Qt as SectionBuilder, R as PreviewFieldProps, Rn as useAdminStore, Rr as WidgetConfig, Rt as AdminHelpers, S as PreviewConfig, Si as LayoutMode, Sn as DashboardPage, Sr as SidebarItem, St as useCollectionDelete, T as PreviewToAdminMessage, Ti as SectionLayout, Tn as AdminProvider, Tr as SidebarSection, Tt as useCollectionUpdate, U as PreviewPaneProps, Un as TableViewConfig, Ur as page, Ut as AppAdmin, V as usePreviewContext, Vn as AdminSidebar, Vr as PageBuilderState, Vt as collection, W as PreviewPaneRef, Wn as TableViewProps, Wr as GlobalBuilderState, Wt as InferAdminCMS, X as BlockPrefetchResult, Xn as AcceptInviteForm, Xr as ColumnConfigObject, Xt as RegisteredGlobalNames, Y as BlockPrefetchParams, Yn as SetupFormValues, Yr as ColumnConfig, Yt as RegisteredCollectionNames, Z as TypedBlockPrefetch, Zn as ResetPasswordForm, Zr as ListViewConfig, Zt as AdminBuilder, _ as useCollectionPreview, _i as FieldComponentProps, _n as AcceptInvitePage, _r as LocaleConfig, _t as useSavedViews, a as FocusContextValue, ai as BlockRendererProps$1, an as TypedSidebarItem, ar as widget, at as AdminTopbar, b as FieldClickedMessage, bi as FormSidebarConfig, bn as ForgotPasswordPage, br as SidebarDividerItem, bt as useCurrentUser, c as FocusState, ci as isBlockContent, cn as GlobalBuilder, cr as EditViewDefinition, ct as DashboardGrid, d as useFocus, di as FieldDefinition, dn as block, dr as ListViewDefinition, dt as TipTapDoc, ei as InferBlockValues, en as SidebarBuilder, er as AuthLayout, et as BlockRendererProps, f as useFocusOptional, fi as field, fn as AuthLoading, fr as editView, ft as TipTapNode, g as UseCollectionPreviewResult, gi as EmbeddedFieldConfig, gn as SetupPageProps, gr as DashboardConfig, gt as useSetupStatus, h as UseCollectionPreviewOptions, hi as EmbeddedCollectionProps, hn as SetupPage, hr as BrandingConfig, ht as useMediaQuery, i as GlobalNames, ii as BlockPrefetch, in as TypedSidebarGlobalItem, ir as WidgetDefinition, it as getFlagUrl, j as BlockScopeProvider, ji as IconComponent, jn as selectBasePath, jr as GenericWidgetConfig, jt as adminMessagesSK, k as isPreviewToAdminMessage, ki as WrapperMode, kn as selectAdmin, kr as CustomWidgetConfig, kt as createTypedHooks, l as parsePreviewFieldPath, li as FieldBuilder, ln as CollectionBuilder, lr as ListViewBuilder, lt as RichTextRenderer, m as useIsFieldFocused, mi as ComponentRegistry, mn as AdminLink, mr as DefaultViewsConfig, mt as useIsMobile, n as CollectionItem, ni as BlockContent, nn as SidebarItemForApp, nr as WidgetBuilder, nt as getCountryCode, o as FocusProvider, oi as EMPTY_BLOCK_CONTENT, on as section, or as EditViewBuilder, ot as GlobalForm, p as useIsBlockFocused, pi as ArrayFieldConfig, pn as AuthGuard, pr as listView, pt as useIsDesktop, q as BlockPrefetchContext, qn as FormViewRegistryConfig, qr as CollectionBuilderState, qt as RegisteredAdmin, r as CollectionNames, ri as BlockNode, rn as TypedSidebarCollectionItem, rr as WidgetBuilderState, rt as getFlagConfig, s as FocusProviderProps, si as createBlockNode, sn as sidebar, sr as EditViewBuilderState, st as DashboardWidget, t as CollectionFieldKeys, ti as BlockCategory, tn as SidebarBuilderState, tr as AdminBuilderState, tt as FlagConfig, u as scrollFieldIntoView, ui as FieldBuilderState, un as BlockBuilder, ur as ListViewBuilderState, ut as RichTextStyles, v as AdminToPreviewMessage, vi as FieldLayoutItem, vn as InvitePage, vr as SidebarCollectionItem, vt as useGlobal, w as PreviewRefreshMessage, wi as RichTextConfig, wn as AdminRouterProps, wr as SidebarPageItem, wt as useCollectionList, x as FocusFieldMessage, xi as FormViewConfig, xn as LoginPage, xr as SidebarGlobalItem, xt as useCollectionCreate, y as BlockClickedMessage, yi as FieldUIConfig, yn as ResetPasswordPage, yr as SidebarConfig, yt as useGlobalUpdate, z as PreviewProvider, zn as AdminLayoutProvider, zr as WidgetDataSource, zt as createAdminHelpers } from "./client-CcWZbkBP.mjs";
|
|
2
|
+
import "./index-B9Xwk4hi.mjs";
|
|
3
|
+
export { AcceptInviteForm, AcceptInvitePage, Admin, AdminBuilder, AdminBuilderState, AdminHelpers, AdminLayout, AdminLayoutProvider, AdminLink, AdminModule, AdminProvider, AdminProviderProps, AdminRouter, AdminRouterProps, AdminSidebar, AdminState, AdminStore, AdminToPreviewMessage, AdminTopbar, AdminTypeRegistry, AnyWidgetConfig, AppAdmin, ArrayFieldConfig, AuthGuard, AuthLayout, AuthLoading, AutoSaveConfig, BaseFieldProps, BaseWidgetConfig, BlockBuilder, BlockBuilderState, BlockCategory, BlockClickedMessage, BlockContent, BlockDefinition, BlockNode, BlockPrefetch, BlockPrefetchContext, BlockPrefetchError, BlockPrefetchParams, BlockPrefetchResult, BlockRenderer, BlockRendererProps as BlockRendererComponentProps, BlockRendererProps$1 as BlockRendererProps, BlockScopeContextValue, BlockScopeProvider, BlockScopeProviderProps, BrandingConfig, ChartWidgetConfig, CollectionBuilder, CollectionBuilderState, CollectionConfig, CollectionFieldKeys, CollectionItem, CollectionNames, ColumnConfig, ColumnConfigObject, ComponentRegistry, CoreAdminModule, CustomWidgetConfig, DashboardConfig, DashboardGrid, DashboardPage, DashboardWidget, DashboardWidgetConfig, DefaultViewsConfig, EMPTY_BLOCK_CONTENT, EditViewBuilder, EditViewBuilderState, EditViewDefinition, EmbeddedCollectionProps, EmbeddedFieldConfig, FieldBuilder, FieldBuilderState, FieldClickedMessage, FieldComponentProps, FieldDefinition, FieldLayoutItem, FieldUIConfig, FlagConfig, FocusContextValue, FocusFieldMessage, FocusProvider, FocusProviderProps, FocusState, ForgotPasswordForm, ForgotPasswordPage, FormSidebarConfig, FormView, FormViewConfig, FormViewProps, FormViewRegistryConfig, GenericWidgetConfig, GlobalBuilder, GlobalBuilderState, GlobalConfig, GlobalForm, GlobalNames, I18nContext, I18nText, IconComponent, InferAdminCMS, InferBlockValues, InvitePage, IsRegistered, KnownWidgetType, LayoutMode, ListViewBuilder, ListViewBuilderState, ListViewConfig, ListViewDefinition, LocaleConfig, LoginForm, LoginPage, MaybeLazyComponent, PageBuilder, PageBuilderState, PageDefinition, PreviewBanner, PreviewBannerProps, PreviewConfig, PreviewField, PreviewFieldProps, PreviewPane, PreviewPaneProps, PreviewPaneRef, PreviewProvider, PreviewReadyMessage, PreviewRefreshMessage, PreviewToAdminMessage, PreviewToggleButton, PreviewToggleButtonProps, QuickActionsWidgetConfig, RecentItemsWidgetConfig, RefreshCompleteMessage, RegisteredAdmin, RegisteredCMS, RegisteredCollectionNames, RegisteredGlobalNames, RelationFieldConfig, ResetPasswordForm, ResetPasswordPage, RichTextConfig, RichTextRenderer, RichTextStyles, SectionBuilder, SectionBuilderState, SectionLayout, SelectBlockMessage, SelectOption, SetupForm, SetupFormValues, SetupPage, SetupPageProps, SidebarBuilder, SidebarBuilderState, SidebarCollectionItem, SidebarConfig, SidebarDividerItem, SidebarGlobalItem, SidebarItem, SidebarItemForApp, SidebarLinkItem, SidebarPageItem, SidebarSection, StandalonePreviewField, StatsWidgetConfig, TabConfig, TableView, TableViewConfig, TableViewProps, TabsLayout, TipTapDoc, TipTapNode, TypedBlockPrefetch, TypedHooks, TypedSidebarCollectionItem, TypedSidebarGlobalItem, TypedSidebarItem, UseCollectionPreviewOptions, UseCollectionPreviewResult, WidgetAction, WidgetBuilder, WidgetBuilderState, WidgetComponentProps, WidgetConfig, WidgetDataSource, WidgetDefinition, WrapperMode, adminMessagesEN, adminMessagesSK, adminModule, block, collection, coreAdminModule, createAdminAuthClient, createAdminHelpers, createBlockNode, createTypedHooks, editView, field, getCountryCode, getFlagConfig, getFlagUrl, global, isAdminToPreviewMessage, isBlockContent, isPreviewToAdminMessage, listView, page, parsePreviewFieldPath, prefetchBlockData, qa, scrollFieldIntoView, section, selectAdmin, selectAuthClient, selectBasePath, selectBrandName, selectClient, selectContentLocale, selectNavigate, selectNavigation, selectSetContentLocale, sidebar, useAdminStore, useAuthClient, useBlockScope, useCollectionCreate, useCollectionDelete, useCollectionItem, useCollectionList, useCollectionPreview, useCollectionUpdate, useCurrentUser, useFocus, useFocusOptional, useGlobal, useGlobalUpdate, useIsBlockFocused, useIsDesktop, useIsFieldFocused, useIsMobile, useMediaQuery, usePreviewContext, useResolveFieldPath, useSavedViews, useSetupStatus, useShallow, widget };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { $ as useIsBlockFocused, A as ListViewBuilder, B as useGlobal, C as AuthGuard, D as qa, E as adminModule, F as FieldBuilder, G as PreviewToggleButton, H as useCurrentUser, I as field, J as FocusProvider, K as isAdminToPreviewMessage, L as AdminLink, M as listView, N as TableView, O as coreAdminModule, P as adminMessagesSK, Q as useFocusOptional, R as FormView, S as RichTextRenderer, T as createAdminHelpers, U as createTypedHooks, V as useGlobalUpdate, W as PreviewPane, X as scrollFieldIntoView, Y as parsePreviewFieldPath, Z as useFocus, _ as AdminLayout, _t as GlobalBuilder, a as StandalonePreviewField, at as getFlagConfig, b as GlobalForm, bt as BlockBuilder, c as prefetchBlockData, ct as WidgetBuilder, d as useBlockScope, dt as SidebarBuilder, et as useIsFieldFocused, f as useResolveFieldPath, ft as section, g as AdminLayoutProvider, gt as global, h as InvitePage, ht as page, i as PreviewProvider, it as getCountryCode, j as editView, k as EditViewBuilder, l as BlockRenderer, lt as widget, m as AcceptInvitePage, mt as PageBuilder, n as PreviewBanner, nt as createBlockNode, o as usePreviewContext, ot as getFlagUrl, p as AdminRouter, pt as sidebar, q as isPreviewToAdminMessage, r as PreviewField, rt as isBlockContent, s as BlockPrefetchError, st as AdminBuilder, t as useCollectionPreview, tt as EMPTY_BLOCK_CONTENT, u as BlockScopeProvider, ut as SectionBuilder, v as AdminTopbar, vt as collection, w as AuthLoading, x as AcceptInviteForm, xt as block, y as AdminSidebar, yt as CollectionBuilder, z as useSavedViews } from "./client-BCGpkAz6.mjs";
|
|
2
|
+
import { a as selectBasePath, c as selectContentLocale, d as selectSetContentLocale, f as useAdminStore, i as selectAuthClient, l as selectNavigate, m as Admin, n as AdminProvider, o as selectBrandName, p as adminMessagesEN, r as selectAdmin, s as selectClient, u as selectNavigation } from "./content-locales-provider-BXvuIgfg.mjs";
|
|
3
|
+
import { t as AuthLayout } from "./auth-layout-M8K8_q5R.mjs";
|
|
4
|
+
import { c as useCollectionItem, i as DashboardWidget, l as useCollectionList, o as useCollectionCreate, r as DashboardGrid, s as useCollectionDelete, t as DashboardPage, u as useCollectionUpdate } from "./dashboard-page-B4PGEdc2.mjs";
|
|
5
|
+
import { t as useShallow } from "./runtime-6VZM878K.mjs";
|
|
6
|
+
import { S as useMediaQuery, b as useIsDesktop, x as useIsMobile } from "./dropzone-Do3awXKd.mjs";
|
|
7
|
+
import { n as useAuthClient, t as createAdminAuthClient } from "./use-auth-BoLmWtmU.mjs";
|
|
8
|
+
import { i as useSetupStatus, r as LoginForm, t as LoginPage } from "./login-page-CP4gA-dl.mjs";
|
|
9
|
+
import "./card-BKHjBQfw.mjs";
|
|
10
|
+
import { r as ForgotPasswordForm, t as ForgotPasswordPage } from "./forgot-password-page-Bcp-An4Y.mjs";
|
|
11
|
+
import { r as ResetPasswordForm, t as ResetPasswordPage } from "./reset-password-page-BqfDmLxA.mjs";
|
|
12
|
+
import { r as SetupForm, t as SetupPage } from "./setup-page-YAP_fzqh.mjs";
|
|
13
|
+
|
|
14
|
+
export { AcceptInviteForm, AcceptInvitePage, Admin, AdminBuilder, AdminLayout, AdminLayoutProvider, AdminLink, AdminProvider, AdminRouter, AdminSidebar, AdminTopbar, AuthGuard, AuthLayout, AuthLoading, BlockBuilder, BlockPrefetchError, BlockRenderer, BlockScopeProvider, CollectionBuilder, DashboardGrid, DashboardPage, DashboardWidget, EMPTY_BLOCK_CONTENT, EditViewBuilder, FieldBuilder, FocusProvider, ForgotPasswordForm, ForgotPasswordPage, FormView, GlobalBuilder, GlobalForm, InvitePage, ListViewBuilder, LoginForm, LoginPage, PageBuilder, PreviewBanner, PreviewField, PreviewPane, PreviewProvider, PreviewToggleButton, ResetPasswordForm, ResetPasswordPage, RichTextRenderer, SectionBuilder, SetupForm, SetupPage, SidebarBuilder, StandalonePreviewField, TableView, WidgetBuilder, adminMessagesEN, adminMessagesSK, adminModule, block, collection, coreAdminModule, createAdminAuthClient, createAdminHelpers, createBlockNode, createTypedHooks, editView, field, getCountryCode, getFlagConfig, getFlagUrl, global, isAdminToPreviewMessage, isBlockContent, isPreviewToAdminMessage, listView, page, parsePreviewFieldPath, prefetchBlockData, qa, scrollFieldIntoView, section, selectAdmin, selectAuthClient, selectBasePath, selectBrandName, selectClient, selectContentLocale, selectNavigate, selectNavigation, selectSetContentLocale, sidebar, useAdminStore, useAuthClient, useBlockScope, useCollectionCreate, useCollectionDelete, useCollectionItem, useCollectionList, useCollectionPreview, useCollectionUpdate, useCurrentUser, useFocus, useFocusOptional, useGlobal, useGlobalUpdate, useIsBlockFocused, useIsDesktop, useIsFieldFocused, useIsMobile, useMediaQuery, usePreviewContext, useResolveFieldPath, useSavedViews, useSetupStatus, useShallow, widget };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./content-locales-provider-BXvuIgfg.mjs";
|
|
2
|
+
import "./auth-layout-M8K8_q5R.mjs";
|
|
3
|
+
import "./use-auth-BoLmWtmU.mjs";
|
|
4
|
+
import { n as login_page_default, t as LoginPage } from "./login-page-CP4gA-dl.mjs";
|
|
5
|
+
import "./card-BKHjBQfw.mjs";
|
|
6
|
+
|
|
7
|
+
export { LoginPage, login_page_default as default };
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { a as selectBasePath, b as useTranslation, f as useAdminStore, g as cn, h as Button, l as selectNavigate, o as selectBrandName, s as selectClient } from "./content-locales-provider-BXvuIgfg.mjs";
|
|
2
|
+
import { a as FieldContent, c as FieldGroup, f as Input, i as Field, l as FieldLabel, n as Alert, r as AlertDescription, s as FieldError, t as AuthLayout } from "./auth-layout-M8K8_q5R.mjs";
|
|
3
|
+
import { n as useAuthClient } from "./use-auth-BoLmWtmU.mjs";
|
|
4
|
+
import { Envelope, Lock, SpinnerGap, WarningCircle } from "@phosphor-icons/react";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { useForm } from "react-hook-form";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
|
+
|
|
10
|
+
//#region src/client/hooks/use-setup-status.ts
|
|
11
|
+
/**
|
|
12
|
+
* Setup Status Hook
|
|
13
|
+
*
|
|
14
|
+
* Hook to check if the CMS setup is required (no users exist).
|
|
15
|
+
* Useful for redirecting to setup page on first visit.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Check if CMS setup is required.
|
|
19
|
+
*
|
|
20
|
+
* Returns `required: true` if no users exist in the system,
|
|
21
|
+
* meaning the setup page should be shown to create the first admin.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* function App() {
|
|
26
|
+
* const { data, isLoading } = useSetupStatus();
|
|
27
|
+
*
|
|
28
|
+
* if (isLoading) return <LoadingSpinner />;
|
|
29
|
+
*
|
|
30
|
+
* if (data?.required) {
|
|
31
|
+
* return <Navigate to="/admin/setup" />;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* return <AdminPanel />;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function useSetupStatus() {
|
|
39
|
+
const client = useAdminStore(selectClient);
|
|
40
|
+
return useQuery({
|
|
41
|
+
queryKey: ["questpie", "setup-status"],
|
|
42
|
+
queryFn: async () => {
|
|
43
|
+
try {
|
|
44
|
+
return { required: (await client.functions.isSetupRequired({})).required };
|
|
45
|
+
} catch {
|
|
46
|
+
return { required: false };
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
staleTime: 1e3 * 60,
|
|
50
|
+
retry: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/client/views/auth/login-form.tsx
|
|
56
|
+
/**
|
|
57
|
+
* Login Form - email/password authentication
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Login form with email and password fields
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* const authClient = createAdminAuthClient<typeof cms>({ baseURL: '...' })
|
|
65
|
+
*
|
|
66
|
+
* function LoginPage() {
|
|
67
|
+
* const [error, setError] = useState<string | null>(null)
|
|
68
|
+
*
|
|
69
|
+
* const handleLogin = async (values: LoginFormValues) => {
|
|
70
|
+
* const result = await authClient.signIn.email({
|
|
71
|
+
* email: values.email,
|
|
72
|
+
* password: values.password,
|
|
73
|
+
* })
|
|
74
|
+
* if (result.error) {
|
|
75
|
+
* setError(result.error.message)
|
|
76
|
+
* }
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* return (
|
|
80
|
+
* <AuthLayout title="Sign in">
|
|
81
|
+
* <LoginForm onSubmit={handleLogin} error={error} />
|
|
82
|
+
* </AuthLayout>
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function LoginForm({ onSubmit, onSignUpClick, onForgotPasswordClick, showRememberMe = false, showSignUp = true, showForgotPassword = true, defaultValues, className, error }) {
|
|
88
|
+
const { t } = useTranslation();
|
|
89
|
+
const { register, handleSubmit, formState: { errors, isSubmitting } } = useForm({ defaultValues: {
|
|
90
|
+
email: "",
|
|
91
|
+
password: "",
|
|
92
|
+
rememberMe: false,
|
|
93
|
+
...defaultValues
|
|
94
|
+
} });
|
|
95
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
96
|
+
onSubmit: handleSubmit(async (values) => {
|
|
97
|
+
await onSubmit(values);
|
|
98
|
+
}),
|
|
99
|
+
className: cn("space-y-4", className),
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsxs(FieldGroup, { children: [
|
|
102
|
+
/* @__PURE__ */ jsxs(Field, {
|
|
103
|
+
"data-invalid": !!errors.email,
|
|
104
|
+
children: [/* @__PURE__ */ jsx(FieldLabel, {
|
|
105
|
+
htmlFor: "email",
|
|
106
|
+
children: t("auth.email")
|
|
107
|
+
}), /* @__PURE__ */ jsxs(FieldContent, { children: [/* @__PURE__ */ jsxs("div", {
|
|
108
|
+
className: "relative",
|
|
109
|
+
children: [/* @__PURE__ */ jsx(Envelope, {
|
|
110
|
+
className: "text-muted-foreground absolute left-2 top-1/2 size-4 -translate-y-1/2",
|
|
111
|
+
weight: "duotone"
|
|
112
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
113
|
+
id: "email",
|
|
114
|
+
type: "email",
|
|
115
|
+
placeholder: t("auth.emailPlaceholder"),
|
|
116
|
+
className: "pl-8",
|
|
117
|
+
autoComplete: "email",
|
|
118
|
+
"aria-invalid": !!errors.email,
|
|
119
|
+
...register("email", {
|
|
120
|
+
required: t("auth.emailRequired"),
|
|
121
|
+
pattern: {
|
|
122
|
+
value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
123
|
+
message: t("auth.invalidEmail")
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
}), /* @__PURE__ */ jsx(FieldError, { children: errors.email?.message })] })]
|
|
128
|
+
}),
|
|
129
|
+
/* @__PURE__ */ jsxs(Field, {
|
|
130
|
+
"data-invalid": !!errors.password,
|
|
131
|
+
children: [/* @__PURE__ */ jsx(FieldLabel, {
|
|
132
|
+
htmlFor: "password",
|
|
133
|
+
children: t("auth.password")
|
|
134
|
+
}), /* @__PURE__ */ jsxs(FieldContent, { children: [/* @__PURE__ */ jsxs("div", {
|
|
135
|
+
className: "relative",
|
|
136
|
+
children: [/* @__PURE__ */ jsx(Lock, {
|
|
137
|
+
className: "text-muted-foreground absolute left-2 top-1/2 size-4 -translate-y-1/2",
|
|
138
|
+
weight: "duotone"
|
|
139
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
140
|
+
id: "password",
|
|
141
|
+
type: "password",
|
|
142
|
+
placeholder: t("auth.passwordPlaceholder"),
|
|
143
|
+
className: "pl-8",
|
|
144
|
+
autoComplete: "current-password",
|
|
145
|
+
"aria-invalid": !!errors.password,
|
|
146
|
+
...register("password", {
|
|
147
|
+
required: t("auth.passwordRequired"),
|
|
148
|
+
minLength: {
|
|
149
|
+
value: 6,
|
|
150
|
+
message: t("auth.passwordMinLength", { min: 6 })
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
})]
|
|
154
|
+
}), /* @__PURE__ */ jsx(FieldError, { children: errors.password?.message })] })]
|
|
155
|
+
}),
|
|
156
|
+
(showRememberMe || showForgotPassword) && /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: "flex items-center justify-between",
|
|
158
|
+
children: [showRememberMe && /* @__PURE__ */ jsxs("label", {
|
|
159
|
+
className: "text-muted-foreground flex items-center gap-2 text-xs",
|
|
160
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
161
|
+
type: "checkbox",
|
|
162
|
+
className: "rounded border-gray-300",
|
|
163
|
+
...register("rememberMe")
|
|
164
|
+
}), t("auth.rememberMe")]
|
|
165
|
+
}), showForgotPassword && /* @__PURE__ */ jsx(Button, {
|
|
166
|
+
type: "button",
|
|
167
|
+
variant: "link",
|
|
168
|
+
size: "sm",
|
|
169
|
+
onClick: onForgotPasswordClick,
|
|
170
|
+
className: "h-auto p-0 text-xs",
|
|
171
|
+
children: t("auth.forgotPassword")
|
|
172
|
+
})]
|
|
173
|
+
})
|
|
174
|
+
] }),
|
|
175
|
+
error && /* @__PURE__ */ jsxs(Alert, {
|
|
176
|
+
variant: "destructive",
|
|
177
|
+
children: [/* @__PURE__ */ jsx(WarningCircle, {}), /* @__PURE__ */ jsx(AlertDescription, { children: error })]
|
|
178
|
+
}),
|
|
179
|
+
/* @__PURE__ */ jsx(Button, {
|
|
180
|
+
type: "submit",
|
|
181
|
+
className: "w-full",
|
|
182
|
+
size: "lg",
|
|
183
|
+
disabled: isSubmitting,
|
|
184
|
+
children: isSubmitting ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SpinnerGap, {
|
|
185
|
+
className: "animate-spin",
|
|
186
|
+
weight: "bold"
|
|
187
|
+
}), t("auth.signingIn")] }) : t("auth.signIn")
|
|
188
|
+
}),
|
|
189
|
+
showSignUp && /* @__PURE__ */ jsxs("p", {
|
|
190
|
+
className: "text-muted-foreground text-center text-xs",
|
|
191
|
+
children: [
|
|
192
|
+
t("auth.dontHaveAccount"),
|
|
193
|
+
" ",
|
|
194
|
+
/* @__PURE__ */ jsx(Button, {
|
|
195
|
+
type: "button",
|
|
196
|
+
variant: "link",
|
|
197
|
+
size: "sm",
|
|
198
|
+
onClick: onSignUpClick,
|
|
199
|
+
className: "h-auto p-0 text-xs",
|
|
200
|
+
children: t("auth.signUp")
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/client/views/pages/login-page.tsx
|
|
210
|
+
/**
|
|
211
|
+
* Login Page
|
|
212
|
+
*
|
|
213
|
+
* Default login page that uses AuthLayout and LoginForm.
|
|
214
|
+
* Integrates with authClient from AdminProvider context.
|
|
215
|
+
*
|
|
216
|
+
* Automatically redirects to setup page if no users exist.
|
|
217
|
+
*/
|
|
218
|
+
/**
|
|
219
|
+
* Default login page component.
|
|
220
|
+
*
|
|
221
|
+
* Uses authClient from AdminProvider to handle authentication.
|
|
222
|
+
* Automatically redirects to setup page if no users exist.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```tsx
|
|
226
|
+
* // In your admin config
|
|
227
|
+
* const admin = qa<AppCMS>()
|
|
228
|
+
* .use(adminModule)
|
|
229
|
+
* .pages({
|
|
230
|
+
* login: page("login", { component: LoginPage }).path("/login"),
|
|
231
|
+
* })
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
function LoginPage({ title = "Sign in", description = "Enter your credentials to access the admin panel", logo, redirectTo, forgotPasswordPath, signUpPath, showForgotPassword = true, showSignUp = false }) {
|
|
235
|
+
const authClient = useAuthClient();
|
|
236
|
+
const navigate = useAdminStore(selectNavigate);
|
|
237
|
+
const basePath = useAdminStore(selectBasePath);
|
|
238
|
+
const brandName = useAdminStore(selectBrandName);
|
|
239
|
+
const [error, setError] = React$1.useState(null);
|
|
240
|
+
const { data: setupStatus, isLoading: isCheckingSetup } = useSetupStatus();
|
|
241
|
+
React$1.useEffect(() => {
|
|
242
|
+
if (!isCheckingSetup && setupStatus?.required) navigate(`${basePath}/setup`);
|
|
243
|
+
}, [
|
|
244
|
+
isCheckingSetup,
|
|
245
|
+
setupStatus,
|
|
246
|
+
navigate,
|
|
247
|
+
basePath
|
|
248
|
+
]);
|
|
249
|
+
const handleSubmit = async (values) => {
|
|
250
|
+
setError(null);
|
|
251
|
+
try {
|
|
252
|
+
const result = await authClient.signIn.email({
|
|
253
|
+
email: values.email,
|
|
254
|
+
password: values.password
|
|
255
|
+
});
|
|
256
|
+
if (result.error) {
|
|
257
|
+
setError(result.error.message || "Invalid credentials");
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
navigate(redirectTo ?? basePath);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const handleForgotPasswordClick = () => {
|
|
266
|
+
navigate(forgotPasswordPath ?? `${basePath}/forgot-password`);
|
|
267
|
+
};
|
|
268
|
+
const handleSignUpClick = () => {
|
|
269
|
+
if (signUpPath) navigate(signUpPath);
|
|
270
|
+
};
|
|
271
|
+
return /* @__PURE__ */ jsx(AuthLayout, {
|
|
272
|
+
title,
|
|
273
|
+
description,
|
|
274
|
+
logo: logo ?? /* @__PURE__ */ jsx(DefaultLogo, { brandName }),
|
|
275
|
+
children: /* @__PURE__ */ jsx(LoginForm, {
|
|
276
|
+
onSubmit: handleSubmit,
|
|
277
|
+
onForgotPasswordClick: handleForgotPasswordClick,
|
|
278
|
+
onSignUpClick: handleSignUpClick,
|
|
279
|
+
showForgotPassword,
|
|
280
|
+
showSignUp,
|
|
281
|
+
error
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function DefaultLogo({ brandName }) {
|
|
286
|
+
return /* @__PURE__ */ jsx("div", {
|
|
287
|
+
className: "text-center",
|
|
288
|
+
children: /* @__PURE__ */ jsx("h1", {
|
|
289
|
+
className: "text-xl font-bold",
|
|
290
|
+
children: brandName
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
var login_page_default = LoginPage;
|
|
295
|
+
|
|
296
|
+
//#endregion
|
|
297
|
+
export { useSetupStatus as i, login_page_default as n, LoginForm as r, LoginPage as t };
|
|
298
|
+
//# sourceMappingURL=login-page-CP4gA-dl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-page-CP4gA-dl.mjs","names":["React"],"sources":["../src/client/hooks/use-setup-status.ts","../src/client/views/auth/login-form.tsx","../src/client/views/pages/login-page.tsx"],"sourcesContent":["/**\n * Setup Status Hook\n *\n * Hook to check if the CMS setup is required (no users exist).\n * Useful for redirecting to setup page on first visit.\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { selectClient, useAdminStore } from \"../runtime/provider\";\n\nexport interface SetupStatus {\n /** Whether setup is required (no users exist) */\n required: boolean;\n}\n\n/**\n * Check if CMS setup is required.\n *\n * Returns `required: true` if no users exist in the system,\n * meaning the setup page should be shown to create the first admin.\n *\n * @example\n * ```tsx\n * function App() {\n * const { data, isLoading } = useSetupStatus();\n *\n * if (isLoading) return <LoadingSpinner />;\n *\n * if (data?.required) {\n * return <Navigate to=\"/admin/setup\" />;\n * }\n *\n * return <AdminPanel />;\n * }\n * ```\n */\nexport function useSetupStatus() {\n const client = useAdminStore(selectClient);\n\n return useQuery<SetupStatus>({\n queryKey: [\"questpie\", \"setup-status\"],\n queryFn: async () => {\n try {\n const result = await (client as any).functions.isSetupRequired({});\n return { required: result.required };\n } catch {\n // If the function doesn't exist, setup is not required\n return { required: false };\n }\n },\n staleTime: 1000 * 60, // Cache for 1 minute\n retry: false,\n });\n}\n","/**\n * Login Form - email/password authentication\n */\n\nimport {\n\tEnvelope,\n\tLock,\n\tSpinnerGap,\n\tWarningCircle,\n} from \"@phosphor-icons/react\";\nimport * as React from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { Alert, AlertDescription } from \"../../components/ui/alert\";\nimport { Button } from \"../../components/ui/button\";\nimport {\n\tField,\n\tFieldContent,\n\tFieldDescription,\n\tFieldError,\n\tFieldGroup,\n\tFieldLabel,\n} from \"../../components/ui/field\";\nimport { Input } from \"../../components/ui/input\";\nimport { useTranslation } from \"../../i18n/hooks\";\nimport { cn } from \"../../lib/utils\";\n\nexport type LoginFormValues = {\n\temail: string;\n\tpassword: string;\n\trememberMe?: boolean;\n};\n\nexport type LoginFormProps = {\n\t/** Called when form is submitted with valid data */\n\tonSubmit: (values: LoginFormValues) => Promise<void>;\n\t/** Called when sign up link is clicked */\n\tonSignUpClick?: () => void;\n\t/** Called when forgot password link is clicked */\n\tonForgotPasswordClick?: () => void;\n\t/** Show remember me checkbox */\n\tshowRememberMe?: boolean;\n\t/** Show sign up link */\n\tshowSignUp?: boolean;\n\t/** Show forgot password link */\n\tshowForgotPassword?: boolean;\n\t/** Default values */\n\tdefaultValues?: Partial<LoginFormValues>;\n\t/** Additional class name */\n\tclassName?: string;\n\t/** Error message from auth */\n\terror?: string | null;\n};\n\n/**\n * Login form with email and password fields\n *\n * @example\n * ```tsx\n * const authClient = createAdminAuthClient<typeof cms>({ baseURL: '...' })\n *\n * function LoginPage() {\n * const [error, setError] = useState<string | null>(null)\n *\n * const handleLogin = async (values: LoginFormValues) => {\n * const result = await authClient.signIn.email({\n * email: values.email,\n * password: values.password,\n * })\n * if (result.error) {\n * setError(result.error.message)\n * }\n * }\n *\n * return (\n * <AuthLayout title=\"Sign in\">\n * <LoginForm onSubmit={handleLogin} error={error} />\n * </AuthLayout>\n * )\n * }\n * ```\n */\nexport function LoginForm({\n\tonSubmit,\n\tonSignUpClick,\n\tonForgotPasswordClick,\n\tshowRememberMe = false,\n\tshowSignUp = true,\n\tshowForgotPassword = true,\n\tdefaultValues,\n\tclassName,\n\terror,\n}: LoginFormProps) {\n\tconst { t } = useTranslation();\n\tconst {\n\t\tregister,\n\t\thandleSubmit,\n\t\tformState: { errors, isSubmitting },\n\t} = useForm<LoginFormValues>({\n\t\tdefaultValues: {\n\t\t\temail: \"\",\n\t\t\tpassword: \"\",\n\t\t\trememberMe: false,\n\t\t\t...defaultValues,\n\t\t},\n\t});\n\n\tconst handleFormSubmit = handleSubmit(async (values) => {\n\t\tawait onSubmit(values);\n\t});\n\n\treturn (\n\t\t<form onSubmit={handleFormSubmit} className={cn(\"space-y-4\", className)}>\n\t\t\t<FieldGroup>\n\t\t\t\t{/* Email Field */}\n\t\t\t\t<Field data-invalid={!!errors.email}>\n\t\t\t\t\t<FieldLabel htmlFor=\"email\">{t(\"auth.email\")}</FieldLabel>\n\t\t\t\t\t<FieldContent>\n\t\t\t\t\t\t<div className=\"relative\">\n\t\t\t\t\t\t\t<Envelope\n\t\t\t\t\t\t\t\tclassName=\"text-muted-foreground absolute left-2 top-1/2 size-4 -translate-y-1/2\"\n\t\t\t\t\t\t\t\tweight=\"duotone\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tid=\"email\"\n\t\t\t\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t\t\t\tplaceholder={t(\"auth.emailPlaceholder\")}\n\t\t\t\t\t\t\t\tclassName=\"pl-8\"\n\t\t\t\t\t\t\t\tautoComplete=\"email\"\n\t\t\t\t\t\t\t\taria-invalid={!!errors.email}\n\t\t\t\t\t\t\t\t{...register(\"email\", {\n\t\t\t\t\t\t\t\t\trequired: t(\"auth.emailRequired\"),\n\t\t\t\t\t\t\t\t\tpattern: {\n\t\t\t\t\t\t\t\t\t\tvalue: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\n\t\t\t\t\t\t\t\t\t\tmessage: t(\"auth.invalidEmail\"),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<FieldError>{errors.email?.message}</FieldError>\n\t\t\t\t\t</FieldContent>\n\t\t\t\t</Field>\n\n\t\t\t\t{/* Password Field */}\n\t\t\t\t<Field data-invalid={!!errors.password}>\n\t\t\t\t\t<FieldLabel htmlFor=\"password\">{t(\"auth.password\")}</FieldLabel>\n\t\t\t\t\t<FieldContent>\n\t\t\t\t\t\t<div className=\"relative\">\n\t\t\t\t\t\t\t<Lock\n\t\t\t\t\t\t\t\tclassName=\"text-muted-foreground absolute left-2 top-1/2 size-4 -translate-y-1/2\"\n\t\t\t\t\t\t\t\tweight=\"duotone\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tid=\"password\"\n\t\t\t\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t\t\t\tplaceholder={t(\"auth.passwordPlaceholder\")}\n\t\t\t\t\t\t\t\tclassName=\"pl-8\"\n\t\t\t\t\t\t\t\tautoComplete=\"current-password\"\n\t\t\t\t\t\t\t\taria-invalid={!!errors.password}\n\t\t\t\t\t\t\t\t{...register(\"password\", {\n\t\t\t\t\t\t\t\t\trequired: t(\"auth.passwordRequired\"),\n\t\t\t\t\t\t\t\t\tminLength: {\n\t\t\t\t\t\t\t\t\t\tvalue: 6,\n\t\t\t\t\t\t\t\t\t\tmessage: t(\"auth.passwordMinLength\", { min: 6 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<FieldError>{errors.password?.message}</FieldError>\n\t\t\t\t\t</FieldContent>\n\t\t\t\t</Field>\n\n\t\t\t\t{/* Remember Me & Forgot Password */}\n\t\t\t\t{(showRememberMe || showForgotPassword) && (\n\t\t\t\t\t<div className=\"flex items-center justify-between\">\n\t\t\t\t\t\t{showRememberMe && (\n\t\t\t\t\t\t\t<label className=\"text-muted-foreground flex items-center gap-2 text-xs\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\t\tclassName=\"rounded border-gray-300\"\n\t\t\t\t\t\t\t\t\t{...register(\"rememberMe\")}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{t(\"auth.rememberMe\")}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{showForgotPassword && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\t\t\tonClick={onForgotPasswordClick}\n\t\t\t\t\t\t\t\tclassName=\"h-auto p-0 text-xs\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(\"auth.forgotPassword\")}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</FieldGroup>\n\n\t\t\t{/* Error Message */}\n\t\t\t{error && (\n\t\t\t\t<Alert variant=\"destructive\">\n\t\t\t\t\t<WarningCircle />\n\t\t\t\t\t<AlertDescription>{error}</AlertDescription>\n\t\t\t\t</Alert>\n\t\t\t)}\n\n\t\t\t{/* Submit Button */}\n\t\t\t<Button\n\t\t\t\ttype=\"submit\"\n\t\t\t\tclassName=\"w-full\"\n\t\t\t\tsize=\"lg\"\n\t\t\t\tdisabled={isSubmitting}\n\t\t\t>\n\t\t\t\t{isSubmitting ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<SpinnerGap className=\"animate-spin\" weight=\"bold\" />\n\t\t\t\t\t\t{t(\"auth.signingIn\")}\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tt(\"auth.signIn\")\n\t\t\t\t)}\n\t\t\t</Button>\n\n\t\t\t{/* Sign Up Link */}\n\t\t\t{showSignUp && (\n\t\t\t\t<p className=\"text-muted-foreground text-center text-xs\">\n\t\t\t\t\t{t(\"auth.dontHaveAccount\")}{\" \"}\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\tonClick={onSignUpClick}\n\t\t\t\t\t\tclassName=\"h-auto p-0 text-xs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{t(\"auth.signUp\")}\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t)}\n\t\t</form>\n\t);\n}\n","/**\n * Login Page\n *\n * Default login page that uses AuthLayout and LoginForm.\n * Integrates with authClient from AdminProvider context.\n *\n * Automatically redirects to setup page if no users exist.\n */\n\nimport * as React from \"react\";\nimport { useAuthClient } from \"../../hooks/use-auth\";\nimport { useSetupStatus } from \"../../hooks/use-setup-status\";\nimport {\n selectBasePath,\n selectBrandName,\n selectNavigate,\n useAdminStore,\n} from \"../../runtime/provider\";\nimport { AuthLayout } from \"../auth/auth-layout\";\nimport { LoginForm, type LoginFormValues } from \"../auth/login-form\";\n\nexport interface LoginPageProps {\n /**\n * Title shown on the login page\n * @default \"Sign in\"\n */\n title?: string;\n\n /**\n * Description shown below the title\n * @default \"Enter your credentials to access the admin panel\"\n */\n description?: string;\n\n /**\n * Logo component to show above the form\n */\n logo?: React.ReactNode;\n\n /**\n * Path to redirect after successful login\n * @default basePath (e.g., \"/admin\")\n */\n redirectTo?: string;\n\n /**\n * Path to forgot password page\n * @default \"{basePath}/forgot-password\"\n */\n forgotPasswordPath?: string;\n\n /**\n * Path to sign up page (if enabled)\n */\n signUpPath?: string;\n\n /**\n * Show forgot password link\n * @default true\n */\n showForgotPassword?: boolean;\n\n /**\n * Show sign up link\n * @default false\n */\n showSignUp?: boolean;\n}\n\n/**\n * Default login page component.\n *\n * Uses authClient from AdminProvider to handle authentication.\n * Automatically redirects to setup page if no users exist.\n *\n * @example\n * ```tsx\n * // In your admin config\n * const admin = qa<AppCMS>()\n * .use(adminModule)\n * .pages({\n * login: page(\"login\", { component: LoginPage }).path(\"/login\"),\n * })\n * ```\n */\nexport function LoginPage({\n title = \"Sign in\",\n description = \"Enter your credentials to access the admin panel\",\n logo,\n redirectTo,\n forgotPasswordPath,\n signUpPath,\n showForgotPassword = true,\n showSignUp = false,\n}: LoginPageProps) {\n const authClient = useAuthClient();\n const navigate = useAdminStore(selectNavigate);\n const basePath = useAdminStore(selectBasePath);\n const brandName = useAdminStore(selectBrandName);\n\n const [error, setError] = React.useState<string | null>(null);\n\n // Check if setup is required (no users exist)\n const { data: setupStatus, isLoading: isCheckingSetup } = useSetupStatus();\n\n // Redirect to setup page if no users exist\n React.useEffect(() => {\n if (!isCheckingSetup && setupStatus?.required) {\n navigate(`${basePath}/setup`);\n }\n }, [isCheckingSetup, setupStatus, navigate, basePath]);\n\n const handleSubmit = async (values: LoginFormValues) => {\n setError(null);\n\n try {\n const result = await authClient.signIn.email({\n email: values.email,\n password: values.password,\n });\n\n if (result.error) {\n setError(result.error.message || \"Invalid credentials\");\n return;\n }\n\n // Redirect on success\n navigate(redirectTo ?? basePath);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"An error occurred\");\n }\n };\n\n const handleForgotPasswordClick = () => {\n navigate(forgotPasswordPath ?? `${basePath}/forgot-password`);\n };\n\n const handleSignUpClick = () => {\n if (signUpPath) {\n navigate(signUpPath);\n }\n };\n\n return (\n <AuthLayout\n title={title}\n description={description}\n logo={logo ?? <DefaultLogo brandName={brandName} />}\n >\n <LoginForm\n onSubmit={handleSubmit}\n onForgotPasswordClick={handleForgotPasswordClick}\n onSignUpClick={handleSignUpClick}\n showForgotPassword={showForgotPassword}\n showSignUp={showSignUp}\n error={error}\n />\n </AuthLayout>\n );\n}\n\nfunction DefaultLogo({ brandName }: { brandName: string }) {\n return (\n <div className=\"text-center\">\n <h1 className=\"text-xl font-bold\">{brandName}</h1>\n </div>\n );\n}\n\nexport default LoginPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiB;CAC/B,MAAM,SAAS,cAAc,aAAa;AAE1C,QAAO,SAAsB;EAC3B,UAAU,CAAC,YAAY,eAAe;EACtC,SAAS,YAAY;AACnB,OAAI;AAEF,WAAO,EAAE,WADM,MAAO,OAAe,UAAU,gBAAgB,EAAE,CAAC,EACxC,UAAU;WAC9B;AAEN,WAAO,EAAE,UAAU,OAAO;;;EAG9B,WAAW,MAAO;EAClB,OAAO;EACR,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6BJ,SAAgB,UAAU,EACzB,UACA,eAC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U;EAAS,CAAC;CAEtD,MAAM,eAAe,OAAO,WAA4B;AACtD,WAAS,KAAK;AAEd,MAAI;GACF,MAAM,SAAS,MAAM,WAAW,OAAO,MAAM;IAC3C,OAAO,OAAO;IACd,UAAU,OAAO;IAClB,CAAC;AAEF,OAAI,OAAO,OAAO;AAChB,aAAS,OAAO,MAAM,WAAW,sBAAsB;AACvD;;AAIF,YAAS,cAAc,SAAS;WACzB,KAAK;AACZ,YAAS,eAAe,QAAQ,IAAI,UAAU,oBAAoB;;;CAItE,MAAM,kCAAkC;AACtC,WAAS,sBAAsB,GAAG,SAAS,kBAAkB;;CAG/D,MAAM,0BAA0B;AAC9B,MAAI,WACF,UAAS,WAAW;;AAIxB,QACE,oBAAC;EACQ;EACM;EACb,MAAM,QAAQ,oBAAC,eAAuB,YAAa;YAEnD,oBAAC;GACC,UAAU;GACV,uBAAuB;GACvB,eAAe;GACK;GACR;GACL;IACP;GACS;;AAIjB,SAAS,YAAY,EAAE,aAAoC;AACzD,QACE,oBAAC;EAAI,WAAU;YACb,oBAAC;GAAG,WAAU;aAAqB;IAAe;GAC9C;;AAIV,yBAAe"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/shared/preview-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Preview Utilities - Browser-safe
|
|
4
|
+
*
|
|
5
|
+
* Utilities that can run in both browser and server environments.
|
|
6
|
+
* No Node.js dependencies (crypto, etc.)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Cookie name for draft mode.
|
|
10
|
+
* Set by /api/preview route, checked by page loaders.
|
|
11
|
+
*/
|
|
12
|
+
const DRAFT_MODE_COOKIE = "__draft_mode";
|
|
13
|
+
/**
|
|
14
|
+
* Check if draft mode is enabled from cookie header.
|
|
15
|
+
*
|
|
16
|
+
* @param cookieHeader - The Cookie header value from request
|
|
17
|
+
* @returns true if draft mode cookie is present and set to "true"
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const isDraft = isDraftMode(request.headers.get("cookie"));
|
|
22
|
+
* const page = await cms.pages.findOne({
|
|
23
|
+
* where: isDraft ? { slug } : { slug, isPublished: true }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function isDraftMode(cookieHeader) {
|
|
28
|
+
if (!cookieHeader) return false;
|
|
29
|
+
return cookieHeader.includes(`${DRAFT_MODE_COOKIE}=true`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create Set-Cookie header value for draft mode.
|
|
33
|
+
*
|
|
34
|
+
* @param enabled - Whether to enable or disable draft mode
|
|
35
|
+
* @param maxAge - Cookie max age in seconds (default: 1 hour)
|
|
36
|
+
* @returns Set-Cookie header value
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // Enable draft mode
|
|
41
|
+
* headers.set("Set-Cookie", createDraftModeCookie(true));
|
|
42
|
+
*
|
|
43
|
+
* // Disable draft mode
|
|
44
|
+
* headers.set("Set-Cookie", createDraftModeCookie(false));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function createDraftModeCookie(enabled, maxAge = 3600) {
|
|
48
|
+
if (enabled) return `${DRAFT_MODE_COOKIE}=true; Path=/; Max-Age=${maxAge}; SameSite=Lax; HttpOnly`;
|
|
49
|
+
return `${DRAFT_MODE_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax; HttpOnly`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get preview secret from environment variables.
|
|
53
|
+
* Falls back to SECRET if PREVIEW_SECRET is not set.
|
|
54
|
+
*
|
|
55
|
+
* @returns The preview secret
|
|
56
|
+
*/
|
|
57
|
+
function getPreviewSecret() {
|
|
58
|
+
const secret = process.env.PREVIEW_SECRET || process.env.SECRET || "dev-preview-secret";
|
|
59
|
+
if (process.env.NODE_ENV === "production" && secret === "dev-preview-secret") console.warn("[preview] Using default secret in production. Set PREVIEW_SECRET or SECRET env var.");
|
|
60
|
+
return secret;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { isDraftMode as i, createDraftModeCookie as n, getPreviewSecret as r, DRAFT_MODE_COOKIE as t };
|
|
65
|
+
//# sourceMappingURL=preview-utils-BKQ9-TMa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-utils-BKQ9-TMa.mjs","names":[],"sources":["../src/shared/preview-utils.ts"],"sourcesContent":["/**\n * Preview Utilities - Browser-safe\n *\n * Utilities that can run in both browser and server environments.\n * No Node.js dependencies (crypto, etc.)\n */\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Cookie name for draft mode.\n * Set by /api/preview route, checked by page loaders.\n */\nexport const DRAFT_MODE_COOKIE = \"__draft_mode\";\n\n// ============================================================================\n// Browser-Safe Utilities\n// ============================================================================\n\n/**\n * Check if draft mode is enabled from cookie header.\n *\n * @param cookieHeader - The Cookie header value from request\n * @returns true if draft mode cookie is present and set to \"true\"\n *\n * @example\n * ```ts\n * const isDraft = isDraftMode(request.headers.get(\"cookie\"));\n * const page = await cms.pages.findOne({\n * where: isDraft ? { slug } : { slug, isPublished: true }\n * });\n * ```\n */\nexport function isDraftMode(cookieHeader: string | null | undefined): boolean {\n\tif (!cookieHeader) return false;\n\treturn cookieHeader.includes(`${DRAFT_MODE_COOKIE}=true`);\n}\n\n/**\n * Create Set-Cookie header value for draft mode.\n *\n * @param enabled - Whether to enable or disable draft mode\n * @param maxAge - Cookie max age in seconds (default: 1 hour)\n * @returns Set-Cookie header value\n *\n * @example\n * ```ts\n * // Enable draft mode\n * headers.set(\"Set-Cookie\", createDraftModeCookie(true));\n *\n * // Disable draft mode\n * headers.set(\"Set-Cookie\", createDraftModeCookie(false));\n * ```\n */\nexport function createDraftModeCookie(enabled: boolean, maxAge = 3600): string {\n\tif (enabled) {\n\t\treturn `${DRAFT_MODE_COOKIE}=true; Path=/; Max-Age=${maxAge}; SameSite=Lax; HttpOnly`;\n\t}\n\t// Delete cookie by setting Max-Age=0\n\treturn `${DRAFT_MODE_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax; HttpOnly`;\n}\n\n/**\n * Get preview secret from environment variables.\n * Falls back to SECRET if PREVIEW_SECRET is not set.\n *\n * @returns The preview secret\n */\nexport function getPreviewSecret(): string {\n\tconst secret =\n\t\tprocess.env.PREVIEW_SECRET || process.env.SECRET || \"dev-preview-secret\";\n\n\tif (\n\t\tprocess.env.NODE_ENV === \"production\" &&\n\t\tsecret === \"dev-preview-secret\"\n\t) {\n\t\tconsole.warn(\n\t\t\t\"[preview] Using default secret in production. Set PREVIEW_SECRET or SECRET env var.\",\n\t\t);\n\t}\n\n\treturn secret;\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,oBAAoB;;;;;;;;;;;;;;;AAoBjC,SAAgB,YAAY,cAAkD;AAC7E,KAAI,CAAC,aAAc,QAAO;AAC1B,QAAO,aAAa,SAAS,GAAG,kBAAkB,OAAO;;;;;;;;;;;;;;;;;;AAmB1D,SAAgB,sBAAsB,SAAkB,SAAS,MAAc;AAC9E,KAAI,QACH,QAAO,GAAG,kBAAkB,yBAAyB,OAAO;AAG7D,QAAO,GAAG,kBAAkB;;;;;;;;AAS7B,SAAgB,mBAA2B;CAC1C,MAAM,SACL,QAAQ,IAAI,kBAAkB,QAAQ,IAAI,UAAU;AAErD,KACC,QAAQ,IAAI,aAAa,gBACzB,WAAW,qBAEX,SAAQ,KACP,sFACA;AAGF,QAAO"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { a as selectBasePath, f as useAdminStore, g as cn, h as Button, l as selectNavigate, o as selectBrandName } from "./content-locales-provider-BXvuIgfg.mjs";
|
|
2
|
+
import { a as FieldContent, c as FieldGroup, f as Input, i as Field, l as FieldLabel, n as Alert, o as FieldDescription, r as AlertDescription, s as FieldError, t as AuthLayout } from "./auth-layout-M8K8_q5R.mjs";
|
|
3
|
+
import { n as useAuthClient } from "./use-auth-BoLmWtmU.mjs";
|
|
4
|
+
import { CheckCircle, Lock, SpinnerGap, WarningCircle } from "@phosphor-icons/react";
|
|
1
5
|
import * as React$1 from "react";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from "../../components/ui/button";
|
|
4
|
-
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel } from "../../components/ui/field";
|
|
5
|
-
import { Input } from "../../components/ui/input";
|
|
6
|
-
import { cn } from "../../lib/utils";
|
|
7
|
-
import { CheckCircle, Lock, SpinnerGap } from "@phosphor-icons/react";
|
|
8
6
|
import { useForm } from "react-hook-form";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
8
|
|
|
10
|
-
//#region src/views/auth/reset-password-form.tsx
|
|
9
|
+
//#region src/client/views/auth/reset-password-form.tsx
|
|
11
10
|
/**
|
|
12
11
|
* Reset Password Form - set new password with token
|
|
13
12
|
*/
|
|
@@ -58,7 +57,7 @@ function ResetPasswordForm({ token, onSubmit, onBackToLoginClick, minPasswordLen
|
|
|
58
57
|
className: cn("space-y-4 text-center", className),
|
|
59
58
|
children: [
|
|
60
59
|
/* @__PURE__ */ jsx("div", {
|
|
61
|
-
className: "bg-primary/10 mx-auto flex size-12 items-center justify-center
|
|
60
|
+
className: "bg-primary/10 mx-auto flex size-12 items-center justify-center",
|
|
62
61
|
children: /* @__PURE__ */ jsx(CheckCircle, {
|
|
63
62
|
className: "text-primary size-6",
|
|
64
63
|
weight: "duotone"
|
|
@@ -149,9 +148,9 @@ function ResetPasswordForm({ token, onSubmit, onBackToLoginClick, minPasswordLen
|
|
|
149
148
|
})]
|
|
150
149
|
}), /* @__PURE__ */ jsx(FieldError, { children: errors.confirmPassword?.message })] })]
|
|
151
150
|
})] }),
|
|
152
|
-
error && /* @__PURE__ */
|
|
153
|
-
|
|
154
|
-
children: error
|
|
151
|
+
error && /* @__PURE__ */ jsxs(Alert, {
|
|
152
|
+
variant: "destructive",
|
|
153
|
+
children: [/* @__PURE__ */ jsx(WarningCircle, {}), /* @__PURE__ */ jsx(AlertDescription, { children: error })]
|
|
155
154
|
}),
|
|
156
155
|
/* @__PURE__ */ jsx(Button, {
|
|
157
156
|
type: "submit",
|
|
@@ -168,10 +167,12 @@ function ResetPasswordForm({ token, onSubmit, onBackToLoginClick, minPasswordLen
|
|
|
168
167
|
children: [
|
|
169
168
|
"Remember your password?",
|
|
170
169
|
" ",
|
|
171
|
-
/* @__PURE__ */ jsx(
|
|
170
|
+
/* @__PURE__ */ jsx(Button, {
|
|
172
171
|
type: "button",
|
|
172
|
+
variant: "link",
|
|
173
|
+
size: "sm",
|
|
173
174
|
onClick: onBackToLoginClick,
|
|
174
|
-
className: "text-
|
|
175
|
+
className: "h-auto p-0 text-xs",
|
|
175
176
|
children: "Back to login"
|
|
176
177
|
})
|
|
177
178
|
]
|
|
@@ -181,4 +182,100 @@ function ResetPasswordForm({ token, onSubmit, onBackToLoginClick, minPasswordLen
|
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
//#endregion
|
|
184
|
-
|
|
185
|
+
//#region src/client/views/pages/reset-password-page.tsx
|
|
186
|
+
/**
|
|
187
|
+
* Reset Password Page
|
|
188
|
+
*
|
|
189
|
+
* Default reset password page that uses AuthLayout and ResetPasswordForm.
|
|
190
|
+
* Integrates with authClient from AdminProvider context.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Default reset password page component.
|
|
194
|
+
*
|
|
195
|
+
* Uses authClient from AdminProvider to handle password reset.
|
|
196
|
+
* Expects a token in the URL query params (?token=...).
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```tsx
|
|
200
|
+
* // In your admin config
|
|
201
|
+
* const admin = qa<AppCMS>()
|
|
202
|
+
* .use(coreAdminModule)
|
|
203
|
+
* .pages({
|
|
204
|
+
* resetPassword: page("reset-password", { component: ResetPasswordPage })
|
|
205
|
+
* .path("/reset-password"),
|
|
206
|
+
* })
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
function ResetPasswordPage({ title = "Reset password", description = "Enter your new password", logo, loginPath, minPasswordLength = 8, getToken }) {
|
|
210
|
+
const authClient = useAuthClient();
|
|
211
|
+
const navigate = useAdminStore(selectNavigate);
|
|
212
|
+
const basePath = useAdminStore(selectBasePath);
|
|
213
|
+
const brandName = useAdminStore(selectBrandName);
|
|
214
|
+
const [error, setError] = React$1.useState(null);
|
|
215
|
+
const token = React$1.useMemo(() => {
|
|
216
|
+
if (getToken) return getToken();
|
|
217
|
+
if (typeof window !== "undefined") return new URLSearchParams(window.location.search).get("token");
|
|
218
|
+
return null;
|
|
219
|
+
}, [getToken]);
|
|
220
|
+
const handleSubmit = async (values) => {
|
|
221
|
+
setError(null);
|
|
222
|
+
try {
|
|
223
|
+
const result = await authClient.resetPassword({
|
|
224
|
+
token: values.token,
|
|
225
|
+
newPassword: values.password
|
|
226
|
+
});
|
|
227
|
+
if (result.error) {
|
|
228
|
+
setError(result.error.message || "Failed to reset password");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
} catch (err) {
|
|
232
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const handleBackToLoginClick = () => {
|
|
236
|
+
navigate(loginPath ?? `${basePath}/login`);
|
|
237
|
+
};
|
|
238
|
+
if (!token) return /* @__PURE__ */ jsx(AuthLayout, {
|
|
239
|
+
title: "Invalid Link",
|
|
240
|
+
description: "The password reset link is invalid or has expired.",
|
|
241
|
+
logo: logo ?? /* @__PURE__ */ jsx(DefaultLogo, { brandName }),
|
|
242
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
243
|
+
className: "space-y-4 text-center",
|
|
244
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
245
|
+
className: "text-muted-foreground text-sm",
|
|
246
|
+
children: "Please request a new password reset link."
|
|
247
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
248
|
+
type: "button",
|
|
249
|
+
variant: "link",
|
|
250
|
+
onClick: handleBackToLoginClick,
|
|
251
|
+
children: "Back to login"
|
|
252
|
+
})]
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
return /* @__PURE__ */ jsx(AuthLayout, {
|
|
256
|
+
title,
|
|
257
|
+
description,
|
|
258
|
+
logo: logo ?? /* @__PURE__ */ jsx(DefaultLogo, { brandName }),
|
|
259
|
+
children: /* @__PURE__ */ jsx(ResetPasswordForm, {
|
|
260
|
+
token,
|
|
261
|
+
onSubmit: handleSubmit,
|
|
262
|
+
onBackToLoginClick: handleBackToLoginClick,
|
|
263
|
+
minPasswordLength,
|
|
264
|
+
error
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function DefaultLogo({ brandName }) {
|
|
269
|
+
return /* @__PURE__ */ jsx("div", {
|
|
270
|
+
className: "text-center",
|
|
271
|
+
children: /* @__PURE__ */ jsx("h1", {
|
|
272
|
+
className: "text-xl font-bold",
|
|
273
|
+
children: brandName
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
var reset_password_page_default = ResetPasswordPage;
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
export { reset_password_page_default as n, ResetPasswordForm as r, ResetPasswordPage as t };
|
|
281
|
+
//# sourceMappingURL=reset-password-page-BqfDmLxA.mjs.map
|