@teamturing/react-kit 2.16.3 → 2.18.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.
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react';
1
+ import { forwardRef, useCallback } from 'react';
2
2
  import SvgClose from '../../packages/icons/esm/Close.js';
3
3
  import { r as reactIsExports } from '../../node_modules/react-is/index.js';
4
4
  import styled from 'styled-components';
@@ -11,36 +11,73 @@ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js'
11
11
  import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
12
12
 
13
13
  const Pill = ({
14
- text,
14
+ children,
15
15
  size = 'm',
16
- variant = 'secondary',
16
+ variant = 'outlined',
17
+ disabled = false,
17
18
  leadingVisual: LeadingVisual,
18
- onRemove,
19
+ trailingVisual: TrailingVisual,
20
+ onRemove: propOnRemove,
19
21
  removeIcon: RemoveIcon = SvgClose,
20
22
  ...props
21
- }, ref) => /*#__PURE__*/jsxRuntimeExports.jsxs(BasePill, {
22
- ref: ref,
23
- size: size,
24
- variant: variant,
25
- hasLeadingVisual: !isNullable(LeadingVisual),
26
- hasRemoveButton: !isNullable(onRemove),
27
- ...props,
28
- children: [typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
29
- title: text,
30
- children: text
31
- }), onRemove ? /*#__PURE__*/jsxRuntimeExports.jsx(UnstyledButton, {
32
- type: 'button',
33
- onClick: onRemove,
34
- "aria-label": 'Remove Pill',
35
- children: /*#__PURE__*/jsxRuntimeExports.jsx(RemoveIcon, {})
36
- }) : null]
37
- });
38
- const BasePill = styled.span`
23
+ }, ref) => {
24
+ const handleRemove = useCallback(event => {
25
+ propOnRemove?.(event);
26
+ }, [propOnRemove]);
27
+ const handleRemoveClick = useCallback(event => {
28
+ if (disabled) return;
29
+ handleRemove(event);
30
+ }, [handleRemove, disabled]);
31
+ const handleRemoveKeydown = useCallback(event => {
32
+ if (disabled) return;
33
+ if ([' ', 'Enter'].includes(event.key)) {
34
+ handleRemove(event);
35
+ }
36
+ }, [handleRemove, disabled]);
37
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(BasePill, {
38
+ ref: ref,
39
+ size: size,
40
+ variant: variant,
41
+ hasLeadingVisual: !isNullable(LeadingVisual),
42
+ hasRemoveButton: !isNullable(propOnRemove),
43
+ disabled: disabled,
44
+ ...props,
45
+ children: [typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
46
+ title: children?.toString(),
47
+ children: children
48
+ }), typeof TrailingVisual !== 'string' && reactIsExports.isValidElementType(TrailingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(TrailingVisual, {}) : TrailingVisual, propOnRemove ? /*#__PURE__*/jsxRuntimeExports.jsx("div", {
49
+ onClick: e => {
50
+ e.preventDefault();
51
+ handleRemoveClick(e);
52
+ e.stopPropagation();
53
+ },
54
+ onKeyDown: e => {
55
+ if ([' ', 'Enter'].includes(e.key)) {
56
+ e.preventDefault();
57
+ e.stopPropagation();
58
+ handleRemoveKeydown(e);
59
+ return;
60
+ }
61
+ },
62
+ "aria-label": 'Remove Pill',
63
+ role: 'button',
64
+ "aria-disabled": disabled,
65
+ tabIndex: disabled ? -1 : 0,
66
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(RemoveIcon, {})
67
+ }) : null]
68
+ });
69
+ };
70
+ const BasePill = styled(UnstyledButton)`
39
71
  display: inline-flex;
40
72
  align-items: center;
41
73
  border-radius: ${({
42
74
  theme
43
- }) => forcePixelValue(theme.radii.xxs)};
75
+ }) => forcePixelValue(theme.radii.xs)};
76
+ column-gap: ${({
77
+ theme
78
+ }) => forcePixelValue(theme.space[2])};
79
+
80
+ transition: background-color 100ms;
44
81
 
