@teleporthq/teleport-plugin-css 0.44.0-alpha.0 → 0.44.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.
- package/__tests__/component-scoped.ts +4 -2
- package/__tests__/referenced-styles.ts +61 -0
- package/__tests__/selector-paren-sanitize.ts +69 -0
- package/dist/cjs/index.d.ts +9 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +510 -48
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/style-sheet.d.ts.map +1 -1
- package/dist/cjs/style-sheet.js +8 -2
- package/dist/cjs/style-sheet.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils.d.ts +11 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +125 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/index.d.ts +9 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +512 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/style-sheet.d.ts.map +1 -1
- package/dist/esm/style-sheet.js +9 -3
- package/dist/esm/style-sheet.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +11 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +120 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +5 -5
- package/src/index.ts +663 -64
- package/src/style-sheet.ts +10 -4
- package/src/utils.ts +132 -0
package/dist/esm/index.js
CHANGED
|
@@ -45,20 +45,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
48
|
+
import { join } from 'path';
|
|
49
|
+
import { StringUtils, UIDLUtils, GenericUtils } from '@teleporthq/teleport-shared';
|
|
50
|
+
import { StyleUtils, StyleBuilders, HASTUtils, HASTBuilders, ASTUtils, createBinaryExpression, } from '@teleporthq/teleport-plugin-common';
|
|
50
51
|
import * as types from '@babel/types';
|
|
51
52
|
import { ChunkType, FileType, PluginCSS, } from '@teleporthq/teleport-types';
|
|
52
53
|
import { createStyleSheetPlugin } from './style-sheet';
|
|
54
|
+
import { createConditionalStatement } from './utils';
|
|
55
|
+
var prefixUrlPathsInCss = function (css, folderPath) {
|
|
56
|
+
var relativePrefix = GenericUtils.localRelativePath(join.apply(void 0, folderPath), './');
|
|
57
|
+
if (!relativePrefix) {
|
|
58
|
+
return css;
|
|
59
|
+
}
|
|
60
|
+
return css.replace(/url\(["']?(.*?)["']?\)/g, function (match, url) {
|
|
61
|
+
if (url.startsWith('http') ||
|
|
62
|
+
url.startsWith('data:') ||
|
|
63
|
+
url.startsWith('../') ||
|
|
64
|
+
url.startsWith('#')) {
|
|
65
|
+
return match;
|
|
66
|
+
}
|
|
67
|
+
return "url(\"".concat(join(relativePrefix, url), "\")");
|
|
68
|
+
});
|
|
69
|
+
};
|
|
53
70
|
var createCSSPlugin = function (config) {
|
|
54
|
-
var _a = config || {}, _b = _a.chunkName, chunkName = _b === void 0 ? 'style-chunk' : _b, _c = _a.templateChunkName, templateChunkName = _c === void 0 ? 'template-chunk' : _c, _d = _a.componentDecoratorChunkName, componentDecoratorChunkName = _d === void 0 ? 'component-decorator' : _d, _e = _a.inlineStyleAttributeKey, inlineStyleAttributeKey = _e === void 0 ? 'style' : _e, _f = _a.classAttributeName, classAttributeName = _f === void 0 ? 'class' : _f, _g = _a.templateStyle, templateStyle = _g === void 0 ? 'html' : _g, _h = _a.declareDependency, declareDependency = _h === void 0 ? 'none' : _h, _j = _a.
|
|
71
|
+
var _a = config || {}, _b = _a.chunkName, chunkName = _b === void 0 ? 'style-chunk' : _b, _c = _a.templateChunkName, templateChunkName = _c === void 0 ? 'template-chunk' : _c, _d = _a.componentDecoratorChunkName, componentDecoratorChunkName = _d === void 0 ? 'component-decorator' : _d, _e = _a.inlineStyleAttributeKey, inlineStyleAttributeKey = _e === void 0 ? 'style' : _e, _f = _a.classAttributeName, classAttributeName = _f === void 0 ? 'class' : _f, _g = _a.templateStyle, templateStyle = _g === void 0 ? 'html' : _g, _h = _a.declareDependency, declareDependency = _h === void 0 ? 'none' : _h, dynamicVariantPrefix = _a.dynamicVariantPrefix, _j = _a.staticPropReferences, staticPropReferences = _j === void 0 ? false : _j, _k = _a.standaloneHtmlComponents, standaloneHtmlComponents = _k === void 0 ? false : _k, _l = _a.doubleElementClass, doubleElementClass = _l === void 0 ? false : _l;
|
|
55
72
|
var cssPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var uidl, chunks, dependencies, options, node, _a, componentStyleSet, _b, propDefinitions, _c,
|
|
57
|
-
|
|
73
|
+
var uidl, chunks, dependencies, options, node, _a, componentStyleSet, _b, propDefinitions, _c, stateDefinitions, _d, projectStyleSet, _e, _f, _g, tokens, isRootComponent, _h, globalStateDefinitions, prefixInlineClasses, _j, _k, styleSetDefinitions, projectStyleSheetName, projectStyleSheetPath, templateChunk, componentDecoratorChunk, jsxNodesLookup, propsPrefix, cssMap, mediaStylesMap, usedProjectStyleIds, generateStylesForElementNode, _i, _l, prop, inlineCssMap, hasTokens, hasUsedProjectStyles, globalAssets, scopedRootClass_1, scopeCssSelectors_1, inlineStyleAssets, _m, inlineStyleAssets_1, styleAsset, css, tokenSelector, usedProjectStyles_1, filteredDefinitions, projectStylesCssMap, projectMediaStylesMap, scopedProjectStyles, mediaStyles, scopedMediaStyles, scopedCssMap, fontAssets, fontLinkNodes, _o, fontAssets_1, fontAsset, linkNode, _p, _q, _r, attrKey, attrValue, value, nodesToPrepend, styleNode, cssContent, cssFileName, decoratorAST, decoratorParam, folderPath_1, cssContent;
|
|
74
|
+
var _s;
|
|
75
|
+
var _t, _u;
|
|
76
|
+
return __generator(this, function (_v) {
|
|
58
77
|
uidl = structure.uidl, chunks = structure.chunks, dependencies = structure.dependencies, options = structure.options;
|
|
59
|
-
node = uidl.node, _a = uidl.styleSetDefinitions, componentStyleSet = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b;
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
node = uidl.node, _a = uidl.styleSetDefinitions, componentStyleSet = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b, _c = uidl.stateDefinitions, stateDefinitions = _c === void 0 ? {} : _c;
|
|
79
|
+
_d = options || {}, projectStyleSet = _d.projectStyleSet, _e = _d.designLanguage, _f = _e === void 0 ? {} : _e, _g = _f.tokens, tokens = _g === void 0 ? {} : _g, isRootComponent = _d.isRootComponent, _h = _d.globalStateDefinitions, globalStateDefinitions = _h === void 0 ? {} : _h, prefixInlineClasses = _d.prefixInlineClasses;
|
|
80
|
+
_j = projectStyleSet || {}, _k = _j.styleSetDefinitions, styleSetDefinitions = _k === void 0 ? {} : _k, projectStyleSheetName = _j.fileName, projectStyleSheetPath = _j.path;
|
|
62
81
|
if (isRootComponent) {
|
|
63
82
|
if (Object.keys(tokens).length > 0 || Object.keys(styleSetDefinitions).length > 0) {
|
|
64
83
|
dependencies[projectStyleSheetName] = {
|
|
@@ -73,62 +92,108 @@ var createCSSPlugin = function (config) {
|
|
|
73
92
|
}
|
|
74
93
|
templateChunk = chunks.find(function (chunk) { return chunk.name === templateChunkName; });
|
|
75
94
|
componentDecoratorChunk = chunks.find(function (chunk) { return chunk.name === componentDecoratorChunkName; });
|
|
76
|
-
|
|
95
|
+
jsxNodesLookup = templateChunk.meta.nodesLookup;
|
|
77
96
|
propsPrefix = templateChunk.meta.dynamicRefPrefix
|
|
78
97
|
? templateChunk.meta.dynamicRefPrefix.prop
|
|
79
98
|
: '';
|
|
80
99
|
cssMap = [];
|
|
81
100
|
mediaStylesMap = {};
|
|
82
|
-
|
|
101
|
+
usedProjectStyleIds = new Set();
|
|
102
|
+
generateStylesForElementNode = function (element) {
|
|
83
103
|
var _a, _b;
|
|
84
104
|
var classNamesToAppend = new Set();
|
|
85
105
|
var dynamicVariantsToAppend = new Set();
|
|
86
|
-
var _c = element.style, style = _c === void 0 ? {} : _c, key = element.key, _d = element.referencedStyles, referencedStyles = _d === void 0 ? {} : _d,
|
|
87
|
-
var
|
|
88
|
-
|
|
106
|
+
var _c = element.style, style = _c === void 0 ? {} : _c, key = element.key, _d = element.referencedStyles, referencedStyles = _d === void 0 ? {} : _d, _e = element.attrs, attrs = _e === void 0 ? {} : _e, elementType = element.elementType, dependency = element.dependency;
|
|
107
|
+
var dynamicStyleBindings = element.dynamicStyleBindings;
|
|
108
|
+
var hasDynamicBindings = dynamicStyleBindings && Object.keys(dynamicStyleBindings).length > 0;
|
|
109
|
+
var root = jsxNodesLookup[key];
|
|
110
|
+
if (!root) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Refer to line 323 all component scoped styles are appended with component name by default
|
|
114
|
+
if ((dependency === null || dependency === void 0 ? void 0 : dependency.type) === 'local') {
|
|
89
115
|
StyleBuilders.setPropValueForCompStyle({
|
|
90
116
|
attrs: attrs,
|
|
91
|
-
|
|
92
|
-
jsxNodesLookup: templateLookup,
|
|
117
|
+
root: root,
|
|
93
118
|
templateStyle: templateStyle,
|
|
119
|
+
// elementType is used here in-order to target the component name that the class is actually defined.
|
|
120
|
+
// Here we are appendigng to the node where the component is being called.
|
|
94
121
|
getClassName: function (styleName) {
|
|
95
|
-
return
|
|
122
|
+
return StringUtils.camelCaseToDashCase(elementType + styleName);
|
|
96
123
|
},
|
|
97
124
|
});
|
|
98
125
|
}
|
|
99
126
|
if (Object.keys(style).length === 0 &&
|
|
100
127
|
Object.keys(referencedStyles).length === 0 &&
|
|
101
|
-
Object.keys(componentStyleSet).length === 0
|
|
128
|
+
Object.keys(componentStyleSet).length === 0 &&
|
|
129
|
+
!hasDynamicBindings) {
|
|
102
130
|
return;
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
132
|
+
// Inline (node-key-derived) classes can share a name with a real project
|
|
133
|
+
// class. When `prefixInlineClasses` is set (AI editor codegen only), tag
|
|
134
|
+
// every inline class so the consumer can tell fake from real by name.
|
|
135
|
+
var className = prefixInlineClasses
|
|
136
|
+
? "".concat(prefixInlineClasses).concat(StringUtils.camelCaseToDashCase(key))
|
|
137
|
+
: StringUtils.camelCaseToDashCase(key);
|
|
138
|
+
// `&` is the class; doubled it reads `.name.name`. Nested, because JSS
|
|
139
|
+
// escapes a dot written into the class name itself. The element still
|
|
140
|
+
// wears the class once.
|
|
141
|
+
var own = doubleElementClass ? "&.".concat(className) : '&';
|
|
109
142
|
var _f = UIDLUtils.splitDynamicAndStaticStyles(style), staticStyles = _f.staticStyles, dynamicStyles = _f.dynamicStyles, tokenStyles = _f.tokenStyles;
|
|
110
143
|
if (Object.keys(staticStyles).length > 0 || Object.keys(tokenStyles).length > 0) {
|
|
111
144
|
var collectedStyles = __assign(__assign({}, StyleUtils.getContentOfStyleObject(staticStyles)), StyleUtils.getCSSVariablesContentFromTokenStyles(tokenStyles));
|
|
112
|
-
cssMap.push(
|
|
145
|
+
cssMap.push(doubleElementClass
|
|
146
|
+
? StyleBuilders.createCSSClassWithSelector(className, own, collectedStyles)
|
|
147
|
+
: StyleBuilders.createCSSClass(className, collectedStyles));
|
|
113
148
|
classNamesToAppend.add(className);
|
|
114
149
|
}
|
|
150
|
+
var jsxInlineStyles = null;
|
|
115
151
|
if (Object.keys(dynamicStyles).length > 0) {
|
|
152
|
+
for (var _i = 0, _g = Object.values(dynamicStyles); _i < _g.length; _i++) {
|
|
153
|
+
var styleValue = _g[_i];
|
|
154
|
+
if (styleValue.type === 'dynamic' &&
|
|
155
|
+
styleValue.content.referenceType === 'global' &&
|
|
156
|
+
templateChunk.meta.globalReferences) {
|
|
157
|
+
;
|
|
158
|
+
templateChunk.meta.globalReferences.push(styleValue.content.id);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
116
161
|
/* If dynamic styles are on nested-styles they are unfortunately lost,
|
|
117
162
|
since inline style does not support that */
|
|
118
163
|
if (templateStyle === 'html') {
|
|
119
164
|
var inlineStyles = createDynamicInlineStyle(dynamicStyles);
|
|
120
|
-
|
|
165
|
+
var bindingParts = hasDynamicBindings
|
|
166
|
+
? createDynamicBindingInlineStyle(dynamicStyleBindings)
|
|
167
|
+
: '';
|
|
168
|
+
var combined = bindingParts ? "".concat(inlineStyles, ", ").concat(bindingParts) : inlineStyles;
|
|
169
|
+
HASTUtils.addAttributeToNode(root, inlineStyleAttributeKey, "{".concat(combined, "}"));
|
|
121
170
|
}
|
|
122
171
|
else {
|
|
123
|
-
|
|
172
|
+
jsxInlineStyles = UIDLUtils.transformDynamicStyles(dynamicStyles, function (styleValue) {
|
|
124
173
|
return StyleBuilders.createDynamicStyleExpression(styleValue, propsPrefix);
|
|
125
174
|
});
|
|
126
|
-
ASTUtils.addAttributeToJSXTag(root, inlineStyleAttributeKey, inlineStyles);
|
|
127
175
|
}
|
|
128
176
|
}
|
|
177
|
+
else if (hasDynamicBindings && templateStyle === 'html') {
|
|
178
|
+
var bindingParts = createDynamicBindingInlineStyle(dynamicStyleBindings);
|
|
179
|
+
HASTUtils.addAttributeToNode(root, inlineStyleAttributeKey, "{".concat(bindingParts, "}"));
|
|
180
|
+
}
|
|
181
|
+
if (hasDynamicBindings && templateStyle !== 'html') {
|
|
182
|
+
if (!jsxInlineStyles) {
|
|
183
|
+
jsxInlineStyles = {};
|
|
184
|
+
}
|
|
185
|
+
for (var _h = 0, _j = Object.entries(dynamicStyleBindings); _h < _j.length; _h++) {
|
|
186
|
+
var _k = _j[_h], cssProperty = _k[0], binding = _k[1];
|
|
187
|
+
var camelCaseProperty = StringUtils.cssPropertyToInlineStyleKey(cssProperty);
|
|
188
|
+
jsxInlineStyles[camelCaseProperty] = StyleBuilders.createDynamicBindingExpression(binding);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (jsxInlineStyles) {
|
|
192
|
+
ASTUtils.addAttributeToJSXTag(root, inlineStyleAttributeKey, jsxInlineStyles);
|
|
193
|
+
}
|
|
129
194
|
Object.values(referencedStyles).forEach(function (styleRef) {
|
|
130
|
-
var _a;
|
|
131
|
-
var
|
|
195
|
+
var _a, _b;
|
|
196
|
+
var _c, _d;
|
|
132
197
|
switch (styleRef.content.mapType) {
|
|
133
198
|
case 'inlined': {
|
|
134
199
|
var filtredStyles = UIDLUtils.splitDynamicAndStaticStyles(styleRef.content.styles);
|
|
@@ -140,10 +205,12 @@ var createCSSPlugin = function (config) {
|
|
|
140
205
|
if (!mediaStylesMap[String(maxWidth)]) {
|
|
141
206
|
mediaStylesMap[String(maxWidth)] = [];
|
|
142
207
|
}
|
|
143
|
-
mediaStylesMap[String(maxWidth)].push((_a = {},
|
|
208
|
+
mediaStylesMap[String(maxWidth)].push((_a = {},
|
|
209
|
+
_a[className] = doubleElementClass ? (_b = {}, _b[own] = collectedStyles, _b) : collectedStyles,
|
|
210
|
+
_a));
|
|
144
211
|
}
|
|
145
212
|
if (condition.conditionType === 'element-state') {
|
|
146
|
-
cssMap.push(StyleBuilders.createCSSClassWithSelector(className, "
|
|
213
|
+
cssMap.push(StyleBuilders.createCSSClassWithSelector(className, "".concat(own, ":").concat(condition.content), collectedStyles));
|
|
147
214
|
}
|
|
148
215
|
classNamesToAppend.add(className);
|
|
149
216
|
return;
|
|
@@ -154,19 +221,20 @@ var createCSSPlugin = function (config) {
|
|
|
154
221
|
}
|
|
155
222
|
if (styleRef.content.content.type === 'dynamic' &&
|
|
156
223
|
styleRef.content.content.content.referenceType === 'prop') {
|
|
157
|
-
var defaultPropValue = (
|
|
224
|
+
var defaultPropValue = (_c = propDefinitions[styleRef.content.content.content.id]) === null || _c === void 0 ? void 0 : _c.defaultValue;
|
|
158
225
|
if (defaultPropValue) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
propDefinitions[styleRef.content.content.content.id].defaultValue = getClassName(forceScoping, uidl.name, String(defaultPropValue));
|
|
226
|
+
propDefinitions[styleRef.content.content.content.id].defaultValue =
|
|
227
|
+
StringUtils.camelCaseToDashCase(String(defaultPropValue));
|
|
162
228
|
}
|
|
229
|
+
// staticPropReferences flag is only used for just html-code generation.
|
|
230
|
+
// This is used to append the class name to the node where the component is being called.
|
|
231
|
+
// Instead of how frameworks handle them using props at runtime. This makes the props
|
|
232
|
+
// to behave statically during the generation time instead by appending them directly.
|
|
163
233
|
if (staticPropReferences) {
|
|
164
|
-
if (
|
|
234
|
+
if (defaultPropValue === undefined || typeof defaultPropValue !== 'string') {
|
|
165
235
|
return;
|
|
166
236
|
}
|
|
167
|
-
|
|
168
|
-
classNamesToAppend.add(getClassName(forceScoping, uidl.name, String(defaultPropValue)));
|
|
169
|
-
}
|
|
237
|
+
classNamesToAppend.add(StringUtils.camelCaseToDashCase(uidl.name + defaultPropValue));
|
|
170
238
|
}
|
|
171
239
|
else {
|
|
172
240
|
dynamicVariantsToAppend.add(styleRef.content.content.content.id);
|
|
@@ -177,7 +245,7 @@ var createCSSPlugin = function (config) {
|
|
|
177
245
|
if (!componentStyleSet[styleRef.content.content.content.id]) {
|
|
178
246
|
throw new PluginCSS("Node ".concat(elementType, " is referring to a comp style instance ").concat(styleRef.content.content.content.id, " which is missing."));
|
|
179
247
|
}
|
|
180
|
-
classNamesToAppend.add(
|
|
248
|
+
classNamesToAppend.add(StringUtils.camelCaseToDashCase(uidl.name + styleRef.content.content.content.id));
|
|
181
249
|
}
|
|
182
250
|
return;
|
|
183
251
|
}
|
|
@@ -185,9 +253,201 @@ var createCSSPlugin = function (config) {
|
|
|
185
253
|
var content = styleRef.content;
|
|
186
254
|
var referedStyle = styleSetDefinitions[content.referenceId];
|
|
187
255
|
if (!referedStyle) {
|
|
188
|
-
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
usedProjectStyleIds.add(content.referenceId);
|
|
259
|
+
if (styleRef.content.condition) {
|
|
260
|
+
if (templateStyle === 'html') {
|
|
261
|
+
var _e = styleRef.content.condition, staticValue = _e.value, reference = _e.reference, matchingCriteria = _e.expression.matchingCriteria;
|
|
262
|
+
// Class conditions are single-reference flat chains: no writer
|
|
263
|
+
// emits per-entry references or nested groups here.
|
|
264
|
+
var conditions = styleRef.content.condition.expression
|
|
265
|
+
.conditions;
|
|
266
|
+
var _f = reference.content, referenceType = _f.referenceType, id = _f.id, _g = _f.refPath, refPath = _g === void 0 ? [] : _g;
|
|
267
|
+
switch (referenceType) {
|
|
268
|
+
case 'prop': {
|
|
269
|
+
var usedProp = propDefinitions[id];
|
|
270
|
+
if (usedProp === undefined || usedProp.defaultValue === undefined) {
|
|
271
|
+
throw new PluginCSS("Prop with ".concat(id, " is missing in the propDefinitions."));
|
|
272
|
+
}
|
|
273
|
+
var defaultValue = usedProp.defaultValue;
|
|
274
|
+
var operandDefaultValue = void 0;
|
|
275
|
+
for (var _i = 0, refPath_1 = refPath; _i < refPath_1.length; _i++) {
|
|
276
|
+
var path = refPath_1[_i];
|
|
277
|
+
defaultValue = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[path];
|
|
278
|
+
}
|
|
279
|
+
// If defaultValue is undefined or null after path traversal, use original default
|
|
280
|
+
defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : usedProp.defaultValue;
|
|
281
|
+
// our conditions can be of type 'expr' or they can be a dynamic reference
|
|
282
|
+
var rightSideCondition = conditions[0].operand;
|
|
283
|
+
var rightSideConditionType = typeof rightSideCondition;
|
|
284
|
+
if (rightSideConditionType === 'object') {
|
|
285
|
+
var type = rightSideCondition.type;
|
|
286
|
+
if (type === 'dynamic') {
|
|
287
|
+
var dynamicRef = rightSideCondition;
|
|
288
|
+
if (dynamicRef.content.referenceType === 'prop') {
|
|
289
|
+
var prop = propDefinitions[dynamicRef.content.id];
|
|
290
|
+
if (prop && prop.defaultValue) {
|
|
291
|
+
operandDefaultValue = prop.defaultValue;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (dynamicRef.content.referenceType === 'state') {
|
|
295
|
+
var state = stateDefinitions[dynamicRef.content.id];
|
|
296
|
+
if (state && state.defaultValue) {
|
|
297
|
+
defaultValue = state.defaultValue;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (type === 'expr') {
|
|
302
|
+
operandDefaultValue = rightSideCondition.content;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
operandDefaultValue = rightSideCondition;
|
|
307
|
+
}
|
|
308
|
+
// Since we know the operand and the default value from the prop.
|
|
309
|
+
// We can try building the condition and check if the condition is true or false.
|
|
310
|
+
// @todo: You can only use a 'value' in UIDL or 'conditions' but not both.
|
|
311
|
+
// UIDL validations need to be improved on this aspect.
|
|
312
|
+
var resolvedConditions = [
|
|
313
|
+
{
|
|
314
|
+
operation: conditions[0].operation,
|
|
315
|
+
operand: operandDefaultValue,
|
|
316
|
+
},
|
|
317
|
+
];
|
|
318
|
+
var dynamicConditions = createConditionalStatement(staticValue !== undefined
|
|
319
|
+
? [{ operand: staticValue, operation: '===' }]
|
|
320
|
+
: resolvedConditions, defaultValue);
|
|
321
|
+
var matchCondition = matchingCriteria && matchingCriteria === 'all' ? '&&' : '||';
|
|
322
|
+
var conditionString = dynamicConditions.join(" ".concat(matchCondition, " "));
|
|
323
|
+
// tslint:disable-next-line function-constructor
|
|
324
|
+
var isConditionPassing = new Function("return ".concat(conditionString))();
|
|
325
|
+
if (isConditionPassing) {
|
|
326
|
+
classNamesToAppend.add(styleRef.content.referenceId);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
case 'state': {
|
|
332
|
+
var usedState = stateDefinitions[id];
|
|
333
|
+
if (usedState === undefined || usedState.defaultValue === undefined) {
|
|
334
|
+
throw new PluginCSS("State with ".concat(id, " is missing in the stateDefinitions."));
|
|
335
|
+
}
|
|
336
|
+
var defaultValue = usedState.defaultValue;
|
|
337
|
+
for (var _h = 0, refPath_2 = refPath; _h < refPath_2.length; _h++) {
|
|
338
|
+
var path = refPath_2[_h];
|
|
339
|
+
defaultValue = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[path];
|
|
340
|
+
}
|
|
341
|
+
if (typeof defaultValue === 'object' &&
|
|
342
|
+
defaultValue !== null &&
|
|
343
|
+
'type' in defaultValue &&
|
|
344
|
+
'content' in defaultValue) {
|
|
345
|
+
var entry = defaultValue;
|
|
346
|
+
if (entry.type === 'static') {
|
|
347
|
+
defaultValue = entry.content;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : usedState.defaultValue;
|
|
351
|
+
var dynamicConditions = createConditionalStatement(staticValue !== undefined
|
|
352
|
+
? [{ operand: staticValue, operation: '===' }]
|
|
353
|
+
: conditions, defaultValue);
|
|
354
|
+
var matchCondition = matchingCriteria && matchingCriteria === 'all' ? '&&' : '||';
|
|
355
|
+
var conditionString = dynamicConditions.join(" ".concat(matchCondition, " "));
|
|
356
|
+
// tslint:disable-next-line function-constructor
|
|
357
|
+
var isConditionPassing = new Function("return ".concat(conditionString))();
|
|
358
|
+
if (isConditionPassing) {
|
|
359
|
+
classNamesToAppend.add(styleRef.content.referenceId);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
case 'globalState': {
|
|
365
|
+
var gsDef = findGlobalStateDefinitionById(id, globalStateDefinitions);
|
|
366
|
+
if (!gsDef) {
|
|
367
|
+
classNamesToAppend.add(styleRef.content.referenceId);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
var defaultValue = gsDef.defaultValue;
|
|
371
|
+
for (var _j = 0, refPath_3 = refPath; _j < refPath_3.length; _j++) {
|
|
372
|
+
var path = refPath_3[_j];
|
|
373
|
+
defaultValue = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[path];
|
|
374
|
+
}
|
|
375
|
+
defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : gsDef.defaultValue;
|
|
376
|
+
var dynamicConditions = createConditionalStatement(staticValue !== undefined
|
|
377
|
+
? [{ operand: staticValue, operation: '===' }]
|
|
378
|
+
: conditions, defaultValue);
|
|
379
|
+
var matchCondition = matchingCriteria && matchingCriteria === 'all' ? '&&' : '||';
|
|
380
|
+
var conditionString = dynamicConditions.join(" ".concat(matchCondition, " "));
|
|
381
|
+
// tslint:disable-next-line function-constructor
|
|
382
|
+
var isConditionPassing = new Function("return ".concat(conditionString))();
|
|
383
|
+
if (isConditionPassing) {
|
|
384
|
+
classNamesToAppend.add(styleRef.content.referenceId);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
default: {
|
|
390
|
+
classNamesToAppend.add(styleRef.content.referenceId);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
var referenceContent = styleRef.content.condition.reference.content;
|
|
397
|
+
var referenceType = referenceContent.referenceType;
|
|
398
|
+
var nameToAppend = referenceType === 'local' && ((_d = referenceContent.refPath) === null || _d === void 0 ? void 0 : _d.length)
|
|
399
|
+
? referenceContent.refPath.join('.')
|
|
400
|
+
: referenceContent.id;
|
|
401
|
+
// Same flat-leaf contract as the html branch above.
|
|
402
|
+
var conditions = styleRef.content.condition.expression
|
|
403
|
+
.conditions;
|
|
404
|
+
var operator = conditions[0].operation;
|
|
405
|
+
var right = conditions[0].operand;
|
|
406
|
+
var binaryExpressionType = '';
|
|
407
|
+
switch (referenceType) {
|
|
408
|
+
case 'prop': {
|
|
409
|
+
binaryExpressionType = propDefinitions[nameToAppend].type;
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
case 'state': {
|
|
413
|
+
binaryExpressionType = stateDefinitions[nameToAppend].type;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case 'local': {
|
|
417
|
+
binaryExpressionType = typeof right;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
default: {
|
|
421
|
+
if (referenceType === 'globalState') {
|
|
422
|
+
var gsDef = findGlobalStateDefinitionById(nameToAppend, globalStateDefinitions);
|
|
423
|
+
if (gsDef) {
|
|
424
|
+
binaryExpressionType = gsDef.type;
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
throw new PluginCSS("Un-supported reference type ".concat(referenceType, " for ").concat(nameToAppend));
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
var binaryKey = nameToAppend;
|
|
432
|
+
if (referenceType === 'prop') {
|
|
433
|
+
binaryKey = 'props?.' + nameToAppend;
|
|
434
|
+
}
|
|
435
|
+
else if (referenceType === 'globalState') {
|
|
436
|
+
var gsDef = findGlobalStateDefinitionById(nameToAppend, globalStateDefinitions);
|
|
437
|
+
binaryKey = gsDef ? gsDef.name : nameToAppend;
|
|
438
|
+
}
|
|
439
|
+
var binaryExpression = createBinaryExpression({ operation: operator, operand: right }, {
|
|
440
|
+
key: binaryKey,
|
|
441
|
+
type: binaryExpressionType,
|
|
442
|
+
});
|
|
443
|
+
var conditionalExpression = types.conditionalExpression(binaryExpression, types.stringLiteral(content.referenceId), types.stringLiteral(''));
|
|
444
|
+
dynamicVariantsToAppend.add(conditionalExpression);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
classNamesToAppend.add(content.referenceId);
|
|
189
450
|
}
|
|
190
|
-
classNamesToAppend.add(content.referenceId);
|
|
191
451
|
return;
|
|
192
452
|
}
|
|
193
453
|
default: {
|
|
@@ -211,17 +471,200 @@ var createCSSPlugin = function (config) {
|
|
|
211
471
|
var dynamicAttrValueIdentifier = dynamicVariantPrefix
|
|
212
472
|
? types.identifier(dynamicVariantPrefix)
|
|
213
473
|
: types.identifier(propsPrefix);
|
|
214
|
-
|
|
474
|
+
if (typeof variant === 'string') {
|
|
475
|
+
return types.memberExpression(dynamicAttrValueIdentifier, types.identifier(variant));
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
// variant is a ConditionalExpression, so return it directly
|
|
479
|
+
return variant;
|
|
480
|
+
}
|
|
215
481
|
}));
|
|
216
482
|
}
|
|
217
|
-
}
|
|
483
|
+
};
|
|
484
|
+
UIDLUtils.traverseElements(node, generateStylesForElementNode);
|
|
485
|
+
for (_i = 0, _l = Object.values(propDefinitions); _i < _l.length; _i++) {
|
|
486
|
+
prop = _l[_i];
|
|
487
|
+
if (prop.type === 'element' && prop.defaultValue) {
|
|
488
|
+
UIDLUtils.traverseElements(prop.defaultValue, generateStylesForElementNode);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
218
491
|
if (Object.keys(componentStyleSet).length > 0) {
|
|
219
|
-
StyleBuilders.generateStylesFromStyleSetDefinitions(componentStyleSet, cssMap, mediaStylesMap, function (styleName) {
|
|
492
|
+
StyleBuilders.generateStylesFromStyleSetDefinitions(componentStyleSet, cssMap, mediaStylesMap, function (styleName) {
|
|
493
|
+
return StringUtils.camelCaseToDashCase(uidl.name + styleName);
|
|
494
|
+
});
|
|
220
495
|
}
|
|
221
496
|
if (Object.keys(mediaStylesMap).length > 0) {
|
|
222
497
|
cssMap.push.apply(cssMap, StyleBuilders.generateMediaStyle(mediaStylesMap));
|
|
223
498
|
}
|
|
224
|
-
|
|
499
|
+
// Handle inline style tag for HTML templates (self-contained fragments)
|
|
500
|
+
if (standaloneHtmlComponents && templateStyle === 'html' && templateChunk) {
|
|
501
|
+
inlineCssMap = [];
|
|
502
|
+
hasTokens = Object.keys(tokens).length > 0;
|
|
503
|
+
hasUsedProjectStyles = usedProjectStyleIds.size > 0;
|
|
504
|
+
globalAssets = options.globalAssets || [];
|
|
505
|
+
scopedRootClass_1 = (_t = templateChunk.meta) === null || _t === void 0 ? void 0 : _t.scopedRootClass;
|
|
506
|
+
scopeCssSelectors_1 = function (css, rootSelector) {
|
|
507
|
+
// Replace :root with scoped root class
|
|
508
|
+
var scopedCss = css.replace(/:root\s*\{/g, "".concat(rootSelector, " {"));
|
|
509
|
+
// Scope regular selectors (but not inside @media or @keyframes)
|
|
510
|
+
// This regex matches CSS rules outside of @ blocks
|
|
511
|
+
scopedCss = scopedCss.replace(/(?:^|\})\s*([^@{}]+?)\s*\{/gm, function (match, selectors) {
|
|
512
|
+
// Skip if it's just closing brace or empty
|
|
513
|
+
if (!selectors || selectors.trim() === '') {
|
|
514
|
+
return match;
|
|
515
|
+
}
|
|
516
|
+
// Skip if selector is already the root class
|
|
517
|
+
if (selectors.trim() === rootSelector) {
|
|
518
|
+
return match;
|
|
519
|
+
}
|
|
520
|
+
// Handle multiple selectors (comma-separated)
|
|
521
|
+
var scopedSelectors = selectors
|
|
522
|
+
.split(',')
|
|
523
|
+
.map(function (sel) {
|
|
524
|
+
var trimmedSel = sel.trim();
|
|
525
|
+
// Skip empty selectors
|
|
526
|
+
if (!trimmedSel) {
|
|
527
|
+
return '';
|
|
528
|
+
}
|
|
529
|
+
// Skip if already scoped
|
|
530
|
+
if (trimmedSel.startsWith(rootSelector)) {
|
|
531
|
+
return trimmedSel;
|
|
532
|
+
}
|
|
533
|
+
// Replace html/body with root selector
|
|
534
|
+
if (trimmedSel === 'html' || trimmedSel === 'body') {
|
|
535
|
+
return rootSelector;
|
|
536
|
+
}
|
|
537
|
+
// For universal selector, scope it
|
|
538
|
+
if (trimmedSel === '*') {
|
|
539
|
+
return "".concat(rootSelector, " *");
|
|
540
|
+
}
|
|
541
|
+
// Prefix other selectors with root
|
|
542
|
+
return "".concat(rootSelector, " ").concat(trimmedSel);
|
|
543
|
+
})
|
|
544
|
+
.filter(Boolean)
|
|
545
|
+
.join(', ');
|
|
546
|
+
return match.replace(selectors, scopedSelectors);
|
|
547
|
+
});
|
|
548
|
+
return scopedCss;
|
|
549
|
+
};
|
|
550
|
+
inlineStyleAssets = globalAssets.filter(function (asset) { return asset.type === 'style' && 'content' in asset; });
|
|
551
|
+
for (_m = 0, inlineStyleAssets_1 = inlineStyleAssets; _m < inlineStyleAssets_1.length; _m++) {
|
|
552
|
+
styleAsset = inlineStyleAssets_1[_m];
|
|
553
|
+
if (styleAsset.content) {
|
|
554
|
+
css = scopedRootClass_1
|
|
555
|
+
? scopeCssSelectors_1(styleAsset.content, ".".concat(scopedRootClass_1))
|
|
556
|
+
: styleAsset.content;
|
|
557
|
+
inlineCssMap.push(css);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
// 1. Add CSS variables (tokens) - scoped to root class instead of :root
|
|
561
|
+
if (hasTokens) {
|
|
562
|
+
tokenSelector = scopedRootClass_1 ? ".".concat(scopedRootClass_1) : ':root';
|
|
563
|
+
inlineCssMap.push(StyleBuilders.createCSSClassWithSelector('@global', tokenSelector, StyleUtils.getTokensContentFromTokensObject(tokens)));
|
|
564
|
+
}
|
|
565
|
+
// 2. Add project-referenced styles that this component uses (scoped)
|
|
566
|
+
if (hasUsedProjectStyles) {
|
|
567
|
+
usedProjectStyles_1 = Array.from(usedProjectStyleIds);
|
|
568
|
+
filteredDefinitions = Object.fromEntries(Object.entries(styleSetDefinitions).filter(function (_a) {
|
|
569
|
+
var key = _a[0], definition = _a[1];
|
|
570
|
+
// Include if exact match
|
|
571
|
+
if (usedProjectStyles_1.includes(key)) {
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
// Include compound selectors where className matches a used project style
|
|
575
|
+
// e.g., "navigation-mobile-overlay.navigation-mobile-overlay-active" has className "navigation-mobile-overlay"
|
|
576
|
+
var className = definition.className;
|
|
577
|
+
if (className && usedProjectStyles_1.includes(className)) {
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
// Include compound selectors where the base class (before the dot or space) is a used style
|
|
581
|
+
// e.g., "dashboard-sidebar.collapsed" should be included if "dashboard-sidebar" is used
|
|
582
|
+
// e.g., "dashboard-sidebar.collapsed .sidebar-brand-text" should also be included
|
|
583
|
+
var dotIdx = key.indexOf('.');
|
|
584
|
+
var spaceIdx = key.indexOf(' ');
|
|
585
|
+
if (dotIdx > 0) {
|
|
586
|
+
var baseClass = key.substring(0, dotIdx);
|
|
587
|
+
if (usedProjectStyles_1.includes(baseClass)) {
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (spaceIdx > 0 && dotIdx < 0) {
|
|
592
|
+
var baseClass = key.substring(0, spaceIdx);
|
|
593
|
+
if (usedProjectStyles_1.includes(baseClass)) {
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return false;
|
|
598
|
+
}));
|
|
599
|
+
projectStylesCssMap = [];
|
|
600
|
+
projectMediaStylesMap = {};
|
|
601
|
+
StyleBuilders.generateStylesFromStyleSetDefinitions(filteredDefinitions, projectStylesCssMap, projectMediaStylesMap, function (styleName) { return styleName; });
|
|
602
|
+
// Scope the project styles if scoped root class is available
|
|
603
|
+
if (scopedRootClass_1) {
|
|
604
|
+
scopedProjectStyles = projectStylesCssMap.map(function (css) {
|
|
605
|
+
return scopeCssSelectors_1(css, ".".concat(scopedRootClass_1));
|
|
606
|
+
});
|
|
607
|
+
inlineCssMap.push.apply(inlineCssMap, scopedProjectStyles);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
inlineCssMap.push.apply(inlineCssMap, projectStylesCssMap);
|
|
611
|
+
}
|
|
612
|
+
if (Object.keys(projectMediaStylesMap).length > 0) {
|
|
613
|
+
mediaStyles = StyleBuilders.generateMediaStyle(projectMediaStylesMap);
|
|
614
|
+
if (scopedRootClass_1) {
|
|
615
|
+
scopedMediaStyles = mediaStyles.map(function (css) {
|
|
616
|
+
return scopeCssSelectors_1(css, ".".concat(scopedRootClass_1));
|
|
617
|
+
});
|
|
618
|
+
inlineCssMap.push.apply(inlineCssMap, scopedMediaStyles);
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
inlineCssMap.push.apply(inlineCssMap, mediaStyles);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
// 3. Add component-specific styles (scoped)
|
|
626
|
+
if (scopedRootClass_1) {
|
|
627
|
+
scopedCssMap = cssMap.map(function (css) { return scopeCssSelectors_1(css, ".".concat(scopedRootClass_1)); });
|
|
628
|
+
inlineCssMap.push.apply(inlineCssMap, scopedCssMap);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
inlineCssMap.push.apply(inlineCssMap, cssMap);
|
|
632
|
+
}
|
|
633
|
+
fontAssets = globalAssets.filter(function (asset) { return asset.type === 'font' && 'path' in asset; });
|
|
634
|
+
fontLinkNodes = [];
|
|
635
|
+
for (_o = 0, fontAssets_1 = fontAssets; _o < fontAssets_1.length; _o++) {
|
|
636
|
+
fontAsset = fontAssets_1[_o];
|
|
637
|
+
linkNode = HASTBuilders.createHTMLNode('link');
|
|
638
|
+
HASTUtils.addAttributeToNode(linkNode, 'rel', 'stylesheet');
|
|
639
|
+
HASTUtils.addAttributeToNode(linkNode, 'href', fontAsset.path);
|
|
640
|
+
if (fontAsset.attrs) {
|
|
641
|
+
for (_p = 0, _q = Object.entries(fontAsset.attrs); _p < _q.length; _p++) {
|
|
642
|
+
_r = _q[_p], attrKey = _r[0], attrValue = _r[1];
|
|
643
|
+
value = typeof attrValue === 'object' && 'content' in attrValue
|
|
644
|
+
? String(attrValue.content)
|
|
645
|
+
: String(attrValue);
|
|
646
|
+
HASTUtils.addAttributeToNode(linkNode, attrKey, value);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
fontLinkNodes.push(linkNode);
|
|
650
|
+
}
|
|
651
|
+
// 5. Create <style> node and prepend to HTML (fonts first, then styles)
|
|
652
|
+
if (inlineCssMap.length > 0 || fontLinkNodes.length > 0) {
|
|
653
|
+
nodesToPrepend = [];
|
|
654
|
+
// Add font links first
|
|
655
|
+
nodesToPrepend.push.apply(nodesToPrepend, fontLinkNodes);
|
|
656
|
+
// Add style tag with all CSS
|
|
657
|
+
if (inlineCssMap.length > 0) {
|
|
658
|
+
styleNode = HASTBuilders.createHTMLNode('style');
|
|
659
|
+
cssContent = HASTBuilders.createTextNode(inlineCssMap.join('\n\n'));
|
|
660
|
+
styleNode.children.push(cssContent);
|
|
661
|
+
nodesToPrepend.push(styleNode);
|
|
662
|
+
}
|
|
663
|
+
;
|
|
664
|
+
(_s = templateChunk.content.children).unshift.apply(_s, nodesToPrepend);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
else if (cssMap.length > 0) {
|
|
225
668
|
cssFileName = UIDLUtils.getStyleFileName(uidl);
|
|
226
669
|
if (declareDependency === 'decorator' && componentDecoratorChunk) {
|
|
227
670
|
decoratorAST = componentDecoratorChunk.content;
|
|
@@ -241,11 +684,15 @@ var createCSSPlugin = function (config) {
|
|
|
241
684
|
},
|
|
242
685
|
};
|
|
243
686
|
}
|
|
687
|
+
folderPath_1 = (_u = uidl.outputOptions) === null || _u === void 0 ? void 0 : _u.folderPath;
|
|
688
|
+
cssContent = (folderPath_1 === null || folderPath_1 === void 0 ? void 0 : folderPath_1.length) > 0
|
|
689
|
+
? cssMap.map(function (css) { return prefixUrlPathsInCss(css, folderPath_1); }).join('\n \n')
|
|
690
|
+
: cssMap.join('\n \n');
|
|
244
691
|
chunks.push({
|
|
245
692
|
type: ChunkType.STRING,
|
|
246
693
|
name: chunkName,
|
|
247
694
|
fileType: FileType.CSS,
|
|
248
|
-
content:
|
|
695
|
+
content: cssContent,
|
|
249
696
|
linkAfter: [],
|
|
250
697
|
});
|
|
251
698
|
}
|
|
@@ -256,6 +703,15 @@ var createCSSPlugin = function (config) {
|
|
|
256
703
|
};
|
|
257
704
|
export { createStyleSheetPlugin, createCSSPlugin };
|
|
258
705
|
export default createCSSPlugin();
|
|
706
|
+
var findGlobalStateDefinitionById = function (id, definitions) {
|
|
707
|
+
for (var _i = 0, _a = Object.values(definitions); _i < _a.length; _i++) {
|
|
708
|
+
var def = _a[_i];
|
|
709
|
+
if (def.id === id) {
|
|
710
|
+
return def;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return undefined;
|
|
714
|
+
};
|
|
259
715
|
var createDynamicInlineStyle = function (styles) {
|
|
260
716
|
return Object.keys(styles)
|
|
261
717
|
.map(function (styleKey) {
|
|
@@ -263,9 +719,15 @@ var createDynamicInlineStyle = function (styles) {
|
|
|
263
719
|
})
|
|
264
720
|
.join(', ');
|
|
265
721
|
};
|
|
266
|
-
var
|
|
267
|
-
return
|
|
268
|
-
|
|
269
|
-
|
|
722
|
+
var createDynamicBindingInlineStyle = function (bindings) {
|
|
723
|
+
return Object.entries(bindings)
|
|
724
|
+
.map(function (_a) {
|
|
725
|
+
var prop = _a[0], binding = _a[1];
|
|
726
|
+
var value = binding.referenceType === 'ctx' && binding.contextName
|
|
727
|
+
? "".concat(binding.contextName, ".").concat(binding.stateKey)
|
|
728
|
+
: binding.stateKey;
|
|
729
|
+
return "".concat(prop, ": ").concat(value, " != null ? ").concat(value, " : '").concat(binding.defaultValue || '', "'");
|
|
730
|
+
})
|
|
731
|
+
.join(', ');
|
|
270
732
|
};
|
|
271
733
|
//# sourceMappingURL=index.js.map
|