@tipp/ui 1.4.7 → 1.4.9

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 (77) hide show
  1. package/dist/atoms/button.cjs +30 -10
  2. package/dist/atoms/button.cjs.map +1 -1
  3. package/dist/atoms/button.d.cts +3 -2
  4. package/dist/atoms/button.d.ts +3 -2
  5. package/dist/atoms/button.js +1 -1
  6. package/dist/atoms/dialog.cjs +30 -10
  7. package/dist/atoms/dialog.cjs.map +1 -1
  8. package/dist/atoms/dialog.js +2 -2
  9. package/dist/atoms/drawer.cjs +30 -10
  10. package/dist/atoms/drawer.cjs.map +1 -1
  11. package/dist/atoms/drawer.js +2 -2
  12. package/dist/atoms/field-error-wrapper.js +2 -2
  13. package/dist/atoms/index.cjs +30 -10
  14. package/dist/atoms/index.cjs.map +1 -1
  15. package/dist/atoms/index.d.cts +1 -0
  16. package/dist/atoms/index.d.ts +1 -0
  17. package/dist/atoms/index.js +60 -60
  18. package/dist/atoms/pagination.js +2 -2
  19. package/dist/chunk-3YBBMDHJ.js +60 -0
  20. package/dist/chunk-3YBBMDHJ.js.map +1 -0
  21. package/dist/chunk-7YPMSAU3.js +164 -0
  22. package/dist/chunk-7YPMSAU3.js.map +1 -0
  23. package/dist/chunk-BSG2Q4XC.js +192 -0
  24. package/dist/chunk-BSG2Q4XC.js.map +1 -0
  25. package/dist/chunk-EIAK47TI.js +77 -0
  26. package/dist/chunk-EIAK47TI.js.map +1 -0
  27. package/dist/chunk-EQC3MBY2.js +164 -0
  28. package/dist/chunk-EQC3MBY2.js.map +1 -0
  29. package/dist/chunk-GIUL45NR.js +63 -0
  30. package/dist/chunk-GIUL45NR.js.map +1 -0
  31. package/dist/chunk-KK6EZCIU.js +192 -0
  32. package/dist/chunk-KK6EZCIU.js.map +1 -0
  33. package/dist/chunk-LGWPZRFJ.js +340 -0
  34. package/dist/chunk-LGWPZRFJ.js.map +1 -0
  35. package/dist/chunk-PCWEW2UL.js +80 -0
  36. package/dist/chunk-PCWEW2UL.js.map +1 -0
  37. package/dist/chunk-TSVUJJVY.js +340 -0
  38. package/dist/chunk-TSVUJJVY.js.map +1 -0
  39. package/dist/chunk-WM3XQMNK.js +88 -0
  40. package/dist/chunk-WM3XQMNK.js.map +1 -0
  41. package/dist/chunk-XXODW32Q.js +63 -0
  42. package/dist/chunk-XXODW32Q.js.map +1 -0
  43. package/dist/chunk-ZQLHJD5Q.js +192 -0
  44. package/dist/chunk-ZQLHJD5Q.js.map +1 -0
  45. package/dist/index.cjs +40 -18
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +1 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.js +80 -80
  50. package/dist/molecules/date-picker/index.js +2 -2
  51. package/dist/molecules/expand-table/index.cjs +10 -8
  52. package/dist/molecules/expand-table/index.cjs.map +1 -1
  53. package/dist/molecules/expand-table/index.d.cts +1 -0
  54. package/dist/molecules/expand-table/index.d.ts +1 -0
  55. package/dist/molecules/expand-table/index.js +29 -29
  56. package/dist/molecules/expand-table/row.cjs +4 -4
  57. package/dist/molecules/expand-table/row.cjs.map +1 -1
  58. package/dist/molecules/expand-table/row.d.cts +2 -1
  59. package/dist/molecules/expand-table/row.d.ts +2 -1
  60. package/dist/molecules/expand-table/row.js +28 -28
  61. package/dist/molecules/index.cjs +40 -18
  62. package/dist/molecules/index.cjs.map +1 -1
  63. package/dist/molecules/index.js +37 -37
  64. package/dist/molecules/learning-post.cjs +30 -10
  65. package/dist/molecules/learning-post.cjs.map +1 -1
  66. package/dist/molecules/learning-post.js +4 -4
  67. package/dist/molecules/navigation.cjs +30 -10
  68. package/dist/molecules/navigation.cjs.map +1 -1
  69. package/dist/molecules/navigation.js +28 -28
  70. package/dist/molecules/stepper.js +3 -3
  71. package/dist/molecules/tag-selector.cjs +30 -10
  72. package/dist/molecules/tag-selector.cjs.map +1 -1
  73. package/dist/molecules/tag-selector.js +28 -28
  74. package/package.json +1 -1
  75. package/src/atoms/button.tsx +39 -11
  76. package/src/molecules/expand-table/index.tsx +6 -3
  77. package/src/molecules/expand-table/row.tsx +6 -3
@@ -2,28 +2,56 @@ import {
2
2
  Button as RadixButton,
3
3
  type ButtonProps as RadixButtonProps,
4
4
  } from '@radix-ui/themes';
5
+ import type { Breakpoint, Responsive } from '@radix-ui/themes/props';
5
6
  import React, { forwardRef, useMemo } from 'react';
6
7
 
7
8
  export type ButtonProps = Omit<RadixButtonProps, 'size' | 'variant'> & {
8
- size?: 'small' | 'medium' | 'large';
9
+ size?: Responsive<'small' | 'medium' | 'large'>;
9
10
  variant?: RadixButtonProps['variant'] | 'transparent';
10
11
  };
11
12
 
