lism-css 0.8.3 → 0.8.4

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.
Files changed (148) hide show
  1. package/bin/script-build-css.js +1 -1
  2. package/config/default-config.ts +9 -0
  3. package/config/defaults/{props.js → props.ts} +4 -4
  4. package/config/defaults/{states.js → states.ts} +2 -2
  5. package/config/defaults/{tokens.js → tokens.ts} +1 -1
  6. package/config/helper/{getSvgUrl.js → getSvgUrl.ts} +1 -3
  7. package/config/helper/{minifyHtml.js → minifyHtml.ts} +1 -1
  8. package/config/helper.test.ts +238 -0
  9. package/config/helper.ts +79 -0
  10. package/config/{index.js → index.ts} +17 -4
  11. package/config/tsconfig.json +18 -0
  12. package/config.d.ts +2 -0
  13. package/config.js +1 -1
  14. package/dist/components/Box/Box.d.ts +4 -1
  15. package/dist/components/Box/index.d.ts +1 -1
  16. package/dist/components/Center/Center.d.ts +4 -1
  17. package/dist/components/Center/index.d.ts +1 -1
  18. package/dist/components/Cluster/Cluster.d.ts +4 -1
  19. package/dist/components/Cluster/index.js +2 -2
  20. package/dist/components/Columns/Columns.d.ts +4 -1
  21. package/dist/components/Container/Container.d.ts +6 -4
  22. package/dist/components/Dummy/Dummy.d.ts +10 -8
  23. package/dist/components/Dummy/getContent.d.ts +13 -7
  24. package/dist/components/Dummy/getContent.js +7 -6
  25. package/dist/components/Dummy/index.js +8 -7
  26. package/dist/components/Flex/Flex.d.ts +4 -1
  27. package/dist/components/Flow/Flow.d.ts +4 -1
  28. package/dist/components/Flow/index.d.ts +1 -1
  29. package/dist/components/FluidCols/FluidCols.d.ts +4 -1
  30. package/dist/components/Frame/Frame.d.ts +4 -1
  31. package/dist/components/Grid/Grid.d.ts +4 -1
  32. package/dist/components/HTML/HTML.d.ts +16 -13
  33. package/dist/components/HTML/index.d.ts +13 -13
  34. package/dist/components/HTML/index.js +3 -3
  35. package/dist/components/HTML/index2.js +30 -29
  36. package/dist/components/Layer/Layer.d.ts +6 -1
  37. package/dist/components/Layer/Layer.test.d.ts +1 -0
  38. package/dist/components/Layer/getProps.d.ts +5 -1
  39. package/dist/components/LinkBox/LinkBox.d.ts +4 -4
  40. package/dist/components/Lism/Lism.d.ts +28 -7
  41. package/dist/components/Lism/Lism.stories.d.ts +667 -0
  42. package/dist/components/Lism/Lism.test.d.ts +1 -0
  43. package/dist/components/Lism/index.d.ts +1 -3
  44. package/dist/components/Lism/index.js +3 -3
  45. package/dist/components/SideMain/SideMain.d.ts +4 -1
  46. package/dist/components/Stack/Stack.d.ts +4 -1
  47. package/dist/components/SwitchCols/SwitchCols.d.ts +4 -1
  48. package/dist/components/Wrapper/Wrapper.d.ts +6 -4
  49. package/dist/components/atomic/Decorator/Decorator.d.ts +2 -1
  50. package/dist/components/atomic/Decorator/getProps.d.ts +10 -12
  51. package/dist/components/atomic/Decorator/getProps.js +10 -9
  52. package/dist/components/atomic/Divider/Divider.d.ts +2 -1
  53. package/dist/components/atomic/Divider/getProps.d.ts +2 -7
  54. package/dist/components/atomic/Divider/getProps.js +8 -7
  55. package/dist/components/atomic/Icon/Icon.d.ts +4 -3
  56. package/dist/components/atomic/Icon/SVG.d.ts +8 -9
  57. package/dist/components/atomic/Icon/getProps.d.ts +21 -12
  58. package/dist/components/atomic/Icon/getProps.js +31 -25
  59. package/dist/components/atomic/Icon/index.js +9 -8
  60. package/dist/components/atomic/Icon/presets.d.ts +2 -2
  61. package/dist/components/atomic/Media/Media.d.ts +2 -1
  62. package/dist/components/atomic/Media/getProps.d.ts +9 -1
  63. package/dist/components/atomic/Media/getProps.js +5 -6
  64. package/dist/components/atomic/Media/index.js +3 -3
  65. package/dist/components/atomic/Spacer/Spacer.d.ts +2 -1
  66. package/dist/components/atomic/Spacer/getProps.d.ts +2 -7
  67. package/dist/components/atomic/Spacer/getProps.js +8 -2
  68. package/dist/components/getFilterProps.d.ts +10 -1
  69. package/dist/components/getFilterProps.js +15 -5
  70. package/dist/components/getFilterProps.test.d.ts +1 -0
  71. package/dist/components/index.js +44 -48
  72. package/dist/components/setMaybeTransformStyles.d.ts +12 -1
  73. package/dist/components/setMaybeTransformStyles.js +4 -4
  74. package/dist/components/setMaybeTransformStyles.test.d.ts +1 -0
  75. package/dist/config/default-config.d.ts +838 -0
  76. package/dist/config/defaults/props.d.ts +797 -0
  77. package/dist/config/defaults/states.d.ts +29 -0
  78. package/dist/config/defaults/tokens.d.ts +28 -0
  79. package/dist/config/helper/getSvgUrl.d.ts +5 -0
  80. package/dist/config/helper/minifyHtml.d.ts +5 -0
  81. package/dist/config/helper.d.ts +21 -0
  82. package/dist/config/helper.js +14 -18
  83. package/dist/config/index.d.ts +1675 -0
  84. package/dist/config/index.js +15 -11
  85. package/dist/css/base/set.css +1 -1
  86. package/dist/css/base.css +1 -1
  87. package/dist/css/main.css +1 -1
  88. package/dist/css/main_no_layer.css +1 -1
  89. package/dist/css/reset.css +1 -1
  90. package/dist/lib/LismPropsData.test.d.ts +1 -0
  91. package/dist/lib/getBpData.d.ts +9 -1
  92. package/dist/lib/getBpData.js +16 -10
  93. package/dist/lib/getBpData.test.d.ts +1 -0
  94. package/dist/lib/getLayoutProps.d.ts +22 -1
  95. package/dist/lib/getLayoutProps.js +19 -19
  96. package/dist/lib/getLayoutProps.test.d.ts +1 -0
  97. package/dist/lib/getLismProps.d.ts +77 -2
  98. package/dist/lib/getLismProps.js +122 -107
  99. package/dist/lib/getLismProps.test.d.ts +1 -0
  100. package/dist/lib/getMaybeCssVar.d.ts +5 -3
  101. package/dist/lib/getMaybeCssVar.js +15 -15
  102. package/dist/lib/getMaybeCssVar.test.d.ts +1 -0
  103. package/dist/lib/getMaybeTokenValue.d.ts +10 -1
  104. package/dist/lib/getMaybeTokenValue.js +21 -21
  105. package/dist/lib/getMaybeTokenValue.test.d.ts +1 -0
  106. package/dist/lib/getUtilKey.d.ts +7 -1
  107. package/dist/lib/getUtilKey.js +6 -6
  108. package/dist/lib/getUtilKey.test.d.ts +1 -0
  109. package/dist/lib/helper/atts.d.ts +6 -3
  110. package/dist/lib/helper/atts.test.d.ts +1 -0
  111. package/dist/lib/helper/filterEmptyObj.d.ts +20 -1
  112. package/dist/lib/helper/filterEmptyObj.js +6 -5
  113. package/dist/lib/helper/filterEmptyObj.test.d.ts +1 -0
  114. package/dist/lib/helper/hasSomeKeys.d.ts +1 -1
  115. package/dist/lib/helper/isNumStr.d.ts +4 -1
  116. package/dist/lib/helper/isNumStr.test.d.ts +1 -0
  117. package/dist/lib/helper/objMap.d.ts +8 -1
  118. package/dist/lib/helper/objMap.test.d.ts +1 -0
  119. package/dist/lib/helper/splitWithComma.d.ts +1 -1
  120. package/dist/lib/helper/splitWithComma.test.d.ts +1 -0
  121. package/dist/lib/isPresetValue.d.ts +3 -1
  122. package/dist/lib/isPresetValue.js +10 -3
  123. package/dist/lib/isPresetValue.test.d.ts +1 -0
  124. package/dist/lib/isTokenValue.d.ts +1 -1
  125. package/dist/lib/isTokenValue.js +24 -7
  126. package/dist/lib/isTokenValue.test.d.ts +1 -0
  127. package/dist/lib/types/LayoutProps.d.ts +50 -0
  128. package/dist/lib/types/PropValueTypes.d.ts +83 -0
  129. package/dist/lib/types/PropValueTypes.spec-d.d.ts +1 -0
  130. package/dist/lib/types/ResponsiveProps.d.ts +50 -0
  131. package/dist/lib/types/ResponsiveProps.spec-d.d.ts +1 -0
  132. package/dist/lib/types/StateProps.d.ts +27 -0
  133. package/dist/lib/types/StateProps.spec-d.d.ts +1 -0
  134. package/dist/lib/types/utils.d.ts +79 -0
  135. package/dist/lib/types/utils.spec-d.d.ts +1 -0
  136. package/dist/lib/types.d.ts +2 -0
  137. package/package.json +30 -11
  138. package/src/scss/_auto_output.scss +2 -1
  139. package/src/scss/_with_layer.scss +1 -0
  140. package/src/scss/base/_base.scss +2 -2
  141. package/src/scss/base/set/_plain.scss +1 -0
  142. package/src/scss/reset.scss +1 -1
  143. package/config/default-config.js +0 -9
  144. package/config/helper.js +0 -67
  145. package/dist/components/Lism/Link.d.ts +0 -1
  146. package/dist/components/Lism/Link.js +0 -8
  147. package/dist/components/Lism/Text.d.ts +0 -1
  148. package/dist/components/Lism/Text.js +0 -8
