@teamturing/react-kit 2.15.0 → 2.16.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.
- package/dist/core/ActionList/ActionListItem.d.ts +15 -0
- package/dist/core/ActionList/ActionListSectionDivider.d.ts +5 -0
- package/dist/core/ActionList/ActionListSectionHeader.d.ts +6 -0
- package/dist/core/ActionList/index.d.ts +21 -0
- package/dist/core/Overlay/index.d.ts +2 -0
- package/dist/hook/useSafeLayoutEffect.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -2
- package/esm/core/Checkbox/index.js +3 -2
- package/esm/core/Overlay/index.js +9 -1
- package/esm/core/OverlayPopper/index.js +1 -0
- package/esm/hook/useSafeLayoutEffect.js +5 -0
- package/esm/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElementType, PropsWithChildren, ReactNode, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
|
+
import { SxProp } from '../../utils/styled-system';
|
|
3
|
+
type Props = {
|
|
4
|
+
variant?: 'neutral' | 'danger';
|
|
5
|
+
leadingVisual?: ElementType | ReactNode;
|
|
6
|
+
trailingVisual?: ElementType | ReactNode;
|
|
7
|
+
description?: string;
|
|
8
|
+
descriptionLayout?: 'inline' | 'block';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
onSelect?: (event: ReactMouseEvent<HTMLLIElement> | ReactKeyboardEvent<HTMLLIElement>) => void;
|
|
12
|
+
} & SxProp;
|
|
13
|
+
declare const ActionListItem: ({ variant, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, description, descriptionLayout, disabled, selected, onSelect: propOnSelect, children, sx, }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default ActionListItem;
|
|
15
|
+
export type { Props as ActionListItemProps };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HorizontalDividerProps } from '../HorizontalDivider';
|
|
2
|
+
type Props = {} & HorizontalDividerProps;
|
|
3
|
+
declare const ActionListSectionDivider: ({ color, variant, width, sx }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default ActionListSectionDivider;
|
|
5
|
+
export type { Props as ActionListSectionDividerProps };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { SxProp } from '../../utils/styled-system';
|
|
3
|
+
type Props = {} & SxProp;
|
|
4
|
+
declare const ActionListSectionHeader: ({ ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export default ActionListSectionHeader;
|
|
6
|
+
export type { Props as ActionListSectionHeaderProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { SxProp } from '../../utils/styled-system';
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* ActionList의 아이템에 선택이 되어있다는 것을 표시할 때 사용하는 속성입니다.
|
|
6
|
+
* `undefine`: 선택에 대한 표시를 하지 않습니다.
|
|
7
|
+
* `single`: 하나의 선택된 아이템에 대해, CheckIcon을 보여줍니다.
|
|
8
|
+
* `multiple`: 모든 아이템에 Checkbox를 표시합니다.
|
|
9
|
+
*/
|
|
10
|
+
selectionVariant?: 'single' | 'multiple';
|
|
11
|
+
} & SxProp;
|
|
12
|
+
type ActionListContextValue = {} & Pick<Props, 'selectionVariant'>;
|
|
13
|
+
declare const ActionListContext: import("react").Context<Pick<Props, "selectionVariant">>;
|
|
14
|
+
declare const _default: (({ ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element) & {
|
|
15
|
+
Item: ({ variant, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, description, descriptionLayout, disabled, selected, onSelect: propOnSelect, children, sx, }: PropsWithChildren<import("./ActionListItem").ActionListItemProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
SectionDivider: ({ color, variant, width, sx }: import("./ActionListSectionDivider").ActionListSectionDividerProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
SectionHeader: ({ ...props }: PropsWithChildren<SxProp>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
20
|
+
export { ActionListContext };
|
|
21
|
+
export type { Props as ActionListProps, ActionListContextValue };
|
|
@@ -5,12 +5,14 @@ type Props = {
|
|
|
5
5
|
onDismiss?: () => void;
|
|
6
6
|
size?: ResponsiveValue<'m'>;
|
|
7
7
|
ignoreOutsideClickRefs?: RefObject<HTMLElement>[];
|
|
8
|
+
dismissFocusRef?: RefObject<HTMLElement>;
|
|
8
9
|
} & HTMLAttributes<HTMLElement>;
|
|
9
10
|
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
10
11
|
isOpen?: boolean | undefined;
|
|
11
12
|
onDismiss?: (() => void) | undefined;
|
|
12
13
|
size?: ResponsiveValue<"m"> | undefined;
|
|
13
14
|
ignoreOutsideClickRefs?: RefObject<HTMLElement>[] | undefined;
|
|
15
|
+
dismissFocusRef?: RefObject<HTMLElement> | undefined;
|
|
14
16
|
} & HTMLAttributes<HTMLElement> & {
|
|
15
17
|
children?: import("react").ReactNode;
|
|
16
18
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export { default as useOutsideClick } from './hook/useOutsideClick';
|
|
|
86
86
|
export { default as useProvidedOrCreatedRef } from './hook/useProvidedOrCreatedRef';
|
|
87
87
|
export { default as useRelocation } from './hook/useRelocation';
|
|
88
88
|
export { default as useResize } from './hook/useResize';
|
|
89
|
+
export { default as useSafeLayoutEffect } from './hook/useSafeLayoutEffect';
|
|
89
90
|
export { default as useToggleHandler } from './hook/useToggleHandler';
|
|
90
91
|
/**
|
|
91
92
|
* theme
|
package/dist/index.js
CHANGED
|
@@ -16256,6 +16256,8 @@ const useProvidedOrCreatedRef = providedRef => {
|
|
|
16256
16256
|
return providedRef ?? createdRef;
|
|
16257
16257
|
};
|
|
16258
16258
|
|
|
16259
|
+
const useSafeLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
16260
|
+
|
|
16259
16261
|
const Checkbox = ({
|
|
16260
16262
|
checked,
|
|
16261
16263
|
validationStatus,
|
|
@@ -16263,7 +16265,7 @@ const Checkbox = ({
|
|
|
16263
16265
|
...props
|
|
16264
16266
|
}, ref) => {
|
|
16265
16267
|
const checkboxRef = useProvidedOrCreatedRef(ref);
|
|
16266
|
-
|
|
16268
|
+
useSafeLayoutEffect(() => {
|
|
16267
16269
|
if (checkboxRef.current) {
|
|
16268
16270
|
checkboxRef.current.indeterminate = indeterminate || false;
|
|
16269
16271
|
}
|
|
@@ -18515,11 +18517,19 @@ const Overlay = ({
|
|
|
18515
18517
|
onDismiss,
|
|
18516
18518
|
size = 'm',
|
|
18517
18519
|
ignoreOutsideClickRefs = [],
|
|
18520
|
+
dismissFocusRef,
|
|
18518
18521
|
...props
|
|
18519
18522
|
}, ref) => {
|
|
18520
18523
|
const overlayRef = React.useRef(null);
|
|
18521
18524
|
React.useImperativeHandle(ref, () => overlayRef.current);
|
|
18522
|
-
const handleDismiss = React.useCallback(() =>
|
|
18525
|
+
const handleDismiss = React.useCallback(() => {
|
|
18526
|
+
if (dismissFocusRef && dismissFocusRef.current) {
|
|
18527
|
+
setTimeout(() => {
|
|
18528
|
+
dismissFocusRef.current?.focus();
|
|
18529
|
+
}, 0);
|
|
18530
|
+
}
|
|
18531
|
+
onDismiss?.();
|
|
18532
|
+
}, [onDismiss]);
|
|
18523
18533
|
const handleOutsideClick = React.useCallback(e => {
|
|
18524
18534
|
if (overlayRef.current && e.target instanceof Node && !overlayRef.current.contains(e.target) && ignoreOutsideClickRefs && !ignoreOutsideClickRefs.some(({
|
|
18525
18535
|
current
|
|
@@ -20221,6 +20231,7 @@ const OverlayPopper = ({
|
|
|
20221
20231
|
ref: refs.setFloating,
|
|
20222
20232
|
isOpen: isOpen,
|
|
20223
20233
|
onDismiss: closeOverlay,
|
|
20234
|
+
dismissFocusRef: refs.reference,
|
|
20224
20235
|
ignoreOutsideClickRefs: [refs.reference],
|
|
20225
20236
|
style: floatingStyles,
|
|
20226
20237
|
children: renderOverlay({
|
|
@@ -22907,6 +22918,7 @@ exports.useOutsideClick = useOutsideClick;
|
|
|
22907
22918
|
exports.useProvidedOrCreatedRef = useProvidedOrCreatedRef;
|
|
22908
22919
|
exports.useRelocation = useRelocation;
|
|
22909
22920
|
exports.useResize = useResize;
|
|
22921
|
+
exports.useSafeLayoutEffect = useSafeLayoutEffect;
|
|
22910
22922
|
exports.useToggleHandler = useToggleHandler;
|
|
22911
22923
|
exports.whiteSpace = whiteSpace;
|
|
22912
22924
|
exports.wordBreak = wordBreak;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { forwardRef
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import useProvidedOrCreatedRef from '../../hook/useProvidedOrCreatedRef.js';
|
|
4
|
+
import useSafeLayoutEffect from '../../hook/useSafeLayoutEffect.js';
|
|
4
5
|
import { forcePixelValue } from '../../utils/forcePixelValue.js';
|
|
5
6
|
import { sx } from '../../utils/styled-system/index.js';
|
|
6
7
|
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
@@ -12,7 +13,7 @@ const Checkbox = ({
|
|
|
12
13
|
...props
|
|
13
14
|
}, ref) => {
|
|
14
15
|
const checkboxRef = useProvidedOrCreatedRef(ref);
|
|
15
|
-
|
|
16
|
+
useSafeLayoutEffect(() => {
|
|
16
17
|
if (checkboxRef.current) {
|
|
17
18
|
checkboxRef.current.indeterminate = indeterminate || false;
|
|
18
19
|
}
|
|
@@ -13,11 +13,19 @@ const Overlay = ({
|
|
|
13
13
|
onDismiss,
|
|
14
14
|
size = 'm',
|
|
15
15
|
ignoreOutsideClickRefs = [],
|
|
16
|
+
dismissFocusRef,
|
|
16
17
|
...props
|
|
17
18
|
}, ref) => {
|
|
18
19
|
const overlayRef = useRef(null);
|
|
19
20
|
useImperativeHandle(ref, () => overlayRef.current);
|
|
20
|
-
const handleDismiss = useCallback(() =>
|
|
21
|
+
const handleDismiss = useCallback(() => {
|
|
22
|
+
if (dismissFocusRef && dismissFocusRef.current) {
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
dismissFocusRef.current?.focus();
|
|
25
|
+
}, 0);
|
|
26
|
+
}
|
|
27
|
+
onDismiss?.();
|
|
28
|
+
}, [onDismiss]);
|
|
21
29
|
const handleOutsideClick = useCallback(e => {
|
|
22
30
|
if (overlayRef.current && e.target instanceof Node && !overlayRef.current.contains(e.target) && ignoreOutsideClickRefs && !ignoreOutsideClickRefs.some(({
|
|
23
31
|
current
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useLayoutEffect, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useSafeLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
|
4
|
+
|
|
5
|
+
export { useSafeLayoutEffect as default };
|
package/esm/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { default as useOutsideClick } from './hook/useOutsideClick.js';
|
|
|
43
43
|
export { default as useProvidedOrCreatedRef } from './hook/useProvidedOrCreatedRef.js';
|
|
44
44
|
export { default as useRelocation } from './hook/useRelocation.js';
|
|
45
45
|
export { default as useResize } from './hook/useResize.js';
|
|
46
|
+
export { default as useSafeLayoutEffect } from './hook/useSafeLayoutEffect.js';
|
|
46
47
|
export { default as useToggleHandler } from './hook/useToggleHandler.js';
|
|
47
48
|
export { default as theme } from './theme/index.js';
|
|
48
49
|
export { lineClamp, sx, textDecoration, whiteSpace, wordBreak } from './utils/styled-system/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamturing/react-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.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",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"react-is": "^18.2.0",
|
|
63
63
|
"styled-system": "^5.1.5"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "8b02a8dd365e7ddc45036f1dd2fd05ebcbf03f72"
|
|
66
66
|
}
|