fower-plugin-layout
Advanced tools
Comparing version 1.72.0 to 1.73.0
@@ -16,15 +16,10 @@ 'use strict'; | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
@@ -43,3 +38,2 @@ if (it) o = it; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
@@ -79,3 +73,2 @@ } | ||
*/ | ||
function toLayoutStyle(key, direction) { | ||
@@ -86,3 +79,2 @@ var style = {}; | ||
/** 根据 row 和 column 设置属性,这里比较复杂 */ | ||
if (direction.startsWith('row')) { | ||
@@ -92,3 +84,2 @@ if ([toLeft, toRight, toCenterX, toBetween, toAround, toEvenly].includes(key)) { | ||
} | ||
if ([toTop, toBottom, toCenterY].includes(key)) { | ||
@@ -101,3 +92,2 @@ styleKey = 'alignItems'; | ||
} | ||
if ([toLeft, toRight, toCenterX].includes(key)) { | ||
@@ -107,7 +97,5 @@ styleKey = 'alignItems'; | ||
} | ||
var isRowReverse = /^rowReverse$/i.test(direction); | ||
var isColumnReverse = /^columnReverse$/i.test(direction); | ||
/** 设置container样式 */ | ||
if (key === toTop) { | ||
@@ -134,4 +122,2 @@ style[styleKey] = isColumnReverse ? flexEnd : flexStart; | ||
/** TODO: 设置 self align样式 */ | ||
if ([selfTop, selfLeft].includes(key)) { | ||
@@ -146,3 +132,2 @@ style.alignSelf = flexStart; | ||
} | ||
return style; | ||
@@ -152,15 +137,11 @@ } | ||
var layoutReg = /*#__PURE__*/new RegExp("" + /*#__PURE__*/layoutKeys.join('|'), 'i'); | ||
function isFlexDirection(key) { | ||
return /^flexDirection$/.test(key); | ||
} | ||
function isDirection(key) { | ||
return /^(row|column)(Reverse)?$/i.test(key); | ||
} | ||
function isLayout(key) { | ||
return layoutReg.test(key); | ||
} | ||
function isMatch(key) { | ||
@@ -172,5 +153,3 @@ return isDirection(key) || isFlexDirection(key) || isLayout(key); | ||
isMatch: isMatch, | ||
/** For cache atom, we set id in beforeHandleAtom */ | ||
beforeHandleAtom: function beforeHandleAtom(atom) { | ||
/** For cache atom, we set id in beforeHandleAtom */beforeHandleAtom: function beforeHandleAtom(atom) { | ||
/** @example <Box column></Box> */ | ||
@@ -184,4 +163,2 @@ if (isDirection(atom.key)) { | ||
/** @example <Box flexDirection="row"></Box> */ | ||
if (isFlexDirection(atom.key)) { | ||
@@ -192,3 +169,2 @@ atom.style = { | ||
} | ||
return atom; | ||
@@ -207,7 +183,5 @@ }, | ||
var layoutAtoms = []; | ||
for (var _iterator = _createForOfIteratorHelperLoose(parser.atoms), _step; !(_step = _iterator()).done;) { | ||
var _atom = _step.value; | ||
if (!isMatch(_atom.key)) continue; | ||
if (isLayout(_atom.key)) { | ||
@@ -222,4 +196,2 @@ layoutAtoms.push(_atom); | ||
*/ | ||
if (!directionAtoms.length) { | ||
@@ -229,3 +201,2 @@ var directionRow = 'row'; | ||
var rowAtom = parser.store.atomCache.get(rowKey); | ||
if (rowAtom) { | ||
@@ -251,23 +222,17 @@ parser.addAtom(rowAtom); | ||
/** 每个 layout atom 要根据 breakpoint 生成 */ | ||
for (var _i = 0, _directionAtoms = directionAtoms; _i < _directionAtoms.length; _i++) { | ||
var directionAtom = _directionAtoms[_i]; | ||
var key = directionAtom.key, | ||
value = directionAtom.value; | ||
value = directionAtom.value; | ||
var breakpoint = directionAtom.meta.breakpoint; | ||
var direction = isDirection(key) ? key : value; | ||
for (var _iterator2 = _createForOfIteratorHelperLoose(layoutAtoms), _step2; !(_step2 = _iterator2()).done;) { | ||
var layoutAtom = _step2.value; | ||
var newAtom = new core.Atom(layoutAtom); | ||
if (breakpoint) { | ||
newAtom.meta.breakpoint = layoutAtom.meta.breakpoint || breakpoint; | ||
} | ||
newAtom.setId(); | ||
newAtom.id = direction + "-" + newAtom.id; | ||
var cachedAtom = parser.store.atomCache.get(newAtom.id); | ||
if (cachedAtom) { | ||
@@ -280,8 +245,6 @@ parser.addAtom(cachedAtom); | ||
} | ||
} // if have display style, don't create flex atom | ||
} | ||
// if have display style, don't create flex atom | ||
var findDisplay = parser.atoms.find(function (i) { | ||
var _i$style, _i$meta; | ||
return !!(i != null && (_i$style = i.style) != null && _i$style.display) && !((_i$meta = i.meta) != null && _i$meta.pseudo); | ||
@@ -292,3 +255,2 @@ }); | ||
var flexAtom = parser.store.atomCache.get(flexKey); | ||
if (flexAtom) { | ||
@@ -295,0 +257,0 @@ parser.addAtom(flexAtom); |
@@ -12,15 +12,10 @@ import { Atom } from '@fower/core'; | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
@@ -39,3 +34,2 @@ if (it) o = it; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
@@ -75,3 +69,2 @@ } | ||
*/ | ||
function toLayoutStyle(key, direction) { | ||
@@ -82,3 +75,2 @@ var style = {}; | ||
/** 根据 row 和 column 设置属性,这里比较复杂 */ | ||
if (direction.startsWith('row')) { | ||
@@ -88,3 +80,2 @@ if ([toLeft, toRight, toCenterX, toBetween, toAround, toEvenly].includes(key)) { | ||
} | ||
if ([toTop, toBottom, toCenterY].includes(key)) { | ||
@@ -97,3 +88,2 @@ styleKey = 'alignItems'; | ||
} | ||
if ([toLeft, toRight, toCenterX].includes(key)) { | ||
@@ -103,7 +93,5 @@ styleKey = 'alignItems'; | ||
} | ||
var isRowReverse = /^rowReverse$/i.test(direction); | ||
var isColumnReverse = /^columnReverse$/i.test(direction); | ||
/** 设置container样式 */ | ||
if (key === toTop) { | ||
@@ -130,4 +118,2 @@ style[styleKey] = isColumnReverse ? flexEnd : flexStart; | ||
/** TODO: 设置 self align样式 */ | ||
if ([selfTop, selfLeft].includes(key)) { | ||
@@ -142,3 +128,2 @@ style.alignSelf = flexStart; | ||
} | ||
return style; | ||
@@ -148,15 +133,11 @@ } | ||
var layoutReg = /*#__PURE__*/new RegExp("" + /*#__PURE__*/layoutKeys.join('|'), 'i'); | ||
function isFlexDirection(key) { | ||
return /^flexDirection$/.test(key); | ||
} | ||
function isDirection(key) { | ||
return /^(row|column)(Reverse)?$/i.test(key); | ||
} | ||
function isLayout(key) { | ||
return layoutReg.test(key); | ||
} | ||
function isMatch(key) { | ||
@@ -168,5 +149,3 @@ return isDirection(key) || isFlexDirection(key) || isLayout(key); | ||
isMatch: isMatch, | ||
/** For cache atom, we set id in beforeHandleAtom */ | ||
beforeHandleAtom: function beforeHandleAtom(atom) { | ||
/** For cache atom, we set id in beforeHandleAtom */beforeHandleAtom: function beforeHandleAtom(atom) { | ||
/** @example <Box column></Box> */ | ||
@@ -180,4 +159,2 @@ if (isDirection(atom.key)) { | ||
/** @example <Box flexDirection="row"></Box> */ | ||
if (isFlexDirection(atom.key)) { | ||
@@ -188,3 +165,2 @@ atom.style = { | ||
} | ||
return atom; | ||
@@ -203,7 +179,5 @@ }, | ||
var layoutAtoms = []; | ||
for (var _iterator = _createForOfIteratorHelperLoose(parser.atoms), _step; !(_step = _iterator()).done;) { | ||
var _atom = _step.value; | ||
if (!isMatch(_atom.key)) continue; | ||
if (isLayout(_atom.key)) { | ||
@@ -218,4 +192,2 @@ layoutAtoms.push(_atom); | ||
*/ | ||
if (!directionAtoms.length) { | ||
@@ -225,3 +197,2 @@ var directionRow = 'row'; | ||
var rowAtom = parser.store.atomCache.get(rowKey); | ||
if (rowAtom) { | ||
@@ -247,23 +218,17 @@ parser.addAtom(rowAtom); | ||
/** 每个 layout atom 要根据 breakpoint 生成 */ | ||
for (var _i = 0, _directionAtoms = directionAtoms; _i < _directionAtoms.length; _i++) { | ||
var directionAtom = _directionAtoms[_i]; | ||
var key = directionAtom.key, | ||
value = directionAtom.value; | ||
value = directionAtom.value; | ||
var breakpoint = directionAtom.meta.breakpoint; | ||
var direction = isDirection(key) ? key : value; | ||
for (var _iterator2 = _createForOfIteratorHelperLoose(layoutAtoms), _step2; !(_step2 = _iterator2()).done;) { | ||
var layoutAtom = _step2.value; | ||
var newAtom = new Atom(layoutAtom); | ||
if (breakpoint) { | ||
newAtom.meta.breakpoint = layoutAtom.meta.breakpoint || breakpoint; | ||
} | ||
newAtom.setId(); | ||
newAtom.id = direction + "-" + newAtom.id; | ||
var cachedAtom = parser.store.atomCache.get(newAtom.id); | ||
if (cachedAtom) { | ||
@@ -276,8 +241,6 @@ parser.addAtom(cachedAtom); | ||
} | ||
} // if have display style, don't create flex atom | ||
} | ||
// if have display style, don't create flex atom | ||
var findDisplay = parser.atoms.find(function (i) { | ||
var _i$style, _i$meta; | ||
return !!(i != null && (_i$style = i.style) != null && _i$style.display) && !((_i$meta = i.meta) != null && _i$meta.pseudo); | ||
@@ -288,3 +251,2 @@ }); | ||
var flexAtom = parser.store.atomCache.get(flexKey); | ||
if (flexAtom) { | ||
@@ -291,0 +253,0 @@ parser.addAtom(flexAtom); |
{ | ||
"name": "fower-plugin-layout", | ||
"version": "1.72.0", | ||
"version": "1.73.0", | ||
"license": "MIT", | ||
@@ -26,7 +26,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@fower/atomic-props": "^1.72.0", | ||
"@fower/core": "^1.72.0", | ||
"@fower/utils": "^1.72.0" | ||
"@fower/atomic-props": "^1.73.0", | ||
"@fower/core": "^1.73.0", | ||
"@fower/utils": "^1.73.0" | ||
}, | ||
"gitHead": "c84a9d5fe0b3a55ab835f3a7a77c6654d25ef6ef" | ||
"gitHead": "cfc4d4e79e4ed784b2a3442fc8c0b43061a23a8d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
70186
Updated@fower/atomic-props@^1.73.0
Updated@fower/core@^1.73.0
Updated@fower/utils@^1.73.0