postcss-focus-within 2.0.0 → 3.0.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes to PostCSS Focus Within
2
2
 
3
+ ### 3.0.0 (September 17, 2018)
4
+
5
+ - Updated: Support for PostCSS v7+
6
+ - Updated: Support for Node v6+
7
+
3
8
  ### 2.0.0 (April 7, 2018)
4
9
 
5
10
  - Changed: default functionality to preserve the original rule
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # PostCSS Focus Within [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2
2
 
3
3
  [![NPM Version][npm-img]][npm-url]
4
+ [![CSS Standard Status][css-img]][css-url]
4
5
  [![Build Status][cli-img]][cli-url]
5
- [![Windows Build Status][win-img]][win-url]
6
6
  [![Gitter Chat][git-img]][git-url]
7
7
 
8
8
  [PostCSS Focus Within] lets you use the `:focus-within` pseudo-class in CSS,
@@ -30,128 +30,40 @@ It is the companion to the [focus-within polyfill].
30
30
  with a `[focus-within]` attribute selector, the same selector used by the
31
31
  [focus-within polyfill]. This replacement selector can be changed using the
32
32
  `replaceWith` option. Also, the preservation of the original `:focus-within`
33
- rule can be disabled using the `preserve` option.
33
+ rule can be disabled using the `preserve` option.
34
34
 
35
35
  ## Usage
36
36
 
37
- Add [PostCSS Focus Within] to your build tool:
37
+ Add [PostCSS Focus Within] to your project:
38
38
 
39
39
  ```bash
40
40
  npm install postcss-focus-within --save-dev
41
41
  ```
42
42
 
43
- #### Node
44
-
45
43
  Use [PostCSS Focus Within] to process your CSS:
46
44
 
47
45
  ```js
48
- import focusWithin from 'postcss-focus-within';
49
-
50
- focusWithin.process(YOUR_CSS);
51
- ```
52
-
53
- #### PostCSS
54
-
55
- Add [PostCSS] to your build tool:
46
+ const postcssFocusWithin = require('postcss-focus-within');
56
47
 
57
- ```bash
58
- npm install postcss --save-dev
48
+ postcssFocusWithin.process(YOUR_CSS /*, processOptions, pluginOptions */);
59
49
  ```
60
50
 
61
- Use [PostCSS Focus Within] as a plugin:
51
+ Or use it as a [PostCSS] plugin:
62
52
 
63
53
  ```js
64
- import postcss from 'gulp-postcss';
65
- import focusWithin from 'postcss-focus-within';
54
+ const postcss = require('postcss');
55
+ const postcssFocusWithin = require('postcss-focus-within');
66
56
 
67
57
  postcss([
68
- focusWithin()
69
- ]).process(YOUR_CSS);
70
- ```
71
-
72
- #### Webpack
73
-
74
- Add [PostCSS Loader] to your build tool:
75
-
76
- ```bash
77
- npm install postcss-loader --save-dev
78
- ```
79
-
80
- Use [PostCSS Focus Within] in your Gulpfile:
81
-
82
- ```js
83
- import focusWithin from 'postcss-focus-within';
84
-
85
- module.exports = {
86
- module: {
87
- rules: [
88
- {
89
- test: /\.css$/,
90
- use: [
91
- 'style-loader',
92
- { loader: 'css-loader', options: { importLoaders: 1 } },
93
- { loader: 'postcss-loader', options: {
94
- ident: 'postcss',
95
- plugins: () => [ focusWithin() ]
96
- } }
97
- ]
98
- }
99
- ]
100
- }
101
- }
102
- ```
103
-
104
- #### Gulp
105
-
106
- Add [Gulp PostCSS] to your build tool:
107
-
108
- ```bash
109
- npm install gulp-postcss --save-dev
110
- ```
111
-
112
- Use [PostCSS Focus Within] in your Gulpfile:
113
-
114
- ```js
115
- import postcss from 'gulp-postcss';
116
- import focusWithin from 'postcss-focus-within';
117
-
118
- gulp.task('css', () => gulp.src('./src/*.css').pipe(
119
- postcss([
120
- focusWithin()
121
- ])
122
- ).pipe(
123
- gulp.dest('.')
124
- ));
125
- ```
126
-
127
- #### Grunt
128
-
129
- Add [Grunt PostCSS] to your build tool:
130
-
131
- ```bash
132
- npm install grunt-postcss --save-dev
58
+ postcssFocusWithin(/* pluginOptions */)
59
+ ]).process(YOUR_CSS /*, processOptions */);
133
60
  ```
