nextjs-cms 0.9.35 → 0.9.37
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/api/actions/pages.d.ts +3 -3
- package/dist/api/trpc/root.d.ts +3 -3
- package/dist/api/trpc/routers/navigation.d.ts +3 -3
- package/dist/api/trpc/server.d.ts +9 -9
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +43 -10
- package/dist/core/config/config-loader.d.ts +2 -2
- package/dist/core/fields/date-range.d.ts +4 -4
- package/dist/core/fields/slug.d.ts +55 -3
- package/dist/core/fields/slug.d.ts.map +1 -1
- package/dist/core/fields/slug.js +56 -2
- package/dist/core/sections/category.d.ts +4 -4
- package/dist/core/sections/hasItems.d.ts +4 -4
- package/dist/core/sections/section.d.ts +3 -3
- package/dist/core/sections/simple.d.ts +4 -4
- package/dist/core/submit/ItemEditSubmit.js +5 -5
- package/dist/translations/base/en.d.ts +3 -0
- package/dist/translations/base/en.d.ts.map +1 -1
- package/dist/translations/base/en.js +3 -0
- package/dist/translations/client.d.ts +40 -4
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/server.d.ts +40 -4
- package/dist/translations/server.d.ts.map +1 -1
- package/package.json +6 -3
- package/dist/api/axios/axiosInstance.d.ts +0 -2
- package/dist/api/axios/axiosInstance.d.ts.map +0 -1
- package/dist/api/axios/axiosInstance.js +0 -8
- package/dist/api/client.d.ts +0 -30
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -82
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -0
- package/dist/api/lib/serverActions.d.ts +0 -338
- package/dist/api/lib/serverActions.d.ts.map +0 -1
- package/dist/api/lib/serverActions.js +0 -1517
- package/dist/api/root.d.ts +0 -19
- package/dist/api/root.d.ts.map +0 -1
- package/dist/api/root.js +0 -50
- package/dist/api/routers/accountSettings.d.ts +0 -66
- package/dist/api/routers/accountSettings.d.ts.map +0 -1
- package/dist/api/routers/accountSettings.js +0 -202
- package/dist/api/routers/admins.d.ts +0 -112
- package/dist/api/routers/admins.d.ts.map +0 -1
- package/dist/api/routers/admins.js +0 -323
- package/dist/api/routers/auth.d.ts +0 -54
- package/dist/api/routers/auth.d.ts.map +0 -1
- package/dist/api/routers/auth.js +0 -50
- package/dist/api/routers/categorySection.d.ts +0 -105
- package/dist/api/routers/categorySection.d.ts.map +0 -1
- package/dist/api/routers/categorySection.js +0 -49
- package/dist/api/routers/config.d.ts +0 -48
- package/dist/api/routers/config.d.ts.map +0 -1
- package/dist/api/routers/config.js +0 -18
- package/dist/api/routers/cpanel.d.ts +0 -82
- package/dist/api/routers/cpanel.d.ts.map +0 -1
- package/dist/api/routers/cpanel.js +0 -216
- package/dist/api/routers/fields.d.ts +0 -35
- package/dist/api/routers/fields.d.ts.map +0 -1
- package/dist/api/routers/fields.js +0 -81
- package/dist/api/routers/files.d.ts +0 -34
- package/dist/api/routers/files.d.ts.map +0 -1
- package/dist/api/routers/files.js +0 -14
- package/dist/api/routers/gallery.d.ts +0 -35
- package/dist/api/routers/gallery.d.ts.map +0 -1
- package/dist/api/routers/gallery.js +0 -92
- package/dist/api/routers/hasItemsSection.d.ts +0 -194
- package/dist/api/routers/hasItemsSection.d.ts.map +0 -1
- package/dist/api/routers/hasItemsSection.js +0 -86
- package/dist/api/routers/logs.d.ts +0 -59
- package/dist/api/routers/logs.d.ts.map +0 -1
- package/dist/api/routers/logs.js +0 -76
- package/dist/api/routers/navigation.d.ts +0 -50
- package/dist/api/routers/navigation.d.ts.map +0 -1
- package/dist/api/routers/navigation.js +0 -11
- package/dist/api/routers/simpleSection.d.ts +0 -93
- package/dist/api/routers/simpleSection.d.ts.map +0 -1
- package/dist/api/routers/simpleSection.js +0 -54
- package/dist/api/server.d.ts +0 -2748
- package/dist/api/server.d.ts.map +0 -1
- package/dist/api/server.js +0 -100
- package/dist/api/trpc/error-logging.d.ts +0 -14
- package/dist/api/trpc/error-logging.d.ts.map +0 -1
- package/dist/api/trpc/error-logging.js +0 -75
- package/dist/api/trpc.d.ts +0 -111
- package/dist/api/trpc.d.ts.map +0 -1
- package/dist/api/trpc.js +0 -99
- package/dist/api/utils/async-caller-proxy.d.ts +0 -2
- package/dist/api/utils/async-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/async-caller-proxy.js +0 -36
- package/dist/api/utils/lazy-caller-proxy.d.ts +0 -2
- package/dist/api/utils/lazy-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/lazy-caller-proxy.js +0 -36
- package/dist/api/utils/router-types.d.ts +0 -7
- package/dist/api/utils/router-types.d.ts.map +0 -1
- package/dist/api/utils/router-types.js +0 -0
- package/dist/auth/axios/axiosInstance.d.ts +0 -2
- package/dist/auth/axios/axiosInstance.d.ts.map +0 -1
- package/dist/auth/axios/axiosInstance.js +0 -8
- package/dist/auth/hooks/useAxiosPrivate.d.ts +0 -5
- package/dist/auth/hooks/useAxiosPrivate.d.ts.map +0 -1
- package/dist/auth/hooks/useAxiosPrivate.js +0 -74
- package/dist/auth/trpc.d.ts +0 -6
- package/dist/auth/trpc.d.ts.map +0 -1
- package/dist/auth/trpc.js +0 -81
- package/dist/plugins/manifest.d.ts +0 -28
- package/dist/plugins/manifest.d.ts.map +0 -1
- package/dist/plugins/manifest.js +0 -83
- package/dist/plugins/registry.d.ts +0 -22
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -25
- package/dist/utils/log.d.ts +0 -18
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js +0 -28
|
@@ -70,13 +70,13 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
70
70
|
maxDate: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodLiteral<"now">]>>;
|
|
71
71
|
defaultStartValue: z.ZodOptional<z.ZodDate>;
|
|
72
72
|
defaultEndValue: z.ZodOptional<z.ZodDate>;
|
|
73
|
-
order: z.ZodOptional<z.ZodNumber>;
|
|
74
|
-
localized: z.ZodOptional<z.ZodBoolean>;
|
|
75
73
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
76
74
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
77
75
|
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
76
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
78
77
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
79
78
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
79
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
80
80
|
}, z.core.$strict>;
|
|
81
81
|
declare const dateRangeFieldConfigSchema: z.ZodObject<{
|
|
82
82
|
/**
|
|
@@ -97,13 +97,13 @@ declare const dateRangeFieldConfigSchema: z.ZodObject<{
|
|
|
97
97
|
maxDate: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodLiteral<"now">]>>;
|
|
98
98
|
defaultStartValue: z.ZodOptional<z.ZodDate>;
|
|
99
99
|
defaultEndValue: z.ZodOptional<z.ZodDate>;
|
|
100
|
-
order: z.ZodOptional<z.ZodNumber>;
|
|
101
|
-
localized: z.ZodOptional<z.ZodBoolean>;
|
|
102
100
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
103
101
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
104
102
|
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
103
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
105
104
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
106
105
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
106
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
107
107
|
}, z.core.$strict>;
|
|
108
108
|
export type DateRangeFieldConfig = z.infer<typeof dateRangeFieldConfigSchema>;
|
|
109
109
|
/**
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type { BaseFieldConfig } from './field.js';
|
|
2
|
-
import { Field } from './field.js';
|
|
3
|
-
import { entityKind } from '../helpers/index.js';
|
|
4
1
|
import * as z from 'zod';
|
|
2
|
+
import type { MultilingualString } from '../../translations/language-utils.js';
|
|
3
|
+
import type { BaseFieldConfig } from './field.js';
|
|
5
4
|
import type { TextFieldConfig } from './text.js';
|
|
5
|
+
import { entityKind } from '../helpers/index.js';
|
|
6
|
+
import { Field } from './field.js';
|
|
7
|
+
type SlugEditProtectionAlertConfig = {
|
|
8
|
+
title?: MultilingualString;
|
|
9
|
+
description?: MultilingualString;
|
|
10
|
+
};
|
|
11
|
+
type NormalizedSlugEditProtection = {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
alert?: SlugEditProtectionAlertConfig;
|
|
14
|
+
};
|
|
6
15
|
declare const slugFieldConfigSchema: z.ZodObject<{
|
|
7
16
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
8
17
|
minLength: z.ZodOptional<z.ZodNumber>;
|
|
@@ -50,6 +59,17 @@ declare const slugFieldConfigSchema: z.ZodObject<{
|
|
|
50
59
|
adminGenerated?: boolean | "readonly" | undefined;
|
|
51
60
|
localized?: boolean | undefined;
|
|
52
61
|
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Prevents edit forms from automatically changing this slug when the linked field changes.
|
|
64
|
+
* Disabled by default. Set to true or provide an object config to protect edit forms.
|
|
65
|
+
*/
|
|
66
|
+
editProtection: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
67
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
alert: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
70
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
71
|
+
}, z.core.$strict>>;
|
|
72
|
+
}, z.core.$strict>]>>;
|
|
53
73
|
}, z.core.$strict>;
|
|
54
74
|
type Config = z.infer<typeof slugFieldConfigSchema>;
|
|
55
75
|
export declare class SlugField extends Field<'slug', Config> {
|
|
@@ -59,9 +79,12 @@ export declare class SlugField extends Field<'slug', Config> {
|
|
|
59
79
|
readonly placeholder: string | undefined;
|
|
60
80
|
readonly forFieldName: string;
|
|
61
81
|
readonly forFieldConfig: TextFieldConfig;
|
|
82
|
+
readonly editProtection: NormalizedSlugEditProtection;
|
|
62
83
|
private readonly _defaultValue;
|
|
63
84
|
value: string | undefined;
|
|
64
85
|
constructor(config: BaseFieldConfig<Config>);
|
|
86
|
+
private static normalizeEditProtection;
|
|
87
|
+
private getEditProtectionClientConfig;
|
|
65
88
|
/**
|
|
66
89
|
* Convert a string to a URL-friendly slug.
|
|
67
90
|
* - Converts to lowercase
|
|
@@ -76,6 +99,13 @@ export declare class SlugField extends Field<'slug', Config> {
|
|
|
76
99
|
minLength: number | undefined;
|
|
77
100
|
placeholder: string | undefined;
|
|
78
101
|
forFieldName: string;
|
|
102
|
+
editProtection: {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
alert: {
|
|
105
|
+
title: string | undefined;
|
|
106
|
+
description: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
79
109
|
type: "slug";
|
|
80
110
|
name: string;
|
|
81
111
|
label: string;
|
|
@@ -147,6 +177,17 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
147
177
|
adminGenerated?: boolean | "readonly" | undefined;
|
|
148
178
|
localized?: boolean | undefined;
|
|
149
179
|
}>;
|
|
180
|
+
/**
|
|
181
|
+
* Prevents edit forms from automatically changing this slug when the linked field changes.
|
|
182
|
+
* Disabled by default. Set to true or provide an object config to protect edit forms.
|
|
183
|
+
*/
|
|
184
|
+
editProtection: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
185
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
alert: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
188
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
}, z.core.$strict>]>>;
|
|
150
191
|
name: z.ZodString;
|
|
151
192
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
152
193
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -204,6 +245,17 @@ declare const configSchema: z.ZodObject<{
|
|
|
204
245
|
adminGenerated?: boolean | "readonly" | undefined;
|
|
205
246
|
localized?: boolean | undefined;
|
|
206
247
|
}>;
|
|
248
|
+
/**
|
|
249
|
+
* Prevents edit forms from automatically changing this slug when the linked field changes.
|
|
250
|
+
* Disabled by default. Set to true or provide an object config to protect edit forms.
|
|
251
|
+
*/
|
|
252
|
+
editProtection: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
253
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
alert: z.ZodOptional<z.ZodObject<{
|
|
255
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
256
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
257
|
+
}, z.core.$strict>>;
|
|
258
|
+
}, z.core.$strict>]>>;
|
|
207
259
|
name: z.ZodString;
|
|
208
260
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
209
261
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../../src/core/fields/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../../src/core/fields/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAyB,KAAK,EAAE,MAAM,YAAY,CAAA;AAwBzD,KAAK,6BAA6B,GAAG;IACjC,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACnC,CAAA;AAED,KAAK,4BAA4B,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,6BAA6B,CAAA;CACxC,CAAA;AAED,QAAA,MAAM,qBAAqB;;;;IAIvB;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnD,qBAAa,SAAU,SAAQ,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;IAChD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAc;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAA;IACxC,QAAQ,CAAC,cAAc,EAAE,4BAA4B,CAAA;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEtB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;IAY3C,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAetC,OAAO,CAAC,6BAA6B;IAgBrC;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUpB,eAAe;;;;;;;;;;;;;;;;;;;;;;IAW/B;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,aAAa;IAQJ,kBAAkB,IAAI,OAAO;IAOtC;;;;OAIG;IACG,oBAAoB;CAwB7B;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE5E,QAAA,MAAM,aAAa;;;;IA9Jf;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;kBAmJL,CAAA;AAEF,QAAA,MAAM,YAAY;;;;;;IAnKd;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;kBAyJL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,eAAe,CAkB/E"}
|
package/dist/core/fields/slug.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { Field, baseFieldConfigSchema } from './field.js';
|
|
2
|
-
import { entityKind } from '../helpers/index.js';
|
|
3
1
|
import * as z from 'zod';
|
|
4
2
|
import getString from '../../translations/index.js';
|
|
3
|
+
import { resolveMultilingualString } from '../../translations/language-utils.js';
|
|
4
|
+
import { entityKind } from '../helpers/index.js';
|
|
5
|
+
import { baseFieldConfigSchema, Field } from './field.js';
|
|
6
|
+
const multilingualStringSchema = z
|
|
7
|
+
.union([z.string(), z.record(z.string(), z.string())])
|
|
8
|
+
.describe('A plain string or an object with language codes as keys');
|
|
9
|
+
const editProtectionAlertSchema = z.strictObject({
|
|
10
|
+
title: multilingualStringSchema.optional().describe('The alert title shown when editing a protected slug'),
|
|
11
|
+
description: multilingualStringSchema
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('The alert description shown when editing a protected slug'),
|
|
14
|
+
});
|
|
15
|
+
const editProtectionSchema = z
|
|
16
|
+
.union([
|
|
17
|
+
z.boolean(),
|
|
18
|
+
z.strictObject({
|
|
19
|
+
enabled: z.boolean().optional().describe('Whether edit protection is enabled'),
|
|
20
|
+
alert: editProtectionAlertSchema.optional().describe('Custom alert text for protected slug edits'),
|
|
21
|
+
}),
|
|
22
|
+
])
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Protects the slug from automatic changes in edit forms');
|
|
5
25
|
const slugFieldConfigSchema = z.strictObject({
|
|
6
26
|
placeholder: z.string().optional().describe('The placeholder text for the field'),
|
|
7
27
|
minLength: z.number().optional().describe('The minimum length of the slug'),
|
|
@@ -17,6 +37,11 @@ const slugFieldConfigSchema = z.strictObject({
|
|
|
17
37
|
* generate a slug from that value.
|
|
18
38
|
*/
|
|
19
39
|
for: z.custom().describe('The text field config this slug is derived from'),
|
|
40
|
+
/**
|
|
41
|
+
* Prevents edit forms from automatically changing this slug when the linked field changes.
|
|
42
|
+
* Disabled by default. Set to true or provide an object config to protect edit forms.
|
|
43
|
+
*/
|
|
44
|
+
editProtection: editProtectionSchema,
|
|
20
45
|
});
|
|
21
46
|
export class SlugField extends Field {
|
|
22
47
|
static [entityKind] = 'SlugField';
|
|
@@ -25,6 +50,7 @@ export class SlugField extends Field {
|
|
|
25
50
|
placeholder;
|
|
26
51
|
forFieldName;
|
|
27
52
|
forFieldConfig;
|
|
53
|
+
editProtection;
|
|
28
54
|
_defaultValue;
|
|
29
55
|
value;
|
|
30
56
|
constructor(config) {
|
|
@@ -36,6 +62,33 @@ export class SlugField extends Field {
|
|
|
36
62
|
this._defaultValue = config.defaultValue;
|
|
37
63
|
this.forFieldName = config.for.name;
|
|
38
64
|
this.forFieldConfig = config.for;
|
|
65
|
+
this.editProtection = SlugField.normalizeEditProtection(config.editProtection);
|
|
66
|
+
}
|
|
67
|
+
static normalizeEditProtection(editProtection) {
|
|
68
|
+
if (!editProtection) {
|
|
69
|
+
return { enabled: false };
|
|
70
|
+
}
|
|
71
|
+
if (typeof editProtection === 'boolean') {
|
|
72
|
+
return { enabled: editProtection };
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
enabled: editProtection.enabled ?? false,
|
|
76
|
+
alert: editProtection.alert,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
getEditProtectionClientConfig() {
|
|
80
|
+
const alert = this.editProtection.alert;
|
|
81
|
+
return {
|
|
82
|
+
enabled: this.editProtection.enabled,
|
|
83
|
+
alert: {
|
|
84
|
+
title: alert?.title
|
|
85
|
+
? resolveMultilingualString(alert.title, this.language, this.fallbackLanguage)
|
|
86
|
+
: undefined,
|
|
87
|
+
description: alert?.description
|
|
88
|
+
? resolveMultilingualString(alert.description, this.language, this.fallbackLanguage)
|
|
89
|
+
: undefined,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
39
92
|
}
|
|
40
93
|
/**
|
|
41
94
|
* Convert a string to a URL-friendly slug.
|
|
@@ -61,6 +114,7 @@ export class SlugField extends Field {
|
|
|
61
114
|
minLength: this.minLength,
|
|
62
115
|
placeholder: this.placeholder,
|
|
63
116
|
forFieldName: this.forFieldName,
|
|
117
|
+
editProtection: this.getEditProtectionClientConfig(),
|
|
64
118
|
};
|
|
65
119
|
}
|
|
66
120
|
/**
|