summaryrefslogtreecommitdiff
path: root/node_modules/postcss-dir-pseudo-class/dist
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss-dir-pseudo-class/dist')
-rw-r--r--node_modules/postcss-dir-pseudo-class/dist/index.cjs1
-rw-r--r--node_modules/postcss-dir-pseudo-class/dist/index.d.ts12
-rw-r--r--node_modules/postcss-dir-pseudo-class/dist/index.mjs1
3 files changed, 14 insertions, 0 deletions
diff --git a/node_modules/postcss-dir-pseudo-class/dist/index.cjs b/node_modules/postcss-dir-pseudo-class/dist/index.cjs
new file mode 100644
index 00000000..f91c7465
--- /dev/null
+++ b/node_modules/postcss-dir-pseudo-class/dist/index.cjs
@@ -0,0 +1 @@
+"use strict";var e=require("postcss-selector-parser");const creator=t=>{const r=Object.assign({dir:null,preserve:!1,shadow:!1},t);return{postcssPlugin:"postcss-dir-pseudo-class",prepare(){const t=new WeakSet;return{Rule(o,{result:s}){if(t.has(o))return;let a,n=!1;if(o.selector.toLowerCase().includes(":dir(")){try{a=e((t=>{t.nodes.forEach((t=>{t.walk((t=>{if("pseudo"!==t.type)return;if(":dir"!==t.value.toLowerCase())return;if(!t.nodes||!t.nodes.length)return;const a=t.nodes.toString().toLowerCase();if("rtl"!==a&&"ltr"!==a)return;const l=t.parent;l.nodes.filter((e=>"pseudo"===e.type&&":dir"===e.value.toLowerCase())).length>1&&!n&&(n=!0,o.warn(s,`Hierarchical :dir pseudo class usage can't be transformed correctly to [dir] attributes. This will lead to incorrect selectors for "${o.selector}"`));const c=t.prev(),p=t.next(),i=c&&c.type&&"combinator"!==c.type,u=p&&p.type&&"combinator"!==p.type,d=p&&p.type&&("combinator"!==p.type||"combinator"===p.type&&" "===p.value);i||u||0===l.nodes.indexOf(t)&&d||1===l.nodes.length?t.remove():t.replaceWith(e.universal());const v=l.nodes[0],w=v&&"combinator"===v.type&&" "===v.value,y=v&&"tag"===v.type&&"html"===v.value.toLowerCase(),f=v&&"pseudo"===v.type&&":root"===v.value.toLowerCase();!v||y||f||w||l.prepend(e.combinator({value:" "}));const h=r.dir===a,b=e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${a}"`,raws:null}),m=e.pseudo({value:":host-context"});m.append(b);const g=e.pseudo({value:(y||f?"":"html")+":not"});g.append(e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${"ltr"===a?"rtl":"ltr"}"`,raws:null})),h?y?l.insertAfter(v,g):l.prepend(g):y?l.insertAfter(v,b):r.shadow&&!f?l.prepend(m):l.prepend(b)}))}))})).processSync(o.selector)}catch(e){return void o.warn(s,`Failed to parse selector : ${o.selector}`)}void 0!==a&&a!==o.selector&&(t.add(o),o.cloneBefore({selector:a}),r.preserve||o.remove())}}}}}};creator.postcss=!0,module.exports=creator;
diff --git a/node_modules/postcss-dir-pseudo-class/dist/index.d.ts b/node_modules/postcss-dir-pseudo-class/dist/index.d.ts
new file mode 100644
index 00000000..8e6f1148
--- /dev/null
+++ b/node_modules/postcss-dir-pseudo-class/dist/index.d.ts
@@ -0,0 +1,12 @@
+import type { PluginCreator } from 'postcss';
+/** postcss-dir-pseudo-class plugin options */
+export type pluginOptions = {
+ /** Preserve the original notation. default: true */
+ preserve?: boolean;
+ /** Assume a direction for the document. default: null */
+ dir?: 'ltr' | 'rtl';
+ /** Assume that the CSS is intended to be used in Shadow DOM with Custom Elements. default: false */
+ shadow?: boolean;
+};
+declare const creator: PluginCreator<pluginOptions>;
+export default creator;
diff --git a/node_modules/postcss-dir-pseudo-class/dist/index.mjs b/node_modules/postcss-dir-pseudo-class/dist/index.mjs
new file mode 100644
index 00000000..66e7dabe
--- /dev/null
+++ b/node_modules/postcss-dir-pseudo-class/dist/index.mjs
@@ -0,0 +1 @@
+import e from"postcss-selector-parser";const creator=t=>{const r=Object.assign({dir:null,preserve:!1,shadow:!1},t);return{postcssPlugin:"postcss-dir-pseudo-class",prepare(){const t=new WeakSet;return{Rule(o,{result:s}){if(t.has(o))return;let a,n=!1;if(o.selector.toLowerCase().includes(":dir(")){try{a=e((t=>{t.nodes.forEach((t=>{t.walk((t=>{if("pseudo"!==t.type)return;if(":dir"!==t.value.toLowerCase())return;if(!t.nodes||!t.nodes.length)return;const a=t.nodes.toString().toLowerCase();if("rtl"!==a&&"ltr"!==a)return;const l=t.parent;l.nodes.filter((e=>"pseudo"===e.type&&":dir"===e.value.toLowerCase())).length>1&&!n&&(n=!0,o.warn(s,`Hierarchical :dir pseudo class usage can't be transformed correctly to [dir] attributes. This will lead to incorrect selectors for "${o.selector}"`));const p=t.prev(),c=t.next(),i=p&&p.type&&"combinator"!==p.type,d=c&&c.type&&"combinator"!==c.type,u=c&&c.type&&("combinator"!==c.type||"combinator"===c.type&&" "===c.value);i||d||0===l.nodes.indexOf(t)&&u||1===l.nodes.length?t.remove():t.replaceWith(e.universal());const v=l.nodes[0],f=v&&"combinator"===v.type&&" "===v.value,w=v&&"tag"===v.type&&"html"===v.value.toLowerCase(),y=v&&"pseudo"===v.type&&":root"===v.value.toLowerCase();!v||w||y||f||l.prepend(e.combinator({value:" "}));const h=r.dir===a,b=e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${a}"`,raws:null}),m=e.pseudo({value:":host-context"});m.append(b);const g=e.pseudo({value:(w||y?"":"html")+":not"});g.append(e.attribute({attribute:"dir",operator:"=",quoteMark:'"',value:`"${"ltr"===a?"rtl":"ltr"}"`,raws:null})),h?w?l.insertAfter(v,g):l.prepend(g):w?l.insertAfter(v,b):r.shadow&&!y?l.prepend(m):l.prepend(b)}))}))})).processSync(o.selector)}catch(e){return void o.warn(s,`Failed to parse selector : ${o.selector}`)}void 0!==a&&a!==o.selector&&(t.add(o),o.cloneBefore({selector:a}),r.preserve||o.remove())}}}}}};creator.postcss=!0;export{creator as default};