@project-sunbird/collection-editor-react 0.1.16 → 0.1.18
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/framework.d.ts +17 -0
- package/dist/collection-editor.umd.js +93 -93
- package/dist/components/SparkMetaForm/hooks/emitTransform.d.ts +17 -0
- package/dist/components/SparkMetaForm/hooks/emitTransform.test.d.ts +1 -0
- package/dist/components/SparkMetaForm/hooks/useCascade.d.ts +12 -4
- package/dist/components/SparkMetaForm/hooks/useFieldPrepare.d.ts +33 -1
- package/dist/components/SparkMetaForm/hooks/useFieldPrepare.defaults.test.d.ts +1 -0
- package/dist/components/SparkMetaForm/hooks/useFieldPrepare.test.d.ts +1 -0
- package/dist/hooks/useFrameworkOptions.d.ts +20 -0
- package/dist/index.cjs +93 -93
- package/dist/index.js +6534 -6347
- package/dist/store/editor.store.d.ts +3 -0
- package/dist/types/framework.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const EMIT_OMIT_KEYS: readonly ["allowECM", "levels", "setPeriod", "instances"];
|
|
2
|
+
export declare function createLevels(levels: unknown[]): Record<string, {
|
|
3
|
+
label: unknown;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Transform the full form value object before it is written to the node /
|
|
7
|
+
* emitted — used for batch / cascade writes (Angular emits the whole `data`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformEmit(values: Record<string, unknown>, opts?: {
|
|
10
|
+
isReview?: boolean;
|
|
11
|
+
nodeTitle?: string;
|
|
12
|
+
}): Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Transform a single changed field into the patch to persist. Returns null
|
|
15
|
+
* when the field is UI-only and must not be written (allowECM / setPeriod).
|
|
16
|
+
*/
|
|
17
|
+
export declare function transformFieldPatch(changedField: string, value: unknown): Record<string, unknown> | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,10 +5,18 @@ export type { IFieldConfig } from './useFieldPrepare';
|
|
|
5
5
|
/**
|
|
6
6
|
* useCascade
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* When a parent field changes, clear every field that depends on it —
|
|
9
|
+
* TRANSITIVELY, in a single pass (board → clears medium → grade → subject all
|
|
10
|
+
* at once). Mirrors Angular's `resetDependents` (spark-meta-form.component.ts:
|
|
11
|
+
* 449-465), which walks the full `depends` graph rather than relying on the
|
|
12
|
+
* RHF watch ripple to clear one level per microtask.
|
|
13
|
+
*
|
|
14
|
+
* The child's *options* are recomputed reactively in useFieldPrepare (filtered
|
|
15
|
+
* by the parent's selected value via term associations), so this hook only has
|
|
16
|
+
* to clear the now-stale child values.
|
|
17
|
+
*
|
|
18
|
+
* A re-entrancy guard stops the setValue calls we make here from re-triggering
|
|
19
|
+
* the watch callback and clearing the same fields again.
|
|
12
20
|
*
|
|
13
21
|
* @param form react-hook-form UseFormReturn instance.
|
|
14
22
|
* @param fields Prepared field list (carries the `depends` graph).
|
|
@@ -40,4 +40,36 @@ export interface IFieldConfig extends PreparedField {
|
|
|
40
40
|
identifier: string;
|
|
41
41
|
}>;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Extra context the form needs to seed defaults / ranges and to decide
|
|
45
|
+
* per-field editability — mirrors the data Angular reads from EditorService,
|
|
46
|
+
* HelperService.channelInfo and ConfigService inside `prepareFields` /
|
|
47
|
+
* `ifFieldIsEditable`. All fields optional so existing callers keep working.
|
|
48
|
+
*/
|
|
49
|
+
export interface IPrepareContext {
|
|
50
|
+
editorMode?: string;
|
|
51
|
+
/** editorConfig.config.editableFields — { review: ['name', …], … }. */
|
|
52
|
+
editableFields?: Record<string, string[]>;
|
|
53
|
+
/** editorConfig.config.objectType — picks the channel additionalCategories source. */
|
|
54
|
+
objectType?: string;
|
|
55
|
+
setDefaultCopyRight?: boolean;
|
|
56
|
+
/** editorConfig.context.defaultLicense */
|
|
57
|
+
defaultLicense?: string;
|
|
58
|
+
/** editorConfig.context.additionalCategories (fallback). */
|
|
59
|
+
contextAdditionalCategories?: string[];
|
|
60
|
+
/** editorConfig.context.user.fullName */
|
|
61
|
+
userFullName?: string;
|
|
62
|
+
/** channelInfo.name — used as default copyright when setDefaultCopyRight. */
|
|
63
|
+
channelName?: string;
|
|
64
|
+
/** channelInfo.collectionAdditionalCategories */
|
|
65
|
+
collectionAdditionalCategories?: string[];
|
|
66
|
+
/** channelInfo.contentAdditionalCategories */
|
|
67
|
+
contentAdditionalCategories?: string[];
|
|
68
|
+
/** Count of the active node's direct children — feeds maxQuestions range. */
|
|
69
|
+
childCount?: number;
|
|
70
|
+
}
|
|
71
|
+
export declare function useFieldPrepare(formConfig: Array<Record<string, unknown>>, nodeMetadata: Record<string, unknown>, frameworkDetails: IFrameworkDetails, isRoot: boolean, ctx?: IPrepareContext): PreparedField[];
|
|
72
|
+
export declare function __computeFieldOptionsForTest(field: Record<string, unknown>, fw: IFrameworkDetails, nodeMetadata: Record<string, unknown>, siblingFields?: Array<Record<string, unknown>>): Array<{
|
|
73
|
+
label: string;
|
|
74
|
+
value: string;
|
|
75
|
+
}> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface ChannelFramework {
|
|
2
|
+
identifier: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Build the option list for the `framework` (Course Type) field.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors Angular's getFrameworkDetails (editor.component.ts:277-318):
|
|
10
|
+
* - Start from the channel's frameworks.
|
|
11
|
+
* - If the category definition declares `orgFWType`, restrict to frameworks of
|
|
12
|
+
* those types; for any declared type the channel does NOT cover, fetch the
|
|
13
|
+
* system-default frameworks of that type via composite search and merge them.
|
|
14
|
+
* - With no `orgFWType`, fall back to all channel frameworks.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useFrameworkOptions(channelFrameworks: ChannelFramework[] | undefined, orgFWType: string[] | undefined, channel: string | undefined): Array<{
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|