@charcoal-ui/react 3.1.2-beta.5 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/index.d.ts +2 -12
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/performance.test.d.ts +4 -0
- package/dist/components/Checkbox/performance.test.d.ts.map +1 -0
- package/dist/components/Checkbox/snapshot.test.d.ts +2 -0
- package/dist/components/Checkbox/snapshot.test.d.ts.map +1 -0
- package/dist/index.cjs.js +35 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +35 -44
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Button/__snapshots__/index.test.tsx.snap +0 -155
- package/src/components/Button/index.tsx +37 -54
- package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +763 -0
- package/src/components/Checkbox/performance.test.tsx +30 -0
- package/src/components/Checkbox/snapshot.test.tsx +66 -0
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { ClickableElement, ClickableProps } from '../Clickable';
|
|
2
2
|
type Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation';
|
|
3
3
|
type Size = 'S' | 'M';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ボタンのスタイル
|
|
7
|
-
*/
|
|
4
|
+
export type ButtonProps = Partial<{
|
|
8
5
|
variant: Variant;
|
|
9
|
-
/**
|
|
10
|
-
* ボタンのサイズ
|
|
11
|
-
*/
|
|
12
6
|
size: Size;
|
|
13
|
-
/**
|
|
14
|
-
* 幅を最大まで広げて描画
|
|
15
|
-
*/
|
|
16
7
|
fullWidth: boolean;
|
|
17
|
-
}
|
|
18
|
-
export type ButtonProps = Partial<StyledProps> & ClickableProps;
|
|
8
|
+
}> & ClickableProps;
|
|
19
9
|
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<ClickableElement>>;
|
|
20
10
|
export default Button;
|
|
21
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAIA,OAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE1E,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAC1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAIA,OAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE1E,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAC1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;AAQrB,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,GACA,cAAc,CAAA;AAEhB,QAAA,MAAM,MAAM,0GAuBV,CAAA;AACF,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.test.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/performance.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAA;AAG/B,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAI3C,wBAAgB,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,8EAI3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.test.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/snapshot.test.tsx"],"names":[],"mappings":"AAOA,OAAO,wBAAwB,CAAA"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -238,21 +238,17 @@ var Button2 = (0, import_react2.forwardRef)(function Button3({
|
|
|
238
238
|
{
|
|
239
239
|
...rest,
|
|
240
240
|
disabled,
|
|
241
|
-
variant,
|
|
242
|
-
size,
|
|
243
|
-
fullWidth: fixed,
|
|
241
|
+
$variant: variant,
|
|
242
|
+
$size: size,
|
|
243
|
+
$fullWidth: fixed,
|
|
244
244
|
ref,
|
|
245
245
|
children
|
|
246
246
|
}
|
|
247
247
|
);
|
|
248
248
|
});
|
|
249
249
|
var Button_default = Button2;
|
|
250
|
-
var StyledButton = (0, import_styled_components4.default)(Clickable_default)
|
|
251
|
-
|
|
252
|
-
return prop !== "fullWidth";
|
|
253
|
-
}
|
|
254
|
-
}).attrs(styledProps)`
|
|
255
|
-
width: ${(p) => p.fullWidth ? "stretch" : "min-content"};
|
|
250
|
+
var StyledButton = (0, import_styled_components4.default)(Clickable_default)`
|
|
251
|
+
width: ${(p) => p.$fullWidth ? "stretch" : "min-content"};
|
|
256
252
|
display: inline-grid;
|
|
257
253
|
align-items: center;
|
|
258
254
|
justify-content: center;
|
|
@@ -261,53 +257,48 @@ var StyledButton = (0, import_styled_components4.default)(Clickable_default).wit
|
|
|
261
257
|
white-space: nowrap;
|
|
262
258
|
|
|
263
259
|
${(p) => theme((o) => [
|
|
264
|
-
o.font[p
|
|
265
|
-
o.bg[p
|
|
260
|
+
o.font[variantToFont(p.$variant)].hover.press,
|
|
261
|
+
o.bg[variantToBackgraund(p.$variant)].hover.press,
|
|
266
262
|
o.typography(14).bold.preserveHalfLeading,
|
|
267
|
-
o.padding.horizontal(p
|
|
263
|
+
o.padding.horizontal(p.$size === "M" ? 24 : 16),
|
|
268
264
|
o.disabled,
|
|
269
265
|
o.borderRadius("oval"),
|
|
270
266
|
o.outline.default.focus
|
|
271
267
|
])}
|
|
272
268
|
|
|
273
269
|
/* よく考えたらheight=32って定義が存在しないな... */
|
|
274
|
-
height: ${(p) => p
|
|
270
|
+
height: ${(p) => p.$size === "M" ? 40 : 32}px;
|
|
275
271
|
`;
|
|
276
|
-
function
|
|
277
|
-
return {
|
|
278
|
-
...props,
|
|
279
|
-
...variantToProps(props.variant),
|
|
280
|
-
...sizeToProps(props.size)
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function variantToProps(variant) {
|
|
272
|
+
function variantToBackgraund(variant) {
|
|
284
273
|
switch (variant) {
|
|
285
274
|
case "Overlay":
|
|
286
|
-
return
|
|
275
|
+
return "surface4";
|
|
287
276
|
case "Default":
|
|
288
|
-
return
|
|
277
|
+
return "surface3";
|
|
289
278
|
case "Primary":
|
|
290
|
-
return
|
|
279
|
+
return "brand";
|
|
291
280
|
case "Navigation":
|
|
292
|
-
return
|
|
281
|
+
return "surface6";
|
|
293
282
|
case "Danger":
|
|
294
|
-
return
|
|
283
|
+
return "assertive";
|
|
295
284
|
default:
|
|
296
285
|
return unreachable(variant);
|
|
297
286
|
}
|
|
298
287
|
}
|
|
299
|
-
function
|
|
300
|
-
switch (
|
|
301
|
-
case "
|
|
302
|
-
return
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
288
|
+
function variantToFont(variant) {
|
|
289
|
+
switch (variant) {
|
|
290
|
+
case "Overlay":
|
|
291
|
+
return "text5";
|
|
292
|
+
case "Default":
|
|
293
|
+
return "text2";
|
|
294
|
+
case "Primary":
|
|
295
|
+
return "text5";
|
|
296
|
+
case "Navigation":
|
|
297
|
+
return "text5";
|
|
298
|
+
case "Danger":
|
|
299
|
+
return "text5";
|
|
300
|
+
default:
|
|
301
|
+
return unreachable(variant);
|
|
311
302
|
}
|
|
312
303
|
}
|
|
313
304
|
|
|
@@ -322,7 +313,7 @@ var IconButton = (0, import_react3.forwardRef)(
|
|
|
322
313
|
}
|
|
323
314
|
);
|
|
324
315
|
var IconButton_default = IconButton;
|
|
325
|
-
var StyledIconButton = (0, import_styled_components5.default)(Clickable_default).attrs(
|
|
316
|
+
var StyledIconButton = (0, import_styled_components5.default)(Clickable_default).attrs(styledProps)`
|
|
326
317
|
user-select: none;
|
|
327
318
|
|
|
328
319
|
width: ${(p) => p.width}px;
|
|
@@ -339,14 +330,14 @@ var StyledIconButton = (0, import_styled_components5.default)(Clickable_default)
|
|
|
339
330
|
o.outline.default.focus
|
|
340
331
|
])}
|
|
341
332
|
`;
|
|
342
|
-
function
|
|
333
|
+
function styledProps(props) {
|
|
343
334
|
return {
|
|
344
335
|
...props,
|
|
345
|
-
...
|
|
346
|
-
...
|
|
336
|
+
...variantToProps(props.variant),
|
|
337
|
+
...sizeToProps(props.size)
|
|
347
338
|
};
|
|
348
339
|
}
|
|
349
|
-
function
|
|
340
|
+
function variantToProps(variant) {
|
|
350
341
|
switch (variant) {
|
|
351
342
|
case "Default":
|
|
352
343
|
return { font: "text3", background: "transparent" };
|
|
@@ -354,7 +345,7 @@ function variantToProps2(variant) {
|
|
|
354
345
|
return { font: "text5", background: "surface4" };
|
|
355
346
|
}
|
|
356
347
|
}
|
|
357
|
-
function
|
|
348
|
+
function sizeToProps(size) {
|
|
358
349
|
switch (size) {
|
|
359
350
|
case "XS":
|
|
360
351
|
return {
|