@teamturing/react-kit 2.67.1 → 2.69.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.
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ type DialogContextValue = {
3
+ titleId?: string;
4
+ };
5
+ declare const DialogContext: import("react").Context<DialogContextValue>;
6
+ export default DialogContext;
7
+ export type { DialogContextValue };
@@ -1,16 +1,17 @@
1
1
  import { SpaceKey } from '@teamturing/token-studio';
2
2
  import { PropsWithChildren, RefObject } from 'react';
3
3
  import { ResponsiveValue } from 'styled-system';
4
+ import { SxProp } from '../../utils/styled-system';
4
5
  type Props = {
5
6
  variant?: 'plain' | 'outlined' | 'underline';
6
7
  size?: ResponsiveValue<'l' | 'm' | 's'>;
7
8
  gap?: ResponsiveValue<SpaceKey>;
8
- };
9
+ } & SxProp;
9
10
  type TabContextValue = {
10
11
  containerRef?: RefObject<HTMLElement>;
11
12
  } & Props;
12
13
  declare const TabContext: import("react").Context<TabContextValue>;
13
- declare const _default: (({ variant, size, gap, children }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element) & {
14
+ declare const _default: (({ variant, size, gap, sx, children }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element) & {
14
15
  Item: ({ children, leadingIcon: LeadingIcon, selected, onClick, size: propSize, variant: propVariant, }: PropsWithChildren<import("./TabItem").TabItemProps>) => import("react/jsx-runtime").JSX.Element;
15
16
  };
16
17
  export default _default;
package/dist/index.js CHANGED
@@ -5436,6 +5436,8 @@ const DialogBody = ({
5436
5436
  children: children
5437
5437
  });
5438
5438
 
5439
+ const DialogContext = /*#__PURE__*/React.createContext({});
5440
+
5439
5441
  const UnstyledDialogFooter = /*#__PURE__*/styled__default.default.div.attrs({
5440
5442
  className: 'trk-dialog_footer'
5441
5443
  }).withConfig({
@@ -5482,6 +5484,7 @@ const DialogHeader = ({
5482
5484
  sx: {
5483
5485
  px: 5,
5484
5486
  py: 4,
5487
+ minHeight: utils.forcePixelValue(63),
5485
5488
  borderBottomWidth: 1,
5486
5489
  borderBottomStyle: 'solid',
5487
5490
  borderBottomColor: 'border/neutral',
@@ -5505,12 +5508,18 @@ const DialogHeaderTitle = ({
5505
5508
  typography = 'm/bold',
5506
5509
  color = 'text/neutral',
5507
5510
  ...props
5508
- }) => /*#__PURE__*/jsxRuntime.jsx(Text, {
5509
- className: 'trk-dialog_header_title',
5510
- typography: typography,
5511
- color: color,
5512
- ...props
5513
- });
5511
+ }) => {
5512
+ const {
5513
+ titleId
5514
+ } = React.useContext(DialogContext);
5515
+ return /*#__PURE__*/jsxRuntime.jsx(Text, {
5516
+ id: titleId,
5517
+ className: 'trk-dialog_header_title',
5518
+ typography: typography,
5519
+ color: color,
5520
+ ...props
5521
+ });
5522
+ };
5514
5523
 
5515
5524
  const Dialog = ({
5516
5525
  children,
@@ -5522,6 +5531,7 @@ const Dialog = ({
5522
5531
  sx
5523
5532
  }, ref) => {
5524
5533
  const theme = styled.useTheme();
5534
+ const titleId = React.useId();
5525
5535
  const handleDismiss = React.useCallback(() => onDismiss?.(), [onDismiss]);
5526
5536
  const blanketRef = React.useRef(null);
5527
5537
  const dialogRef = React.useRef(null);
@@ -5543,7 +5553,8 @@ const Dialog = ({
5543
5553
  useFocusTrap({
5544
5554
  containerRef: dialogRef,
5545
5555
  initialFocusRef: initialFocusRef || closeButtonRef,
5546
- disabled: !isOpen
5556
+ disabled: !isOpen,
5557
+ restoreFocusOnCleanUp: true
5547
5558
  });
5548
5559
  React.useEffect(() => {
5549
5560
  if (isOpen && isOutsideClickDismissable) {
@@ -5593,6 +5604,7 @@ const Dialog = ({
5593
5604
  className: `trk-dialog--${size}`,
5594
5605
  ref: dialogRef,
5595
5606
  "aria-modal": 'true',
5607
+ "aria-labelledby": titleId,
5596
5608
  role: 'dialog',
5597
5609
  tabIndex: -1,
5598
5610
  sx: {
@@ -5642,7 +5654,12 @@ const Dialog = ({
5642
5654
  size: 'm',
5643
5655
  onClick: handleDismiss
5644
5656
  })
5645
- }), children]
5657
+ }), /*#__PURE__*/jsxRuntime.jsx(DialogContext.Provider, {
5658
+ value: {
5659
+ titleId
5660
+ },
5661
+ children: children
5662
+ })]
5646
5663
  })
5647
5664
  })]
5648
5665
  })
@@ -7055,6 +7072,7 @@ const TabItem = ({
7055
7072
  onClick?.(e);
7056
7073
  };
7057
7074
  return /*#__PURE__*/jsxRuntime.jsx(BaseTabItem, {
7075
+ className: 'trk-tab_item',
7058
7076
  type: 'button',
7059
7077
  role: 'tab',
7060
7078
  ref: ref,
@@ -7064,6 +7082,7 @@ const TabItem = ({
7064
7082
  selected: selected,
7065
7083
  onClick: handleClick,
7066
7084
  children: /*#__PURE__*/jsxRuntime.jsxs(View, {
7085
+ className: 'trk-tab_item__content',
7067
7086
  sx: {
7068
7087
  display: 'flex',
7069
7088
  flexDirection: 'row',
@@ -7072,6 +7091,7 @@ const TabItem = ({
7072
7091
  columnGap: 1
7073
7092
  },
7074
7093
  children: [LeadingIcon ? /*#__PURE__*/jsxRuntime.jsx(LeadingIcon, {}) : null, /*#__PURE__*/jsxRuntime.jsx(View, {
7094
+ className: 'trk-tab_item__label',
7075
7095
  children: children
7076
7096
  })]
7077
7097
  })
@@ -7241,6 +7261,7 @@ const Tab = ({
7241
7261
  variant = 'plain',
7242
7262
  size = 'm',
7243
7263
  gap = 2,
7264
+ sx,
7244
7265
  children
7245
7266
  }) => {
7246
7267
  const theme = styled.useTheme();
@@ -7282,8 +7303,11 @@ const Tab = ({
7282
7303
  containerRef: rootRef
7283
7304
  },
7284
7305
  children: /*#__PURE__*/jsxRuntime.jsxs(View, {
7306
+ className: 'trk-tab__wrapper',
7285
7307
  position: 'relative',
7308
+ sx: sx,
7286
7309
  children: [/*#__PURE__*/jsxRuntime.jsx(View, {
7310
+ className: 'trk-tab__list',
7287
7311
  ref: rootRef,
7288
7312
  role: 'tablist',
7289
7313
  sx: {
@@ -7301,9 +7325,11 @@ const Tab = ({
7301
7325
  onScroll: throttle__default.default(handleScrollButtonVisibility, 150),
7302
7326
  children: children
7303
7327
  }), /*#__PURE__*/jsxRuntime.jsxs(View, {
7328
+ className: 'trk-tab__navigation',
7304
7329
  display: ['none', 'initial', 'initial'],
7305
7330
  children: [isLeftButtonVisible ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
7306
7331
  children: [/*#__PURE__*/jsxRuntime.jsx(View, {
7332
+ className: 'trk-tab__left_gradient',
7307
7333
  sx: {
7308
7334
  position: 'absolute',
7309
7335
  top: 0,
@@ -7315,6 +7341,7 @@ const Tab = ({
7315
7341
  pointerEvents: 'none'
7316
7342
  }
7317
7343
  }), /*#__PURE__*/jsxRuntime.jsx(View, {
7344
+ className: 'trk-tab__left_button',
7318
7345
  sx: {
7319
7346
  position: 'absolute',
7320
7347
  display: 'flex',
@@ -7333,6 +7360,7 @@ const Tab = ({
7333
7360
  })]
7334
7361
  }) : null, isRightButtonVisible ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
7335
7362
  children: [/*#__PURE__*/jsxRuntime.jsx(View, {
7363
+ className: 'trk-tab__right_gradient',
7336
7364
  sx: {
7337
7365
  position: 'absolute',
7338
7366
  top: 0,
@@ -7344,6 +7372,7 @@ const Tab = ({
7344
7372
  pointerEvents: 'none'
7345
7373
  }
7346
7374
  }), /*#__PURE__*/jsxRuntime.jsx(View, {
7375
+ className: 'trk-tab__right_button',
7347
7376
  sx: {
7348
7377
  position: 'absolute',
7349
7378
  display: 'flex',
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+
3
+ const DialogContext = /*#__PURE__*/createContext({});
4
+
5
+ export { DialogContext as default };
@@ -1,3 +1,4 @@
1
+ import { forcePixelValue } from '@teamturing/utils';
1
2
  import UnstyledDialogHeader from './_UnstyledDialogHeader.js';
2
3
  import { jsx } from 'react/jsx-runtime';
3
4
 
@@ -10,6 +11,7 @@ const DialogHeader = ({
10
11
  sx: {
11
12
  px: 5,
12
13
  py: 4,
14
+ minHeight: forcePixelValue(63),
13
15
  borderBottomWidth: 1,
14
16
  borderBottomStyle: 'solid',
15
17
  borderBottomColor: 'border/neutral',
@@ -1,15 +1,23 @@
1
+ import { useContext } from 'react';
1
2
  import Text from '../Text/index.js';
3
+ import DialogContext from './DialogContext.js';
2
4
  import { jsx } from 'react/jsx-runtime';
3
5
 
4
6
  const DialogHeaderTitle = ({
5
7
  typography = 'm/bold',
6
8
  color = 'text/neutral',
7
9
  ...props
8
- }) => /*#__PURE__*/jsx(Text, {
9
- className: 'trk-dialog_header_title',
10
- typography: typography,
11
- color: color,
12
- ...props
13
- });
10
+ }) => {
11
+ const {
12
+ titleId
13
+ } = useContext(DialogContext);
14
+ return /*#__PURE__*/jsx(Text, {
15
+ id: titleId,
16
+ className: 'trk-dialog_header_title',
17
+ typography: typography,
18
+ color: color,
19
+ ...props
20
+ });
21
+ };
14
22
 
15
23
  export { DialogHeaderTitle as default };
@@ -1,7 +1,7 @@
1
1
  import { CloseIcon } from '@teamturing/icons';
2
2
  import { forcePixelValue } from '@teamturing/utils';
3
3
  import { AnimatePresence, cubicBezier } from 'framer-motion';
4
- import { forwardRef, useCallback, useRef, useImperativeHandle, useEffect } from 'react';
4
+ import { forwardRef, useId, useCallback, useRef, useImperativeHandle, useEffect } from 'react';
5
5
  import styled, { useTheme } from 'styled-components';
6
6
  import IconButton from '../IconButton/index.js';
7
7
  import View from '../View/index.js';
@@ -9,6 +9,7 @@ import useFocusTrap from '../../hook/useFocusTrap.js';
9
9
  import { sx } from '../../utils/styled-system/index.js';
10
10
  import MotionView from '../MotionView/index.js';
11
11
  import DialogBody from './DialogBody.js';
12
+ import DialogContext from './DialogContext.js';
12
13
  import DialogFooter from './DialogFooter.js';
13
14
  import DialogHeader from './DialogHeader.js';
14
15
  import DialogHeaderSubtitle from './DialogHeaderSubtitle.js';
@@ -28,6 +29,7 @@ const Dialog = ({
28
29
  sx
29
30
  }, ref) => {
30
31
  const theme = useTheme();
32
+ const titleId = useId();
31
33
  const handleDismiss = useCallback(() => onDismiss?.(), [onDismiss]);
32
34
  const blanketRef = useRef(null);
33
35
  const dialogRef = useRef(null);
@@ -49,7 +51,8 @@ const Dialog = ({
49
51
  useFocusTrap({
50
52
  containerRef: dialogRef,
51
53
  initialFocusRef: initialFocusRef || closeButtonRef,
52
- disabled: !isOpen
54
+ disabled: !isOpen,
55
+ restoreFocusOnCleanUp: true
53
56
  });
54
57
  useEffect(() => {
55
58
  if (isOpen && isOutsideClickDismissable) {
@@ -99,6 +102,7 @@ const Dialog = ({
99
102
  className: `trk-dialog--${size}`,
100
103
  ref: dialogRef,
101
104
  "aria-modal": 'true',
105
+ "aria-labelledby": titleId,
102
106
  role: 'dialog',
103
107
  tabIndex: -1,
104
108
  sx: {
@@ -148,7 +152,12 @@ const Dialog = ({
148
152
  size: 'm',
149
153
  onClick: handleDismiss
150
154
  })
151
- }), children]
155
+ }), /*#__PURE__*/jsx(DialogContext.Provider, {
156
+ value: {
157
+ titleId
158
+ },
159
+ children: children
160
+ })]
152
161
  })
153
162
  })]
154
163
  })
@@ -38,6 +38,7 @@ const TabItem = ({
38
38
  onClick?.(e);
39
39
  };
40
40
  return /*#__PURE__*/jsx(BaseTabItem, {
41
+ className: 'trk-tab_item',
41
42
  type: 'button',
42
43
  role: 'tab',
43
44
  ref: ref,
@@ -47,6 +48,7 @@ const TabItem = ({
47
48
  selected: selected,
48
49
  onClick: handleClick,
49
50
  children: /*#__PURE__*/jsxs(View, {
51
+ className: 'trk-tab_item__content',
50
52
  sx: {
51
53
  display: 'flex',
52
54
  flexDirection: 'row',
@@ -55,6 +57,7 @@ const TabItem = ({
55
57
  columnGap: 1
56
58
  },
57
59
  children: [LeadingIcon ? /*#__PURE__*/jsx(LeadingIcon, {}) : null, /*#__PURE__*/jsx(View, {
60
+ className: 'trk-tab_item__label',
58
61
  children: children
59
62
  })]
60
63
  })
@@ -14,6 +14,7 @@ const Tab = ({
14
14
  variant = 'plain',
15
15
  size = 'm',
16
16
  gap = 2,
17
+ sx,
17
18
  children
18
19
  }) => {
19
20
  const theme = useTheme();
@@ -55,8 +56,11 @@ const Tab = ({
55
56
  containerRef: rootRef
56
57
  },
57
58
  children: /*#__PURE__*/jsxs(View, {
59
+ className: 'trk-tab__wrapper',
58
60
  position: 'relative',
61
+ sx: sx,
59
62
  children: [/*#__PURE__*/jsx(View, {
63
+ className: 'trk-tab__list',
60
64
  ref: rootRef,
61
65
  role: 'tablist',
62
66
  sx: {
@@ -74,9 +78,11 @@ const Tab = ({
74
78
  onScroll: throttle(handleScrollButtonVisibility, 150),
75
79
  children: children
76
80
  }), /*#__PURE__*/jsxs(View, {
81
+ className: 'trk-tab__navigation',
77
82
  display: ['none', 'initial', 'initial'],
78
83
  children: [isLeftButtonVisible ? /*#__PURE__*/jsxs(Fragment, {
79
84
  children: [/*#__PURE__*/jsx(View, {
85
+ className: 'trk-tab__left_gradient',
80
86
  sx: {
81
87
  position: 'absolute',
82
88
  top: 0,
@@ -88,6 +94,7 @@ const Tab = ({
88
94
  pointerEvents: 'none'
89
95
  }
90
96
  }), /*#__PURE__*/jsx(View, {
97
+ className: 'trk-tab__left_button',
91
98
  sx: {
92
99
  position: 'absolute',
93
100
  display: 'flex',
@@ -106,6 +113,7 @@ const Tab = ({
106
113
  })]
107
114
  }) : null, isRightButtonVisible ? /*#__PURE__*/jsxs(Fragment, {
108
115
  children: [/*#__PURE__*/jsx(View, {
116
+ className: 'trk-tab__right_gradient',
109
117
  sx: {
110
118
  position: 'absolute',
111
119
  top: 0,
@@ -117,6 +125,7 @@ const Tab = ({
117
125
  pointerEvents: 'none'
118
126
  }
119
127
  }), /*#__PURE__*/jsx(View, {
128
+ className: 'trk-tab__right_button',
120
129
  sx: {
121
130
  position: 'absolute',
122
131
  display: 'flex',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.67.1",
3
+ "version": "2.69.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": "3c0e01658258a289c7cf02291609a90b166588ba"
68
+ "gitHead": "116ff31ab9416028bc458439c710c91122326fee"
69
69
  }