45
82
  & span {
46
83
  max-width: 240px;
@@ -49,90 +86,92 @@ const BasePill = styled.span`
49
86
  white-space: pre;
50
87
  word-break: break-all;
51
88
  }
52
- & > button {
89
+
90
+ &:focus-visible {
91
+ outline-color: ${({
92
+ theme
93
+ }) => theme.colors['border/focused']};
94
+ outline-style: solid;
95
+ outline-width: ${forcePixelValue(2)};
96
+ outline-offset: ${({
97
+ theme
98
+ }) => forcePixelValue(theme.space[0.5])};
99
+ }
100
+
101
+ & > div {
53
102
  display: flex;
54
- transition: background-color 100ms;
55
103
  border-radius: ${({
56
104
  theme
57
- }) => forcePixelValue(theme.radii.full)};
105
+ }) => forcePixelValue(theme.radii.xxs)};
106
+ }
107
+ & > div:focus-visible {
108
+ outline-color: ${({
109
+ theme
110
+ }) => theme.colors['border/focused']};
111
+ outline-style: solid;
112
+ outline-width: ${forcePixelValue(2)};
113
+ outline-offset: ${({
114
+ theme
115
+ }) => forcePixelValue(theme.space[-0.5])};
58
116
  }
59
117
 
60
118
  ${({
61
119
  theme,
62
- hasLeadingVisual,
63
120
  hasRemoveButton
64
121
  }) => variant({
65
122
  prop: 'size',
66
123
  variants: {
67
- l: {
68
- 'pl': hasLeadingVisual || hasRemoveButton ? 2 : 3,
69
- 'pr': hasRemoveButton ? 0.5 : hasLeadingVisual ? 2 : 3,
70
- 'py': 1,
71
- 'fontSize': theme.fontSizes.s,
72
- 'fontWeight': theme.fontWeights.medium,
73
- 'lineHeight': theme.lineHeights[2],
74
- 'columnGap': 1,
75
- '& svg': {
76
- minWidth: 16,
77
- height: 16,
78
- color: theme.colors['icon/primary']
79
- },
80
- '& button': {
81
- p: 1
82
- }
83
- },
84
124
  m: {
85
- 'pl': hasLeadingVisual || hasRemoveButton ? 2 : 3,
86
- 'pr': hasRemoveButton ? 1 : hasLeadingVisual ? 2 : 3,
87
- 'py': 1,
88
- 'fontSize': theme.fontSizes.xs,
89
- 'fontWeight': theme.fontWeights.medium,
90
- 'lineHeight': theme.lineHeights[2],
91
- 'columnGap': 0.5,
92
- '& svg': {
93
- minWidth: 16,
94
- height: 16,
95
- color: theme.colors['icon/primary']
96
- },
97
- '& button': {
98
- p: 0.5
99
- }
100
- },
101
- s: {
102
- 'pl': 2,
103
- 'pr': hasRemoveButton ? 1 : 2,
104
- 'py': 0.5,
125
+ 'pl': 3,
126
+ 'pr': !hasRemoveButton ? 3 : 1,
127
+ 'height': forcePixelValue(32),
105
128
  'fontSize': theme.fontSizes.xxs,
106
129
  'fontWeight': theme.fontWeights.medium,
107
130
  'lineHeight': theme.lineHeights[2],
108
- 'columnGap': 0.5,
131
+ 'columnGap': 1,
109
132
  '& svg': {
110
133
  minWidth: 12,
111
- height: 12,
112
- color: theme.colors['icon/primary']
134
+ height: 12
113
135
  },
114
- '& button': {
115
- p: 0.5
136
+ '& > div': {
137
+ p: 1
116
138
  }
117
139
  }
118
140
  }
119
141
  })}
120
142
  ${({
121
- theme
143
+ theme,
144
+ disabled
122
145
  }) => variant({
123
146
  prop: 'variant',
124
147
  variants: {
125
- secondary: {
126
- 'color': theme.colors['text/primary'],
127
- 'backgroundColor': theme.colors['bg/secondary'],
128
- '& button': {
129
- '&:hover': {
130
- backgroundColor: theme.colors['bg/secondary/hovered']
148
+ outlined: {
149
+ 'backgroundColor': theme.colors['bg/neutral/subtler'],
150
+ 'borderWidth': 1,
151
+ 'borderStyle': 'solid',
152
+ 'borderColor': theme.colors['border/neutral'],
153
+ 'color': 'text/neutral/subtle',
154
+ '& svg': {
155
+ color: theme.colors['icon/neutral/bolder']
156
+ },
157
+ '&:hover': {
158
+ backgroundColor: theme.colors['bg/neutral/subtler/hovered']
159
+ },
160
+ '&:active': {
161
+ backgroundColor: theme.colors['bg/neutral/subtler/pressed']
162
+ },
163
+ ...(disabled ? {
164
+ 'cursor': 'not-allowed',
165
+ 'backgroundColor': theme.colors['bg/disabled'],
166
+ 'color': theme.colors['text/disabled'],
167
+ '& svg': {
168
+ color: theme.colors['icon/disabled']
131
169
  }
132
- }
170
+ } : {})
133
171
  }
134
172
  }
135
173
  })}
174
+
136
175
  ${sx}
137
176
  `;
138
177
  var index = /*#__PURE__*/forwardRef(Pill);
@@ -0,0 +1,17 @@
1
+ import styled from 'styled-components';
2
+ import { isNullable } from '../../utils/isNullable.js';
3
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
4
+
5
+ const SelectOption = ({
6
+ children: propChildren,
7
+ ...props
8
+ }) => {
9
+ const children = isNullable(propChildren) ? props.label : propChildren;
10
+ return /*#__PURE__*/jsxRuntimeExports.jsx(BaseSelectOption, {
11
+ ...props,
12
+ children: children
13
+ });
14
+ };
15
+ const BaseSelectOption = styled.option``;
16
+
17
+ export { SelectOption as default };
@@ -8,6 +8,7 @@ import { isFunction } from '../../utils/isFunction.js';
8
8
  import { isNullable } from '../../utils/isNullable.js';
9
9
  import StyledIcon from '../StyledIcon/index.js';
10
10
  import View from '../View/index.js';
11
+ import SelectOption from './SelectOption.js';
11
12
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
12
13
 
13
14
  const Select = ({
@@ -38,8 +39,8 @@ const Select = ({
38
39
  'color': 'text/neutral',
39
40
  '& > svg': {
40
41
  display: 'block',
41
- width: 20,
42
- height: 20,
42
+ width: 16,
43
+ height: 16,
43
44
  color: 'icon/neutral/bold'
44
45
  }
45
46
  },
@@ -180,7 +181,7 @@ const SelectWrapper = styled.div`
180
181
  ${props => props.hasLeadingVisual && css`
181
182
  padding-left: ${forcePixelValue(props.theme.space[5])};
182
183
  select {
183
- padding-left: ${forcePixelValue(props.theme.space[3])};
184
+ padding-left: ${forcePixelValue(props.theme.space[2])};
184
185
  }
185
186
  `}
186
187
 
@@ -226,7 +227,6 @@ const BaseSelect = styled(UnstyledSelect)`
226
227
  white-space: pre;
227
228
  text-overflow: ellipsis;
228
229
  `;
229
- const SelectOption = styled.option``;
230
230
  var index = Object.assign( /*#__PURE__*/forwardRef(Select), {
231
231
  Option: SelectOption
232
232
  });
@@ -0,0 +1,58 @@
1
+ import { forwardRef } from 'react';
2
+ import styled from 'styled-components';
3
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
4
+ import { sx } from '../../utils/styled-system/index.js';
5
+ import UnstyledButton from '../_UnstyledButton.js';
6
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
7
+
8
+ const TextInputTrailingAction = ({
9
+ icon: Icon,
10
+ disabled,
11
+ ...props
12
+ }, ref) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseTextInputTrailingAction, {
13
+ ref: ref,
14
+ ...props,
15
+ disabled: disabled,
16
+ "aria-disabled": disabled,
17
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(Icon, {})
18
+ });
19
+ const BaseTextInputTrailingAction = styled(UnstyledButton)`
20
+ display: inline-flex;
21
+ padding: ${({
22
+ theme
23
+ }) => forcePixelValue(theme.space[2])};
24
+ background-color: ${({
25
+ theme
26
+ }) => theme.colors['bg/neutral/subtler']};
27
+ border-radius: ${({
28
+ theme
29
+ }) => forcePixelValue(theme.radii.full)};
30
+
31
+ & svg {
32
+ width: ${forcePixelValue(16)};
33
+ height: ${forcePixelValue(16)};
34
+ color: ${({
35
+ theme
36
+ }) => theme.colors['icon/neutral/bolder']};
37
+ }
38
+
39
+ &:hover {
40
+ background-color: ${({
41
+ theme
42
+ }) => theme.colors['bg/neutral/subtler/hovered']};
43
+ }
44
+
45
+ &[aria-disabled='true'] {
46
+ cursor: not-allowed;
47
+ & svg {
48
+ color: ${({
49
+ theme
50
+ }) => theme.colors['icon/disabled']};
51
+ }
52
+ }
53
+
54
+ ${sx}
55
+ `;
56
+ var TextInputTrailingAction$1 = /*#__PURE__*/forwardRef(TextInputTrailingAction);
57
+
58
+ export { TextInputTrailingAction$1 as default };
@@ -8,9 +8,10 @@ import { forcePixelValue } from '../../utils/forcePixelValue.js';
8
8
  import { isFunction } from '../../utils/isFunction.js';
9
9
  import { isNullable } from '../../utils/isNullable.js';
10
10
  import View from '../View/index.js';
11
+ import TextInputTrailingAction from './TextInputTrailingAction.js';
11
12
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
12
13
 
13
- const TextInput = /*#__PURE__*/forwardRef(({
14
+ const TextInput = ({
14
15
  type = 'text',
15
16
  disabled,
16
17
  validationStatus,
@@ -38,8 +39,8 @@ const TextInput = /*#__PURE__*/forwardRef(({
38
39
  'color': color['text/neutral'],
39
40
  '& > svg': {
40
41
  display: 'block',
41
- width: 20,
42
- height: 20,
42
+ width: 16,
43
+ height: 16,
43
44
  color: color['icon/neutral/bold']
44
45
  }
45
46
  },
@@ -63,8 +64,8 @@ const TextInput = /*#__PURE__*/forwardRef(({
63
64
  'color': color['text/neutral'],
64
65
  '& > svg': {
65
66
  display: 'block',
66
- width: 24,
67
- height: 24,
67
+ width: 16,
68
+ height: 16,
68
69
  color: color['icon/neutral/bold']
69
70
  }
70
71
  },
@@ -73,7 +74,7 @@ const TextInput = /*#__PURE__*/forwardRef(({
73
74
  }) : null]
74
75
  })]
75
76
  });
76
- });
77
+ };
77
78
  const TextInputWrapper = styled.div`
78
79
  position: relative;
79
80
  width: ${forcePixelValue('100%')};
@@ -170,17 +171,25 @@ const TextInputWrapper = styled.div`
170
171
  ${props => props.hasLeadingVisual && css`
171
172
  padding-left: ${forcePixelValue(props.theme.space[5])};
172
173
  input {
173
- padding-left: ${forcePixelValue(props.theme.space[3])};
174
+ padding-left: ${forcePixelValue(props.theme.space[2])};
174
175
  }
175
176
  `}
176
177
 
177
- ${props => (props.hasTrailingVisual || props.hasTrailingAction) && css`
178
+ ${props => props.hasTrailingVisual && css`
179
+ padding-right: ${forcePixelValue(props.theme.space[5])};
180
+ `}
181
+
182
+ ${props => props.hasTrailingAction && css`
178
183
  padding-right: ${forcePixelValue(props.theme.space[3])};
184
+ `}
185
+
186
+ ${props => (props.hasTrailingVisual || props.hasTrailingAction) && css`
179
187
  input {
180
- padding-right: ${forcePixelValue(props.theme.space[3])};
188
+ padding-right: ${forcePixelValue(props.theme.space[2])};
181
189
  }
182
190
  `}
183
191
 
192
+
184
193
  transition: color 100ms, background-color 100ms;
185
194
  &:after {
186
195
  transition: border-color 100ms;
@@ -208,7 +217,7 @@ const BaseInput = styled(UnstyledInput)`
208
217
  }) => forcePixelValue(theme.space['4'])};
209
218
  padding-right: ${({
210
219
  theme
211
- }) => forcePixelValue(theme.space['4'])};
220
+ }) => forcePixelValue(theme.space['5'])};
212
221
  padding-bottom: ${({
213
222
  theme
214
223
  }) => forcePixelValue(theme.space['4'])};
@@ -216,5 +225,8 @@ const BaseInput = styled(UnstyledInput)`
216
225
  theme
217
226
  }) => forcePixelValue(theme.space['5'])};
218
227
  `;
228
+ var index = Object.assign( /*#__PURE__*/forwardRef(TextInput), {
229
+ TrailingAction: TextInputTrailingAction
230
+ });
219
231
 
220
- export { TextInput as default };
232
+ export { index as default };
package/esm/index.js CHANGED
@@ -8,6 +8,7 @@ export { default as Datagrid } from './core/Datagrid/index.js';
8
8
  export { default as DescriptionList } from './core/DescriptionList/index.js';
9
9
  export { default as Dialog } from './core/Dialog/index.js';
10
10
  export { default as DialogHandler } from './core/DialogHandler/index.js';
11
+ export { default as EmptyState } from './core/EmptyState/index.js';
11
12
  export { default as GradientText } from './core/GradientText/index.js';
12
13
  export { default as Grid } from './core/Grid/index.js';
13
14
  export { default as HorizontalDivider } from './core/HorizontalDivider/index.js';
@@ -18,6 +19,7 @@ export { default as ItemList } from './core/ItemList/index.js';
18
19
  export { default as MotionView } from './core/MotionView/index.js';
19
20
  export { default as Overlay } from './core/Overlay/index.js';
20
21
  export { default as OverlayPopper } from './core/OverlayPopper/index.js';
22
+ export { default as OverlaySelectInput } from './core/OverlaySelectInput/index.js';
21
23
  export { default as Pagination } from './core/Pagination/index.js';
22
24
  export { default as Pill } from './core/Pill/index.js';
23
25
  export { default as Select } from './core/Select/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.16.3",
3
+ "version": "2.18.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": "5d22785a97a7991ab894c44c6ea913202821cd01"
65
+ "gitHead": "7e5d700d947efa6123f50698bdcef68160fb21e3"
66
66
  }