@e-llm-studio/instant-learning 1.3.13 → 1.3.15-alpha.1
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/ComponentRegistry.js +4 -0
- package/dist/ComponentRegistry.js.map +1 -1
- package/dist/ILMarketplaceWrapper.js +29 -4
- package/dist/ILMarketplaceWrapper.js.map +1 -1
- package/dist/cjs/ComponentRegistry.js +4 -0
- package/dist/cjs/ComponentRegistry.js.map +1 -1
- package/dist/cjs/ILMarketplaceWrapper.js +29 -4
- package/dist/cjs/ILMarketplaceWrapper.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/ILOTJ.js +5 -1
- package/dist/cjs/features/IL-OTJ/ILOTJ.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +21 -7
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +16 -9
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +188 -30
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
- package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js +31 -15
- package/dist/cjs/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
- package/dist/cjs/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
- package/dist/cjs/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/hooks/useVariantEditSession.js +21 -7
- package/dist/cjs/features/IL-OTJ/_components/hooks/useVariantEditSession.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/_components/templates/SchemaDriven/SchemaDrivenCreateRule.js +5 -3
- package/dist/cjs/features/IL-OTJ/_components/templates/SchemaDriven/SchemaDrivenCreateRule.js.map +1 -1
- package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js +19 -0
- package/dist/cjs/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
- package/dist/cjs/features/IL-OTJ/helpers/utils.js +45 -1
- package/dist/cjs/features/IL-OTJ/helpers/utils.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js +26 -0
- package/dist/cjs/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js +27 -2
- package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js +6 -5
- package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +5 -2
- package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js +1 -0
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
- package/dist/cjs/features/IL-marketplace/components/LearningManagementWrapper.js +4 -1
- package/dist/cjs/features/IL-marketplace/components/LearningManagementWrapper.js.map +1 -1
- package/dist/cjs/features/IL-marketplace/services/IL-marketplace.api.js +6 -1
- package/dist/cjs/features/IL-marketplace/services/IL-marketplace.api.js.map +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js +5 -1
- package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js.map +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +31 -7
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +47 -18
- package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
- package/dist/cjs/features/LearningManagement/store/useEnvStore.js +2 -0
- package/dist/cjs/features/LearningManagement/store/useEnvStore.js.map +1 -1
- package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +2 -1
- package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +7 -1
- package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js.map +1 -1
- package/dist/cjs/schema-driven/BPARenderer.js +80 -12
- package/dist/cjs/schema-driven/BPARenderer.js.map +1 -1
- package/dist/cjs/schema-driven/components/FileUploadField.js +815 -0
- package/dist/cjs/schema-driven/components/FileUploadField.js.map +1 -0
- package/dist/cjs/schema-driven/components/FileUploadField.module.css.js +12 -0
- package/dist/cjs/schema-driven/components/FileUploadField.module.css.js.map +1 -0
- package/dist/cjs/schema-driven/components/GroupEditRow.js +3 -2
- package/dist/cjs/schema-driven/components/GroupEditRow.js.map +1 -1
- package/dist/cjs/schema-driven/components/PromptTextEditorField.js +71 -23
- package/dist/cjs/schema-driven/components/PromptTextEditorField.js.map +1 -1
- package/dist/cjs/schema-driven/components/VariantListField.js +135 -13
- package/dist/cjs/schema-driven/components/VariantListField.js.map +1 -1
- package/dist/cjs/schema-driven/hooks/useUnifiedEditSession.js +147 -0
- package/dist/cjs/schema-driven/hooks/useUnifiedEditSession.js.map +1 -0
- package/dist/cjs/schema-driven/primitives/Accordion.js +7 -4
- package/dist/cjs/schema-driven/primitives/Accordion.js.map +1 -1
- package/dist/cjs/schema-driven/types.js.map +1 -1
- package/dist/cjs/schema-driven/utils/PayloadUtils.js +2 -2
- package/dist/cjs/schema-driven/utils/PayloadUtils.js.map +1 -1
- package/dist/cjs/schema-driven/utils/fileUploadService.js +461 -0
- package/dist/cjs/schema-driven/utils/fileUploadService.js.map +1 -0
- package/dist/features/IL-OTJ/ILOTJ.js +5 -1
- package/dist/features/IL-OTJ/ILOTJ.js.map +1 -1
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +21 -7
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js.map +1 -1
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +16 -9
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +189 -31
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js.map +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.module.css.js +2 -2
- package/dist/features/IL-OTJ/_components/CriticalGaps.js +31 -15
- package/dist/features/IL-OTJ/_components/CriticalGaps.js.map +1 -1
- package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js +3 -1
- package/dist/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js.map +1 -1
- package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js +31 -8
- package/dist/features/IL-OTJ/_components/MessageRendering/MessageRendering.js.map +1 -1
- package/dist/features/IL-OTJ/_components/hooks/useVariantEditSession.js +21 -8
- package/dist/features/IL-OTJ/_components/hooks/useVariantEditSession.js.map +1 -1
- package/dist/features/IL-OTJ/_components/templates/SchemaDriven/SchemaDrivenCreateRule.js +5 -3
- package/dist/features/IL-OTJ/_components/templates/SchemaDriven/SchemaDrivenCreateRule.js.map +1 -1
- package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js +14 -0
- package/dist/features/IL-OTJ/helpers/rhsFieldAttention.js.map +1 -0
- package/dist/features/IL-OTJ/helpers/utils.js +45 -2
- package/dist/features/IL-OTJ/helpers/utils.js.map +1 -1
- package/dist/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js +26 -0
- package/dist/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.js.map +1 -1
- package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js +27 -2
- package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
- package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js +6 -5
- package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
- package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +5 -2
- package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js +1 -0
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.js.map +1 -1
- package/dist/features/IL-marketplace/components/GuidelineLibraryCard.module.css.js +2 -2
- package/dist/features/IL-marketplace/components/LearningManagementWrapper.js +4 -1
- package/dist/features/IL-marketplace/components/LearningManagementWrapper.js.map +1 -1
- package/dist/features/IL-marketplace/services/IL-marketplace.api.js +6 -1
- package/dist/features/IL-marketplace/services/IL-marketplace.api.js.map +1 -1
- package/dist/features/LearningManagement/RuleContent/VariantCard.js +6 -2
- package/dist/features/LearningManagement/RuleContent/VariantCard.js.map +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +32 -8
- package/dist/features/LearningManagement/components/InstantLearningModal.js.map +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +48 -19
- package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js.map +1 -1
- package/dist/features/LearningManagement/store/useEnvStore.js +2 -0
- package/dist/features/LearningManagement/store/useEnvStore.js.map +1 -1
- package/dist/features/LearningManagement/store/useLMSConfigStore.js +2 -1
- package/dist/features/LearningManagement/store/useLMSConfigStore.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +8 -2
- package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js.map +1 -1
- package/dist/schema-driven/BPARenderer.js +81 -13
- package/dist/schema-driven/BPARenderer.js.map +1 -1
- package/dist/schema-driven/components/FileUploadField.js +811 -0
- package/dist/schema-driven/components/FileUploadField.js.map +1 -0
- package/dist/schema-driven/components/FileUploadField.module.css.js +8 -0
- package/dist/schema-driven/components/FileUploadField.module.css.js.map +1 -0
- package/dist/schema-driven/components/GroupEditRow.js +3 -2
- package/dist/schema-driven/components/GroupEditRow.js.map +1 -1
- package/dist/schema-driven/components/PromptTextEditorField.js +71 -23
- package/dist/schema-driven/components/PromptTextEditorField.js.map +1 -1
- package/dist/schema-driven/components/VariantListField.js +136 -14
- package/dist/schema-driven/components/VariantListField.js.map +1 -1
- package/dist/schema-driven/hooks/useUnifiedEditSession.js +143 -0
- package/dist/schema-driven/hooks/useUnifiedEditSession.js.map +1 -0
- package/dist/schema-driven/primitives/Accordion.js +7 -4
- package/dist/schema-driven/primitives/Accordion.js.map +1 -1
- package/dist/schema-driven/types.js.map +1 -1
- package/dist/schema-driven/utils/PayloadUtils.js +2 -2
- package/dist/schema-driven/utils/PayloadUtils.js.map +1 -1
- package/dist/schema-driven/utils/fileUploadService.js +443 -0
- package/dist/schema-driven/utils/fileUploadService.js.map +1 -0
- package/dist/types/src/ComponentRegistry.d.ts.map +1 -1
- package/dist/types/src/ILMarketplaceMockTest.d.ts.map +1 -1
- package/dist/types/src/ILMarketplaceWrapper.d.ts +8 -1
- package/dist/types/src/ILMarketplaceWrapper.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/ILOTJ.d.ts +3 -0
- package/dist/types/src/features/IL-OTJ/ILOTJ.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts +4 -0
- package/dist/types/src/features/IL-OTJ/_components/ChatComponents/ChatComponent.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts +2 -1
- package/dist/types/src/features/IL-OTJ/_components/CriticalGaps.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts +2 -1
- package/dist/types/src/features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/MessageRendering/MessageRendering.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/hooks/useVariantEditSession.d.ts +3 -3
- package/dist/types/src/features/IL-OTJ/_components/hooks/useVariantEditSession.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/templates/SchemaDriven/SchemaDrivenCreateRule.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts +7 -0
- package/dist/types/src/features/IL-OTJ/helpers/rhsFieldAttention.d.ts.map +1 -0
- package/dist/types/src/features/IL-OTJ/helpers/utils.d.ts +12 -2
- package/dist/types/src/features/IL-OTJ/helpers/utils.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/PromoteFlow/EnvironmentConfigurationModal.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/PromoteFlow/PromoteFlow.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts +4 -0
- package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/GuidelineLibraryCard.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/components/LearningManagementWrapper.d.ts +3 -1
- package/dist/types/src/features/IL-marketplace/components/LearningManagementWrapper.d.ts.map +1 -1
- package/dist/types/src/features/IL-marketplace/services/IL-marketplace.api.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/VariantCard.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts +5 -0
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts +11 -0
- package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts +2 -0
- package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +3 -0
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
- package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
- package/dist/types/src/schema-driven/BPARenderer.d.ts +4 -0
- package/dist/types/src/schema-driven/BPARenderer.d.ts.map +1 -1
- package/dist/types/src/schema-driven/components/FileUploadField.d.ts +81 -0
- package/dist/types/src/schema-driven/components/FileUploadField.d.ts.map +1 -0
- package/dist/types/src/schema-driven/components/GroupEditRow.d.ts.map +1 -1
- package/dist/types/src/schema-driven/components/PromptTextEditorField.d.ts.map +1 -1
- package/dist/types/src/schema-driven/components/VariantListField.d.ts.map +1 -1
- package/dist/types/src/schema-driven/demoSchema.d.ts.map +1 -1
- package/dist/types/src/schema-driven/hooks/useUnifiedEditSession.d.ts +12 -0
- package/dist/types/src/schema-driven/hooks/useUnifiedEditSession.d.ts.map +1 -0
- package/dist/types/src/schema-driven/primitives/Accordion.d.ts.map +1 -1
- package/dist/types/src/schema-driven/types.d.ts +7 -0
- package/dist/types/src/schema-driven/types.d.ts.map +1 -1
- package/dist/types/src/schema-driven/utils/PayloadUtils.d.ts.map +1 -1
- package/dist/types/src/schema-driven/utils/fileUploadService.d.ts +196 -0
- package/dist/types/src/schema-driven/utils/fileUploadService.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useDynamicFormStore = require('../store/useDynamicFormStore.js');
|
|
7
|
+
var useVariantEditSession = require('../../features/IL-OTJ/_components/hooks/useVariantEditSession.js');
|
|
8
|
+
var conditionText = require('../utils/conditionText.js');
|
|
9
|
+
var editLock = require('../utils/editLock.js');
|
|
10
|
+
|
|
11
|
+
const keyFor = (location, key) => location.kind === "global" ? `global:${key}` : `variant:${location.tier}:${location.index}:${key}`;
|
|
12
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
13
|
+
const isVariantWrapper = (node) => (node == null ? void 0 : node.is_repeatable_variant) || (node == null ? void 0 : node.bpa_ui_component) === "VariantListWrapper";
|
|
14
|
+
const isRepeatable = (node) => (node == null ? void 0 : node.repeatable) || (node == null ? void 0 : node.bpa_ui_component) === "RepeatableSection";
|
|
15
|
+
const conditionValue = (value) => Array.isArray(value) ? value.map((row) => row.text).filter(Boolean).join("\n") : value;
|
|
16
|
+
function useUnifiedEditSession(properties, uiState, state) {
|
|
17
|
+
const variantData = useDynamicFormStore.useDynamicFormStore((s) => s.variantData);
|
|
18
|
+
const [draft, setDraft] = React.useState(null);
|
|
19
|
+
const [original, setOriginal] = React.useState(null);
|
|
20
|
+
const [pending, setPending] = React.useState(false);
|
|
21
|
+
const priorStreaming = React.useRef(uiState == null ? void 0 : uiState.isAiStreaming);
|
|
22
|
+
const sessionId = "unified-form-edit";
|
|
23
|
+
const leaves = React.useMemo(() => {
|
|
24
|
+
const found = [];
|
|
25
|
+
const walk = (props, location) => Object.entries(props || {}).forEach(([name, node]) => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (!node || node.hidden || node.read_only || editLock.isNodeLocked(node, uiState)) return;
|
|
28
|
+
if (isVariantWrapper(node)) {
|
|
29
|
+
const tier = node.tier_key || "tier_1";
|
|
30
|
+
const count = Math.max(((_b = (_a = state == null ? void 0 : state.variantsByTier) == null ? void 0 : _a[tier]) == null ? void 0 : _b.length) || 0, Object.keys((variantData == null ? void 0 : variantData[tier]) || {}).length, 1);
|
|
31
|
+
for (let index = 0; index < count; index += 1) walk(node.properties, { kind: "variant", tier, index });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (node.data_key) {
|
|
35
|
+
const cleanKey = String(node.data_key).replace("global.", "");
|
|
36
|
+
found.push({ node, cleanKey, location, id: keyFor(location, cleanKey) });
|
|
37
|
+
}
|
|
38
|
+
if (node.properties && !isRepeatable(node)) walk(node.properties, location);
|
|
39
|
+
});
|
|
40
|
+
walk(properties, { kind: "global" });
|
|
41
|
+
return found;
|
|
42
|
+
}, [properties, uiState == null ? void 0 : uiState.usedFor, state == null ? void 0 : state.variantsByTier, variantData]);
|
|
43
|
+
const editing = (uiState == null ? void 0 : uiState.activeEditId) === sessionId && !!draft;
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (priorStreaming.current && !(uiState == null ? void 0 : uiState.isAiStreaming)) {
|
|
46
|
+
setPending(false);
|
|
47
|
+
useDynamicFormStore.useDynamicFormStore.getState().clearAllMirages();
|
|
48
|
+
}
|
|
49
|
+
priorStreaming.current = uiState == null ? void 0 : uiState.isAiStreaming;
|
|
50
|
+
}, [uiState == null ? void 0 : uiState.isAiStreaming]);
|
|
51
|
+
const read = (leaf) => {
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
const store = useDynamicFormStore.useDynamicFormStore.getState();
|
|
54
|
+
return leaf.location.kind === "global" ? (_a = store.globalData[leaf.cleanKey]) != null ? _a : "" : (_e = (_d = (_c = (_b = store.variantData) == null ? void 0 : _b[leaf.location.tier]) == null ? void 0 : _c[leaf.location.index]) == null ? void 0 : _d[leaf.cleanKey]) != null ? _e : "";
|
|
55
|
+
};
|
|
56
|
+
const start = () => {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
if ((uiState == null ? void 0 : uiState.activeEditId) && uiState.activeEditId !== sessionId) {
|
|
59
|
+
(_a = uiState == null ? void 0 : uiState.setPendingEditId) == null ? void 0 : _a.call(uiState, uiState.activeEditId);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const snapshot = Object.fromEntries(leaves.map((leaf) => [
|
|
63
|
+
leaf.id,
|
|
64
|
+
leaf.node.bpa_ui_component === "ConditionSection" ? conditionText.splitConditions(String(read(leaf)), leaf.cleanKey) : read(leaf)
|
|
65
|
+
]));
|
|
66
|
+
setOriginal(snapshot);
|
|
67
|
+
setDraft(snapshot);
|
|
68
|
+
(_b = uiState == null ? void 0 : uiState.setActiveEditId) == null ? void 0 : _b.call(uiState, sessionId);
|
|
69
|
+
(_c = uiState == null ? void 0 : uiState.setPendingEditId) == null ? void 0 : _c.call(uiState, null);
|
|
70
|
+
};
|
|
71
|
+
const cancel = () => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
setDraft(null);
|
|
74
|
+
setOriginal(null);
|
|
75
|
+
(_a = uiState == null ? void 0 : uiState.setActiveEditId) == null ? void 0 : _a.call(uiState, null);
|
|
76
|
+
(_b = uiState == null ? void 0 : uiState.setPendingEditId) == null ? void 0 : _b.call(uiState, null);
|
|
77
|
+
};
|
|
78
|
+
const changed = draft && original ? leaves.filter((leaf) => !same(draft[leaf.id], original[leaf.id])) : [];
|
|
79
|
+
const save = () => {
|
|
80
|
+
if (!draft || !original) return;
|
|
81
|
+
if (!changed.length) {
|
|
82
|
+
cancel();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const store = useDynamicFormStore.useDynamicFormStore.getState();
|
|
86
|
+
changed.forEach((leaf) => {
|
|
87
|
+
const value = conditionValue(draft[leaf.id]);
|
|
88
|
+
const direct = leaf.node.ai_generated === false || leaf.node.bpa_ui_component === "PromptTextEditor";
|
|
89
|
+
if (leaf.location.kind === "global") {
|
|
90
|
+
if (direct) store.setGlobalField(leaf.cleanKey, value);
|
|
91
|
+
else store.setGlobalMirage(leaf.cleanKey, value);
|
|
92
|
+
} else if (direct) {
|
|
93
|
+
store.setVariantField(leaf.location.tier, leaf.location.index, leaf.cleanKey, value);
|
|
94
|
+
} else {
|
|
95
|
+
store.setVariantMirage(leaf.location.tier, leaf.location.index, leaf.cleanKey, value);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const aiFields = changed.filter((leaf) => leaf.node.ai_generated !== false && leaf.node.bpa_ui_component !== "PromptTextEditor").map((leaf) => {
|
|
99
|
+
var _a;
|
|
100
|
+
return { action: "update", label: leaf.node.title || leaf.cleanKey, value: String((_a = conditionValue(draft[leaf.id])) != null ? _a : "").trim() || "None" };
|
|
101
|
+
});
|
|
102
|
+
const rhs = changed.filter((leaf) => leaf.node.ai_generated === false && leaf.node.bpa_ui_component !== "PromptTextEditor").map((leaf) => `I have updated ${leaf.node.title || leaf.cleanKey} on RHS`);
|
|
103
|
+
const promptChanged = changed.some((leaf) => leaf.node.bpa_ui_component === "PromptTextEditor");
|
|
104
|
+
const message = [aiFields.length || promptChanged ? useVariantEditSession.buildEditMessage(aiFields, promptChanged) : "", ...rhs].filter(Boolean).join(". ");
|
|
105
|
+
if ((uiState == null ? void 0 : uiState.setSendMessageInChat) && message) {
|
|
106
|
+
uiState.setSendMessageInChat(`__SKELETON__:sk-${Date.now()}:${message}`);
|
|
107
|
+
setPending(true);
|
|
108
|
+
}
|
|
109
|
+
cancel();
|
|
110
|
+
};
|
|
111
|
+
const getOverride = (node, cleanKey, tierKey, variantIndex) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const location = tierKey !== void 0 && variantIndex !== void 0 ? { kind: "variant", tier: tierKey, index: variantIndex } : { kind: "global" };
|
|
114
|
+
const id = keyFor(location, cleanKey);
|
|
115
|
+
const leaf = leaves.find((candidate) => candidate.id === id);
|
|
116
|
+
if (!leaf) return void 0;
|
|
117
|
+
const update = (value) => setDraft((current) => {
|
|
118
|
+
if (!current) return current;
|
|
119
|
+
const next = { ...current, [id]: value };
|
|
120
|
+
leaves.forEach((other) => {
|
|
121
|
+
const sameLocation = other.location.kind === location.kind && (location.kind === "global" || other.location.kind === "variant" && other.location.tier === location.tier && other.location.index === location.index);
|
|
122
|
+
if (sameLocation && other.node.depends_on_global_key === cleanKey) next[other.id] = "";
|
|
123
|
+
});
|
|
124
|
+
return next;
|
|
125
|
+
});
|
|
126
|
+
const base = { readOnly: !editing || !!(uiState == null ? void 0 : uiState.isAiStreaming), enableInlineEdit: false, hideEditControls: true, parentEditing: editing };
|
|
127
|
+
if (!editing) return base;
|
|
128
|
+
if (node.bpa_ui_component !== "ConditionSection") {
|
|
129
|
+
const parentKey = node.depends_on_global_key;
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
value: draft == null ? void 0 : draft[id],
|
|
133
|
+
onChange: update,
|
|
134
|
+
// Dependent dropdowns must filter against the same draft that is being
|
|
135
|
+
// edited, rather than the still-uncommitted store value.
|
|
136
|
+
...parentKey ? { parentValueOverride: (_a = draft == null ? void 0 : draft[keyFor(location, parentKey)]) != null ? _a : "" } : {}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const rows = Array.isArray(draft == null ? void 0 : draft[id]) ? draft[id] : conditionText.splitConditions(String((_b = draft == null ? void 0 : draft[id]) != null ? _b : ""), cleanKey);
|
|
140
|
+
const writeRows = (next) => update(next);
|
|
141
|
+
return { ...base, conditions: rows, onAdd: () => writeRows([...rows, { id: `draft-${Date.now()}`, text: "" }]), onRemove: (_t, _i, rowId) => writeRows(rows.filter((row) => row.id !== rowId)), onEdit: (_t, _i, rowId, text) => writeRows(rows.map((row) => row.id === rowId ? { ...row, text } : row)) };
|
|
142
|
+
};
|
|
143
|
+
return { editing, pending, isSaveDisabled: !draft || !changed.length, start, cancel, save, getOverride };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
exports.useUnifiedEditSession = useUnifiedEditSession;
|
|
147
|
+
//# sourceMappingURL=useUnifiedEditSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnifiedEditSession.js","sources":["../../../../src/schema-driven/hooks/useUnifiedEditSession.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useDynamicFormStore } from '../store/useDynamicFormStore';\nimport { buildEditMessage } from '../../features/IL-OTJ/_components/hooks/useVariantEditSession';\nimport { splitConditions } from '../utils/conditionText';\nimport { isNodeLocked } from '../utils/editLock';\n\ntype Location = { kind: 'global' } | { kind: 'variant'; tier: string; index: number };\ntype Leaf = { node: any; cleanKey: string; location: Location; id: string };\nconst keyFor = (location: Location, key: string) =>\n location.kind === 'global' ? `global:${key}` : `variant:${location.tier}:${location.index}:${key}`;\nconst same = (a: any, b: any) => JSON.stringify(a) === JSON.stringify(b);\nconst isVariantWrapper = (node: any) => node?.is_repeatable_variant || node?.bpa_ui_component === 'VariantListWrapper';\nconst isRepeatable = (node: any) => node?.repeatable || node?.bpa_ui_component === 'RepeatableSection';\nconst conditionValue = (value: any) => Array.isArray(value)\n ? value.map((row) => row.text).filter(Boolean).join('\\n')\n : value;\n\n/** A form-wide draft. It deliberately has no required-field validation: a unified\n * save is allowed to contain just one changed field (or an intentionally blank one). */\nexport function useUnifiedEditSession(properties: Record<string, any>, uiState: any, state: any) {\n const variantData = useDynamicFormStore((s) => s.variantData);\n const [draft, setDraft] = useState<Record<string, any> | null>(null);\n const [original, setOriginal] = useState<Record<string, any> | null>(null);\n const [pending, setPending] = useState(false);\n const priorStreaming = useRef(uiState?.isAiStreaming);\n const sessionId = 'unified-form-edit';\n\n const leaves = useMemo(() => {\n const found: Leaf[] = [];\n const walk = (props: Record<string, any>, location: Location) => Object.entries(props || {}).forEach(([name, node]: [string, any]) => {\n if (!node || node.hidden || node.read_only || isNodeLocked(node, uiState)) return;\n if (isVariantWrapper(node)) {\n const tier = node.tier_key || 'tier_1';\n const count = Math.max(state?.variantsByTier?.[tier]?.length || 0, Object.keys(variantData?.[tier] || {}).length, 1);\n for (let index = 0; index < count; index += 1) walk(node.properties, { kind: 'variant', tier, index });\n return;\n }\n if (node.data_key) {\n const cleanKey = String(node.data_key).replace('global.', '');\n found.push({ node, cleanKey, location, id: keyFor(location, cleanKey) });\n }\n if (node.properties && !isRepeatable(node)) walk(node.properties, location);\n });\n walk(properties, { kind: 'global' });\n return found;\n }, [properties, uiState?.usedFor, state?.variantsByTier, variantData]);\n\n const editing = uiState?.activeEditId === sessionId && !!draft;\n useEffect(() => {\n if (priorStreaming.current && !uiState?.isAiStreaming) {\n setPending(false);\n useDynamicFormStore.getState().clearAllMirages();\n }\n priorStreaming.current = uiState?.isAiStreaming;\n }, [uiState?.isAiStreaming]);\n\n const read = (leaf: Leaf) => {\n const store = useDynamicFormStore.getState();\n return leaf.location.kind === 'global'\n ? store.globalData[leaf.cleanKey] ?? ''\n : store.variantData?.[leaf.location.tier]?.[leaf.location.index]?.[leaf.cleanKey] ?? '';\n };\n const start = () => {\n if (uiState?.activeEditId && uiState.activeEditId !== sessionId) {\n uiState?.setPendingEditId?.(uiState.activeEditId); return;\n }\n const snapshot = Object.fromEntries(leaves.map((leaf) => [\n leaf.id,\n leaf.node.bpa_ui_component === 'ConditionSection'\n ? splitConditions(String(read(leaf)), leaf.cleanKey)\n : read(leaf),\n ]));\n setOriginal(snapshot); setDraft(snapshot);\n uiState?.setActiveEditId?.(sessionId); uiState?.setPendingEditId?.(null);\n };\n const cancel = () => { setDraft(null); setOriginal(null); uiState?.setActiveEditId?.(null); uiState?.setPendingEditId?.(null); };\n const changed = draft && original ? leaves.filter((leaf) => !same(draft[leaf.id], original[leaf.id])) : [];\n const save = () => {\n if (!draft || !original) return;\n if (!changed.length) { cancel(); return; }\n const store = useDynamicFormStore.getState();\n changed.forEach((leaf) => {\n const value = conditionValue(draft[leaf.id]);\n const direct = leaf.node.ai_generated === false || leaf.node.bpa_ui_component === 'PromptTextEditor';\n if (leaf.location.kind === 'global') {\n if (direct) store.setGlobalField(leaf.cleanKey, value);\n else store.setGlobalMirage(leaf.cleanKey, value);\n } else if (direct) {\n store.setVariantField(leaf.location.tier, leaf.location.index, leaf.cleanKey, value);\n } else {\n store.setVariantMirage(leaf.location.tier, leaf.location.index, leaf.cleanKey, value);\n }\n });\n const aiFields = changed.filter((leaf) => leaf.node.ai_generated !== false && leaf.node.bpa_ui_component !== 'PromptTextEditor')\n .map((leaf) => ({ action: 'update' as const, label: leaf.node.title || leaf.cleanKey, value: String(conditionValue(draft[leaf.id]) ?? '').trim() || 'None' }));\n const rhs = changed.filter((leaf) => leaf.node.ai_generated === false && leaf.node.bpa_ui_component !== 'PromptTextEditor')\n .map((leaf) => `I have updated ${leaf.node.title || leaf.cleanKey} on RHS`);\n const promptChanged = changed.some((leaf) => leaf.node.bpa_ui_component === 'PromptTextEditor');\n const message = [aiFields.length || promptChanged ? buildEditMessage(aiFields, promptChanged) : '', ...rhs].filter(Boolean).join('. ');\n if (uiState?.setSendMessageInChat && message) {\n uiState.setSendMessageInChat(`__SKELETON__:sk-${Date.now()}:${message}`); setPending(true);\n }\n cancel();\n };\n const getOverride = (node: any, cleanKey: string, tierKey?: string, variantIndex?: number) => {\n const location: Location = tierKey !== undefined && variantIndex !== undefined\n ? { kind: 'variant', tier: tierKey, index: variantIndex } : { kind: 'global' };\n const id = keyFor(location, cleanKey);\n const leaf = leaves.find((candidate) => candidate.id === id);\n if (!leaf) return undefined;\n const update = (value: any) => setDraft((current) => {\n if (!current) return current;\n const next = { ...current, [id]: value };\n // Match the existing section/group-edit dependency rule using the unified\n // draft, so changing Category clears its now-stale Sub-Category.\n leaves.forEach((other) => {\n const sameLocation = other.location.kind === location.kind\n && (location.kind === 'global' || (other.location.kind === 'variant' && other.location.tier === location.tier && other.location.index === location.index));\n if (sameLocation && other.node.depends_on_global_key === cleanKey) next[other.id] = '';\n });\n return next;\n });\n const base: any = { readOnly: !editing || !!uiState?.isAiStreaming, enableInlineEdit: false, hideEditControls: true, parentEditing: editing };\n if (!editing) return base;\n if (node.bpa_ui_component !== 'ConditionSection') {\n const parentKey = node.depends_on_global_key;\n return {\n ...base,\n value: draft?.[id],\n onChange: update,\n // Dependent dropdowns must filter against the same draft that is being\n // edited, rather than the still-uncommitted store value.\n ...(parentKey ? { parentValueOverride: draft?.[keyFor(location, parentKey)] ?? '' } : {}),\n };\n }\n const rows = Array.isArray(draft?.[id]) ? draft![id] : splitConditions(String(draft?.[id] ?? ''), cleanKey);\n const writeRows = (next: any[]) => update(next);\n return { ...base, conditions: rows, onAdd: () => writeRows([...rows, { id: `draft-${Date.now()}`, text: '' }]), onRemove: (_t: any, _i: any, rowId: any) => writeRows(rows.filter((row: any) => row.id !== rowId)), onEdit: (_t: any, _i: any, rowId: any, text: string) => writeRows(rows.map((row: any) => row.id === rowId ? { ...row, text } : row)) };\n };\n return { editing, pending, isSaveDisabled: !draft || !changed.length, start, cancel, save, getOverride };\n}\n"],"names":["useDynamicFormStore","useState","useRef","useMemo","isNodeLocked","useEffect","splitConditions","buildEditMessage"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,CAAC,QAAA,EAAoB,GAClC,KAAA,QAAA,CAAS,SAAS,QAAW,GAAA,CAAA,OAAA,EAAU,GAAG,CAAA,CAAA,GAAK,WAAW,QAAS,CAAA,IAAI,IAAI,QAAS,CAAA,KAAK,IAAI,GAAG,CAAA,CAAA,CAAA;AAClG,MAAM,IAAA,GAAO,CAAC,CAAA,EAAQ,CAAW,KAAA,IAAA,CAAK,UAAU,CAAC,CAAA,KAAM,IAAK,CAAA,SAAA,CAAU,CAAC,CAAA,CAAA;AACvE,MAAM,mBAAmB,CAAC,IAAA,KAAA,CAAc,IAAM,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAA,qBAAA,KAAA,CAAyB,6BAAM,gBAAqB,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AU,CAAA,CAAC,GAAG,IAAA,EAAM,EAAE,EAAA,EAAI,CAAS,MAAA,EAAA,IAAA,CAAK,GAAI,EAAC,CAAI,CAAA,EAAA,IAAA,EAAM,EAAG,EAAC,CAAC,CAAA,EAAG,QAAU,EAAA,CAAC,EAAS,EAAA,EAAA,EAAS,KAAe,KAAA,SAAA,CAAU,IAAK,CAAA,MAAA,CAAO,CAAC,GAAA,KAAa,GAAI,CAAA,EAAA,KAAO,KAAK,CAAC,CAAG,EAAA,MAAA,EAAQ,CAAC,EAAA,EAAS,EAAS,EAAA,KAAA,EAAY,IAAiB,KAAA,SAAA,CAAU,IAAK,CAAA,GAAA,CAAI,CAAC,GAAA,KAAa,GAAI,CAAA,EAAA,KAAO,KAAQ,GAAA,EAAE,GAAG,GAAA,EAAK,IAAK,EAAA,GAAI,GAAG,CAAC,CAAE,EAAA,CAAA;AAAA,GAC3V,CAAA;AACA,EAAA,OAAO,EAAE,OAAA,EAAS,OAAS,EAAA,cAAA,EAAgB,CAAC,KAAA,IAAS,CAAC,OAAA,CAAQ,MAAQ,EAAA,KAAA,EAAO,MAAQ,EAAA,IAAA,EAAM,WAAY,EAAA,CAAA;AACzG;;;;"}
|
|
@@ -27,12 +27,15 @@ const Accordion = (props) => {
|
|
|
27
27
|
const { schema, children, renderChildren, uiState } = props;
|
|
28
28
|
const [isOpen, setIsOpen] = React.useState(!!schema.default_open);
|
|
29
29
|
const sectionId = `section-${props.id || schema.title || "accordion"}`;
|
|
30
|
+
const unifiedOwner = !!props.unifiedEditOwner;
|
|
31
|
+
const unifiedSession = props.unifiedEditSession;
|
|
30
32
|
const ownsVariants = useSectionEditSession.sectionHasVariantWrapper(schema.properties);
|
|
31
33
|
const editableLeaves = useSectionEditSession.collectSectionLeaves(schema.properties, uiState);
|
|
32
|
-
const parentEditEnabled = useParentEditEnabled.useParentEditEnabled(schema);
|
|
34
|
+
const parentEditEnabled = useParentEditEnabled.useParentEditEnabled(schema) && !props.unifiedEditSession;
|
|
33
35
|
const editLocked = editLock.isWrapperEditLocked(schema, uiState);
|
|
34
|
-
const useEditSession = parentEditEnabled && !ownsVariants && editableLeaves.length > 0 && !editLocked;
|
|
35
|
-
const
|
|
36
|
+
const useEditSession = unifiedOwner || parentEditEnabled && !ownsVariants && editableLeaves.length > 0 && !editLocked;
|
|
37
|
+
const localSession = useSectionEditSession.useSectionEditSession(sectionId, schema.properties, uiState);
|
|
38
|
+
const session = unifiedOwner ? { ...unifiedSession, isEditing: unifiedSession == null ? void 0 : unifiedSession.editing, isPending: unifiedSession == null ? void 0 : unifiedSession.pending, isEmpty: false } : localSession;
|
|
36
39
|
if (!useEditSession) {
|
|
37
40
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { border: "1px solid var(--il-border, #E2E8F0)", borderRadius: 12, marginBottom: 12, overflow: "hidden" }, children: [
|
|
38
41
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -69,7 +72,7 @@ const Accordion = (props) => {
|
|
|
69
72
|
),
|
|
70
73
|
isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 16, display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
71
74
|
schema.subtitle && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontFamily: "Inter", fontWeight: 400, fontSize: 12, lineHeight: "130%", color: "var(--il-muted, #64748B)" }, children: schema.subtitle }),
|
|
72
|
-
editLock.isNodeLocked(schema, uiState) && renderChildren ? renderChildren(void 0, editLock.buildLockedSubtreeOverrides(schema.properties)) : children
|
|
75
|
+
editLock.isNodeLocked(schema, uiState) && renderChildren ? renderChildren(void 0, editLock.buildLockedSubtreeOverrides(schema.properties)) : renderChildren && props.unifiedEditSession ? renderChildren(void 0, void 0) : children
|
|
73
76
|
] })
|
|
74
77
|
] });
|
|
75
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../../src/schema-driven/primitives/Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { ChevronDown, AlertTriangle } from 'lucide-react';\nimport { SchemaComponentProps } from '../types';\nimport AccordionSection from '../../features/IL-OTJ/_components/AccordianSection';\nimport { EditPencilIcon } from '../../features/IL-OTJ/_components/_svg/EditPencilIcon';\nimport { useSectionEditSession, sectionHasVariantWrapper, collectSectionLeaves } from '../hooks/useSectionEditSession';\nimport { useParentEditEnabled } from '../hooks/useParentEditEnabled';\nimport { isWrapperEditLocked, isNodeLocked, buildLockedSubtreeOverrides } from '../utils/editLock';\n\nconst ghostButtonStyle: React.CSSProperties = {\n display: 'flex', alignItems: 'center', gap: '7px', padding: '7px 10.5px',\n borderRadius: '6px', border: '1px solid var(--il-primary, #D9D6FE)', color: 'var(--il-primary, #2563EB)', fontSize: '14px', fontWeight: 500,\n};\n\n/**\n * Generic, reusable collapsible container. Registered as `bpa_ui_component: \"Accordion\"`.\n * Any schema node with nested `properties` and this component name renders its\n * children inside a togglable section — no per-field knowledge required.\n *\n * With `parent_edit: true` on the section node, its editable leaves are drafted\n * together behind ONE \"Edit\" (header top-right, with ghost Save/Cancel) and the children\n * drop their own inline pencils — matching the variant accordions. The action reads\n * \"Add\" while every leaf in the section is still empty. Without the flag\n * the section stays a plain collapsible and each field keeps its own inline edit.\n * Sections holding a variant wrapper are always excluded: those belong to\n * VariantListField's own per-variant session.\n *\n * Outside the dynamic form there is no schema node to carry the flag, so the gate\n * falls back to `backwardCompatibility === false` — see useParentEditEnabled.\n */\nconst Accordion: React.FC<SchemaComponentProps> = (props) => {\n const { schema, children, renderChildren, uiState } = props as any;\n const [isOpen, setIsOpen] = useState(!!schema.default_open);\n\n const sectionId = `section-${(props as any).id || schema.title || 'accordion'}`;\n const ownsVariants = sectionHasVariantWrapper(schema.properties);\n const editableLeaves = collectSectionLeaves(schema.properties, uiState);\n const parentEditEnabled = useParentEditEnabled(schema);\n // Edit flow + the section (or every editable leaf in it) frozen → the section keeps\n // rendering, it just loses its Edit button; `editableLeaves` is already empty when\n // all leaves are frozen, which alone drops the session.\n const editLocked = isWrapperEditLocked(schema, uiState);\n const useEditSession = parentEditEnabled && !ownsVariants && editableLeaves.length > 0 && !editLocked;\n\n const session = useSectionEditSession(sectionId, schema.properties, uiState);\n\n if (!useEditSession) {\n return (\n <div style={{ border: '1px solid var(--il-border, #E2E8F0)', borderRadius: 12, marginBottom: 12, overflow: 'hidden' }}>\n <button\n type=\"button\"\n onClick={() => setIsOpen((open) => !open)}\n aria-expanded={isOpen}\n style={{\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: '12px 16px',\n background: 'var(--il-surface-alt, #f8fafc)',\n border: 'none',\n cursor: 'pointer',\n fontSize: 14,\n fontWeight: 500,\n color: 'var(--il-foreground, #19213D)',\n fontFamily: '\"Plus Jakarta Sans\", sans-serif',\n }}\n >\n {schema.title}\n <ChevronDown\n size={18}\n style={{ transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }}\n />\n </button>\n {isOpen && (\n <div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 12 }}>\n {(schema as any).subtitle && (\n <div style={{ fontFamily: 'Inter', fontWeight: 400, fontSize: 12, lineHeight: '130%', color: 'var(--il-muted, #64748B)' }}>\n {(schema as any).subtitle}\n </div>\n )}\n {/* A frozen section freezes its whole subtree, including leaves that don't\n carry the flag themselves — so render them behind read-only overrides. */}\n {isNodeLocked(schema, uiState) && renderChildren\n ? renderChildren(undefined, buildLockedSubtreeOverrides(schema.properties))\n : children}\n </div>\n )}\n </div>\n );\n }\n\n // Edit / Save / Cancel live at the TOP-RIGHT of the section header, exactly like the\n // variant accordions (VariantListField) — one consistent place for section actions.\n const renderHeaderActions = (isOpen: boolean, onToggle: () => void) => {\n if (session.isEditing) {\n return (\n <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>\n <button\n onClick={(e) => { e.stopPropagation(); session.save(); }}\n disabled={session.isSaveDisabled || session.isPending}\n style={{\n ...ghostButtonStyle,\n backgroundColor: session.isPending ? 'var(--il-primary-subtle, #f5f3ff)' : 'var(--il-surface, #ffffff)',\n cursor: (session.isSaveDisabled || session.isPending) ? 'not-allowed' : 'pointer',\n opacity: session.isSaveDisabled ? 0.5 : 1,\n }}\n >\n {session.isPending ? 'Validating...' : 'Save'}\n </button>\n {!session.isPending && (\n <button\n onClick={(e) => { e.stopPropagation(); session.cancel(); }}\n style={{ ...ghostButtonStyle, backgroundColor: 'var(--il-surface, #ffffff)', cursor: 'pointer' }}\n >\n Cancel\n </button>\n )}\n </div>\n );\n }\n\n const isDisabled = session.isPending || !!uiState?.isAiStreaming;\n // Nothing filled in yet → the action reads \"Add\" rather than \"Edit\".\n const label = \"Edit\";\n // session.isEmpty ? 'Add' : 'Edit';\n\n return (\n <button\n title={session.isPending ? 'Validating...' : label}\n onClick={(e) => {\n e.stopPropagation();\n session.start();\n if (!isOpen) onToggle();\n }}\n disabled={isDisabled}\n style={{\n display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '6px',\n padding: '6px 10px', border: '1px solid var(--il-border, #CBD5E1)', borderRadius: '6px',\n backgroundColor: 'var(--il-surface, #ffffff)', color: 'var(--il-muted, #64748B)', fontSize: '13px', fontWeight: 500,\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n opacity: isDisabled ? 0.5 : 1,\n }}\n >\n {session.isPending ? 'Validating...' : (<><EditPencilIcon size={12} /> {label}</>)}\n </button>\n );\n };\n\n return (\n <div data-edit-id={sectionId}>\n <AccordionSection\n title={{ type: 'other', label: schema.title || '' }}\n subtitle={(schema as any).subtitle}\n defaultOpen={schema.default_open ?? true}\n isAiStreaming={uiState?.isAiStreaming}\n actionButtons={renderHeaderActions}\n // Keep the header actions mounted while streaming so Save can show \"Validating...\".\n alwaysShowActions\n >\n <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>\n {renderChildren ? renderChildren(undefined, session.childOverrides) : children}\n\n {uiState?.pendingEditId === sectionId && (\n <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>\n <AlertTriangle size={14} style={{ color: 'var(--il-warning, #C2410C)' }} />\n <div style={{ color: 'var(--il-warning, #C2410C)', fontSize: '13px' }}>\n Pending - Changes not applied yet. Apply or discard them to continue.\n </div>\n </div>\n )}\n </div>\n </AccordionSection>\n </div>\n );\n};\n\nexport default Accordion;\n"],"names":["useState","sectionHasVariantWrapper","collectSectionLeaves","useParentEditEnabled","isWrapperEditLocked","useSectionEditSession","jsxs","jsx","ChevronDown","isNodeLocked","buildLockedSubtreeOverrides","isOpen","Fragment","EditPencilIcon","AccordionSection","AlertTriangle"],"mappings":";;;;;;;;;;;;;AASA,MAAM,gBAAwC,GAAA;AAAA,EAC5C,OAAS,EAAA,MAAA;AAAA,EAAQ,UAAY,EAAA,QAAA;AAAA,EAAU,GAAK,EAAA,KAAA;AAAA,EAAO,OAAS,EAAA,YAAA;AAAA,EAC5D,YAAc,EAAA,KAAA;AAAA,EAAO,MAAQ,EAAA,sCAAA;AAAA,EAAwC,KAAO,EAAA,4BAAA;AAAA,EAA8B,QAAU,EAAA,MAAA;AAAA,EAAQ,UAAY,EAAA,GAAA;AAC1I,CAAA,CAAA;AAkBM,MAAA,SAAA,GAA4C,CAAC,KAAU,KAAA;AA9B7D,EAAA,IAAA,EAAA,CAAA;AA+BE,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAU,EAAA,cAAA,EAAgB,SAAY,GAAA,KAAA,CAAA;AACtD,EAAM,MAAA,CAAC,QAAQ,SAAS,CAAA,GAAIA,eAAS,CAAC,CAAC,OAAO,YAAY,CAAA,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAY,QAAA,EAAA,KAAA,CAAc,EAAM,IAAA,MAAA,CAAO,SAAS,WAAW,CAAA,CAAA,CAAA;AAC7E,EAAM,MAAA,YAAA,GAAeC,8CAAyB,CAAA,MAAA,CAAO,UAAU,CAAA,CAAA;AAC/D,EAAA,MAAM,cAAiB,GAAAC,0CAAA,CAAqB,MAAO,CAAA,UAAA,EAAY,OAAO,C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,CAAA,YAAA,KAAP,IAAuB,GAAA,EAAA,GAAA,IAAA;AAAA,MACpC,eAAe,OAAS,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,aAAA;AAAA,MACxB,aAAe,EAAA,mBAAA;AAAA,MAEf,iBAAiB,EAAA,IAAA;AAAA,MAEjB,QAAA,kBAAAR,eAAA,CAAC,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,OAAA,EAAS,QAAQ,aAAe,EAAA,QAAA,EAAU,GAAK,EAAA,EAAA,EAC1D,EAAA,QAAA,EAAA;AAAA,QAAA,cAAA,GAAiB,cAAe,CAAA,KAAA,CAAA,EAAW,OAAQ,CAAA,cAAc,CAAI,GAAA,QAAA;AAAA,QAAA,CAErE,OAAS,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,aAAA,MAAkB,SAC1B,oBAAAA,eAAA,CAAC,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,OAAA,EAAS,MAAQ,EAAA,UAAA,EAAY,QAAU,EAAA,GAAA,EAAK,OACxD,EAAA,QAAA,EAAA;AAAA,0BAAAC,cAAA,CAACQ,6BAAc,IAAM,EAAA,EAAA,EAAI,OAAO,EAAE,KAAA,EAAO,8BAAgC,EAAA,CAAA;AAAA,0BACzER,cAAA,CAAC,SAAI,KAAO,EAAA,EAAE,OAAO,4BAA8B,EAAA,QAAA,EAAU,MAAO,EAAA,EAAG,QAEvE,EAAA,uEAAA,EAAA,CAAA;AAAA,SACF,EAAA,CAAA;AAAA,OAEJ,EAAA,CAAA;AAAA,KAAA;AAAA,GAEJ,EAAA,CAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../../../src/schema-driven/primitives/Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { ChevronDown, AlertTriangle } from 'lucide-react';\nimport { SchemaComponentProps } from '../types';\nimport AccordionSection from '../../features/IL-OTJ/_components/AccordianSection';\nimport { EditPencilIcon } from '../../features/IL-OTJ/_components/_svg/EditPencilIcon';\nimport { useSectionEditSession, sectionHasVariantWrapper, collectSectionLeaves } from '../hooks/useSectionEditSession';\nimport { useParentEditEnabled } from '../hooks/useParentEditEnabled';\nimport { isWrapperEditLocked, isNodeLocked, buildLockedSubtreeOverrides } from '../utils/editLock';\n\nconst ghostButtonStyle: React.CSSProperties = {\n display: 'flex', alignItems: 'center', gap: '7px', padding: '7px 10.5px',\n borderRadius: '6px', border: '1px solid var(--il-primary, #D9D6FE)', color: 'var(--il-primary, #2563EB)', fontSize: '14px', fontWeight: 500,\n};\n\n/**\n * Generic, reusable collapsible container. Registered as `bpa_ui_component: \"Accordion\"`.\n * Any schema node with nested `properties` and this component name renders its\n * children inside a togglable section — no per-field knowledge required.\n *\n * With `parent_edit: true` on the section node, its editable leaves are drafted\n * together behind ONE \"Edit\" (header top-right, with ghost Save/Cancel) and the children\n * drop their own inline pencils — matching the variant accordions. The action reads\n * \"Add\" while every leaf in the section is still empty. Without the flag\n * the section stays a plain collapsible and each field keeps its own inline edit.\n * Sections holding a variant wrapper are always excluded: those belong to\n * VariantListField's own per-variant session.\n *\n * Outside the dynamic form there is no schema node to carry the flag, so the gate\n * falls back to `backwardCompatibility === false` — see useParentEditEnabled.\n */\nconst Accordion: React.FC<SchemaComponentProps> = (props) => {\n const { schema, children, renderChildren, uiState } = props as any;\n const [isOpen, setIsOpen] = useState(!!schema.default_open);\n\n const sectionId = `section-${(props as any).id || schema.title || 'accordion'}`;\n const unifiedOwner = !!(props as any).unifiedEditOwner;\n const unifiedSession = (props as any).unifiedEditSession;\n const ownsVariants = sectionHasVariantWrapper(schema.properties);\n const editableLeaves = collectSectionLeaves(schema.properties, uiState);\n // The root unified session owns every section's draft and actions.\n const parentEditEnabled = useParentEditEnabled(schema) && !(props as any).unifiedEditSession;\n // Edit flow + the section (or every editable leaf in it) frozen → the section keeps\n // rendering, it just loses its Edit button; `editableLeaves` is already empty when\n // all leaves are frozen, which alone drops the session.\n const editLocked = isWrapperEditLocked(schema, uiState);\n const useEditSession = unifiedOwner || (parentEditEnabled && !ownsVariants && editableLeaves.length > 0 && !editLocked);\n\n const localSession = useSectionEditSession(sectionId, schema.properties, uiState);\n // The first section retains its usual header controls in unified mode, but they\n // operate on the root draft so every other section opens/saves/cancels with it.\n const session = unifiedOwner\n ? { ...unifiedSession, isEditing: unifiedSession?.editing, isPending: unifiedSession?.pending, isEmpty: false }\n : localSession;\n\n if (!useEditSession) {\n return (\n <div style={{ border: '1px solid var(--il-border, #E2E8F0)', borderRadius: 12, marginBottom: 12, overflow: 'hidden' }}>\n <button\n type=\"button\"\n onClick={() => setIsOpen((open) => !open)}\n aria-expanded={isOpen}\n style={{\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: '12px 16px',\n background: 'var(--il-surface-alt, #f8fafc)',\n border: 'none',\n cursor: 'pointer',\n fontSize: 14,\n fontWeight: 500,\n color: 'var(--il-foreground, #19213D)',\n fontFamily: '\"Plus Jakarta Sans\", sans-serif',\n }}\n >\n {schema.title}\n <ChevronDown\n size={18}\n style={{ transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)', transition: 'transform 0.2s' }}\n />\n </button>\n {isOpen && (\n <div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 12 }}>\n {(schema as any).subtitle && (\n <div style={{ fontFamily: 'Inter', fontWeight: 400, fontSize: 12, lineHeight: '130%', color: 'var(--il-muted, #64748B)' }}>\n {(schema as any).subtitle}\n </div>\n )}\n {/* A frozen section freezes its whole subtree, including leaves that don't\n carry the flag themselves — so render them behind read-only overrides. */}\n {isNodeLocked(schema, uiState) && renderChildren\n ? renderChildren(undefined, buildLockedSubtreeOverrides(schema.properties))\n : (renderChildren && (props as any).unifiedEditSession\n ? renderChildren(undefined, undefined)\n : children)}\n </div>\n )}\n </div>\n );\n }\n\n // Edit / Save / Cancel live at the TOP-RIGHT of the section header, exactly like the\n // variant accordions (VariantListField) — one consistent place for section actions.\n const renderHeaderActions = (isOpen: boolean, onToggle: () => void) => {\n if (session.isEditing) {\n return (\n <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>\n <button\n onClick={(e) => { e.stopPropagation(); session.save(); }}\n disabled={session.isSaveDisabled || session.isPending}\n style={{\n ...ghostButtonStyle,\n backgroundColor: session.isPending ? 'var(--il-primary-subtle, #f5f3ff)' : 'var(--il-surface, #ffffff)',\n cursor: (session.isSaveDisabled || session.isPending) ? 'not-allowed' : 'pointer',\n opacity: session.isSaveDisabled ? 0.5 : 1,\n }}\n >\n {session.isPending ? 'Validating...' : 'Save'}\n </button>\n {!session.isPending && (\n <button\n onClick={(e) => { e.stopPropagation(); session.cancel(); }}\n style={{ ...ghostButtonStyle, backgroundColor: 'var(--il-surface, #ffffff)', cursor: 'pointer' }}\n >\n Cancel\n </button>\n )}\n </div>\n );\n }\n\n const isDisabled = session.isPending || !!uiState?.isAiStreaming;\n // Nothing filled in yet → the action reads \"Add\" rather than \"Edit\".\n const label = \"Edit\";\n // session.isEmpty ? 'Add' : 'Edit';\n\n return (\n <button\n title={session.isPending ? 'Validating...' : label}\n onClick={(e) => {\n e.stopPropagation();\n session.start();\n if (!isOpen) onToggle();\n }}\n disabled={isDisabled}\n style={{\n display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '6px',\n padding: '6px 10px', border: '1px solid var(--il-border, #CBD5E1)', borderRadius: '6px',\n backgroundColor: 'var(--il-surface, #ffffff)', color: 'var(--il-muted, #64748B)', fontSize: '13px', fontWeight: 500,\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n opacity: isDisabled ? 0.5 : 1,\n }}\n >\n {session.isPending ? 'Validating...' : (<><EditPencilIcon size={12} /> {label}</>)}\n </button>\n );\n };\n\n return (\n <div data-edit-id={sectionId}>\n <AccordionSection\n title={{ type: 'other', label: schema.title || '' }}\n subtitle={(schema as any).subtitle}\n defaultOpen={schema.default_open ?? true}\n isAiStreaming={uiState?.isAiStreaming}\n actionButtons={renderHeaderActions}\n // Keep the header actions mounted while streaming so Save can show \"Validating...\".\n alwaysShowActions\n >\n <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>\n {renderChildren ? renderChildren(undefined, session.childOverrides) : children}\n\n {uiState?.pendingEditId === sectionId && (\n <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>\n <AlertTriangle size={14} style={{ color: 'var(--il-warning, #C2410C)' }} />\n <div style={{ color: 'var(--il-warning, #C2410C)', fontSize: '13px' }}>\n Pending - Changes not applied yet. Apply or discard them to continue.\n </div>\n </div>\n )}\n </div>\n </AccordionSection>\n </div>\n );\n};\n\nexport default Accordion;\n"],"names":["useState","sectionHasVariantWrapper","collectSectionLeaves","useParentEditEnabled","isWrapperEditLocked","useSectionEditSession","jsxs","jsx","ChevronDown","isNodeLocked","buildLockedSubtreeOverrides","isOpen","Fragment","EditPencilIcon","AccordionSection","AlertTriangle"],"mappings":";;;;;;;;;;;;;AASA,MAAM,gBAAwC,GAAA;AAAA,EAC5C,OAAS,EAAA,MAAA;AAAA,EAAQ,UAAY,EAAA,QAAA;AAAA,EAAU,GAAK,EAAA,KAAA;AAAA,EAAO,OAAS,EAAA,YAAA;AAAA,EAC5D,YAAc,EAAA,KAAA;AAAA,EAAO,MAAQ,EAAA,sCAAA;AAAA,EAAwC,KAAO,EAAA,4BAAA;AAAA,EAA8B,QAAU,EAAA,MAAA;AAAA,EAAQ,UAAY,EAAA,GAAA;AAC1I,CAAA,CAAA;AAkBM,MAAA,SAAA,GAA4C,CAAC,KAAU,KAAA;AA9B7D,EAAA,IAAA,EAAA,CAAA;AA+BE,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAU,EAAA,cAAA,EAAgB,SAAY,GAAA,KAAA,CAAA;AACtD,EAAM,MAAA,CAAC,QAAQ,SAAS,CAAA,GAAIA,eAAS,CAAC,CAAC,OAAO,YAAY,CAAA,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAY,QAAA,EAAA,KAAA,CAAc,EAAM,IAAA,MAAA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,CAAC,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,OAAA,EAAS,MAAQ,EAAA,UAAA,EAAY,QAAU,EAAA,GAAA,EAAK,OACxD,EAAA,QAAA,EAAA;AAAA,0BAAAC,cAAA,CAACQ,6BAAc,IAAM,EAAA,EAAA,EAAI,OAAO,EAAE,KAAA,EAAO,8BAAgC,EAAA,CAAA;AAAA,0BACzER,cAAA,CAAC,SAAI,KAAO,EAAA,EAAE,OAAO,4BAA8B,EAAA,QAAA,EAAU,MAAO,EAAA,EAAG,QAEvE,EAAA,uEAAA,EAAA,CAAA;AAAA,SACF,EAAA,CAAA;AAAA,OAEJ,EAAA,CAAA;AAAA,KAAA;AAAA,GAEJ,EAAA,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/schema-driven/types.ts"],"sourcesContent":["// src/schema-driven/types.ts\nimport React from 'react';\n\nexport type TableColumnType =\n | 'text'\n | 'number'\n | 'checkbox'\n | 'dropdown'\n | 'readonly'\n | 'badge'\n | 'badgeSelect'\n | 'tags'\n | 'fileType';\n\n/** Configuration consumed by the schema-driven TableComponent. */\nexport interface TableColumnSchema {\n key: string;\n header: string;\n type: TableColumnType;\n options?: (string | { label: string; value: string })[];\n editable?: boolean;\n width?: string;\n placeholder?: string;\n defaultValue?: unknown;\n info?: string;\n badgeMap?: Record<string, { label?: string; tone?: string; color?: string; background?: string }>;\n tagOptions?: string[];\n}\n\n/**\n * Shape of a single node in the `learningMetadataComponents` JSON schema.\n * Mirrors `LMSMetadataField` (useLMSConfigStore) plus the `data_key` field,\n * which is reserved for the upcoming state-binding phase.\n */\nexport interface SchemaFieldNode {\n type?: 'string' | 'array' | 'object' | 'boolean';\n title?: string;\n placeholder?: string;\n /** Optional character limit. Omit for unlimited input. */\n maxLength?: number;\n /** Numeric range input configuration (used by PageRangeInput). */\n minimum?: number;\n step?: number;\n min_label?: string;\n max_label?: string;\n min_prefix?: string;\n max_prefix?: string;\n min_placeholder?: string;\n max_placeholder?: string;\n tooltip?: string;\n description?: string; // AI-facing authoring guideline (\"Guideline to create a ...\")\n /** Optional helper copy rendered under the field's title in the UI — the schema\n * equivalent of the hardcoded `wtaInformation` / `ruleDescriptionInformation`\n * strings the non-dynamic templates read from their renderer config. Every\n * registry component receives this via BPARenderer. */\n subtitle?: string;\n ui_position?: number;\n bpa_ui_component?: string;\n data_key?: string;\n\n // Select/dropdown options (config-driven). Prefer `options`; `enum` is\n // auto-mapped to `{ label, value }` for convenience. `parentValue` lets a\n // dependent dropdown (see `depends_on_global_key`) filter its options by the\n // parent field's selected value\n options?: { label: string; value: string; parentValue?: string }[];\n enum?: Array<string | { label: string; value: string; parentValue?: string }>;\n\n // Dropdown option source / dependency wiring.\n dynamic_options_key?: string; // key into host-injected uiState.dynamicOptions\n depends_on_global_key?: string; // data_key of the parent field to filter by\n\n // Payload Generation Flags\n core_field?: boolean; // true = Root payload, false = learning_metadata\n ui_only?: boolean; // true = Do not send this to the API at all\n ai_generated?: boolean; // true = AI is allowed to write to this field\n is_required?: boolean; // true = field must be filled (validation), distinct from core_field\n\n // UI Behaviors\n read_only?: boolean;\n /** Frozen-after-creation flag (defaults to false). In the EDIT flow the field can\n * never be opened for editing — not even inside a parent edit session — while it\n * stays fully editable during creation. On a wrapper node it freezes the whole\n * subtree and removes that section's Edit button. See utils/editLock.ts. */\n read_only_in_edit_flow?: boolean;\n hidden?: boolean;\n default_open?: boolean;\n is_repeatable_variant?: boolean;\n /** Renders this node's `properties` as an addable/removable list. The node must\n * have a `data_key`; its value is stored as an array of item objects. */\n repeatable?: boolean;\n /** `inline` renders item fields directly in rows with only a trailing delete\n * button. `cards` (the default) renders an Edit/Save card per item. */\n repeatable_layout?: 'cards' | 'inline';\n /** Variant wrapper only: set false to hide the \"Variant N\" pill in each variant\n * accordion header. Defaults to true (pill shown). */\n show_variant_pill?: boolean;\n /** Section-level editing. On an `Accordion` or `VariantListWrapper` node, the\n * section's fields are drafted together behind ONE Edit (with a single combined\n * Save) and their individual inline pencils are suppressed. Omit it to keep\n * per-field inline editing. */\n parent_edit?: boolean;\n group_edit?: boolean;\n group_title?: string;\n /** Horizontal placement of a field within a FlexRow column. */\n layout_align?: 'start' | 'center' | 'end';\n /** TableComponent column definitions. Row data is stored under `data_key`. */\n columns?: TableColumnSchema[];\n /** Optional schema-level initial rows; host/API values take precedence. */\n rows?: Record<string, unknown>[];\n /** Show row drag handles and allow rows to be reordered. */\n reorderable?: boolean;\n /** Show the interactive per-row lock control. */\n lockable?: boolean;\n /** Row property used to persist the interactive lock state. */\n lockedKey?: string;\n properties?: Record<string, SchemaFieldNode>;\n}\n\n/** Root shape of `learningMetadataComponents` itself. */\nexport interface SchemaRoot {\n type?: string;\n title?: string;\n properties?: Record<string, SchemaFieldNode>;\n}\n\n/**\n * Uniform prop contract every registry-resolved component must accept.\n * Container components (`isContainer: true` in the registry) receive the\n * recursively rendered subtree as `children`; leaf components ignore it.\n */\nexport interface SchemaComponentProps {\n id?: string;\n schema: SchemaFieldNode;\n value?: any;\n onChange?: (val: any) => void;\n readOnly?: boolean;\n errorMessage?: string;\n isAiStreaming?: boolean;\n children?: React.ReactNode;\n title?: string;\n [key: string]: any; // Allows injected array handlers (onAdd, onRemove) to pass without TS errors\n}\n\n\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\nexport type ColumnType =\n | 'text'\n | 'number'\n | 'checkbox'\n | 'dropdown'\n | 'readonly'\n | 'badge'\n | 'badgeSelect'\n | 'tags'\n | 'fileType';\n\nexport type BadgeTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';\n\nexport interface BadgeConfig {\n /** text shown in the pill; falls back to the raw value */\n label?: string;\n /** built-in color scheme */\n tone?: BadgeTone;\n /** explicit overrides, take precedence over tone */\n color?: string;\n background?: string;\n}\n\nexport interface ColumnDef<T> {\n /** key into the row object this column reads/writes */\n key: Extract<keyof T, string>;\n /** column header label */\n header: string;\n /** which kind of control renders each cell in this column */\n type: ColumnType;\n /** options for type === 'dropdown' */\n options?: string[];\n /** can the user edit this cell? defaults to true (forced false for 'readonly') */\n editable?: boolean;\n /** css width, e.g. '140px' or '1fr' */\n width?: string;\n /** placeholder for text/number inputs */\n placeholder?: string;\n /** value a new row gets for this column when \"Add\" is clicked */\n defaultValue?: T[Extract<keyof T, string>];\n /** custom renderer for a readonly cell's value, e.g. icon + label */\n renderReadonly?: (value: any, row: T) => React.ReactNode;\n /** for type === 'badge' or 'badgeSelect': maps a raw value to a label + color scheme */\n badgeMap?: Record<string, BadgeConfig>;\n /** for type === 'tags': the value is a string[]; these are the choices offered in the \"+ Add\" control */\n tagOptions?: string[];\n /** small (i) tooltip icon shown next to the header label */\n info?: string;\n}\n\nexport interface TableComponentProps<T extends Record<string, any>> {\n /** column configuration — defines both header and how each cell edits */\n columns?: ColumnDef<T>[];\n /** current row data (fully controlled). Used by standalone consumers. */\n rows?: T[];\n /** called with the next rows array whenever anything changes. */\n onRowsChange?: (rows: T[]) => void;\n /** Schema-driven renderer contract: table configuration lives on `schema`. */\n schema?: {\n columns?: ColumnDef<T>[];\n rows?: T[];\n reorderable?: boolean;\n lockable?: boolean;\n lockedKey?: Extract<keyof T, string>;\n orderKey?: Extract<keyof T, string>;\n };\n /** Schema-driven renderer contract: the current array value. */\n value?: T[];\n /** Schema-driven renderer contract: receives the next array value. */\n onChange?: (rows: T[]) => void;\n /** Disables all table mutations when supplied by the schema-driven renderer. */\n readOnly?: boolean;\n /** unique id field on each row; falls back to array index if omitted */\n rowKey?: Extract<keyof T, string>;\n /** show the \"+ Add\" button and allow appending blank rows. default: true */\n addable?: boolean;\n /** show a delete icon per row. default: true */\n deletable?: boolean;\n /** allow drag-handle reordering of rows. default: false */\n reorderable?: boolean;\n addButtonLabel?: string;\n emptyStateMessage?: string;\n /** rows matching this predicate are PERMANENTLY locked — shown with a static lock icon, never toggleable */\n isRowLocked?: (row: T) => boolean;\n /**\n * Turns on an interactive lock column. Rows not covered by `isRowLocked`\n * can be locked/unlocked by clicking the icon; state is stored on\n * `row[lockedKey]` unless `onToggleLock` is supplied.\n * default: false\n */\n lockable?: boolean;\n /** row field used to persist the toggleable lock state. default: 'locked' */\n lockedKey?: Extract<keyof T, string>;\n /** override the default toggle-in-place behavior for the lock icon */\n onToggleLock?: (row: T, rowIndex: number) => void;\n /**\n * When set, every row is stamped with its 1-based position in this field\n * (`row[orderKey] = index + 1`) any time the array's order or length\n * changes — after add, delete, or drag reorder. This mirrors the visible\n * \"Sr No\" column but persists it into the row data so it's included in\n * whatever payload is built from `rows`/`value`. Omit to leave rows\n * untouched (no field is added or written).\n */\n orderKey?: Extract<keyof T, string>;\n className?: string;\n /** quick accent-color override without writing a full stylesheet */\n accentColor?: string;\n /**\n * Raw CSS for the table. Target the et-* class names below (see\n * buildDefaultCss / DEFAULT_TABLE_CSS_TEMPLATE for the full list) to\n * restyle specific parts, or pass a whole stylesheet to replace the\n * look entirely. Omit it to get the built-in default look.\n * Each table instance is scoped automatically, so two tables on the\n * same page can be given different css props without colliding.\n */\n css?: string;\n}\n\n\n\nexport const FILE_ICON_COLOR: Record<string, string> = {\n PDF: '#D6483F',\n DOCX: '#2E5FD9',\n DOC: '#2E5FD9',\n XLSX: '#1E8E5A',\n XLS: '#1E8E5A',\n CSV: '#1E8E5A',\n PPTX: '#D9701E',\n};\n\nexport const BADGE_TONE_DEFAULT: BadgeTone = 'neutral';\nexport const DEFAULT_FILE_TYPES = ['PDF', 'DOC', 'DOCX', 'XLS', 'XLSX', 'CSV', 'PPTX'];\n"],"names":[],"mappings":";;;;AA6QO,MAAM,eAA0C,GAAA;AAAA,EACrD,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,GAAK,EAAA,SAAA;AAAA,EACL,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AACR,EAAA;AAEO,MAAM,kBAAgC,GAAA,UAAA;AAChC,MAAA,kBAAA,GAAqB,CAAC,KAAO,EAAA,KAAA,EAAO,QAAQ,KAAO,EAAA,MAAA,EAAQ,OAAO,MAAM;;;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/schema-driven/types.ts"],"sourcesContent":["// src/schema-driven/types.ts\nimport React from 'react';\n\nexport type TableColumnType =\n | 'text'\n | 'number'\n | 'checkbox'\n | 'dropdown'\n | 'readonly'\n | 'badge'\n | 'badgeSelect'\n | 'tags'\n | 'fileType';\n\n/** Configuration consumed by the schema-driven TableComponent. */\nexport interface TableColumnSchema {\n key: string;\n header: string;\n type: TableColumnType;\n options?: (string | { label: string; value: string })[];\n editable?: boolean;\n width?: string;\n placeholder?: string;\n defaultValue?: unknown;\n info?: string;\n badgeMap?: Record<string, { label?: string; tone?: string; color?: string; background?: string }>;\n tagOptions?: string[];\n}\n\n/**\n * Shape of a single node in the `learningMetadataComponents` JSON schema.\n * Mirrors `LMSMetadataField` (useLMSConfigStore) plus the `data_key` field,\n * which is reserved for the upcoming state-binding phase.\n */\nexport interface SchemaFieldNode {\n type?: 'string' | 'array' | 'object' | 'boolean';\n title?: string;\n placeholder?: string;\n /** Optional character limit. Omit for unlimited input. */\n maxLength?: number;\n /** Numeric range input configuration (used by PageRangeInput). */\n minimum?: number;\n step?: number;\n min_label?: string;\n max_label?: string;\n min_prefix?: string;\n max_prefix?: string;\n min_placeholder?: string;\n max_placeholder?: string;\n tooltip?: string;\n description?: string; // AI-facing authoring guideline (\"Guideline to create a ...\")\n /** Optional helper copy rendered under the field's title in the UI — the schema\n * equivalent of the hardcoded `wtaInformation` / `ruleDescriptionInformation`\n * strings the non-dynamic templates read from their renderer config. Every\n * registry component receives this via BPARenderer. */\n subtitle?: string;\n ui_position?: number;\n bpa_ui_component?: string;\n data_key?: string;\n /** FileUpload constraints. `max_size` accepts unit-bearing strings such as `10mb`. */\n accept?: string | string[];\n upload_type?: 'single' | 'multiple';\n max_uploads?: number;\n max_size?: string | number;\n\n // Select/dropdown options (config-driven). Prefer `options`; `enum` is\n // auto-mapped to `{ label, value }` for convenience. `parentValue` lets a\n // dependent dropdown (see `depends_on_global_key`) filter its options by the\n // parent field's selected value\n options?: { label: string; value: string; parentValue?: string }[];\n enum?: Array<string | { label: string; value: string; parentValue?: string }>;\n\n // Dropdown option source / dependency wiring.\n dynamic_options_key?: string; // key into host-injected uiState.dynamicOptions\n depends_on_global_key?: string; // data_key of the parent field to filter by\n\n // Payload Generation Flags\n core_field?: boolean; // true = Root payload, false = learning_metadata\n ui_only?: boolean; // true = Do not send this to the API at all\n ai_generated?: boolean; // true = AI is allowed to write to this field\n is_required?: boolean; // true = field must be filled (validation), distinct from core_field\n\n // UI Behaviors\n read_only?: boolean;\n /** Frozen-after-creation flag (defaults to false). In the EDIT flow the field can\n * never be opened for editing — not even inside a parent edit session — while it\n * stays fully editable during creation. On a wrapper node it freezes the whole\n * subtree and removes that section's Edit button. See utils/editLock.ts. */\n read_only_in_edit_flow?: boolean;\n hidden?: boolean;\n default_open?: boolean;\n is_repeatable_variant?: boolean;\n /** Renders this node's `properties` as an addable/removable list. The node must\n * have a `data_key`; its value is stored as an array of item objects. */\n repeatable?: boolean;\n /** `inline` renders item fields directly in rows with only a trailing delete\n * button. `cards` (the default) renders an Edit/Save card per item. */\n repeatable_layout?: 'cards' | 'inline';\n /** Variant wrapper only: set false to hide the \"Variant N\" pill in each variant\n * accordion header. Defaults to true (pill shown). */\n show_variant_pill?: boolean;\n /** Section-level editing. On an `Accordion` or `VariantListWrapper` node, the\n * section's fields are drafted together behind ONE Edit (with a single combined\n * Save) and their individual inline pencils are suppressed. Omit it to keep\n * per-field inline editing. */\n parent_edit?: boolean;\n group_edit?: boolean;\n group_title?: string;\n /** Horizontal placement of a field within a FlexRow column. */\n layout_align?: 'start' | 'center' | 'end';\n /** TableComponent column definitions. Row data is stored under `data_key`. */\n columns?: TableColumnSchema[];\n /** Optional schema-level initial rows; host/API values take precedence. */\n rows?: Record<string, unknown>[];\n /** Show row drag handles and allow rows to be reordered. */\n reorderable?: boolean;\n /** Show the interactive per-row lock control. */\n lockable?: boolean;\n /** Row property used to persist the interactive lock state. */\n lockedKey?: string;\n properties?: Record<string, SchemaFieldNode>;\n}\n\n/** Root shape of `learningMetadataComponents` itself. */\nexport interface SchemaRoot {\n type?: string;\n title?: string;\n properties?: Record<string, SchemaFieldNode>;\n /** One form-level Edit/Save/Cancel session for every editable field. */\n unified_edit?: boolean;\n}\n\n/**\n * Uniform prop contract every registry-resolved component must accept.\n * Container components (`isContainer: true` in the registry) receive the\n * recursively rendered subtree as `children`; leaf components ignore it.\n */\nexport interface SchemaComponentProps {\n id?: string;\n schema: SchemaFieldNode;\n value?: any;\n onChange?: (val: any) => void;\n readOnly?: boolean;\n errorMessage?: string;\n isAiStreaming?: boolean;\n children?: React.ReactNode;\n title?: string;\n [key: string]: any; // Allows injected array handlers (onAdd, onRemove) to pass without TS errors\n}\n\n\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\nexport type ColumnType =\n | 'text'\n | 'number'\n | 'checkbox'\n | 'dropdown'\n | 'readonly'\n | 'badge'\n | 'badgeSelect'\n | 'tags'\n | 'fileType';\n\nexport type BadgeTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';\n\nexport interface BadgeConfig {\n /** text shown in the pill; falls back to the raw value */\n label?: string;\n /** built-in color scheme */\n tone?: BadgeTone;\n /** explicit overrides, take precedence over tone */\n color?: string;\n background?: string;\n}\n\nexport interface ColumnDef<T> {\n /** key into the row object this column reads/writes */\n key: Extract<keyof T, string>;\n /** column header label */\n header: string;\n /** which kind of control renders each cell in this column */\n type: ColumnType;\n /** options for type === 'dropdown' */\n options?: string[];\n /** can the user edit this cell? defaults to true (forced false for 'readonly') */\n editable?: boolean;\n /** css width, e.g. '140px' or '1fr' */\n width?: string;\n /** placeholder for text/number inputs */\n placeholder?: string;\n /** value a new row gets for this column when \"Add\" is clicked */\n defaultValue?: T[Extract<keyof T, string>];\n /** custom renderer for a readonly cell's value, e.g. icon + label */\n renderReadonly?: (value: any, row: T) => React.ReactNode;\n /** for type === 'badge' or 'badgeSelect': maps a raw value to a label + color scheme */\n badgeMap?: Record<string, BadgeConfig>;\n /** for type === 'tags': the value is a string[]; these are the choices offered in the \"+ Add\" control */\n tagOptions?: string[];\n /** small (i) tooltip icon shown next to the header label */\n info?: string;\n}\n\nexport interface TableComponentProps<T extends Record<string, any>> {\n /** column configuration — defines both header and how each cell edits */\n columns?: ColumnDef<T>[];\n /** current row data (fully controlled). Used by standalone consumers. */\n rows?: T[];\n /** called with the next rows array whenever anything changes. */\n onRowsChange?: (rows: T[]) => void;\n /** Schema-driven renderer contract: table configuration lives on `schema`. */\n schema?: {\n columns?: ColumnDef<T>[];\n rows?: T[];\n reorderable?: boolean;\n lockable?: boolean;\n lockedKey?: Extract<keyof T, string>;\n orderKey?: Extract<keyof T, string>;\n };\n /** Schema-driven renderer contract: the current array value. */\n value?: T[];\n /** Schema-driven renderer contract: receives the next array value. */\n onChange?: (rows: T[]) => void;\n /** Disables all table mutations when supplied by the schema-driven renderer. */\n readOnly?: boolean;\n /** unique id field on each row; falls back to array index if omitted */\n rowKey?: Extract<keyof T, string>;\n /** show the \"+ Add\" button and allow appending blank rows. default: true */\n addable?: boolean;\n /** show a delete icon per row. default: true */\n deletable?: boolean;\n /** allow drag-handle reordering of rows. default: false */\n reorderable?: boolean;\n addButtonLabel?: string;\n emptyStateMessage?: string;\n /** rows matching this predicate are PERMANENTLY locked — shown with a static lock icon, never toggleable */\n isRowLocked?: (row: T) => boolean;\n /**\n * Turns on an interactive lock column. Rows not covered by `isRowLocked`\n * can be locked/unlocked by clicking the icon; state is stored on\n * `row[lockedKey]` unless `onToggleLock` is supplied.\n * default: false\n */\n lockable?: boolean;\n /** row field used to persist the toggleable lock state. default: 'locked' */\n lockedKey?: Extract<keyof T, string>;\n /** override the default toggle-in-place behavior for the lock icon */\n onToggleLock?: (row: T, rowIndex: number) => void;\n /**\n * When set, every row is stamped with its 1-based position in this field\n * (`row[orderKey] = index + 1`) any time the array's order or length\n * changes — after add, delete, or drag reorder. This mirrors the visible\n * \"Sr No\" column but persists it into the row data so it's included in\n * whatever payload is built from `rows`/`value`. Omit to leave rows\n * untouched (no field is added or written).\n */\n orderKey?: Extract<keyof T, string>;\n className?: string;\n /** quick accent-color override without writing a full stylesheet */\n accentColor?: string;\n /**\n * Raw CSS for the table. Target the et-* class names below (see\n * buildDefaultCss / DEFAULT_TABLE_CSS_TEMPLATE for the full list) to\n * restyle specific parts, or pass a whole stylesheet to replace the\n * look entirely. Omit it to get the built-in default look.\n * Each table instance is scoped automatically, so two tables on the\n * same page can be given different css props without colliding.\n */\n css?: string;\n}\n\n\n\nexport const FILE_ICON_COLOR: Record<string, string> = {\n PDF: '#D6483F',\n DOCX: '#2E5FD9',\n DOC: '#2E5FD9',\n XLSX: '#1E8E5A',\n XLS: '#1E8E5A',\n CSV: '#1E8E5A',\n PPTX: '#D9701E',\n};\n\nexport const BADGE_TONE_DEFAULT: BadgeTone = 'neutral';\nexport const DEFAULT_FILE_TYPES = ['PDF', 'DOC', 'DOCX', 'XLS', 'XLSX', 'CSV', 'PPTX'];\n"],"names":[],"mappings":";;;;AAoRO,MAAM,eAA0C,GAAA;AAAA,EACrD,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,GAAK,EAAA,SAAA;AAAA,EACL,GAAK,EAAA,SAAA;AAAA,EACL,IAAM,EAAA,SAAA;AACR,EAAA;AAEO,MAAM,kBAAgC,GAAA,UAAA;AAChC,MAAA,kBAAA,GAAqB,CAAC,KAAO,EAAA,KAAA,EAAO,QAAQ,KAAO,EAAA,MAAA,EAAQ,OAAO,MAAM;;;;;;"}
|
|
@@ -80,7 +80,7 @@ const generatePayloadFromSchema = (jsonSchema, tierKey, variantIndex) => {
|
|
|
80
80
|
else if (node.type === "object") value = {};
|
|
81
81
|
else value = "";
|
|
82
82
|
}
|
|
83
|
-
if (typeof value === "string" && value.includes("<ai_reasoning>")) {
|
|
83
|
+
if (node.core_field && typeof value === "string" && value.includes("<ai_reasoning>")) {
|
|
84
84
|
value = aiReasoning.stripAiReasoning(value).clean;
|
|
85
85
|
}
|
|
86
86
|
if (node.core_field) {
|
|
@@ -227,7 +227,7 @@ const applyResponseToStore = (jsonSchema, response, tierKey, variantIndex, optio
|
|
|
227
227
|
if (incoming !== void 0) {
|
|
228
228
|
const isConditionField = node.bpa_ui_component === "ConditionSection";
|
|
229
229
|
let reasoningRaw = null;
|
|
230
|
-
if (!isConditionField && typeof incoming === "string" && incoming.includes("<ai_reasoning>")) {
|
|
230
|
+
if (node.core_field && !isConditionField && typeof incoming === "string" && incoming.includes("<ai_reasoning>")) {
|
|
231
231
|
const stripped = aiReasoning.stripAiReasoning(incoming);
|
|
232
232
|
incoming = stripped.clean;
|
|
233
233
|
reasoningRaw = stripped.raw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadUtils.js","sources":["../../../../src/schema-driven/utils/PayloadUtils.ts"],"sourcesContent":["// src/schema-driven/utils/PayloadUtils.ts\nimport { useDynamicFormStore } from '../store/useDynamicFormStore';\nimport { isTableValueValid } from '../helper';\nimport { stripAiReasoning } from './aiReasoning';\n/**\n * Two distinct keys per schema leaf, and they are NOT interchangeable:\n * - PROPERTY KEY — the key under `properties` (e.g. `rule_title`, `wta`). This is\n * the ON-THE-WIRE key: what we send to the AI in `ui_state` and what the AI\n * echoes back in its response JSON.\n * - data_key — the internal dynamic-store slot the RHS field reads/writes\n * (e.g. `template_title`, `whenToApply`).\n * So the round-trip is: read store by data_key → emit under property key → AI\n * responds under property key → write store by data_key.\n *\n * Which store bucket a leaf lives in, mirrored by both read (generatePayloadFromSchema)\n * and write (applyResponseToStore) so the round-trip stays symmetric:\n * - `global.`-prefixed data_key, OR a field outside a variant wrapper → global.\n * - otherwise → variant-scoped (tierKey + variantIndex).\n * The data_key is stored WITHOUT the `global.` prefix (`cleanKey`).\n */\nconst resolveScope = (dataKey: string, isVariantLevel: boolean) => ({\n cleanKey: dataKey.replace('global.', ''),\n isGlobal: dataKey.startsWith('global.') || !isVariantLevel,\n});\n/**\n * A section is the repeatable-variant container if it renders as VariantListWrapper\n * OR is explicitly flagged `is_repeatable_variant: true`. Detection MUST match what\n * VariantListField renders per variant, so the store scope (global vs variant) and\n * the UI stay in sync. Its child leaves are variant-scoped; everything else is global.\n */\nconst isVariantWrapper = (node: any): boolean =>\n node?.is_repeatable_variant === true || node?.bpa_ui_component === 'VariantListWrapper';\n\n// Unlike a normal object wrapper, a repeatable section owns one array value. Its\n// descendants are an item template, not independent top-level payload fields.\nconst isRepeatableSection = (node: any): boolean =>\n node?.repeatable === true || node?.bpa_ui_component === 'RepeatableSection';\n\nexport const getVariantPrefilledData = (jsonSchema: any, prefilledData: Record<string, any>) => {\n const variantData: Record<string, Record<number, Record<string, any>>> = {};\n\n const traverse = (properties: any, isVariantLevel = false) => {\n if (!properties) return;\n Object.values(properties).forEach((node: any) => {\n const dataKey = node?.data_key;\n const cleanKey = dataKey?.replace('global.', '');\n const isVariantField = isVariantLevel && !dataKey?.startsWith('global.');\n\n if (isVariantField && Object.prototype.hasOwnProperty.call(prefilledData, cleanKey)) {\n variantData.tier_1 ??= {};\n variantData.tier_1[0] ??= {};\n variantData.tier_1[0][cleanKey] = prefilledData[cleanKey];\n }\n\n if (node?.properties) traverse(node.properties, isVariantLevel || isVariantWrapper(node));\n });\n };\n\n traverse(jsonSchema?.properties);\n return variantData;\n};\n\n/**\n * A core leaf's value may arrive under a looser name than the property key:\n * - from the AI's `updated_fields` (e.g. `title` for `rule_title`), or\n * - from the rule-fetch API on load, which uses its own fixed field names\n * (`ruleTitle`, `description`, `whenToApply`, `whenNotToApply`).\n * Read those aliases without changing the canonical wire key we emit. Keys here\n * are the conventional property keys; a schema using different keys would extend this.\n * Shared by `applyResponseToStore` (store hydration) and `buildFieldLabelMap`\n * (chat labels) so both resolve the AI's key names the same way.\n */\nexport const CORE_KEY_ALIASES: Record<string, string[]> = {\n rule_title: ['title', 'ruleTitle'],\n rule_description: ['description', 'variant_description'],\n wta: ['whenToApply', 'when_to_apply'],\n wnta: ['whenNotToApply', 'when_not_to_apply'],\n};\n\n/**\n * Build the AI-key → user-facing-label map for the schema-driven flow.\n *\n * The C.A.R.E. response echoes schema PROPERTY KEYS (or their `CORE_KEY_ALIASES`)\n * in `updated_fields` / `identified_fields`. The chat renderer must label those\n * with the same title the RHS form shows, and the JSON owns that title\n * (`rule_title` → \"Template Title\", `rule_description` → \"Template Goal\", …),\n * so it is derived here instead of being hardcoded in the renderer.\n *\n * Every leaf that carries a `title` contributes an entry under its property key\n * plus each of its aliases, so `title`, `rule_title` and `ruleTitle` all resolve\n * to the same label. Only the schema-driven modal passes this map down; the\n * legacy flow keeps the renderer's built-in defaults.\n */\nexport const buildFieldLabelMap = (jsonSchema: any): Record<string, string> => {\n const labels: Record<string, string> = {};\n const traverseSchema = (properties: any) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // `ui_only` wrappers (sections/rows) carry no value of their own, but their\n // children do — so recurse through them and only record leaf titles.\n if (node?.data_key && node?.title) {\n labels[propKey] = node.title;\n CORE_KEY_ALIASES[propKey]?.forEach((alias) => {\n labels[alias] = node.title;\n });\n }\n if (node?.properties) traverseSchema(node.properties);\n });\n };\n traverseSchema(jsonSchema?.properties);\n return labels;\n};\n\nexport const generatePayloadFromSchema = (\n jsonSchema: any,\n tierKey: string,\n variantIndex: number\n) => {\n const { getGlobalField, getVariantField } = useDynamicFormStore.getState();\n\n // `core_field: true` leaves sit at the top level of the payload; everything\n // else is collected under `learning_metadata`.\n const rootPayload: any = {};\n const metadataProperties: any = {};\n const metadataRequired: string[] = [];\n // Property keys whose value came from the per-variant store slot (getVariantField),\n // as opposed to the global slot shared across every variant. Callers that merge this\n // metadata bag with a variant's own API-saved metadata need this to know which keys\n // must always take the live store value (e.g. instruction_prompt) vs. which are fine\n // to let the API snapshot win (e.g. category).\n const variantScopedMetadataKeys: string[] = [];\n const traverseSchema = (properties: any, isVariantLevel: boolean = false) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // A repeatable node is a value-bearing array even if older DTs left\n // `ui_only: true` on it. Treat it as the array field, never as a wrapper\n // whose item-template leaves should be emitted as flat metadata.\n if (node.ui_only && !isRepeatableSection(node)) {\n if (isVariantWrapper(node)) return;\n if (node.properties) traverseSchema(node.properties, isVariantLevel);\n return;\n }\n if (node.data_key) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, isVariantLevel);\n // A repeatable section owns an array under its data_key. Unlike ordinary\n // fields, its config property key may be an implementation-generated id,\n // so use the data_key as its stable wire/payload key.\n const payloadKey = isRepeatableSection(node) ? cleanKey : propKey;\n let value = isGlobal\n ? getGlobalField(cleanKey)\n : getVariantField(tierKey, variantIndex, cleanKey);\n // ALWAYS provide a fallback default so the AI sees the empty keys\n // (it needs the previous value to reason about the user's request).\n if (value === undefined) {\n if (node.type === 'array') value = [];\n else if (node.type === 'boolean') value = false;\n else if (node.type === 'object') value = {};\n else value = ''; // default string (incl. \\n-joined wta/wnta)\n }\n // Condition fields keep AI reasoning inline in the store; never echo the\n // <ai_reasoning> tags back to the AI — send only the clean value.\n if (typeof value === 'string' && value.includes('<ai_reasoning>')) {\n value = stripAiReasoning(value).clean;\n }\n // Emit under the PROPERTY KEY (the AI's wire key), not the data_key.\n if (node.core_field) {\n rootPayload[payloadKey] = value;\n } else {\n metadataProperties[payloadKey] = value;\n // `required` is derived from each field's `is_required` flag in the JSON.\n if (node.is_required && !metadataRequired.includes(payloadKey)) {\n metadataRequired.push(payloadKey);\n }\n if (!isGlobal) variantScopedMetadataKeys.push(payloadKey);\n }\n }\n // Recursively traverse object properties\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, isVariantLevel);\n }\n });\n };\n const schemaProperties = jsonSchema?.properties || {};\n // 1. Traverse global properties\n traverseSchema(schemaProperties, false);\n // 2. Traverse variant properties\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper && variantWrapper.properties) {\n traverseSchema(variantWrapper.properties, true);\n }\n const learningMetadata = { properties: metadataProperties, required: metadataRequired };\n return { rootPayload, learningMetadata, variantScopedMetadataKeys };\n};\n/**\n * PROPERTY KEYS that hand ownership of the ruleset id to a form field. In the\n * JSON-driven flow the Sub-Category dropdown carries it (`ruleset_id`), so\n * whichever sub-category the user picks decides which ruleset the template is\n * saved into. `scope_id` is accepted as the same thing under the BE's name.\n */\nconst RULE_SET_ID_PROPERTY_KEYS = ['ruleset_id', 'scope_id'];\n\n/** First leaf (depth-first) whose property key hands over the ruleset id. */\nconst findRuleSetIdNode = (properties: any): any => {\n if (!properties) return null;\n for (const [propKey, node] of Object.entries<any>(properties)) {\n if (RULE_SET_ID_PROPERTY_KEYS.includes(propKey) && node?.data_key) return node;\n const nested = findRuleSetIdNode(node?.properties);\n if (nested) return nested;\n }\n return null;\n};\n\n/**\n * Options for a leaf, resolved exactly like DropdownSectionField renders them:\n * host-injected `dynamicOptions[<dynamic_options_key | data_key + 'Options'>]`\n * wins when non-empty, then inline `options`, then `enum`. Keeping the two in\n * sync matters — the id we return must come from the option the user saw.\n */\nconst resolveNodeOptions = (node: any, dynamicOptions?: Record<string, any>): any[] => {\n const optionsKey = node?.dynamic_options_key || `${node?.data_key}Options`;\n const hostOptions = dynamicOptions?.[optionsKey];\n if (Array.isArray(hostOptions) && hostOptions.length > 0) return hostOptions;\n if (Array.isArray(node?.options)) return node.options;\n if (Array.isArray(node?.enum)) {\n return node.enum.map((opt: any) =>\n opt && typeof opt === 'object' ? opt : { label: String(opt), value: opt }\n );\n }\n return [];\n};\n\n/**\n * The ruleset id the SCHEMA selects, or null when it doesn't select one.\n *\n * The dynamic store holds a dropdown's `value` (e.g. `weekly_digest`), never the\n * backing id — that travels on the option itself (`{ id, label, value }`, from\n * `dynamicOptions` or from inline JSON options that carry an `id`). So: find the\n * `ruleset_id`/`scope_id` leaf, read its store value, and return the id of the\n * option currently selected in it.\n *\n * Null means \"the schema has no opinion\" and the caller keeps whatever ruleset\n * it already used — that's the case for a schema without such a leaf, nothing\n * picked yet, or an option without an id. Only GLOBAL store values are read: a\n * ruleset is a per-template choice, not a per-variant one.\n */\nexport const resolveSchemaRuleSetId = (\n jsonSchema: any,\n dynamicOptions?: Record<string, any>\n): string | null => {\n const node = findRuleSetIdNode(jsonSchema?.properties);\n if (!node) return null;\n\n // `cleanKey` — the store slot, with any `global.` data_key prefix stripped.\n const { cleanKey } = resolveScope(node.data_key, false);\n const value = useDynamicFormStore.getState().getGlobalField(cleanKey);\n if (!value) return null;\n\n // The API may hydrate a value with different casing from the dropdown option\n // (for example, `nyc` vs. `NYC`). Match strings case-insensitively, while\n // returning the option's UUID — never its display/value token.\n const normalizedValue = typeof value === 'string' ? value.trim().toLowerCase() : value;\n const selected = resolveNodeOptions(node, dynamicOptions).find((opt: any) => {\n const optionValue =\n typeof opt?.value === 'string' ? opt.value.trim().toLowerCase() : opt?.value;\n return optionValue === normalizedValue;\n });\n return selected?.id ?? null;\n};\n\nconst isFieldFilled = (value: any, node?: any): boolean => {\n if (node?.bpa_ui_component === 'TableComponent') return isTableValueValid(node, value);\n if (value === undefined || value === null) return false;\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'string') return value.trim() !== '';\n return true;\n};\n/**\n * Checks required JSON fields in the dynamic form store.\n * Optional tier/variant scopes limit validation to the data being saved.\n */\nexport const areRequiredFieldsFilled = (\n jsonSchema: any,\n tierVariantMap: Map<string, Map<number, any>>,\n activeTierKeys?: Iterable<string>,\n activeVariantIndexes?: Iterable<number>\n): boolean => {\n const { getGlobalField, getVariantField } = useDynamicFormStore.getState();\n const schemaProperties = jsonSchema?.properties;\n if (!schemaProperties) return false;\n const activeTierKeySet = activeTierKeys ? new Set(activeTierKeys) : null;\n const activeVariantIndexSet = activeVariantIndexes ? new Set(activeVariantIndexes) : null;\n let allFilled = true;\n const traverseSchema = (properties: any, tierKey?: string, variantIndex?: number) => {\n if (!properties) return;\n Object.entries(properties).forEach(([, node]: [string, any]) => {\n if (node.ui_only && isVariantWrapper(node)) return;\n if (node.data_key && node.is_required) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, tierKey !== undefined);\n const value = isGlobal\n ? getGlobalField(cleanKey)\n : getVariantField(tierKey as string, variantIndex as number, cleanKey);\n if (!isFieldFilled(value, node)) allFilled = false;\n }\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, tierKey, variantIndex);\n }\n });\n };\n // Global fields, checked once.\n traverseSchema(schemaProperties);\n // Variant fields, checked once per tier/variantIndex pair actually in use.\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper?.properties) {\n tierVariantMap.forEach((variantMap, tierKey) => {\n if (activeTierKeySet && !activeTierKeySet.has(tierKey)) return;\n variantMap.forEach((_config, variantIndex) => {\n if (activeVariantIndexSet && !activeVariantIndexSet.has(variantIndex)) return;\n traverseSchema(variantWrapper.properties, tierKey, variantIndex);\n });\n });\n }\n return allFilled;\n};\n/**\n * Write an AI/C.A.R.E. response back into the dynamic store.\n *\n * The AI echoes the same PROPERTY KEYS we sent in `ui_state` (e.g. `rule_title`,\n * `wta`). For every schema leaf whose property key is present in `response`, we\n * write the value into the store slot (`data_key`) the field reads from — so the\n * RHS re-renders with the AI's value and the next payload build reflects it.\n * String-typed fields that carry a list (wta/wnta) may arrive as an array; we\n * join those to a single `\\n`-separated string to match the store's string shape.\n *\n * Where each key is read depends on where the writer put it (symmetry with\n * `generatePayloadFromSchema`):\n * - core_field leaves → top level of `response` (e.g. `response.wta`).\n * - non-core (learning_metadata) → under `response.learning_metadata.properties`.\n * For non-core we also tolerate older shapes on load/edit: a flat\n * `learning_metadata[propKey]`, or the legacy `{ type, title, value }` wrapper.\n *\n * Pass `tierKey`/`variantIndex` to hydrate a specific variant; omit them for the\n * global (non-variant) flow. `read_only` and `ui_only` leaves are never written\n * (host-owned values like Category/Sub-Category must survive the round-trip).\n */\nexport const applyResponseToStore = (\n jsonSchema: any,\n response: Record<string, any> | null | undefined,\n tierKey?: string,\n variantIndex?: number,\n // `hydrateAll` writes EVERY leaf (incl. non-AI fields like Category/Sub-Category).\n // Use it for the initial load/edit hydration from the fetched rule; the default\n // (live AI updates) only touches `ai_generated: true` leaves.\n // `variantOnly` skips the global pass entirely and writes only the variant\n // section — used when loading fetched variants so the API never fills global\n // fields (title/category), which are owned by the user + C.A.R.E.\n options?: { hydrateAll?: boolean; variantOnly?: boolean }\n) => {\n if (!response || typeof response !== 'object') return;\n const { setGlobalField, setVariantField, setGlobalReasoning, setVariantReasoning } =\n useDynamicFormStore.getState();\n const canWriteVariant = !!tierKey && variantIndex !== undefined;\n // Sentinel so we can distinguish \"key absent\" from \"key present but undefined\".\n const NOT_FOUND = Symbol('not-found');\n const metadataBag = response.learning_metadata?.properties ?? response.learning_metadata;\n // Core leaves may arrive under a looser name than the property key — see the\n // shared CORE_KEY_ALIASES table at the top of this file.\n const unwrapLegacyValue = (raw: any) =>\n raw && typeof raw === 'object' && !Array.isArray(raw) && 'value' in raw ? raw.value : raw;\n // Resolve the incoming value for a leaf, honoring core vs learning_metadata\n // placement and unwrapping the legacy `{ value }` shape when present. Initial\n // edit payloads from integrations may be flat API objects, so metadata leaves\n // also accept their `data_key` from either the metadata bag or that object.\n const readIncoming = (propKey: string, node: any, isCore: boolean): any => {\n if (isCore) {\n if (Object.prototype.hasOwnProperty.call(response, propKey)) return response[propKey];\n const alias = CORE_KEY_ALIASES[propKey]?.find((key) =>\n Object.prototype.hasOwnProperty.call(response, key)\n );\n return alias ? response[alias] : NOT_FOUND;\n }\n const dataKey = node.data_key?.replace('global.', '');\n for (const source of [metadataBag, response]) {\n if (!source || typeof source !== 'object') continue;\n if (propKey in source) return unwrapLegacyValue((source as any)[propKey]);\n if (dataKey && dataKey in source) return unwrapLegacyValue((source as any)[dataKey]);\n }\n return NOT_FOUND;\n };\n const traverseSchema = (properties: any, isVariantLevel: boolean = false) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // Backward compatibility for DTs that still carry `ui_only: true` on a\n // repeatable array. Its data_key is the persisted array slot.\n if (node.ui_only && !isRepeatableSection(node)) {\n if (isVariantWrapper(node)) return;\n if (node.properties) traverseSchema(node.properties, isVariantLevel);\n return;\n }\n // A leaf is hydrated from the response when the AI/system owns its value —\n // `ai_generated: true` (incl. read_only system fields like `value_id`, a\n // pipeline-resolved id the AI echoes back — we just store + re-send it) — or on\n // `hydrateAll` (initial load/edit seeds every leaf from the fetched rule). Plain\n // user-owned leaves (not ai_generated) are set immediately from input and are\n // never waited on or overwritten by the AI. `readIncoming` returns NOT_FOUND\n // when the response omits the key, so a field the AI doesn't send is untouched.\n if (node.data_key && (node.ai_generated === true || options?.hydrateAll)) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, isVariantLevel);\n let incoming = readIncoming(propKey, node, !!node.core_field);\n if (incoming !== NOT_FOUND) {\n // Normalize a list-shaped payload back into a \\n-joined string for\n // string leaves (wta/wnta), whose store slot holds a single string.\n if (node.type !== 'array' && Array.isArray(incoming)) {\n incoming = incoming.join('\\n');\n }\n if (incoming !== undefined) {\n // ConditionSection leaves (wta/wnta) can hold MANY conditions, each with\n // its own inline <ai_reasoning>. A single reasoning slot can't hold N of\n // them, so we keep the raw string (tags inline) and let the field parse\n // per-condition reasoning. Single-value leaves (title/goal) instead get\n // their reasoning stripped into the parallel reasoning bucket.\n const isConditionField = node.bpa_ui_component === 'ConditionSection';\n let reasoningRaw: string | null = null;\n if (\n !isConditionField &&\n typeof incoming === 'string' &&\n incoming.includes('<ai_reasoning>')\n ) {\n const stripped = stripAiReasoning(incoming);\n incoming = stripped.clean;\n reasoningRaw = stripped.raw;\n }\n // Write it into the store under the data_key.\n if (isGlobal) {\n setGlobalField(cleanKey, incoming);\n if (reasoningRaw) setGlobalReasoning(cleanKey, reasoningRaw);\n } else if (canWriteVariant) {\n setVariantField(tierKey as string, variantIndex as number, cleanKey, incoming);\n if (reasoningRaw)\n setVariantReasoning(\n tierKey as string,\n variantIndex as number,\n cleanKey,\n reasoningRaw\n );\n }\n }\n }\n }\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, isVariantLevel);\n }\n });\n };\n const schemaProperties = jsonSchema?.properties || {};\n // Global pass — skipped for a variant-only hydrate (the API load).\n if (!options?.variantOnly) traverseSchema(schemaProperties, false);\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper && variantWrapper.properties) {\n traverseSchema(variantWrapper.properties, true);\n }\n};\n"],"names":["useDynamicFormStore","stripAiReasoning","isTableValueValid","_a","_b"],"mappings":";;;;;;;;AAoBA,MAAM,YAAA,GAAe,CAAC,OAAA,EAAiB,cAA6B,MAAA;AAAA,EAClE,QAAU,EAAA,OAAA,CAAQ,OAAQ,CAAA,SAAA,EAAW,EAAE,CAAA;AAAA,EACvC,QAAU,EAAA,OAAA,CAAQ,UAAW,CAAA,SAAS,KAAK,CAAC,cAAA;AAC9C,CAAA,CAAA,CAAA;AAOA,MAAM,mBAAmB,CAAC,IAAA,KAAA,CACxB,6BAAM,qBAA0B,MAAA,IAAA,IAAA,CAAQ,6BAAM,gBAAqB,MAAA,oBAAA,CAAA;AAIrE,MAAM,sBAAsB,CAAC,IAAA,KAAA,CAC3B,6BAAM,UAAe,MAAA,IAAA,IAAA,CAAQ,6BAAM,gBAAqB,MAAA,mBAAA,CAAA;AAE7C,MAAA,uBAAA,GAA0B,CAAC,UAAA,EAAiB,aAAuC,KAAA;AAC9F,EAAA,MAAM,cAAmE,EAAC,CAAA;AAE1E,EAAA,MAAM,QAAW,GAAA,CAAC,UAAiB,EAAA,cAAA,GAAiB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KAAA,CAAA,GAAA,UAAA,CAAA,UAAA,KAAc,EAAC,CAAA;AAEpD,EAAA,IAAI,EAAC,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,WAAa,CAAA,EAAA,cAAA,CAAe,kBAAkB,KAAK,CAAA,CAAA;AACjE,EAAA,MAAM,iBAAsB,MAAO,CAAA,MAAA,CAAO,gBAAgB,CAAA,CAAE,KAAK,gBAAgB,CAAA,CAAA;AACjF,EAAI,IAAA,cAAA,IAAkB,eAAe,UAAY,EAAA;AAC/C,IAAe,cAAA,CAAA,cAAA,CAAe,YAAY,IAAI,CAAA,CAAA;AAAA,GAChD;AACF;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"PayloadUtils.js","sources":["../../../../src/schema-driven/utils/PayloadUtils.ts"],"sourcesContent":["// src/schema-driven/utils/PayloadUtils.ts\nimport { useDynamicFormStore } from '../store/useDynamicFormStore';\nimport { isTableValueValid } from '../helper';\nimport { stripAiReasoning } from './aiReasoning';\n/**\n * Two distinct keys per schema leaf, and they are NOT interchangeable:\n * - PROPERTY KEY — the key under `properties` (e.g. `rule_title`, `wta`). This is\n * the ON-THE-WIRE key: what we send to the AI in `ui_state` and what the AI\n * echoes back in its response JSON.\n * - data_key — the internal dynamic-store slot the RHS field reads/writes\n * (e.g. `template_title`, `whenToApply`).\n * So the round-trip is: read store by data_key → emit under property key → AI\n * responds under property key → write store by data_key.\n *\n * Which store bucket a leaf lives in, mirrored by both read (generatePayloadFromSchema)\n * and write (applyResponseToStore) so the round-trip stays symmetric:\n * - `global.`-prefixed data_key, OR a field outside a variant wrapper → global.\n * - otherwise → variant-scoped (tierKey + variantIndex).\n * The data_key is stored WITHOUT the `global.` prefix (`cleanKey`).\n */\nconst resolveScope = (dataKey: string, isVariantLevel: boolean) => ({\n cleanKey: dataKey.replace('global.', ''),\n isGlobal: dataKey.startsWith('global.') || !isVariantLevel,\n});\n/**\n * A section is the repeatable-variant container if it renders as VariantListWrapper\n * OR is explicitly flagged `is_repeatable_variant: true`. Detection MUST match what\n * VariantListField renders per variant, so the store scope (global vs variant) and\n * the UI stay in sync. Its child leaves are variant-scoped; everything else is global.\n */\nconst isVariantWrapper = (node: any): boolean =>\n node?.is_repeatable_variant === true || node?.bpa_ui_component === 'VariantListWrapper';\n\n// Unlike a normal object wrapper, a repeatable section owns one array value. Its\n// descendants are an item template, not independent top-level payload fields.\nconst isRepeatableSection = (node: any): boolean =>\n node?.repeatable === true || node?.bpa_ui_component === 'RepeatableSection';\n\nexport const getVariantPrefilledData = (jsonSchema: any, prefilledData: Record<string, any>) => {\n const variantData: Record<string, Record<number, Record<string, any>>> = {};\n\n const traverse = (properties: any, isVariantLevel = false) => {\n if (!properties) return;\n Object.values(properties).forEach((node: any) => {\n const dataKey = node?.data_key;\n const cleanKey = dataKey?.replace('global.', '');\n const isVariantField = isVariantLevel && !dataKey?.startsWith('global.');\n\n if (isVariantField && Object.prototype.hasOwnProperty.call(prefilledData, cleanKey)) {\n variantData.tier_1 ??= {};\n variantData.tier_1[0] ??= {};\n variantData.tier_1[0][cleanKey] = prefilledData[cleanKey];\n }\n\n if (node?.properties) traverse(node.properties, isVariantLevel || isVariantWrapper(node));\n });\n };\n\n traverse(jsonSchema?.properties);\n return variantData;\n};\n\n/**\n * A core leaf's value may arrive under a looser name than the property key:\n * - from the AI's `updated_fields` (e.g. `title` for `rule_title`), or\n * - from the rule-fetch API on load, which uses its own fixed field names\n * (`ruleTitle`, `description`, `whenToApply`, `whenNotToApply`).\n * Read those aliases without changing the canonical wire key we emit. Keys here\n * are the conventional property keys; a schema using different keys would extend this.\n * Shared by `applyResponseToStore` (store hydration) and `buildFieldLabelMap`\n * (chat labels) so both resolve the AI's key names the same way.\n */\nexport const CORE_KEY_ALIASES: Record<string, string[]> = {\n rule_title: ['title', 'ruleTitle'],\n rule_description: ['description', 'variant_description'],\n wta: ['whenToApply', 'when_to_apply'],\n wnta: ['whenNotToApply', 'when_not_to_apply'],\n};\n\n/**\n * Build the AI-key → user-facing-label map for the schema-driven flow.\n *\n * The C.A.R.E. response echoes schema PROPERTY KEYS (or their `CORE_KEY_ALIASES`)\n * in `updated_fields` / `identified_fields`. The chat renderer must label those\n * with the same title the RHS form shows, and the JSON owns that title\n * (`rule_title` → \"Template Title\", `rule_description` → \"Template Goal\", …),\n * so it is derived here instead of being hardcoded in the renderer.\n *\n * Every leaf that carries a `title` contributes an entry under its property key\n * plus each of its aliases, so `title`, `rule_title` and `ruleTitle` all resolve\n * to the same label. Only the schema-driven modal passes this map down; the\n * legacy flow keeps the renderer's built-in defaults.\n */\nexport const buildFieldLabelMap = (jsonSchema: any): Record<string, string> => {\n const labels: Record<string, string> = {};\n const traverseSchema = (properties: any) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // `ui_only` wrappers (sections/rows) carry no value of their own, but their\n // children do — so recurse through them and only record leaf titles.\n if (node?.data_key && node?.title) {\n labels[propKey] = node.title;\n CORE_KEY_ALIASES[propKey]?.forEach((alias) => {\n labels[alias] = node.title;\n });\n }\n if (node?.properties) traverseSchema(node.properties);\n });\n };\n traverseSchema(jsonSchema?.properties);\n return labels;\n};\n\nexport const generatePayloadFromSchema = (\n jsonSchema: any,\n tierKey: string,\n variantIndex: number\n) => {\n const { getGlobalField, getVariantField } = useDynamicFormStore.getState();\n\n // `core_field: true` leaves sit at the top level of the payload; everything\n // else is collected under `learning_metadata`.\n const rootPayload: any = {};\n const metadataProperties: any = {};\n const metadataRequired: string[] = [];\n // Property keys whose value came from the per-variant store slot (getVariantField),\n // as opposed to the global slot shared across every variant. Callers that merge this\n // metadata bag with a variant's own API-saved metadata need this to know which keys\n // must always take the live store value (e.g. instruction_prompt) vs. which are fine\n // to let the API snapshot win (e.g. category).\n const variantScopedMetadataKeys: string[] = [];\n const traverseSchema = (properties: any, isVariantLevel: boolean = false) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // A repeatable node is a value-bearing array even if older DTs left\n // `ui_only: true` on it. Treat it as the array field, never as a wrapper\n // whose item-template leaves should be emitted as flat metadata.\n if (node.ui_only && !isRepeatableSection(node)) {\n if (isVariantWrapper(node)) return;\n if (node.properties) traverseSchema(node.properties, isVariantLevel);\n return;\n }\n if (node.data_key) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, isVariantLevel);\n // A repeatable section owns an array under its data_key. Unlike ordinary\n // fields, its config property key may be an implementation-generated id,\n // so use the data_key as its stable wire/payload key.\n const payloadKey = isRepeatableSection(node) ? cleanKey : propKey;\n let value = isGlobal\n ? getGlobalField(cleanKey)\n : getVariantField(tierKey, variantIndex, cleanKey);\n // ALWAYS provide a fallback default so the AI sees the empty keys\n // (it needs the previous value to reason about the user's request).\n if (value === undefined) {\n if (node.type === 'array') value = [];\n else if (node.type === 'boolean') value = false;\n else if (node.type === 'object') value = {};\n else value = ''; // default string (incl. \\n-joined wta/wnta)\n }\n // Cognitive reasoning belongs to the core, AI-managed rule fields only.\n // Learning metadata (including `instruction_prompt`) is user-owned content\n // and can intentionally contain an `<ai_reasoning>` block, so preserve it\n // verbatim when it is sent back in `ui_state`.\n if (node.core_field && typeof value === 'string' && value.includes('<ai_reasoning>')) {\n value = stripAiReasoning(value).clean;\n }\n // Emit under the PROPERTY KEY (the AI's wire key), not the data_key.\n if (node.core_field) {\n rootPayload[payloadKey] = value;\n } else {\n metadataProperties[payloadKey] = value;\n // `required` is derived from each field's `is_required` flag in the JSON.\n if (node.is_required && !metadataRequired.includes(payloadKey)) {\n metadataRequired.push(payloadKey);\n }\n if (!isGlobal) variantScopedMetadataKeys.push(payloadKey);\n }\n }\n // Recursively traverse object properties\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, isVariantLevel);\n }\n });\n };\n const schemaProperties = jsonSchema?.properties || {};\n // 1. Traverse global properties\n traverseSchema(schemaProperties, false);\n // 2. Traverse variant properties\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper && variantWrapper.properties) {\n traverseSchema(variantWrapper.properties, true);\n }\n const learningMetadata = { properties: metadataProperties, required: metadataRequired };\n return { rootPayload, learningMetadata, variantScopedMetadataKeys };\n};\n/**\n * PROPERTY KEYS that hand ownership of the ruleset id to a form field. In the\n * JSON-driven flow the Sub-Category dropdown carries it (`ruleset_id`), so\n * whichever sub-category the user picks decides which ruleset the template is\n * saved into. `scope_id` is accepted as the same thing under the BE's name.\n */\nconst RULE_SET_ID_PROPERTY_KEYS = ['ruleset_id', 'scope_id'];\n\n/** First leaf (depth-first) whose property key hands over the ruleset id. */\nconst findRuleSetIdNode = (properties: any): any => {\n if (!properties) return null;\n for (const [propKey, node] of Object.entries<any>(properties)) {\n if (RULE_SET_ID_PROPERTY_KEYS.includes(propKey) && node?.data_key) return node;\n const nested = findRuleSetIdNode(node?.properties);\n if (nested) return nested;\n }\n return null;\n};\n\n/**\n * Options for a leaf, resolved exactly like DropdownSectionField renders them:\n * host-injected `dynamicOptions[<dynamic_options_key | data_key + 'Options'>]`\n * wins when non-empty, then inline `options`, then `enum`. Keeping the two in\n * sync matters — the id we return must come from the option the user saw.\n */\nconst resolveNodeOptions = (node: any, dynamicOptions?: Record<string, any>): any[] => {\n const optionsKey = node?.dynamic_options_key || `${node?.data_key}Options`;\n const hostOptions = dynamicOptions?.[optionsKey];\n if (Array.isArray(hostOptions) && hostOptions.length > 0) return hostOptions;\n if (Array.isArray(node?.options)) return node.options;\n if (Array.isArray(node?.enum)) {\n return node.enum.map((opt: any) =>\n opt && typeof opt === 'object' ? opt : { label: String(opt), value: opt }\n );\n }\n return [];\n};\n\n/**\n * The ruleset id the SCHEMA selects, or null when it doesn't select one.\n *\n * The dynamic store holds a dropdown's `value` (e.g. `weekly_digest`), never the\n * backing id — that travels on the option itself (`{ id, label, value }`, from\n * `dynamicOptions` or from inline JSON options that carry an `id`). So: find the\n * `ruleset_id`/`scope_id` leaf, read its store value, and return the id of the\n * option currently selected in it.\n *\n * Null means \"the schema has no opinion\" and the caller keeps whatever ruleset\n * it already used — that's the case for a schema without such a leaf, nothing\n * picked yet, or an option without an id. Only GLOBAL store values are read: a\n * ruleset is a per-template choice, not a per-variant one.\n */\nexport const resolveSchemaRuleSetId = (\n jsonSchema: any,\n dynamicOptions?: Record<string, any>\n): string | null => {\n const node = findRuleSetIdNode(jsonSchema?.properties);\n if (!node) return null;\n\n // `cleanKey` — the store slot, with any `global.` data_key prefix stripped.\n const { cleanKey } = resolveScope(node.data_key, false);\n const value = useDynamicFormStore.getState().getGlobalField(cleanKey);\n if (!value) return null;\n\n // The API may hydrate a value with different casing from the dropdown option\n // (for example, `nyc` vs. `NYC`). Match strings case-insensitively, while\n // returning the option's UUID — never its display/value token.\n const normalizedValue = typeof value === 'string' ? value.trim().toLowerCase() : value;\n const selected = resolveNodeOptions(node, dynamicOptions).find((opt: any) => {\n const optionValue =\n typeof opt?.value === 'string' ? opt.value.trim().toLowerCase() : opt?.value;\n return optionValue === normalizedValue;\n });\n return selected?.id ?? null;\n};\n\nconst isFieldFilled = (value: any, node?: any): boolean => {\n if (node?.bpa_ui_component === 'TableComponent') return isTableValueValid(node, value);\n if (value === undefined || value === null) return false;\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === 'string') return value.trim() !== '';\n return true;\n};\n/**\n * Checks required JSON fields in the dynamic form store.\n * Optional tier/variant scopes limit validation to the data being saved.\n */\nexport const areRequiredFieldsFilled = (\n jsonSchema: any,\n tierVariantMap: Map<string, Map<number, any>>,\n activeTierKeys?: Iterable<string>,\n activeVariantIndexes?: Iterable<number>\n): boolean => {\n const { getGlobalField, getVariantField } = useDynamicFormStore.getState();\n const schemaProperties = jsonSchema?.properties;\n if (!schemaProperties) return false;\n const activeTierKeySet = activeTierKeys ? new Set(activeTierKeys) : null;\n const activeVariantIndexSet = activeVariantIndexes ? new Set(activeVariantIndexes) : null;\n let allFilled = true;\n const traverseSchema = (properties: any, tierKey?: string, variantIndex?: number) => {\n if (!properties) return;\n Object.entries(properties).forEach(([, node]: [string, any]) => {\n if (node.ui_only && isVariantWrapper(node)) return;\n if (node.data_key && node.is_required) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, tierKey !== undefined);\n const value = isGlobal\n ? getGlobalField(cleanKey)\n : getVariantField(tierKey as string, variantIndex as number, cleanKey);\n if (!isFieldFilled(value, node)) allFilled = false;\n }\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, tierKey, variantIndex);\n }\n });\n };\n // Global fields, checked once.\n traverseSchema(schemaProperties);\n // Variant fields, checked once per tier/variantIndex pair actually in use.\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper?.properties) {\n tierVariantMap.forEach((variantMap, tierKey) => {\n if (activeTierKeySet && !activeTierKeySet.has(tierKey)) return;\n variantMap.forEach((_config, variantIndex) => {\n if (activeVariantIndexSet && !activeVariantIndexSet.has(variantIndex)) return;\n traverseSchema(variantWrapper.properties, tierKey, variantIndex);\n });\n });\n }\n return allFilled;\n};\n/**\n * Write an AI/C.A.R.E. response back into the dynamic store.\n *\n * The AI echoes the same PROPERTY KEYS we sent in `ui_state` (e.g. `rule_title`,\n * `wta`). For every schema leaf whose property key is present in `response`, we\n * write the value into the store slot (`data_key`) the field reads from — so the\n * RHS re-renders with the AI's value and the next payload build reflects it.\n * String-typed fields that carry a list (wta/wnta) may arrive as an array; we\n * join those to a single `\\n`-separated string to match the store's string shape.\n *\n * Where each key is read depends on where the writer put it (symmetry with\n * `generatePayloadFromSchema`):\n * - core_field leaves → top level of `response` (e.g. `response.wta`).\n * - non-core (learning_metadata) → under `response.learning_metadata.properties`.\n * For non-core we also tolerate older shapes on load/edit: a flat\n * `learning_metadata[propKey]`, or the legacy `{ type, title, value }` wrapper.\n *\n * Pass `tierKey`/`variantIndex` to hydrate a specific variant; omit them for the\n * global (non-variant) flow. `read_only` and `ui_only` leaves are never written\n * (host-owned values like Category/Sub-Category must survive the round-trip).\n */\nexport const applyResponseToStore = (\n jsonSchema: any,\n response: Record<string, any> | null | undefined,\n tierKey?: string,\n variantIndex?: number,\n // `hydrateAll` writes EVERY leaf (incl. non-AI fields like Category/Sub-Category).\n // Use it for the initial load/edit hydration from the fetched rule; the default\n // (live AI updates) only touches `ai_generated: true` leaves.\n // `variantOnly` skips the global pass entirely and writes only the variant\n // section — used when loading fetched variants so the API never fills global\n // fields (title/category), which are owned by the user + C.A.R.E.\n options?: { hydrateAll?: boolean; variantOnly?: boolean }\n) => {\n if (!response || typeof response !== 'object') return;\n const { setGlobalField, setVariantField, setGlobalReasoning, setVariantReasoning } =\n useDynamicFormStore.getState();\n const canWriteVariant = !!tierKey && variantIndex !== undefined;\n // Sentinel so we can distinguish \"key absent\" from \"key present but undefined\".\n const NOT_FOUND = Symbol('not-found');\n const metadataBag = response.learning_metadata?.properties ?? response.learning_metadata;\n // Core leaves may arrive under a looser name than the property key — see the\n // shared CORE_KEY_ALIASES table at the top of this file.\n const unwrapLegacyValue = (raw: any) =>\n raw && typeof raw === 'object' && !Array.isArray(raw) && 'value' in raw ? raw.value : raw;\n // Resolve the incoming value for a leaf, honoring core vs learning_metadata\n // placement and unwrapping the legacy `{ value }` shape when present. Initial\n // edit payloads from integrations may be flat API objects, so metadata leaves\n // also accept their `data_key` from either the metadata bag or that object.\n const readIncoming = (propKey: string, node: any, isCore: boolean): any => {\n if (isCore) {\n if (Object.prototype.hasOwnProperty.call(response, propKey)) return response[propKey];\n const alias = CORE_KEY_ALIASES[propKey]?.find((key) =>\n Object.prototype.hasOwnProperty.call(response, key)\n );\n return alias ? response[alias] : NOT_FOUND;\n }\n const dataKey = node.data_key?.replace('global.', '');\n for (const source of [metadataBag, response]) {\n if (!source || typeof source !== 'object') continue;\n if (propKey in source) return unwrapLegacyValue((source as any)[propKey]);\n if (dataKey && dataKey in source) return unwrapLegacyValue((source as any)[dataKey]);\n }\n return NOT_FOUND;\n };\n const traverseSchema = (properties: any, isVariantLevel: boolean = false) => {\n if (!properties) return;\n Object.entries(properties).forEach(([propKey, node]: [string, any]) => {\n // Backward compatibility for DTs that still carry `ui_only: true` on a\n // repeatable array. Its data_key is the persisted array slot.\n if (node.ui_only && !isRepeatableSection(node)) {\n if (isVariantWrapper(node)) return;\n if (node.properties) traverseSchema(node.properties, isVariantLevel);\n return;\n }\n // A leaf is hydrated from the response when the AI/system owns its value —\n // `ai_generated: true` (incl. read_only system fields like `value_id`, a\n // pipeline-resolved id the AI echoes back — we just store + re-send it) — or on\n // `hydrateAll` (initial load/edit seeds every leaf from the fetched rule). Plain\n // user-owned leaves (not ai_generated) are set immediately from input and are\n // never waited on or overwritten by the AI. `readIncoming` returns NOT_FOUND\n // when the response omits the key, so a field the AI doesn't send is untouched.\n if (node.data_key && (node.ai_generated === true || options?.hydrateAll)) {\n const { cleanKey, isGlobal } = resolveScope(node.data_key, isVariantLevel);\n let incoming = readIncoming(propKey, node, !!node.core_field);\n if (incoming !== NOT_FOUND) {\n // Normalize a list-shaped payload back into a \\n-joined string for\n // string leaves (wta/wnta), whose store slot holds a single string.\n if (node.type !== 'array' && Array.isArray(incoming)) {\n incoming = incoming.join('\\n');\n }\n if (incoming !== undefined) {\n // ConditionSection leaves (wta/wnta) can hold MANY conditions, each with\n // its own inline <ai_reasoning>. A single reasoning slot can't hold N of\n // them, so we keep the raw string (tags inline) and let the field parse\n // per-condition reasoning. Learning metadata is also kept verbatim:\n // instruction prompts may intentionally use these tags as prompt content.\n // Only single-value core fields (title/goal) move their reasoning into the\n // parallel reasoning bucket.\n const isConditionField = node.bpa_ui_component === 'ConditionSection';\n let reasoningRaw: string | null = null;\n if (\n node.core_field &&\n !isConditionField &&\n typeof incoming === 'string' &&\n incoming.includes('<ai_reasoning>')\n ) {\n const stripped = stripAiReasoning(incoming);\n incoming = stripped.clean;\n reasoningRaw = stripped.raw;\n }\n // Write it into the store under the data_key.\n if (isGlobal) {\n setGlobalField(cleanKey, incoming);\n if (reasoningRaw) setGlobalReasoning(cleanKey, reasoningRaw);\n } else if (canWriteVariant) {\n setVariantField(tierKey as string, variantIndex as number, cleanKey, incoming);\n if (reasoningRaw)\n setVariantReasoning(\n tierKey as string,\n variantIndex as number,\n cleanKey,\n reasoningRaw\n );\n }\n }\n }\n }\n if (node.properties && !isVariantWrapper(node) && !isRepeatableSection(node)) {\n traverseSchema(node.properties, isVariantLevel);\n }\n });\n };\n const schemaProperties = jsonSchema?.properties || {};\n // Global pass — skipped for a variant-only hydrate (the API load).\n if (!options?.variantOnly) traverseSchema(schemaProperties, false);\n const variantWrapper: any = Object.values(schemaProperties).find(isVariantWrapper);\n if (variantWrapper && variantWrapper.properties) {\n traverseSchema(variantWrapper.properties, true);\n }\n};\n"],"names":["useDynamicFormStore","stripAiReasoning","isTableValueValid","_a","_b"],"mappings":";;;;;;;;AAoBA,MAAM,YAAA,GAAe,CAAC,OAAA,EAAiB,cAA6B,MAAA;AAAA,EAClE,QAAU,EAAA,OAAA,CAAQ,OAAQ,CAAA,SAAA,EAAW,EAAE,CAAA;AAAA,EACvC,QAAU,EAAA,OAAA,CAAQ,UAAW,CAAA,SAAS,KAAK,CAAC,cAAA;AAC9C,CAAA,CAAA,CAAA;AAOA,MAAM,mBAAmB,CAAC,IAAA,KAAA,CACxB,6BAAM,qBAA0B,MAAA,IAAA,IAAA,CAAQ,6BAAM,gBAAqB,MAAA,oBAAA,CAAA;AAIrE,MAAM,sBAAsB,CAAC,IAAA,KAAA,CAC3B,6BAAM,UAAe,MAAA,IAAA,IAAA,CAAQ,6BAAM,gBAAqB,MAAA,mBAAA,CAAA;AAE7C,MAAA,uBAAA,GAA0B,CAAC,UAAA,EAAiB,aAAuC,KAAA;AAC9F,EAAA,MAAM,cAAmE,EAAC,CAAA;AAE1E,EAAA,MAAM,QAAW,GAAA,CAAC,UAAiB,EAAA,cAAA,GAAiB,KAAU,KAAA;AAC5D,IAAA,IAAI,CAAC,UAAY,EAAA,OAAA;AACjB,IAAA,MAAA,CAAO,MAAO,CAAA,UAAU,CAAE,CAAA,OAAA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