@teamturing/react-kit 2.52.2 → 2.53.1

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,25 @@
1
+ import { HTMLProps } from 'react';
2
+ import { SxProp } from '../../utils/styled-system';
3
+ type Props = {
4
+ file: File | Blob;
5
+ variant?: 'default' | 'thumbnail';
6
+ /**
7
+ * 비활성화 상태를 정의합니다.
8
+ */
9
+ disabled?: boolean;
10
+ /**
11
+ * 로딩 상태를 정의합니다.
12
+ */
13
+ loading?: boolean;
14
+ /**
15
+ *
16
+ */
17
+ validationStatus?: 'error' | undefined;
18
+ /**
19
+ * 시각적인 후행 부분에 상호작용할 요소를 정의합니다.
20
+ */
21
+ trailingAction?: React.ReactElement<HTMLProps<HTMLButtonElement>>;
22
+ } & SxProp;
23
+ declare const FileItem: ({ file, variant, disabled, loading, validationStatus, trailingAction, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
24
+ export default FileItem;
25
+ export type { Props as FileItemProps };
package/dist/index.d.ts CHANGED
@@ -37,6 +37,8 @@ export { default as Drawer } from './core/Drawer';
37
37
  export type { DrawerProps, UnstyledDrawerHeaderProps, UnstyledDrawerBodyProps, UnstyledDrawerFooterProps, DrawerHeaderProps, DrawerHeaderIconButtonProps, DrawerBodyProps, DrawerFooterProps, } from './core/Drawer';
38
38
  export { default as EmptyState } from './core/EmptyState';
39
39
  export type { EmptyStateProps } from './core/EmptyState';
40
+ export { default as FileItem } from './core/FileItem';
41
+ export type { FileItemProps } from './core/FileItem';
40
42
  export { default as Flash } from './core/Flash';
41
43
  export type { FlashProps } from './core/Flash';
42
44
  export { default as FormControl } from './core/FormControl';
package/dist/index.js CHANGED
@@ -4023,7 +4023,9 @@ const BaseIconButton = styled__default.default(UnstyledButton)(({
4023
4023
 
4024
4024
  const MotionView = framerMotion.motion(View);
4025
4025
 
4026
- const UnstyledDialogBody = styled__default.default.div`
4026
+ const UnstyledDialogBody = styled__default.default.div.attrs({
4027
+ className: 'trk-dialog_body'
4028
+ })`
4027
4029
  flex-grow: 1;
4028
4030
  flex-shrink: 1;
4029
4031
  flex-basis: auto;
@@ -4045,7 +4047,9 @@ const DialogBody = ({
4045
4047
  children: children
4046
4048
  });
4047
4049
 
4048
- const UnstyledDialogFooter = styled__default.default.div`
4050
+ const UnstyledDialogFooter = styled__default.default.div.attrs({
4051
+ className: 'trk-dialog_footer'
4052
+ })`
4049
4053
  flex-grow: 0;
4050
4054
  flex-shrink: 0;
4051
4055
  flex-basis: auto;
@@ -4076,7 +4080,9 @@ const DialogFooter = ({
4076
4080
  children: children
4077
4081
  });
4078
4082
 
4079
- const UnstyledDialogHeader = styled__default.default.div`
4083
+ const UnstyledDialogHeader = styled__default.default.div.attrs({
4084
+ className: 'trk-dialog_header'
4085
+ })`
4080
4086
  flex-grow: 0;
4081
4087
  flex-shrink: 0;
4082
4088
  flex-basis: auto;
@@ -4106,6 +4112,7 @@ const DialogHeaderSubtitle = ({
4106
4112
  color = 'text/neutral/subtler',
4107
4113
  ...props
4108
4114
  }) => /*#__PURE__*/jsxRuntime.jsx(Text, {
4115
+ className: 'trk-dialog_header_subtitle',
4109
4116
  typography: typography,
4110
4117
  color: color,
4111
4118
  ...props
@@ -4116,6 +4123,7 @@ const DialogHeaderTitle = ({
4116
4123
  color = 'text/neutral',
4117
4124
  ...props
4118
4125
  }) => /*#__PURE__*/jsxRuntime.jsx(Text, {
4126
+ className: 'trk-dialog_header_title',
4119
4127
  typography: typography,
4120
4128
  color: color,
4121
4129
  ...props
@@ -4198,6 +4206,7 @@ const Dialog = ({
4198
4206
  width: '100%',
4199
4207
  height: '100%',
4200
4208
  children: /*#__PURE__*/jsxRuntime.jsxs(BaseDialog, {
4209
+ className: `rkt-dialog--${size}`,
4201
4210
  ref: dialogRef,
4202
4211
  "aria-modal": 'true',
4203
4212
  role: 'dialog',
@@ -4242,6 +4251,7 @@ const Dialog = ({
4242
4251
  right: 3
4243
4252
  },
4244
4253
  children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
4254
+ className: 'trk-dialog__close_button',
4245
4255
  ref: closeButtonRef,
4246
4256
  icon: icons.CloseIcon,
4247
4257
  variant: 'plain',
@@ -4293,7 +4303,9 @@ var index$8 = Object.assign( /*#__PURE__*/React.forwardRef(Dialog), {
4293
4303
  Footer: DialogFooter
4294
4304
  });
4295
4305
 
4296
- const UnstyledDrawerBody = styled__default.default.div`
4306
+ const UnstyledDrawerBody = styled__default.default.div.attrs({
4307
+ className: 'trk-drawer_body'
4308
+ })`
4297
4309
  flex-grow: 1;
4298
4310
  flex-shrink: 1;
4299
4311
  flex-basis: auto;
@@ -4315,7 +4327,9 @@ const DrawerBody = ({
4315
4327
  children: children
4316
4328
  });
4317
4329
 
4318
- const UnstyledDrawerFooter = styled__default.default.div`
4330
+ const UnstyledDrawerFooter = styled__default.default.div.attrs({
4331
+ className: 'trk-drawer_footer'
4332
+ })`
4319
4333
  flex-grow: 0;
4320
4334
  flex-shrink: 0;
4321
4335
  flex-basis: auto;
@@ -4346,7 +4360,9 @@ const DrawerFooter = ({
4346
4360
  children: children
4347
4361
  });
4348
4362
 
4349
- const UnstyledDrawerHeader = styled__default.default.div`
4363
+ const UnstyledDrawerHeader = styled__default.default.div.attrs({
4364
+ className: 'trk-drawer_header'
4365
+ })`
4350
4366
  flex-grow: 0;
4351
4367
  flex-shrink: 0;
4352
4368
  flex-basis: auto;
@@ -4498,6 +4514,7 @@ const Drawer = ({
4498
4514
  } : {})
4499
4515
  },
4500
4516
  children: /*#__PURE__*/jsxRuntime.jsxs(BaseDrawer, {
4517
+ className: `trk-drawer--${size}`,
4501
4518
  ref: drawerRef,
4502
4519
  "aria-modal": 'true',
4503
4520
  role: 'dialog',
@@ -4513,6 +4530,7 @@ const Drawer = ({
4513
4530
  right: 5
4514
4531
  },
4515
4532
  children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
4533
+ className: 'trk-drawer__close_button',
4516
4534
  ref: closeButtonRef,
4517
4535
  icon: icons.CloseIcon,
4518
4536
  variant: 'plain-bold',
@@ -4716,6 +4734,219 @@ const BaseEmptyState = styled__default.default.div`
4716
4734
  ${sx}
4717
4735
  `;
4718
4736
 
4737
+ const FileItem = ({
4738
+ file,
4739
+ variant = 'default',
4740
+ disabled,
4741
+ loading,
4742
+ validationStatus,
4743
+ trailingAction,
4744
+ ...props
4745
+ }) => {
4746
+ const fileType = file.type.match('image/*') ? 'image' : file.type.match('video/*') ? 'video' : 'whatever';
4747
+ const fileName = 'name' in file ? file.name : '';
4748
+ const FileIcon = fileType === 'image' ? icons.PictureIcon : fileType === 'video' ? icons.VideoIcon : icons.DocumentIcon;
4749
+ const [objectUrl, setObjectUrl] = React.useState('');
4750
+ React.useEffect(() => {
4751
+ setObjectUrl(URL.createObjectURL(file));
4752
+ return () => {
4753
+ URL.revokeObjectURL(objectUrl);
4754
+ };
4755
+ }, []);
4756
+ return /*#__PURE__*/jsxRuntime.jsx(BaseFile, {
4757
+ variant: variant,
4758
+ disabled: disabled,
4759
+ loading: disabled,
4760
+ validationStatus: validationStatus,
4761
+ trailingAction: trailingAction,
4762
+ ...props,
4763
+ children: variant === 'default' ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4764
+ children: [/*#__PURE__*/jsxRuntime.jsx(FileIcon, {}), /*#__PURE__*/jsxRuntime.jsx("span", {
4765
+ children: fileName
4766
+ }), validationStatus === 'error' ? /*#__PURE__*/jsxRuntime.jsx(StyledIcon, {
4767
+ icon: icons.ExclamationPointInCircleIcon,
4768
+ size: 24,
4769
+ color: 'icon/danger'
4770
+ }) : loading ? /*#__PURE__*/jsxRuntime.jsx(Spinner, {
4771
+ width: 24,
4772
+ height: 24
4773
+ }) : null, trailingAction]
4774
+ }) : variant === 'thumbnail' ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4775
+ children: [fileType === 'image' ? /*#__PURE__*/jsxRuntime.jsx("img", {
4776
+ src: objectUrl
4777
+ }) : fileType === 'video' ? /*#__PURE__*/jsxRuntime.jsxs("div", {
4778
+ className: 'file__thumbnail__video',
4779
+ children: [/*#__PURE__*/jsxRuntime.jsx("video", {
4780
+ src: objectUrl
4781
+ }), /*#__PURE__*/jsxRuntime.jsx(icons.VideoIcon, {})]
4782
+ }) : /*#__PURE__*/jsxRuntime.jsx("div", {
4783
+ className: 'file__thumbnail__whatever',
4784
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.DocumentIcon, {})
4785
+ }), validationStatus === 'error' || loading ? /*#__PURE__*/jsxRuntime.jsx("div", {
4786
+ className: 'file__thumbnail__cover',
4787
+ children: validationStatus === 'error' ? /*#__PURE__*/jsxRuntime.jsx(StyledIcon, {
4788
+ icon: icons.ExclamationPointInCircleIcon,
4789
+ size: 24,
4790
+ color: 'icon/danger'
4791
+ }) : loading ? /*#__PURE__*/jsxRuntime.jsx(Spinner, {
4792
+ width: 24,
4793
+ height: 24
4794
+ }) : null
4795
+ }) : null, trailingAction]
4796
+ }) : null
4797
+ });
4798
+ };
4799
+ const BaseFile = styled__default.default.div({
4800
+ position: 'relative'
4801
+ }, ({
4802
+ theme,
4803
+ disabled
4804
+ }) => variant({
4805
+ prop: 'variant',
4806
+ variants: {
4807
+ default: {
4808
+ 'backgroundColor': theme.colors['bg/neutral'],
4809
+ 'borderRadius': theme.radii.xs,
4810
+ 'width': '100%',
4811
+ 'height': utils.forcePixelValue(48),
4812
+ 'py': 1,
4813
+ 'pr': 2,
4814
+ 'pl': 4,
4815
+ 'display': 'flex',
4816
+ 'columnGap': 2,
4817
+ 'alignItems': 'center',
4818
+ '& > svg': {
4819
+ width: 24,
4820
+ height: 24,
4821
+ color: theme.colors['icon/neutral/bold']
4822
+ },
4823
+ '& > span': {
4824
+ flex: 1,
4825
+ fontSize: theme.fontSizes.xs,
4826
+ fontWeight: theme.fontWeights.medium,
4827
+ lineHeight: theme.lineHeights[2],
4828
+ overflow: 'hidden',
4829
+ textOverflow: 'ellipsis',
4830
+ whiteSpace: 'nowrap',
4831
+ color: theme.colors['text/neutral/subtle']
4832
+ },
4833
+ ...(disabled ? {
4834
+ '& > svg': {
4835
+ color: theme.colors['icon/disabled']
4836
+ },
4837
+ '& span': {
4838
+ color: theme.colors['text/disabled']
4839
+ }
4840
+ } : {})
4841
+ },
4842
+ thumbnail: {
4843
+ 'display': 'flex',
4844
+ 'alignItems': 'center',
4845
+ 'justifyContent': 'center',
4846
+ 'width': utils.forcePixelValue(160),
4847
+ 'maxWidth': utils.forcePixelValue(160),
4848
+ 'aspectRatio': '16 / 9',
4849
+ 'backgroundColor': theme.colors['bg/neutral'],
4850
+ 'overflow': 'hidden',
4851
+ 'borderRadius': 'xs',
4852
+ '&:after': {
4853
+ content: '""',
4854
+ position: 'absolute',
4855
+ top: utils.forcePixelValue(0),
4856
+ right: utils.forcePixelValue(0),
4857
+ bottom: utils.forcePixelValue(0),
4858
+ left: utils.forcePixelValue(0),
4859
+ borderWidth: 1,
4860
+ borderColor: theme.colors['border/neutral'],
4861
+ borderStyle: 'solid',
4862
+ borderRadius: 'xs',
4863
+ pointerEvents: 'none'
4864
+ },
4865
+ '& > .file__thumbnail__cover': {
4866
+ position: 'absolute',
4867
+ top: 0,
4868
+ left: 0,
4869
+ right: 0,
4870
+ bottom: 0,
4871
+ display: 'flex',
4872
+ justifyContent: 'center',
4873
+ alignItems: 'center',
4874
+ pointerEvents: 'none',
4875
+ backgroundColor: 'bg/neutral'
4876
+ },
4877
+ '& > img': {
4878
+ width: '100%',
4879
+ height: '100%',
4880
+ objectFit: 'cover'
4881
+ },
4882
+ '& > .file__thumbnail__video': {
4883
+ position: 'relative',
4884
+ width: '100%',
4885
+ height: '100%',
4886
+ backgroundColor: 'transparent',
4887
+ display: 'flex',
4888
+ alignItems: 'center',
4889
+ justifyContent: 'center',
4890
+ svg: {
4891
+ position: 'absolute',
4892
+ top: '50%',
4893
+ left: '50%',
4894
+ transform: 'translate(-50%, -50%)',
4895
+ width: 24,
4896
+ height: 24,
4897
+ color: 'icon/primary'
4898
+ },
4899
+ video: {
4900
+ width: '100%'
4901
+ }
4902
+ },
4903
+ '& > .file__thumbnail__whatever': {
4904
+ width: '100%',
4905
+ height: '100%',
4906
+ backgroundColor: 'bg/neutral',
4907
+ display: 'flex',
4908
+ alignItems: 'center',
4909
+ justifyContent: 'center',
4910
+ svg: {
4911
+ width: 24,
4912
+ height: 24,
4913
+ color: 'icon/neutral/bold'
4914
+ }
4915
+ },
4916
+ '& > button': {
4917
+ position: 'absolute',
4918
+ top: 0,
4919
+ right: 0
4920
+ },
4921
+ ...(disabled ? {} : {})
4922
+ }
4923
+ }
4924
+ }), ({
4925
+ theme,
4926
+ variant: propVariant
4927
+ }) => variant({
4928
+ prop: 'validationStatus',
4929
+ variants: {
4930
+ error: {
4931
+ ...(propVariant === 'thumbnail' ? {
4932
+ '&:after': {
4933
+ content: '""',
4934
+ position: 'absolute',
4935
+ top: utils.forcePixelValue(0),
4936
+ right: utils.forcePixelValue(0),
4937
+ bottom: utils.forcePixelValue(0),
4938
+ left: utils.forcePixelValue(0),
4939
+ borderWidth: 2,
4940
+ borderColor: theme.colors['border/danger'],
4941
+ borderStyle: 'solid',
4942
+ borderRadius: 'xs',
4943
+ pointerEvents: 'none'
4944
+ }
4945
+ } : {})
4946
+ }
4947
+ }
4948
+ }), sx);
4949
+
4719
4950
  const Flash = ({
4720
4951
  variant = 'neutral',
4721
4952
  icon: Icon = variant === 'danger' ? icons.WarningIcon : variant === 'assist' ? icons.TwinkleIcon : variant === 'accent' ? icons.InfoInCircleIcon : icons.InfoInCircleIcon,
@@ -7986,6 +8217,7 @@ exports.Dialog = index$8;
7986
8217
  exports.Drawer = index$7;
7987
8218
  exports.EmptyState = EmptyState;
7988
8219
  exports.EnigmaUI = index;
8220
+ exports.FileItem = FileItem;
7989
8221
  exports.Flash = index$6;
7990
8222
  exports.FormControl = index$5;
7991
8223
  exports.GradientText = GradientText;
@@ -6,6 +6,7 @@ const DialogHeaderSubtitle = ({
6
6
  color = 'text/neutral/subtler',
7
7
  ...props
8
8
  }) => /*#__PURE__*/jsx(Text, {
9
+ className: 'trk-dialog_header_subtitle',
9
10
  typography: typography,
10
11
  color: color,
11
12
  ...props
@@ -6,6 +6,7 @@ const DialogHeaderTitle = ({
6
6
  color = 'text/neutral',
7
7
  ...props
8
8
  }) => /*#__PURE__*/jsx(Text, {
9
+ className: 'trk-dialog_header_title',
9
10
  typography: typography,
10
11
  color: color,
11
12
  ...props
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDialogBody = styled.div`
4
+ const UnstyledDialogBody = styled.div.attrs({
5
+ className: 'trk-dialog_body'
6
+ })`
5
7
  flex-grow: 1;
6
8
  flex-shrink: 1;
7
9
  flex-basis: auto;
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDialogFooter = styled.div`
4
+ const UnstyledDialogFooter = styled.div.attrs({
5
+ className: 'trk-dialog_footer'
6
+ })`
5
7
  flex-grow: 0;
6
8
  flex-shrink: 0;
7
9
  flex-basis: auto;
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDialogHeader = styled.div`
4
+ const UnstyledDialogHeader = styled.div.attrs({
5
+ className: 'trk-dialog_header'
6
+ })`
5
7
  flex-grow: 0;
6
8
  flex-shrink: 0;
7
9
  flex-basis: auto;
@@ -94,6 +94,7 @@ const Dialog = ({
94
94
  width: '100%',
95
95
  height: '100%',
96
96
  children: /*#__PURE__*/jsxs(BaseDialog, {
97
+ className: `rkt-dialog--${size}`,
97
98
  ref: dialogRef,
98
99
  "aria-modal": 'true',
99
100
  role: 'dialog',
@@ -138,6 +139,7 @@ const Dialog = ({
138
139
  right: 3
139
140
  },
140
141
  children: /*#__PURE__*/jsx(IconButton, {
142
+ className: 'trk-dialog__close_button',
141
143
  ref: closeButtonRef,
142
144
  icon: CloseIcon,
143
145
  variant: 'plain',
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDrawerBody = styled.div`
4
+ const UnstyledDrawerBody = styled.div.attrs({
5
+ className: 'trk-drawer_body'
6
+ })`
5
7
  flex-grow: 1;
6
8
  flex-shrink: 1;
7
9
  flex-basis: auto;
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDrawerFooter = styled.div`
4
+ const UnstyledDrawerFooter = styled.div.attrs({
5
+ className: 'trk-drawer_footer'
6
+ })`
5
7
  flex-grow: 0;
6
8
  flex-shrink: 0;
7
9
  flex-basis: auto;
@@ -1,7 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import { sx } from '../../utils/styled-system/index.js';
3
3
 
4
- const UnstyledDrawerHeader = styled.div`
4
+ const UnstyledDrawerHeader = styled.div.attrs({
5
+ className: 'trk-drawer_header'
6
+ })`
5
7
  flex-grow: 0;
6
8
  flex-shrink: 0;
7
9
  flex-basis: auto;
@@ -129,6 +129,7 @@ const Drawer = ({
129
129
  } : {})
130
130
  },
131
131
  children: /*#__PURE__*/jsxs(BaseDrawer, {
132
+ className: `trk-drawer--${size}`,
132
133
  ref: drawerRef,
133
134
  "aria-modal": 'true',
134
135
  role: 'dialog',
@@ -144,6 +145,7 @@ const Drawer = ({
144
145
  right: 5
145
146
  },
146
147
  children: /*#__PURE__*/jsx(IconButton, {
148
+ className: 'trk-drawer__close_button',
147
149
  ref: closeButtonRef,
148
150
  icon: CloseIcon,
149
151
  variant: 'plain-bold',