postcss-calc 6.0.1 → 10.1.1

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,25 @@
1
+ export = pluginCreator;
2
+ /**
3
+ * @typedef {{precision?: number | false,
4
+ * preserve?: boolean,
5
+ * warnWhenCannotResolve?: boolean,
6
+ * mediaQueries?: boolean,
7
+ * selectors?: boolean}} PostCssCalcOptions
8
+ */
9
+ /**
10
+ * @type {import('postcss').PluginCreator<PostCssCalcOptions>}
11
+ * @param {PostCssCalcOptions} opts
12
+ * @return {import('postcss').Plugin}
13
+ */
14
+ declare function pluginCreator(opts: PostCssCalcOptions): import("postcss").Plugin;
15
+ declare namespace pluginCreator {
16
+ export { postcss, PostCssCalcOptions };
17
+ }
18
+ declare var postcss: true;
19
+ type PostCssCalcOptions = {
20
+ precision?: number | false;
21
+ preserve?: boolean;
22
+ warnWhenCannotResolve?: boolean;
23
+ mediaQueries?: boolean;
24
+ selectors?: boolean;
25
+ };
@@ -0,0 +1,8 @@
1
+ export = convertUnit;
2
+ /**
3
+ * @param {number} value
4
+ * @param {string} sourceUnit
5
+ * @param {string} targetUnit
6
+ * @param {number|false} precision
7
+ */
8
+ declare function convertUnit(value: number, sourceUnit: string, targetUnit: string, precision: number | false): number;
@@ -0,0 +1,14 @@
1
+ export = reduce;
2
+ /**
3
+ * @param {import('../parser').CalcNode} node
4
+ * @param {number} precision
5
+ * @return {import('../parser').CalcNode}
6
+ */
7
+ declare function reduce(node: import("../parser").CalcNode, precision: number): import("../parser").CalcNode;
8
+ declare namespace reduce {
9
+ export { Collectible };
10
+ }
11
+ type Collectible = {
12
+ preOperator: "+" | "-";
13
+ node: import("../parser").CalcNode;
14
+ };
@@ -0,0 +1,5 @@
1
+ declare function _exports(calc: string, node: import("../parser").CalcNode, originalValue: string, options: {
2
+ precision: number | false;
3
+ warnWhenCannotResolve: boolean;
4
+ }, result: import("postcss").Result, item: import("postcss").ChildNode): string;
5
+ export = _exports;
@@ -0,0 +1,6 @@
1
+ declare function _exports(node: any, property: "value" | "params" | "selector", options: {
2
+ precision: number;
3
+ preserve: boolean;
4
+ warnWhenCannotResolve: boolean;
5
+ }, result: import("postcss").Result): void;
6
+ export = _exports;
package/CHANGELOG.md DELETED
@@ -1,72 +0,0 @@
1
- # 6.0.1 - 2017-10-10
2
-
3
- - Fixed: throwing error for attribute selectors without a value
4
-
5
- # 6.0.0 - 2017-05-08
6
-
7
- - Breaking: Updated PostCSS from v5.x to v6.x, and reduce-css-calc from v1.x
8
- to v2.x (thanks to @andyjansson).
9
-
10
- # 5.3.1 - 2016-08-22
11
-
12
- - Fixed: avoid security issue related to ``reduce-css-calc@< 1.2.4``.
13
-
14
- # 5.3.0 - 2016-07-11
15
-
16
- - Added: support for selector transformation via `selectors` option.
17
- ([#29](https://github.com/postcss/postcss-calc/pull/29) - @uniquegestaltung)
18
-
19
- # 5.2.1 - 2016-04-10
20
-
21
- - Fixed: support for multiline value
22
- ([#27](https://github.com/postcss/postcss-calc/pull/27))

23
-
24
- # 5.2.0 - 2016-01-08
25
-
26
- - Added: "mediaQueries" option for `@media` support
27
- ([#22](https://github.com/postcss/postcss-calc/pull/22))
28
-
29
- # 5.1.0 - 2016-01-07
30
-
31
- - Added: "warnWhenCannotResolve" option to warn when calc() are not reduced to a single value
32
- ([#20](https://github.com/postcss/postcss-calc/pull/20))
33
-
34
- # 5.0.0 - 2015-08-25
35
-
36
- - Removed: compatibility with postcss v4.x
37
- - Added: compatibility with postcss v5.x
38
-
39
- # 4.1.0 - 2015-04-09
40
-
41
- - Added: compatibility with postcss v4.1.x ([#12](https://github.com/postcss/postcss-calc/pull/12))
42
-
43
- # 4.0.1 - 2015-04-09
44
-
45
- - Fixed: `preserve` option does not create duplicated values ([#7](https://github.com/postcss/postcss-calc/issues/7))
46
-
47
- # 4.0.0 - 2015-01-26
48
-
49
- - Added: compatibility with postcss v4.x
50
- - Changed: partial compatiblity with postcss v3.x (stack traces have lost filename)
51
-
52
- # 3.0.0 - 2014-11-24
53
-
54
- - Added: GNU like exceptions ([#4](https://github.com/postcss/postcss-calc/issues/4))
55
- - Added: `precision` option ([#5](https://github.com/postcss/postcss-calc/issues/5))
56
- - Added: `preserve` option ([#6](https://github.com/postcss/postcss-calc/issues/6))
57
-
58
- # 2.1.0 - 2014-10-15
59
-
60
- - Added: source of the error (gnu like message) (fix [#3](https://github.com/postcss/postcss-calc/issues/3))
61
-
62
- # 2.0.1 - 2014-08-10
63
-
64
- - Fixed: correctly ignore unrecognized values (fix [#2](https://github.com/postcss/postcss-calc/issues/2))
65
-
66
- # 2.0.0 - 2014-08-06
67
-
68
- - Changed: Plugin now return a function to have a consistent api. ([ref 1](https://github.com/ianstormtaylor/rework-color-function/issues/6), [ref 2](https://twitter.com/jongleberry/status/496552790416576513))
69
-
70
- # 1.0.0 - 2014-08-04
71
-
72
- ✨ First release based on [rework-calc](https://github.com/reworkcss/rework-calc) v1.1.0 (code mainly exported to [`reduce-css-calc`](https://github.com/MoOx/reduce-css-calc))
package/dist/index.js DELETED
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _postcss = require('postcss');
8
-
9
- var _transform = require('./lib/transform');
10
-
11
- var _transform2 = _interopRequireDefault(_transform);
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- exports.default = (0, _postcss.plugin)('postcss-calc', function (opts) {
16
- var options = Object.assign({
17
- precision: 5,
18
- preserve: false,
19
- warnWhenCannotResolve: false,
20
- mediaQueries: false,
21
- selectors: false
22
- }, opts);
23
-
24
- return function (css, result) {
25
- css.walk(function (node) {
26
- var type = node.type;
27
-
28
- if (type === 'decl') (0, _transform2.default)(node, "value", options, result);
29
- if (type === 'atrule' && options.mediaQueries) (0, _transform2.default)(node, "params", options, result);
30
- if (type === 'rule' && options.selectors) (0, _transform2.default)(node, "selector", options, result);
31
- });
32
- };
33
- });
34
- module.exports = exports['default'];
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _postcssSelectorParser = require('postcss-selector-parser');
8
-
9
- var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
10
-
11
- var _reduceCssCalc = require('reduce-css-calc');
12
-
13
- var _reduceCssCalc2 = _interopRequireDefault(_reduceCssCalc);
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- var MATCH_CALC = /((?:\-[a-z]+\-)?calc)/;
18
-
19
- function transformValue(value, options, result, item) {
20
- if (!value) {
21
- return value;
22
- }
23
-
24
- var reduced = (0, _reduceCssCalc2.default)(value, options.precision);
25
- // if the warnWhenCannotResolve option is on, inform the user that the calc
26
- // expression could not be resolved to a single value
27
- if (options.warnWhenCannotResolve && MATCH_CALC.test(reduced)) {
28
- result.warn("Could not reduce expression: " + value, { plugin: 'postcss-calc', node: item });
29
- }
30
-
31
- return reduced;
32
- }
33
-
34
- function transformSelector(value, options, result, item) {
35
- return (0, _postcssSelectorParser2.default)(function (selectors) {
36
- selectors.walk(function (node) {
37
- // attribute value
38
- // e.g. the "calc(3*3)" part of "div[data-size="calc(3*3)"]"
39
- if (node.type === 'attribute') {
40
- var val = transformValue(node.raws.unquoted, options, result, item);
41
- node.value = node.quoted ? '"' + val + '"' : val;
42
- }
43
-
44
- // tag value
45
- // e.g. the "calc(3*3)" part of "div:nth-child(2n + calc(3*3))"
46
- if (node.type === 'tag') node.value = transformValue(node.value, options, result, item);
47
-
48
- return;
49
- });
50
- }).process(value).result.toString();
51
- }
52
-
53
- exports.default = function (node, property, options, result) {
54
- var value = property === "selector" ? transformSelector(node[property], options, result, node) : transformValue(node[property], options, result, node);
55
-
56
- // if the preserve option is enabled and the value has changed, write the
57
- // transformed value into a cloned node which is inserted before the current
58
- // node, preserving the original value. Otherwise, overwrite the original
59
- // value.
60
- if (options.preserve && node[property] !== value) {
61
- var clone = node.clone();
62
- clone[property] = value;
63
- node.parent.insertBefore(node, clone);
64
- } else node[property] = value;
65
- };
66
-
67
- module.exports = exports['default'];