134
61
 
135
- Use [PostCSS Focus Within] in your Gruntfile:
62
+ [PostCSS Focus Within] runs in all Node environments, with special
63
+ instructions for:
136
64
 
137
- ```js
138
- import focusWithin from 'postcss-focus-within';
139
-
140
- grunt.loadNpmTasks('grunt-postcss');
141
-
142
- grunt.initConfig({
143
- postcss: {
144
- options: {
145
- use: [
146
- focusWithin()
147
- ]
148
- },
149
- dist: {
150
- src: '*.css'
151
- }
152
- }
153
- });
154
- ```
65
+ | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
66
+ | --- | --- | --- | --- | --- | --- |
155
67
 
156
68
  ## Options
157
69
 
@@ -201,14 +113,14 @@ focusWithin({ replaceWith: '.focus-within' });
201
113
  }
202
114
  ```
203
115
 
204
- [npm-url]: https://www.npmjs.com/package/postcss-focus-within
205
- [npm-img]: https://img.shields.io/npm/v/postcss-focus-within.svg
206
- [cli-url]: https://travis-ci.org/jonathantneal/postcss-focus-within
116
+ [css-img]: https://cssdb.org/badge/focus-within-pseudo-class.svg
117
+ [css-url]: https://cssdb.org/#focus-within-pseudo-class
207
118
  [cli-img]: https://img.shields.io/travis/jonathantneal/postcss-focus-within.svg
208
- [win-url]: https://ci.appveyor.com/project/jonathantneal/postcss-focus-within
209
- [win-img]: https://img.shields.io/appveyor/ci/jonathantneal/postcss-focus-within.svg
210
- [git-url]: https://gitter.im/postcss/postcss
119
+ [cli-url]: https://travis-ci.org/jonathantneal/postcss-focus-within
211
120
  [git-img]: https://img.shields.io/badge/support-chat-blue.svg
121
+ [git-url]: https://gitter.im/postcss/postcss
122
+ [npm-img]: https://img.shields.io/npm/v/postcss-focus-within.svg
123
+ [npm-url]: https://www.npmjs.com/package/postcss-focus-within
212
124
 
213
125
  [focus-within polyfill]: https://github.com/jonathantneal/focus-within
214
126
  [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
package/index.cjs.js CHANGED
@@ -4,27 +4,27 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
4
4
 
5
5
  var postcss = _interopDefault(require('postcss'));
6
6
 
7
- var selectorRegExp = /:focus-within([^\w-]|$)/gi;
8
-
9
- var index = postcss.plugin('postcss-focus-within', function (opts) {
10
- var replaceWith = String(Object(opts).replaceWith || '[focus-within]');
11
- var preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
12
-
13
- return function (root) {
14
- root.walkRules(selectorRegExp, function (rule) {
15
- var selector = rule.selector.replace(selectorRegExp, function ($0, $1) {
16
- return `${replaceWith}${$1}`;
17
- });
18
-
19
- var clone = rule.clone({ selector });
20
-
21
- if (preserve) {
22
- rule.before(clone);
23
- } else {
24
- rule.replaceWith(clone);
25
- }
26
- });
27
- };
7
+ const selectorRegExp = /:focus-within([^\w-]|$)/gi;
8
+ var index = postcss.plugin('postcss-focus-within', opts => {
9
+ const replaceWith = String(Object(opts).replaceWith || '[focus-within]');
10
+ const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
11
+ return root => {
12
+ root.walkRules(selectorRegExp, rule => {
13
+ const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
14
+ return `${replaceWith}${$1}`;
15
+ });
16
+ const clone = rule.clone({
17
+ selector
18
+ });
19
+
20
+ if (preserve) {
21
+ rule.before(clone);
22
+ } else {
23
+ rule.replaceWith(clone);
24
+ }
25
+ });
26
+ };
28
27
  });
29
28
 
30
29
  module.exports = index;
30
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["index.js"],"sourcesContent":["import postcss from 'postcss';\n\nconst selectorRegExp = /:focus-within([^\\w-]|$)/gi;\n\nexport default postcss.plugin('postcss-focus-within', opts => {\n\tconst replaceWith = String(Object(opts).replaceWith || '[focus-within]');\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn root => {\n\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\tconst selector = rule.selector.replace(selectorRegExp, ($0, $1) => {\n\t\t\t\treturn `${replaceWith}${$1}`;\n\t\t\t});\n\n\t\t\tconst clone = rule.clone({ selector });\n\n\t\t\tif (preserve) {\n\t\t\t\trule.before(clone);\n\t\t\t} else {\n\t\t\t\trule.replaceWith(clone);\n\t\t\t}\n\t\t});\n\t};\n});\n"],"names":["selectorRegExp","postcss","plugin","opts","replaceWith","String","Object","preserve","Boolean","root","walkRules","rule","selector","replace","$0","$1","clone","before"],"mappings":";;;;;;AAEA,MAAMA,cAAc,GAAG,2BAAvB;AAEA,YAAeC,OAAO,CAACC,MAAR,CAAe,sBAAf,EAAuCC,IAAI,IAAI;QACvDC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAD,CAAN,CAAaC,WAAb,IAA4B,gBAA7B,CAA1B;QACMG,QAAQ,GAAGC,OAAO,CAAC,cAAcF,MAAM,CAACH,IAAD,CAApB,GAA6BA,IAAI,CAACI,QAAlC,GAA6C,IAA9C,CAAxB;SAEOE,IAAI,IAAI;IACdA,IAAI,CAACC,SAAL,CAAeV,cAAf,EAA+BW,IAAI,IAAI;YAChCC,QAAQ,GAAGD,IAAI,CAACC,QAAL,CAAcC,OAAd,CAAsBb,cAAtB,EAAsC,CAACc,EAAD,EAAKC,EAAL,KAAY;eAC1D,GAAEX,WAAY,GAAEW,EAAG,EAA3B;OADgB,CAAjB;YAIMC,KAAK,GAAGL,IAAI,CAACK,KAAL,CAAW;QAAEJ;OAAb,CAAd;;UAEIL,QAAJ,EAAc;QACbI,IAAI,CAACM,MAAL,CAAYD,KAAZ;OADD,MAEO;QACNL,IAAI,CAACP,WAAL,CAAiBY,KAAjB;;KAVF;GADD;CAJc,CAAf;;;;"}
package/index.es.mjs ADDED
@@ -0,0 +1,26 @@
1
+ import postcss from 'postcss';
2
+
3
+ const selectorRegExp = /:focus-within([^\w-]|$)/gi;
4
+ var index = postcss.plugin('postcss-focus-within', opts => {
5
+ const replaceWith = String(Object(opts).replaceWith || '[focus-within]');
6
+ const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
7
+ return root => {
8
+ root.walkRules(selectorRegExp, rule => {
9
+ const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
10
+ return `${replaceWith}${$1}`;
11
+ });
12
+ const clone = rule.clone({
13
+ selector
14
+ });
15
+
16
+ if (preserve) {
17
+ rule.before(clone);
18
+ } else {
19
+ rule.replaceWith(clone);
20
+ }
21
+ });
22
+ };
23
+ });
24
+
25
+ export default index;
26
+ //# sourceMappingURL=index.es.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.mjs","sources":["index.js"],"sourcesContent":["import postcss from 'postcss';\n\nconst selectorRegExp = /:focus-within([^\\w-]|$)/gi;\n\nexport default postcss.plugin('postcss-focus-within', opts => {\n\tconst replaceWith = String(Object(opts).replaceWith || '[focus-within]');\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn root => {\n\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\tconst selector = rule.selector.replace(selectorRegExp, ($0, $1) => {\n\t\t\t\treturn `${replaceWith}${$1}`;\n\t\t\t});\n\n\t\t\tconst clone = rule.clone({ selector });\n\n\t\t\tif (preserve) {\n\t\t\t\trule.before(clone);\n\t\t\t} else {\n\t\t\t\trule.replaceWith(clone);\n\t\t\t}\n\t\t});\n\t};\n});\n"],"names":["selectorRegExp","postcss","plugin","opts","replaceWith","String","Object","preserve","Boolean","root","walkRules","rule","selector","replace","$0","$1","clone","before"],"mappings":";;AAEA,MAAMA,cAAc,GAAG,2BAAvB;AAEA,YAAeC,OAAO,CAACC,MAAR,CAAe,sBAAf,EAAuCC,IAAI,IAAI;QACvDC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAD,CAAN,CAAaC,WAAb,IAA4B,gBAA7B,CAA1B;QACMG,QAAQ,GAAGC,OAAO,CAAC,cAAcF,MAAM,CAACH,IAAD,CAApB,GAA6BA,IAAI,CAACI,QAAlC,GAA6C,IAA9C,CAAxB;SAEOE,IAAI,IAAI;IACdA,IAAI,CAACC,SAAL,CAAeV,cAAf,EAA+BW,IAAI,IAAI;YAChCC,QAAQ,GAAGD,IAAI,CAACC,QAAL,CAAcC,OAAd,CAAsBb,cAAtB,EAAsC,CAACc,EAAD,EAAKC,EAAL,KAAY;eAC1D,GAAEX,WAAY,GAAEW,EAAG,EAA3B;OADgB,CAAjB;YAIMC,KAAK,GAAGL,IAAI,CAACK,KAAL,CAAW;QAAEJ;OAAb,CAAd;;UAEIL,QAAJ,EAAc;QACbI,IAAI,CAACM,MAAL,CAAYD,KAAZ;OADD,MAEO;QACNL,IAAI,CAACP,WAAL,CAAiBY,KAAjB;;KAVF;GADD;CAJc,CAAf;;;;"}
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "postcss-focus-within",
3
- "version": "2.0.0",
4
- "description": "Ise the :focus-within pseudo-selector in CSS",
3
+ "version": "3.0.0",
4
+ "description": "Use the :focus-within pseudo-selector in CSS",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "CC0-1.0",
7
7
  "repository": "jonathantneal/postcss-focus-within",
8
8
  "homepage": "https://github.com/jonathantneal/postcss-focus-within#readme",
9
9
  "bugs": "https://github.com/jonathantneal/postcss-focus-within/issues",
10
10
  "main": "index.cjs.js",
11
- "module": "index.es.js",
11
+ "module": "index.es.mjs",
12
12
  "files": [
13
13
  "index.cjs.js",
14
- "index.es.js"
14
+ "index.cjs.js.map",
15
+ "index.es.mjs",
16
+ "index.es.mjs.map"
15
17
  ],
16
18
  "scripts": {
17
19
  "prepublishOnly": "npm test",
@@ -21,21 +23,21 @@
21
23
  "test:tape": "postcss-tape"
22
24
  },
23
25
  "engines": {
24
- "node": ">=4.0.0"
26
+ "node": ">=6.0.0"
25
27
  },
26
28
  "dependencies": {
27
- "postcss": "^6.0.21"
29
+ "postcss": "^7.0.2"
28
30
  },
29
31
  "devDependencies": {
30
- "babel-core": "^6.26.0",
31
- "babel-eslint": "^8.2.2",
32
- "babel-preset-env": "^1.6.1",
33
- "eslint": "^4.19.1",
32
+ "@babel/core": "^7.0.0",
33
+ "@babel/preset-env": "^7.0.0",
34
+ "babel-eslint": "^9.0.0",
35
+ "eslint": "^5.6.0",
34
36
  "eslint-config-dev": "2.0.0",
35
37
  "postcss-tape": "2.2.0",
36
38
  "pre-commit": "^1.2.2",
37
- "rollup": "^0.57.1",
38
- "rollup-plugin-babel": "^3.0.3"
39
+ "rollup": "^0.66.0",
40
+ "rollup-plugin-babel": "^4.0.1"
39
41
  },
40
42
  "eslintConfig": {
41
43
  "extends": "dev",
package/index.es.js DELETED
@@ -1,26 +0,0 @@
1
- import postcss from 'postcss';
2
-
3
- var selectorRegExp = /:focus-within([^\w-]|$)/gi;
4
-
5
- var index = postcss.plugin('postcss-focus-within', function (opts) {
6
- var replaceWith = String(Object(opts).replaceWith || '[focus-within]');
7
- var preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
8
-
9
- return function (root) {
10
- root.walkRules(selectorRegExp, function (rule) {
11
- var selector = rule.selector.replace(selectorRegExp, function ($0, $1) {
12
- return `${replaceWith}${$1}`;
13
- });
14
-
15
- var clone = rule.clone({ selector });
16
-
17
- if (preserve) {
18
- rule.before(clone);
19
- } else {
20
- rule.replaceWith(clone);
21
- }
22
- });
23
- };
24
- });
25
-
26
- export default index;