@@ -1,6 +1,6 @@
1
1
  import buildCSS from './build-css.js';
2
2
  import buildConfig from './build-config.js';
3
- import { CONFIG } from '../config/index.js';
3
+ import { CONFIG } from '../config/index.ts';
4
4
 
5
5
  await buildConfig(CONFIG);
6
6
  await buildCSS();
@@ -0,0 +1,9 @@
1
+ import TOKENS from './defaults/tokens';
2
+ import PROPS from './defaults/props';
3
+ import STATES from './defaults/states';
4
+
5
+ export default {
6
+ tokens: TOKENS,
7
+ props: PROPS,
8
+ states: STATES,
9
+ } as const;
@@ -15,9 +15,9 @@
15
15
  * important: 1 → !important を付けて最終的に出力する
16
16
  */
17
17
 
18
- const PLACE_PRESETS = ['start', 'center', 'end'];
19
- const PLACE_UTILS = { 'flex-s': 'flex-start', 'flex-e': 'flex-end' };
20
- const PLACE_SHORTHANDS = { s: 'start', e: 'end', c: 'center', fs: 'flex-s', fe: 'flex-e' };
18
+ const PLACE_PRESETS = ['start', 'center', 'end'] as const;
19
+ const PLACE_UTILS = { 'flex-s': 'flex-start', 'flex-e': 'flex-end' } as const;
20
+ const PLACE_SHORTHANDS = { s: 'start', e: 'end', c: 'center', fs: 'flex-s', fe: 'flex-e' } as const;
21
21
 
