@teamturing/react-kit 2.74.0 → 2.75.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,6 +1,6 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { AriaAttributes, HTMLAttributes, PropsWithChildren } from 'react';
2
2
  import { SxProp } from '../../utils/styled-system';
3
- type Props = {} & SxProp;
4
- declare const DatagridBody: ({ ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
3
+ type Props = {} & SxProp & Pick<HTMLAttributes<HTMLDivElement>, 'id' | 'role'> & AriaAttributes;
4
+ declare const DatagridBody: ({ role, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
5
5
  export default DatagridBody;
6
6
  export type { Props as DatagridBodyProps };
@@ -1,6 +1,11 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { AriaAttributes, HTMLAttributes, PropsWithChildren } from 'react';
2
2
  import { GridUnitProps } from '../Grid';
3
- type Props = {} & Pick<GridUnitProps, 'size' | 'sx'>;
4
- declare const DatagridCell: ({ children, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
3
+ type Props = {
4
+ /**
5
+ * 셀을 열 헤더(`columnheader`)로 표시합니다. 기본값(`false`)은 데이터 셀(`cell`)입니다.
6
+ */
7
+ columnHeader?: boolean;
8
+ } & Pick<GridUnitProps, 'size' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'id' | 'role' | 'tabIndex'> & AriaAttributes;
9
+ declare const DatagridCell: ({ children, columnHeader, role, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
5
10
  export default DatagridCell;
6
11
  export type { Props as DatagridCellProps };
@@ -1,9 +1,9 @@
1
- import { ElementType, HTMLAttributes, ReactElement, ReactNode } from 'react';
1
+ import { AriaAttributes, ElementType, HTMLAttributes, ReactElement, ReactNode } from 'react';
2
2
  import { SxProp } from '../../utils/styled-system';
3
3
  type Props = {
4
4
  leadingVisual?: ElementType | ReactNode;
5
5
  trailingAction?: ReactElement<HTMLAttributes<HTMLElement>>;
6
- } & SxProp;
6
+ } & SxProp & Pick<HTMLAttributes<HTMLDivElement>, 'id'> & AriaAttributes;
7
7
  declare const DatagridHeader: ({ leadingVisual: LeadingVisual, trailingAction, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
8
8
  export default DatagridHeader;
9
9
  export type { Props as DatagridHeaderProps };
@@ -1,7 +1,12 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { AriaAttributes, HTMLAttributes, PropsWithChildren } from 'react';
2
2
  import { GridProps } from '../Grid';
3
3
  import { SpaceProps } from '../Space';
4
- type Props = {} & Pick<GridProps, 'gapX' | 'alignItems' | 'justifyContent'> & Pick<SpaceProps, 'p' | 'px' | 'py' | 'pt' | 'pr' | 'pb' | 'pl' | 'padding' | 'paddingX' | 'paddingY' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'sx'>;
5
- declare const DatagridRow: ({ gapX, alignItems, justifyContent, children, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
4
+ type Props = {
5
+ /**
6
+ * 행을 열 제목 행으로 표시합니다. `true`이면 하위 `Datagrid.Cell`들이 열 헤더(`columnheader`)로 처리됩니다.
7
+ */
8
+ columnHeader?: boolean;
9
+ } & Pick<GridProps, 'gapX' | 'alignItems' | 'justifyContent'> & Pick<SpaceProps, 'p' | 'px' | 'py' | 'pt' | 'pr' | 'pb' | 'pl' | 'padding' | 'paddingX' | 'paddingY' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'id' | 'role' | 'tabIndex'> & AriaAttributes;
10
+ declare const DatagridRow: ({ gapX, alignItems, justifyContent, columnHeader, role, children, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
6
11
  export default DatagridRow;
7
12
  export type { Props as DatagridRowProps };
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { ItemListProps } from '../ItemList';
3
+ import { DatagridCellProps } from './DatagridCell';
4
+ import { DatagridRowProps } from './DatagridRow';
5
+ type Props<T extends {
6
+ id: string;
7
+ }> = {
8
+ rows: readonly T[];
9
+ columns: readonly {
10
+ field: string;
11
+ size: DatagridCellProps['size'];
12
+ renderValue: (row: T, index: number) => ReactNode;
13
+ }[];
14
+ rowProps?: DatagridRowProps;
15
+ columnsTransformer?: (columns: Props<T>['columns']) => typeof columns;
16
+ } & Pick<ItemListProps<T>, 'renderItemWrapper' | 'emptyState'>;
17
+ declare const DatagridRowList: <T extends {
18
+ id: string;
19
+ }>({ rows, columns, rowProps, renderItemWrapper, emptyState, columnsTransformer, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
20
+ export default DatagridRowList;
21
+ export type { Props as DatagridRowListProps };
@@ -4,13 +4,17 @@ import { DatagridBodyProps } from './DatagridBody';
4
4
  import { DatagridCellProps } from './DatagridCell';
5
5
  import { DatagridHeaderProps } from './DatagridHeader';
6
6
  import { DatagridRowProps } from './DatagridRow';
7
+ import { DatagridRowListProps } from './DatagridRowList';
7
8
  type Props = {} & HTMLAttributes<HTMLDivElement> & SxProp;
8
- declare const _default: (({ children, sx, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element) & {
9
+ declare const _default: (({ children, sx, role, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element) & {
9
10
  Header: ({ leadingVisual: LeadingVisual, trailingAction, ...props }: DatagridHeaderProps) => import("react/jsx-runtime").JSX.Element;
10
11
  Subheader: ({ ...props }: PropsWithChildren<SxProp>) => import("react/jsx-runtime").JSX.Element;
11
- Body: ({ ...props }: PropsWithChildren<SxProp>) => import("react/jsx-runtime").JSX.Element;
12
- Row: ({ gapX, alignItems, justifyContent, children, ...props }: PropsWithChildren<DatagridRowProps>) => import("react/jsx-runtime").JSX.Element;
13
- Cell: ({ children, ...props }: PropsWithChildren<Pick<import("../Grid").GridUnitProps, "size" | "sx">>) => import("react/jsx-runtime").JSX.Element;
12
+ Body: ({ role, ...props }: PropsWithChildren<DatagridBodyProps>) => import("react/jsx-runtime").JSX.Element;
13
+ Row: ({ gapX, alignItems, justifyContent, columnHeader, role, children, ...props }: PropsWithChildren<DatagridRowProps>) => import("react/jsx-runtime").JSX.Element;
14
+ RowList: <T extends {
15
+ id: string;
16
+ }>({ rows, columns, rowProps, renderItemWrapper, emptyState, columnsTransformer, }: DatagridRowListProps<T>) => import("react/jsx-runtime").JSX.Element;
17
+ Cell: ({ children, columnHeader, role, ...props }: PropsWithChildren<DatagridCellProps>) => import("react/jsx-runtime").JSX.Element;
14
18
  };
15
19
  export default _default;
16
- export type { Props as DatagridProps, DatagridBodyProps, DatagridCellProps, DatagridHeaderProps, DatagridRowProps };
20
+ export type { Props as DatagridProps, DatagridBodyProps, DatagridCellProps, DatagridHeaderProps, DatagridRowProps, DatagridRowListProps, };
@@ -1,5 +1,5 @@
1
1
  import { SpaceKey } from '@teamturing/token-studio';
2
- import { HTMLAttributes, PropsWithChildren } from 'react';
2
+ import { AriaAttributes, HTMLAttributes, PropsWithChildren } from 'react';
3
3
  import { ResponsiveValue } from 'styled-system';
4
4
  import { AsProp } from '../../utils/styled-system';
5
5
  import { ViewProps } from '../View';
@@ -11,11 +11,11 @@ type Props = {
11
11
  * 화면의 레이아웃을 위해 사용하는 경우 document size를 넘어가는 경우를 방지하기 위해 사용합니다.
12
12
  */
13
13
  layout?: boolean;
14
- } & Pick<ViewProps, 'alignItems' | 'justifyContent' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'className'> & AsProp;
14
+ } & Pick<ViewProps, 'alignItems' | 'justifyContent' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'id' | 'role' | 'tabIndex'> & AriaAttributes & AsProp;
15
15
  type UnitSizeType = 'min' | 'max' | number;
16
16
  type GridUnitProps = {
17
17
  size: ResponsiveValue<UnitSizeType>;
18
- } & Pick<ViewProps, 'order' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'className'> & AsProp;
18
+ } & Pick<ViewProps, 'order' | 'sx'> & Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'id' | 'role' | 'tabIndex'> & AriaAttributes & AsProp;
19
19
  declare const _default: import("react").ForwardRefExoticComponent<{
20
20
  gapX?: ResponsiveValue<0 | 1 | 20 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 12 | 14 | 16 | 18 | "-80" | "-50" | "-48" | "-40" | "-32" | "-30" | "-28" | "-24" | "-20" | "-18" | "-16" | "-14" | "-12" | "-10" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "-0.5" | "-0.25" | 0.25 | 0.5 | 24 | 28 | 30 | 32 | 40 | 48 | 50 | 80> | undefined;
21
21
  gapY?: ResponsiveValue<0 | 1 | 20 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 12 | 14 | 16 | 18 | "-80" | "-50" | "-48" | "-40" | "-32" | "-30" | "-28" | "-24" | "-20" | "-18" | "-16" | "-14" | "-12" | "-10" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "-0.5" | "-0.25" | 0.25 | 0.5 | 24 | 28 | 30 | 32 | 40 | 48 | 50 | 80> | undefined;
@@ -24,7 +24,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
24
24
  * 화면의 레이아웃을 위해 사용하는 경우 document size를 넘어가는 경우를 방지하기 위해 사용합니다.
25
25
  */
26
26
  layout?: boolean | undefined;
27
- } & Pick<ViewProps, "alignItems" | "justifyContent" | "sx"> & Pick<HTMLAttributes<HTMLDivElement>, "className"> & AsProp & {
27
+ } & Pick<ViewProps, "alignItems" | "justifyContent" | "sx"> & Pick<HTMLAttributes<HTMLDivElement>, "className" | "id" | "tabIndex" | "role"> & AriaAttributes & AsProp & {
28
28
  children?: import("react").ReactNode;
29
29
  } & import("react").RefAttributes<HTMLDivElement>> & {
30
30
  Unit: ({ size, as, children, ...props }: PropsWithChildren<GridUnitProps>) => import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ export type { ClickAreaProps } from './core/ClickArea';
32
32
  export { default as CounterBadge } from './core/CounterBadge';
33
33
  export type { CounterBadgeProps } from './core/CounterBadge';
34
34
  export { default as Datagrid } from './core/Datagrid';
35
- export type { DatagridProps, DatagridBodyProps, DatagridCellProps, DatagridHeaderProps, DatagridRowProps, } from './core/Datagrid';
35
+ export type { DatagridProps, DatagridBodyProps, DatagridCellProps, DatagridHeaderProps, DatagridRowProps, DatagridRowListProps, } from './core/Datagrid';
36
36
  export { default as DescriptionList } from './core/DescriptionList';
37
37
  export type { DescriptionListProps } from './core/DescriptionList';
38
38
  export { default as Dialog } from './core/Dialog';
package/dist/index.js CHANGED
@@ -5103,8 +5103,10 @@ const BaseCounterBadge = /*#__PURE__*/styled__default.default.span.withConfig({
5103
5103
  }), sx);
5104
5104
 
5105
5105
  const DatagridBody = ({
5106
+ role,
5106
5107
  ...props
5107
5108
  }) => /*#__PURE__*/jsxRuntime.jsx(BaseDatagridBody, {
5109
+ role: role ?? 'rowgroup',
5108
5110
  ...props
5109
5111
  });
5110
5112
  const BaseDatagridBody = /*#__PURE__*/styled__default.default.div.withConfig({
@@ -5116,8 +5118,11 @@ const BaseDatagridBody = /*#__PURE__*/styled__default.default.div.withConfig({
5116
5118
 
5117
5119
  const DatagridCell = ({
5118
5120
  children,
5121
+ columnHeader = false,
5122
+ role,
5119
5123
  ...props
5120
5124
  }) => /*#__PURE__*/jsxRuntime.jsx(BaseDatagridCell, {
5125
+ role: role ?? (columnHeader ? 'columnheader' : 'cell'),
5121
5126
  ...props,
5122
5127
  children: children
5123
5128
  });
@@ -5154,21 +5159,69 @@ const DatagridRow = ({
5154
5159
  gapX = 2,
5155
5160
  alignItems,
5156
5161
  justifyContent,
5162
+ columnHeader = false,
5163
+ role,
5157
5164
  children,
5158
5165
  ...props
5159
- }) => /*#__PURE__*/jsxRuntime.jsx(DatagridRowWrapper, {
5166
+ }) =>
5167
+ /*#__PURE__*/
5168
+ // 외부 wrapper가 `rowgroup`의 직접 자식이 되도록 여기에 role="row"를 부여하고,
5169
+ // 셀을 직접 감싸는 내부 Grid는 presentation 처리하여 row가 cell을 직접 소유하도록 한다.
5170
+ jsxRuntime.jsx(DatagridRowWrapper, {
5171
+ role: role ?? 'row',
5160
5172
  ...props,
5161
5173
  children: /*#__PURE__*/jsxRuntime.jsx(BaseDatagridRow, {
5174
+ role: 'presentation',
5162
5175
  wrap: false,
5163
5176
  gapX: gapX,
5164
5177
  alignItems: alignItems,
5165
5178
  justifyContent: justifyContent,
5166
- children: children
5179
+ children: columnHeader ? React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
5180
+ columnHeader: child.props.columnHeader ?? true
5181
+ }) : child) : children
5167
5182
  })
5168
5183
  });
5169
5184
  const BaseDatagridRow = Grid$1;
5170
5185
  const DatagridRowWrapper = Space;
5171
5186
 
5187
+ const ItemList = ({
5188
+ items,
5189
+ renderItem,
5190
+ renderItemWrapper = children => children,
5191
+ emptyState = null
5192
+ }) => {
5193
+ if (items.length === 0) return emptyState;
5194
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5195
+ children: items.map((item, i) => renderItemWrapper(renderItem(item, i), item, i))
5196
+ });
5197
+ };
5198
+
5199
+ const DatagridRowList = ({
5200
+ rows,
5201
+ columns,
5202
+ rowProps = {
5203
+ alignItems: 'center'
5204
+ },
5205
+ renderItemWrapper,
5206
+ emptyState,
5207
+ columnsTransformer = columns => columns
5208
+ }) => /*#__PURE__*/jsxRuntime.jsx(ItemList, {
5209
+ items: rows,
5210
+ renderItem: (row, i) => /*#__PURE__*/jsxRuntime.jsx(DatagridRow, {
5211
+ ...rowProps,
5212
+ children: columnsTransformer(columns).filter(column => !utils.isNullable(column)).map(({
5213
+ field,
5214
+ renderValue,
5215
+ size
5216
+ }) => /*#__PURE__*/jsxRuntime.jsx(DatagridCell, {
5217
+ size: size,
5218
+ children: renderValue(row, i)
5219
+ }, field))
5220
+ }, row.id),
5221
+ renderItemWrapper: renderItemWrapper,
5222
+ emptyState: emptyState
5223
+ });
5224
+
5172
5225
  const DatagridSubheader = ({
5173
5226
  ...props
5174
5227
  }) => /*#__PURE__*/jsxRuntime.jsx(DataGridSubheaderWrapper, {
@@ -5188,6 +5241,9 @@ const DataGridSubheaderWrapper = /*#__PURE__*/styled__default.default.div.withCo
5188
5241
  const Datagrid = ({
5189
5242
  children,
5190
5243
  sx,
5244
+ role = 'table',
5245
+ 'aria-label': ariaLabel,
5246
+ 'aria-labelledby': ariaLabelledby,
5191
5247
  ...props
5192
5248
  }) => {
5193
5249
  const [relocatableComponentsObject, restConmponents] = useRelocation({
@@ -5197,9 +5253,28 @@ const Datagrid = ({
5197
5253
  subHeader: DatagridSubheader
5198
5254
  }
5199
5255
  });
5256
+
5257
+ // Header가 있고 별도 라벨이 지정되지 않은 경우, Header를 표의 접근 가능한 이름으로 연결한다.
5258
+ const generatedHeaderId = React.useId();
5259
+ const {
5260
+ header: rawHeader,
5261
+ subHeader
5262
+ } = relocatableComponentsObject;
5263
+ let headerNode = rawHeader;
5264
+ let resolvedLabelledby = ariaLabelledby;
5265
+ if (!ariaLabel && !ariaLabelledby && /*#__PURE__*/React.isValidElement(rawHeader)) {
5266
+ const headerId = rawHeader.props.id ?? generatedHeaderId;
5267
+ headerNode = /*#__PURE__*/React.cloneElement(rawHeader, {
5268
+ id: headerId
5269
+ });
5270
+ resolvedLabelledby = headerId;
5271
+ }
5200
5272
  return /*#__PURE__*/jsxRuntime.jsxs(DatagridWrapper, {
5201
5273
  sx: sx,
5202
- children: [relocatableComponentsObject.header, relocatableComponentsObject.subHeader, /*#__PURE__*/jsxRuntime.jsx(BaseDatagrid, {
5274
+ children: [headerNode, subHeader, /*#__PURE__*/jsxRuntime.jsx(BaseDatagrid, {
5275
+ role: role,
5276
+ "aria-label": ariaLabel,
5277
+ "aria-labelledby": resolvedLabelledby,
5203
5278
  ...props,
5204
5279
  children: restConmponents
5205
5280
  })]
@@ -5222,21 +5297,10 @@ var index$9 = Object.assign(Datagrid, {
5222
5297
  Subheader: DatagridSubheader,
5223
5298
  Body: DatagridBody,
5224
5299
  Row: DatagridRow,
5300
+ RowList: DatagridRowList,
5225
5301
  Cell: DatagridCell
5226
5302
  });
5227
5303
 
5228
- const ItemList = ({
5229
- items,
5230
- renderItem,
5231
- renderItemWrapper = children => children,
5232
- emptyState = null
5233
- }) => {
5234
- if (items.length === 0) return emptyState;
5235
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5236
- children: items.map((item, i) => renderItemWrapper(renderItem(item, i), item, i))
5237
- });
5238
- };
5239
-
5240
5304
  const DescriptionList = ({
5241
5305
  item,
5242
5306
  itemDescriptions,
@@ -4,8 +4,10 @@ import { sx } from '../../utils/styled-system/index.js';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
6
  const DatagridBody = ({
7
+ role,
7
8
  ...props
8
9
  }) => /*#__PURE__*/jsx(BaseDatagridBody, {
10
+ role: role ?? 'rowgroup',
9
11
  ...props
10
12
  });
11
13
  const BaseDatagridBody = /*#__PURE__*/styled.div.withConfig({
@@ -3,8 +3,11 @@ import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const DatagridCell = ({
5
5
  children,
6
+ columnHeader = false,
7
+ role,
6
8
  ...props
7
9
  }) => /*#__PURE__*/jsx(BaseDatagridCell, {
10
+ role: role ?? (columnHeader ? 'columnheader' : 'cell'),
8
11
  ...props,
9
12
  children: children
10
13
  });
@@ -1,3 +1,4 @@
1
+ import { Children, isValidElement, cloneElement } from 'react';
1
2
  import Grid from '../Grid/index.js';
2
3
  import Space from '../Space/index.js';
3
4
  import { jsx } from 'react/jsx-runtime';
@@ -6,16 +7,26 @@ const DatagridRow = ({
6
7
  gapX = 2,
7
8
  alignItems,
8
9
  justifyContent,
10
+ columnHeader = false,
11
+ role,
9
12
  children,
10
13
  ...props
11
- }) => /*#__PURE__*/jsx(DatagridRowWrapper, {
14
+ }) =>
15
+ /*#__PURE__*/
16
+ // 외부 wrapper가 `rowgroup`의 직접 자식이 되도록 여기에 role="row"를 부여하고,
17
+ // 셀을 직접 감싸는 내부 Grid는 presentation 처리하여 row가 cell을 직접 소유하도록 한다.
18
+ jsx(DatagridRowWrapper, {
19
+ role: role ?? 'row',
12
20
  ...props,
13
21
  children: /*#__PURE__*/jsx(BaseDatagridRow, {
22
+ role: 'presentation',
14
23
  wrap: false,
15
24
  gapX: gapX,
16
25
  alignItems: alignItems,
17
26
  justifyContent: justifyContent,
18
- children: children
27
+ children: columnHeader ? Children.map(children, child => /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, {
28
+ columnHeader: child.props.columnHeader ?? true
29
+ }) : child) : children
19
30
  })
20
31
  });
21
32
  const BaseDatagridRow = Grid;
@@ -0,0 +1,33 @@
1
+ import { isNullable } from '@teamturing/utils';
2
+ import ItemList from '../ItemList/index.js';
3
+ import DatagridCell from './DatagridCell.js';
4
+ import DatagridRow from './DatagridRow.js';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ const DatagridRowList = ({
8
+ rows,
9
+ columns,
10
+ rowProps = {
11
+ alignItems: 'center'
12
+ },
13
+ renderItemWrapper,
14
+ emptyState,
15
+ columnsTransformer = columns => columns
16
+ }) => /*#__PURE__*/jsx(ItemList, {
17
+ items: rows,
18
+ renderItem: (row, i) => /*#__PURE__*/jsx(DatagridRow, {
19
+ ...rowProps,
20
+ children: columnsTransformer(columns).filter(column => !isNullable(column)).map(({
21
+ field,
22
+ renderValue,
23
+ size
24
+ }) => /*#__PURE__*/jsx(DatagridCell, {
25
+ size: size,
26
+ children: renderValue(row, i)
27
+ }, field))
28
+ }, row.id),
29
+ renderItemWrapper: renderItemWrapper,
30
+ emptyState: emptyState
31
+ });
32
+
33
+ export { DatagridRowList as default };
@@ -1,4 +1,5 @@
1
1
  import { forcePixelValue } from '@teamturing/utils';
2
+ import { useId, isValidElement, cloneElement } from 'react';
2
3
  import styled from 'styled-components';
3
4
  import useRelocation from '../../hook/useRelocation.js';
4
5
  import { sx } from '../../utils/styled-system/index.js';
@@ -6,12 +7,16 @@ import DatagridBody from './DatagridBody.js';
6
7
  import DatagridCell from './DatagridCell.js';
7
8
  import DatagridHeader from './DatagridHeader.js';
8
9
  import DatagridRow from './DatagridRow.js';
10
+ import DatagridRowList from './DatagridRowList.js';
9
11
  import DatagridSubheader from './DatagridSubheader.js';
10
12
  import { jsxs, jsx } from 'react/jsx-runtime';
11
13
 
12
14
  const Datagrid = ({
13
15
  children,
14
16
  sx,
17
+ role = 'table',
18
+ 'aria-label': ariaLabel,
19
+ 'aria-labelledby': ariaLabelledby,
15
20
  ...props
16
21
  }) => {
17
22
  const [relocatableComponentsObject, restConmponents] = useRelocation({
@@ -21,9 +26,28 @@ const Datagrid = ({
21
26
  subHeader: DatagridSubheader
22
27
  }
23
28
  });
29
+
30
+ // Header가 있고 별도 라벨이 지정되지 않은 경우, Header를 표의 접근 가능한 이름으로 연결한다.
31
+ const generatedHeaderId = useId();
32
+ const {
33
+ header: rawHeader,
34
+ subHeader
35
+ } = relocatableComponentsObject;
36
+ let headerNode = rawHeader;
37
+ let resolvedLabelledby = ariaLabelledby;
38
+ if (!ariaLabel && !ariaLabelledby && /*#__PURE__*/isValidElement(rawHeader)) {
39
+ const headerId = rawHeader.props.id ?? generatedHeaderId;
40
+ headerNode = /*#__PURE__*/cloneElement(rawHeader, {
41
+ id: headerId
42
+ });
43
+ resolvedLabelledby = headerId;
44
+ }
24
45
  return /*#__PURE__*/jsxs(DatagridWrapper, {
25
46
  sx: sx,
26
- children: [relocatableComponentsObject.header, relocatableComponentsObject.subHeader, /*#__PURE__*/jsx(BaseDatagrid, {
47
+ children: [headerNode, subHeader, /*#__PURE__*/jsx(BaseDatagrid, {
48
+ role: role,
49
+ "aria-label": ariaLabel,
50
+ "aria-labelledby": resolvedLabelledby,
27
51
  ...props,
28
52
  children: restConmponents
29
53
  })]
@@ -46,6 +70,7 @@ var index = Object.assign(Datagrid, {
46
70
  Subheader: DatagridSubheader,
47
71
  Body: DatagridBody,
48
72
  Row: DatagridRow,
73
+ RowList: DatagridRowList,
49
74
  Cell: DatagridCell
50
75
  });
51
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.74.0",
3
+ "version": "2.75.0",
4
4
  "description": "React components, hooks for create teamturing web application",
5
5
  "author": "Sungchang Park <psch300@gmail.com> (https://github.com/psch300)",
6
6
  "homepage": "https://github.com/weareteamturing/bombe#readme",
@@ -65,5 +65,5 @@
65
65
  "react-textarea-autosize": "^8.5.3",
66
66
  "styled-system": "^5.1.5"
67
67
  },
68
- "gitHead": "b096bdb9ffa2f75b160b773e60a1a2130989ff3c"
68
+ "gitHead": "dfe41b5bceb6209a01bc7fe08d2cb52ac8447a4e"
69
69
  }