boss-css 0.0.1 → 0.0.2
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/README.md +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.mjs +20 -0
- package/dist/api/browser.cjs +54 -0
- package/dist/api/browser.mjs +48 -0
- package/dist/api/config.cjs +94 -0
- package/dist/api/config.mjs +91 -0
- package/dist/api/css.cjs +304 -0
- package/dist/api/css.mjs +303 -0
- package/dist/api/dictionary.cjs +218 -0
- package/dist/api/dictionary.mjs +215 -0
- package/dist/api/file/dts.cjs +21 -0
- package/dist/api/file/dts.mjs +21 -0
- package/dist/api/file/file.cjs +123 -0
- package/dist/api/file/file.mjs +120 -0
- package/dist/api/file/js.cjs +118 -0
- package/dist/api/file/js.mjs +116 -0
- package/dist/api/names.cjs +52 -0
- package/dist/api/names.mjs +46 -0
- package/dist/api/noopCss.cjs +37 -0
- package/dist/api/noopCss.mjs +36 -0
- package/dist/api/propTree.cjs +54 -0
- package/dist/api/propTree.mjs +48 -0
- package/dist/api/server.cjs +112 -0
- package/dist/api/server.mjs +106 -0
- package/dist/cli/build.cjs +1 -0
- package/dist/cli/build.mjs +3 -0
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.mjs +29 -0
- package/dist/cli/tasks/build.cjs +24 -0
- package/dist/cli/tasks/build.mjs +23 -0
- package/dist/cli/tasks/choose.cjs +47 -0
- package/dist/cli/tasks/choose.mjs +46 -0
- package/dist/cli/tasks/compile.cjs +68 -0
- package/dist/cli/tasks/compile.mjs +67 -0
- package/dist/cli/tasks/dev.cjs +51 -0
- package/dist/cli/tasks/dev.mjs +48 -0
- package/dist/cli/tasks/init.cjs +1835 -0
- package/dist/cli/tasks/init.mjs +1831 -0
- package/dist/cli/tasks/watch.cjs +38 -0
- package/dist/cli/tasks/watch.mjs +37 -0
- package/dist/cli/templates/init.cjs +82 -0
- package/dist/cli/templates/init.mjs +78 -0
- package/dist/cli/types.cjs +13 -0
- package/dist/cli/types.mjs +13 -0
- package/dist/cli/utils.cjs +43 -0
- package/dist/cli/utils.mjs +41 -0
- package/dist/compile/classname-strategy.cjs +79 -0
- package/dist/compile/classname-strategy.mjs +77 -0
- package/dist/compile/classname.cjs +366 -0
- package/dist/compile/classname.mjs +360 -0
- package/dist/compile/index.cjs +238 -0
- package/dist/compile/index.mjs +235 -0
- package/dist/compile/jsx.cjs +803 -0
- package/dist/compile/jsx.mjs +800 -0
- package/dist/compile/prepared.cjs +88 -0
- package/dist/compile/prepared.mjs +87 -0
- package/dist/compile/runtime.cjs +33 -0
- package/dist/compile/runtime.mjs +32 -0
- package/dist/compile/transform.cjs +371 -0
- package/dist/compile/transform.mjs +369 -0
- package/dist/cx/index.cjs +93 -0
- package/dist/cx/index.mjs +85 -0
- package/dist/detect-fw/index.cjs +384 -0
- package/dist/detect-fw/index.mjs +379 -0
- package/dist/dev/client.cjs +39 -0
- package/dist/dev/client.mjs +38 -0
- package/dist/dev/plugin/browser.cjs +11 -0
- package/dist/dev/plugin/browser.mjs +9 -0
- package/dist/dev/plugin/server.cjs +86 -0
- package/dist/dev/plugin/server.mjs +78 -0
- package/dist/dev/port.cjs +46 -0
- package/dist/dev/port.mjs +43 -0
- package/dist/dev/runtime.cjs +28 -0
- package/dist/dev/runtime.mjs +29 -0
- package/dist/dev/server.cjs +808 -0
- package/dist/dev/server.mjs +805 -0
- package/dist/dev/shared.cjs +6 -0
- package/dist/dev/shared.mjs +5 -0
- package/dist/eslint-plugin/index.cjs +66 -0
- package/dist/eslint-plugin/index.mjs +66 -0
- package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
- package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
- package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
- package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
- package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
- package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
- package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
- package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
- package/dist/eslint-plugin/rules/props-only.cjs +115 -0
- package/dist/eslint-plugin/rules/props-only.mjs +115 -0
- package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
- package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
- package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
- package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
- package/dist/eslint-plugin/utils/api.cjs +30 -0
- package/dist/eslint-plugin/utils/api.mjs +29 -0
- package/dist/eslint-plugin/utils/ast.cjs +119 -0
- package/dist/eslint-plugin/utils/ast.mjs +112 -0
- package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
- package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
- package/dist/eslint-plugin/utils/defaults.cjs +99 -0
- package/dist/eslint-plugin/utils/defaults.mjs +93 -0
- package/dist/eslint-plugin/utils/format.cjs +20 -0
- package/dist/eslint-plugin/utils/format.mjs +19 -0
- package/dist/eslint-plugin/utils/order.cjs +76 -0
- package/dist/eslint-plugin/utils/order.mjs +76 -0
- package/dist/eslint-plugin/utils/property-order.cjs +449 -0
- package/dist/eslint-plugin/utils/property-order.mjs +448 -0
- package/dist/eslint-plugin/utils/static.cjs +36 -0
- package/dist/eslint-plugin/utils/static.mjs +35 -0
- package/dist/fontsource/directory.cjs +39588 -0
- package/dist/fontsource/directory.mjs +39587 -0
- package/dist/fontsource/server.cjs +291 -0
- package/dist/fontsource/server.mjs +282 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +6 -0
- package/dist/log/browser.cjs +28 -0
- package/dist/log/browser.mjs +28 -0
- package/dist/log/server.cjs +32 -0
- package/dist/log/server.mjs +30 -0
- package/dist/merge/index.cjs +590 -0
- package/dist/merge/index.mjs +586 -0
- package/dist/native/browser.cjs +78 -0
- package/dist/native/browser.mjs +77 -0
- package/dist/native/server.cjs +180 -0
- package/dist/native/server.mjs +176 -0
- package/dist/native/styleTypes.cjs +168 -0
- package/dist/native/styleTypes.mjs +164 -0
- package/dist/parser/classname/server.cjs +239 -0
- package/dist/parser/classname/server.mjs +232 -0
- package/dist/parser/jsx/browser.cjs +66 -0
- package/dist/parser/jsx/browser.mjs +63 -0
- package/dist/parser/jsx/extractCode.cjs +99 -0
- package/dist/parser/jsx/extractCode.mjs +98 -0
- package/dist/parser/jsx/extractPrepared.cjs +123 -0
- package/dist/parser/jsx/extractPrepared.mjs +122 -0
- package/dist/parser/jsx/extractProps.cjs +234 -0
- package/dist/parser/jsx/extractProps.mjs +232 -0
- package/dist/parser/jsx/isDOMProp.cjs +17 -0
- package/dist/parser/jsx/isDOMProp.mjs +15 -0
- package/dist/parser/jsx/native.cjs +110 -0
- package/dist/parser/jsx/native.mjs +108 -0
- package/dist/parser/jsx/runtime.cjs +4 -0
- package/dist/parser/jsx/runtime.mjs +3 -0
- package/dist/parser/jsx/server.cjs +278 -0
- package/dist/parser/jsx/server.mjs +268 -0
- package/dist/postcss/index.cjs +16 -0
- package/dist/postcss/index.mjs +16 -0
- package/dist/prop/at/runtime-only.cjs +90 -0
- package/dist/prop/at/runtime-only.mjs +88 -0
- package/dist/prop/at/server.cjs +282 -0
- package/dist/prop/at/server.mjs +268 -0
- package/dist/prop/at/shared.cjs +153 -0
- package/dist/prop/at/shared.mjs +144 -0
- package/dist/prop/bosswind/browser.cjs +18 -0
- package/dist/prop/bosswind/browser.mjs +16 -0
- package/dist/prop/bosswind/runtime-only.cjs +18 -0
- package/dist/prop/bosswind/runtime-only.mjs +16 -0
- package/dist/prop/bosswind/server.cjs +81 -0
- package/dist/prop/bosswind/server.mjs +72 -0
- package/dist/prop/bosswind/shared.cjs +861 -0
- package/dist/prop/bosswind/shared.mjs +855 -0
- package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
- package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
- package/dist/prop/child/runtime-only.cjs +18 -0
- package/dist/prop/child/runtime-only.mjs +15 -0
- package/dist/prop/child/server.cjs +81 -0
- package/dist/prop/child/server.mjs +72 -0
- package/dist/prop/css/getDtsTemplate.cjs +65 -0
- package/dist/prop/css/getDtsTemplate.mjs +63 -0
- package/dist/prop/css/runtime-only.cjs +14 -0
- package/dist/prop/css/runtime-only.mjs +13 -0
- package/dist/prop/css/server.cjs +99 -0
- package/dist/prop/css/server.mjs +90 -0
- package/dist/prop/pseudo/runtime-only.cjs +23 -0
- package/dist/prop/pseudo/runtime-only.mjs +21 -0
- package/dist/prop/pseudo/server.cjs +91 -0
- package/dist/prop/pseudo/server.mjs +82 -0
- package/dist/prop/pseudo/shared.cjs +61 -0
- package/dist/prop/pseudo/shared.mjs +60 -0
- package/dist/reset/server.cjs +34 -0
- package/dist/reset/server.mjs +26 -0
- package/dist/runtime/index.cjs +119 -0
- package/dist/runtime/index.mjs +118 -0
- package/dist/runtime/preact.cjs +4 -0
- package/dist/runtime/preact.mjs +3 -0
- package/dist/runtime/qwik.cjs +21 -0
- package/dist/runtime/qwik.mjs +18 -0
- package/dist/runtime/react.cjs +4 -0
- package/dist/runtime/react.mjs +3 -0
- package/dist/runtime/solid.cjs +15 -0
- package/dist/runtime/solid.mjs +14 -0
- package/dist/runtime/stencil.cjs +25 -0
- package/dist/runtime/stencil.mjs +21 -0
- package/dist/runtime/style.cjs +14 -0
- package/dist/runtime/style.mjs +13 -0
- package/dist/shared/boundaries.cjs +288 -0
- package/dist/shared/boundaries.mjs +285 -0
- package/dist/shared/customCss.cjs +212 -0
- package/dist/shared/customCss.mjs +211 -0
- package/dist/shared/debug.cjs +76 -0
- package/dist/shared/debug.mjs +74 -0
- package/dist/shared/file.cjs +21 -0
- package/dist/shared/file.mjs +19 -0
- package/dist/shared/framework.cjs +10 -0
- package/dist/shared/framework.mjs +9 -0
- package/dist/shared/json.cjs +58 -0
- package/dist/shared/json.mjs +57 -0
- package/dist/shared/types.cjs +11 -0
- package/dist/shared/types.mjs +10 -0
- package/dist/strategy/classic/runtime-only.cjs +190 -0
- package/dist/strategy/classic/runtime-only.mjs +186 -0
- package/dist/strategy/classname-first/runtime-only.cjs +138 -0
- package/dist/strategy/classname-first/runtime-only.mjs +134 -0
- package/dist/strategy/classname-first/server.cjs +139 -0
- package/dist/strategy/classname-first/server.mjs +133 -0
- package/dist/strategy/classname-only/server.cjs +43 -0
- package/dist/strategy/classname-only/server.mjs +35 -0
- package/dist/strategy/inline-first/browser.cjs +61 -0
- package/dist/strategy/inline-first/browser.mjs +58 -0
- package/dist/strategy/inline-first/runtime-only.cjs +159 -0
- package/dist/strategy/inline-first/runtime-only.mjs +155 -0
- package/dist/strategy/inline-first/server.cjs +92 -0
- package/dist/strategy/inline-first/server.mjs +83 -0
- package/dist/strategy/runtime/runtime-only.cjs +24 -0
- package/dist/strategy/runtime/runtime-only.mjs +22 -0
- package/dist/strategy/runtime/server.cjs +72 -0
- package/dist/strategy/runtime/server.mjs +63 -0
- package/dist/strategy/runtime-only/css.cjs +183 -0
- package/dist/strategy/runtime-only/css.mjs +181 -0
- package/dist/tasks/build.cjs +88 -0
- package/dist/tasks/build.mjs +84 -0
- package/dist/tasks/compile.cjs +12 -0
- package/dist/tasks/compile.mjs +12 -0
- package/dist/tasks/postcss.cjs +116 -0
- package/dist/tasks/postcss.mjs +113 -0
- package/dist/tasks/session.cjs +46 -0
- package/dist/tasks/session.mjs +42 -0
- package/dist/tasks/watch.cjs +102 -0
- package/dist/tasks/watch.mjs +99 -0
- package/dist/transform/cache.cjs +24 -0
- package/dist/transform/cache.mjs +21 -0
- package/dist/transform/processFile.cjs +26 -0
- package/dist/transform/processFile.mjs +24 -0
- package/dist/use/token/browser.cjs +65 -0
- package/dist/use/token/browser.mjs +61 -0
- package/dist/use/token/runtime-only.cjs +245 -0
- package/dist/use/token/runtime-only.mjs +239 -0
- package/dist/use/token/server.cjs +325 -0
- package/dist/use/token/server.mjs +313 -0
- package/dist/use/token/vars.cjs +47 -0
- package/dist/use/token/vars.mjs +46 -0
- package/package.json +300 -4
- package/src/api/config.d.ts +1 -0
- package/src/fontsource/types.d.ts +50 -0
- package/src/packages/document-create-element/createElement.browser.js +3 -0
- package/src/packages/document-create-element/createElement.js +7 -0
- package/src/packages/document-create-element/package.json +17 -0
- package/src/packages/is-css-prop/browser.js +13 -0
- package/src/packages/is-css-prop/index.js +13 -0
- package/src/packages/is-css-prop/package-lock.json +52 -0
- package/src/packages/is-css-prop/package.json +17 -0
- package/src/prop/css/csstype.json +4387 -0
- package/src/prop/css/package.json +3 -0
- package/src/reset/reset.css +259 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/eslint-plugin/utils/defaults.js
|
|
2
|
+
const DEFAULT_ATTRIBUTE_PATTERNS = ["^class(?:Name)?$"];
|
|
3
|
+
const DEFAULT_CALLEE_PATTERNS = [
|
|
4
|
+
"^cx$",
|
|
5
|
+
"^merge$",
|
|
6
|
+
"^\\$\\$\\.cx$",
|
|
7
|
+
"^\\$\\$\\.merge$"
|
|
8
|
+
];
|
|
9
|
+
const DEFAULT_VARIABLE_PATTERNS = ["^classNames?$", "^classes$"];
|
|
10
|
+
const DEFAULT_TAG_PATTERNS = [];
|
|
11
|
+
const DEFAULT_COMPONENTS = ["$$"];
|
|
12
|
+
const DEFAULT_BREAKPOINTS = {
|
|
13
|
+
micro: [null, 375],
|
|
14
|
+
mobile: [376, 639],
|
|
15
|
+
tablet: [640, 1023],
|
|
16
|
+
small: [1024, 1439],
|
|
17
|
+
medium: [1440, 1919],
|
|
18
|
+
large: [1920, null],
|
|
19
|
+
device: [null, 1023]
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_PSEUDO_CONTEXTS = [
|
|
22
|
+
"defined",
|
|
23
|
+
"any-link",
|
|
24
|
+
"link",
|
|
25
|
+
"visited",
|
|
26
|
+
"local-link",
|
|
27
|
+
"target",
|
|
28
|
+
"target-within",
|
|
29
|
+
"scope",
|
|
30
|
+
"hover",
|
|
31
|
+
"active",
|
|
32
|
+
"focus",
|
|
33
|
+
"focus-visible",
|
|
34
|
+
"focus-within",
|
|
35
|
+
"current",
|
|
36
|
+
"past",
|
|
37
|
+
"future",
|
|
38
|
+
"playing",
|
|
39
|
+
"paused",
|
|
40
|
+
"seeking",
|
|
41
|
+
"buffering",
|
|
42
|
+
"stalled",
|
|
43
|
+
"muted",
|
|
44
|
+
"volume-locked",
|
|
45
|
+
"open",
|
|
46
|
+
"closed",
|
|
47
|
+
"modal",
|
|
48
|
+
"fullscreen",
|
|
49
|
+
"picture-in-picture",
|
|
50
|
+
"enabled",
|
|
51
|
+
"disabled",
|
|
52
|
+
"read-write",
|
|
53
|
+
"read-only",
|
|
54
|
+
"placeholder-shown",
|
|
55
|
+
"autofill",
|
|
56
|
+
"default",
|
|
57
|
+
"checked",
|
|
58
|
+
"indeterminate",
|
|
59
|
+
"blank",
|
|
60
|
+
"valid",
|
|
61
|
+
"invalid",
|
|
62
|
+
"in-range",
|
|
63
|
+
"out-of-range",
|
|
64
|
+
"user-valid",
|
|
65
|
+
"root",
|
|
66
|
+
"empty",
|
|
67
|
+
"first-child",
|
|
68
|
+
"last-child",
|
|
69
|
+
"only-child",
|
|
70
|
+
"first-of-type",
|
|
71
|
+
"last-of-type",
|
|
72
|
+
"only-of-type",
|
|
73
|
+
"after",
|
|
74
|
+
"before"
|
|
75
|
+
];
|
|
76
|
+
const getDefaultContexts = () => {
|
|
77
|
+
const contexts = new Set(DEFAULT_PSEUDO_CONTEXTS);
|
|
78
|
+
const breakpointNames = Object.keys(DEFAULT_BREAKPOINTS);
|
|
79
|
+
for (const name of breakpointNames) {
|
|
80
|
+
contexts.add(name);
|
|
81
|
+
contexts.add(`${name}+`);
|
|
82
|
+
contexts.add(`${name}-`);
|
|
83
|
+
}
|
|
84
|
+
contexts.add("at");
|
|
85
|
+
contexts.add("container");
|
|
86
|
+
contexts.add("dark");
|
|
87
|
+
contexts.add("light");
|
|
88
|
+
contexts.add("hdpi");
|
|
89
|
+
return contexts;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { DEFAULT_ATTRIBUTE_PATTERNS, DEFAULT_CALLEE_PATTERNS, DEFAULT_COMPONENTS, DEFAULT_TAG_PATTERNS, DEFAULT_VARIABLE_PATTERNS, getDefaultContexts };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/eslint-plugin/utils/format.js
|
|
3
|
+
const escapeString = (value, quote) => {
|
|
4
|
+
let escaped = value.replace(/\\/g, "\\\\");
|
|
5
|
+
if (quote === "'") escaped = escaped.replace(/'/g, "\\'");
|
|
6
|
+
else escaped = escaped.replace(/"/g, "\\\"");
|
|
7
|
+
return escaped.replace(/\r/g, "\\r").replace(/\n/g, "\\n");
|
|
8
|
+
};
|
|
9
|
+
const escapeTemplate = (value) => {
|
|
10
|
+
return value.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
11
|
+
};
|
|
12
|
+
const buildLiteralReplacement = (node, sourceCode, value) => {
|
|
13
|
+
if (node.type === "TemplateLiteral") return `\`${escapeTemplate(value)}\``;
|
|
14
|
+
const raw = sourceCode.getText(node);
|
|
15
|
+
const quote = raw && (raw[0] === "\"" || raw[0] === "'") ? raw[0] : "\"";
|
|
16
|
+
return `${quote}${escapeString(value, quote)}${quote}`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.buildLiteralReplacement = buildLiteralReplacement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/eslint-plugin/utils/format.js
|
|
2
|
+
const escapeString = (value, quote) => {
|
|
3
|
+
let escaped = value.replace(/\\/g, "\\\\");
|
|
4
|
+
if (quote === "'") escaped = escaped.replace(/'/g, "\\'");
|
|
5
|
+
else escaped = escaped.replace(/"/g, "\\\"");
|
|
6
|
+
return escaped.replace(/\r/g, "\\r").replace(/\n/g, "\\n");
|
|
7
|
+
};
|
|
8
|
+
const escapeTemplate = (value) => {
|
|
9
|
+
return value.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
10
|
+
};
|
|
11
|
+
const buildLiteralReplacement = (node, sourceCode, value) => {
|
|
12
|
+
if (node.type === "TemplateLiteral") return `\`${escapeTemplate(value)}\``;
|
|
13
|
+
const raw = sourceCode.getText(node);
|
|
14
|
+
const quote = raw && (raw[0] === "\"" || raw[0] === "'") ? raw[0] : "\"";
|
|
15
|
+
return `${quote}${escapeString(value, quote)}${quote}`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { buildLiteralReplacement };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const require_boss_classes = require('./boss-classes.cjs');
|
|
2
|
+
const require_property_order = require('./property-order.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/eslint-plugin/utils/order.js
|
|
5
|
+
const dashToCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
6
|
+
const getOrderMap = () => {
|
|
7
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
|
+
const dictionary = require_boss_classes.getDictionary();
|
|
9
|
+
for (const [index, prop] of require_property_order.propertyOrder.entries()) if (!map.has(prop)) map.set(prop, index);
|
|
10
|
+
if (!dictionary) return map;
|
|
11
|
+
for (const entry of dictionary.values()) {
|
|
12
|
+
if (!entry?.isCSSProp) continue;
|
|
13
|
+
if (map.has(entry.property)) continue;
|
|
14
|
+
map.set(entry.property, map.size);
|
|
15
|
+
}
|
|
16
|
+
return map;
|
|
17
|
+
};
|
|
18
|
+
const getTokenInfo = (token, extraProps) => {
|
|
19
|
+
const grouped = require_boss_classes.parseGroupedSelector(token);
|
|
20
|
+
if (grouped) {
|
|
21
|
+
if (grouped.entries.length !== 1) return null;
|
|
22
|
+
const [entry] = grouped.entries;
|
|
23
|
+
if (!require_boss_classes.isCssPropName(entry.name, extraProps)) return null;
|
|
24
|
+
return {
|
|
25
|
+
contexts: require_boss_classes.splitFragments(grouped.prefix),
|
|
26
|
+
prop: entry.name
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const fragments = require_boss_classes.splitFragments(token);
|
|
30
|
+
if (!fragments.length) return null;
|
|
31
|
+
let propIndex = -1;
|
|
32
|
+
for (let i = 0; i < fragments.length; i += 1) if (require_boss_classes.isCssPropName(fragments[i], extraProps)) {
|
|
33
|
+
propIndex = i;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (propIndex === -1) return null;
|
|
37
|
+
return {
|
|
38
|
+
contexts: fragments.slice(0, propIndex),
|
|
39
|
+
prop: fragments[propIndex]
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const sortOfficial = (classOrder) => {
|
|
43
|
+
return classOrder.toSorted(([, a], [, b]) => {
|
|
44
|
+
if (a === b) return 0;
|
|
45
|
+
if (a === null) return -1;
|
|
46
|
+
if (b === null) return 1;
|
|
47
|
+
return a - b;
|
|
48
|
+
}).map(([className]) => className);
|
|
49
|
+
};
|
|
50
|
+
const sortTokens = (tokens, options) => {
|
|
51
|
+
const order = options.order ?? "improved";
|
|
52
|
+
if (order === "none") return tokens;
|
|
53
|
+
if (order === "asc" || order === "desc") {
|
|
54
|
+
const sorted = [...tokens].sort((a, b) => a.localeCompare(b));
|
|
55
|
+
return order === "desc" ? sorted.reverse() : sorted;
|
|
56
|
+
}
|
|
57
|
+
const extraProps = options.additionalProps?.length ? new Set(options.additionalProps) : null;
|
|
58
|
+
const orderMap = getOrderMap();
|
|
59
|
+
const official = sortOfficial(tokens.map((token) => {
|
|
60
|
+
const info = getTokenInfo(token, extraProps);
|
|
61
|
+
if (!info) return [token, null];
|
|
62
|
+
const entry = require_boss_classes.getDictionaryEntry(info.prop);
|
|
63
|
+
return [token, (entry?.property ? orderMap.get(entry.property) : null) ?? orderMap.get(info.prop) ?? orderMap.get(dashToCamelCase(info.prop)) ?? null];
|
|
64
|
+
}));
|
|
65
|
+
if (order === "official") return official;
|
|
66
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const className of official) {
|
|
68
|
+
const info = getTokenInfo(className, extraProps);
|
|
69
|
+
const variants = info ? info.contexts.join(":") : "";
|
|
70
|
+
grouped.set(variants, [...grouped.get(variants) ?? [], className]);
|
|
71
|
+
}
|
|
72
|
+
return Array.from(grouped.values()).flat();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.sortTokens = sortTokens;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getDictionary, getDictionaryEntry, isCssPropName, parseGroupedSelector, splitFragments } from "./boss-classes.mjs";
|
|
2
|
+
import { propertyOrder } from "./property-order.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/eslint-plugin/utils/order.js
|
|
5
|
+
const dashToCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
6
|
+
const getOrderMap = () => {
|
|
7
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
|
+
const dictionary = getDictionary();
|
|
9
|
+
for (const [index, prop] of propertyOrder.entries()) if (!map.has(prop)) map.set(prop, index);
|
|
10
|
+
if (!dictionary) return map;
|
|
11
|
+
for (const entry of dictionary.values()) {
|
|
12
|
+
if (!entry?.isCSSProp) continue;
|
|
13
|
+
if (map.has(entry.property)) continue;
|
|
14
|
+
map.set(entry.property, map.size);
|
|
15
|
+
}
|
|
16
|
+
return map;
|
|
17
|
+
};
|
|
18
|
+
const getTokenInfo = (token, extraProps) => {
|
|
19
|
+
const grouped = parseGroupedSelector(token);
|
|
20
|
+
if (grouped) {
|
|
21
|
+
if (grouped.entries.length !== 1) return null;
|
|
22
|
+
const [entry] = grouped.entries;
|
|
23
|
+
if (!isCssPropName(entry.name, extraProps)) return null;
|
|
24
|
+
return {
|
|
25
|
+
contexts: splitFragments(grouped.prefix),
|
|
26
|
+
prop: entry.name
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const fragments = splitFragments(token);
|
|
30
|
+
if (!fragments.length) return null;
|
|
31
|
+
let propIndex = -1;
|
|
32
|
+
for (let i = 0; i < fragments.length; i += 1) if (isCssPropName(fragments[i], extraProps)) {
|
|
33
|
+
propIndex = i;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (propIndex === -1) return null;
|
|
37
|
+
return {
|
|
38
|
+
contexts: fragments.slice(0, propIndex),
|
|
39
|
+
prop: fragments[propIndex]
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const sortOfficial = (classOrder) => {
|
|
43
|
+
return classOrder.toSorted(([, a], [, b]) => {
|
|
44
|
+
if (a === b) return 0;
|
|
45
|
+
if (a === null) return -1;
|
|
46
|
+
if (b === null) return 1;
|
|
47
|
+
return a - b;
|
|
48
|
+
}).map(([className]) => className);
|
|
49
|
+
};
|
|
50
|
+
const sortTokens = (tokens, options) => {
|
|
51
|
+
const order = options.order ?? "improved";
|
|
52
|
+
if (order === "none") return tokens;
|
|
53
|
+
if (order === "asc" || order === "desc") {
|
|
54
|
+
const sorted = [...tokens].sort((a, b) => a.localeCompare(b));
|
|
55
|
+
return order === "desc" ? sorted.reverse() : sorted;
|
|
56
|
+
}
|
|
57
|
+
const extraProps = options.additionalProps?.length ? new Set(options.additionalProps) : null;
|
|
58
|
+
const orderMap = getOrderMap();
|
|
59
|
+
const official = sortOfficial(tokens.map((token) => {
|
|
60
|
+
const info = getTokenInfo(token, extraProps);
|
|
61
|
+
if (!info) return [token, null];
|
|
62
|
+
const entry = getDictionaryEntry(info.prop);
|
|
63
|
+
return [token, (entry?.property ? orderMap.get(entry.property) : null) ?? orderMap.get(info.prop) ?? orderMap.get(dashToCamelCase(info.prop)) ?? null];
|
|
64
|
+
}));
|
|
65
|
+
if (order === "official") return official;
|
|
66
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const className of official) {
|
|
68
|
+
const info = getTokenInfo(className, extraProps);
|
|
69
|
+
const variants = info ? info.contexts.join(":") : "";
|
|
70
|
+
grouped.set(variants, [...grouped.get(variants) ?? [], className]);
|
|
71
|
+
}
|
|
72
|
+
return Array.from(grouped.values()).flat();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { sortTokens };
|