22
22
  export default {
23
23
  f: { prop: 'font', presets: ['inherit'] },
@@ -364,4 +364,4 @@ export default {
364
364
  float: { prop: 'float', presets: ['left', 'right'] },
365
365
  clear: { prop: 'clear', presets: ['both'] },
366
366
  isolation: { prop: 'isolation', presets: ['isolate'] },
367
- };
367
+ } as const;
@@ -25,7 +25,7 @@ export default {
25
25
  setMask: {
26
26
  // 'set-mask',
27
27
  className: 'set-mask',
28
- setStyles: (propVal) => {
28
+ setStyles: (propVal: string) => {
29
29
  // minify化
30
30
  // propVal = minifyHtml(propVal);
31
31
  let imgUrl = propVal;
@@ -40,4 +40,4 @@ export default {
40
40
  setPlain: 'set-plain',
41
41
  // setRevert: 'set-revert',
42
42
  setInnerRs: 'set-innerRs',
43
- };
43
+ } as const;
@@ -24,4 +24,4 @@ export default {
24
24
  },
25
25
  writing: ['vertical'],
26
26
  flow: ['s', 'l'],
27
- };
27
+ } as const;
@@ -1,9 +1,7 @@
1
- // import minifyHtml from './minifyHtml.js';
2
-
3
1
  /**
4
2
  * svgをcssの image url に変換
5
3
  */
6
- const getSvgUrl = (svg, encode = '') => {
4
+ const getSvgUrl = (svg: string, encode = '') => {
7
5
  if (!svg) return '';
8
6
 
9
7
  // minify化
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * html文字列をminify
3
3
  */
4
- const minifyHtml = (html) => {
4
+ const minifyHtml = (html:string) => {
5
5
  if (!html) return '';
6
6
 
7
7
  // 改行先に削除
@@ -0,0 +1,238 @@
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
+ });
@@ -0,0 +1,79 @@
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
11
+ ? K extends keyof T
12
+ ? DeepMergeResult<T[K], U[K]>
13
+ : U[K]
14
+ : K extends keyof T
15
+ ? T[K]
16
+ : never;
17
+ }
18
+ : T
19
+ : U extends PlainObject
20
+ ? U
21
+ : T;
22
+
23
+ /**
24
+ * 深いマージを行う関数
25
+ * @param origin - マージ先となる元オブジェクト
26
+ * @param source - マージするソース(このデータに更新される)
27
+ * @returns マージされたオブジェクト
28
+ */
29
+ export function objDeepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(origin: T, source: U): DeepMergeResult<T, U> {
30
+ const result = { ...origin } as Record<string, unknown>;
31
+
32
+ for (const key in source) {
33
+ if (Object.hasOwn(source, key)) {
34
+ const originValue = result[key];
35
+ const sourceValue = (source as Record<string, unknown>)[key];
36
+
37
+ if (!originValue) {
38
+ // origin側に存在しない新たなキーの場合はそのまま追加する
39
+ result[key] = sourceValue;
40
+ } else if (isObj(sourceValue) && isObj(originValue)) {
41
+ // どちらもオブジェクトの場合は再帰的にマージ
42
+ result[key] = objDeepMerge(originValue, sourceValue);
43
+ } else {
44
+ // どちらかのデータがobjectではない場合、そのまま上書き
45
+ result[key] = sourceValue;
46
+ }
47
+ }
48
+ }
49
+
50
+ return result as DeepMergeResult<T, U>;
51
+ }
52
+
53
+ type DeepArrayToSet<T> = T extends unknown[] ? Set<T[number]> : T extends PlainObject ? { [K in keyof T]: DeepArrayToSet<T[K]> } : T;
54
+
55
+ /**
56
+ * オブジェクト内の配列を再帰的にSetに変換する関数
57
+ * @param obj - 変換対象のオブジェクト
58
+ * @returns 変換されたオブジェクト
59
+ */
60
+ export function arrayConvertToSet<T>(obj: T): DeepArrayToSet<T> {
61
+ // 配列の場合はSetに変換
62
+ if (Array.isArray(obj)) {
63
+ return new Set(obj) as DeepArrayToSet<T>;
64
+ }
65
+
66
+ // オブジェクトの場合は再帰的に処理
67
+ if (isObj(obj)) {
68
+ const result: Record<string, unknown> = {};
69
+ for (const key in obj) {
70
+ if (Object.hasOwn(obj, key)) {
71
+ result[key] = arrayConvertToSet(obj[key]);
72
+ }
73
+ }
74
+ return result as DeepArrayToSet<T>;
75
+ }
76
+
77
+ // その他の値はそのまま返す
78
+ return obj as DeepArrayToSet<T>;
79
+ }
@@ -1,6 +1,11 @@
1
- import defaultConfig from './default-config.js';
1
+ import defaultConfig from './default-config';
2
2
  import userConfig from 'lism-css/config.js'; // ユーザーが上書きできる
3
- import { objDeepMerge, arrayConvertToSet } from './helper.js';
3
+ import { objDeepMerge, arrayConvertToSet } from './helper';
4
+
5
+ interface Window {
6
+ _LISM_CSS_CONFIG_: Partial<typeof defaultConfig>;
7
+ }
8
+ declare const window: Window;
4
9
 
5
10
  // ビルド時の設定をマージ
6
11
  let mergedConfig = objDeepMerge(defaultConfig, userConfig);
@@ -14,10 +19,18 @@ export const CONFIG = mergedConfig;
14
19
 
15
20
  const { tokens, props, states } = CONFIG;
16
21
 
22
+ const tokensWithColor = {
23
+ color: [...tokens.c.values, ...tokens.palette.values],
24
+ ...tokens,
25
+ } as const;
26
+
17
27
  // 配列を Set化.
18
- export const TOKENS = arrayConvertToSet(structuredClone(tokens));
28
+ export const TOKENS = arrayConvertToSet(structuredClone(tokensWithColor));
19
29
  export const PROPS = arrayConvertToSet(structuredClone(props));
30
+
31
+ // STATES は objDeepMerge の型推論により literal types が保持される
20
32
  export const STATES = states;
21
33
 
22
34
  // ブレイクポイント
23
- export const BREAK_POINTS = ['sm', 'md', 'lg', 'xl'];
35
+ export const BREAK_POINTS = ['sm', 'md', 'lg', 'xl'] as const;
36
+ export const BREAK_POINTS_ALL = ['base', ...BREAK_POINTS] as const;
@@ -0,0 +1,18 @@
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
+ }
package/config.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
package/config.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // ユーザーのプロジェクトファイルから上書きできる設定
2
- export default {};
2
+ export default /** @type {const} */ ({});
@@ -1 +1,4 @@
1
- export default function Box(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { BoxProps } from '../../lib/types/LayoutProps';
4
+ export default function Box<T extends ElementType = 'div'>(props: LayoutComponentProps<T, BoxProps>): import("react").JSX.Element;
@@ -1 +1 @@
1
- export { default as Box } from './Box.jsx';
1
+ export { default as Box } from './Box';
@@ -1 +1,4 @@
1
- export default function Center(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { CenterProps } from '../../lib/types/LayoutProps';
4
+ export default function Center<T extends ElementType = 'div'>(props: LayoutComponentProps<T, CenterProps>): import("react").JSX.Element;
@@ -1 +1 @@
1
- export { default as Center } from './Center.jsx';
1
+ export { default as Center } from './Center';
@@ -1 +1,4 @@
1
- export default function Flex(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { ClusterProps } from '../../lib/types/LayoutProps';
4
+ export default function Cluster<T extends ElementType = 'div'>(props: LayoutComponentProps<T, ClusterProps>): import("react").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import o from "../Lism/index.js";
3
- function u(r) {
3
+ function m(r) {
4
4
  return /* @__PURE__ */ t(o, { layout: "cluster", ...r });
5
5
  }
6
6
  export {
7
- u as default
7
+ m as default
8
8
  };
@@ -1 +1,4 @@
1
- export default function Columns(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { ColumnsProps } from '../../lib/types/LayoutProps';
4
+ export default function Columns<T extends ElementType = 'div'>(props: LayoutComponentProps<T, ColumnsProps>): import("react").JSX.Element;
@@ -1,4 +1,6 @@
1
- export default function Container({ size, ...props }: {
2
- [x: string]: any;
3
- size: any;
4
- }): import("react").JSX.Element;
1
+ import { LismComponentProps } from '../Lism';
2
+ type ContainerProps = LismComponentProps & {
3
+ size?: LismComponentProps['isWrapper'];
4
+ };
5
+ export default function Container({ size, ...props }: ContainerProps): import("react").JSX.Element;
6
+ export {};
@@ -1,8 +1,10 @@
1
- export default function Dummy({ tag, pre, length, lang, offset, ...props }: {
2
- [x: string]: any;
3
- tag?: string | undefined;
4
- pre?: string | undefined;
5
- length?: string | undefined;
6
- lang?: string | undefined;
7
- offset?: number | undefined;
8
- }): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LismComponentProps } from '../Lism';
3
+ type DummyProps<T extends ElementType = 'p'> = LismComponentProps<T> & {
4
+ pre?: string;
5
+ length?: string;
6
+ lang?: 'ja' | 'en' | 'ar';
7
+ offset?: number;
8
+ };
9
+ export default function Dummy<T extends ElementType = 'p'>({ pre, length, lang, offset, ...props }: DummyProps<T>): import("react").JSX.Element;
10
+ export {};
@@ -1,7 +1,13 @@
1
- export default function getContent({ tag, pre, length, lang, offset }: {
2
- tag?: string | undefined;
3
- pre?: string | undefined;
4
- length?: string | undefined;
5
- lang?: string | undefined;
6
- offset?: number | undefined;
7
- }): any;
1
+ import { ElementType } from 'react';
2
+ import { default as TEXTS } from './texts';
3
+ type Lang = keyof typeof TEXTS;
4
+ type Length = string;
5
+ interface GetContentOptions {
6
+ tag?: ElementType;
7
+ pre?: string;
8
+ length?: Length;
9
+ lang?: Lang;
10
+ offset?: number;
11
+ }
12
+ export default function getContent({ tag, pre, length, lang, offset }: GetContentOptions): string;
13
+ export {};
@@ -1,9 +1,10 @@
1
- import s from "./texts.js";
2
- const o = (e) => e.split(/([,.、。])/).filter((i) => i !== "").reduce((i, r, n, l) => (n % 2 === 0 && i.push(r + (l[n + 1] || "")), i), []);
3
- function c({ tag: e = "p", pre: i = "", length: r = "m", lang: n = "en", offset: l = 0 }) {
4
- let t = s[n][r] || "";
5
- return e === "ul" || e === "ol" ? (t = o(t).map((u) => `<li>${u.trim()}</li>`).join(""), i && (t = `<li>${i}</li>` + t)) : (l && (t = o(t).slice(l).join("").trim(), t = t.charAt(0).toUpperCase() + t.slice(1)), i && (t = i + t)), t;
1
+ import c from "./texts.js";
2
+ const u = (n) => n.split(/([,.、。])/).filter((i) => i !== "").reduce((i, o, e, l) => (e % 2 === 0 && i.push(o + (l[e + 1] || "")), i), []);
3
+ function m({ tag: n = "p", pre: i = "", length: o = "m", lang: e = "en", offset: l = 0 }) {
4
+ const r = c[e];
5
+ let t = (r == null ? void 0 : r[o]) || "";
6
+ return n === "ul" || n === "ol" ? (t = u(t).map((s) => `<li>${s.trim()}</li>`).join(""), i && (t = `<li>${i}</li>` + t)) : (l && (t = u(t).slice(l).join("").trim(), t = t.charAt(0).toUpperCase() + t.slice(1)), i && (t = i + t)), t;
6
7
  }
7
8
  export {
8
- c as default
9
+ m as default
9
10
  };
@@ -1,12 +1,13 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import u from "./getContent.js";
2
+ import s from "./getContent.js";
3
3
  import e from "../Lism/index.js";
4
- function h({ tag: t = "p", pre: r = "", length: i = "m", lang: o = "en", offset: s = 0, ...m }) {
5
- if (t === "img")
6
- return /* @__PURE__ */ n(e, { tag: "img", src: "https://cdn.lism-css.com/dummy-image.jpg", width: "600", height: "400", alt: "", ...m });
7
- const c = u({ tag: t, pre: r, lang: o, length: i, offset: s });
8
- return /* @__PURE__ */ n(e, { tag: t, ...m, dangerouslySetInnerHTML: { __html: c } });
4
+ function d({ pre: i = "", length: a = "m", lang: o = "en", offset: r = 0, ...t }) {
5
+ const m = t.as || t.tag || "p";
6
+ if (m === "img")
7
+ return /* @__PURE__ */ n(e, { as: "img", src: "https://cdn.lism-css.com/dummy-image.jpg", width: 600, height: 400, alt: "", ...t });
8
+ const g = s({ tag: m, pre: i, lang: o, length: a, offset: r });
9
+ return /* @__PURE__ */ n(e, { ...t, dangerouslySetInnerHTML: { __html: g } });
9
10
  }
10
11
  export {
11
- h as default
12
+ d as default
12
13
  };
@@ -1 +1,4 @@
1
- export default function Flex(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { FlexProps } from '../../lib/types/LayoutProps';
4
+ export default function Flex<T extends ElementType = 'div'>(props: LayoutComponentProps<T, FlexProps>): import("react").JSX.Element;
@@ -1 +1,4 @@
1
- export default function Flow(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { FlowLayoutProps } from '../../lib/types/LayoutProps';
4
+ export default function Flow<T extends ElementType = 'div'>(props: LayoutComponentProps<T, FlowLayoutProps>): import("react").JSX.Element;
@@ -1 +1 @@
1
- export { default as Flow } from './Flow.jsx';
1
+ export { default as Flow } from './Flow';
@@ -1 +1,4 @@
1
- export default function FluidCols(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { FluidColsProps } from '../../lib/types/LayoutProps';
4
+ export default function FluidCols<T extends ElementType = 'div'>(props: LayoutComponentProps<T, FluidColsProps>): import("react").JSX.Element;
@@ -1 +1,4 @@
1
- export default function Frame(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { FrameProps } from '../../lib/types/LayoutProps';
4
+ export default function Frame<T extends ElementType = 'div'>(props: LayoutComponentProps<T, FrameProps>): import("react").JSX.Element;
@@ -1 +1,4 @@
1
- export default function Grid(props: any): import("react").JSX.Element;
1
+ import { ElementType } from 'react';
2
+ import { LayoutComponentProps } from '../Lism';
3
+ import { GridLayoutProps } from '../../lib/types/LayoutProps';
4
+ export default function Grid<T extends ElementType = 'div'>(props: LayoutComponentProps<T, GridLayoutProps>): import("react").JSX.Element;