rimecms 0.29.0 → 0.30.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/dist/adapter-sqlite/area.server.js +8 -8
- package/dist/adapter-sqlite/generate-schema/column.server.d.ts +13 -0
- package/dist/adapter-sqlite/generate-schema/column.server.js +77 -0
- package/dist/adapter-sqlite/generate-schema/index.server.js +7 -12
- package/dist/adapter-sqlite/generate-schema/root.server.js +35 -39
- package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +12 -0
- package/dist/adapter-sqlite/generate-schema/templates.server.js +19 -0
- package/dist/adapter-sqlite/index.server.d.ts +1 -2
- package/dist/adapter-sqlite/index.server.js +0 -2
- package/dist/adapter-sqlite/relations.server.js +6 -1
- package/dist/adapter-sqlite/util.server.d.ts +1 -6
- package/dist/adapter-sqlite/util.server.js +6 -0
- package/dist/adapter-sqlite/where.server.js +17 -16
- package/dist/adapter-sqlite/with.server.js +9 -9
- package/dist/core/collections/auth/fields.d.ts +2 -182
- package/dist/core/collections/config/augment-auth.server.js +1 -1
- package/dist/core/collections/config/augment-nested.server.js +1 -1
- package/dist/core/collections/config/augment-upload.js +2 -2
- package/dist/core/collections/config/augment-upload.server.js +4 -1
- package/dist/core/collections/operations/duplicate.js +30 -11
- package/dist/core/collections/operations/updateById.js +6 -5
- package/dist/core/collections/rest/duplicate.server.js +7 -3
- package/dist/core/collections/upload/disk/delete.server.d.ts +1 -1
- package/dist/core/collections/upload/disk/delete.server.js +48 -1
- package/dist/core/collections/upload/hooks/clean-up-files.server.js +2 -2
- package/dist/core/collections/upload/hooks/extract-path.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/extract-path.server.js +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.js +3 -3
- package/dist/core/config/server/validate.server.js +50 -30
- package/dist/core/config/shared/find-thumbnail.js +12 -12
- package/dist/core/config/shared/find-title.js +13 -13
- package/dist/core/config/shared/upload-directories.js +1 -1
- package/dist/core/constant.server.d.ts +1 -0
- package/dist/core/constant.server.js +2 -0
- package/dist/core/dev/cache/index.server.js +9 -9
- package/dist/core/dev/cli/build/index.js +2 -2
- package/dist/core/dev/cli/clear/index.server.js +2 -1
- package/dist/core/dev/cli/generate/index.server.js +3 -2
- package/dist/core/dev/cli/init/index.server.js +1 -1
- package/dist/core/dev/generate/routes/index.server.js +2 -2
- package/dist/core/dev/generate/types/index.server.js +17 -17
- package/dist/core/dev/vite/index.server.js +21 -5
- package/dist/core/fields/builders/boolean-builder.d.ts +3 -1
- package/dist/core/fields/builders/boolean-builder.js +3 -0
- package/dist/core/fields/builders/field-builder.d.ts +35 -2
- package/dist/core/fields/builders/field-builder.js +33 -2
- package/dist/core/fields/builders/form-field-builder.d.ts +71 -12
- package/dist/core/fields/builders/form-field-builder.js +96 -6
- package/dist/core/fields/builders/select-builder.d.ts +4 -1
- package/dist/core/fields/builders/select-builder.js +3 -0
- package/dist/core/fields/util.d.ts +8 -16
- package/dist/core/fields/util.js +49 -83
- package/dist/core/handlers/routes.server.js +16 -3
- package/dist/core/naming.d.ts +34 -0
- package/dist/core/naming.js +39 -0
- package/dist/core/operations/blocks/diff.server.js +1 -1
- package/dist/core/operations/blocks/extract.server.js +1 -1
- package/dist/core/operations/configMap/buildTreeMap.d.ts +3 -2
- package/dist/core/operations/configMap/buildTreeMap.js +1 -1
- package/dist/core/operations/configMap/index.d.ts +2 -1
- package/dist/core/operations/configMap/index.js +13 -13
- package/dist/core/operations/configMap/types.d.ts +2 -2
- package/dist/core/operations/hooks/before-read/process-document-fields.server.js +14 -17
- package/dist/core/operations/hooks/before-upsert/data-config-map.server.js +1 -1
- package/dist/core/operations/hooks/before-upsert/original-config-map.server.js +1 -1
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.d.ts +2 -4
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.js +10 -15
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.js +49 -31
- package/dist/core/operations/relations/extract.server.js +5 -5
- package/dist/core/operations/shared/fallback-data-from-original.js +2 -2
- package/dist/core/operations/tree/diff.server.js +1 -1
- package/dist/core/operations/tree/extract.server.js +1 -1
- package/dist/core/plugins/cache/cache.server.js +3 -3
- package/dist/fields/blocks/component/AddBlockButton.svelte +7 -7
- package/dist/fields/blocks/component/AddBlockButton.svelte.d.ts +2 -2
- package/dist/fields/blocks/component/Blocks.svelte +6 -7
- package/dist/fields/blocks/component/props.d.ts +2 -2
- package/dist/fields/blocks/index.d.ts +1 -1
- package/dist/fields/blocks/index.js +3 -3
- package/dist/fields/blocks/index.server.js +1 -1
- package/dist/fields/checkbox/component/Checkbox.svelte +2 -2
- package/dist/fields/checkbox/component/props.d.ts +2 -2
- package/dist/fields/checkbox/index.server.d.ts +1 -2
- package/dist/fields/checkbox/index.server.js +1 -10
- package/dist/fields/combobox/component/ComboBox.svelte +3 -3
- package/dist/fields/combobox/component/props.d.ts +2 -2
- package/dist/fields/combobox/index.server.d.ts +1 -2
- package/dist/fields/combobox/index.server.js +2 -11
- package/dist/fields/component/index.d.ts +1 -1
- package/dist/fields/date/component/Date.svelte +4 -4
- package/dist/fields/date/component/Date.svelte.d.ts +2 -2
- package/dist/fields/date/index.d.ts +3 -1
- package/dist/fields/date/index.js +3 -0
- package/dist/fields/date/index.server.d.ts +1 -2
- package/dist/fields/date/index.server.js +1 -10
- package/dist/fields/email/component/Email.svelte +5 -6
- package/dist/fields/email/component/props.d.ts +2 -3
- package/dist/fields/email/index.d.ts +3 -2
- package/dist/fields/email/index.js +4 -1
- package/dist/fields/email/index.server.d.ts +0 -3
- package/dist/fields/email/index.server.js +0 -9
- package/dist/fields/group/component/Group.svelte +9 -15
- package/dist/fields/group/component/Group.svelte.d.ts +2 -2
- package/dist/fields/group/index.d.ts +4 -2
- package/dist/fields/group/index.server.js +2 -2
- package/dist/fields/index.server.d.ts +1 -4
- package/dist/fields/index.server.js +17 -13
- package/dist/fields/link/component/Link.svelte +5 -5
- package/dist/fields/link/component/props.d.ts +2 -2
- package/dist/fields/link/index.d.ts +4 -1
- package/dist/fields/link/index.js +9 -10
- package/dist/fields/link/runtime.d.ts +2 -0
- package/dist/fields/link/runtime.js +1 -0
- package/dist/fields/link/{index.server.d.ts → runtime.server.d.ts} +1 -2
- package/dist/fields/link/{index.server.js → runtime.server.js} +2 -11
- package/dist/fields/number/component/Number.svelte +6 -6
- package/dist/fields/number/component/props.d.ts +2 -2
- package/dist/fields/number/index.d.ts +4 -10
- package/dist/fields/number/index.js +3 -4
- package/dist/fields/number/index.server.d.ts +1 -2
- package/dist/fields/number/index.server.js +1 -10
- package/dist/fields/radio/component/Radio.svelte +6 -7
- package/dist/fields/radio/component/props.d.ts +2 -2
- package/dist/fields/radio/index.server.d.ts +1 -2
- package/dist/fields/radio/index.server.js +2 -11
- package/dist/fields/relation/component/Relation.svelte +18 -14
- package/dist/fields/relation/component/Relation.svelte.d.ts +2 -2
- package/dist/fields/relation/index.d.ts +7 -4
- package/dist/fields/relation/index.js +8 -47
- package/dist/fields/relation/runtime.d.ts +5 -0
- package/dist/fields/relation/runtime.js +4 -0
- package/dist/fields/relation/runtime.server.d.ts +8 -0
- package/dist/fields/relation/runtime.server.js +49 -0
- package/dist/fields/rich-text/component/RichText.svelte +5 -5
- package/dist/fields/rich-text/component/props.d.ts +2 -2
- package/dist/fields/rich-text/core/features/fields/fields.svelte +2 -2
- package/dist/fields/rich-text/index.d.ts +2 -0
- package/dist/fields/rich-text/index.js +3 -0
- package/dist/fields/rich-text/index.server.d.ts +1 -2
- package/dist/fields/rich-text/index.server.js +1 -10
- package/dist/fields/select/component/Select.svelte +16 -16
- package/dist/fields/select/component/props.d.ts +2 -2
- package/dist/fields/select/index.d.ts +2 -0
- package/dist/fields/select/index.js +3 -0
- package/dist/fields/select/index.server.d.ts +1 -2
- package/dist/fields/select/index.server.js +2 -17
- package/dist/fields/slug/component/Slug.svelte +14 -10
- package/dist/fields/slug/component/Slug.svelte.d.ts +2 -2
- package/dist/fields/slug/index.d.ts +5 -2
- package/dist/fields/slug/index.js +3 -0
- package/dist/fields/slug/index.server.d.ts +1 -2
- package/dist/fields/slug/index.server.js +1 -10
- package/dist/fields/tabs/component/Tabs.svelte +15 -15
- package/dist/fields/tabs/component/Tabs.svelte.d.ts +2 -2
- package/dist/fields/tabs/index.d.ts +4 -16
- package/dist/fields/tabs/index.js +1 -8
- package/dist/fields/tabs/index.server.js +3 -3
- package/dist/fields/text/component/Text.svelte +5 -5
- package/dist/fields/text/component/props.d.ts +2 -3
- package/dist/fields/text/index.d.ts +4 -10
- package/dist/fields/text/index.js +3 -4
- package/dist/fields/text/index.server.d.ts +1 -2
- package/dist/fields/text/index.server.js +1 -10
- package/dist/fields/textarea/component/TextArea.svelte +3 -3
- package/dist/fields/textarea/component/props.d.ts +2 -2
- package/dist/fields/textarea/index.d.ts +4 -1
- package/dist/fields/textarea/index.js +3 -0
- package/dist/fields/textarea/index.server.d.ts +1 -2
- package/dist/fields/textarea/index.server.js +1 -10
- package/dist/fields/time/component/Time.svelte +5 -5
- package/dist/fields/time/component/Time.svelte.d.ts +1 -1
- package/dist/fields/time/component/props.d.ts +2 -2
- package/dist/fields/time/index.d.ts +2 -0
- package/dist/fields/time/index.js +3 -0
- package/dist/fields/time/index.server.d.ts +1 -2
- package/dist/fields/time/index.server.js +1 -10
- package/dist/fields/toggle/component/Toggle.svelte +3 -3
- package/dist/fields/toggle/component/Toggle.svelte.d.ts +1 -1
- package/dist/fields/toggle/component/props.d.ts +2 -2
- package/dist/fields/toggle/index.d.ts +2 -1
- package/dist/fields/toggle/index.server.d.ts +1 -2
- package/dist/fields/toggle/index.server.js +1 -10
- package/dist/fields/tree/component/AddItemButton.svelte +1 -2
- package/dist/fields/tree/component/Tree.svelte +6 -6
- package/dist/fields/tree/component/TreeBlock.svelte +5 -12
- package/dist/fields/tree/component/props.d.ts +3 -3
- package/dist/fields/tree/index.d.ts +3 -1
- package/dist/fields/tree/index.js +2 -2
- package/dist/fields/types.d.ts +11 -5
- package/dist/panel/components/fields/FieldsPreview.svelte +4 -5
- package/dist/panel/components/fields/Hint.svelte +5 -4
- package/dist/panel/components/fields/Hint.svelte.d.ts +3 -2
- package/dist/panel/components/fields/Label.svelte +6 -11
- package/dist/panel/components/fields/Label.svelte.d.ts +3 -2
- package/dist/panel/components/fields/LabelFor.svelte +4 -4
- package/dist/panel/components/fields/LabelFor.svelte.d.ts +2 -1
- package/dist/panel/components/fields/RenderFields.svelte +11 -16
- package/dist/panel/components/fields/{root.svelte.d.ts → fieldset.svelte.d.ts} +1 -1
- package/dist/panel/components/fields/{root.svelte.js → fieldset.svelte.js} +1 -1
- package/dist/panel/components/fields/index.d.ts +5 -5
- package/dist/panel/components/fields/index.js +2 -2
- package/dist/panel/components/sections/document/AuthFooter.svelte +2 -7
- package/dist/panel/components/sections/live/LiveEditPanel.svelte +2 -2
- package/dist/panel/context/collection.svelte.js +9 -9
- package/dist/panel/context/documentForm.svelte.d.ts +8 -21
- package/dist/panel/context/documentForm.svelte.js +45 -52
- package/dist/panel/context/form.svelte.d.ts +4 -3
- package/dist/panel/context/form.svelte.js +14 -16
- package/dist/panel/pages/auth/fields.d.ts +4 -4
- package/dist/panel/pages/auth/fields.js +6 -22
- package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +3 -10
- package/dist/util/doc.js +15 -17
- package/package.json +3 -2
- package/dist/fields/relation/index.server.d.ts +0 -4
- package/dist/fields/relation/index.server.js +0 -13
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { applyAction, deserialize } from '$app/forms';
|
|
2
2
|
import { page } from '$app/state';
|
|
3
|
-
import { compileDocumentConfig } from '../../core/config/shared/compile.js';
|
|
4
3
|
import { PARAMS, VERSIONS_STATUS } from '../../core/constant.js';
|
|
5
|
-
import {
|
|
4
|
+
import { getFieldAtPath } from '../../core/fields/util.js';
|
|
6
5
|
import { buildConfigMap } from '../../core/operations/configMap/index.js';
|
|
7
6
|
import { isJSONContent, richTextJSONToText } from '../../fields/rich-text/index.js';
|
|
8
7
|
import { normalizeFieldPath } from '../../util/doc.js';
|
|
@@ -28,7 +27,7 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
28
27
|
let initialDoc = $state(initial);
|
|
29
28
|
let doc = $state(initial);
|
|
30
29
|
let formElement = $state();
|
|
31
|
-
const documentConfig =
|
|
30
|
+
const documentConfig = config;
|
|
32
31
|
const changes = $derived(diff(initialDoc, doc));
|
|
33
32
|
let isDisabled = $state(readOnly);
|
|
34
33
|
let processing = $state(false);
|
|
@@ -335,32 +334,43 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
335
334
|
// Return primitive values as is
|
|
336
335
|
return data;
|
|
337
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* `config` is the raw compiled field data, same as every field component
|
|
339
|
+
* (Text.svelte, Group.svelte, ...) already works with — this mirrors
|
|
340
|
+
* `form.svelte.ts`'s `useField` on purpose, since both read plain field
|
|
341
|
+
* data (`.required`, `.isEmpty(value)`, `.validate(...)`, `.access.read`,
|
|
342
|
+
* `.condition(...)`), never builder methods. `config` is only omitted by
|
|
343
|
+
* callers with just a path in hand (e.g. `Group.svelte`'s `getField`), in
|
|
344
|
+
* which case it's resolved from `documentConfig.fields` and unwrapped via
|
|
345
|
+
* `.get` — the field must exist in the document's own field tree for that
|
|
346
|
+
* to work, which doesn't hold for standalone fields like the panel's
|
|
347
|
+
* password inputs (see AuthFooter.svelte), so those always pass `config`.
|
|
348
|
+
*/
|
|
338
349
|
function useField(path, config) {
|
|
339
350
|
if (!config) {
|
|
340
|
-
|
|
341
|
-
if (!
|
|
351
|
+
const resolved = getFieldAtPath(path, documentConfig.fields);
|
|
352
|
+
if (!resolved)
|
|
342
353
|
throw new Error(`can't find config for field : ${path}`);
|
|
354
|
+
config = resolved;
|
|
343
355
|
}
|
|
344
356
|
path = path ? normalizeFieldPath(path) : config.name;
|
|
345
357
|
const parts = $derived(path.split('.'));
|
|
346
358
|
const validate = (value) => {
|
|
347
|
-
if (config.required && config.isEmpty(value)) {
|
|
359
|
+
if (config.get.required && config.run.isEmpty(value)) {
|
|
348
360
|
errors.set(path, 'required::required_field');
|
|
349
361
|
return 'required';
|
|
350
362
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return false;
|
|
363
|
-
}
|
|
363
|
+
const validated = config.run.validate(value, {
|
|
364
|
+
data: doc,
|
|
365
|
+
locale: locale.code,
|
|
366
|
+
id: doc.id ?? undefined,
|
|
367
|
+
operation: doc.id ? 'update' : 'create',
|
|
368
|
+
user: user.attributes,
|
|
369
|
+
config: config.get
|
|
370
|
+
});
|
|
371
|
+
if (validated !== true) {
|
|
372
|
+
errors.set(path, validated);
|
|
373
|
+
return false;
|
|
364
374
|
}
|
|
365
375
|
if (errors.has(path)) {
|
|
366
376
|
errors.delete(path);
|
|
@@ -398,25 +408,20 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
398
408
|
setFieldValue(removeIds(defaultLocaleValue));
|
|
399
409
|
}
|
|
400
410
|
};
|
|
401
|
-
const setFieldValue = (value) => {
|
|
411
|
+
const setFieldValue = async (value) => {
|
|
412
|
+
value = await config.run.beforeValidate(value, { config, data: doc });
|
|
402
413
|
const valid = validate(value);
|
|
403
|
-
if (!config.
|
|
404
|
-
return;
|
|
405
|
-
if (operation === 'update' && !config.access.update(user.attributes)) {
|
|
414
|
+
if (operation === 'update' && !config.run.canUpdate(user.attributes)) {
|
|
406
415
|
return;
|
|
407
416
|
}
|
|
408
417
|
if (valid) {
|
|
409
418
|
setValue(path, value);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
useTree
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
419
|
+
config.run.onChange?.(value, {
|
|
420
|
+
siblings: getSiblings(),
|
|
421
|
+
useField,
|
|
422
|
+
useBlocks,
|
|
423
|
+
useTree
|
|
424
|
+
});
|
|
420
425
|
}
|
|
421
426
|
};
|
|
422
427
|
return {
|
|
@@ -431,35 +436,24 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
431
436
|
get editable() {
|
|
432
437
|
if (readOnly)
|
|
433
438
|
return false;
|
|
434
|
-
if (!config.access)
|
|
435
|
-
return false;
|
|
436
439
|
if (operation === 'create') {
|
|
437
|
-
return config.
|
|
440
|
+
return !!config.run.canCreate?.(user.attributes);
|
|
438
441
|
}
|
|
439
442
|
else {
|
|
440
|
-
return config.
|
|
443
|
+
return !!config.run.canUpdate?.(user.attributes);
|
|
441
444
|
}
|
|
442
445
|
},
|
|
443
446
|
get visible() {
|
|
444
|
-
if (
|
|
447
|
+
if (!config.run.canRead(user.attributes)) {
|
|
445
448
|
return false;
|
|
446
449
|
}
|
|
447
|
-
|
|
448
|
-
if (config.condition) {
|
|
449
|
-
try {
|
|
450
|
-
visible = config.condition(doc, getSiblings());
|
|
451
|
-
}
|
|
452
|
-
catch (err) {
|
|
453
|
-
console.error(err.message);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
return visible;
|
|
450
|
+
return config.run.condition(doc, getSiblings());
|
|
457
451
|
},
|
|
458
452
|
get error() {
|
|
459
453
|
return errors.value[path] || false;
|
|
460
454
|
},
|
|
461
455
|
get isEmpty() {
|
|
462
|
-
return
|
|
456
|
+
return config.run.isEmpty(getValueAtPath(path, doc));
|
|
463
457
|
}
|
|
464
458
|
};
|
|
465
459
|
}
|
|
@@ -618,7 +612,7 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
618
612
|
let data = { ...defaultLocaleDoc, locale: locale.code };
|
|
619
613
|
const configMap = buildConfigMap(defaultLocaleDoc, documentConfig.fields);
|
|
620
614
|
for (const [key, field] of Object.entries(configMap)) {
|
|
621
|
-
if (field.localized) {
|
|
615
|
+
if (field.get.localized) {
|
|
622
616
|
let value = getValueAtPath(key, data);
|
|
623
617
|
value = removeIds(value);
|
|
624
618
|
data = setValueAtPath(key, data, value);
|
|
@@ -693,8 +687,7 @@ export function setDocumentFormContext(args) {
|
|
|
693
687
|
const initial = {
|
|
694
688
|
...args.initial,
|
|
695
689
|
_type: args.initial._type || args.config.type,
|
|
696
|
-
_prototype: args.initial._prototype || args.config.slug
|
|
697
|
-
title: args.initial.title || '[untitled]'
|
|
690
|
+
_prototype: args.initial._prototype || args.config.slug
|
|
698
691
|
};
|
|
699
692
|
const store = createDocumentFormState({ ...args, initial });
|
|
700
693
|
return setContext(`${FORM_KEY}.${args.key}`, store);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormFieldBuilder } from '../../core/fields/builders/form-field-builder';
|
|
2
|
+
import type { FormField } from '../../fields/types.js';
|
|
2
3
|
import type { Dic } from '../../util/types.js';
|
|
3
4
|
import type { SubmitFunction } from '@sveltejs/kit';
|
|
4
5
|
export declare function setFormContext(initial: Dic, key: string): {
|
|
5
6
|
setValue: (path: string, value: any) => void;
|
|
6
|
-
useField: (path: string | undefined, config:
|
|
7
|
+
useField: (path: string | undefined, config: FormFieldBuilder<FormField>) => {
|
|
7
8
|
path: string;
|
|
8
9
|
value: any;
|
|
9
10
|
readonly editable: boolean;
|
|
@@ -43,7 +44,7 @@ export declare function setFormContext(initial: Dic, key: string): {
|
|
|
43
44
|
};
|
|
44
45
|
export declare function getFormContext(key: string): {
|
|
45
46
|
setValue: (path: string, value: any) => void;
|
|
46
|
-
useField: (path: string | undefined, config:
|
|
47
|
+
useField: (path: string | undefined, config: FormFieldBuilder<FormField>) => {
|
|
47
48
|
path: string;
|
|
48
49
|
value: any;
|
|
49
50
|
readonly editable: boolean;
|
|
@@ -43,29 +43,27 @@ function createFormStore(initial, key) {
|
|
|
43
43
|
const validate = (value) => {
|
|
44
44
|
let isEmpty;
|
|
45
45
|
try {
|
|
46
|
-
isEmpty = config.isEmpty(value);
|
|
46
|
+
isEmpty = config.run.isEmpty(value);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
49
|
console.error(err.message);
|
|
50
50
|
throw new Error(config.type + ' ' + err.message);
|
|
51
51
|
}
|
|
52
|
-
if (config.required && isEmpty) {
|
|
52
|
+
if (config.get.required && isEmpty) {
|
|
53
53
|
errors.value[path] = 'required::required_field';
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
56
|
+
const validated = config.run.validate(value, {
|
|
57
|
+
data: form,
|
|
58
|
+
id: undefined,
|
|
59
|
+
operation: undefined,
|
|
60
|
+
user: undefined,
|
|
61
|
+
locale: undefined,
|
|
62
|
+
config: config.get
|
|
63
|
+
});
|
|
64
|
+
if (validated !== true) {
|
|
65
|
+
errors.value[path] = validated;
|
|
66
|
+
return false;
|
|
69
67
|
}
|
|
70
68
|
if (errors.has(path)) {
|
|
71
69
|
errors.delete(path);
|
|
@@ -87,7 +85,7 @@ function createFormStore(initial, key) {
|
|
|
87
85
|
}
|
|
88
86
|
},
|
|
89
87
|
get visible() {
|
|
90
|
-
return config.
|
|
88
|
+
return config.run.condition(form, {});
|
|
91
89
|
},
|
|
92
90
|
get error() {
|
|
93
91
|
return errors.value[path] || false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const emailField:
|
|
4
|
-
export declare const nameField:
|
|
1
|
+
export declare const passwordField: import("../../../fields/text/index.js").TextFieldBuilder;
|
|
2
|
+
export declare const confirmPasswordField: import("../../../fields/text/index.js").TextFieldBuilder;
|
|
3
|
+
export declare const emailField: import("../../../fields/email/index.js").EmailFieldBuilder;
|
|
4
|
+
export declare const nameField: import("../../../fields/text/index.js").TextFieldBuilder;
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
+
import { email } from '../../../fields/email/index.js';
|
|
2
|
+
import { text } from '../../../fields/text/index.js';
|
|
1
3
|
import { email as validateEmail } from '../../../util/validate.js';
|
|
2
|
-
export const passwordField =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
required: true,
|
|
7
|
-
isEmpty: (value) => !value
|
|
8
|
-
};
|
|
9
|
-
export const emailField = {
|
|
10
|
-
name: 'email',
|
|
11
|
-
type: 'email',
|
|
12
|
-
layout: 'compact',
|
|
13
|
-
required: true,
|
|
14
|
-
validate: validateEmail,
|
|
15
|
-
isEmpty: (value) => !value
|
|
16
|
-
};
|
|
17
|
-
export const nameField = {
|
|
18
|
-
name: 'name',
|
|
19
|
-
type: 'text',
|
|
20
|
-
layout: 'compact',
|
|
21
|
-
required: true,
|
|
22
|
-
isEmpty: (value) => !value
|
|
23
|
-
};
|
|
4
|
+
export const passwordField = text('password').required();
|
|
5
|
+
export const confirmPasswordField = text('confirmPassword').required();
|
|
6
|
+
export const emailField = email('email').layout('compact').required().validate(validateEmail);
|
|
7
|
+
export const nameField = text('name').layout('compact').required();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import AuthForm from '../../../components/sections/auth/AuthForm.svelte';
|
|
5
5
|
import Button from '../../../components/ui/button/button.svelte';
|
|
6
6
|
import { setFormContext } from '../../../context/form.svelte';
|
|
7
|
-
import { passwordField } from '../fields.js';
|
|
7
|
+
import { confirmPasswordField, passwordField } from '../fields.js';
|
|
8
8
|
import { authClient } from '../../../util/auth';
|
|
9
9
|
import { toast } from 'svelte-sonner';
|
|
10
10
|
|
|
@@ -19,15 +19,8 @@
|
|
|
19
19
|
};
|
|
20
20
|
const { data }: Props = $props();
|
|
21
21
|
|
|
22
|
-
const passwordConfig =
|
|
23
|
-
|
|
24
|
-
placeholder: t__('common.newPassword')
|
|
25
|
-
};
|
|
26
|
-
const confirmPasswordConfig = {
|
|
27
|
-
...passwordField,
|
|
28
|
-
name: 'confirmPassword',
|
|
29
|
-
placeholder: t__('common.confirmPassword')
|
|
30
|
-
};
|
|
22
|
+
const passwordConfig = passwordField.placeholder(t__('common.newPassword'));
|
|
23
|
+
const confirmPasswordConfig = confirmPasswordField.placeholder(t__('common.confirmPassword'));
|
|
31
24
|
|
|
32
25
|
async function resetPassword() {
|
|
33
26
|
const token = new URLSearchParams(window.location.search).get('token');
|
package/dist/util/doc.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { isUploadConfig } from '../core/collections/upload/util/config.js';
|
|
2
|
+
import { FormFieldBuilder } from '../core/fields/builders/form-field-builder.js';
|
|
3
|
+
import { GroupFieldBuilder } from '../fields/group/index.js';
|
|
2
4
|
import { TabsBuilder } from '../fields/tabs/index.js';
|
|
3
5
|
import { getValueAtPath } from './object.js';
|
|
4
6
|
import { snapshot } from './state.js';
|
|
@@ -20,28 +22,24 @@ export const createBlankDocument = (config, event) => {
|
|
|
20
22
|
function reduceFieldsToBlankDocument(prev, curr) {
|
|
21
23
|
try {
|
|
22
24
|
if (curr instanceof TabsBuilder) {
|
|
23
|
-
curr.
|
|
24
|
-
prev[tab.name] = tab.
|
|
25
|
+
curr.get.tabs.forEach((tab) => {
|
|
26
|
+
prev[tab.name] = tab.get.fields.reduce(reduceFieldsToBlankDocument, {});
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
else if (['blocks', 'relation', 'tree'].includes(curr.type)) {
|
|
28
|
-
prev[curr.
|
|
30
|
+
prev[curr.name] = [];
|
|
29
31
|
}
|
|
30
|
-
else if (
|
|
31
|
-
prev[curr.
|
|
32
|
+
else if (curr instanceof GroupFieldBuilder) {
|
|
33
|
+
prev[curr.name] = curr.get.fields.reduce(reduceFieldsToBlankDocument, {});
|
|
32
34
|
}
|
|
33
|
-
else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
prev[curr.raw.name] = null;
|
|
44
|
-
}
|
|
35
|
+
else if (curr instanceof FormFieldBuilder) {
|
|
36
|
+
// Presentational fields (separator, bare component()) are plain
|
|
37
|
+
// FieldBuilder, never FormFieldBuilder, and get skipped here rather
|
|
38
|
+
// than assigned `prev['']` (they never got a real name) — that used
|
|
39
|
+
// to corrupt the parent object into looking array-like once
|
|
40
|
+
// flattened/unflattened.
|
|
41
|
+
const defaultValue = curr.run.defaultValue({ event });
|
|
42
|
+
prev[curr.name] = defaultValue !== undefined ? defaultValue : null;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"test:multilang": "playwright test -c ./tests/multilang/playwright.config.multilang.ts",
|
|
18
18
|
"test:basic": "playwright test -c ./tests/basic/playwright.config.basic.ts",
|
|
19
19
|
"test:empty": "playwright test -c ./tests/empty/playwright.config.empty.ts",
|
|
20
|
+
"test:fields": "playwright test -c ./tests/fields/playwright.config.fields.ts",
|
|
20
21
|
"test:versions": "playwright test -c ./tests/versions/playwright.config.versions.ts",
|
|
21
22
|
"test:versions-multilang": "playwright test -c ./tests/versions-multilang/playwright.config.versions.ts",
|
|
22
|
-
"test": "pnpm test:empty && pnpm test:multilang && pnpm test:versions && pnpm test:versions-multilang && pnpm test:basic",
|
|
23
|
+
"test": "pnpm test:empty && pnpm test:fields && pnpm test:multilang && pnpm test:versions && pnpm test:versions-multilang && pnpm test:basic",
|
|
23
24
|
"check:circular-deps": "pnpm dlx madge -c --extensions ts ./src/",
|
|
24
25
|
"local-pack": "npm run build && npm pack && echo \"Package created at: $(pwd)/$(npm pack | tail -1)\""
|
|
25
26
|
},
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
|
-
import { capitalize } from '../../util/string.js';
|
|
4
|
-
export const toSchema = (field, parentPath) => {
|
|
5
|
-
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
6
|
-
const suffix = templateUniqueRequired(field.raw, {});
|
|
7
|
-
if (field._generateSchema)
|
|
8
|
-
return field._generateSchema({ camel, snake, suffix });
|
|
9
|
-
return `${camel}: text('${snake}', { mode: 'json' })${suffix}`;
|
|
10
|
-
};
|
|
11
|
-
export const toType = (field) => {
|
|
12
|
-
return `${field.name}${field.raw.required ? '' : '?'}: RelationValue<${capitalize(field.raw.relationTo)}Doc>`;
|
|
13
|
-
};
|