postcss-focus-within 8.0.0 → 8.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes to PostCSS Focus Within
2
2
 
3
+ ### 8.0.1
4
+
5
+ _December 15, 2023_
6
+
7
+ - Fix type definitions
8
+
3
9
  ### 8.0.0
4
10
 
5
11
  _July 3, 2023_
@@ -12,99 +18,4 @@ _February 8, 2023_
12
18
 
13
19
  - Reduce the amount of duplicate fallback CSS.
14
20
 
15
- ### 7.0.1
16
-
17
- _January 28, 2023_
18
-
19
- - Improve `types` declaration in `package.json`
20
-
21
- ### 7.0.0
22
-
23
- _January 24, 2023_
24
-
25
- - Updated: Support for Node v14+ (major).
26
- - Fix: Do not throw when a selector is invalid, show a warning instead.
27
-
28
- ### 6.1.1
29
-
30
- _August 23, 2022_
31
-
32
- - Fix: assign global browser polyfill to `window`, `self` or a blank object.
33
-
34
- ### 6.1.0
35
-
36
- _July 30, 2022_
37
-
38
- - Added: `disablePolyfillReadyClass` plugin option to prevent `.js-focus-within` from being added.
39
-
40
- ### 6.0.0
41
-
42
- _July 8, 2022_
43
-
44
- - Breaking: Changed generated classes so it prepends `.js-focus-within` to the
45
- generated class so CSS is applied when the polyfill is known to be running.
46
- - Added: Now bundling browser polyfill.
47
-
48
- ### 5.0.4
49
-
50
- _February 5, 2022_
51
-
52
- - Improved `es module` and `commonjs` compatibility
53
-
54
- ### 5.0.3
55
-
56
- _January 2, 2022_
57
-
58
- - Removed Sourcemaps from package tarball.
59
- - Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
60
-
61
- ### 5.0.2
62
-
63
- _December 13, 2021_
64
-
65
- - Changed: now uses `postcss-selector-parser` for parsing.
66
- - Updated: documentation
67
-
68
- ### 5.0.1
69
-
70
- _September 22, 2021_
71
-
72
- - Added missing `dist` to bundle.
73
- - Added missing `exports` to `package.json`
74
- - Added missing `types` to `package.json`
75
- - Added bundling & testing as prepublish step.
76
-
77
- ### 5.0.0
78
-
79
- _September 17, 2021_
80
-
81
- - Updated: Support for PostCS 8+ (major).
82
- - Updated: Support for Node 12+ (major).
83
-
84
- ### 4.0.0
85
-
86
- _April 20, 2020_
87
-
88
- - Fixed: Allow `:focus-within` to appear escaped in a selector
89
- - Updated: Support for Node 10+
90
- - Updated: Ownership moved to CSS Tools
91
-
92
- ### 3.0.0
93
-
94
- _September 17, 2018_
95
-
96
- - Updated: Support for PostCSS v7+
97
- - Updated: Support for Node v6+
98
-
99
- ### 2.0.0
100
-
101
- _April 7, 2018_
102
-
103
- - Changed: default functionality to preserve the original rule
104
- - Added: `preserve` option to preserve the original rule using `:focus-within`
105
-
106
- ### 1.0.0
107
-
108
- _February 17, 2018_
109
-
110
- - Initial version
21
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within/CHANGELOG.md)
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  [<img alt="npm version" src="https://img.shields.io/npm/v/postcss-focus-within.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/focus-within-pseudo-class.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
4
4
 
5
+ ```bash
6
+ npm install postcss-focus-within --save-dev
7
+ ```
8
+
5
9
  [PostCSS Focus Within] lets you use the `:focus-within` pseudo-class in CSS,
6
10
  following the [Selectors Level 4 specification].
7
11
 
@@ -152,7 +156,7 @@ or
152
156
 
153
157
  ```html
154
158
  <!-- When using a CDN url you will have to manually update the version number -->
155
- <script src="https://unpkg.com/postcss-focus-within@8.0.0/dist/browser-global.js"></script>
159
+ <script src="https://unpkg.com/postcss-focus-within@8.0.1/dist/browser-global.js"></script>
156
160
  <script>focusWithinInit()</script>
157
161
  ```
158
162
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),l=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(r,{result:a}){if(s.has(r))return;if(!r.selector.toLowerCase().includes(n))return;const i=r.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let i;try{i=e().astSync(s)}catch(e){return r.warn(a,`Failed to parse selector : "${s}" with message: "${e.message}"`),s}if(void 0===i)return[s];let c=!1;if(i.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(l.clone({}))))})),!c)return[s];const u=i.clone();if(!o.disablePolyfillReadyClass){var d,p,f,h,g;if(null!=(d=i.nodes)&&null!=(p=d[0])&&null!=(f=p.nodes)&&f.length)for(let s=0;s<i.nodes[0].nodes.length;s++){const n=i.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){i.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===i.nodes[0].nodes.length-1){i.nodes[0].append(e.className({value:t}));break}}return null!=(h=i.nodes)&&null!=(g=h[0])&&g.nodes&&(u.nodes[0].prepend(e.combinator({value:" "})),u.nodes[0].prepend(e.className({value:t}))),[i.toString(),u.toString()]}return[i.toString()]}));i.join(",")!==r.selectors.join(",")&&(s.add(r),r.cloneBefore({selectors:i}),o.preserve||r.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0,module.exports=creator;
1
+ "use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))})),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s<a.nodes[0].nodes.length;s++){const n=a.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){a.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===a.nodes[0].nodes.length-1){a.nodes[0].append(e.className({value:t}));break}}return a.nodes?.[0]?.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[a.toString(),d.toString()]}return[a.toString()]}));a.join(",")!==l.selectors.join(",")&&(s.add(l),l.cloneBefore({selectors:a}),o.preserve||l.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0,module.exports=creator;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { PluginCreator } from 'postcss';
2
+
3
+ declare const creator: PluginCreator<pluginOptions>;
4
+ export default creator;
5
+
2
6
  /** postcss-focus-within plugin options */
3
- export type pluginOptions = {
7
+ export declare type pluginOptions = {
4
8
  /** Preserve the original notation. default: true */
5
9
  preserve?: boolean;
6
10
  /** The replacement class to be used in the polyfill. default: "[focus-within]" */
@@ -8,5 +12,5 @@ export type pluginOptions = {
8
12
  /** Disable the selector prefix that is used to prevent a flash of incorrectly styled content. default: false */
9
13
  disablePolyfillReadyClass?: boolean;
10
14
  };
11
- declare const creator: PluginCreator<pluginOptions>;
12
- export default creator;
15
+
16
+ export { }
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),l=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(r,{result:a}){if(s.has(r))return;if(!r.selector.toLowerCase().includes(n))return;const i=r.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let i;try{i=e().astSync(s)}catch(e){return r.warn(a,`Failed to parse selector : "${s}" with message: "${e.message}"`),s}if(void 0===i)return[s];let c=!1;if(i.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(l.clone({}))))})),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){var u,p,f,h,m;if(null!=(u=i.nodes)&&null!=(p=u[0])&&null!=(f=p.nodes)&&f.length)for(let s=0;s<i.nodes[0].nodes.length;s++){const n=i.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){i.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===i.nodes[0].nodes.length-1){i.nodes[0].append(e.className({value:t}));break}}return null!=(h=i.nodes)&&null!=(m=h[0])&&m.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[i.toString(),d.toString()]}return[i.toString()]}));i.join(",")!==r.selectors.join(",")&&(s.add(r),r.cloneBefore({selectors:i}),o.preserve||r.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0;export{creator as default};
1
+ import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(l,{result:a}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const i=l.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let i;try{i=e().astSync(s)}catch(e){return l.warn(a,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===i)return[s];let c=!1;if(i.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))})),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){if(i.nodes?.[0]?.nodes?.length)for(let s=0;s<i.nodes[0].nodes.length;s++){const n=i.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){i.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===i.nodes[0].nodes.length-1){i.nodes[0].append(e.className({value:t}));break}}return i.nodes?.[0]?.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[i.toString(),d.toString()]}return[i.toString()]}));i.join(",")!==l.selectors.join(",")&&(s.add(l),l.cloneBefore({selectors:i}),o.preserve||l.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0;export{creator as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "postcss-focus-within",
3
3
  "description": "Use the :focus-within pseudo-selector in CSS",
4
- "version": "8.0.0",
4
+ "version": "8.0.1",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -31,15 +31,18 @@
31
31
  "engines": {
32
32
  "node": "^14 || ^16 || >=18"
33
33
  },
34
+ "type": "module",
34
35
  "main": "dist/index.cjs",
35
36
  "module": "dist/index.mjs",
36
- "types": "dist/index.d.ts",
37
37
  "exports": {
38
38
  ".": {
39
- "types": "./dist/index.d.ts",
40
- "import": "./dist/index.mjs",
41
- "require": "./dist/index.cjs",
42
- "default": "./dist/index.mjs"
39
+ "import": {
40
+ "types": "./dist/index.d.ts",
41
+ "default": "./dist/index.mjs"
42
+ },
43
+ "require": {
44
+ "default": "./dist/index.cjs"
45
+ }
43
46
  },
44
47
  "./browser": {
45
48
  "import": "./dist/browser.mjs",
@@ -62,18 +65,6 @@
62
65
  "peerDependencies": {
63
66
  "postcss": "^8.4"
64
67
  },
65
- "devDependencies": {
66
- "@csstools/postcss-tape": "*"
67
- },
68
- "scripts": {
69
- "build": "rollup -c ../../rollup/default.mjs",
70
- "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
71
- "lint": "node ../../.github/bin/format-package-json.mjs",
72
- "prepublishOnly": "npm run build && npm run test",
73
- "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
74
- "test:browser": "node ./test/_browser.mjs",
75
- "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
76
- },
77
68
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within#readme",
78
69
  "repository": {
79
70
  "type": "git",
@@ -94,14 +85,5 @@
94
85
  "pseudos",
95
86
  "selectors",
96
87
  "within"
97
- ],
98
- "csstools": {
99
- "cssdbId": "focus-within-pseudo-class",
100
- "exportName": "postcssFocusWithin",
101
- "humanReadableName": "PostCSS Focus Within",
102
- "specUrl": "https://www.w3.org/TR/selectors-4/#the-focus-within-pseudo"
103
- },
104
- "volta": {
105
- "extends": "../../package.json"
106
- }
88
+ ]
107
89
  }