@project-sunbird/collection-editor-react 0.1.17 → 0.1.19

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.
@@ -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;
@@ -5,10 +5,18 @@ export type { IFieldConfig } from './useFieldPrepare';
5
5
  /**
6
6
  * useCascade
7
7
  *
8
- * Resets a child field's value whenever one of its parent fields (declared via
9
- * `depends`) changes. The child's *options* are recomputed reactively in
10
- * useFieldPrepare (filtered by the parent's selected value via term
11
- * associations), so this hook only has to clear the now-stale child value.
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
- export declare function useFieldPrepare(formConfig: Array<Record<string, unknown>>, nodeMetadata: Record<string, unknown>, frameworkDetails: IFrameworkDetails, isRoot: boolean): PreparedField[];
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,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 {};
@@ -0,0 +1,16 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+
3
+ interface UseQumlContentOptions {
4
+ enabled?: boolean;
5
+ }
6
+ /**
7
+ * Fetches and assembles the QuestionSet metadata a QuML player needs.
8
+ * - reads the questionset hierarchy
9
+ * - collects all question identifiers from the tree
10
+ * - fetches full question bodies via /question/v2/list
11
+ * - replaces question stubs in the hierarchy with the full data
12
+ * - backfills outcomeDeclaration.maxScore where missing
13
+ * The result is passed straight to <sunbird-quml-player> as `metadata`.
14
+ */
15
+ export declare function useQumlContent(questionSetId: string, options?: UseQumlContentOptions): UseQueryResult<Record<string, unknown>, Error>;
16
+ export {};