@chakrabortyrajarshi2005/chai-tailwind-css 1.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/src/main.js ADDED
@@ -0,0 +1,19 @@
1
+ import { scan } from "./scanner.js";
2
+ import { parse } from "./parser.js";
3
+ import { applyStyle } from "./apply.js";
4
+
5
+ function run() {
6
+ scan().forEach(function (item) {
7
+ applyStyle(item.element, parse(item.className));
8
+ });
9
+ }
10
+
11
+ export { scan } from "./scanner.js";
12
+ export { parse } from "./parser.js";
13
+ export { applyStyle } from "./apply.js";
14
+ export { propertyMap, categoryGroups } from "./config/propertyMap.js";
15
+ if (document.readyState === "loading") {
16
+ document.addEventListener("DOMContentLoaded", run);
17
+ } else {
18
+ run();
19
+ }
package/src/parser.js ADDED
@@ -0,0 +1,21 @@
1
+ import { propertyMap } from "./config/propertyMap.js";
2
+
3
+ export function parse(className) {
4
+ const withoutPrefix = className.slice(5);
5
+ const parts = withoutPrefix.split("-");
6
+
7
+ if (parts.length < 2) return null;
8
+
9
+ for (let i = 1; i < parts.length; i++) {
10
+ const property = parts.slice(0, i).join("-");
11
+ const value = parts.slice(i).join("-");
12
+
13
+ if (propertyMap[property] !== undefined) {
14
+ return { property, value };
15
+ }
16
+ }
17
+ return null;
18
+ }
19
+
20
+
21
+
package/src/scanner.js ADDED
@@ -0,0 +1,17 @@
1
+ export function scan() {
2
+ const found = [];
3
+ document.querySelectorAll("*").forEach(function (element) {
4
+ element.classList.forEach(function (className) {
5
+ if (className.startsWith("chai-")) {
6
+ found.push(
7
+ {
8
+ element: element,
9
+ className: className
10
+ }
11
+ );
12
+ }
13
+ });
14
+ });
15
+
16
+ return found;
17
+ }