lism-css 0.9.4 → 0.10.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/README.md +5 -5
- package/bin/__build-css.cjs +54 -54
- package/bin/build-config.js +120 -120
- package/bin/build-css.js +52 -52
- package/bin/cli.mjs +33 -33
- package/config/__prop_list.js +42 -42
- package/config/__props.scss +20 -20
- package/config/default-config.ts +3 -3
- package/config/defaults/props.ts +326 -326
- package/config/defaults/states.ts +38 -38
- package/config/defaults/tokens.ts +25 -25
- package/config/helper/getSvgUrl.ts +16 -16
- package/config/helper/minifyHtml.ts +11 -11
- package/config/helper.test.ts +231 -231
- package/config/helper.ts +43 -49
- package/config/index.ts +4 -4
- package/config/tsconfig.json +16 -16
- package/dist/components/Dummy/Dummy.d.ts +6 -9
- package/dist/components/Dummy/index.js +5 -10
- package/dist/components/Group/Group.d.ts +3 -0
- package/dist/components/Group/index.d.ts +1 -0
- package/dist/components/Group/index.js +8 -0
- package/dist/components/HTML/HTML.d.ts +10 -0
- package/dist/components/Heading/Heading.d.ts +7 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/Heading/index.js +9 -0
- package/dist/components/Inline/Inline.d.ts +3 -0
- package/dist/components/Inline/index.d.ts +1 -0
- package/dist/components/Inline/index.js +8 -0
- package/dist/components/Layer/Layer.d.ts +1 -2
- package/dist/components/Layer/index.js +3 -4
- package/dist/components/Link/Link.d.ts +2 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/Link/index.js +8 -0
- package/dist/components/LinkBox/LinkBox.d.ts +3 -2
- package/dist/components/LinkBox/index.js +5 -5
- package/dist/components/Lism/Lism.d.ts +7 -8
- package/dist/components/List/List.d.ts +3 -0
- package/dist/components/List/ListItem.d.ts +3 -0
- package/dist/components/List/ListItem.js +8 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/List/index.js +8 -0
- package/dist/components/Text/Text.d.ts +3 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/Text/index.js +8 -0
- package/dist/components/atomic/Decorator/getProps.d.ts +1 -3
- package/dist/components/atomic/Decorator/getProps.js +10 -10
- package/dist/components/atomic/Icon/getProps.d.ts +1 -2
- package/dist/components/atomic/Icon/getProps.js +35 -34
- package/dist/components/atomic/Media/Media.d.ts +1 -4
- package/dist/components/atomic/Media/Media.stories.d.ts +1 -2
- package/dist/components/atomic/Media/index.js +4 -5
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +50 -36
- package/dist/config/helper.d.ts +1 -1
- package/dist/css/main.css +1 -1
- package/dist/css/main_no_layer.css +1 -1
- package/dist/css/modules/atomic.css +1 -1
- package/dist/css/modules/layout.css +1 -1
- package/dist/lib/getLismProps.d.ts +3 -2
- package/dist/lib/getMaybeCssVar.js +15 -10
- package/package.json +2 -1
- package/packages/astro/Box/Box.astro +6 -4
- package/packages/astro/Center/Center.astro +6 -3
- package/packages/astro/Cluster/Cluster.astro +6 -3
- package/packages/astro/Columns/Columns.astro +6 -3
- package/packages/astro/Container/Container.astro +7 -5
- package/packages/astro/Decorator/Decorator.astro +8 -5
- package/packages/astro/Divider/Divider.astro +5 -4
- package/packages/astro/Dummy/Dummy.astro +9 -12
- package/packages/astro/Flex/Flex.astro +6 -3
- package/packages/astro/Flow/Flow.astro +7 -3
- package/packages/astro/FluidCols/FluidCols.astro +7 -3
- package/packages/astro/Frame/Frame.astro +6 -3
- package/packages/astro/Grid/Grid.astro +6 -3
- package/packages/astro/Group/Group.astro +11 -0
- package/packages/astro/Group/index.ts +1 -0
- package/packages/astro/HTML/_index_memo.js +7 -7
- package/packages/astro/HTML/a.astro +5 -4
- package/packages/astro/HTML/button.astro +5 -4
- package/packages/astro/HTML/div.astro +5 -4
- package/packages/astro/HTML/h.astro +5 -4
- package/packages/astro/HTML/img.astro +5 -4
- package/packages/astro/HTML/li.astro +5 -4
- package/packages/astro/HTML/ol.astro +5 -4
- package/packages/astro/HTML/p.astro +5 -4
- package/packages/astro/HTML/span.astro +5 -4
- package/packages/astro/HTML/ul.astro +5 -4
- package/packages/astro/Heading/Heading.astro +13 -0
- package/packages/astro/Heading/index.ts +1 -0
- package/packages/astro/Icon/Icon.astro +13 -10
- package/packages/astro/Icon/SVG.astro +16 -16
- package/packages/astro/Inline/Inline.astro +11 -0
- package/packages/astro/Inline/index.ts +1 -0
- package/packages/astro/Layer/Layer.astro +6 -6
- package/packages/astro/Link/Link.astro +10 -0
- package/packages/astro/Link/index.ts +1 -0
- package/packages/astro/LinkBox/LinkBox.astro +9 -9
- package/packages/astro/Lism/Lism.astro +5 -7
- package/packages/astro/List/List.astro +11 -0
- package/packages/astro/List/ListItem.astro +11 -0
- package/packages/astro/List/index.ts +2 -0
- package/packages/astro/Media/Media.astro +6 -9
- package/packages/astro/SideMain/SideMain.astro +7 -3
- package/packages/astro/Spacer/Spacer.astro +6 -4
- package/packages/astro/Stack/Stack.astro +6 -3
- package/packages/astro/SwitchCols/SwitchCols.astro +7 -3
- package/packages/astro/Text/Text.astro +11 -0
- package/packages/astro/Text/index.ts +1 -0
- package/packages/astro/Wrapper/Wrapper.astro +8 -5
- package/packages/astro/env.d.ts +3 -3
- package/packages/astro/index.ts +9 -0
- package/packages/astro/tsconfig.json +10 -10
- package/packages/astro/types.ts +10 -42
- package/src/scss/__memo/_lh-auto-all.scss +12 -12
- package/src/scss/__memo/_lh-auto-h.scss +17 -17
- package/src/scss/__memo/_lh-manual.scss +27 -27
- package/src/scss/_auto_output.scss +174 -174
- package/src/scss/_mixin.scss +32 -32
- package/src/scss/_prop-config.scss +850 -850
- package/src/scss/_query.scss +26 -26
- package/src/scss/_setting.scss +6 -6
- package/src/scss/_with_layer.scss +13 -13
- package/src/scss/base/_html.scss +47 -47
- package/src/scss/base/set/_bp.scss +8 -8
- package/src/scss/base/set/_cqUnit.scss +22 -22
- package/src/scss/base/set/_gutter.scss +1 -1
- package/src/scss/base/set/_hov.scss +10 -10
- package/src/scss/base/set/_innerRs.scss +1 -1
- package/src/scss/base/set/_plain.scss +15 -15
- package/src/scss/base/set/_transition.scss +2 -2
- package/src/scss/base/tokens/_property.scss +3 -3
- package/src/scss/base/tokens/_shadow.scss +12 -12
- package/src/scss/base/tokens/_tokens.scss +77 -77
- package/src/scss/base/tokens/_typography.scss +69 -69
- package/src/scss/main_no_layer.scss +1 -1
- package/src/scss/modules/atomic/_divider.scss +4 -4
- package/src/scss/modules/atomic/_icon.scss +4 -4
- package/src/scss/modules/atomic/_spacer.scss +2 -2
- package/src/scss/modules/atomic/index.scss +0 -1
- package/src/scss/modules/layout/_center.scss +3 -3
- package/src/scss/modules/layout/_cluster.scss +3 -3
- package/src/scss/modules/layout/_columns.scss +3 -3
- package/src/scss/modules/layout/_flex.scss +4 -4
- package/src/scss/modules/layout/_flow.scss +16 -16
- package/src/scss/modules/layout/_fluidCols.scss +4 -4
- package/src/scss/modules/layout/_frame.scss +8 -8
- package/src/scss/modules/layout/_grid.scss +9 -9
- package/src/scss/modules/layout/_sideMain.scss +12 -12
- package/src/scss/modules/layout/_stack.scss +2 -2
- package/src/scss/modules/layout/_switchCols.scss +5 -5
- package/src/scss/modules/state/_container.scss +4 -4
- package/src/scss/modules/state/_layer.scss +3 -3
- package/src/scss/modules/state/_linkbox.scss +9 -9
- package/src/scss/modules/state/_vertical.scss +3 -3
- package/src/scss/modules/state/_wrapper.scss +8 -8
- package/src/scss/props/_border.scss +18 -18
- package/src/scss/props/_hover.scss +26 -26
- package/src/scss/props/_lh.scss +6 -6
- package/src/scss/props/_size.scss +7 -7
- package/src/scss/reset.scss +137 -137
- package/src/scss/utility/_cbox.scss +10 -10
- package/src/scss/utility/_clipText.scss +2 -2
- package/src/scss/utility/_hidden.scss +9 -9
- package/src/scss/utility/_itemDivider.scss +7 -7
- package/src/scss/utility/_linkExpand.scss +9 -9
- package/src/scss/utility/_snap.scss +5 -5
- package/src/scss/utility/_trimHL.scss +11 -11
- package/dist/components/Dummy/getContent.d.ts +0 -12
- package/dist/components/Dummy/getContent.js +0 -9
- package/dist/components/Dummy/texts.d.ts +0 -22
- package/dist/components/Dummy/texts.js +0 -39
- package/dist/components/Layer/getProps.d.ts +0 -5
- package/dist/components/atomic/Media/getProps.d.ts +0 -9
- package/dist/components/atomic/Media/getProps.js +0 -8
- package/dist/components/getFilterProps.d.ts +0 -10
- package/dist/components/getFilterProps.js +0 -23
- package/dist/components/getFilterProps.test.d.ts +0 -1
- package/dist/components/setMaybeTransformStyles.d.ts +0 -12
- package/dist/components/setMaybeTransformStyles.js +0 -7
- package/dist/components/setMaybeTransformStyles.test.d.ts +0 -1
- package/src/scss/modules/atomic/_media.scss +0 -3
package/config/helper.test.ts
CHANGED
|
@@ -2,237 +2,237 @@ import { describe, test, expect } from 'vitest';
|
|
|
2
2
|
import { objDeepMerge, arrayConvertToSet } from './helper.js';
|
|
3
3
|
|
|
4
4
|
describe('objDeepMerge', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
119
|
});
|
|
120
120
|
describe('arrayConvertToSet', () => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
238
|
});
|
package/config/helper.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
type PlainObject = Record<string, unknown>;
|
|
2
2
|
|
|
3
3
|
function isObj(value: unknown): value is PlainObject {
|
|
4
|
-
|
|
4
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
type DeepMergeResult<T, U> = T extends PlainObject
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
: never;
|
|
17
|
-
}
|
|
18
|
-
: T
|
|
19
|
-
: U extends PlainObject
|
|
20
|
-
? U
|
|
21
|
-
: T;
|
|
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;
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
18
|
* 深いマージを行う関数
|
|
@@ -27,27 +21,27 @@ type DeepMergeResult<T, U> = T extends PlainObject
|
|
|
27
21
|
* @returns マージされたオブジェクト
|
|
28
22
|
*/
|
|
29
23
|
export function objDeepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(origin: T, source: U): DeepMergeResult<T, U> {
|
|
30
|
-
|
|
24
|
+
const result = { ...origin } as Record<string, unknown>;
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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];
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
}
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
return result as DeepMergeResult<T, U>;
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
type DeepArrayToSet<T> = T extends unknown[] ? Set<T[number]> : T extends PlainObject ? { [K in keyof T]: DeepArrayToSet<T[K]> } : T;
|
|
@@ -58,22 +52,22 @@ type DeepArrayToSet<T> = T extends unknown[] ? Set<T[number]> : T extends PlainO
|
|
|
58
52
|
* @returns 変換されたオブジェクト
|
|
59
53
|
*/
|
|
60
54
|
export function arrayConvertToSet<T>(obj: T): DeepArrayToSet<T> {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
// 配列の場合はSetに変換
|
|
56
|
+
if (Array.isArray(obj)) {
|
|
57
|
+
return new Set(obj) as DeepArrayToSet<T>;
|
|
58
|
+
}
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
+
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
// その他の値はそのまま返す
|
|
72
|
+
return obj as DeepArrayToSet<T>;
|
|
79
73
|
}
|
package/config/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import userConfig from 'lism-css/config.js'; // ユーザーが上書きでき
|
|
|
3
3
|
import { objDeepMerge, arrayConvertToSet } from './helper';
|
|
4
4
|
|
|
5
5
|
interface Window {
|
|
6
|
-
|
|
6
|
+
_LISM_CSS_CONFIG_: Partial<typeof defaultConfig>;
|
|
7
7
|
}
|
|
8
8
|
declare const window: Window;
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ let mergedConfig = objDeepMerge(defaultConfig, userConfig);
|
|
|
12
12
|
|
|
13
13
|
// ブラウザ環境で window._LISM_CSS_CONFIG_ があればランタイムでマージ
|
|
14
14
|
if (typeof window !== 'undefined' && window._LISM_CSS_CONFIG_) {
|
|
15
|
-
|
|
15
|
+
mergedConfig = objDeepMerge(mergedConfig, window._LISM_CSS_CONFIG_);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const CONFIG = mergedConfig;
|
|
@@ -20,8 +20,8 @@ export const CONFIG = mergedConfig;
|
|
|
20
20
|
const { tokens, props, states } = CONFIG;
|
|
21
21
|
|
|
22
22
|
const tokensWithColor = {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
color: [...tokens.c.values, ...tokens.palette.values],
|
|
24
|
+
...tokens,
|
|
25
25
|
} as const;
|
|
26
26
|
|
|
27
27
|
// 配列を Set化.
|
package/config/tsconfig.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
18
|
}
|