@flairjs/client 0.0.1-beta.1 → 0.0.1-beta.3
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/dist/cjs/index.js +33 -0
- package/dist/esm/index.js +32 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -2
- package/dist/types/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.50.0_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js +23 -0
- package/dist/types/packages/client/src/theme.js +37 -0
- package/dist/types/preact/index.js +1 -1
- package/dist/types/react/index.js +1 -1
- package/dist/types/solidjs/index.js +1 -1
- package/dist/types/theme.d.ts +32 -0
- package/package.json +2 -2
- /package/dist/types/{preact → packages/client/src/preact}/style.js +0 -0
- /package/dist/types/{react → packages/client/src/react}/style.js +0 -0
- /package/dist/types/{solidjs → packages/client/src/solidjs}/style.js +0 -0
- /package/dist/types/{utils.js → packages/client/src/utils.js} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -9,7 +9,40 @@ const cn = c;
|
|
|
9
9
|
const css = String.raw;
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
|
+
//#region src/theme.ts
|
|
13
|
+
function defineConfig(config) {
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
const buildThemeTokens = (theme, themeName) => {
|
|
17
|
+
let css$1 = "";
|
|
18
|
+
const { tokens, selector } = theme;
|
|
19
|
+
if (typeof selector === "string") css$1 += `${selector} {\n`;
|
|
20
|
+
css$1 += tokensToCSSVars(tokens, theme.prefix ? [theme.prefix] : []);
|
|
21
|
+
if (typeof selector === "string") css$1 += `}\n`;
|
|
22
|
+
else css$1 = selector(css$1, themeName);
|
|
23
|
+
Object.entries(theme.themes ?? {}).forEach(([name, themeConfig]) => {
|
|
24
|
+
css$1 += buildThemeTokens({
|
|
25
|
+
prefix: theme.prefix,
|
|
26
|
+
selector: theme.selector,
|
|
27
|
+
...themeConfig
|
|
28
|
+
}, name);
|
|
29
|
+
});
|
|
30
|
+
return css$1;
|
|
31
|
+
};
|
|
32
|
+
function tokensToCSSVars(tokens, prefix = []) {
|
|
33
|
+
let css$1 = "";
|
|
34
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
35
|
+
const newPrefix = [...prefix, key];
|
|
36
|
+
if (typeof value === "string" || typeof value === "number") css$1 += `--${newPrefix.join("-")}: ${value};\n`;
|
|
37
|
+
else if (typeof value === "object" && value !== null) css$1 += tokensToCSSVars(value, newPrefix);
|
|
38
|
+
}
|
|
39
|
+
return css$1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.buildThemeTokens = buildThemeTokens;
|
|
12
44
|
exports.c = c;
|
|
13
45
|
exports.cn = cn;
|
|
14
46
|
exports.css = css;
|
|
47
|
+
exports.defineConfig = defineConfig;
|
|
15
48
|
exports.flair = flair;
|
package/dist/esm/index.js
CHANGED
|
@@ -7,4 +7,35 @@ const cn = c;
|
|
|
7
7
|
const css = String.raw;
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
|
-
|
|
10
|
+
//#region src/theme.ts
|
|
11
|
+
function defineConfig(config) {
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
14
|
+
const buildThemeTokens = (theme, themeName) => {
|
|
15
|
+
let css$1 = "";
|
|
16
|
+
const { tokens, selector } = theme;
|
|
17
|
+
if (typeof selector === "string") css$1 += `${selector} {\n`;
|
|
18
|
+
css$1 += tokensToCSSVars(tokens, theme.prefix ? [theme.prefix] : []);
|
|
19
|
+
if (typeof selector === "string") css$1 += `}\n`;
|
|
20
|
+
else css$1 = selector(css$1, themeName);
|
|
21
|
+
Object.entries(theme.themes ?? {}).forEach(([name, themeConfig]) => {
|
|
22
|
+
css$1 += buildThemeTokens({
|
|
23
|
+
prefix: theme.prefix,
|
|
24
|
+
selector: theme.selector,
|
|
25
|
+
...themeConfig
|
|
26
|
+
}, name);
|
|
27
|
+
});
|
|
28
|
+
return css$1;
|
|
29
|
+
};
|
|
30
|
+
function tokensToCSSVars(tokens, prefix = []) {
|
|
31
|
+
let css$1 = "";
|
|
32
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
33
|
+
const newPrefix = [...prefix, key];
|
|
34
|
+
if (typeof value === "string" || typeof value === "number") css$1 += `--${newPrefix.join("-")}: ${value};\n`;
|
|
35
|
+
else if (typeof value === "object" && value !== null) css$1 += tokensToCSSVars(value, newPrefix);
|
|
36
|
+
}
|
|
37
|
+
return css$1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { buildThemeTokens, c, cn, css, defineConfig, flair };
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { c, cn, css, flair } from "./utils.js";
|
|
1
|
+
import { c, cn, css, flair } from "./packages/client/src/utils.js";
|
|
2
|
+
import { buildThemeTokens, defineConfig } from "./packages/client/src/theme.js";
|
|
2
3
|
|
|
3
|
-
export { c, cn, css, flair };
|
|
4
|
+
export { buildThemeTokens, c, cn, css, defineConfig, flair };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@rollup+plugin-typescript@12.1.4_rollup@4.50.0_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js
|
|
2
|
+
var __assign = function() {
|
|
3
|
+
__assign = Object.assign || function __assign$1(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
function __spreadArray(to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) {
|
|
14
|
+
for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { __assign, __spreadArray };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { __assign, __spreadArray } from "../../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.50.0_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js";
|
|
2
|
+
|
|
3
|
+
//#region src/theme.ts
|
|
4
|
+
function defineConfig(config) {
|
|
5
|
+
return config;
|
|
6
|
+
}
|
|
7
|
+
var buildThemeTokens = function(theme, themeName) {
|
|
8
|
+
var _a;
|
|
9
|
+
var css = "";
|
|
10
|
+
var tokens = theme.tokens, selector = theme.selector;
|
|
11
|
+
if (typeof selector === "string") css += "".concat(selector, " {\n");
|
|
12
|
+
css += tokensToCSSVars(tokens, theme.prefix ? [theme.prefix] : []);
|
|
13
|
+
if (typeof selector === "string") css += "}\n";
|
|
14
|
+
else css = selector(css, themeName);
|
|
15
|
+
Object.entries((_a = theme.themes) !== null && _a !== void 0 ? _a : {}).forEach(function(_a$1) {
|
|
16
|
+
var name = _a$1[0], themeConfig = _a$1[1];
|
|
17
|
+
css += buildThemeTokens(__assign({
|
|
18
|
+
prefix: theme.prefix,
|
|
19
|
+
selector: theme.selector
|
|
20
|
+
}, themeConfig), name);
|
|
21
|
+
});
|
|
22
|
+
return css;
|
|
23
|
+
};
|
|
24
|
+
function tokensToCSSVars(tokens, prefix) {
|
|
25
|
+
if (prefix === void 0) prefix = [];
|
|
26
|
+
var css = "";
|
|
27
|
+
for (var _i = 0, _a = Object.entries(tokens); _i < _a.length; _i++) {
|
|
28
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
29
|
+
var newPrefix = __spreadArray(__spreadArray([], prefix, true), [key], false);
|
|
30
|
+
if (typeof value === "string" || typeof value === "number") css += "--".concat(newPrefix.join("-"), ": ").concat(value, ";\n");
|
|
31
|
+
else if (typeof value === "object" && value !== null) css += tokensToCSSVars(value, newPrefix);
|
|
32
|
+
}
|
|
33
|
+
return css;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { buildThemeTokens, defineConfig };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface ThemeObjItem {
|
|
2
|
+
[key: string | number]: string | ThemeObjItem;
|
|
3
|
+
}
|
|
4
|
+
export interface FlairThemeObject {
|
|
5
|
+
colors?: Record<string | number, string | ThemeObjItem>;
|
|
6
|
+
space?: Record<string | number, string | ThemeObjItem>;
|
|
7
|
+
fontSizes?: Record<string | number, string | ThemeObjItem>;
|
|
8
|
+
fonts?: Record<string | number, string | ThemeObjItem>;
|
|
9
|
+
fontWeights?: Record<string | number, string | ThemeObjItem>;
|
|
10
|
+
lineHeights?: Record<string | number, string | ThemeObjItem>;
|
|
11
|
+
letterSpacings?: Record<string | number, string | ThemeObjItem>;
|
|
12
|
+
sizes?: Record<string | number, string | ThemeObjItem>;
|
|
13
|
+
borderWidths?: Record<string | number, string | ThemeObjItem>;
|
|
14
|
+
borderStyles?: Record<string | number, string | ThemeObjItem>;
|
|
15
|
+
radii?: Record<string | number, string | ThemeObjItem>;
|
|
16
|
+
shadows?: Record<string | number, string | ThemeObjItem>;
|
|
17
|
+
zIndices?: Record<string | number, string | ThemeObjItem>;
|
|
18
|
+
transitions?: Record<string | number, string | ThemeObjItem>;
|
|
19
|
+
}
|
|
20
|
+
export type FlairThemeConfig = {
|
|
21
|
+
tokens: FlairThemeObject;
|
|
22
|
+
breakpoints?: Record<string, string | number>;
|
|
23
|
+
prefix?: string;
|
|
24
|
+
selector: string | ((content: string, themeName?: string) => string);
|
|
25
|
+
themes?: Record<string, {
|
|
26
|
+
tokens: FlairThemeObject;
|
|
27
|
+
selector?: string | ((content: string, themeName?: string) => string);
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
export declare function defineConfig<T extends FlairThemeConfig>(config: T): T;
|
|
31
|
+
export declare const buildThemeTokens: (theme: FlairThemeConfig, themeName?: string) => string;
|
|
32
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flairjs/client",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
4
4
|
"module": "./dist/esm/index.js",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"csstype": "^3.1.3",
|
|
68
68
|
"rolldown": "1.0.0-beta.37",
|
|
69
69
|
"typescript": "^5.8.3",
|
|
70
|
-
"@flairjs/core": "0.0.1-beta.
|
|
70
|
+
"@flairjs/core": "0.0.1-beta.3"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "rolldown -c",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|