0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _postcss = require("postcss");
var _postcss2 = _interopRequireDefault(_postcss);
var _postcssValueParser = require("postcss-value-parser");
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
var _cssnanoUtilGetMatch = require("cssnano-util-get-match");
var _cssnanoUtilGetMatch2 = _interopRequireDefault(_cssnanoUtilGetMatch);
var _map = require("./lib/map");
var _map2 = _interopRequireDefault(_map);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default);
function evenValues(list, index) {
return index % 2 === 0;
}
exports.default = _postcss2.default.plugin("postcss-normalize-display-values", () => {
return css => {
const cache = {};
css.walkDecls(/display/i, decl => {
const value = decl.value;
if (cache[value]) {
decl.value = cache[value];
return;
}
const { nodes } = (0, _postcssValueParser2.default)(value);
if (nodes.length === 1) {
cache[value] = value;
return;
}
const match = getMatch(nodes.filter(evenValues).map(n => n.value.toLowerCase()));
if (!match) {
cache[value] = value;
return;
}
const result = match;
decl.value = result;
cache[value] = result;
});
};
});
module.exports = exports["default"];

View file

@ -0,0 +1,32 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
const block = 'block';
const flex = 'flex';
const flow = 'flow';
const flowRoot = 'flow-root';
const grid = 'grid';
const inline = 'inline';
const inlineBlock = 'inline-block';
const inlineFlex = 'inline-flex';
const inlineGrid = 'inline-grid';
const inlineTable = 'inline-table';
const listItem = 'list-item';
const ruby = 'ruby';
const rubyBase = 'ruby-base';
const rubyText = 'ruby-text';
const runIn = 'run-in';
const table = 'table';
const tableCell = 'table-cell';
const tableCaption = 'table-caption';
/**
* Specification: https://drafts.csswg.org/css-display/#the-display-properties
*/
exports.default = [[block, [block, flow]], [flowRoot, [block, flowRoot]], [inline, [inline, flow]], [inlineBlock, [inline, flowRoot]], [runIn, [runIn, flow]], [listItem, [listItem, block, flow]], [inline + ' ' + listItem, [inline, flow, listItem]], [flex, [block, flex]], [inlineFlex, [inline, flex]], [grid, [block, grid]], [inlineGrid, [inline, grid]], [ruby, [inline, ruby]],
// `block ruby` is same
[table, [block, table]], [inlineTable, [inline, table]], [tableCell, [tableCell, flow]], [tableCaption, [tableCaption, flow]], [rubyBase, [rubyBase, flow]], [rubyText, [rubyText, flow]]];
module.exports = exports['default'];