@questpie/admin 3.2.3 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +106 -220
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +107 -313
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -182
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +8 -19
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +196 -530
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +39 -74
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +306 -611
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +177 -494
- package/dist/client/components/preview/live-preview-mode.mjs +240 -438
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +200 -559
- package/dist/client/components/primitives/select-single.mjs +165 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.d.mts +4 -0
- package/dist/client/contexts/focus-context.mjs +87 -150
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/diff.mjs +110 -0
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +166 -409
- package/dist/client/preview/use-collection-preview.mjs +135 -201
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -400
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +109 -363
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +11 -24
- package/dist/client/views/collection/form-view.mjs +288 -560
- package/dist/client/views/collection/table-view.mjs +239 -469
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -543
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +478 -1298
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +457 -1289
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/modules/admin/collections/account.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +34 -34
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +53 -53
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/index.d.mts +21 -20
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -27
- package/package.json +3 -5
|
@@ -6,8 +6,7 @@ import { getCookie } from "../lib/cookies.mjs";
|
|
|
6
6
|
import { buildNavigation } from "./routes.mjs";
|
|
7
7
|
import { TranslationsProvider, getUiLocaleFromCookie as getUiLocaleFromCookie$1 } from "./translations-provider.mjs";
|
|
8
8
|
import { ContentLocalesProvider } from "./content-locales-provider.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
9
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
11
10
|
import { DEFAULT_LOCALE } from "questpie/shared";
|
|
12
11
|
import { createStore, useStore } from "zustand";
|
|
13
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -70,47 +69,22 @@ function mergeMessages(baseMessages, customTranslations) {
|
|
|
70
69
|
};
|
|
71
70
|
return result;
|
|
72
71
|
}
|
|
73
|
-
function LegacyI18nProvider(
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
locales: localeConfig.supported ?? [DEFAULT_LOCALE],
|
|
84
|
-
messages,
|
|
85
|
-
fallbackLocale: defaultLocale,
|
|
86
|
-
onLocaleChange: setUiLocaleCookie
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
$[0] = admin;
|
|
90
|
-
$[1] = customI18nAdapter;
|
|
91
|
-
$[2] = defaultLocale;
|
|
92
|
-
$[3] = locale;
|
|
93
|
-
$[4] = localeConfig;
|
|
94
|
-
$[5] = t1;
|
|
95
|
-
} else t1 = $[5];
|
|
96
|
-
const [i18nAdapter] = useState(t1);
|
|
97
|
-
let t2;
|
|
98
|
-
if ($[6] !== children) {
|
|
99
|
-
t2 = /* @__PURE__ */ jsx(ContentLocalesProvider, { children });
|
|
100
|
-
$[6] = children;
|
|
101
|
-
$[7] = t2;
|
|
102
|
-
} else t2 = $[7];
|
|
103
|
-
let t3;
|
|
104
|
-
if ($[8] !== i18nAdapter || $[9] !== t2) {
|
|
105
|
-
t3 = /* @__PURE__ */ jsx(I18nProvider, {
|
|
106
|
-
adapter: i18nAdapter,
|
|
107
|
-
children: t2
|
|
72
|
+
function LegacyI18nProvider({ admin, locale, localeConfig, defaultLocale, customI18nAdapter, children }) {
|
|
73
|
+
const [i18nAdapter] = useState(() => {
|
|
74
|
+
if (customI18nAdapter) return customI18nAdapter;
|
|
75
|
+
const messages = mergeMessages(adminMessages, admin.getTranslations());
|
|
76
|
+
return createSimpleI18n({
|
|
77
|
+
locale,
|
|
78
|
+
locales: localeConfig.supported ?? [DEFAULT_LOCALE],
|
|
79
|
+
messages,
|
|
80
|
+
fallbackLocale: defaultLocale,
|
|
81
|
+
onLocaleChange: setUiLocaleCookie
|
|
108
82
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
83
|
+
});
|
|
84
|
+
return /* @__PURE__ */ jsx(I18nProvider, {
|
|
85
|
+
adapter: i18nAdapter,
|
|
86
|
+
children: /* @__PURE__ */ jsx(ContentLocalesProvider, { children })
|
|
87
|
+
});
|
|
114
88
|
}
|
|
115
89
|
/**
|
|
116
90
|
* Admin provider component
|
|
@@ -138,187 +112,72 @@ function LegacyI18nProvider(t0) {
|
|
|
138
112
|
* }
|
|
139
113
|
* ```
|
|
140
114
|
*/
|
|
141
|
-
function AdminProvider(
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} else t3 = $[1];
|
|
152
|
-
const admin = t3;
|
|
153
|
-
let t4;
|
|
154
|
-
if ($[2] !== navigateProp) {
|
|
155
|
-
t4 = (path) => {
|
|
156
|
-
if (navigateProp) {
|
|
157
|
-
navigateProp(path);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (typeof window !== "undefined") window.location.href = path;
|
|
161
|
-
};
|
|
162
|
-
$[2] = navigateProp;
|
|
163
|
-
$[3] = t4;
|
|
164
|
-
} else t4 = $[3];
|
|
165
|
-
const navigate = t4;
|
|
166
|
-
let t5;
|
|
167
|
-
if ($[4] !== admin) {
|
|
168
|
-
t5 = admin.getLocale();
|
|
169
|
-
$[4] = admin;
|
|
170
|
-
$[5] = t5;
|
|
171
|
-
} else t5 = $[5];
|
|
172
|
-
const localeConfig = t5;
|
|
115
|
+
function AdminProvider({ admin: adminInput, client, authClient, basePath = "/admin", realtime, navigate: navigateProp, initialUiLocale, initialContentLocale, i18nAdapter: customI18nAdapter, useServerTranslations = false, translationsFallback, children }) {
|
|
116
|
+
const admin = useMemo(() => Admin.normalize(adminInput), [adminInput]);
|
|
117
|
+
const navigate = useCallback((path) => {
|
|
118
|
+
if (navigateProp) {
|
|
119
|
+
navigateProp(path);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (typeof window !== "undefined") window.location.href = path;
|
|
123
|
+
}, [navigateProp]);
|
|
124
|
+
const localeConfig = admin.getLocale();
|
|
173
125
|
const defaultLocale = localeConfig.default ?? DEFAULT_LOCALE;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
patch.basePath = basePath;
|
|
230
|
-
patch.navigation = buildNavigation(admin, { basePath });
|
|
231
|
-
}
|
|
232
|
-
if (current.client !== client) patch.client = client;
|
|
233
|
-
if (current.authClient !== nextAuthClient) patch.authClient = nextAuthClient;
|
|
234
|
-
if (current.navigate !== navigate) patch.navigate = navigate;
|
|
235
|
-
if (current.realtime.enabled !== realtimeConfig.enabled) patch.realtime = realtimeConfig;
|
|
236
|
-
if (Object.keys(patch).length > 0) store.setState(patch);
|
|
237
|
-
};
|
|
238
|
-
t12 = [
|
|
239
|
-
admin,
|
|
240
|
-
basePath,
|
|
241
|
-
realtimeConfig,
|
|
242
|
-
client,
|
|
243
|
-
authClient,
|
|
244
|
-
navigate,
|
|
245
|
-
store
|
|
246
|
-
];
|
|
247
|
-
$[23] = admin;
|
|
248
|
-
$[24] = authClient;
|
|
249
|
-
$[25] = basePath;
|
|
250
|
-
$[26] = client;
|
|
251
|
-
$[27] = navigate;
|
|
252
|
-
$[28] = realtimeConfig;
|
|
253
|
-
$[29] = store;
|
|
254
|
-
$[30] = t11;
|
|
255
|
-
$[31] = t12;
|
|
256
|
-
} else {
|
|
257
|
-
t11 = $[30];
|
|
258
|
-
t12 = $[31];
|
|
259
|
-
}
|
|
260
|
-
useEffect(t11, t12);
|
|
261
|
-
const contentLocale = useStore(store, _temp);
|
|
262
|
-
let t13;
|
|
263
|
-
let t14;
|
|
264
|
-
if ($[32] !== client || $[33] !== contentLocale) {
|
|
265
|
-
t13 = () => {
|
|
266
|
-
if (client && contentLocale && "setLocale" in client) client.setLocale(contentLocale);
|
|
267
|
-
};
|
|
268
|
-
t14 = [client, contentLocale];
|
|
269
|
-
$[32] = client;
|
|
270
|
-
$[33] = contentLocale;
|
|
271
|
-
$[34] = t13;
|
|
272
|
-
$[35] = t14;
|
|
273
|
-
} else {
|
|
274
|
-
t13 = $[34];
|
|
275
|
-
t14 = $[35];
|
|
276
|
-
}
|
|
277
|
-
useEffect(t13, t14);
|
|
278
|
-
let t15;
|
|
279
|
-
if ($[36] !== admin || $[37] !== children || $[38] !== customI18nAdapter || $[39] !== defaultLocale || $[40] !== localeConfig || $[41] !== resolvedUiLocale || $[42] !== translationsFallback || $[43] !== useServerTranslations) {
|
|
280
|
-
t15 = useServerTranslations ? /* @__PURE__ */ jsx(TranslationsProvider, {
|
|
281
|
-
initialLocale: resolvedUiLocale,
|
|
282
|
-
fallback: translationsFallback,
|
|
283
|
-
children: /* @__PURE__ */ jsx(ContentLocalesProvider, { children })
|
|
284
|
-
}) : /* @__PURE__ */ jsx(LegacyI18nProvider, {
|
|
285
|
-
admin,
|
|
286
|
-
locale: resolvedUiLocale,
|
|
287
|
-
localeConfig,
|
|
288
|
-
defaultLocale,
|
|
289
|
-
customI18nAdapter,
|
|
290
|
-
children
|
|
291
|
-
});
|
|
292
|
-
$[36] = admin;
|
|
293
|
-
$[37] = children;
|
|
294
|
-
$[38] = customI18nAdapter;
|
|
295
|
-
$[39] = defaultLocale;
|
|
296
|
-
$[40] = localeConfig;
|
|
297
|
-
$[41] = resolvedUiLocale;
|
|
298
|
-
$[42] = translationsFallback;
|
|
299
|
-
$[43] = useServerTranslations;
|
|
300
|
-
$[44] = t15;
|
|
301
|
-
} else t15 = $[44];
|
|
302
|
-
const i18nContent = t15;
|
|
303
|
-
let t16;
|
|
304
|
-
if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
|
|
305
|
-
t16 = /* @__PURE__ */ jsx(BrandingSync, {});
|
|
306
|
-
$[45] = t16;
|
|
307
|
-
} else t16 = $[45];
|
|
308
|
-
let t17;
|
|
309
|
-
if ($[46] !== i18nContent || $[47] !== store) {
|
|
310
|
-
t17 = /* @__PURE__ */ jsxs(AdminStoreContext.Provider, {
|
|
311
|
-
value: store,
|
|
312
|
-
children: [t16, i18nContent]
|
|
313
|
-
});
|
|
314
|
-
$[46] = i18nContent;
|
|
315
|
-
$[47] = store;
|
|
316
|
-
$[48] = t17;
|
|
317
|
-
} else t17 = $[48];
|
|
318
|
-
return t17;
|
|
319
|
-
}
|
|
320
|
-
function _temp(s) {
|
|
321
|
-
return s.contentLocale;
|
|
126
|
+
const resolvedUiLocale = useServerTranslations ? initialUiLocale ?? getUiLocaleFromCookie$1() ?? defaultLocale : initialUiLocale ?? getUiLocaleFromCookie() ?? defaultLocale;
|
|
127
|
+
const resolvedContentLocale = initialContentLocale ?? getContentLocaleFromCookie() ?? defaultLocale;
|
|
128
|
+
const realtimeConfig = useMemo(() => ({ enabled: typeof realtime === "boolean" ? realtime : realtime?.enabled ?? true }), [realtime]);
|
|
129
|
+
const [store] = useState(() => createAdminStore({
|
|
130
|
+
admin,
|
|
131
|
+
client,
|
|
132
|
+
authClient: authClient ?? null,
|
|
133
|
+
basePath,
|
|
134
|
+
navigate,
|
|
135
|
+
realtime: realtimeConfig,
|
|
136
|
+
initialContentLocale: resolvedContentLocale
|
|
137
|
+
}));
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
const current = store.getState();
|
|
140
|
+
const nextAuthClient = authClient ?? null;
|
|
141
|
+
const patch = {};
|
|
142
|
+
if (current.admin !== admin || current.basePath !== basePath) {
|
|
143
|
+
patch.admin = admin;
|
|
144
|
+
patch.basePath = basePath;
|
|
145
|
+
patch.navigation = buildNavigation(admin, { basePath });
|
|
146
|
+
}
|
|
147
|
+
if (current.client !== client) patch.client = client;
|
|
148
|
+
if (current.authClient !== nextAuthClient) patch.authClient = nextAuthClient;
|
|
149
|
+
if (current.navigate !== navigate) patch.navigate = navigate;
|
|
150
|
+
if (current.realtime.enabled !== realtimeConfig.enabled) patch.realtime = realtimeConfig;
|
|
151
|
+
if (Object.keys(patch).length > 0) store.setState(patch);
|
|
152
|
+
}, [
|
|
153
|
+
admin,
|
|
154
|
+
basePath,
|
|
155
|
+
realtimeConfig,
|
|
156
|
+
client,
|
|
157
|
+
authClient,
|
|
158
|
+
navigate,
|
|
159
|
+
store
|
|
160
|
+
]);
|
|
161
|
+
const contentLocale = useStore(store, (s) => s.contentLocale);
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (client && contentLocale && "setLocale" in client) client.setLocale(contentLocale);
|
|
164
|
+
}, [client, contentLocale]);
|
|
165
|
+
const i18nContent = useServerTranslations ? /* @__PURE__ */ jsx(TranslationsProvider, {
|
|
166
|
+
initialLocale: resolvedUiLocale,
|
|
167
|
+
fallback: translationsFallback,
|
|
168
|
+
children: /* @__PURE__ */ jsx(ContentLocalesProvider, { children })
|
|
169
|
+
}) : /* @__PURE__ */ jsx(LegacyI18nProvider, {
|
|
170
|
+
admin,
|
|
171
|
+
locale: resolvedUiLocale,
|
|
172
|
+
localeConfig,
|
|
173
|
+
defaultLocale,
|
|
174
|
+
customI18nAdapter,
|
|
175
|
+
children
|
|
176
|
+
});
|
|
177
|
+
return /* @__PURE__ */ jsxs(AdminStoreContext.Provider, {
|
|
178
|
+
value: store,
|
|
179
|
+
children: [/* @__PURE__ */ jsx(BrandingSync, {}), i18nContent]
|
|
180
|
+
});
|
|
322
181
|
}
|
|
323
182
|
function resolveBrandText(value, fallback) {
|
|
324
183
|
if (typeof value === "string") return value;
|
|
@@ -343,39 +202,26 @@ function applyFavicon(href) {
|
|
|
343
202
|
link.href = href;
|
|
344
203
|
}
|
|
345
204
|
function BrandingSync() {
|
|
346
|
-
const $ = c(3);
|
|
347
205
|
const store = useContext(AdminStoreContext);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
if (!
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (Object.keys(next).length > 0) store.setState(next);
|
|
368
|
-
}).catch(_temp2);
|
|
369
|
-
};
|
|
370
|
-
t1 = [store];
|
|
371
|
-
$[0] = store;
|
|
372
|
-
$[1] = t0;
|
|
373
|
-
$[2] = t1;
|
|
374
|
-
} else {
|
|
375
|
-
t0 = $[1];
|
|
376
|
-
t1 = $[2];
|
|
377
|
-
}
|
|
378
|
-
useEffect(t0, t1);
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (!store) return;
|
|
208
|
+
const client = store.getState().client;
|
|
209
|
+
if (!client || !client.routes?.getAdminConfig) return;
|
|
210
|
+
client.routes.getAdminConfig().then((config) => {
|
|
211
|
+
const branding = config?.branding;
|
|
212
|
+
if (!branding) return;
|
|
213
|
+
const next = {};
|
|
214
|
+
if (branding.name !== void 0) next.brandName = resolveBrandText(branding.name, "Admin");
|
|
215
|
+
if (branding.logo !== void 0) next.brandLogo = branding.logo ?? null;
|
|
216
|
+
if (branding.tagline !== void 0) next.brandTagline = branding.tagline ? resolveBrandText(branding.tagline, "") : null;
|
|
217
|
+
if (branding.favicon !== void 0) {
|
|
218
|
+
const favicon = branding.favicon ?? null;
|
|
219
|
+
next.brandFavicon = favicon;
|
|
220
|
+
applyFavicon(favicon);
|
|
221
|
+
}
|
|
222
|
+
if (Object.keys(next).length > 0) store.setState(next);
|
|
223
|
+
}).catch(() => {});
|
|
224
|
+
}, [store]);
|
|
379
225
|
return null;
|
|
380
226
|
}
|
|
381
227
|
/**
|
|
@@ -396,7 +242,6 @@ function BrandingSync() {
|
|
|
396
242
|
* const navigation = useAdminStore((s) => s.navigation);
|
|
397
243
|
* ```
|
|
398
244
|
*/
|
|
399
|
-
function _temp2() {}
|
|
400
245
|
function useAdminStore(selector) {
|
|
401
246
|
const store = useContext(AdminStoreContext);
|
|
402
247
|
if (!store) throw new Error("useAdminStore must be used within AdminProvider. Wrap your app with <AdminProvider admin={admin} client={client}>");
|
|
@@ -2,8 +2,7 @@ import { I18nProvider } from "../i18n/hooks.mjs";
|
|
|
2
2
|
import { createSimpleI18n } from "../i18n/simple.mjs";
|
|
3
3
|
import { getCookie } from "../lib/cookies.mjs";
|
|
4
4
|
import { selectClient, useAdminStore } from "./provider.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { Suspense, useState } from "react";
|
|
5
|
+
import { Suspense, useCallback, useMemo, useState } from "react";
|
|
7
6
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
8
7
|
import { DEFAULT_LOCALE } from "questpie/shared";
|
|
9
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -107,80 +106,43 @@ function getAdminLocalesQueryOptions(client) {
|
|
|
107
106
|
gcTime: Number.POSITIVE_INFINITY
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
|
-
function TranslationsInner(
|
|
111
|
-
const $ = c(14);
|
|
112
|
-
const { initialLocale, children } = t0;
|
|
109
|
+
function TranslationsInner({ initialLocale, children }) {
|
|
113
110
|
const client = useAdminStore(selectClient);
|
|
114
111
|
const [locale, setLocaleState] = useState(initialLocale);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
} else t3 = $[5];
|
|
138
|
-
const setLocale = t3;
|
|
139
|
-
let t4;
|
|
140
|
-
if ($[6] !== localesData.locales || $[7] !== translationsData.fallbackLocale || $[8] !== translationsData.locale || $[9] !== translationsData.messages) {
|
|
141
|
-
t4 = createSimpleI18n({
|
|
142
|
-
locale: translationsData.locale,
|
|
143
|
-
locales: localesData.locales,
|
|
144
|
-
messages: { [translationsData.locale]: translationsData.messages },
|
|
145
|
-
fallbackLocale: translationsData.fallbackLocale,
|
|
146
|
-
onLocaleChange: setLocale
|
|
147
|
-
});
|
|
148
|
-
$[6] = localesData.locales;
|
|
149
|
-
$[7] = translationsData.fallbackLocale;
|
|
150
|
-
$[8] = translationsData.locale;
|
|
151
|
-
$[9] = translationsData.messages;
|
|
152
|
-
$[10] = t4;
|
|
153
|
-
} else t4 = $[10];
|
|
154
|
-
const i18nAdapter = t4;
|
|
155
|
-
let t5;
|
|
156
|
-
if ($[11] !== children || $[12] !== i18nAdapter) {
|
|
157
|
-
t5 = /* @__PURE__ */ jsx(I18nProvider, {
|
|
158
|
-
adapter: i18nAdapter,
|
|
159
|
-
children
|
|
160
|
-
});
|
|
161
|
-
$[11] = children;
|
|
162
|
-
$[12] = i18nAdapter;
|
|
163
|
-
$[13] = t5;
|
|
164
|
-
} else t5 = $[13];
|
|
165
|
-
return t5;
|
|
112
|
+
const { data: localesData } = useSuspenseQuery(getAdminLocalesQueryOptions(client));
|
|
113
|
+
const { data: translationsData } = useSuspenseQuery(getAdminTranslationsQueryOptions(client, locale));
|
|
114
|
+
const setLocale = useCallback((newLocale) => {
|
|
115
|
+
setLocaleState(newLocale);
|
|
116
|
+
setUiLocaleCookie(newLocale);
|
|
117
|
+
}, []);
|
|
118
|
+
return /* @__PURE__ */ jsx(I18nProvider, {
|
|
119
|
+
adapter: useMemo(() => {
|
|
120
|
+
return createSimpleI18n({
|
|
121
|
+
locale: translationsData.locale,
|
|
122
|
+
locales: localesData.locales,
|
|
123
|
+
messages: { [translationsData.locale]: translationsData.messages },
|
|
124
|
+
fallbackLocale: translationsData.fallbackLocale,
|
|
125
|
+
onLocaleChange: setLocale
|
|
126
|
+
});
|
|
127
|
+
}, [
|
|
128
|
+
translationsData,
|
|
129
|
+
localesData.locales,
|
|
130
|
+
setLocale
|
|
131
|
+
]),
|
|
132
|
+
children
|
|
133
|
+
});
|
|
166
134
|
}
|
|
167
135
|
function LoadingFallback() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
className: "qp-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})]
|
|
179
|
-
})
|
|
180
|
-
});
|
|
181
|
-
$[0] = t0;
|
|
182
|
-
} else t0 = $[0];
|
|
183
|
-
return t0;
|
|
136
|
+
return /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "qp-flex qp-h-screen qp-w-screen qp-items-center qp-justify-center qp-bg-background",
|
|
138
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: "qp-flex qp-flex-col qp-items-center qp-gap-4",
|
|
140
|
+
children: [/* @__PURE__ */ jsx("div", { className: "qp-h-8 qp-w-8 qp-animate-spin qp-rounded-full qp-border-4 qp-border-foreground qp-border-t-transparent" }), /* @__PURE__ */ jsx("span", {
|
|
141
|
+
className: "qp-text-sm qp-text-muted-foreground",
|
|
142
|
+
children: "Loading..."
|
|
143
|
+
})]
|
|
144
|
+
})
|
|
145
|
+
});
|
|
184
146
|
}
|
|
185
147
|
/**
|
|
186
148
|
* Translations Provider
|
|
@@ -199,43 +161,15 @@ function LoadingFallback() {
|
|
|
199
161
|
* </AdminStoreContext.Provider>
|
|
200
162
|
* ```
|
|
201
163
|
*/
|
|
202
|
-
function TranslationsProvider(
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
t1 = initialLocale ?? getUiLocaleFromCookie() ?? DEFAULT_LOCALE;
|
|
208
|
-
$[0] = initialLocale;
|
|
209
|
-
$[1] = t1;
|
|
210
|
-
} else t1 = $[1];
|
|
211
|
-
const resolvedLocale = t1;
|
|
212
|
-
let t2;
|
|
213
|
-
if ($[2] !== fallback) {
|
|
214
|
-
t2 = fallback ?? /* @__PURE__ */ jsx(LoadingFallback, {});
|
|
215
|
-
$[2] = fallback;
|
|
216
|
-
$[3] = t2;
|
|
217
|
-
} else t2 = $[3];
|
|
218
|
-
let t3;
|
|
219
|
-
if ($[4] !== children || $[5] !== resolvedLocale) {
|
|
220
|
-
t3 = /* @__PURE__ */ jsx(TranslationsInner, {
|
|
164
|
+
function TranslationsProvider({ initialLocale, children, fallback }) {
|
|
165
|
+
const resolvedLocale = initialLocale ?? getUiLocaleFromCookie() ?? DEFAULT_LOCALE;
|
|
166
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
167
|
+
fallback: fallback ?? /* @__PURE__ */ jsx(LoadingFallback, {}),
|
|
168
|
+
children: /* @__PURE__ */ jsx(TranslationsInner, {
|
|
221
169
|
initialLocale: resolvedLocale,
|
|
222
170
|
children
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
$[5] = resolvedLocale;
|
|
226
|
-
$[6] = t3;
|
|
227
|
-
} else t3 = $[6];
|
|
228
|
-
let t4;
|
|
229
|
-
if ($[7] !== t2 || $[8] !== t3) {
|
|
230
|
-
t4 = /* @__PURE__ */ jsx(Suspense, {
|
|
231
|
-
fallback: t2,
|
|
232
|
-
children: t3
|
|
233
|
-
});
|
|
234
|
-
$[7] = t2;
|
|
235
|
-
$[8] = t3;
|
|
236
|
-
$[9] = t4;
|
|
237
|
-
} else t4 = $[9];
|
|
238
|
-
return t4;
|
|
171
|
+
})
|
|
172
|
+
});
|
|
239
173
|
}
|
|
240
174
|
|
|
241
175
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScopePickerProps } from "./types.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime27 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/client/scope/picker.d.ts
|
|
5
5
|
|
|
@@ -48,6 +48,6 @@ declare function ScopePicker({
|
|
|
48
48
|
clearText,
|
|
49
49
|
className,
|
|
50
50
|
compact
|
|
51
|
-
}: ScopePickerProps):
|
|
51
|
+
}: ScopePickerProps): react_jsx_runtime27.JSX.Element;
|
|
52
52
|
//#endregion
|
|
53
53
|
export { ScopePicker };
|