@teamturing/react-kit 2.19.12 → 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.
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { SxProp } from '../../utils/styled-system';
3
+ type FlashVariantType = 'danger';
4
+ type Props = {
5
+ variant?: FlashVariantType;
6
+ } & SxProp;
7
+ declare const Flash: ({ variant, children, ...props }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
8
+ export default Flash;
9
+ export type { Props as FlashProps };
@@ -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
- type Props = {
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
- } & InputHTMLAttributes<HTMLInputElement>;
12
- declare const _default: import("react").ForwardRefExoticComponent<{
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
- } & InputHTMLAttributes<HTMLInputElement> & {
22
- children?: ReactNode;
23
- } & import("react").RefAttributes<HTMLInputElement>>;
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.d.ts CHANGED
@@ -27,6 +27,8 @@ export { default as Dialog } from './core/Dialog';
27
27
  export type { DialogProps, UnstyledDialogHeaderProps, UnstyledDialogBodyProps, UnstyledDialogFooterProps, DialogHeaderProps, DialogHeaderTitleProps, DialogHeaderSubtitleProps, DialogBodyProps, DialogFooterProps, } from './core/Dialog';
28
28
  export { default as EmptyState } from './core/EmptyState';
29
29
  export type { EmptyStateProps } from './core/EmptyState';
30
+ export { default as Flash } from './core/Flash';
31
+ export type { FlashProps } from './core/Flash';
30
32
  export { default as FormControl } from './core/FormControl';
31
33
  export type { FormControlProps, FormControlFieldProps, FormControlCaptionProps, FormControlErrorMessageProps, FormControlLabelProps, FormControlSuccessMessageProps, } from './core/FormControl';
32
34
  export { default as GradientText } from './core/GradientText';
package/dist/index.js CHANGED
@@ -19102,6 +19102,53 @@ const BaseEmptyState = styled__default.default.div`
19102
19102
  ${sx}
19103
19103
  `;
19104
19104
 
19105
+ const Flash = ({
19106
+ variant = 'danger',
19107
+ children,
19108
+ ...props
19109
+ }) => {
19110
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(BaseFlash, {
19111
+ variant: variant,
19112
+ ...props,
19113
+ children: [variant === 'danger' ? /*#__PURE__*/jsxRuntimeExports.jsx(SvgWarning, {}) : null, children]
19114
+ });
19115
+ };
19116
+ const BaseFlash = styled__default.default.div`
19117
+ border-radius: ${({
19118
+ theme
19119
+ }) => forcePixelValue(theme.radii.xs)};
19120
+ & > svg {
19121
+ min-width: ${forcePixelValue(16)};
19122
+ height: ${forcePixelValue(16)};
19123
+ margin-right: ${({
19124
+ theme
19125
+ }) => forcePixelValue(theme.space[2])};
19126
+ }
19127
+ word-break: keep-all;
19128
+
19129
+ ${variant({
19130
+ prop: 'variant',
19131
+ variants: {
19132
+ danger: {
19133
+ 'display': 'flex',
19134
+ 'flexDirection': 'row',
19135
+ 'alignItems': 'center',
19136
+ 'padding': 4,
19137
+ 'fontSize': 'xs',
19138
+ 'fontWeight': 'medium',
19139
+ 'lineHeight': 2,
19140
+ 'color': 'text/neutral',
19141
+ 'backgroundColor': 'bg/danger',
19142
+ '& > svg': {
19143
+ color: 'icon/danger'
19144
+ }
19145
+ }
19146
+ }
19147
+ })}
19148
+
19149
+ ${sx}
19150
+ `;
19151
+
19105
19152
  const Overlay = ({
19106
19153
  children,
19107
19154
  isOpen,
@@ -20793,7 +20840,9 @@ const OverlayPopper = ({
20793
20840
  renderOverlay,
20794
20841
  placement = 'bottom-start',
20795
20842
  focusZoneSettings,
20796
- focusTrapSettings
20843
+ focusTrapSettings,
20844
+ onOpen,
20845
+ onClose
20797
20846
  }) => {
20798
20847
  const {
20799
20848
  refs,
@@ -20814,11 +20863,23 @@ const OverlayPopper = ({
20814
20863
  } = useToggleHandler({
20815
20864
  initialState: false
20816
20865
  });
20817
- const handleDismiss = () => {
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?.();
20818
20876
  closeOverlay();
20819
20877
  };
20878
+ const handleDismiss = () => {
20879
+ handleOverlayClose();
20880
+ };
20820
20881
  const defaultPopperProps = {
20821
- onClick: toggleOverlay,
20882
+ onClick: handleOverlayToggle,
20822
20883
  tabIndex: 0,
20823
20884
  ...{
20824
20885
  ref: refs.setReference
@@ -20828,7 +20889,7 @@ const OverlayPopper = ({
20828
20889
  ...defaultPopperProps
20829
20890
  }, {
20830
20891
  isOpen,
20831
- openOverlay
20892
+ openOverlay: handleOverlayOpen
20832
20893
  }) : React.Children.map(propChildren, child => /*#__PURE__*/React.cloneElement(child, {
20833
20894
  ...defaultPopperProps
20834
20895
  }));
@@ -20854,7 +20915,7 @@ const OverlayPopper = ({
20854
20915
  onDismiss: handleDismiss
20855
20916
  }, {
20856
20917
  isOpen,
20857
- closeOverlay
20918
+ closeOverlay: handleOverlayClose
20858
20919
  }, {
20859
20920
  elements
20860
20921
  })]
@@ -20865,16 +20926,41 @@ const OverlaySelectInput = ({
20865
20926
  validationStatus,
20866
20927
  leadingVisual: LeadingVisual,
20867
20928
  children,
20929
+ onChange,
20930
+ focusTrapSettings,
20931
+ focusZoneSettings,
20932
+ onOpen,
20933
+ onClose,
20868
20934
  ...props
20869
20935
  }, ref) => {
20870
- const inputRef = useProvidedOrCreatedRef(ref);
20936
+ const valueInputRef = useProvidedOrCreatedRef(ref);
20937
+ const labelInputRef = React.useRef(null);
20871
20938
  const focusInput = () => {
20872
- inputRef.current?.focus();
20939
+ labelInputRef.current?.focus();
20873
20940
  };
20874
20941
  const {
20875
- disabled
20942
+ id,
20943
+ disabled,
20944
+ placeholder
20876
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
+ };
20877
20959
  return /*#__PURE__*/jsxRuntimeExports.jsx(OverlayPopper, {
20960
+ focusTrapSettings: focusTrapSettings,
20961
+ focusZoneSettings: focusZoneSettings,
20962
+ onOpen: onOpen,
20963
+ onClose: onClose,
20878
20964
  renderOverlay: (overlayProps, _, {
20879
20965
  elements
20880
20966
  }) => /*#__PURE__*/jsxRuntimeExports.jsx(Overlay$1, {
@@ -20883,7 +20969,9 @@ const OverlaySelectInput = ({
20883
20969
  ...overlayProps.style,
20884
20970
  width: elements?.reference?.getBoundingClientRect().width
20885
20971
  },
20886
- children: children
20972
+ children: children?.({
20973
+ handleSelect
20974
+ })
20887
20975
  }),
20888
20976
  children: (popperProps, {
20889
20977
  openOverlay
@@ -20915,19 +21003,16 @@ const OverlaySelectInput = ({
20915
21003
  },
20916
21004
  children: typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual
20917
21005
  }), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput$1, {
20918
- ref: e => {
20919
- isFunction(ref) ? ref(e) : null;
20920
- inputRef.current = e;
20921
- },
20922
- value: '',
21006
+ id: id,
21007
+ ref: labelInputRef,
20923
21008
  onChange: noop$2,
20924
- ...props,
20925
21009
  autoComplete: 'off',
20926
21010
  tabIndex: -1,
20927
21011
  onClick: e => {
20928
21012
  popperProps.onClick?.(e);
20929
21013
  props.onClick?.(e);
20930
- }
21014
+ },
21015
+ placeholder: placeholder
20931
21016
  }), /*#__PURE__*/jsxRuntimeExports.jsx(StyledIcon, {
20932
21017
  sx: {
20933
21018
  position: 'absolute',
@@ -20939,6 +21024,12 @@ const OverlaySelectInput = ({
20939
21024
  icon: SvgChevronDown,
20940
21025
  color: disabled ? 'icon/disabled' : 'icon/neutral/bolder',
20941
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'
20942
21033
  })]
20943
21034
  })
20944
21035
  });
@@ -24134,6 +24225,7 @@ exports.DescriptionList = DescriptionList;
24134
24225
  exports.Dialog = index$6;
24135
24226
  exports.EmptyState = EmptyState;
24136
24227
  exports.EnigmaUI = index;
24228
+ exports.Flash = Flash;
24137
24229
  exports.FormControl = index$4;
24138
24230
  exports.GradientText = GradientText;
24139
24231
  exports.Grid = Grid$1;
@@ -0,0 +1,57 @@
1
+ import 'react';
2
+ import SvgWarning from '../../packages/icons/esm/Warning.js';
3
+ import { forcePixelValue } from '../../packages/utils/esm/forcePixelValue.js';
4
+ import styled from 'styled-components';
5
+ import '../../node_modules/styled-system/dist/index.esm.js';
6
+ import { sx } from '../../utils/styled-system/index.js';
7
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
8
+ import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
9
+
10
+ const Flash = ({
11
+ variant = 'danger',
12
+ children,
13
+ ...props
14
+ }) => {
15
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(BaseFlash, {
16
+ variant: variant,
17
+ ...props,
18
+ children: [variant === 'danger' ? /*#__PURE__*/jsxRuntimeExports.jsx(SvgWarning, {}) : null, children]
19
+ });
20
+ };
21
+ const BaseFlash = styled.div`
22
+ border-radius: ${({
23
+ theme
24
+ }) => forcePixelValue(theme.radii.xs)};
25
+ & > svg {
26
+ min-width: ${forcePixelValue(16)};
27
+ height: ${forcePixelValue(16)};
28
+ margin-right: ${({
29
+ theme
30
+ }) => forcePixelValue(theme.space[2])};
31
+ }
32
+ word-break: keep-all;
33
+
34
+ ${variant({
35
+ prop: 'variant',
36
+ variants: {
37
+ danger: {
38
+ 'display': 'flex',
39
+ 'flexDirection': 'row',
40
+ 'alignItems': 'center',
41
+ 'padding': 4,
42
+ 'fontSize': 'xs',
43
+ 'fontWeight': 'medium',
44
+ 'lineHeight': 2,
45
+ 'color': 'text/neutral',
46
+ 'backgroundColor': 'bg/danger',
47
+ '& > svg': {
48
+ color: 'icon/danger'
49
+ }
50
+ }
51
+ }
52
+ })}
53
+
54
+ ${sx}
55
+ `;
56
+
57
+ export { Flash as default };
@@ -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 handleDismiss = () => {
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: toggleOverlay,
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 inputRef = useProvidedOrCreatedRef(ref);
27
+ const valueInputRef = useProvidedOrCreatedRef(ref);
28
+ const labelInputRef = useRef(null);
23
29
  const focusInput = () => {
24
- inputRef.current?.focus();
30
+ labelInputRef.current?.focus();
25
31
  };
26
32
  const {
27
- disabled
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
- ref: e => {
71
- isFunction(ref) ? ref(e) : null;
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/esm/index.js CHANGED
@@ -10,6 +10,7 @@ export { default as Datagrid } from './core/Datagrid/index.js';
10
10
  export { default as DescriptionList } from './core/DescriptionList/index.js';
11
11
  export { default as Dialog } from './core/Dialog/index.js';
12
12
  export { default as EmptyState } from './core/EmptyState/index.js';
13
+ export { default as Flash } from './core/Flash/index.js';
13
14
  export { default as FormControl } from './core/FormControl/index.js';
14
15
  export { default as GradientText } from './core/GradientText/index.js';
15
16
  export { default as Grid } from './core/Grid/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.19.12",
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": "cf4b596b8cb53dc61d532f7d01d6064649004ee3"
65
+ "gitHead": "73771f9a29466d5aa4a9e075623a6543d173004c"
66
66
  }