lism-css 0.22.0 → 0.22.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/bin/cli.mjs +2 -2
- package/dist/lib/getLismProps.js +21 -20
- package/package.json +32 -6
- package/config/__prop_list.js +0 -44
- package/config/__props.scss +0 -25
- package/config/default-config.ts +0 -9
- package/config/defaults/__props-memo.js +0 -45
- package/config/defaults/props.ts +0 -361
- package/config/defaults/tokens.ts +0 -27
- package/config/defaults/traits.ts +0 -13
- package/config/helper/minifyHtml.ts +0 -22
- package/config/helper.test.ts +0 -238
- package/config/helper.ts +0 -73
- package/config/index.ts +0 -36
- package/config/tsconfig.json +0 -18
package/bin/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
5
5
|
import buildConfig from './build-config.js';
|
|
6
6
|
import buildCSS from './build-css.js';
|
|
7
|
-
import { objDeepMerge } from '../config/helper.js';
|
|
7
|
+
import { objDeepMerge } from '../dist/config/helper.js';
|
|
8
8
|
|
|
9
9
|
// NOTE: build-config.js を実行するための簡易CLIエントリ
|
|
10
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -16,7 +16,7 @@ const projectRoot = process.cwd();
|
|
|
16
16
|
console.log('🤖 projectRoot:', projectRoot);
|
|
17
17
|
|
|
18
18
|
// 設定ファイルのパス
|
|
19
|
-
const defaultConfigPath = path.resolve(__dirname, '../config/default-config.js');
|
|
19
|
+
const defaultConfigPath = path.resolve(__dirname, '../dist/config/default-config.js');
|
|
20
20
|
|
|
21
21
|
// ユーザー設定ファイルを検索(優先順: .js → .mjs)
|
|
22
22
|
const CONFIG_SEARCH = ['lism.config.js', 'lism.config.mjs'];
|
package/dist/lib/getLismProps.js
CHANGED
|
@@ -2,10 +2,10 @@ import { TRAITS as P, PROPS as d } from "../config/index.js";
|
|
|
2
2
|
import j from "./getLayoutProps.js";
|
|
3
3
|
import k from "./getAtomicProps.js";
|
|
4
4
|
import E from "./isPresetValue.js";
|
|
5
|
-
import
|
|
5
|
+
import x from "./isTokenValue.js";
|
|
6
6
|
import g from "./getUtilKey.js";
|
|
7
7
|
import C from "./getMaybeCssVar.js";
|
|
8
|
-
import
|
|
8
|
+
import w from "./getBpData.js";
|
|
9
9
|
import z from "./warnUnsupportedBp.js";
|
|
10
10
|
import _ from "./helper/atts.js";
|
|
11
11
|
import A from "./helper/isEmptyObj.js";
|
|
@@ -28,8 +28,8 @@ class L {
|
|
|
28
28
|
attrs = {};
|
|
29
29
|
_propConfig;
|
|
30
30
|
constructor(t) {
|
|
31
|
-
const { forwardedRef: s, class: i, className: e, primitiveClass: o, style: r = {}, _propConfig:
|
|
32
|
-
this.styles = { ...r }, this._propConfig = { ...
|
|
31
|
+
const { forwardedRef: s, class: i, className: e, primitiveClass: o, style: r = {}, _propConfig: c = {}, ...u } = t;
|
|
32
|
+
this.styles = { ...r }, this._propConfig = { ...c }, o && o.length && (this.primitiveClass = [...o]), A(u) || (this.attrs = { ...u }, this.analyzeProps()), s && (this.attrs.ref = s), this.className = this.buildClassName(e, i);
|
|
33
33
|
}
|
|
34
34
|
// 最終クラス文字列の組み立て(出力順の唯一の確定地点)
|
|
35
35
|
// 出力順: [className&class] [primitiveClass] [setClasses] [traitClasses] [uClasses] [propClasses]
|
|
@@ -68,7 +68,7 @@ class L {
|
|
|
68
68
|
let i = d[t] || null;
|
|
69
69
|
if (i === null) return;
|
|
70
70
|
this._propConfig?.[t] && (i = Object.assign({}, i, this._propConfig[t]));
|
|
71
|
-
const { base: e, ...o } =
|
|
71
|
+
const { base: e, ...o } = w(s);
|
|
72
72
|
process.env.NODE_ENV !== "production" && !i.bp && Object.keys(o).length > 0 && z(t), this.setAttrs(t, e, i), Object.keys(o).forEach((r) => {
|
|
73
73
|
i && this.setAttrs(t, o[r], i, r);
|
|
74
74
|
});
|
|
@@ -110,24 +110,25 @@ class L {
|
|
|
110
110
|
if (s == null || s === "" || s === !1) return;
|
|
111
111
|
let o = `--${t}`, r = `-${String(i.utilKey || t)}`;
|
|
112
112
|
if (e && (o = `--${t}_${e}`, r += `_${e}`), typeof s == "string" && s.startsWith(":")) {
|
|
113
|
-
|
|
113
|
+
const l = s.slice(1);
|
|
114
|
+
this.addProp(l ? `${r}:${l}` : r);
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
117
|
if (!e) {
|
|
117
|
-
const { presets:
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
118
|
+
const { presets: l, tokenClass: V, utils: y, shorthands: m } = i;
|
|
119
|
+
if (l && E(l, s)) {
|
|
120
|
+
const h = typeof s == "string" || typeof s == "number" ? String(s) : "";
|
|
121
|
+
h && this.addProp(`${r}:${h}`);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
if (V && i.token &&
|
|
124
|
-
const
|
|
125
|
-
|
|
124
|
+
if (V && i.token && x(i.token, s)) {
|
|
125
|
+
const h = typeof s == "string" || typeof s == "number" ? String(s) : "";
|
|
126
|
+
h && this.addProp(`${r}:${h}`);
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
|
-
let
|
|
129
|
-
if (y && typeof s == "string" && (
|
|
130
|
-
this.addProp(`${r}:${
|
|
129
|
+
let f = "";
|
|
130
|
+
if (y && typeof s == "string" && (f = g(y, s)), !f && m && typeof s == "string" && (f = g(m, s, !0)), f) {
|
|
131
|
+
this.addProp(`${r}:${f}`);
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
134
|
}
|
|
@@ -135,14 +136,14 @@ class L {
|
|
|
135
136
|
this.addProp(r);
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
|
-
const { prop:
|
|
139
|
+
const { prop: c, isVar: u, alwaysVar: $, token: p, bp: O } = i;
|
|
139
140
|
let a;
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
141
|
+
if (p && (typeof s == "string" || typeof s == "number") ? a = C(s, p) : typeof s == "string" || typeof s == "number" ? a = s : a = JSON.stringify(s), !e) {
|
|
142
|
+
if (u) {
|
|
142
143
|
this.addStyle(`--${t}`, a);
|
|
143
144
|
return;
|
|
144
145
|
} else if (!O && !$) {
|
|
145
|
-
this.addStyle(
|
|
146
|
+
this.addStyle(c, a);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lism-css",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "Lism CSS is a layout-first CSS framework for websites.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "ddryo",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
-
"config",
|
|
21
20
|
"config.js",
|
|
22
21
|
"config.d.ts",
|
|
23
22
|
"vite-plugin.js",
|
|
@@ -31,11 +30,11 @@
|
|
|
31
30
|
".": "./dist/index.js",
|
|
32
31
|
"./config.js": "./config.js",
|
|
33
32
|
"./config": {
|
|
34
|
-
"import": "./config/index.js",
|
|
33
|
+
"import": "./dist/config/index.js",
|
|
35
34
|
"types": "./dist/config/index.d.ts"
|
|
36
35
|
},
|
|
37
36
|
"./default-config": {
|
|
38
|
-
"import": "./config/default-config.js",
|
|
37
|
+
"import": "./dist/config/default-config.js",
|
|
39
38
|
"types": "./dist/config/default-config.d.ts"
|
|
40
39
|
},
|
|
41
40
|
"./vite-plugin": "./vite-plugin.mjs",
|
|
@@ -52,7 +51,6 @@
|
|
|
52
51
|
"import": "./dist/components/*.js",
|
|
53
52
|
"types": "./dist/components/*.d.ts"
|
|
54
53
|
},
|
|
55
|
-
"./next-js/*": "./packages/next-js/*",
|
|
56
54
|
"./astro": {
|
|
57
55
|
"import": "./packages/astro/index.ts"
|
|
58
56
|
},
|
|
@@ -98,8 +96,36 @@
|
|
|
98
96
|
"peerDependencies": {
|
|
99
97
|
"@types/react": "*",
|
|
100
98
|
"@types/react-dom": "*",
|
|
99
|
+
"autoprefixer": "^10.4.0",
|
|
100
|
+
"cssnano": "^7.0.0",
|
|
101
|
+
"glob": "^11.0.0 || ^13.0.0",
|
|
102
|
+
"postcss": "^8.4.0",
|
|
101
103
|
"react": "^18 || ^19",
|
|
102
|
-
"react-dom": "^18 || ^19"
|
|
104
|
+
"react-dom": "^18 || ^19",
|
|
105
|
+
"sass": "^1.70.0"
|
|
106
|
+
},
|
|
107
|
+
"peerDependenciesMeta": {
|
|
108
|
+
"@types/react": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@types/react-dom": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"autoprefixer": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"cssnano": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"glob": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
123
|
+
"postcss": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"sass": {
|
|
127
|
+
"optional": true
|
|
128
|
+
}
|
|
103
129
|
},
|
|
104
130
|
"sideEffects": false,
|
|
105
131
|
"scripts": {
|
package/config/__prop_list.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const _PROPS = {
|
|
2
|
-
// size
|
|
3
|
-
// mask
|
|
4
|
-
// mski: { style: 'maskImage' },
|
|
5
|
-
// mskbd: { style: 'maskBorder' },
|
|
6
|
-
// msktyp: { style: 'maskType' },
|
|
7
|
-
// mskclp: { style: 'maskClip' },
|
|
8
|
-
// mskcmp: { style: 'maskComposite' },
|
|
9
|
-
// mskmd: { style: 'maskMode' },
|
|
10
|
-
// msko: { style: 'maskOrigin' },
|
|
11
|
-
// mskp: { style: 'maskPosition' },
|
|
12
|
-
// mskr: { style: 'maskRepeat' },
|
|
13
|
-
// msksz: { style: 'maskSize' },
|
|
14
|
-
// bdtlrs: { style: 'borderTopLeftRadius', token: 'bdrs' },
|
|
15
|
-
// bdtrrs: { style: 'borderTopRightRadius', token: 'bdrs' },
|
|
16
|
-
// bdblrs: { style: 'borderBottomLeftRadius', token: 'bdrs' },
|
|
17
|
-
// bdbrrs: { style: 'borderBottomRightRadius', token: 'bdrs' },
|
|
18
|
-
// bdssrs: { style: 'borderStartStartRadius', token: 'bdrs' },
|
|
19
|
-
// bdsers: { style: 'borderStartEndRadius', token: 'bdrs' },
|
|
20
|
-
// bdesrs: { style: 'borderEndStartRadius', token: 'bdrs' },
|
|
21
|
-
// bdeers: { style: 'borderEndEndRadius', token: 'bdrs' },
|
|
22
|
-
// transition
|
|
23
|
-
//display
|
|
24
|
-
// iis: { style: 'insetInlineStart', token: 'space' },
|
|
25
|
-
// iie: { style: 'insetInlineEnd', token: 'space' },
|
|
26
|
-
// ibs: { style: 'insetBlockStart', token: 'space' },
|
|
27
|
-
// ibe: { style: 'insetBlockEnd', token: 'space' },
|
|
28
|
-
// isolation
|
|
29
|
-
// flip: {},
|
|
30
|
-
// Spacing
|
|
31
|
-
// grid
|
|
32
|
-
// transform系
|
|
33
|
-
// trf: { style: 'transform' },
|
|
34
|
-
// trfo: { style: 'transformOrigin' },
|
|
35
|
-
// float
|
|
36
|
-
// fl: { style: 'float', utils: { left: 'l', right: 'r' } },
|
|
37
|
-
// cl: { style: 'clear', utils: { left: 'l', right: 'r', both: 'b' } },
|
|
38
|
-
// object-fit
|
|
39
|
-
// objf: { style: 'objectFit', utils: { cover: 'cv', contain: 'cn' } },
|
|
40
|
-
// objp: { style: 'objectPosition' },
|
|
41
|
-
// filter
|
|
42
|
-
// fltr: { style: 'filter' }, // fltr?
|
|
43
|
-
// bdfltr: { style: 'backdropFilter' }, // bdfltr?
|
|
44
|
-
};
|
package/config/__props.scss
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
@use 'sass:string';
|
|
3
|
-
|
|
4
|
-
$props: (
|
|
5
|
-
// 'objf': (
|
|
6
|
-
// prop: 'object-fit',
|
|
7
|
-
// utilities: (
|
|
8
|
-
// 'cn': 'contain',
|
|
9
|
-
// 'cv': 'cover',
|
|
10
|
-
// ),
|
|
11
|
-
// ),
|
|
12
|
-
// 'bxsz': (
|
|
13
|
-
// prop: 'box-sizing',
|
|
14
|
-
// utilities: (
|
|
15
|
-
// 'cb': 'content-box',
|
|
16
|
-
// 'bb': 'border-box',
|
|
17
|
-
// ),
|
|
18
|
-
// ),
|
|
19
|
-
// 'iso': (
|
|
20
|
-
// prop: 'isolation',
|
|
21
|
-
// utilities: (
|
|
22
|
-
// 'i': 'isolate',
|
|
23
|
-
// ),
|
|
24
|
-
// ),
|
|
25
|
-
);
|
package/config/default-config.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
--size- → --szー
|
|
3
|
-
トークンはハイフン二つ
|
|
4
|
-
|
|
5
|
-
globalトークン、 --target-- → --target- かな
|
|
6
|
-
→ --(\w)+?-- で検索。
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
・flow, container → l--、 frame→is--では?
|
|
10
|
-
・普通のクラス設計、BEMにもどす
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// tier 1 layout・フォントは超短縮系に省略. 覚えてもらう必要があるもの。
|
|
15
|
-
// p m g flex grid ai ac ji jc lh lts
|
|
16
|
-
|
|
17
|
-
// 方向指定、一文字のもの(p,m,g) はそのまま繋げる。 start/endのみハイフン。
|
|
18
|
-
// 2文字以上のものは、すべてハイフンで繋ぐ
|
|
19
|
-
|
|
20
|
-
// tier 2 わかる程度に省略/名称変換
|
|
21
|
-
// ovwrap wbreak
|
|
22
|
-
|
|
23
|
-
// tier 3 非省略
|
|
24
|
-
// whitespace translate rotate scale order
|
|
25
|
-
// -whitespace:nowrap (-whspace?)
|
|
26
|
-
|
|
27
|
-
// wrap-anywhere と break-keep, break-all,
|
|
28
|
-
// -ovwrap:anywhere, -wordbreak:keep -wordbreak:all
|
|
29
|
-
|
|
30
|
-
// 値のキーワード単体で容易に対応するプロパティが想像できるものは、ユーティリティクラスで {-prop} 部分が省略可能とします。
|
|
31
|
-
// .underline .italic .uppercase, .-lowercase, .emphasis
|
|
32
|
-
// .relative .absolute .fixed, ...
|
|
33
|
-
// .block flex block in-block in-flex, ...
|
|
34
|
-
|
|
35
|
-
// -txd:none
|
|
36
|
-
|
|
37
|
-
// -d:none
|
|
38
|
-
// -v:visible, -v:hidden isolate
|
|
39
|
-
|
|
40
|
-
// prop省略系?→utility
|
|
41
|
-
// .u--colorBox .u--trimLeading u--srOnly
|
|
42
|
-
|
|
43
|
-
// .underline
|
|
44
|
-
// --under-offset, --under-c, --under-thickness
|
|
45
|
-
//
|
package/config/defaults/props.ts
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* isVar: 1 → クラス出力はせずstyle属性での変数出力のみ (--bdw, --keycolor など)
|
|
3
|
-
* bp: 0 → Prop-valユーティリティクラス化されなければ、style属性で出力するだけ。
|
|
4
|
-
* bp: 1 → .-prop と --prop の セットがベースにあり、.-prop_bp と .--prop_bp で ブレイクポイント指定できる。
|
|
5
|
-
* .-prop{property:var(--prop)} が基本で、ユーティリティクラスは .-prop:val{property:value} となる。
|
|
6
|
-
*
|
|
7
|
-
* ↓コンポーネント処理で使用される
|
|
8
|
-
* tokenClass: 1 → 対応するトークン値がそのまま全てユーティリティクラス化されるもの。
|
|
9
|
-
* 2 → ユーティリティクラスされ、内容は別途ファイルで記述するもの。
|
|
10
|
-
* shorthands: → コンポーネント側で短く書くための設定
|
|
11
|
-
*
|
|
12
|
-
* ↓SCSS出力で使用される
|
|
13
|
-
* alwaysVar: 1 → state変数扱い。 .-prop,[class*=-prop:] {property:var(--prop)} の base 出力となり、
|
|
14
|
-
* ユーティリティクラスは --prop をセットする形になる。
|
|
15
|
-
* 加えて BPクラスも .-prop_$bp { property: var(--prop); --prop: var(--prop_$bp) !important; } を出力し、
|
|
16
|
-
* 常に --prop が当該要素の現在値になるよう上書きされる(consumer が --prop を参照できる)。
|
|
17
|
-
* important: 1 → !important を付けて最終的に出力する
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const PLACE_PRESETS = ['start', 'center', 'end'] as const;
|
|
21
|
-
const PLACE_FX_PRESETS = ['flex-start', 'flex-end'] as const;
|
|
22
|
-
const PLACE_SHORTHANDS = { s: 'start', e: 'end', c: 'center', fs: 'flex-start', fe: 'flex-end' } as const;
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
f: { prop: 'font', presets: ['inherit'] },
|
|
26
|
-
fz: { prop: 'fontSize', token: 'fz', tokenClass: 1, bp: 1 },
|
|
27
|
-
fw: {
|
|
28
|
-
prop: 'fontWeight',
|
|
29
|
-
token: 'fw',
|
|
30
|
-
tokenClass: 1,
|
|
31
|
-
presets: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
|
|
32
|
-
},
|
|
33
|
-
ff: { prop: 'fontFamily', token: 'ff', tokenClass: 1 },
|
|
34
|
-
fs: { prop: 'fontStyle', presets: ['italic'], shorthands: { i: 'italic' } },
|
|
35
|
-
lh: {
|
|
36
|
-
prop: 'lineHeight',
|
|
37
|
-
presets: ['1'],
|
|
38
|
-
token: 'hl',
|
|
39
|
-
tokenClass: 2,
|
|
40
|
-
exUtility: { 1: '' },
|
|
41
|
-
},
|
|
42
|
-
hl: {
|
|
43
|
-
isVar: 1,
|
|
44
|
-
token: 'hl',
|
|
45
|
-
tokenClass: 0,
|
|
46
|
-
bp: 0,
|
|
47
|
-
},
|
|
48
|
-
lts: { prop: 'letterSpacing', token: 'lts', tokenClass: 1, bp: 0 },
|
|
49
|
-
ta: { prop: 'textAlign', presets: ['center', 'left', 'right'] },
|
|
50
|
-
td: { prop: 'textDecoration', utils: { none: 'none' } },
|
|
51
|
-
tt: { prop: 'textTransform', utils: { upper: 'uppercase', lower: 'lowercase' } },
|
|
52
|
-
// te: { prop: 'textEmphasis', presets: ['filled'] },
|
|
53
|
-
// tsh: { prop: 'textShadow' },
|
|
54
|
-
|
|
55
|
-
d: {
|
|
56
|
-
prop: 'display',
|
|
57
|
-
presets: ['none', 'block', 'flex', 'inline-flex', 'grid', 'inline-grid', 'inline', 'inline-block'],
|
|
58
|
-
bp: 'lg',
|
|
59
|
-
},
|
|
60
|
-
o: { prop: 'opacity', presets: ['0'], token: 'o', tokenClass: 1 },
|
|
61
|
-
v: { prop: 'visibility', presets: ['hidden'] },
|
|
62
|
-
ov: { prop: 'overflow', presets: ['hidden', 'auto', 'clip'] },
|
|
63
|
-
'ov-x': { prop: 'overflowX', presets: ['clip', 'auto', 'scroll'] },
|
|
64
|
-
'ov-y': { prop: 'overflowY', presets: ['clip', 'auto', 'scroll'] },
|
|
65
|
-
// overflow-clip-margin → safariで使えない
|
|
66
|
-
ar: {
|
|
67
|
-
prop: 'aspectRatio',
|
|
68
|
-
presets: ['21/9', '16/9', '3/2', '1/1'], // 4/3, 2/1
|
|
69
|
-
token: 'ar',
|
|
70
|
-
tokenClass: 1,
|
|
71
|
-
bp: 1,
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// size
|
|
75
|
-
w: { prop: 'width', utils: { fit: 'fit-content' }, presets: ['100%'], token: 'sz', bp: 1 },
|
|
76
|
-
h: { prop: 'height', utils: { fit: 'fit-content' }, presets: ['100%'], token: 'sz', bp: 1 },
|
|
77
|
-
'min-w': { prop: 'minWidth', presets: ['100%'], token: 'sz', bp: 1 },
|
|
78
|
-
'max-w': { prop: 'maxWidth', presets: ['100%'], token: 'sz', bp: 1 },
|
|
79
|
-
'min-h': { prop: 'minHeight', presets: ['100%'], token: 'sz', bp: 1 },
|
|
80
|
-
'max-h': { prop: 'maxHeight', presets: ['100%'], token: 'sz', bp: 1 },
|
|
81
|
-
|
|
82
|
-
contentSize: { isVar: 1, presets: ['s', 'm', 'l', 'xl'], token: 'sz' },
|
|
83
|
-
sz: { prop: 'inlineSize', token: 'sz' },
|
|
84
|
-
'min-sz': { prop: 'minInlineSize', token: 'sz' },
|
|
85
|
-
'max-sz': {
|
|
86
|
-
prop: 'maxInlineSize',
|
|
87
|
-
token: 'sz',
|
|
88
|
-
tokenClass: 1,
|
|
89
|
-
presets: ['full', 'bleed'],
|
|
90
|
-
exUtility: {
|
|
91
|
-
full: '',
|
|
92
|
-
bleed: '',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
bsz: { prop: 'blockSize', token: 'sz' },
|
|
96
|
-
'min-bsz': { prop: 'minBlockSize', token: 'sz' },
|
|
97
|
-
'max-bsz': { prop: 'maxBlockSize', token: 'sz' },
|
|
98
|
-
|
|
99
|
-
// bg
|
|
100
|
-
bg: { prop: 'background', bp: 0 },
|
|
101
|
-
bgi: { prop: 'backgroundImage' },
|
|
102
|
-
bgr: { prop: 'backgroundRepeat', presets: ['no-repeat'] },
|
|
103
|
-
bgp: { prop: 'backgroundPosition', presets: ['center'] },
|
|
104
|
-
bgsz: { prop: 'backgroundSize', presets: ['cover', 'contain'] },
|
|
105
|
-
// bga: { prop: 'backgroundAttachment' }, // fixed
|
|
106
|
-
// bgo: { prop: 'backgroundOrigin' }, // border, padding, content
|
|
107
|
-
// bgblend: { prop: 'backgroundBlendMode' },
|
|
108
|
-
// bgclip: {
|
|
109
|
-
// prop: 'backgroundClip',
|
|
110
|
-
// presets: ['text'],
|
|
111
|
-
// },
|
|
112
|
-
bgc: {
|
|
113
|
-
prop: 'backgroundColor',
|
|
114
|
-
presets: ['base', 'base-2', 'text', 'brand', 'accent', 'inherit', 'transparent'],
|
|
115
|
-
token: 'color',
|
|
116
|
-
exUtility: { inherit: { 'background-color': 'inherit' } },
|
|
117
|
-
alwaysVar: 1,
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
c: {
|
|
121
|
-
// Note: bg系(bgclip)より後にくるように。
|
|
122
|
-
prop: 'color',
|
|
123
|
-
presets: ['base', 'text', 'text-2', 'brand', 'accent', 'inherit'],
|
|
124
|
-
token: 'color',
|
|
125
|
-
exUtility: {
|
|
126
|
-
inherit: { color: 'inherit' }, // --c ではなく color で出力したい
|
|
127
|
-
// mix: {'--_c1:currentColor;--_c2:transparent;--c:color-mix(in srgb, var(--_c1) var(--_mix-c, 50%), var(--_c2))'},
|
|
128
|
-
},
|
|
129
|
-
alwaysVar: 1,
|
|
130
|
-
},
|
|
131
|
-
keycolor: { isVar: 1, token: 'color' },
|
|
132
|
-
bd: { prop: 'border', presets: ['none'] },
|
|
133
|
-
bds: { isVar: 1, presets: ['dashed', 'dotted', 'double'] },
|
|
134
|
-
bdc: {
|
|
135
|
-
isVar: 1,
|
|
136
|
-
presets: ['brand', 'accent', 'divider', 'inherit', 'transparent'],
|
|
137
|
-
utils: { current: 'currentColor' },
|
|
138
|
-
token: 'color',
|
|
139
|
-
},
|
|
140
|
-
bdw: { isVar: 1, bp: 1 }, // --bdw のみ
|
|
141
|
-
'bd-x': { prop: 'borderInline' },
|
|
142
|
-
'bd-y': { prop: 'borderBlock' },
|
|
143
|
-
'bd-s': { prop: 'borderInlineStart' },
|
|
144
|
-
'bd-e': { prop: 'borderInlineEnd' },
|
|
145
|
-
'bd-bs': { prop: 'borderBlockStart' },
|
|
146
|
-
'bd-be': { prop: 'borderBlockEnd' },
|
|
147
|
-
'bd-t': { prop: 'borderTop' },
|
|
148
|
-
'bd-b': { prop: 'borderBottom' },
|
|
149
|
-
'bd-l': { prop: 'borderLeft' },
|
|
150
|
-
'bd-r': { prop: 'borderRight' },
|
|
151
|
-
|
|
152
|
-
bdrs: {
|
|
153
|
-
prop: 'borderRadius',
|
|
154
|
-
presets: ['0'],
|
|
155
|
-
token: 'bdrs',
|
|
156
|
-
tokenClass: 1,
|
|
157
|
-
bp: 1,
|
|
158
|
-
alwaysVar: 1,
|
|
159
|
-
},
|
|
160
|
-
'bdrs-tl': { prop: 'borderTopLeftRadius', token: 'bdrs' },
|
|
161
|
-
'bdrs-tr': { prop: 'borderTopRightRadius', token: 'bdrs' },
|
|
162
|
-
'bdrs-br': { prop: 'borderBottomRightRadius', token: 'bdrs' },
|
|
163
|
-
'bdrs-bl': { prop: 'borderBottomLeftRadius', token: 'bdrs' },
|
|
164
|
-
'bdrs-ss': { prop: 'borderStartStartRadius', token: 'bdrs' },
|
|
165
|
-
'bdrs-se': { prop: 'borderStartEndRadius', token: 'bdrs' },
|
|
166
|
-
'bdrs-es': { prop: 'borderEndStartRadius', token: 'bdrs' },
|
|
167
|
-
'bdrs-ee': { prop: 'borderEndEndRadius', token: 'bdrs' },
|
|
168
|
-
|
|
169
|
-
bxsh: { prop: 'boxShadow', utils: { 0: 'none' }, token: 'bxsh', tokenClass: 1, bp: 1 },
|
|
170
|
-
|
|
171
|
-
// position
|
|
172
|
-
pos: {
|
|
173
|
-
prop: 'position',
|
|
174
|
-
presets: ['static', 'fixed', 'sticky', 'relative', 'absolute'],
|
|
175
|
-
bp: 1,
|
|
176
|
-
},
|
|
177
|
-
z: { prop: 'zIndex', presets: ['-1', '0', '1', '99'] },
|
|
178
|
-
t: { prop: 'top', utils: { 0: '0%' }, presets: ['50%', '100%'], token: 'space' },
|
|
179
|
-
l: { prop: 'left', utils: { 0: '0%' }, presets: ['50%', '100%'], token: 'space' },
|
|
180
|
-
r: { prop: 'right', utils: { 0: '0%' }, presets: ['50%', '100%'], token: 'space' },
|
|
181
|
-
b: { prop: 'bottom', utils: { 0: '0%' }, presets: ['50%', '100%'], token: 'space' },
|
|
182
|
-
i: { prop: 'inset', utils: { 0: '0%' }, token: 'space' },
|
|
183
|
-
'i-x': { prop: 'insetInline', token: 'space' },
|
|
184
|
-
'i-y': { prop: 'insetBlock', token: 'space' },
|
|
185
|
-
'i-s': { prop: 'insetInlineStart', token: 'space' },
|
|
186
|
-
'i-e': { prop: 'insetInlineEnd', token: 'space' },
|
|
187
|
-
'i-bs': { prop: 'insetBlockStart', token: 'space' },
|
|
188
|
-
'i-be': { prop: 'insetBlockEnd', token: 'space' },
|
|
189
|
-
|
|
190
|
-
// space
|
|
191
|
-
p: {
|
|
192
|
-
prop: 'padding',
|
|
193
|
-
presets: ['0'],
|
|
194
|
-
token: 'space',
|
|
195
|
-
tokenClass: 1,
|
|
196
|
-
alwaysVar: 1,
|
|
197
|
-
bp: 1,
|
|
198
|
-
},
|
|
199
|
-
px: { prop: 'paddingInline', presets: ['0'], token: 'space', tokenClass: 1, bp: 1 },
|
|
200
|
-
py: { prop: 'paddingBlock', presets: ['0'], token: 'space', tokenClass: 1, bp: 1 },
|
|
201
|
-
ps: { prop: 'paddingInlineStart', token: 'space', bp: 1 },
|
|
202
|
-
pe: { prop: 'paddingInlineEnd', token: 'space', bp: 1 },
|
|
203
|
-
pbs: { prop: 'paddingBlockStart', token: 'space', bp: 1 },
|
|
204
|
-
pbe: { prop: 'paddingBlockEnd', token: 'space', bp: 1 },
|
|
205
|
-
pl: { prop: 'paddingLeft', token: 'space', bp: 0 },
|
|
206
|
-
pr: { prop: 'paddingRight', token: 'space', bp: 0 },
|
|
207
|
-
pt: { prop: 'paddingTop', token: 'space', bp: 0 },
|
|
208
|
-
pb: { prop: 'paddingBottom', token: 'space', bp: 0 },
|
|
209
|
-
m: {
|
|
210
|
-
prop: 'margin',
|
|
211
|
-
presets: ['auto', '0'],
|
|
212
|
-
token: 'space',
|
|
213
|
-
tokenClass: 1,
|
|
214
|
-
alwaysVar: 1,
|
|
215
|
-
bp: 1,
|
|
216
|
-
},
|
|
217
|
-
mx: { prop: 'marginInline', presets: ['auto', '0'], token: 'space', tokenClass: 1, bp: 1 },
|
|
218
|
-
my: { prop: 'marginBlock', presets: ['auto', '0'], token: 'space', tokenClass: 1, bp: 1 },
|
|
219
|
-
ms: { prop: 'marginInlineStart', presets: ['auto'], token: 'space', bp: 1 },
|
|
220
|
-
me: { prop: 'marginInlineEnd', presets: ['auto'], token: 'space', bp: 1 },
|
|
221
|
-
mbs: { prop: 'marginBlockStart', token: 'space', bp: 1, presets: ['auto', '0'], tokenClass: 1 },
|
|
222
|
-
mbe: { prop: 'marginBlockEnd', presets: ['auto'], token: 'space', bp: 1 },
|
|
223
|
-
ml: { prop: 'marginLeft', token: 'space', bp: 0 },
|
|
224
|
-
mr: { prop: 'marginRight', token: 'space', bp: 0 },
|
|
225
|
-
mt: { prop: 'marginTop', token: 'space', bp: 0 },
|
|
226
|
-
mb: { prop: 'marginBottom', token: 'space', bp: 0 },
|
|
227
|
-
|
|
228
|
-
g: {
|
|
229
|
-
prop: 'gap',
|
|
230
|
-
presets: ['0', 'inherit'],
|
|
231
|
-
exUtility: { inherit: { gap: 'inherit' } },
|
|
232
|
-
token: 'space',
|
|
233
|
-
tokenClass: 1,
|
|
234
|
-
bp: 'lg',
|
|
235
|
-
},
|
|
236
|
-
cg: { prop: 'columnGap', token: 'space', bp: 0 },
|
|
237
|
-
rg: { prop: 'rowGap', token: 'space', bp: 0 },
|
|
238
|
-
cols: { isVar: 1, bp: 'lg' },
|
|
239
|
-
rows: { isVar: 1, bp: 1 },
|
|
240
|
-
|
|
241
|
-
// flex
|
|
242
|
-
fxf: { prop: 'flexFlow' },
|
|
243
|
-
fxw: { prop: 'flexWrap', presets: ['wrap'], bp: 1 },
|
|
244
|
-
fxd: { prop: 'flexDirection', presets: ['column', 'column-reverse', 'row-reverse'], bp: 1 },
|
|
245
|
-
fx: { prop: 'flex', presets: ['1'], bp: 1 },
|
|
246
|
-
fxg: { prop: 'flexGrow', presets: ['1'] },
|
|
247
|
-
fxsh: { prop: 'flexShrink', presets: ['0'] },
|
|
248
|
-
fxb: { prop: 'flexBasis', bp: 1 },
|
|
249
|
-
|
|
250
|
-
// grid
|
|
251
|
-
// gd: { prop: 'grid' },
|
|
252
|
-
gt: {
|
|
253
|
-
prop: 'gridTemplate',
|
|
254
|
-
bp: 1,
|
|
255
|
-
},
|
|
256
|
-
gta: { prop: 'gridTemplateAreas', bp: 'lg' },
|
|
257
|
-
gtc: {
|
|
258
|
-
prop: 'gridTemplateColumns',
|
|
259
|
-
presets: ['subgrid'],
|
|
260
|
-
bp: 'lg',
|
|
261
|
-
},
|
|
262
|
-
gtr: {
|
|
263
|
-
prop: 'gridTemplateRows',
|
|
264
|
-
presets: ['subgrid'],
|
|
265
|
-
bp: 'lg',
|
|
266
|
-
},
|
|
267
|
-
gaf: { prop: 'gridAutoFlow', presets: ['row', 'column'], bp: 1 }, //dense
|
|
268
|
-
gac: { prop: 'gridAutoColumns' },
|
|
269
|
-
gar: { prop: 'gridAutoRows' },
|
|
270
|
-
|
|
271
|
-
// grid item
|
|
272
|
-
ga: { prop: 'gridArea', utils: { '1/1': '1 / 1' }, bp: 'lg' },
|
|
273
|
-
gc: { prop: 'gridColumn', utils: { '1/-1': '1 / -1' }, bp: 'lg' },
|
|
274
|
-
gr: { prop: 'gridRow', utils: { '1/-1': '1 / -1' }, bp: 'lg' },
|
|
275
|
-
gcs: { prop: 'gridColumnStart' },
|
|
276
|
-
gce: { prop: 'gridColumnEnd' },
|
|
277
|
-
grs: { prop: 'gridRowStart' },
|
|
278
|
-
gre: { prop: 'gridRowEnd' },
|
|
279
|
-
|
|
280
|
-
// places
|
|
281
|
-
// -(ai|ac|ji|jc|aslf|jslf): / -$1:
|
|
282
|
-
ai: {
|
|
283
|
-
prop: 'alignItems',
|
|
284
|
-
presets: [...PLACE_PRESETS, 'stretch', ...PLACE_FX_PRESETS],
|
|
285
|
-
shorthands: PLACE_SHORTHANDS,
|
|
286
|
-
bp: 1,
|
|
287
|
-
},
|
|
288
|
-
ac: {
|
|
289
|
-
prop: 'alignContent',
|
|
290
|
-
presets: [...PLACE_PRESETS, ...PLACE_FX_PRESETS],
|
|
291
|
-
utils: { between: 'space-between' },
|
|
292
|
-
shorthands: PLACE_SHORTHANDS,
|
|
293
|
-
bp: 1,
|
|
294
|
-
},
|
|
295
|
-
ji: {
|
|
296
|
-
prop: 'justifyItems',
|
|
297
|
-
presets: [...PLACE_PRESETS, 'stretch', ...PLACE_FX_PRESETS],
|
|
298
|
-
shorthands: PLACE_SHORTHANDS,
|
|
299
|
-
bp: 1,
|
|
300
|
-
},
|
|
301
|
-
jc: {
|
|
302
|
-
prop: 'justifyContent',
|
|
303
|
-
presets: [...PLACE_PRESETS, ...PLACE_FX_PRESETS],
|
|
304
|
-
utils: { between: 'space-between' },
|
|
305
|
-
shorthands: PLACE_SHORTHANDS,
|
|
306
|
-
bp: 1,
|
|
307
|
-
},
|
|
308
|
-
pi: { prop: 'placeItems', presets: PLACE_PRESETS },
|
|
309
|
-
pc: { prop: 'placeContent', presets: PLACE_PRESETS },
|
|
310
|
-
aslf: {
|
|
311
|
-
prop: 'alignSelf',
|
|
312
|
-
presets: [...PLACE_PRESETS, 'stretch'],
|
|
313
|
-
shorthands: PLACE_SHORTHANDS,
|
|
314
|
-
},
|
|
315
|
-
jslf: {
|
|
316
|
-
prop: 'justifySelf',
|
|
317
|
-
presets: [...PLACE_PRESETS, 'stretch'],
|
|
318
|
-
shorthands: PLACE_SHORTHANDS,
|
|
319
|
-
},
|
|
320
|
-
pslf: { prop: 'placeSelf', presets: PLACE_PRESETS },
|
|
321
|
-
order: { prop: 'order', presets: ['0', '-1', '1'], bp: 1 },
|
|
322
|
-
|
|
323
|
-
// transform
|
|
324
|
-
// translate: {
|
|
325
|
-
// prop: 'translate',
|
|
326
|
-
// utils: {
|
|
327
|
-
// '-50X': '-50% 0',
|
|
328
|
-
// '-50Y': '0 -50%',
|
|
329
|
-
// '-50XY': '-50% -50%',
|
|
330
|
-
// },
|
|
331
|
-
// },
|
|
332
|
-
|
|
333
|
-
// rotate: {
|
|
334
|
-
// prop: 'rotate',
|
|
335
|
-
// utils: {
|
|
336
|
-
// [`45`]: '45deg',
|
|
337
|
-
// '-45': '-45deg',
|
|
338
|
-
// [`90`]: '90deg',
|
|
339
|
-
// '-90': '-90deg',
|
|
340
|
-
// // '180': '180deg',
|
|
341
|
-
// },
|
|
342
|
-
// },
|
|
343
|
-
|
|
344
|
-
// scale: {
|
|
345
|
-
// prop: 'scale',
|
|
346
|
-
// utils: {
|
|
347
|
-
// '-X': '-1 1',
|
|
348
|
-
// '-Y': '1 -1',
|
|
349
|
-
// '-XY': '-1 -1',
|
|
350
|
-
// },
|
|
351
|
-
// },
|
|
352
|
-
|
|
353
|
-
// others
|
|
354
|
-
ovw: { prop: 'overflowWrap', presets: ['anywhere'] },
|
|
355
|
-
whs: { prop: 'whiteSpace', presets: ['nowrap'] },
|
|
356
|
-
// wordbreak: { prop: 'wordBreak', utils: { keep: 'keep-all', all: 'break-all' } },
|
|
357
|
-
float: { prop: 'float', presets: ['left', 'right'] },
|
|
358
|
-
clear: { prop: 'clear', presets: ['both'] },
|
|
359
|
-
iso: { prop: 'isolation', presets: ['isolate'] },
|
|
360
|
-
wm: { prop: 'writingMode', presets: ['vertical-rl'], bp: 1 },
|
|
361
|
-
} as const;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
fz: ['root', 'base', '5xl', '4xl', '3xl', '2xl', 'xl', 'l', 'm', 's', 'xs', '2xs'],
|
|
3
|
-
lh: ['base', 'xs', 's', 'l'],
|
|
4
|
-
hl: ['base', 'xs', 's', 'l'],
|
|
5
|
-
lts: ['base', 's', 'l', 'xl'],
|
|
6
|
-
ff: ['base', 'accent', 'mono'],
|
|
7
|
-
fw: ['light', 'normal', 'bold'],
|
|
8
|
-
o: ['mp', 'p', 'pp', 'ppp'],
|
|
9
|
-
bdrs: ['10', '20', '30', '40', '99', 'inner'],
|
|
10
|
-
bxsh: ['10', '20', '30', '40', '50'],
|
|
11
|
-
sz: ['xs', 's', 'm', 'l', 'xl'],
|
|
12
|
-
ar: ['og'],
|
|
13
|
-
space: {
|
|
14
|
-
pre: '--s',
|
|
15
|
-
values: ['5', '10', '15', '20', '25', '30', '35', '40', '50', '60', '70', '80'],
|
|
16
|
-
},
|
|
17
|
-
c: {
|
|
18
|
-
pre: '--',
|
|
19
|
-
values: ['base', 'base-2', 'text', 'text-2', 'divider', 'link', 'brand', 'accent', 'neutral'],
|
|
20
|
-
},
|
|
21
|
-
palette: {
|
|
22
|
-
pre: '--',
|
|
23
|
-
values: ['red', 'blue', 'green', 'yellow', 'purple', 'orange', 'pink', 'gray', 'white', 'black', 'keycolor'],
|
|
24
|
-
},
|
|
25
|
-
writing: ['vertical'],
|
|
26
|
-
flow: ['s', 'l'],
|
|
27
|
-
} as const;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
isContainer: 'is--container',
|
|
3
|
-
isWrapper: 'is--wrapper',
|
|
4
|
-
isLayer: 'is--layer',
|
|
5
|
-
isBoxLink: 'is--boxLink',
|
|
6
|
-
isCoverLink: 'is--coverLink',
|
|
7
|
-
isSide: 'is--side',
|
|
8
|
-
isSkipFlow: 'is--skipFlow',
|
|
9
|
-
hasTransition: 'has--transition',
|
|
10
|
-
hasGutter: 'has--gutter',
|
|
11
|
-
hasSnap: 'has--snap',
|
|
12
|
-
hasMask: 'has--mask',
|
|
13
|
-
} as const;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* html文字列をminify
|
|
3
|
-
*/
|
|
4
|
-
const minifyHtml = (html: string) => {
|
|
5
|
-
if (!html) return '';
|
|
6
|
-
|
|
7
|
-
// 改行先に削除
|
|
8
|
-
html = html.replace(/\r?\n/g, '');
|
|
9
|
-
|
|
10
|
-
// タブ → スペース
|
|
11
|
-
html = html.replace(/\t/g, ' ');
|
|
12
|
-
|
|
13
|
-
// 複数のスペースを1つに
|
|
14
|
-
html = html.replace(/\s\s+/g, ' ');
|
|
15
|
-
|
|
16
|
-
// タグとタグの間のスペースを削除
|
|
17
|
-
html = html.replace(/> </g, '><');
|
|
18
|
-
|
|
19
|
-
return html;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default minifyHtml;
|
package/config/helper.test.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest';
|
|
2
|
-
import { objDeepMerge, arrayConvertToSet } from './helper.js';
|
|
3
|
-
|
|
4
|
-
describe('objDeepMerge', () => {
|
|
5
|
-
test('基本的なマージが正しく動作する', () => {
|
|
6
|
-
const origin = { a: 1, b: 2 };
|
|
7
|
-
const source = { b: 3, c: 4 };
|
|
8
|
-
const result = objDeepMerge(origin, source);
|
|
9
|
-
expect(result).toEqual({ a: 1, b: 3, c: 4 });
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('ネストしたオブジェクトを深くマージする', () => {
|
|
13
|
-
const origin = { a: { b: 1, c: 2 }, d: 3 };
|
|
14
|
-
const source = { a: { b: 10, e: 5 }, f: 6 };
|
|
15
|
-
const result = objDeepMerge(origin, source);
|
|
16
|
-
expect(result).toEqual({ a: { b: 10, c: 2, e: 5 }, d: 3, f: 6 });
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('深くネストしたオブジェクトを正しくマージする', () => {
|
|
20
|
-
const origin = { a: { b: { c: 1 } } };
|
|
21
|
-
const source = { a: { b: { d: 2 } } };
|
|
22
|
-
const result = objDeepMerge(origin, source);
|
|
23
|
-
expect(result).toEqual({ a: { b: { c: 1, d: 2 } } });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('originが空オブジェクトの場合、sourceをそのまま返す', () => {
|
|
27
|
-
const origin = {};
|
|
28
|
-
const source = { a: 1, b: 2 };
|
|
29
|
-
const result = objDeepMerge(origin, source);
|
|
30
|
-
expect(result).toEqual({ a: 1, b: 2 });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('sourceが空オブジェクトの場合、originをそのまま返す', () => {
|
|
34
|
-
const origin = { a: 1, b: 2 };
|
|
35
|
-
const source = {};
|
|
36
|
-
const result = objDeepMerge(origin, source);
|
|
37
|
-
expect(result).toEqual({ a: 1, b: 2 });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('originに存在しないキーが追加される', () => {
|
|
41
|
-
const origin = { a: 1 };
|
|
42
|
-
const source = { b: 2, c: 3 };
|
|
43
|
-
const result = objDeepMerge(origin, source);
|
|
44
|
-
expect(result).toEqual({ a: 1, b: 2, c: 3 });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('値がオブジェクトから配列に上書きされる', () => {
|
|
48
|
-
const origin = { a: { b: 1 } };
|
|
49
|
-
const source = { a: [1, 2, 3] };
|
|
50
|
-
const result = objDeepMerge(origin, source);
|
|
51
|
-
expect(result).toEqual({ a: [1, 2, 3] });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('値が配列からオブジェクトに上書きされる', () => {
|
|
55
|
-
const origin = { a: [1, 2, 3] };
|
|
56
|
-
const source = { a: { b: 1 } };
|
|
57
|
-
const result = objDeepMerge(origin, source);
|
|
58
|
-
expect(result).toEqual({ a: { b: 1 } });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('値がプリミティブ型の場合、sourceの値で上書きされる', () => {
|
|
62
|
-
const origin = { a: 1, b: 'hello' };
|
|
63
|
-
const source = { a: 2, b: 'world' };
|
|
64
|
-
const result = objDeepMerge(origin, source);
|
|
65
|
-
expect(result).toEqual({ a: 2, b: 'world' });
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('originValueがnullまたはundefinedの場合、sourceValueを追加する', () => {
|
|
69
|
-
const origin = { a: null, b: undefined };
|
|
70
|
-
const source = { a: 1, b: 2, c: 3 };
|
|
71
|
-
const result = objDeepMerge(origin, source);
|
|
72
|
-
expect(result).toEqual({ a: 1, b: 2, c: 3 });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('元のオブジェクトが変更されないことを確認', () => {
|
|
76
|
-
const origin = { a: 1, b: { c: 2 } };
|
|
77
|
-
const source = { b: { d: 3 } };
|
|
78
|
-
const result = objDeepMerge(origin, source);
|
|
79
|
-
expect(origin).toEqual({ a: 1, b: { c: 2 } });
|
|
80
|
-
expect(result).toEqual({ a: 1, b: { c: 2, d: 3 } });
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('複雑なネスト構造のマージ', () => {
|
|
84
|
-
const origin = {
|
|
85
|
-
level1: {
|
|
86
|
-
level2: {
|
|
87
|
-
a: 1,
|
|
88
|
-
b: 2,
|
|
89
|
-
},
|
|
90
|
-
c: 3,
|
|
91
|
-
},
|
|
92
|
-
d: 4,
|
|
93
|
-
};
|
|
94
|
-
const source = {
|
|
95
|
-
level1: {
|
|
96
|
-
level2: {
|
|
97
|
-
b: 20,
|
|
98
|
-
e: 5,
|
|
99
|
-
},
|
|
100
|
-
f: 6,
|
|
101
|
-
},
|
|
102
|
-
g: 7,
|
|
103
|
-
};
|
|
104
|
-
const result = objDeepMerge(origin, source);
|
|
105
|
-
expect(result).toEqual({
|
|
106
|
-
level1: {
|
|
107
|
-
level2: {
|
|
108
|
-
a: 1,
|
|
109
|
-
b: 20,
|
|
110
|
-
e: 5,
|
|
111
|
-
},
|
|
112
|
-
c: 3,
|
|
113
|
-
f: 6,
|
|
114
|
-
},
|
|
115
|
-
d: 4,
|
|
116
|
-
g: 7,
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
describe('arrayConvertToSet', () => {
|
|
121
|
-
test('配列をSetに変換する', () => {
|
|
122
|
-
const input = [1, 2, 3];
|
|
123
|
-
const result = arrayConvertToSet(input);
|
|
124
|
-
expect(result).toBeInstanceOf(Set);
|
|
125
|
-
expect(result).toEqual(new Set([1, 2, 3]));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('重複した要素を持つ配列をSetに変換する', () => {
|
|
129
|
-
const input = [1, 2, 2, 3, 3, 3];
|
|
130
|
-
const result = arrayConvertToSet(input);
|
|
131
|
-
expect(result).toEqual(new Set([1, 2, 3]));
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('オブジェクト内の配列をSetに変換する', () => {
|
|
135
|
-
const input = { a: [1, 2, 3], b: [4, 5, 6] };
|
|
136
|
-
const result = arrayConvertToSet(input);
|
|
137
|
-
expect(result.a).toEqual(new Set([1, 2, 3]));
|
|
138
|
-
expect(result.b).toEqual(new Set([4, 5, 6]));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test('ネストしたオブジェクト内の配列をSetに変換する', () => {
|
|
142
|
-
const input = {
|
|
143
|
-
level1: {
|
|
144
|
-
level2: {
|
|
145
|
-
arr: [1, 2, 3],
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
const result = arrayConvertToSet(input);
|
|
150
|
-
expect(result.level1.level2.arr).toEqual(new Set([1, 2, 3]));
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('配列とオブジェクトが混在する場合', () => {
|
|
154
|
-
const input = {
|
|
155
|
-
a: [1, 2, 3],
|
|
156
|
-
b: {
|
|
157
|
-
c: [4, 5, 6],
|
|
158
|
-
d: 'string',
|
|
159
|
-
},
|
|
160
|
-
e: 100,
|
|
161
|
-
};
|
|
162
|
-
const result = arrayConvertToSet(input);
|
|
163
|
-
expect(result.a).toEqual(new Set([1, 2, 3]));
|
|
164
|
-
expect(result.b.c).toEqual(new Set([4, 5, 6]));
|
|
165
|
-
expect(result.b.d).toBe('string');
|
|
166
|
-
expect(result.e).toBe(100);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test('プリミティブ値はそのまま返す', () => {
|
|
170
|
-
expect(arrayConvertToSet(1)).toBe(1);
|
|
171
|
-
expect(arrayConvertToSet('string')).toBe('string');
|
|
172
|
-
expect(arrayConvertToSet(true)).toBe(true);
|
|
173
|
-
expect(arrayConvertToSet(null)).toBe(null);
|
|
174
|
-
expect(arrayConvertToSet(undefined)).toBe(undefined);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test('空配列をSetに変換する', () => {
|
|
178
|
-
const input: never[] = [];
|
|
179
|
-
const result = arrayConvertToSet(input);
|
|
180
|
-
expect(result).toEqual(new Set());
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('空オブジェクトをそのまま返す', () => {
|
|
184
|
-
const input = {};
|
|
185
|
-
const result = arrayConvertToSet(input);
|
|
186
|
-
expect(result).toEqual({});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test('深くネストしたオブジェクトと配列の変換', () => {
|
|
190
|
-
const input = {
|
|
191
|
-
a: {
|
|
192
|
-
b: {
|
|
193
|
-
c: [1, 2, 3],
|
|
194
|
-
d: {
|
|
195
|
-
e: [4, 5, 6],
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
const result = arrayConvertToSet(input);
|
|
201
|
-
expect(result.a.b.c).toEqual(new Set([1, 2, 3]));
|
|
202
|
-
expect(result.a.b.d.e).toEqual(new Set([4, 5, 6]));
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test('配列内にオブジェクトがある場合(配列自体がSetになる)', () => {
|
|
206
|
-
const obj = { value: 1 };
|
|
207
|
-
const input = [obj, 2, 3];
|
|
208
|
-
const result = arrayConvertToSet(input);
|
|
209
|
-
expect(result).toEqual(new Set([obj, 2, 3]));
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
test('元のオブジェクトが変更されないことを確認', () => {
|
|
213
|
-
const input = { a: [1, 2, 3] };
|
|
214
|
-
const result = arrayConvertToSet(input);
|
|
215
|
-
expect(Array.isArray(input.a)).toBe(true);
|
|
216
|
-
expect(result.a).toBeInstanceOf(Set);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
test('複数階層のオブジェクトと配列が混在するケース', () => {
|
|
220
|
-
const input = {
|
|
221
|
-
colors: ['red', 'blue', 'green'],
|
|
222
|
-
sizes: {
|
|
223
|
-
small: [1, 2, 3],
|
|
224
|
-
large: [10, 20, 30],
|
|
225
|
-
},
|
|
226
|
-
config: {
|
|
227
|
-
enabled: true,
|
|
228
|
-
tags: ['tag1', 'tag2'],
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
const result = arrayConvertToSet(input);
|
|
232
|
-
expect(result.colors).toEqual(new Set(['red', 'blue', 'green']));
|
|
233
|
-
expect(result.sizes.small).toEqual(new Set([1, 2, 3]));
|
|
234
|
-
expect(result.sizes.large).toEqual(new Set([10, 20, 30]));
|
|
235
|
-
expect(result.config.enabled).toBe(true);
|
|
236
|
-
expect(result.config.tags).toEqual(new Set(['tag1', 'tag2']));
|
|
237
|
-
});
|
|
238
|
-
});
|
package/config/helper.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
type PlainObject = Record<string, unknown>;
|
|
2
|
-
|
|
3
|
-
function isObj(value: unknown): value is PlainObject {
|
|
4
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type DeepMergeResult<T, U> = T extends PlainObject
|
|
8
|
-
? U extends PlainObject
|
|
9
|
-
? {
|
|
10
|
-
[K in keyof T | keyof U]: K extends keyof U ? (K extends keyof T ? DeepMergeResult<T[K], U[K]> : U[K]) : K extends keyof T ? T[K] : never;
|
|
11
|
-
}
|
|
12
|
-
: T
|
|
13
|
-
: U extends PlainObject
|
|
14
|
-
? U
|
|
15
|
-
: T;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 深いマージを行う関数
|
|
19
|
-
* @param origin - マージ先となる元オブジェクト
|
|
20
|
-
* @param source - マージするソース(このデータに更新される)
|
|
21
|
-
* @returns マージされたオブジェクト
|
|
22
|
-
*/
|
|
23
|
-
export function objDeepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(origin: T, source: U): DeepMergeResult<T, U> {
|
|
24
|
-
const result = { ...origin } as Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
for (const key in source) {
|
|
27
|
-
if (Object.hasOwn(source, key)) {
|
|
28
|
-
const originValue = result[key];
|
|
29
|
-
const sourceValue = (source as Record<string, unknown>)[key];
|
|
30
|
-
|
|
31
|
-
if (!originValue) {
|
|
32
|
-
// origin側に存在しない新たなキーの場合はそのまま追加する
|
|
33
|
-
result[key] = sourceValue;
|
|
34
|
-
} else if (isObj(sourceValue) && isObj(originValue)) {
|
|
35
|
-
// どちらもオブジェクトの場合は再帰的にマージ
|
|
36
|
-
result[key] = objDeepMerge(originValue, sourceValue);
|
|
37
|
-
} else {
|
|
38
|
-
// どちらかのデータがobjectではない場合、そのまま上書き
|
|
39
|
-
result[key] = sourceValue;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return result as DeepMergeResult<T, U>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type DeepArrayToSet<T> = T extends unknown[] ? Set<T[number]> : T extends PlainObject ? { [K in keyof T]: DeepArrayToSet<T[K]> } : T;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* オブジェクト内の配列を再帰的にSetに変換する関数
|
|
51
|
-
* @param obj - 変換対象のオブジェクト
|
|
52
|
-
* @returns 変換されたオブジェクト
|
|
53
|
-
*/
|
|
54
|
-
export function arrayConvertToSet<T>(obj: T): DeepArrayToSet<T> {
|
|
55
|
-
// 配列の場合はSetに変換
|
|
56
|
-
if (Array.isArray(obj)) {
|
|
57
|
-
return new Set(obj) as DeepArrayToSet<T>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// オブジェクトの場合は再帰的に処理
|
|
61
|
-
if (isObj(obj)) {
|
|
62
|
-
const result: Record<string, unknown> = {};
|
|
63
|
-
for (const key in obj) {
|
|
64
|
-
if (Object.hasOwn(obj, key)) {
|
|
65
|
-
result[key] = arrayConvertToSet(obj[key]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result as DeepArrayToSet<T>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// その他の値はそのまま返す
|
|
72
|
-
return obj as DeepArrayToSet<T>;
|
|
73
|
-
}
|
package/config/index.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import defaultConfig from './default-config';
|
|
2
|
-
import userConfig from 'lism-css/config.js'; // ユーザーが上書きできる
|
|
3
|
-
import { objDeepMerge, arrayConvertToSet } from './helper';
|
|
4
|
-
|
|
5
|
-
interface Window {
|
|
6
|
-
_LISM_CSS_CONFIG_: Partial<typeof defaultConfig>;
|
|
7
|
-
}
|
|
8
|
-
declare const window: Window;
|
|
9
|
-
|
|
10
|
-
// ビルド時の設定をマージ
|
|
11
|
-
let mergedConfig = objDeepMerge(defaultConfig, userConfig);
|
|
12
|
-
|
|
13
|
-
// ブラウザ環境で window._LISM_CSS_CONFIG_ があればランタイムでマージ
|
|
14
|
-
if (typeof window !== 'undefined' && window._LISM_CSS_CONFIG_) {
|
|
15
|
-
mergedConfig = objDeepMerge(mergedConfig, window._LISM_CSS_CONFIG_);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const CONFIG = mergedConfig;
|
|
19
|
-
|
|
20
|
-
const { tokens, props, traits } = CONFIG;
|
|
21
|
-
|
|
22
|
-
const tokensWithColor = {
|
|
23
|
-
color: [...tokens.c.values, ...tokens.palette.values],
|
|
24
|
-
...tokens,
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
// 配列を Set化.
|
|
28
|
-
export const TOKENS = arrayConvertToSet(structuredClone(tokensWithColor));
|
|
29
|
-
export const PROPS = arrayConvertToSet(structuredClone(props));
|
|
30
|
-
|
|
31
|
-
// TRAITS は objDeepMerge の型推論により literal types が保持される
|
|
32
|
-
export const TRAITS = traits;
|
|
33
|
-
|
|
34
|
-
// ブレイクポイント
|
|
35
|
-
export const BREAK_POINTS = ['sm', 'md', 'lg', 'xl'] as const;
|
|
36
|
-
export const BREAK_POINTS_ALL = ['base', ...BREAK_POINTS] as const;
|
package/config/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"declarationMap": false,
|
|
6
|
-
"declarationDir": "../dist/config",
|
|
7
|
-
"emitDeclarationOnly": true,
|
|
8
|
-
"outDir": "../dist/config",
|
|
9
|
-
"rootDir": ".",
|
|
10
|
-
"composite": false,
|
|
11
|
-
"baseUrl": "..",
|
|
12
|
-
"paths": {
|
|
13
|
-
"lism-css/config.js": ["./config.js"]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"include": ["./**/*.ts"],
|
|
17
|
-
"exclude": ["**/*.test.ts"]
|
|
18
|
-
}
|