@teamturing/react-kit 2.19.13 → 2.19.14
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.
|
@@ -19,7 +19,9 @@ type Props = {
|
|
|
19
19
|
placement?: Placement;
|
|
20
20
|
focusZoneSettings?: Partial<FocusZoneHookSettings>;
|
|
21
21
|
focusTrapSettings?: Partial<FocusTrapHookSettings>;
|
|
22
|
+
onOpen?: () => void;
|
|
23
|
+
onClose?: () => void;
|
|
22
24
|
};
|
|
23
|
-
declare const OverlayPopper: ({ children: propChildren, renderOverlay, placement, focusZoneSettings, focusTrapSettings, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare const OverlayPopper: ({ children: propChildren, renderOverlay, placement, focusZoneSettings, focusTrapSettings, onOpen, onClose, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
export default OverlayPopper;
|
|
25
27
|
export type { Props as OverlayPopperProps };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ElementType, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
|
|
1
|
+
import { ElementType, InputHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { OverlayPopperProps } from '../OverlayPopper';
|
|
3
|
+
type Props<T extends {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string | number | readonly string[];
|
|
6
|
+
}> = {
|
|
3
7
|
/**
|
|
4
8
|
* TODO asdf
|
|
5
9
|
*/
|
|
@@ -8,8 +12,19 @@ type Props = {
|
|
|
8
12
|
* 입력 창 앞에 보여질 시각적 요소를 정의합니다. Icon, Text, Image 등이 될 수 있습니다.
|
|
9
13
|
*/
|
|
10
14
|
leadingVisual?: ElementType | ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
15
|
+
children: ({ handleSelect }: {
|
|
16
|
+
handleSelect: (item: T) => void;
|
|
17
|
+
}) => ReactNode;
|
|
18
|
+
onChange?: (item: T) => void;
|
|
19
|
+
} & Pick<OverlayPopperProps, 'focusTrapSettings' | 'focusZoneSettings' | 'onClose' | 'onOpen'> & Pick<InputHTMLAttributes<HTMLInputElement>, 'id' | 'disabled' | 'onClick' | 'placeholder'>;
|
|
20
|
+
declare const OverlaySelectInput: <T extends {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string | number | readonly string[];
|
|
23
|
+
}>({ validationStatus, leadingVisual: LeadingVisual, children, onChange, focusTrapSettings, focusZoneSettings, onOpen, onClose, ...props }: Props<T>, ref: Ref<HTMLInputElement>) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare const _default: <T extends {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string | number | readonly string[];
|
|
27
|
+
}>(props: {
|
|
13
28
|
/**
|
|
14
29
|
* TODO asdf
|
|
15
30
|
*/
|
|
@@ -18,8 +33,12 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
18
33
|
* 입력 창 앞에 보여질 시각적 요소를 정의합니다. Icon, Text, Image 등이 될 수 있습니다.
|
|
19
34
|
*/
|
|
20
35
|
leadingVisual?: string | number | boolean | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | import("react").ReactPortal | null | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
36
|
+
children: ({ handleSelect }: {
|
|
37
|
+
handleSelect: (item: T) => void;
|
|
38
|
+
}) => ReactNode;
|
|
39
|
+
onChange?: ((item: T) => void) | undefined;
|
|
40
|
+
} & Pick<OverlayPopperProps, "onClose" | "focusZoneSettings" | "focusTrapSettings" | "onOpen"> & Pick<InputHTMLAttributes<HTMLInputElement>, "disabled" | "placeholder" | "id" | "onClick"> & {
|
|
41
|
+
ref?: Ref<HTMLInputElement> | undefined;
|
|
42
|
+
}) => ReturnType<typeof OverlaySelectInput>;
|
|
24
43
|
export default _default;
|
|
25
44
|
export type { Props as OverlaySelectInputProps };
|
package/dist/index.js
CHANGED
|
@@ -20840,7 +20840,9 @@ const OverlayPopper = ({
|
|
|
20840
20840
|
renderOverlay,
|
|
20841
20841
|
placement = 'bottom-start',
|
|
20842
20842
|
focusZoneSettings,
|
|
20843
|
-
focusTrapSettings
|
|
20843
|
+
focusTrapSettings,
|
|
20844
|
+
onOpen,
|
|
20845
|
+
onClose
|
|
20844
20846
|
}) => {
|
|
20845
20847
|
const {
|
|
20846
20848
|
refs,
|
|
@@ -20861,11 +20863,23 @@ const OverlayPopper = ({
|
|
|
20861
20863
|
} = useToggleHandler({
|
|
20862
20864
|
initialState: false
|
|
20863
20865
|
});
|
|
20864
|
-
const
|
|
20866
|
+
const handleOverlayToggle = () => {
|
|
20867
|
+
if (!isOpen) onOpen?.();else onClose?.();
|
|
20868
|
+
toggleOverlay();
|
|
20869
|
+
};
|
|
20870
|
+
const handleOverlayOpen = () => {
|
|
20871
|
+
onOpen?.();
|
|
20872
|
+
openOverlay();
|
|
20873
|
+
};
|
|
20874
|
+
const handleOverlayClose = () => {
|
|
20875
|
+
onClose?.();
|
|
20865
20876
|
closeOverlay();
|
|
20866
20877
|
};
|
|
20878
|
+
const handleDismiss = () => {
|
|
20879
|
+
handleOverlayClose();
|
|
20880
|
+
};
|
|
20867
20881
|
const defaultPopperProps = {
|
|
20868
|
-
onClick:
|
|
20882
|
+
onClick: handleOverlayToggle,
|
|
20869
20883
|
tabIndex: 0,
|
|
20870
20884
|
...{
|
|
20871
20885
|
ref: refs.setReference
|
|
@@ -20875,7 +20889,7 @@ const OverlayPopper = ({
|
|
|
20875
20889
|
...defaultPopperProps
|
|
20876
20890
|
}, {
|
|
20877
20891
|
isOpen,
|
|
20878
|
-
openOverlay
|
|
20892
|
+
openOverlay: handleOverlayOpen
|
|
20879
20893
|
}) : React.Children.map(propChildren, child => /*#__PURE__*/React.cloneElement(child, {
|
|
20880
20894
|
...defaultPopperProps
|
|
20881
20895
|
}));
|
|
@@ -20901,7 +20915,7 @@ const OverlayPopper = ({
|
|
|
20901
20915
|
onDismiss: handleDismiss
|
|
20902
20916
|
}, {
|
|
20903
20917
|
isOpen,
|
|
20904
|
-
closeOverlay
|
|
20918
|
+
closeOverlay: handleOverlayClose
|
|
20905
20919
|
}, {
|
|
20906
20920
|
elements
|
|
20907
20921
|
})]
|
|
@@ -20912,16 +20926,41 @@ const OverlaySelectInput = ({
|
|
|
20912
20926
|
validationStatus,
|
|
20913
20927
|
leadingVisual: LeadingVisual,
|
|
20914
20928
|
children,
|
|
20929
|
+
onChange,
|
|
20930
|
+
focusTrapSettings,
|
|
20931
|
+
focusZoneSettings,
|
|
20932
|
+
onOpen,
|
|
20933
|
+
onClose,
|
|
20915
20934
|
...props
|
|
20916
20935
|
}, ref) => {
|
|
20917
|
-
const
|
|
20936
|
+
const valueInputRef = useProvidedOrCreatedRef(ref);
|
|
20937
|
+
const labelInputRef = React.useRef(null);
|
|
20918
20938
|
const focusInput = () => {
|
|
20919
|
-
|
|
20939
|
+
labelInputRef.current?.focus();
|
|
20920
20940
|
};
|
|
20921
20941
|
const {
|
|
20922
|
-
|
|
20942
|
+
id,
|
|
20943
|
+
disabled,
|
|
20944
|
+
placeholder
|
|
20923
20945
|
} = props;
|
|
20946
|
+
const handleSelect = item => {
|
|
20947
|
+
if (labelInputRef.current && valueInputRef.current) {
|
|
20948
|
+
labelInputRef.current.setAttribute('value', item.label);
|
|
20949
|
+
|
|
20950
|
+
/**
|
|
20951
|
+
* ! valueInput의 native onChange를 trigger하려고 했으나 작동하지 않음.
|
|
20952
|
+
* ! 일단 Custom onChange를 만들어서 해결.
|
|
20953
|
+
*/
|
|
20954
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
|
|
20955
|
+
nativeInputValueSetter?.call(valueInputRef.current, item.value.toString());
|
|
20956
|
+
onChange?.(item);
|
|
20957
|
+
}
|
|
20958
|
+
};
|
|
20924
20959
|
return /*#__PURE__*/jsxRuntimeExports.jsx(OverlayPopper, {
|
|
20960
|
+
focusTrapSettings: focusTrapSettings,
|
|
20961
|
+
focusZoneSettings: focusZoneSettings,
|
|
20962
|
+
onOpen: onOpen,
|
|
20963
|
+
onClose: onClose,
|
|
20925
20964
|
renderOverlay: (overlayProps, _, {
|
|
20926
20965
|
elements
|
|
20927
20966
|
}) => /*#__PURE__*/jsxRuntimeExports.jsx(Overlay$1, {
|
|
@@ -20930,7 +20969,9 @@ const OverlaySelectInput = ({
|
|
|
20930
20969
|
...overlayProps.style,
|
|
20931
20970
|
width: elements?.reference?.getBoundingClientRect().width
|
|
20932
20971
|
},
|
|
20933
|
-
children: children
|
|
20972
|
+
children: children?.({
|
|
20973
|
+
handleSelect
|
|
20974
|
+
})
|
|
20934
20975
|
}),
|
|
20935
20976
|
children: (popperProps, {
|
|
20936
20977
|
openOverlay
|
|
@@ -20962,19 +21003,16 @@ const OverlaySelectInput = ({
|
|
|
20962
21003
|
},
|
|
20963
21004
|
children: typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual
|
|
20964
21005
|
}), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput$1, {
|
|
20965
|
-
|
|
20966
|
-
|
|
20967
|
-
inputRef.current = e;
|
|
20968
|
-
},
|
|
20969
|
-
value: '',
|
|
21006
|
+
id: id,
|
|
21007
|
+
ref: labelInputRef,
|
|
20970
21008
|
onChange: noop$2,
|
|
20971
|
-
...props,
|
|
20972
21009
|
autoComplete: 'off',
|
|
20973
21010
|
tabIndex: -1,
|
|
20974
21011
|
onClick: e => {
|
|
20975
21012
|
popperProps.onClick?.(e);
|
|
20976
21013
|
props.onClick?.(e);
|
|
20977
|
-
}
|
|
21014
|
+
},
|
|
21015
|
+
placeholder: placeholder
|
|
20978
21016
|
}), /*#__PURE__*/jsxRuntimeExports.jsx(StyledIcon, {
|
|
20979
21017
|
sx: {
|
|
20980
21018
|
position: 'absolute',
|
|
@@ -20986,6 +21024,12 @@ const OverlaySelectInput = ({
|
|
|
20986
21024
|
icon: SvgChevronDown,
|
|
20987
21025
|
color: disabled ? 'icon/disabled' : 'icon/neutral/bolder',
|
|
20988
21026
|
size: 16
|
|
21027
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput$1, {
|
|
21028
|
+
ref: e => {
|
|
21029
|
+
isFunction(ref) ? ref(e) : null;
|
|
21030
|
+
valueInputRef.current = e;
|
|
21031
|
+
},
|
|
21032
|
+
type: 'hidden'
|
|
20989
21033
|
})]
|
|
20990
21034
|
})
|
|
20991
21035
|
});
|
|
@@ -15,7 +15,9 @@ const OverlayPopper = ({
|
|
|
15
15
|
renderOverlay,
|
|
16
16
|
placement = 'bottom-start',
|
|
17
17
|
focusZoneSettings,
|
|
18
|
-
focusTrapSettings
|
|
18
|
+
focusTrapSettings,
|
|
19
|
+
onOpen,
|
|
20
|
+
onClose
|
|
19
21
|
}) => {
|
|
20
22
|
const {
|
|
21
23
|
refs,
|
|
@@ -36,11 +38,23 @@ const OverlayPopper = ({
|
|
|
36
38
|
} = useToggleHandler({
|
|
37
39
|
initialState: false
|
|
38
40
|
});
|
|
39
|
-
const
|
|
41
|
+
const handleOverlayToggle = () => {
|
|
42
|
+
if (!isOpen) onOpen?.();else onClose?.();
|
|
43
|
+
toggleOverlay();
|
|
44
|
+
};
|
|
45
|
+
const handleOverlayOpen = () => {
|
|
46
|
+
onOpen?.();
|
|
47
|
+
openOverlay();
|
|
48
|
+
};
|
|
49
|
+
const handleOverlayClose = () => {
|
|
50
|
+
onClose?.();
|
|
40
51
|
closeOverlay();
|
|
41
52
|
};
|
|
53
|
+
const handleDismiss = () => {
|
|
54
|
+
handleOverlayClose();
|
|
55
|
+
};
|
|
42
56
|
const defaultPopperProps = {
|
|
43
|
-
onClick:
|
|
57
|
+
onClick: handleOverlayToggle,
|
|
44
58
|
tabIndex: 0,
|
|
45
59
|
...{
|
|
46
60
|
ref: refs.setReference
|
|
@@ -50,7 +64,7 @@ const OverlayPopper = ({
|
|
|
50
64
|
...defaultPopperProps
|
|
51
65
|
}, {
|
|
52
66
|
isOpen,
|
|
53
|
-
openOverlay
|
|
67
|
+
openOverlay: handleOverlayOpen
|
|
54
68
|
}) : Children.map(propChildren, child => /*#__PURE__*/cloneElement(child, {
|
|
55
69
|
...defaultPopperProps
|
|
56
70
|
}));
|
|
@@ -76,7 +90,7 @@ const OverlayPopper = ({
|
|
|
76
90
|
onDismiss: handleDismiss
|
|
77
91
|
}, {
|
|
78
92
|
isOpen,
|
|
79
|
-
closeOverlay
|
|
93
|
+
closeOverlay: handleOverlayClose
|
|
80
94
|
}, {
|
|
81
95
|
elements
|
|
82
96
|
})]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useRef } from 'react';
|
|
2
2
|
import SvgChevronDown from '../../packages/icons/esm/ChevronDown.js';
|
|
3
3
|
import { forcePixelValue } from '../../packages/utils/esm/forcePixelValue.js';
|
|
4
4
|
import { isFunction } from '../../packages/utils/esm/isFunction.js';
|
|
@@ -17,16 +17,41 @@ const OverlaySelectInput = ({
|
|
|
17
17
|
validationStatus,
|
|
18
18
|
leadingVisual: LeadingVisual,
|
|
19
19
|
children,
|
|
20
|
+
onChange,
|
|
21
|
+
focusTrapSettings,
|
|
22
|
+
focusZoneSettings,
|
|
23
|
+
onOpen,
|
|
24
|
+
onClose,
|
|
20
25
|
...props
|
|
21
26
|
}, ref) => {
|
|
22
|
-
const
|
|
27
|
+
const valueInputRef = useProvidedOrCreatedRef(ref);
|
|
28
|
+
const labelInputRef = useRef(null);
|
|
23
29
|
const focusInput = () => {
|
|
24
|
-
|
|
30
|
+
labelInputRef.current?.focus();
|
|
25
31
|
};
|
|
26
32
|
const {
|
|
27
|
-
|
|
33
|
+
id,
|
|
34
|
+
disabled,
|
|
35
|
+
placeholder
|
|
28
36
|
} = props;
|
|
37
|
+
const handleSelect = item => {
|
|
38
|
+
if (labelInputRef.current && valueInputRef.current) {
|
|
39
|
+
labelInputRef.current.setAttribute('value', item.label);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* ! valueInput의 native onChange를 trigger하려고 했으나 작동하지 않음.
|
|
43
|
+
* ! 일단 Custom onChange를 만들어서 해결.
|
|
44
|
+
*/
|
|
45
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
|
|
46
|
+
nativeInputValueSetter?.call(valueInputRef.current, item.value.toString());
|
|
47
|
+
onChange?.(item);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
29
50
|
return /*#__PURE__*/jsxRuntimeExports.jsx(OverlayPopper, {
|
|
51
|
+
focusTrapSettings: focusTrapSettings,
|
|
52
|
+
focusZoneSettings: focusZoneSettings,
|
|
53
|
+
onOpen: onOpen,
|
|
54
|
+
onClose: onClose,
|
|
30
55
|
renderOverlay: (overlayProps, _, {
|
|
31
56
|
elements
|
|
32
57
|
}) => /*#__PURE__*/jsxRuntimeExports.jsx(Overlay, {
|
|
@@ -35,7 +60,9 @@ const OverlaySelectInput = ({
|
|
|
35
60
|
...overlayProps.style,
|
|
36
61
|
width: elements?.reference?.getBoundingClientRect().width
|
|
37
62
|
},
|
|
38
|
-
children: children
|
|
63
|
+
children: children?.({
|
|
64
|
+
handleSelect
|
|
65
|
+
})
|
|
39
66
|
}),
|
|
40
67
|
children: (popperProps, {
|
|
41
68
|
openOverlay
|
|
@@ -67,19 +94,16 @@ const OverlaySelectInput = ({
|
|
|
67
94
|
},
|
|
68
95
|
children: typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual
|
|
69
96
|
}), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput, {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
inputRef.current = e;
|
|
73
|
-
},
|
|
74
|
-
value: '',
|
|
97
|
+
id: id,
|
|
98
|
+
ref: labelInputRef,
|
|
75
99
|
onChange: noop,
|
|
76
|
-
...props,
|
|
77
100
|
autoComplete: 'off',
|
|
78
101
|
tabIndex: -1,
|
|
79
102
|
onClick: e => {
|
|
80
103
|
popperProps.onClick?.(e);
|
|
81
104
|
props.onClick?.(e);
|
|
82
|
-
}
|
|
105
|
+
},
|
|
106
|
+
placeholder: placeholder
|
|
83
107
|
}), /*#__PURE__*/jsxRuntimeExports.jsx(StyledIcon, {
|
|
84
108
|
sx: {
|
|
85
109
|
position: 'absolute',
|
|
@@ -91,6 +115,12 @@ const OverlaySelectInput = ({
|
|
|
91
115
|
icon: SvgChevronDown,
|
|
92
116
|
color: disabled ? 'icon/disabled' : 'icon/neutral/bolder',
|
|
93
117
|
size: 16
|
|
118
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput, {
|
|
119
|
+
ref: e => {
|
|
120
|
+
isFunction(ref) ? ref(e) : null;
|
|
121
|
+
valueInputRef.current = e;
|
|
122
|
+
},
|
|
123
|
+
type: 'hidden'
|
|
94
124
|
})]
|
|
95
125
|
})
|
|
96
126
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamturing/react-kit",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.14",
|
|
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": "73771f9a29466d5aa4a9e075623a6543d173004c"
|
|
66
66
|
}
|