@project-sunbird/sunbird-questionset-editor-web-component-react 0.1.15 → 0.1.17

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.
@@ -23,6 +23,15 @@ export interface SparkMetaFormProps {
23
23
  * undefined (i.e. the "Details" tab).
24
24
  */
25
25
  section?: string;
26
+ /**
27
+ * Bypasses the `section` tab logic entirely — every visible field is
28
+ * rendered regardless of its own `section`. For a caller with no tabs at
29
+ * all (the question editor's Details form, the read-only question meta
30
+ * view): omitting `section` there would otherwise mean "show only the
31
+ * untabbed fields" (root's Details-tab meaning), silently dropping any
32
+ * framework-driven category field tagged 'Audience & Curriculum'.
33
+ */
34
+ showAllSections?: boolean;
26
35
  /**
27
36
  * Framework terms keyed by sourceCategory (e.g. "board", "medium",
28
37
  * "gradeLevel", "subject"). When provided, fields whose `sourceCategory`
@@ -33,6 +42,13 @@ export interface SparkMetaFormProps {
33
42
  * — `identifier` is used as the option value, `name` as the visible label.
34
43
  */
35
44
  frameworkTerms?: Map<string, FrameworkTerm[]>;
45
+ /**
46
+ * Category codes in framework order (ascending `index`), from the same
47
+ * `useFramework()` call that produced `frameworkTerms` — see
48
+ * `adaptFieldsForFramework`'s single-vs-multi-select rule below. Only
49
+ * meaningful together with `isRoot`; omit for section/question forms.
50
+ */
51
+ categoryOrder?: string[];
36
52
  /**
37
53
  * True for the root (questionset-level) form only. The "framework" field
38
54
  * (code: 'framework') is special-cased to live-update which framework's
@@ -44,13 +60,18 @@ export interface SparkMetaFormProps {
44
60
  }
45
61
  /** Exported so callers (e.g. ContextualEditor's tab bar) can check whether a
46
62
  * given tab's section has any required field, using the exact same
47
- * matching rule the tab's own <SparkMetaForm section="..."/> render uses. */
48
- export declare function fieldMatchesSection(field: ICategoryField, section?: string): boolean;
63
+ * matching rule the tab's own <SparkMetaForm section="..."/> render uses.
64
+ * `showAllSections` bypasses the tab logic entirely — for a caller with no
65
+ * tabs at all (the question editor's Details form, the read-only question
66
+ * meta view), where "undefined section" must mean "show everything",
67
+ * not "show only the untabbed fields" (root's actual meaning for it). */
68
+ export declare function fieldMatchesSection(field: ICategoryField, section?: string, showAllSections?: boolean): boolean;
49
69
  export declare function findMissingRequiredFields(fields: ICategoryField[], values: Record<string, unknown>): ICategoryField[];
50
70
  export interface SelectOption {
51
71
  value: string;
52
72
  label: string;
53
73
  }
74
+ export declare function adaptFieldsForFramework(fields: ICategoryField[], frameworkTerms: Map<string, FrameworkTerm[]> | undefined, categoryOrder: string[] | undefined, isRoot: boolean): ICategoryField[];
54
75
  export interface SingleSelectDropdownProps {
55
76
  fieldId: string;
56
77
  value: string;
@@ -1,8 +1,41 @@
1
1
  import { IFramework, ITerm } from '../types/framework';
2
- export declare function useFramework(): {
2
+ /**
3
+ * @param overrideFrameworkId - Resolves categories against this framework
4
+ * instead of the root/live one, fully locally to the caller — e.g. a
5
+ * question that picked its own Framework in its Details form. Does not
6
+ * touch editor.store's contentFramework or affect any other caller; target
7
+ * frameworks still come from root (questions have no targetFWIds concept of
8
+ * their own). Omit for the existing root-level behaviour, unchanged.
9
+ */
10
+ export declare function useFramework(overrideFrameworkId?: string): {
3
11
  orgFramework: NoInfer<IFramework> | undefined;
4
12
  targetFrameworks: IFramework[];
5
13
  isLoading: boolean;
6
14
  targetFrameworkIds: string[];
7
15
  frameworkTerms: Map<string, ITerm[]>;
16
+ categoryOrder: string[];
8
17
  };
18
+ /**
19
+ * Same target-framework precedence useFramework() applies internally
20
+ * (rootMeta.targetFWIds wins over the host-supplied config) — extracted for
21
+ * plain, non-hook code that needs to resolve the same ids without
22
+ * subscribing to store changes (useSaveQuestion.ts, reading straight out of
23
+ * getState() at save time to sweep target frameworks' categories into the
24
+ * taxonomy payload, same as this hook's frameworkTerms merge does).
25
+ */
26
+ export declare function resolveTargetFrameworkIds(): string[];
27
+ /**
28
+ * Every category code seen across ANY framework fetched this session (the
29
+ * query cache) — the full universe of fields a framework switch could ever
30
+ * have populated, not just the one framework being switched away from.
31
+ *
32
+ * Two frameworks can define the SAME category code with different terms
33
+ * (e.g. both TPD and USF using `industry`/`domain`/`skill`) — clearing only
34
+ * the outgoing framework's own codes leaves a shared code's VALUE sitting
35
+ * in state, so it silently reappears pre-filled the moment a framework that
36
+ * also has that code is selected, even though the user never entered it
37
+ * under the new framework. Clearing this entire known universe on every
38
+ * framework switch (ContextualEditor.tsx's handleFrameworkChange) — not
39
+ * just the outgoing framework's codes — guarantees no such carryover.
40
+ */
41
+ export declare function allKnownFrameworkCategoryCodes(): Set<string>;