@navita/engine 0.0.12 → 0.0.13

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.
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const cssVarRegex = /(?<!var\()(\s*)(--[a-zA-Z0-9_-]+)/g;
4
+ function normalizeCSSVarsValue(value) {
5
+ if (value.startsWith('--') || value.includes(' --') || value.includes(',--')) {
6
+ return value.replace(cssVarRegex, "$1var($2)");
7
+ }
8
+ return value;
9
+ }
10
+
11
+ exports.normalizeCSSVarsValue = normalizeCSSVarsValue;
@@ -0,0 +1,9 @@
1
+ const cssVarRegex = /(?<!var\()(\s*)(--[a-zA-Z0-9_-]+)/g;
2
+ function normalizeCSSVarsValue(value) {
3
+ if (value.startsWith('--') || value.includes(' --') || value.includes(',--')) {
4
+ return value.replace(cssVarRegex, "$1var($2)");
5
+ }
6
+ return value;
7
+ }
8
+
9
+ export { normalizeCSSVarsValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navita/engine",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Navitas CSS-in-JS engine",
5
5
  "keywords": [
6
6
  "css-in-js",
package/processStyles.cjs CHANGED
@@ -10,6 +10,7 @@ var helpers_normalizeCSSVarsProperty = require('./helpers/normalizeCSSVarsProper
10
10
  var helpers_normalizeNestedProperty = require('./helpers/normalizeNestedProperty.cjs');
11
11
  var helpers_pixelifyProperties = require('./helpers/pixelifyProperties.cjs');
12
12
  var helpers_transformContentProperty = require('./helpers/transformContentProperty.cjs');
13
+ var helpers_normalizeCSSVarsValue = require('./helpers/normalizeCSSVarsValue.cjs');
13
14
 
14
15
  const transformValuePropertyMap = {
15
16
  content: helpers_transformContentProperty.transformContentProperty
@@ -57,10 +58,7 @@ function processStyles({ cache , type }) {
57
58
  let newValue = value;
58
59
  if (typeof value === "string") {
59
60
  newValue = value.trim().replace(/;[\n\s]*$/, "");
60
- }
61
- // Check if value starts with --, if so, wrap in var()
62
- if (typeof newValue === "string" && newValue.startsWith("--")) {
63
- newValue = `var(${value})`;
61
+ newValue = helpers_normalizeCSSVarsValue.normalizeCSSVarsValue(newValue);
64
62
  }
65
63
  if (typeof value === "number") {
66
64
  newValue = helpers_pixelifyProperties.pixelifyProperties(newProperty, value);
package/processStyles.mjs CHANGED
@@ -8,6 +8,7 @@ import { normalizeCSSVarsProperty } from './helpers/normalizeCSSVarsProperty.mjs
8
8
  import { normalizeNestedProperty } from './helpers/normalizeNestedProperty.mjs';
9
9
  import { pixelifyProperties } from './helpers/pixelifyProperties.mjs';
10
10
  import { transformContentProperty } from './helpers/transformContentProperty.mjs';
11
+ import { normalizeCSSVarsValue } from './helpers/normalizeCSSVarsValue.mjs';
11
12
 
12
13
  const transformValuePropertyMap = {
13
14
  content: transformContentProperty
@@ -55,10 +56,7 @@ function processStyles({ cache , type }) {
55
56
  let newValue = value;
56
57
  if (typeof value === "string") {
57
58
  newValue = value.trim().replace(/;[\n\s]*$/, "");
58
- }
59
- // Check if value starts with --, if so, wrap in var()
60
- if (typeof newValue === "string" && newValue.startsWith("--")) {
61
- newValue = `var(${value})`;
59
+ newValue = normalizeCSSVarsValue(newValue);
62
60
  }
63
61
  if (typeof value === "number") {
64
62
  newValue = pixelifyProperties(newProperty, value);