@vectoriox/iox-builder 4.22.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 };
|
|
@@ -3791,7 +3817,7 @@ class StyleRegistryService {
|
|
|
3791
3817
|
* (e.g., `{ 'iox-primary-color': '#cb9090' }`).
|
|
3792
3818
|
* Pass an empty object to clear all tokens.
|
|
3793
3819
|
*/
|
|
3794
|
-
upsertTokens(tokens) {
|
|
3820
|
+
upsertTokens(tokens, darkTokens) {
|
|
3795
3821
|
const entries = Object.entries(tokens)
|
|
3796
3822
|
.filter(([, v]) => v !== undefined && v !== null && v !== '')
|
|
3797
3823
|
.map(([k, v]) => ` --${k}: ${v};`);
|
|
@@ -3801,6 +3827,17 @@ class StyleRegistryService {
|
|
|
3801
3827
|
else {
|
|
3802
3828
|
this.rules.delete('__tokens__');
|
|
3803
3829
|
}
|
|
3830
|
+
// Dark-scheme overrides (flavors F0): variables only, appended as the token layer's
|
|
3831
|
+
// LAST rule — one ordering convention for every @media block (responsive A3 lesson).
|
|
3832
|
+
const darkEntries = Object.entries(darkTokens ?? {})
|
|
3833
|
+
.filter(([, v]) => v !== undefined && v !== null && v !== '')
|
|
3834
|
+
.map(([k, v]) => ` --${k}: ${v};`);
|
|
3835
|
+
if (darkEntries.length) {
|
|
3836
|
+
this.rules.set('__tokens_dark__', `@media (prefers-color-scheme: dark) {\n :root {\n${darkEntries.join('\n')}\n }\n}`);
|
|
3837
|
+
}
|
|
3838
|
+
else {
|
|
3839
|
+
this.rules.delete('__tokens_dark__');
|
|
3840
|
+
}
|
|
3804
3841
|
this.flush();
|
|
3805
3842
|
}
|
|
3806
3843
|
remove(nodeId) {
|