13
+ const convertSizeStr = (size: ButtonProps['size']): '1' | '2' | '3' | '4' => {
14
+ switch (size) {
15
+ case 'small':
16
+ return '1';
17
+ case 'medium':
18
+ return '2';
19
+ case 'large':
20
+ return '3';
21
+ default:
22
+ return '2';
23
+ }
24
+ };
25
+
26
+ const convertSizeResponse = (
27
+ size: ButtonProps['size']
28
+ ): RadixButtonProps['size'] => {
29
+ if (typeof size === 'string' || typeof size === 'undefined') {
30
+ return convertSizeStr(size);
31
+ }
32
+ const radixSize: RadixButtonProps['size'] = {};
33
+ let key: Breakpoint = 'initial';
34
+ for (key in radixSize) {
35
+ radixSize[key] = convertSizeStr(size[key]);
36
+ }
37
+ return radixSize;
38
+ };
39
+
40
+ const convertSize = (size: ButtonProps['size']): RadixButtonProps['size'] => {
41
+ if (typeof size === 'string') {
42
+ return convertSizeStr(size);
43
+ }
44
+ return convertSizeResponse(size);
45
+ };
46
+
12
47
  export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
13
48
  (props, ref): React.ReactElement => {
14
49
  const { size, style, variant, ...restProps } = props;
50
+ // string인 경우
51
+ //object인 경우
15
52
 
16
53
  const radixSize = useMemo(() => {
17
- switch (size) {
18
- case 'small':
19
- return '1';
20
- case 'medium':
21
- return '2';
22
- case 'large':
23
- return '3';
24
- default:
25
- return '2';
26
- }
54
+ return convertSize(size);
27
55
  }, [size]);
28
56
 
29
57
  const mergedStyle = useMemo<ButtonProps['style']>(() => {
@@ -35,6 +35,7 @@ export interface ExpandTableProps<Datum extends RowData> {
35
35
  /** 행 클릭 시 실행할 콜백 */
36
36
  onRowClick?: OnRowClick<Datum>;
37
37
  getRowStyle?: (data: Datum) => CSSProperties;
38
+ getCellStyle?: (data: Datum) => CSSProperties;
38
39
  tableStyle?: CSSProperties;
39
40
  isLoading?: boolean;
40
41
 
@@ -64,6 +65,7 @@ export function ExpandTable<Datum extends RowData>(
64
65
  pageSize = 10,
65
66
  siblingCount = 2,
66
67
  getRowStyle,
68
+ getCellStyle,
67
69
  } = props;
68
70
  const defaultAlign = 'left';
69
71
  const [pagination, setPagination] = useState<PaginationState>({
@@ -86,7 +88,7 @@ export function ExpandTable<Datum extends RowData>(
86
88
  onPaginationChange: setPagination,
87
89
  });
88
90
 
89
- const gridColTemp = useMemo<string>(() => {
91
+ const gridTemplateColumns = useMemo<string>(() => {
90
92
  return columns
91
93
  .map((col) => {
92
94
  if (col.meta?.autoSize) return '1fr';
@@ -149,7 +151,7 @@ export function ExpandTable<Datum extends RowData>(
149
151
  <div
150
152
  className="tr"
151
153
  key={headerGroup.id}
152
- style={{ gridTemplateColumns: gridColTemp }}
154
+ style={{ gridTemplateColumns }}
153
155
  >
154
156
  {headerGroup.headers.map((header) => {
155
157
  const sortable = header.column.getCanSort();
@@ -208,8 +210,9 @@ export function ExpandTable<Datum extends RowData>(
208
210
  <Row
209
211
  ExpandComp={ExpandComp}
210
212
  defaultAlign={defaultAlign}
213
+ getCellStyle={getCellStyle}
211
214
  getRowStyle={getRowStyle}
212
- gridColTemp={gridColTemp}
215
+ gridTemplateColumns={gridTemplateColumns}
213
216
  key={`row_${row.id}`}
214
217
  onRowClick={onRowClick}
215
218
  row={row}
@@ -14,15 +14,17 @@ interface RowProps<Datum extends RowData> {
14
14
  row: TanstackRow<Datum>;
15
15
  ExpandComp?: ExpandComp<Datum>;
16
16
  onRowClick?: OnRowClick<Datum>;
17
- gridColTemp: string;
17
+ gridTemplateColumns: string;
18
18
  getRowStyle?: (data: Datum) => React.CSSProperties;
19
+ getCellStyle?: (data: Datum) => React.CSSProperties;
19
20
  defaultAlign: CellAlign;
20
21
  }
21
22
 
22
23
  export function Row<Datum extends RowData>(
23
24
  props: RowProps<Datum>
24
25
  ): React.ReactNode {
25
- const { row, ExpandComp, gridColTemp, getRowStyle } = props;
26
+ const { row, ExpandComp, gridTemplateColumns, getRowStyle, getCellStyle } =
27
+ props;
26
28
  const [open, setOpen] = useState(false);
27
29
 
28
30
  const onClickRow = useCallback(() => {
@@ -48,7 +50,7 @@ export function Row<Datum extends RowData>(
48
50
  key={`tr_${row.id}`}
49
51
  onClick={onClickRow}
50
52
  style={{
51
- gridTemplateColumns: gridColTemp,
53
+ gridTemplateColumns,
52
54
  ...(getRowStyle?.(row.original) || {}),
53
55
  }}
54
56
  type="button"
@@ -66,6 +68,7 @@ export function Row<Datum extends RowData>(
66
68
  // width: autoSize ? undefined : cell.column.getSize(),
67
69
  flexGrow: autoSize ? 1 : undefined,
68
70
  justifyContent,
71
+ ...(getCellStyle?.(row.original) || {}),
69
72
  }}
70
73
  >
71
74
  {flexRender(cell.column.columnDef.cell, cell.getContext())}