@stylexjs/shared 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
- declare function stylexFirstThatWorks<T extends string>(
11
- ...args: ReadonlyArray<T>
12
- ): ReadonlyArray<T>;
10
+ declare function stylexFirstThatWorks(
11
+ ...args: ReadonlyArray<string>
12
+ ): ReadonlyArray<string> | string;
13
13
  export default stylexFirstThatWorks;
@@ -4,9 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = stylexFirstThatWorks;
7
+ const isVar = arg => typeof arg === 'string' && arg.match(/^var\(--[a-zA-Z0-9-_]+\)$/);
7
8
  function stylexFirstThatWorks() {
8
9
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9
10
  args[_key] = arguments[_key];
10
11
  }
11
- return [...args].reverse();
12
+ const firstVar = args.findIndex(isVar);
13
+ if (firstVar === -1) {
14
+ return [...args].reverse();
15
+ }
16
+ const priorities = args.slice(0, firstVar).reverse();
17
+ const rest = args.slice(firstVar);
18
+ const firstNonVar = rest.findIndex(arg => !isVar(arg));
19
+ const varParts = rest.slice(0, firstNonVar === -1 ? rest.length : firstNonVar + 1).reverse();
20
+ const vars = varParts.map(arg => isVar(arg) ? arg.slice(4, -1) : arg);
21
+ const returnValue = [vars.reduce((soFar, varName) => soFar ? `var(${varName}, ${String(soFar)})` : varName.startsWith('--') ? `var(${varName})` : varName, ''), ...priorities];
22
+ if (returnValue.length === 1) {
23
+ return returnValue[0];
24
+ }
25
+ return returnValue;
12
26
  }
@@ -7,6 +7,6 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export default function stylexFirstThatWorks<T: string>(
11
- ...args: $ReadOnlyArray<T>
12
- ): $ReadOnlyArray<T>;
10
+ declare export default function stylexFirstThatWorks(
11
+ ...args: $ReadOnlyArray<string>
12
+ ): $ReadOnlyArray<string> | string;
@@ -56,11 +56,11 @@ longHandLogical.add('border-block-width');
56
56
  shorthandsOfLonghands.add('border-block-start');
57
57
  shorthandsOfLonghands.add('border-top');
58
58
  longHandLogical.add('border-block-start-color');
59
- longHandLogical.add('border-top-color');
59
+ longHandPhysical.add('border-top-color');
60
60
  longHandLogical.add('border-block-start-style');
61
- longHandLogical.add('border-top-style');
61
+ longHandPhysical.add('border-top-style');
62
62
  longHandLogical.add('border-block-start-width');
63
- longHandLogical.add('border-top-width');
63
+ longHandPhysical.add('border-top-width');
64
64
  shorthandsOfLonghands.add('border-block-end');
65
65
  shorthandsOfLonghands.add('border-bottom');
66
66
  longHandLogical.add('border-block-end-color');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/shared",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "main": "lib/index.js",
5
5
  "repository": "https://www.github.com/facebook/stylex",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "postcss-value-parser": "^4.1.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@stylexjs/scripts": "0.7.4"
16
+ "@stylexjs/scripts": "0.7.5"
17
17
  },
18
18
  "jest": {
19
19
  "snapshotFormat": {