postcss-ordered-values
Advanced tools
Comparing version 4.1.2 to 5.0.0-rc.0
@@ -1,91 +0,131 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcss = require('postcss'); | ||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _animation = _interopRequireDefault(require("./rules/animation")); | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _border = _interopRequireDefault(require("./rules/border")); | ||
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); | ||
var _boxShadow = _interopRequireDefault(require("./rules/boxShadow")); | ||
var _animation = require('./rules/animation'); | ||
var _flexFlow = _interopRequireDefault(require("./rules/flexFlow")); | ||
var _animation2 = _interopRequireDefault(_animation); | ||
var _transition = _interopRequireDefault(require("./rules/transition")); | ||
var _border = require('./rules/border'); | ||
var _grid = require("./rules/grid"); | ||
var _border2 = _interopRequireDefault(_border); | ||
var _listStyle = _interopRequireDefault(require("./rules/listStyle")); | ||
var _boxShadow = require('./rules/boxShadow'); | ||
var _columns = require("./rules/columns"); | ||
var _boxShadow2 = _interopRequireDefault(_boxShadow); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _flexFlow = require('./rules/flexFlow'); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var _flexFlow2 = _interopRequireDefault(_flexFlow); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var _transition = require('./rules/transition'); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _transition2 = _interopRequireDefault(_transition); | ||
const borderRules = { | ||
border: _border.default, | ||
'border-block': _border.default, | ||
'border-inline': _border.default, | ||
'border-block-end': _border.default, | ||
'border-block-start': _border.default, | ||
'border-inline-end': _border.default, | ||
'border-inline-start': _border.default, | ||
'border-top': _border.default, | ||
'border-right': _border.default, | ||
'border-bottom': _border.default, | ||
'border-left': _border.default | ||
}; | ||
const grid = { | ||
'grid-auto-flow': _grid.normalizeGridAutoFlow, | ||
'grid-column-gap': _grid.normalizeGridColumnRowGap, | ||
// normal | <length-percentage> | ||
'grid-row-gap': _grid.normalizeGridColumnRowGap, | ||
// normal | <length-percentage> | ||
'grid-column': _grid.normalizeGridColumnRow, | ||
// <grid-line>+ | ||
'grid-row': _grid.normalizeGridColumnRow, | ||
// <grid-line>+ | ||
'grid-row-start': _grid.normalizeGridColumnRow, | ||
// <grid-line> | ||
'grid-row-end': _grid.normalizeGridColumnRow, | ||
// <grid-line> | ||
'grid-column-start': _grid.normalizeGridColumnRow, | ||
// <grid-line> | ||
'grid-column-end': _grid.normalizeGridColumnRow // <grid-line> | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint-disable quote-props */ | ||
const rules = { | ||
'animation': _animation2.default, | ||
'-webkit-animation': _animation2.default, | ||
'border': _border2.default, | ||
'border-top': _border2.default, | ||
'border-right': _border2.default, | ||
'border-bottom': _border2.default, | ||
'border-left': _border2.default, | ||
'outline': _border2.default, | ||
'box-shadow': _boxShadow2.default, | ||
'flex-flow': _flexFlow2.default, | ||
'transition': _transition2.default, | ||
'-webkit-transition': _transition2.default | ||
}; | ||
const columnRules = { | ||
'column-rule': _columns.columnsRule, | ||
columns: _columns.column | ||
}; | ||
/* eslint-enable */ | ||
const rules = _objectSpread(_objectSpread(_objectSpread({ | ||
animation: _animation.default, | ||
outline: _border.default, | ||
'box-shadow': _boxShadow.default, | ||
'flex-flow': _flexFlow.default, | ||
'list-style': _listStyle.default, | ||
transition: _transition.default | ||
}, borderRules), grid), columnRules); | ||
// rules | ||
function shouldAbort(parsed) { | ||
let abort = false; | ||
function vendorUnprefixed(prop) { | ||
return prop.replace(/^-\w+-/, ''); | ||
} | ||
parsed.walk(({ type, value }) => { | ||
if (type === 'comment' || type === 'function' && value.toLowerCase() === 'var' || type === 'word' && ~value.indexOf(`___CSS_LOADER_IMPORT___`)) { | ||
abort = true; | ||
function isVariableFunctionNode(node) { | ||
if (node.type !== 'function') { | ||
return false; | ||
} | ||
return false; | ||
} | ||
}); | ||
return ['var', 'env'].includes(node.value.toLowerCase()); | ||
} | ||
return abort; | ||
function shouldAbort(parsed) { | ||
let abort = false; | ||
parsed.walk(node => { | ||
if (node.type === 'comment' || isVariableFunctionNode(node) || node.type === 'word' && ~node.value.indexOf(`___CSS_LOADER_IMPORT___`)) { | ||
abort = true; | ||
return false; | ||
} | ||
}); | ||
return abort; | ||
} | ||
function getValue(decl) { | ||
let { value, raws } = decl; | ||
let { | ||
value, | ||
raws | ||
} = decl; | ||
if (raws && raws.value && raws.value.raw) { | ||
value = raws.value.raw; | ||
} | ||
if (raws && raws.value && raws.value.raw) { | ||
value = raws.value.raw; | ||
} | ||
return value; | ||
return value; | ||
} | ||
exports.default = _postcss2.default.plugin('postcss-ordered-values', () => { | ||
return css => { | ||
const cache = {}; | ||
function pluginCreator() { | ||
return { | ||
postcssPlugin: 'postcss-ordered-values', | ||
css.walkDecls(decl => { | ||
prepare() { | ||
const cache = {}; | ||
return { | ||
OnceExit(css) { | ||
css.walkDecls(decl => { | ||
const lowerCasedProp = decl.prop.toLowerCase(); | ||
const processor = rules[lowerCasedProp]; | ||
const normalizedProp = vendorUnprefixed(lowerCasedProp); | ||
const processor = rules[normalizedProp]; | ||
if (!processor) { | ||
return; | ||
return; | ||
} | ||
@@ -96,22 +136,28 @@ | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
return; | ||
decl.value = cache[value]; | ||
return; | ||
} | ||
const parsed = (0, _postcssValueParser2.default)(value); | ||
const parsed = (0, _postcssValueParser.default)(value); | ||
if (parsed.nodes.length < 2 || shouldAbort(parsed)) { | ||
cache[value] = value; | ||
return; | ||
cache[value] = value; | ||
return; | ||
} | ||
const result = processor(parsed); | ||
decl.value = result.toString(); | ||
cache[value] = result.toString(); | ||
}); | ||
} | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
}; | ||
}); | ||
module.exports = exports['default']; | ||
}; | ||
} | ||
}; | ||
} | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,10 +0,15 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = addSpace; | ||
function addSpace() { | ||
return { type: 'space', value: ' ' }; | ||
return { | ||
type: 'space', | ||
value: ' ' | ||
}; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,29 +0,31 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = getValue; | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _postcssValueParser = require("postcss-value-parser"); | ||
function getValue(values) { | ||
return (0, _postcssValueParser.stringify)({ | ||
nodes: values.reduce((nodes, arg, index) => { | ||
arg.forEach((val, idx) => { | ||
if (idx === arg.length - 1 && index === values.length - 1 && val.type === 'space') { | ||
return; | ||
} | ||
nodes.push(val); | ||
}); | ||
return (0, _postcssValueParser.stringify)({ | ||
nodes: values.reduce((nodes, arg, index) => { | ||
arg.forEach((val, idx) => { | ||
if (idx === arg.length - 1 && index === values.length - 1 && val.type === 'space') { | ||
return; | ||
} | ||
if (index !== values.length - 1) { | ||
nodes[nodes.length - 1].type = 'div'; | ||
nodes[nodes.length - 1].value = ','; | ||
} | ||
nodes.push(val); | ||
}); | ||
return nodes; | ||
}, []) | ||
}); | ||
if (index !== values.length - 1) { | ||
nodes[nodes.length - 1].type = 'div'; | ||
nodes[nodes.length - 1].value = ','; | ||
} | ||
return nodes; | ||
}, []) | ||
}); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,98 +0,112 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = normalizeAnimation; | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _postcssValueParser = require("postcss-value-parser"); | ||
var _cssnanoUtilGetArguments = require('cssnano-util-get-arguments'); | ||
var _cssnanoUtils = require("cssnano-utils"); | ||
var _cssnanoUtilGetArguments2 = _interopRequireDefault(_cssnanoUtilGetArguments); | ||
var _addSpace = _interopRequireDefault(require("../lib/addSpace")); | ||
var _addSpace = require('../lib/addSpace'); | ||
var _getValue = _interopRequireDefault(require("../lib/getValue")); | ||
var _addSpace2 = _interopRequireDefault(_addSpace); | ||
var _getValue = require('../lib/getValue'); | ||
var _getValue2 = _interopRequireDefault(_getValue); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// animation: [ none | <keyframes-name> ] || <time> || <single-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state> | ||
const isTimingFunction = (value, type) => { | ||
const functions = ['steps', 'cubic-bezier', 'frames']; | ||
const keywords = ['ease', 'ease-in', 'ease-in-out', 'ease-out', 'linear', 'step-end', 'step-start']; | ||
return type === 'function' && functions.includes(value) || keywords.includes(value); | ||
const functions = ['steps', 'cubic-bezier', 'frames']; | ||
const keywords = ['ease', 'ease-in', 'ease-in-out', 'ease-out', 'linear', 'step-end', 'step-start']; | ||
return type === 'function' && functions.includes(value) || keywords.includes(value); | ||
}; | ||
const isDirection = value => { | ||
return ['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(value); | ||
return ['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(value); | ||
}; | ||
const isFillMode = value => { | ||
return ['none', 'forwards', 'backwards', 'both'].includes(value); | ||
return ['none', 'forwards', 'backwards', 'both'].includes(value); | ||
}; | ||
const isPlayState = value => { | ||
return ['running', 'paused'].includes(value); | ||
return ['running', 'paused'].includes(value); | ||
}; | ||
const isTime = value => { | ||
const quantity = (0, _postcssValueParser.unit)(value); | ||
return quantity && ['ms', 's'].includes(quantity.unit); | ||
const quantity = (0, _postcssValueParser.unit)(value); | ||
return quantity && ['ms', 's'].includes(quantity.unit); | ||
}; | ||
const isIterationCount = value => { | ||
const quantity = (0, _postcssValueParser.unit)(value); | ||
return value === 'infinite' || quantity && !quantity.unit; | ||
const quantity = (0, _postcssValueParser.unit)(value); | ||
return value === 'infinite' || quantity && !quantity.unit; | ||
}; | ||
function normalizeAnimation(parsed) { | ||
const args = (0, _cssnanoUtilGetArguments2.default)(parsed); | ||
const args = (0, _cssnanoUtils.getArguments)(parsed); | ||
const values = args.reduce((list, arg) => { | ||
const state = { | ||
name: [], | ||
duration: [], | ||
timingFunction: [], | ||
delay: [], | ||
iterationCount: [], | ||
direction: [], | ||
fillMode: [], | ||
playState: [] | ||
}; | ||
const stateConditions = [{ | ||
property: 'duration', | ||
delegate: isTime | ||
}, { | ||
property: 'timingFunction', | ||
delegate: isTimingFunction | ||
}, { | ||
property: 'delay', | ||
delegate: isTime | ||
}, { | ||
property: 'iterationCount', | ||
delegate: isIterationCount | ||
}, { | ||
property: 'direction', | ||
delegate: isDirection | ||
}, { | ||
property: 'fillMode', | ||
delegate: isFillMode | ||
}, { | ||
property: 'playState', | ||
delegate: isPlayState | ||
}]; | ||
arg.forEach(node => { | ||
let { | ||
type, | ||
value | ||
} = node; | ||
const values = args.reduce((list, arg) => { | ||
const state = { | ||
name: [], | ||
duration: [], | ||
timingFunction: [], | ||
delay: [], | ||
iterationCount: [], | ||
direction: [], | ||
fillMode: [], | ||
playState: [] | ||
}; | ||
const stateConditions = [{ property: 'duration', delegate: isTime }, { property: 'timingFunction', delegate: isTimingFunction }, { property: 'delay', delegate: isTime }, { property: 'iterationCount', delegate: isIterationCount }, { property: 'direction', delegate: isDirection }, { property: 'fillMode', delegate: isFillMode }, { property: 'playState', delegate: isPlayState }]; | ||
if (type === 'space') { | ||
return; | ||
} | ||
arg.forEach(node => { | ||
let { type, value } = node; | ||
value = value.toLowerCase(); | ||
const hasMatch = stateConditions.some(({ | ||
property, | ||
delegate | ||
}) => { | ||
if (delegate(value, type) && !state[property].length) { | ||
state[property] = [node, (0, _addSpace.default)()]; | ||
return true; | ||
} | ||
}); | ||
if (type === 'space') { | ||
return; | ||
} | ||
if (!hasMatch) { | ||
state.name = [...state.name, node, (0, _addSpace.default)()]; | ||
} | ||
}); | ||
return [...list, [...state.name, ...state.duration, ...state.timingFunction, ...state.delay, ...state.iterationCount, ...state.direction, ...state.fillMode, ...state.playState]]; | ||
}, []); | ||
return (0, _getValue.default)(values); | ||
} | ||
value = value.toLowerCase(); | ||
const hasMatch = stateConditions.some(({ property, delegate }) => { | ||
if (delegate(value, type) && !state[property].length) { | ||
state[property] = [node, (0, _addSpace2.default)()]; | ||
return true; | ||
} | ||
}); | ||
if (!hasMatch) { | ||
state.name = [...state.name, node, (0, _addSpace2.default)()]; | ||
} | ||
}); | ||
return [...list, [...state.name, ...state.duration, ...state.timingFunction, ...state.delay, ...state.iterationCount, ...state.direction, ...state.fillMode, ...state.playState]]; | ||
}, []); | ||
return (0, _getValue2.default)(values); | ||
}; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,15 +0,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = normalizeBorder; | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _postcssValueParser = require("postcss-value-parser"); | ||
// border: <line-width> || <line-style> || <color> | ||
// outline: <outline-color> || <outline-style> || <outline-width> | ||
const borderWidths = ['thin', 'medium', 'thick']; | ||
const borderStyles = ['none', 'auto', // only in outline-style | ||
@@ -19,34 +17,46 @@ 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']; | ||
function normalizeBorder(border) { | ||
const order = { width: '', style: '', color: '' }; | ||
const order = { | ||
width: '', | ||
style: '', | ||
color: '' | ||
}; | ||
border.walk(node => { | ||
const { | ||
type, | ||
value | ||
} = node; | ||
border.walk(node => { | ||
const { type, value } = node; | ||
if (type === 'word') { | ||
if (~borderStyles.indexOf(value.toLowerCase())) { | ||
order.style = value; | ||
return false; | ||
} | ||
if (~borderWidths.indexOf(value.toLowerCase()) || (0, _postcssValueParser.unit)(value.toLowerCase())) { | ||
if (order.width !== '') { | ||
order.width = `${order.width} ${value}`; | ||
return false; | ||
} | ||
order.width = value; | ||
return false; | ||
} | ||
order.color = value; | ||
return false; | ||
if (type === 'word') { | ||
if (~borderStyles.indexOf(value.toLowerCase())) { | ||
order.style = value; | ||
return false; | ||
} | ||
if (~borderWidths.indexOf(value.toLowerCase()) || (0, _postcssValueParser.unit)(value.toLowerCase())) { | ||
if (order.width !== '') { | ||
order.width = `${order.width} ${value}`; | ||
return false; | ||
} | ||
if (type === 'function') { | ||
if (value.toLowerCase() === 'calc') { | ||
order.width = (0, _postcssValueParser.stringify)(node); | ||
} else { | ||
order.color = (0, _postcssValueParser.stringify)(node); | ||
} | ||
return false; | ||
} | ||
}); | ||
return `${order.width} ${order.style} ${order.color}`.trim(); | ||
}; | ||
module.exports = exports['default']; | ||
order.width = value; | ||
return false; | ||
} | ||
order.color = value; | ||
return false; | ||
} | ||
if (type === 'function') { | ||
if (value.toLowerCase() === 'calc') { | ||
order.width = (0, _postcssValueParser.stringify)(node); | ||
} else { | ||
order.color = (0, _postcssValueParser.stringify)(node); | ||
} | ||
return false; | ||
} | ||
}); | ||
return `${order.width} ${order.style} ${order.color}`.trim(); | ||
} | ||
module.exports = exports.default; |
@@ -1,67 +0,61 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = normalizeBoxShadow; | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _postcssValueParser = require("postcss-value-parser"); | ||
var _cssnanoUtilGetArguments = require('cssnano-util-get-arguments'); | ||
var _cssnanoUtils = require("cssnano-utils"); | ||
var _cssnanoUtilGetArguments2 = _interopRequireDefault(_cssnanoUtilGetArguments); | ||
var _addSpace = _interopRequireDefault(require("../lib/addSpace")); | ||
var _addSpace = require('../lib/addSpace'); | ||
var _getValue = _interopRequireDefault(require("../lib/getValue")); | ||
var _addSpace2 = _interopRequireDefault(_addSpace); | ||
var _getValue = require('../lib/getValue'); | ||
var _getValue2 = _interopRequireDefault(_getValue); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// box-shadow: inset? && <length>{2,4} && <color>? | ||
function normalizeBoxShadow(parsed) { | ||
let args = (0, _cssnanoUtilGetArguments2.default)(parsed); | ||
let abort = false; | ||
let args = (0, _cssnanoUtils.getArguments)(parsed); | ||
let abort = false; | ||
let values = args.reduce((list, arg) => { | ||
let val = []; | ||
let state = { | ||
inset: [], | ||
color: [] | ||
}; | ||
arg.forEach(node => { | ||
const { | ||
type, | ||
value | ||
} = node; | ||
let values = args.reduce((list, arg) => { | ||
let val = []; | ||
let state = { | ||
inset: [], | ||
color: [] | ||
}; | ||
if (type === 'function' && ~value.toLowerCase().indexOf('calc')) { | ||
abort = true; | ||
return; | ||
} | ||
arg.forEach(node => { | ||
const { type, value } = node; | ||
if (type === 'space') { | ||
return; | ||
} | ||
if (type === 'function' && ~value.toLowerCase().indexOf('calc')) { | ||
abort = true; | ||
return; | ||
} | ||
if ((0, _postcssValueParser.unit)(value)) { | ||
val = [...val, node, (0, _addSpace.default)()]; | ||
} else if (value.toLowerCase() === 'inset') { | ||
state.inset = [...state.inset, node, (0, _addSpace.default)()]; | ||
} else { | ||
state.color = [...state.color, node, (0, _addSpace.default)()]; | ||
} | ||
}); | ||
return [...list, [...state.inset, ...val, ...state.color]]; | ||
}, []); | ||
if (type === 'space') { | ||
return; | ||
} | ||
if (abort) { | ||
return parsed.toString(); | ||
} | ||
if ((0, _postcssValueParser.unit)(value)) { | ||
val = [...val, node, (0, _addSpace2.default)()]; | ||
} else if (value.toLowerCase() === 'inset') { | ||
state.inset = [...state.inset, node, (0, _addSpace2.default)()]; | ||
} else { | ||
state.color = [...state.color, node, (0, _addSpace2.default)()]; | ||
} | ||
}); | ||
return (0, _getValue.default)(values); | ||
} | ||
return [...list, [...state.inset, ...val, ...state.color]]; | ||
}, []); | ||
if (abort) { | ||
return parsed.toString(); | ||
} | ||
return (0, _getValue2.default)(values); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,34 +0,32 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = normalizeFlexFlow; | ||
// flex-flow: <flex-direction> || <flex-wrap> | ||
const flexDirection = ['row', 'row-reverse', 'column', 'column-reverse']; | ||
const flexWrap = ['nowrap', 'wrap', 'wrap-reverse']; | ||
function normalizeFlexFlow(flexFlow) { | ||
let order = { | ||
direction: '', | ||
wrap: '' | ||
}; | ||
let order = { | ||
direction: '', | ||
wrap: '' | ||
}; | ||
flexFlow.walk(({ | ||
value | ||
}) => { | ||
if (~flexDirection.indexOf(value.toLowerCase())) { | ||
order.direction = value; | ||
return; | ||
} | ||
flexFlow.walk(({ value }) => { | ||
if (~flexDirection.indexOf(value.toLowerCase())) { | ||
order.direction = value; | ||
return; | ||
} | ||
if (~flexWrap.indexOf(value.toLowerCase())) { | ||
order.wrap = value; | ||
return; | ||
} | ||
}); | ||
return `${order.direction} ${order.wrap}`.trim(); | ||
} | ||
if (~flexWrap.indexOf(value.toLowerCase())) { | ||
order.wrap = value; | ||
return; | ||
} | ||
}); | ||
return `${order.direction} ${order.wrap}`.trim(); | ||
}; | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
@@ -1,66 +0,59 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = normalizeTransition; | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _postcssValueParser = require("postcss-value-parser"); | ||
var _cssnanoUtilGetArguments = require('cssnano-util-get-arguments'); | ||
var _cssnanoUtils = require("cssnano-utils"); | ||
var _cssnanoUtilGetArguments2 = _interopRequireDefault(_cssnanoUtilGetArguments); | ||
var _addSpace = _interopRequireDefault(require("../lib/addSpace")); | ||
var _addSpace = require('../lib/addSpace'); | ||
var _getValue = _interopRequireDefault(require("../lib/getValue")); | ||
var _addSpace2 = _interopRequireDefault(_addSpace); | ||
var _getValue = require('../lib/getValue'); | ||
var _getValue2 = _interopRequireDefault(_getValue); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// transition: [ none | <single-transition-property> ] || <time> || <single-transition-timing-function> || <time> | ||
const timingFunctions = ['ease', 'linear', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end']; | ||
function normalizeTransition(parsed) { | ||
let args = (0, _cssnanoUtilGetArguments2.default)(parsed); | ||
let args = (0, _cssnanoUtils.getArguments)(parsed); | ||
let values = args.reduce((list, arg) => { | ||
let state = { | ||
timingFunction: [], | ||
property: [], | ||
time1: [], | ||
time2: [] | ||
}; | ||
arg.forEach(node => { | ||
const { | ||
type, | ||
value | ||
} = node; | ||
let values = args.reduce((list, arg) => { | ||
let state = { | ||
timingFunction: [], | ||
property: [], | ||
time1: [], | ||
time2: [] | ||
}; | ||
if (type === 'space') { | ||
return; | ||
} | ||
arg.forEach(node => { | ||
const { type, value } = node; | ||
if (type === 'function' && ~['steps', 'cubic-bezier'].indexOf(value.toLowerCase())) { | ||
state.timingFunction = [...state.timingFunction, node, (0, _addSpace.default)()]; | ||
} else if ((0, _postcssValueParser.unit)(value)) { | ||
if (!state.time1.length) { | ||
state.time1 = [...state.time1, node, (0, _addSpace.default)()]; | ||
} else { | ||
state.time2 = [...state.time2, node, (0, _addSpace.default)()]; | ||
} | ||
} else if (~timingFunctions.indexOf(value.toLowerCase())) { | ||
state.timingFunction = [...state.timingFunction, node, (0, _addSpace.default)()]; | ||
} else { | ||
state.property = [...state.property, node, (0, _addSpace.default)()]; | ||
} | ||
}); | ||
return [...list, [...state.property, ...state.time1, ...state.timingFunction, ...state.time2]]; | ||
}, []); | ||
return (0, _getValue.default)(values); | ||
} | ||
if (type === 'space') { | ||
return; | ||
} | ||
if (type === 'function' && ~['steps', 'cubic-bezier'].indexOf(value.toLowerCase())) { | ||
state.timingFunction = [...state.timingFunction, node, (0, _addSpace2.default)()]; | ||
} else if ((0, _postcssValueParser.unit)(value)) { | ||
if (!state.time1.length) { | ||
state.time1 = [...state.time1, node, (0, _addSpace2.default)()]; | ||
} else { | ||
state.time2 = [...state.time2, node, (0, _addSpace2.default)()]; | ||
} | ||
} else if (~timingFunctions.indexOf(value.toLowerCase())) { | ||
state.timingFunction = [...state.timingFunction, node, (0, _addSpace2.default)()]; | ||
} else { | ||
state.property = [...state.property, node, (0, _addSpace2.default)()]; | ||
} | ||
}); | ||
return [...list, [...state.property, ...state.time1, ...state.timingFunction, ...state.time2]]; | ||
}, []); | ||
return (0, _getValue2.default)(values); | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
{ | ||
"name": "postcss-ordered-values", | ||
"version": "4.1.2", | ||
"version": "5.0.0-rc.0", | ||
"description": "Ensure values are ordered consistently in your CSS.", | ||
@@ -11,3 +11,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/" | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\" && node script/buildListStyleType.js", | ||
"prepublish": "yarn build" | ||
}, | ||
@@ -20,6 +22,2 @@ "keywords": [ | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^5.0.0" | ||
}, | ||
"homepage": "https://github.com/cssnano/cssnano", | ||
@@ -33,5 +31,4 @@ "author": { | ||
"dependencies": { | ||
"cssnano-util-get-arguments": "^4.0.0", | ||
"postcss": "^7.0.0", | ||
"postcss-value-parser": "^3.0.0" | ||
"cssnano-utils": "^2.0.0-rc.0", | ||
"postcss-value-parser": "^4.1.0" | ||
}, | ||
@@ -42,4 +39,12 @@ "bugs": { | ||
"engines": { | ||
"node": ">=6.9.0" | ||
} | ||
"node": "^10 || ^12 || >=14.0" | ||
}, | ||
"devDependencies": { | ||
"node-fetch": "^2.6.0", | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29557
17
702
1
2
+ Addedcssnano-utils@^2.0.0-rc.0
+ Addedcssnano-utils@2.0.1(transitive)
+ Addednanoid@3.3.7(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedpostcss-value-parser@4.2.0(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedcssnano-util-get-arguments@^4.0.0
- Removedpostcss@^7.0.0
- Removedcssnano-util-get-arguments@4.0.0(transitive)
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedpostcss-value-parser@3.3.1(transitive)
- Removedsource-map@0.6.1(transitive)
Updatedpostcss-value-parser@^4.1.0