@teamturing/react-kit 2.17.0 → 2.18.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.
- package/dist/core/EmptyState/index.d.ts +17 -0
- package/dist/core/OverlayPopper/index.d.ts +12 -5
- package/dist/core/OverlaySelectInput/index.d.ts +25 -0
- package/dist/core/Select/SelectOption.d.ts +5 -0
- package/dist/core/Select/index.d.ts +3 -277
- package/dist/index.d.ts +5 -1
- package/dist/index.js +383 -36
- package/esm/core/EmptyState/index.js +117 -0
- package/esm/core/Overlay/index.js +3 -5
- package/esm/core/OverlayPopper/index.js +23 -13
- package/esm/core/OverlaySelectInput/index.js +237 -0
- package/esm/core/Select/SelectOption.js +17 -0
- package/esm/core/Select/index.js +2 -2
- package/esm/index.js +2 -0
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import { Children, cloneElement } from 'react';
|
|
|
5
5
|
import useFocusTrap from '../../hook/useFocusTrap.js';
|
|
6
6
|
import useFocusZone from '../../hook/useFocusZone.js';
|
|
7
7
|
import useToggleHandler from '../../hook/useToggleHandler.js';
|
|
8
|
-
import
|
|
8
|
+
import { isFunction } from '../../utils/isFunction.js';
|
|
9
9
|
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
10
10
|
import { autoUpdate } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js';
|
|
11
11
|
import { offset, flip, shift } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.js';
|
|
@@ -13,13 +13,13 @@ import { offset, flip, shift } from '../../node_modules/@floating-ui/core/dist/f
|
|
|
13
13
|
const OverlayPopper = ({
|
|
14
14
|
children: propChildren,
|
|
15
15
|
renderOverlay,
|
|
16
|
-
overlayProps,
|
|
17
16
|
placement = 'bottom-start',
|
|
18
17
|
focusZoneSettings,
|
|
19
18
|
focusTrapSettings
|
|
20
19
|
}) => {
|
|
21
20
|
const {
|
|
22
21
|
refs,
|
|
22
|
+
elements,
|
|
23
23
|
floatingStyles,
|
|
24
24
|
isPositioned
|
|
25
25
|
} = useFloating({
|
|
@@ -31,20 +31,28 @@ const OverlayPopper = ({
|
|
|
31
31
|
const {
|
|
32
32
|
state: isOpen,
|
|
33
33
|
toggle: toggleOverlay,
|
|
34
|
+
on: openOverlay,
|
|
34
35
|
off: closeOverlay
|
|
35
36
|
} = useToggleHandler({
|
|
36
37
|
initialState: false
|
|
37
38
|
});
|
|
38
39
|
const handleDismiss = () => {
|
|
39
|
-
overlayProps?.onDismiss?.();
|
|
40
40
|
closeOverlay();
|
|
41
41
|
};
|
|
42
|
-
const
|
|
42
|
+
const defaultPopperProps = {
|
|
43
43
|
onClick: toggleOverlay,
|
|
44
44
|
tabIndex: 0,
|
|
45
45
|
...{
|
|
46
46
|
ref: refs.setReference
|
|
47
47
|
}
|
|
48
|
+
};
|
|
49
|
+
const children = isFunction(propChildren) ? propChildren({
|
|
50
|
+
...defaultPopperProps
|
|
51
|
+
}, {
|
|
52
|
+
isOpen,
|
|
53
|
+
openOverlay
|
|
54
|
+
}) : Children.map(propChildren, child => /*#__PURE__*/cloneElement(child, {
|
|
55
|
+
...defaultPopperProps
|
|
48
56
|
}));
|
|
49
57
|
useFocusZone({
|
|
50
58
|
containerRef: refs.floating,
|
|
@@ -57,18 +65,20 @@ const OverlayPopper = ({
|
|
|
57
65
|
...focusTrapSettings
|
|
58
66
|
});
|
|
59
67
|
return /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
|
|
60
|
-
children: [children,
|
|
68
|
+
children: [children, renderOverlay({
|
|
61
69
|
ref: refs.setFloating,
|
|
62
|
-
isOpen
|
|
70
|
+
isOpen,
|
|
63
71
|
dismissFocusRef: refs.reference,
|
|
64
72
|
ignoreOutsideClickRefs: [refs.reference],
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
style: {
|
|
74
|
+
...floatingStyles
|
|
75
|
+
},
|
|
76
|
+
onDismiss: handleDismiss
|
|
77
|
+
}, {
|
|
78
|
+
isOpen,
|
|
79
|
+
closeOverlay
|
|
80
|
+
}, {
|
|
81
|
+
elements
|
|
72
82
|
})]
|
|
73
83
|
});
|
|
74
84
|
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import SvgChevronDown from '../../packages/icons/esm/ChevronDown.js';
|
|
3
|
+
import { noop } from '../../packages/utils/esm/noop.js';
|
|
4
|
+
import { r as reactIsExports } from '../../node_modules/react-is/index.js';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import useProvidedOrCreatedRef from '../../hook/useProvidedOrCreatedRef.js';
|
|
7
|
+
import { forcePixelValue } from '../../utils/forcePixelValue.js';
|
|
8
|
+
import { isFunction } from '../../utils/isFunction.js';
|
|
9
|
+
import { isNullable } from '../../utils/isNullable.js';
|
|
10
|
+
import Overlay from '../Overlay/index.js';
|
|
11
|
+
import OverlayPopper from '../OverlayPopper/index.js';
|
|
12
|
+
import StyledIcon from '../StyledIcon/index.js';
|
|
13
|
+
import View from '../View/index.js';
|
|
14
|
+
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
15
|
+
|
|
16
|
+
const OverlaySelectInput = ({
|
|
17
|
+
validationStatus,
|
|
18
|
+
leadingVisual: LeadingVisual,
|
|
19
|
+
children,
|
|
20
|
+
...props
|
|
21
|
+
}, ref) => {
|
|
22
|
+
const inputRef = useProvidedOrCreatedRef(ref);
|
|
23
|
+
const focusInput = () => {
|
|
24
|
+
inputRef.current?.focus();
|
|
25
|
+
};
|
|
26
|
+
const {
|
|
27
|
+
disabled
|
|
28
|
+
} = props;
|
|
29
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(OverlayPopper, {
|
|
30
|
+
renderOverlay: (overlayProps, _, {
|
|
31
|
+
elements
|
|
32
|
+
}) => /*#__PURE__*/jsxRuntimeExports.jsx(Overlay, {
|
|
33
|
+
...overlayProps,
|
|
34
|
+
style: {
|
|
35
|
+
...overlayProps.style,
|
|
36
|
+
width: elements?.reference?.getBoundingClientRect().width
|
|
37
|
+
},
|
|
38
|
+
children: children
|
|
39
|
+
}),
|
|
40
|
+
children: (popperProps, {
|
|
41
|
+
openOverlay
|
|
42
|
+
}) => /*#__PURE__*/jsxRuntimeExports.jsxs(TextInputWrapper, {
|
|
43
|
+
...popperProps,
|
|
44
|
+
tabIndex: disabled ? -1 : 0,
|
|
45
|
+
disabled: disabled,
|
|
46
|
+
onClick: focusInput,
|
|
47
|
+
hasLeadingVisual: !isNullable(LeadingVisual),
|
|
48
|
+
validationStatus: validationStatus,
|
|
49
|
+
onKeyDown: e => {
|
|
50
|
+
if (['ArrowUp', 'ArrowDown'].includes(e.key)) {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
openOverlay();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
56
|
+
sx: {
|
|
57
|
+
'flexShrink': 0,
|
|
58
|
+
'fontSize': 'xxs',
|
|
59
|
+
'fontWeight': 'medium',
|
|
60
|
+
'color': 'text/neutral',
|
|
61
|
+
'& > svg': {
|
|
62
|
+
display: 'block',
|
|
63
|
+
width: 16,
|
|
64
|
+
height: 16,
|
|
65
|
+
color: 'icon/neutral/bold'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
children: typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual
|
|
69
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(BaseInput, {
|
|
70
|
+
ref: e => {
|
|
71
|
+
isFunction(ref) ? ref(e) : null;
|
|
72
|
+
inputRef.current = e;
|
|
73
|
+
},
|
|
74
|
+
value: '',
|
|
75
|
+
onChange: noop,
|
|
76
|
+
...props,
|
|
77
|
+
tabIndex: -1,
|
|
78
|
+
onClick: e => {
|
|
79
|
+
popperProps.onClick?.(e);
|
|
80
|
+
props.onClick?.(e);
|
|
81
|
+
}
|
|
82
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(StyledIcon, {
|
|
83
|
+
sx: {
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
top: '50%',
|
|
86
|
+
transform: 'translateY(-50%)',
|
|
87
|
+
right: 5,
|
|
88
|
+
pointerEvents: 'none'
|
|
89
|
+
},
|
|
90
|
+
icon: SvgChevronDown,
|
|
91
|
+
color: disabled ? 'icon/disabled' : 'icon/neutral/bolder',
|
|
92
|
+
size: 16
|
|
93
|
+
})]
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const TextInputWrapper = styled.div`
|
|
98
|
+
position: relative;
|
|
99
|
+
width: ${forcePixelValue('100%')};
|
|
100
|
+
border-width: ${forcePixelValue(1)};
|
|
101
|
+
border-style: solid;
|
|
102
|
+
border-radius: ${({
|
|
103
|
+
theme
|
|
104
|
+
}) => forcePixelValue(theme.radii.xs)};
|
|
105
|
+
border-color: ${({
|
|
106
|
+
theme
|
|
107
|
+
}) => theme.colors['border/input']};
|
|
108
|
+
background-color: ${({
|
|
109
|
+
theme
|
|
110
|
+
}) => theme.colors['bg/input']};
|
|
111
|
+
cursor: default;
|
|
112
|
+
input {
|
|
113
|
+
cursor: default;
|
|
114
|
+
}
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
|
|
118
|
+
font-size: ${({
|
|
119
|
+
theme
|
|
120
|
+
}) => forcePixelValue(theme.fontSizes.xs)};
|
|
121
|
+
font-weight: ${({
|
|
122
|
+
theme
|
|
123
|
+
}) => theme.fontWeights.medium};
|
|
124
|
+
line-height: ${({
|
|
125
|
+
theme
|
|
126
|
+
}) => theme.lineHeights[2]};
|
|
127
|
+
color: ${({
|
|
128
|
+
theme
|
|
129
|
+
}) => theme.colors['text/neutral']};
|
|
130
|
+
input::placeholder {
|
|
131
|
+
color: ${({
|
|
132
|
+
theme
|
|
133
|
+
}) => theme.colors['text/neutral/subtlest']};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&:after {
|
|
137
|
+
content: '';
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: ${forcePixelValue(-1)};
|
|
140
|
+
right: ${forcePixelValue(-1)};
|
|
141
|
+
bottom: ${forcePixelValue(-1)};
|
|
142
|
+
left: ${forcePixelValue(-1)};
|
|
143
|
+
|
|
144
|
+
border: ${forcePixelValue(2)} solid transparent;
|
|
145
|
+
border-radius: ${({
|
|
146
|
+
theme
|
|
147
|
+
}) => forcePixelValue(theme.radii.xs)};
|
|
148
|
+
pointer-events: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
${props => props.validationStatus !== 'error' && !props.disabled && css`
|
|
152
|
+
&:hover:not(:focus-within) {
|
|
153
|
+
&:after {
|
|
154
|
+
border-color: ${({
|
|
155
|
+
theme
|
|
156
|
+
}) => theme.colors['border/hovered']};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
`}
|
|
160
|
+
|
|
161
|
+
${props => props.validationStatus === 'error' && css`
|
|
162
|
+
&:after {
|
|
163
|
+
border-color: ${({
|
|
164
|
+
theme
|
|
165
|
+
}) => theme.colors['border/danger']};
|
|
166
|
+
}
|
|
167
|
+
`}
|
|
168
|
+
|
|
169
|
+
${props => props.validationStatus !== 'error' && !props.disabled && css`
|
|
170
|
+
&:focus-within {
|
|
171
|
+
&:after {
|
|
172
|
+
border-color: ${({
|
|
173
|
+
theme
|
|
174
|
+
}) => theme.colors['border/focused']};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`}
|
|
178
|
+
|
|
179
|
+
${props => props.disabled && css`
|
|
180
|
+
border-color: ${props.theme.colors['border/input']};
|
|
181
|
+
background-color: ${props.theme.colors['bg/disabled']};
|
|
182
|
+
color: ${props.theme.colors['text/disabled']};
|
|
183
|
+
|
|
184
|
+
input::placeholder {
|
|
185
|
+
color: ${props.theme.colors['text/disabled']};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
input {
|
|
189
|
+
cursor: not-allowed;
|
|
190
|
+
}
|
|
191
|
+
`};
|
|
192
|
+
|
|
193
|
+
${props => props.hasLeadingVisual && css`
|
|
194
|
+
padding-left: ${forcePixelValue(props.theme.space[5])};
|
|
195
|
+
input {
|
|
196
|
+
padding-left: ${forcePixelValue(props.theme.space[2])};
|
|
197
|
+
}
|
|
198
|
+
`}
|
|
199
|
+
|
|
200
|
+
transition: color 100ms, background-color 100ms;
|
|
201
|
+
&:after {
|
|
202
|
+
transition: border-color 100ms;
|
|
203
|
+
}
|
|
204
|
+
`;
|
|
205
|
+
const UnstyledInput = styled.input`
|
|
206
|
+
font-size: inherit;
|
|
207
|
+
font-weight: inherit;
|
|
208
|
+
line-height: inherit;
|
|
209
|
+
font-family: inherit;
|
|
210
|
+
border-radius: inherit;
|
|
211
|
+
color: inherit;
|
|
212
|
+
transition: inherit;
|
|
213
|
+
|
|
214
|
+
border: 0;
|
|
215
|
+
background-color: transparent;
|
|
216
|
+
width: 100%;
|
|
217
|
+
&:focus {
|
|
218
|
+
outline: 0;
|
|
219
|
+
}
|
|
220
|
+
`;
|
|
221
|
+
const BaseInput = styled(UnstyledInput)`
|
|
222
|
+
padding-top: ${({
|
|
223
|
+
theme
|
|
224
|
+
}) => forcePixelValue(theme.space['4'])};
|
|
225
|
+
padding-right: ${({
|
|
226
|
+
theme
|
|
227
|
+
}) => forcePixelValue(theme.space['5'])};
|
|
228
|
+
padding-bottom: ${({
|
|
229
|
+
theme
|
|
230
|
+
}) => forcePixelValue(theme.space['4'])};
|
|
231
|
+
padding-left: ${({
|
|
232
|
+
theme
|
|
233
|
+
}) => forcePixelValue(theme.space['5'])};
|
|
234
|
+
`;
|
|
235
|
+
var index = /*#__PURE__*/forwardRef(OverlaySelectInput);
|
|
236
|
+
|
|
237
|
+
export { index as default };
|
|
@@ -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 };
|
package/esm/core/Select/index.js
CHANGED
|
@@ -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 = ({
|
|
@@ -62,7 +63,7 @@ const Select = ({
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
|
-
children: [/*#__PURE__*/jsxRuntimeExports.jsx(
|
|
66
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(SelectOption, {
|
|
66
67
|
label: placeholder,
|
|
67
68
|
value: PLACEHOLDER_VALUE
|
|
68
69
|
}), children]
|
|
@@ -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
|
});
|
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.
|
|
3
|
+
"version": "2.18.1",
|
|
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": "1b05ea29fdfa9fdc36731283f8c009b1b3156392"
|
|
66
66
|
}
|