@team-monolith/cds 1.30.1 → 1.30.2

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.
@@ -5,9 +5,9 @@ export interface SegmentedControlButtonProps<T> extends Omit<ButtonProps, "color
5
5
  startIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
6
6
  endIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
7
7
  }
8
+ type SegmentedControlButtonComponent = <T = string>(props: SegmentedControlButtonProps<T>) => React.ReactElement | null;
8
9
  /**
9
10
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
10
11
  */
11
- export declare const SegmentedControlButton: <T>(props: SegmentedControlButtonProps<T> & {
12
- ref?: React.ComponentPropsWithRef<"button">["ref"];
13
- }) => React.ReactElement;
12
+ export declare const SegmentedControlButton: SegmentedControlButtonComponent;
13
+ export {};
@@ -19,8 +19,6 @@ import { Button, shadows } from "../..";
19
19
  /**
20
20
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
21
21
  */
22
- // https://fettblog.eu/typescript-react-generic-forward-refs/
23
- // type assertion
24
22
  export const SegmentedControlButton = React.forwardRef(function SegmentedControlButton(props, ref) {
25
23
  const { onClick, startIcon, endIcon } = props, other = __rest(props, ["onClick", "startIcon", "endIcon"]);
26
24
  const context = useContext(SegmentedControlGroupPropsContext);
@@ -1,8 +1,9 @@
1
1
  import { ButtonSize, SquareButtonSize } from "../..";
2
2
  import React from "react";
3
- export type SegmentedControlGroupProps<T = string> = {
3
+ import { PolymorphicProps } from "@mui/base";
4
+ export type SegmentedControlGroupOwnProps<T, RootComponentType extends React.ElementType> = {
4
5
  className?: string;
5
- component?: React.ElementType;
6
+ component?: RootComponentType;
6
7
  children?: React.ReactNode;
7
8
  /** 컴포넌트 크기 */
8
9
  size: ButtonSize | SquareButtonSize;
@@ -21,9 +22,14 @@ export type SegmentedControlGroupProps<T = string> = {
21
22
  value: T[];
22
23
  onChange?: (newValue: T[]) => void;
23
24
  });
25
+ export interface SegmentedControlGroupTypeMap<T, RootComponentType extends React.ElementType = "div"> {
26
+ props: SegmentedControlGroupOwnProps<T, RootComponentType>;
27
+ defaultComponent: RootComponentType;
28
+ }
29
+ export type SegmentedControlGroupProps<T = string, RootComponentType extends React.ElementType = SegmentedControlGroupTypeMap<T>["defaultComponent"]> = PolymorphicProps<SegmentedControlGroupTypeMap<T, RootComponentType>, RootComponentType>;
30
+ type SegmentedControlGroupComponent = <T = string, RootComponentType extends React.ElementType = "div">(props: SegmentedControlGroupProps<T, RootComponentType>) => React.ReactElement | null;
24
31
  /**
25
32
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
26
33
  */
27
- export declare const SegmentedControlGroup: <T>(props: SegmentedControlGroupProps<T> & {
28
- ref?: React.ComponentPropsWithRef<"div">["ref"];
29
- }) => React.ReactElement;
34
+ export declare const SegmentedControlGroup: SegmentedControlGroupComponent;
35
+ export {};
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
13
  /** @jsxImportSource @emotion/react */
3
14
  import { css, useTheme } from "@emotion/react";
@@ -6,13 +17,11 @@ import React from "react";
6
17
  /**
7
18
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
8
19
  */
9
- // https://fettblog.eu/typescript-react-generic-forward-refs/
10
- // type assertion
11
20
  export const SegmentedControlGroup = React.forwardRef(function SegmentedControlGroup(props, ref) {
12
- const { component: Component = "div", className, children, fullWidth, multiSelect, } = props;
21
+ const { component: Component = "div", className, children, size, fullWidth, disabled, multiSelect, value, onChange } = props, other = __rest(props, ["component", "className", "children", "size", "fullWidth", "disabled", "multiSelect", "value", "onChange"]);
13
22
  const theme = useTheme();
14
23
  const Context = SegmentedControlGroupPropsContext;
15
- return (_jsx(Component, Object.assign({ ref: ref, className: className, css: css `
24
+ return (_jsx(Component, Object.assign({ ref: ref }, other, { className: className, css: css `
16
25
  display: flex;
17
26
  padding: 4px;
18
27
  box-sizing: border-box;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { SegmentedControlGroupProps } from "./SegmentedControlGroup";
3
- export type SegmentedControlGroupPropsContextType<T> = SegmentedControlGroupProps<T> & {
2
+ import { SegmentedControlGroupOwnProps } from "./SegmentedControlGroup";
3
+ export type SegmentedControlGroupPropsContextType<T, RootComponentType extends React.ElementType> = SegmentedControlGroupOwnProps<T, RootComponentType> & {
4
4
  onClick?: (newValue: T) => void;
5
5
  };
6
- export declare const SegmentedControlGroupPropsContext: import("react").Context<SegmentedControlGroupPropsContextType<any>>;
6
+ export declare const SegmentedControlGroupPropsContext: import("react").Context<SegmentedControlGroupPropsContextType<any, import("react").ElementType<any>>>;
@@ -1,5 +1,4 @@
1
1
  import { createContext } from "react";
2
- // TODO: type 추론을 더 잘해서 any를 제거하고 싶습니다.
3
2
  export const SegmentedControlGroupPropsContext = createContext({
4
3
  value: undefined,
5
4
  size: "medium",
@@ -4,9 +4,9 @@ export interface SegmentedControlSquareButtonProps<T> extends Omit<SquareButtonP
4
4
  value: T;
5
5
  icon: React.ReactNode | ((isActive: boolean) => React.ReactNode);
6
6
  }
7
+ type SegmentedControlSquareButtonComponent = <T = string>(props: SegmentedControlSquareButtonProps<T>) => React.ReactElement | null;
7
8
  /**
8
9
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
9
10
  */
10
- export declare const SegmentedControlSquareButton: <T>(props: SegmentedControlSquareButtonProps<T> & {
11
- ref?: React.ComponentPropsWithRef<"button">["ref"];
12
- }) => React.ReactElement;
11
+ export declare const SegmentedControlSquareButton: SegmentedControlSquareButtonComponent;
12
+ export {};
@@ -19,8 +19,6 @@ import { SegmentedControlGroupPropsContext, } from "./SegmentedControlGroupProps
19
19
  /**
20
20
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
21
21
  */
22
- // https://fettblog.eu/typescript-react-generic-forward-refs/
23
- // type assertion
24
22
  export const SegmentedControlSquareButton = React.forwardRef(function SegmentedControlSquareButton(props, ref) {
25
23
  const { onClick, icon } = props, other = __rest(props, ["onClick", "icon"]);
26
24
  const context = useContext(SegmentedControlGroupPropsContext);
@@ -32,7 +30,7 @@ export const SegmentedControlSquareButton = React.forwardRef(function SegmentedC
32
30
  const isActive = context.multiSelect
33
31
  ? context.value.includes(props.value)
34
32
  : context.value === props.value;
35
- return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, icon: typeof icon === "function" ? icon(isActive) : icon, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick })));
33
+ return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, icon: typeof icon === "function" ? icon(isActive) : icon, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick, disabled: context.disabled || props.disabled })));
36
34
  });
37
35
  const StyledSquareButton = styled(SquareButton, {
38
36
  shouldForwardProp: (prop) => prop !== "isActive",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.30.1",
3
+ "version": "1.30.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,