@teamturing/react-kit 2.67.1 → 2.68.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 };
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
  })
@@ -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
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.67.1",
3
+ "version": "2.68.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": "367ba22b7504f2ac19a89ca49cf5deeeb8034592"
69
69
  }