@vectoriox/iox-builder 4.23.0 → 4.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,7 +16,7 @@ import { SelectModule } from 'primeng/select';
|
|
|
16
16
|
import { TooltipModule } from 'primeng/tooltip';
|
|
17
17
|
import { DialogModule } from 'primeng/dialog';
|
|
18
18
|
import * as i18 from '@vectoriox/iox-ui';
|
|
19
|
-
import { VALIDATION_STATES as VALIDATION_STATES$1, VALIDATION_STATE_CLASS as VALIDATION_STATE_CLASS$1, DEFAULT_WIDTH_BY_TYPE, Breakpoint, BREAKPOINTS, countOverrides, setOverride, breakpointDef, breakpointForWidth, FormRenderState, safeSetInput, ContextStore, ComponentInstanceRegistryService, isActionEnabled, isContextAction, contextActionEffect, resolveContextValue, DeclarationContext, buildPartSelector, planResponsiveRules, resolveStyleProps, buildTargetedStateSelector, compileDeclarations, wrapInBreakpointQuery, BreakpointQueryKind, composeVirtualTraits, stateNamesIn, partClassName, resolveInputs, setInputOverride, collectContextSlotKeys, withContextSlots, compilePageStyle, nodeUsesContext, resolveBoundValue, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, computeRelative, IoxPageModule, PART_CLASS_NAMES } from '@vectoriox/iox-ui';
|
|
19
|
+
import { VALIDATION_STATES as VALIDATION_STATES$1, VALIDATION_STATE_CLASS as VALIDATION_STATE_CLASS$1, DEFAULT_WIDTH_BY_TYPE, resolveFlavorDefaults, Breakpoint, BREAKPOINTS, countOverrides, setOverride, DEFAULT_FLAVOR, breakpointDef, breakpointForWidth, FormRenderState, safeSetInput, ContextStore, ComponentInstanceRegistryService, isActionEnabled, isContextAction, contextActionEffect, resolveContextValue, DeclarationContext, buildPartSelector, planResponsiveRules, resolveStyleProps, buildTargetedStateSelector, compileDeclarations, wrapInBreakpointQuery, BreakpointQueryKind, composeVirtualTraits, stateNamesIn, partClassName, resolveInputs, setInputOverride, collectContextSlotKeys, withContextSlots, compilePageStyle, nodeUsesContext, resolveBoundValue, IS_PREVIEW, planDataSource, dataSourcePlanToRequest, normalizeCollectionResult, resolveRepeaterItems, getByPath, computeRelative, IoxPageModule, PART_CLASS_NAMES } from '@vectoriox/iox-ui';
|
|
20
20
|
export { ComponentInstanceRegistryService, VIRTUAL_TRAIT_KEYS, composeVirtualTraits } from '@vectoriox/iox-ui';
|
|
21
21
|
import Lenis from 'lenis';
|
|
22
22
|
import { Subject, BehaviorSubject, of, forkJoin } from 'rxjs';
|
|
@@ -237,6 +237,26 @@ class ComponentConfig {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Layer 2 of the flavor cascade (flavors plan §4), applied by the registry factory to every
|
|
242
|
+
* BRAND-NEW element: overwrite matching styleTrait defaults with the pack's token references
|
|
243
|
+
* (`var(--iox-<token>, <packValue>)`). Runs AFTER the subclass constructor, so a pack beats the
|
|
244
|
+
* constructor's literals; the author's own edits (layer 4) beat everything as always. Self-
|
|
245
|
+
* describing serialisation then writes the var into styleProps on save — which is why the
|
|
246
|
+
* engine's `flavorDefaultDeclarations` only has to cover LEGACY nodes.
|
|
247
|
+
*/
|
|
248
|
+
function applyFlavorDefaults(config, pack) {
|
|
249
|
+
const defaults = resolveFlavorDefaults(config.type, pack);
|
|
250
|
+
const names = Object.keys(defaults);
|
|
251
|
+
if (!names.length)
|
|
252
|
+
return;
|
|
253
|
+
for (const group of config.styleTraits) {
|
|
254
|
+
for (const trait of group.traits) {
|
|
255
|
+
if (defaults[trait.name] !== undefined)
|
|
256
|
+
trait.default = defaults[trait.name];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
240
260
|
class TraitConfig {
|
|
241
261
|
constructor(name, label, type, options, defaultValue, inline, showWhen, responsive) {
|
|
242
262
|
this.name = name;
|
|
@@ -1523,7 +1543,13 @@ class ComponentRegistryService {
|
|
|
1523
1543
|
}
|
|
1524
1544
|
createConfig(type) {
|
|
1525
1545
|
const configType = this.components[type]?.config;
|
|
1526
|
-
|
|
1546
|
+
if (!configType)
|
|
1547
|
+
return null;
|
|
1548
|
+
const config = new configType();
|
|
1549
|
+
// Flavor layer (F1): every new element is born wearing the pack's token references.
|
|
1550
|
+
// DEFAULT_FLAVOR until F2 lets the org choose; see flavors-and-theming-plan.md §4.
|
|
1551
|
+
applyFlavorDefaults(config, DEFAULT_FLAVOR);
|
|
1552
|
+
return config;
|
|
1527
1553
|
}
|
|
1528
1554
|
register(type, component, config) {
|
|
1529
1555
|
this.components[type] = { type, component, config };
|