@charcoal-ui/react 3.1.2-beta.6 → 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.
@@ -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
- interface StyledProps {
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;AAErB,UAAU,WAAW;IACnB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,cAAc,CAAA;AAE/D,QAAA,MAAM,MAAM,0GAuBV,CAAA;AACF,eAAe,MAAM,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,4 @@
1
+ import 'jest-styled-components';
2
+ import renderder from 'react-test-renderer';
3
+ export declare function render(children: JSX.Element): renderder.ReactTestRendererJSON | renderder.ReactTestRendererJSON[] | null;
4
+ //# sourceMappingURL=performance.test.d.ts.map
@@ -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,2 @@
1
+ import 'jest-styled-components';
2
+ //# sourceMappingURL=snapshot.test.d.ts.map
@@ -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).withConfig({
251
- shouldForwardProp(prop) {
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.font].hover.press,
265
- o.bg[p.background].hover.press,
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.padding),
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.height}px;
270
+ height: ${(p) => p.$size === "M" ? 40 : 32}px;
275
271
  `;
276
- function styledProps(props) {
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 { font: "text5", background: "surface4" };
275
+ return "surface4";
287
276
  case "Default":
288
- return { font: "text2", background: "surface3" };
277
+ return "surface3";
289
278
  case "Primary":
290
- return { font: "text5", background: "brand" };
279
+ return "brand";
291
280
  case "Navigation":
292
- return { font: "text5", background: "surface6" };
281
+ return "surface6";
293
282
  case "Danger":
294
- return { font: "text5", background: "assertive" };
283
+ return "assertive";
295
284
  default:
296
285
  return unreachable(variant);
297
286
  }
298
287
  }
299
- function sizeToProps(size) {
300
- switch (size) {
301
- case "S":
302
- return {
303
- height: 32,
304
- padding: 16
305
- };
306
- case "M":
307
- return {
308
- height: 40,
309
- padding: 24
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(styledProps2)`
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 styledProps2(props) {
333
+ function styledProps(props) {
343
334
  return {
344
335
  ...props,
345
- ...variantToProps2(props.variant),
346
- ...sizeToProps2(props.size)
336
+ ...variantToProps(props.variant),
337
+ ...sizeToProps(props.size)
347
338
  };
348
339
  }
349
- function variantToProps2(variant) {
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 sizeToProps2(size) {
348
+ function sizeToProps(size) {
358
349
  switch (size) {
359
350
  case "XS":
360
351
  return {