@zenkigen-inc/component-ui 1.14.3 → 1.14.5

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 CHANGED
@@ -44,11 +44,6 @@ yarn generate-component
44
44
 
45
45
  使用する側の import を簡略化させるため root にある [packages/component-ui/src/index.ts](https://github.com/zenkigen/zenkigen-component/blob/main/packages/components/src/index.ts) に実装したコンポーネントを export してください。
46
46
 
47
- ### コーディングガイドライン(社内のみ)
48
-
49
- 開発する際は以下を参照してください。
50
- https://www.notion.so/zenkigen/5d4ebd0d93b74124a533cf167b852ec0
51
-
52
47
  ## ライセンス
53
48
 
54
49
  @zenkigen-inc/component-ui は MIT ライセンスに基づいています。
@@ -1,6 +1,7 @@
1
1
  import type { ComponentPropsWithoutRef, CSSProperties, ElementType, PropsWithChildren, ReactNode } from 'react';
2
2
  type Size = 'small' | 'medium' | 'large';
3
3
  type Variant = 'fill' | 'fillDanger' | 'outline' | 'text';
4
+ type JustifyContent = 'start' | 'center';
4
5
  export type ElementAs = ElementType;
5
6
  export type AsProp<T extends ElementAs> = {
6
7
  elementAs?: T;
@@ -15,6 +16,7 @@ type Props<T extends ElementAs> = PolymorphicPropsWithoutRef<T, {
15
16
  before?: ReactNode;
16
17
  after?: ReactNode;
17
18
  borderRadius?: CSSProperties['borderRadius'];
19
+ justifyContent?: JustifyContent;
18
20
  }>;
19
- export declare const Button: <T extends ElementAs = "button">({ size, variant, isDisabled, isSelected, width, borderRadius, before, after, elementAs, children, ...props }: Props<T>) => import("react").JSX.Element;
21
+ export declare const Button: <T extends ElementAs = "button">({ size, variant, isDisabled, isSelected, width, borderRadius, justifyContent, before, after, elementAs, children, ...props }: Props<T>) => import("react").JSX.Element;
20
22
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { RefObject } from 'react';
2
- export declare const useOutsideClick: <T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: (event: Event) => void, enabled?: boolean) => void;
2
+ export declare const useOutsideClick: <T extends HTMLElement = HTMLElement>(ref: RefObject<T | null>, handler: (event: Event) => void, enabled?: boolean) => void;
package/dist/index.esm.js CHANGED
@@ -18,7 +18,7 @@ function _objectWithoutPropertiesLoose(r, e) {
18
18
  if (null == r) return {};
19
19
  var t = {};
20
20
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
21
- if (e.includes(n)) continue;
21
+ if (-1 !== e.indexOf(n)) continue;
22
22
  t[n] = r[n];
23
23
  }
24
24
  return t;
@@ -71,7 +71,7 @@ function Breadcrumb(_ref) {
71
71
  }
72
72
  Breadcrumb.Item = BreadcrumbItem;
73
73
 
74
- var _excluded$7 = ["size", "variant", "isDisabled", "isSelected", "width", "borderRadius", "before", "after", "elementAs", "children"];
74
+ var _excluded$7 = ["size", "variant", "isDisabled", "isSelected", "width", "borderRadius", "justifyContent", "before", "after", "elementAs", "children"];
75
75
  var Button = function Button(_ref) {
76
76
  var _clsx;
77
77
  var _ref$size = _ref.size,
@@ -83,17 +83,19 @@ var Button = function Button(_ref) {
83
83
  isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
84
84
  width = _ref.width,
85
85
  borderRadius = _ref.borderRadius,
86
+ _ref$justifyContent = _ref.justifyContent,
87
+ justifyContent = _ref$justifyContent === void 0 ? 'center' : _ref$justifyContent,
86
88
  before = _ref.before,
87
89
  after = _ref.after,
88
90
  elementAs = _ref.elementAs,
89
91
  children = _ref.children,
90
92
  props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
91
- var baseClasses = clsx('flex shrink-0 items-center justify-center gap-1', buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, (_clsx = {
93
+ var baseClasses = clsx('flex shrink-0 items-center gap-1', buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, (_clsx = {
92
94
  'h-6 px-2.5': size === 'small',
93
95
  'h-8 px-3': size === 'medium',
94
96
  'h-10 px-4 leading-[24px]': size === 'large',
95
97
  'inline-flex': elementAs === 'a'
96
- }, _clsx[buttonColors[variant].selected] = isSelected, _clsx[buttonColors[variant].base] = !isSelected, _clsx['hover:text-textOnColor active:text-textOnColor [&:hover>*]:fill-iconOnColor [&:active>*]:fill-iconOnColor'] = isSelected && variant !== 'outline' && variant !== 'text', _clsx['pointer-events-none'] = isDisabled, _clsx['rounded-button'] = borderRadius == null, _clsx['typography-label16regular'] = size === 'large', _clsx['typography-label14regular'] = size !== 'large', _clsx));
98
+ }, _clsx[buttonColors[variant].selected] = isSelected, _clsx[buttonColors[variant].base] = !isSelected, _clsx['hover:text-textOnColor active:text-textOnColor [&:hover>*]:fill-iconOnColor [&:active>*]:fill-iconOnColor'] = isSelected && variant !== 'outline' && variant !== 'text', _clsx['pointer-events-none'] = isDisabled, _clsx['rounded-button'] = borderRadius == null, _clsx['justify-start'] = justifyContent === 'start', _clsx['justify-center'] = justifyContent === 'center', _clsx['typography-label16regular'] = size === 'large', _clsx['typography-label14regular'] = size !== 'large', _clsx));
97
99
  var Component = elementAs != null ? elementAs : 'button';
98
100
  return /*#__PURE__*/jsxs(Component, _extends({
99
101
  className: baseClasses,
@@ -258,7 +260,7 @@ var Icon = function Icon(_ref) {
258
260
  props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
259
261
  var classes = clsx('inline-block shrink-0', (_clsx = {
260
262
  'fill-disabled01': isDisabled
261
- }, _clsx[iconColors.icon01] = !isDisabled && props.color === 'icon01', _clsx[iconColors.icon01Dark] = !isDisabled && props.color === 'icon01Dark', _clsx[iconColors.icon02] = !isDisabled && props.color === 'icon02', _clsx[iconColors.icon02Dark] = !isDisabled && props.color === 'icon02Dark', _clsx[iconColors.icon03] = !isDisabled && props.color === 'icon03', _clsx[iconColors.icon03Dark] = !isDisabled && props.color === 'icon03Dark', _clsx[iconColors.iconOnColor] = !isDisabled && props.color === 'iconOnColor', _clsx['w-3 h-3'] = size === 'x-small', _clsx['w-4 h-4'] = size === 'small', _clsx['w-6 h-6'] = size === 'medium', _clsx['w-8 h-8'] = size === 'large', _clsx['w-10 h-10'] = size === 'x-large', _clsx), props.className);
263
+ }, _clsx[iconColors.icon01] = !isDisabled && props.color === 'icon01', _clsx[iconColors.icon02] = !isDisabled && props.color === 'icon02', _clsx[iconColors.icon03] = !isDisabled && props.color === 'icon03', _clsx[iconColors.iconOnColor] = !isDisabled && props.color === 'iconOnColor', _clsx['w-3 h-3'] = size === 'x-small', _clsx['w-4 h-4'] = size === 'small', _clsx['w-6 h-6'] = size === 'medium', _clsx['w-8 h-8'] = size === 'large', _clsx['w-10 h-10'] = size === 'x-large', _clsx), props.className);
262
264
  return /*#__PURE__*/jsx("span", {
263
265
  className: classes,
264
266
  children: iconElements[props.name]
@@ -695,7 +697,7 @@ function Modal(_ref) {
695
697
  useEffect(function () {
696
698
  setIsMounted(true);
697
699
  }, []);
698
- return isMounted && isOpen ? /*#__PURE__*/createPortal( /*#__PURE__*/jsx(ModalContext.Provider, {
700
+ return isMounted && isOpen ? /*#__PURE__*/createPortal(/*#__PURE__*/jsx(ModalContext.Provider, {
699
701
  value: {
700
702
  onClose: onClose
701
703
  },
@@ -1432,7 +1434,7 @@ var TabItem = function TabItem(_ref) {
1432
1434
  props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
1433
1435
  var classes = clsx('relative z-0 flex py-2 leading-[24px] before:absolute before:inset-x-0 before:bottom-0 before:h-px hover:text-text01 disabled:pointer-events-none disabled:text-disabled01', {
1434
1436
  'typography-label14regular': !isSelected,
1435
- 'text-interactive02 hover:before:bg-uiBorder02Dark': !isSelected,
1437
+ 'text-interactive02 hover:before:bg-uiBorder04': !isSelected,
1436
1438
  'typography-label14bold': isSelected,
1437
1439
  'before:bg-interactive01 hover:before:bg-interactive01 pointer-events-none': isSelected
1438
1440
  });
@@ -1600,15 +1602,18 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
1600
1602
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
1601
1603
  onClickClearButton = _ref.onClickClearButton,
1602
1604
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
1605
+ var isShowClearButton = !!onClickClearButton && props.value.length !== 0 && !disabled;
1603
1606
  var inputWrapClasses = clsx('relative flex items-center gap-2 overflow-hidden rounded border', {
1604
1607
  'border-uiBorder02': !isError && !disabled,
1605
1608
  'border-supportError': isError && !disabled,
1606
1609
  'hover:border-hoverInput': !disabled && !isError,
1607
1610
  'hover:focus-within:border-activeInput': !isError,
1608
1611
  'focus-within:border-activeInput': !isError,
1609
- 'bg-disabled02 border-disabled01': disabled
1612
+ 'bg-disabled02 border-disabled01': disabled,
1613
+ 'pr-2': size === 'medium' && isShowClearButton,
1614
+ 'pr-3': size === 'large' && isShowClearButton
1610
1615
  });
1611
- var inputClasses = clsx('flex-1 pl-2 pr-3 outline-0 placeholder:text-textPlaceholder disabled:text-textPlaceholder', (_clsx = {}, _clsx['typography-label14regular min-h-8'] = size === 'medium', _clsx['typography-label16regular min-h-10'] = size === 'large', _clsx['text-text01'] = !isError, _clsx['text-supportError'] = isError, _clsx));
1616
+ var inputClasses = clsx('flex-1 outline-0 placeholder:text-textPlaceholder disabled:text-textPlaceholder', (_clsx = {}, _clsx['typography-label14regular min-h-8 px-2'] = size === 'medium', _clsx['typography-label16regular min-h-10 px-3'] = size === 'large', _clsx['text-text01'] = !isError, _clsx['text-supportError'] = isError, _clsx['pr-0'] = isShowClearButton, _clsx));
1612
1617
  return /*#__PURE__*/jsxs("div", {
1613
1618
  className: inputWrapClasses,
1614
1619
  children: [/*#__PURE__*/jsx("input", _extends({
@@ -1617,15 +1622,11 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
1617
1622
  className: inputClasses,
1618
1623
  disabled: disabled,
1619
1624
  onChange: props.onChange
1620
- }, props)), onClickClearButton && props.value.length !== 0 && !disabled && /*#__PURE__*/jsx("div", {
1621
- className: "absolute right-3",
1622
- children: /*#__PURE__*/jsx(IconButton, {
1623
- variant: "text",
1624
- icon: "close",
1625
- size: "small",
1626
- isNoPadding: true,
1627
- onClick: onClickClearButton
1628
- })
1625
+ }, props)), isShowClearButton && /*#__PURE__*/jsx(IconButton, {
1626
+ variant: "text",
1627
+ icon: "close",
1628
+ size: "small",
1629
+ onClick: onClickClearButton
1629
1630
  })]
1630
1631
  });
1631
1632
  });
@@ -1743,7 +1744,7 @@ var ToastProvider = function ToastProvider(_ref) {
1743
1744
  addToast: addToast,
1744
1745
  removeToast: removeToast
1745
1746
  },
1746
- children: [children, isClientRender && /*#__PURE__*/createPortal( /*#__PURE__*/jsx("div", {
1747
+ children: [children, isClientRender && /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
1747
1748
  className: "pointer-events-none fixed bottom-0 left-0 z-toast mb-4 ml-4 flex w-full flex-col-reverse gap-[16px]",
1748
1749
  children: toasts.map(function (_ref3) {
1749
1750
  var id = _ref3.id,
@@ -1784,19 +1785,19 @@ function Toggle(_ref) {
1784
1785
  'bg-interactive01 peer-hover:bg-hover01': !isDisabled && isChecked,
1785
1786
  'bg-interactive02 peer-hover:bg-hover02Dark': !isDisabled && !isChecked,
1786
1787
  'w-8 h-4 px-[3px]': size === 'small',
1787
- 'w-12 h-6 px-1': size === 'medium'
1788
+ 'w-12 h-6 px-1': size === 'medium' || size === 'large'
1788
1789
  });
1789
1790
  var inputClasses = clsx$1('peer absolute inset-0 z-[1] opacity-0', isDisabled ? 'cursor-not-allowed' : 'cursor-pointer');
1790
1791
  var indicatorClasses = clsx$1('rounded-full bg-iconOnColor', {
1791
1792
  'w-2.5 h-2.5': size === 'small',
1792
- 'w-4 h-4': size === 'medium',
1793
+ 'w-4 h-4': size === 'medium' || size === 'large',
1793
1794
  'ml-auto': isChecked
1794
1795
  });
1795
1796
  var labelClasses = clsx$1('break-all', {
1796
1797
  'mr-2': labelPosition === 'left',
1797
1798
  'ml-2': labelPosition === 'right',
1798
- 'typography-label12regular': size === 'small',
1799
- 'typography-label16regular': size === 'medium',
1799
+ 'typography-label14regular': size === 'small' || size === 'medium',
1800
+ 'typography-label16regular': size === 'large',
1800
1801
  'pointer-events-none cursor-not-allowed text-disabled01': isDisabled,
1801
1802
  'cursor-pointer text-text01': !isDisabled
1802
1803
  });
@@ -2030,7 +2031,7 @@ function Tooltip(_ref) {
2030
2031
  verticalPosition: verticalPosition,
2031
2032
  horizontalAlign: horizontalAlign,
2032
2033
  tooltipPosition: tooltipPosition
2033
- }) : ( /*#__PURE__*/createPortal( /*#__PURE__*/jsx(TooltipContent, {
2034
+ }) : (/*#__PURE__*/createPortal(/*#__PURE__*/jsx(TooltipContent, {
2034
2035
  isPortal: true,
2035
2036
  content: content,
2036
2037
  size: size,