@teamturing/react-kit 2.16.2 → 2.17.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.
@@ -0,0 +1,28 @@
1
+ import styled from 'styled-components';
2
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
3
+ import { sx } from '../../utils/styled-system/index.js';
4
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
5
+
6
+ const DatagridSubheader = ({
7
+ ...props
8
+ }) => /*#__PURE__*/jsxRuntimeExports.jsx(DataGridSubheaderWrapper, {
9
+ ...props
10
+ });
11
+ const DataGridSubheaderWrapper = styled.div`
12
+ padding: ${({
13
+ theme
14
+ }) => `${forcePixelValue(theme.space[2])} ${forcePixelValue(theme.space[4])}`};
15
+ background-color: ${({
16
+ theme
17
+ }) => theme.colors.surface};
18
+
19
+ border-bottom-width: ${forcePixelValue(1)};
20
+ border-bottom-style: solid;
21
+ border-bottom-color: ${({
22
+ theme
23
+ }) => theme.colors['border/neutral']};
24
+
25
+ ${sx};
26
+ `;
27
+
28
+ export { DatagridSubheader as default };
@@ -6,6 +6,7 @@ import DatagridBody from './DatagridBody.js';
6
6
  import DatagridCell from './DatagridCell.js';
7
7
  import DatagridHeader from './DatagridHeader.js';
8
8
  import DatagridRow from './DatagridRow.js';
9
+ import DatagridSubheader from './DatagridSubheader.js';
9
10
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
10
11
 
11
12
  const Datagrid = ({
@@ -16,12 +17,13 @@ const Datagrid = ({
16
17
  const [relocatableComponentsObject, restConmponents] = useRelocation({
17
18
  children,
18
19
  config: {
19
- header: DatagridHeader
20
+ header: DatagridHeader,
21
+ subHeader: DatagridSubheader
20
22
  }
21
23
  });
22
24
  return /*#__PURE__*/jsxRuntimeExports.jsxs(DatagridWrapper, {
23
25
  sx: sx,
24
- children: [relocatableComponentsObject.header, /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagrid, {
26
+ children: [relocatableComponentsObject.header, relocatableComponentsObject.subHeader, /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagrid, {
25
27
  ...props,
26
28
  children: restConmponents
27
29
  })]
@@ -48,6 +50,7 @@ const BaseDatagrid = styled.div`
48
50
  `;
49
51
  var index = Object.assign(Datagrid, {
50
52
  Header: DatagridHeader,
53
+ Subheader: DatagridSubheader,
51
54
  Body: DatagridBody,
52
55
  Row: DatagridRow,
53
56
  Cell: DatagridCell
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, useRef, useImperativeHandle, useCallback, useEffect } from 'react';
2
2
  import styled from 'styled-components';
3
- import '../../node_modules/styled-system/dist/index.esm.js';
3
+ import { maxHeight } from '../../node_modules/styled-system/dist/index.esm.js';
4
4
  import { forcePixelValue } from '../../utils/forcePixelValue.js';
5
5
  import { sx } from '../../utils/styled-system/index.js';
6
6
  import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
@@ -14,6 +14,7 @@ const Overlay = ({
14
14
  size = 'm',
15
15
  ignoreOutsideClickRefs = [],
16
16
  dismissFocusRef,
17
+ maxHeight = forcePixelValue(600),
17
18
  ...props
18
19
  }, ref) => {
19
20
  const overlayRef = useRef(null);
@@ -66,6 +67,7 @@ const Overlay = ({
66
67
  return isOpen ? /*#__PURE__*/jsxRuntimeExports.jsx(BaseOverlay, {
67
68
  ref: overlayRef,
68
69
  size: size,
70
+ maxHeight: maxHeight,
69
71
  ...props,
70
72
  role: 'dialog',
71
73
  children: children
@@ -90,16 +92,21 @@ const BaseOverlay = styled.div`
90
92
  prop: 'size',
91
93
  variants: {
92
94
  s: {
93
- width: forcePixelValue(256)
95
+ width: forcePixelValue(180)
94
96
  },
95
97
  m: {
96
- width: forcePixelValue(320)
98
+ width: forcePixelValue(256)
97
99
  },
98
100
  l: {
99
- width: forcePixelValue(480)
101
+ width: forcePixelValue(320)
102
+ },
103
+ auto: {
104
+ width: 'auto'
100
105
  }
101
106
  }
102
107
  })}
108
+
109
+ ${maxHeight}
103
110
  ${sx}
104
111
  `;
105
112
  var Overlay$1 = /*#__PURE__*/forwardRef(Overlay);
@@ -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);
@@ -38,8 +38,8 @@ const Select = ({
38
38
  'color': 'text/neutral',
39
39
  '& > svg': {
40
40
  display: 'block',
41
- width: 20,
42
- height: 20,
41
+ width: 16,
42
+ height: 16,
43
43
  color: 'icon/neutral/bold'
44
44
  }
45
45
  },
@@ -180,7 +180,7 @@ const SelectWrapper = styled.div`
180
180
  ${props => props.hasLeadingVisual && css`
181
181
  padding-left: ${forcePixelValue(props.theme.space[5])};
182
182
  select {
183
- padding-left: ${forcePixelValue(props.theme.space[3])};
183
+ padding-left: ${forcePixelValue(props.theme.space[2])};
184
184
  }
185
185
  `}
186
186
 
@@ -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 };
@@ -16,7 +16,7 @@ layout.width;
16
16
  layout.minWidth;
17
17
  layout.minHeight;
18
18
  layout.maxWidth;
19
- layout.maxHeight;
19
+ var maxHeight = layout.maxHeight;
20
20
  layout.size;
21
21
  layout.verticalAlign;
22
22
  layout.display;
@@ -74,4 +74,4 @@ position.zIndex;
74
74
  position.bottom;
75
75
  position.left;
76
76
 
77
- export { background, border, border as borders, color, flexbox, fontSize, fontWeight, grid, layout, lineHeight, position, textAlign, typography };
77
+ export { background, border, border as borders, color, flexbox, fontSize, fontWeight, grid, layout, lineHeight, maxHeight, position, textAlign, typography };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamturing/react-kit",
3
- "version": "2.16.2",
3
+ "version": "2.17.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": "0118720b3b7893121d2252a7098195f196cccf68"
65
+ "gitHead": "ca31c7add2913812b086f4862e431a3656c3f4f9"
66
66
  }