@semcore/inline-input 3.0.9 → 3.0.12
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/CHANGELOG.md +18 -0
- package/README.md +67 -0
- package/lib/cjs/InlineInput.js +67 -44
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/InlineInput.js +67 -44
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/package.json +2 -2
- package/src/InlineInput.tsx +0 -328
- package/src/index.d.ts +0 -163
- package/src/index.ts +0 -2
- package/src/style/inline-input.shadow.css +0 -118
package/src/InlineInput.tsx
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
3
|
-
import { Box } from '@semcore/flex-box';
|
|
4
|
-
import autoFocusEnhance from '@semcore/utils/lib/enhances/autoFocusEnhance';
|
|
5
|
-
import Tooltip, { ITooltipProps } from '@semcore/tooltip';
|
|
6
|
-
import style from './style/inline-input.shadow.css';
|
|
7
|
-
import CheckM from '@semcore/icon/Check/m';
|
|
8
|
-
import CloseM from '@semcore/icon/Close/m';
|
|
9
|
-
import Spin from '@semcore/spin';
|
|
10
|
-
|
|
11
|
-
const isFocusOutsideOf = (element: HTMLElement) => {
|
|
12
|
-
let traversed: Element | null | undefined = document.activeElement;
|
|
13
|
-
for (let i = 0; i < 1000000; i++) {
|
|
14
|
-
if (traversed === element) return false;
|
|
15
|
-
if (traversed === document.body) return true;
|
|
16
|
-
traversed = traversed?.parentElement;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
throw new Error(
|
|
20
|
-
'Failed to traverse parents chain in utilite `isFocusOutsideOf` in reasonable count of iterations. Possibly Shadow DOM or come other uncommon DOM-way is used, that is not supported by utilite yet. If you are not doing weird things or that is reasonable, contact developers team for yours case support.',
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type OnConfirm = (
|
|
25
|
-
value: string,
|
|
26
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
27
|
-
) => void;
|
|
28
|
-
type OnCancel = (
|
|
29
|
-
prevValue: string,
|
|
30
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
31
|
-
) => void;
|
|
32
|
-
type RootAsProps = {
|
|
33
|
-
state?: 'normal' | 'valid' | 'invalid';
|
|
34
|
-
loading?: boolean;
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
onConfirm?: OnConfirm;
|
|
37
|
-
onCancel?: OnCancel;
|
|
38
|
-
value?: string;
|
|
39
|
-
defaultValue?: string;
|
|
40
|
-
autoFocus?: boolean;
|
|
41
|
-
placeholder?: string;
|
|
42
|
-
onChange?: (value: string, event: React.ChangeEvent) => void;
|
|
43
|
-
onBlur?: (event: React.FocusEvent) => void;
|
|
44
|
-
onFocus?: (event: React.FocusEvent) => void;
|
|
45
|
-
onBlurBehavior?: 'cancel' | 'confirm';
|
|
46
|
-
styles?: React.CSSProperties;
|
|
47
|
-
Children: React.FC;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type AddonAsProps = {
|
|
51
|
-
styles?: React.CSSProperties;
|
|
52
|
-
Children: React.FC;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type ControlAsProps = {
|
|
56
|
-
Children: React.FC;
|
|
57
|
-
styles?: React.CSSProperties;
|
|
58
|
-
title?: string;
|
|
59
|
-
$tooltipsProps?: ITooltipProps;
|
|
60
|
-
loading?: boolean;
|
|
61
|
-
disabled?: boolean;
|
|
62
|
-
onCancel?: OnCancel;
|
|
63
|
-
value?: string;
|
|
64
|
-
icon?: React.FC;
|
|
65
|
-
};
|
|
66
|
-
type ConfirmControlAsProps = ControlAsProps & {
|
|
67
|
-
onConfirm?: OnConfirm;
|
|
68
|
-
};
|
|
69
|
-
type CancelControlAsProps = ControlAsProps & {
|
|
70
|
-
onCancel?: OnCancel;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
class InlineInputBase extends Component<RootAsProps> {
|
|
74
|
-
static displayName = 'InlineInput';
|
|
75
|
-
|
|
76
|
-
static defaultProps = {
|
|
77
|
-
state: 'normal',
|
|
78
|
-
onBlurBehavior: 'confirm',
|
|
79
|
-
};
|
|
80
|
-
static style = style;
|
|
81
|
-
|
|
82
|
-
state = {
|
|
83
|
-
focused: false,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
rootRef = React.createRef<HTMLElement>();
|
|
87
|
-
inputRef = React.createRef<HTMLInputElement>();
|
|
88
|
-
initValue: string = '';
|
|
89
|
-
|
|
90
|
-
componentDidMount() {
|
|
91
|
-
this.initValue = this.inputRef.current?.value || '';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
getAddonProps() {
|
|
95
|
-
return {
|
|
96
|
-
onMouseDown: this.handleMouseDownAddon,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getConfirmControlProps() {
|
|
101
|
-
const { loading } = this.asProps;
|
|
102
|
-
return {
|
|
103
|
-
value: this.inputRef.current?.value,
|
|
104
|
-
loading,
|
|
105
|
-
onConfirm: this.handleConfirm,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getCancelControlProps() {
|
|
110
|
-
const { loading, disabled } = this.asProps;
|
|
111
|
-
return {
|
|
112
|
-
value: this.initValue,
|
|
113
|
-
// because double disabled(root disabled and addon disabled)
|
|
114
|
-
disabled: loading && !disabled,
|
|
115
|
-
onCancel: this.handleCancel,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getValueProps() {
|
|
120
|
-
const { state } = this.asProps;
|
|
121
|
-
return {
|
|
122
|
-
ref: this.inputRef,
|
|
123
|
-
state,
|
|
124
|
-
onKeyDown: this.handleKeyDown,
|
|
125
|
-
onFocus: this.bindHandlerValueFocused(true),
|
|
126
|
-
onBlur: this.bindHandlerValueFocused(false),
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
bindHandlerValueFocused = (focused: boolean) => () => {
|
|
131
|
-
this.setState({ focused });
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
handleMouseDownAddon = (event: React.MouseEvent) => {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
this.inputRef.current?.focus();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
handleConfirm = (
|
|
140
|
-
text: string,
|
|
141
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
142
|
-
) => {
|
|
143
|
-
this.asProps.onConfirm?.(text, event);
|
|
144
|
-
};
|
|
145
|
-
handleCancel = (
|
|
146
|
-
prevText: string,
|
|
147
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
148
|
-
) => {
|
|
149
|
-
this.asProps.onCancel?.(prevText, event);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
handleBlur = (event: React.FocusEvent) => {
|
|
153
|
-
const { onConfirm, onCancel, onBlurBehavior } = this.asProps;
|
|
154
|
-
if (onBlurBehavior) {
|
|
155
|
-
setTimeout(() => {
|
|
156
|
-
if (this.rootRef.current && isFocusOutsideOf(this.rootRef.current)) {
|
|
157
|
-
if (onBlurBehavior === 'confirm') onConfirm?.(this.inputRef.current?.value ?? '', event);
|
|
158
|
-
if (onBlurBehavior === 'cancel') onCancel?.(this.initValue, event);
|
|
159
|
-
}
|
|
160
|
-
}, 0);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
handleKeyDown = (event: React.KeyboardEvent) => {
|
|
165
|
-
const { onConfirm, onCancel } = this.asProps;
|
|
166
|
-
if (event.code === 'Enter') onConfirm?.(this.inputRef.current?.value ?? '', event);
|
|
167
|
-
if (event.code === 'Escape') onCancel?.(this.initValue, event);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
render() {
|
|
171
|
-
const SInlineInput = Root;
|
|
172
|
-
const SUnderline = 'div';
|
|
173
|
-
const { Children, styles } = this.asProps;
|
|
174
|
-
const { focused } = this.state;
|
|
175
|
-
|
|
176
|
-
return sstyled(styles)(
|
|
177
|
-
<SInlineInput render={Box} ref={this.rootRef} focused={focused} onBlur={this.handleBlur}>
|
|
178
|
-
<SUnderline>
|
|
179
|
-
<Children />
|
|
180
|
-
</SUnderline>
|
|
181
|
-
</SInlineInput>,
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
class Value extends Component<RootAsProps> {
|
|
187
|
-
static defaultProps = {
|
|
188
|
-
defaultValue: '',
|
|
189
|
-
};
|
|
190
|
-
static enhance = [autoFocusEnhance()];
|
|
191
|
-
static hoistProps = ['disabled'];
|
|
192
|
-
|
|
193
|
-
uncontrolledProps() {
|
|
194
|
-
return {
|
|
195
|
-
value: (event: React.ChangeEvent<HTMLInputElement>) => event.target.value,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
render() {
|
|
200
|
-
const SValue = Root;
|
|
201
|
-
|
|
202
|
-
return sstyled(this.asProps.styles)(<SValue render={Box} tag="input" type="text" />);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const Addon: React.FC<AddonAsProps> = (props) => {
|
|
207
|
-
const SAddon = Root;
|
|
208
|
-
return sstyled(props.styles)(<SAddon render={Box} />) as React.ReactElement;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const ConfirmControl: React.FC<ConfirmControlAsProps> = (props) => {
|
|
212
|
-
const SAddon = Root;
|
|
213
|
-
const { Children, children: hasChildren, title } = props;
|
|
214
|
-
|
|
215
|
-
const handleConfirm = React.useCallback(
|
|
216
|
-
(event: React.MouseEvent | React.KeyboardEvent) => {
|
|
217
|
-
props.onConfirm?.(props.value ?? '', event);
|
|
218
|
-
},
|
|
219
|
-
[props.onConfirm, props.value],
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
const handleKeydown = React.useCallback(
|
|
223
|
-
(event: React.KeyboardEvent) => {
|
|
224
|
-
if (event.code === 'Enter' || event.code === 'Space') {
|
|
225
|
-
event.preventDefault();
|
|
226
|
-
event.stopPropagation();
|
|
227
|
-
handleConfirm(event);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
[handleConfirm],
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
if (props.loading) {
|
|
234
|
-
return sstyled(props.styles)(
|
|
235
|
-
<SAddon render={Box}>{hasChildren ? <Children /> : <Spin size="xs" />}</SAddon>,
|
|
236
|
-
) as React.ReactElement;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const sstyles = sstyled(props.styles);
|
|
240
|
-
const sConfirmIconStyles = sstyles.cn('SConfirmIcon', {});
|
|
241
|
-
|
|
242
|
-
return sstyled(props.styles)(
|
|
243
|
-
<SAddon render={Box} onKeyDown={handleKeydown}>
|
|
244
|
-
{hasChildren ? (
|
|
245
|
-
<Children />
|
|
246
|
-
) : (
|
|
247
|
-
<Tooltip {...props.$tooltipsProps}>
|
|
248
|
-
<Tooltip.Trigger
|
|
249
|
-
tag={props.icon ?? CheckM}
|
|
250
|
-
aria-label={`${title} ${props.value ?? ''}`}
|
|
251
|
-
role="button"
|
|
252
|
-
onClick={handleConfirm}
|
|
253
|
-
className={sConfirmIconStyles.className}
|
|
254
|
-
style={sConfirmIconStyles.style}
|
|
255
|
-
/>
|
|
256
|
-
<Tooltip.Popper p={3}>{props.title}</Tooltip.Popper>
|
|
257
|
-
</Tooltip>
|
|
258
|
-
)}
|
|
259
|
-
</SAddon>,
|
|
260
|
-
) as React.ReactElement;
|
|
261
|
-
};
|
|
262
|
-
ConfirmControl.defaultProps = {
|
|
263
|
-
title: 'Confirm',
|
|
264
|
-
};
|
|
265
|
-
const CancelControl: React.FC<CancelControlAsProps> = (props) => {
|
|
266
|
-
const SAddon = Root;
|
|
267
|
-
const { Children, children: hasChildren, title } = props;
|
|
268
|
-
|
|
269
|
-
const handleCancel = React.useCallback(
|
|
270
|
-
(event: React.MouseEvent | React.KeyboardEvent) => {
|
|
271
|
-
props.onCancel?.(props.value ?? '', event);
|
|
272
|
-
},
|
|
273
|
-
[props.onCancel, props.value],
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
const handleKeydown = React.useCallback(
|
|
277
|
-
(event: React.KeyboardEvent) => {
|
|
278
|
-
if (event.code === 'Enter' || event.code === 'Space') {
|
|
279
|
-
event.preventDefault();
|
|
280
|
-
event.stopPropagation();
|
|
281
|
-
handleCancel(event);
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
[handleCancel],
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
if (props.disabled) {
|
|
288
|
-
return sstyled(props.styles)(
|
|
289
|
-
<SAddon render={Box}>{hasChildren ? <Children /> : <CloseM disabled />}</SAddon>,
|
|
290
|
-
) as React.ReactElement;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const sstyles = sstyled(props.styles);
|
|
294
|
-
const sCancelIconStyles = sstyles.cn('SCancelIcon', {});
|
|
295
|
-
|
|
296
|
-
return sstyled(props.styles)(
|
|
297
|
-
<SAddon render={Box} onKeyDown={handleKeydown}>
|
|
298
|
-
{hasChildren ? (
|
|
299
|
-
<Children />
|
|
300
|
-
) : (
|
|
301
|
-
<Tooltip {...props.$tooltipsProps}>
|
|
302
|
-
<Tooltip.Trigger
|
|
303
|
-
tag={props.icon ?? CloseM}
|
|
304
|
-
aria-label={title}
|
|
305
|
-
role="button"
|
|
306
|
-
onClick={handleCancel}
|
|
307
|
-
className={sCancelIconStyles.className}
|
|
308
|
-
style={sCancelIconStyles.style}
|
|
309
|
-
/>
|
|
310
|
-
<Tooltip.Popper p={3}>{title}</Tooltip.Popper>
|
|
311
|
-
</Tooltip>
|
|
312
|
-
)}
|
|
313
|
-
</SAddon>,
|
|
314
|
-
) as React.ReactElement;
|
|
315
|
-
};
|
|
316
|
-
CancelControl.defaultProps = {
|
|
317
|
-
title: 'Cancel',
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
321
|
-
const InlineInput = createComponent(InlineInputBase, {
|
|
322
|
-
Addon,
|
|
323
|
-
Value,
|
|
324
|
-
ConfirmControl,
|
|
325
|
-
CancelControl,
|
|
326
|
-
}) as any;
|
|
327
|
-
|
|
328
|
-
export default InlineInput;
|
package/src/index.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PropGetterFn } from '@semcore/core';
|
|
3
|
-
import { IBoxProps } from '@semcore/flex-box';
|
|
4
|
-
|
|
5
|
-
/* utils type */
|
|
6
|
-
type CProps<Props, Ctx = {}, UCProps = {}> = Props & {
|
|
7
|
-
children?:
|
|
8
|
-
| ((props: Props & Ctx, handlers: UCProps) => React.ReactNode)
|
|
9
|
-
| React.ReactNode
|
|
10
|
-
| React.ReactNode[];
|
|
11
|
-
};
|
|
12
|
-
/* utils type */
|
|
13
|
-
|
|
14
|
-
export interface IInlineInputProps extends IBoxProps {
|
|
15
|
-
/**
|
|
16
|
-
* Visual state of inline input
|
|
17
|
-
* @default normal
|
|
18
|
-
*/
|
|
19
|
-
state?: 'normal' | 'valid' | 'invalid';
|
|
20
|
-
/**
|
|
21
|
-
* Disabled input and shows spinner instead of confirm control
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
loading?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Disabled input and controls
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Fired with entered value when user clicks confirm control or hits `Enter` or `Space`
|
|
32
|
-
*/
|
|
33
|
-
onConfirm?: (
|
|
34
|
-
value: string,
|
|
35
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
36
|
-
) => void;
|
|
37
|
-
/**
|
|
38
|
-
* Fired with value (or defaultValue) that was provided during component mount when user clicks cancel control or hits `Escape`
|
|
39
|
-
*/
|
|
40
|
-
onCancel?: (
|
|
41
|
-
prevValue: string,
|
|
42
|
-
event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,
|
|
43
|
-
) => void;
|
|
44
|
-
/**
|
|
45
|
-
* Text value of input. Should be used with `onChange` property together
|
|
46
|
-
*/
|
|
47
|
-
value?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Initial text value of input
|
|
50
|
-
*/
|
|
51
|
-
defaultValue?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Makes component to catch browser focus on component mount
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
autoFocus?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Gray text displayed in empty input
|
|
59
|
-
*/
|
|
60
|
-
placeholder?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Fired on every input value change. Should be used with `value` property together
|
|
63
|
-
*/
|
|
64
|
-
onChange?: (value: string, event: React.ChangeEvent) => void;
|
|
65
|
-
/**
|
|
66
|
-
* Fired when browser focus leaves component.
|
|
67
|
-
*/
|
|
68
|
-
onBlur?: (event: React.FocusEvent) => void;
|
|
69
|
-
/**
|
|
70
|
-
* Fired when browser focus enters component.
|
|
71
|
-
*/
|
|
72
|
-
onFocus?: (event: React.FocusEvent) => void;
|
|
73
|
-
/**
|
|
74
|
-
* defines callback (`onCancel` or `onConfirm`) triggered when `blur` event out of container fired
|
|
75
|
-
* Triggered after all previous macrotasks completed (internally called inside of `setTimeout`)
|
|
76
|
-
*/
|
|
77
|
-
onBlurBehavior?: 'cancel' | 'confirm';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface IInlineInputAddonProps extends IBoxProps {}
|
|
81
|
-
export interface IInlineInputValueProps extends IBoxProps {
|
|
82
|
-
/**
|
|
83
|
-
* id attribute of input tag
|
|
84
|
-
*/
|
|
85
|
-
id?: string;
|
|
86
|
-
/**
|
|
87
|
-
* when `true`, element is focused immediately after mount
|
|
88
|
-
*/
|
|
89
|
-
autoFocus?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* value of input tag
|
|
92
|
-
*/
|
|
93
|
-
value?: string;
|
|
94
|
-
/**
|
|
95
|
-
* uncontrolled value of input tag
|
|
96
|
-
*/
|
|
97
|
-
defaultValue?: string;
|
|
98
|
-
/**
|
|
99
|
-
* callback invoked on every change of input tag value
|
|
100
|
-
*/
|
|
101
|
-
onChange?: (value: string, event: React.ChangeEvent) => void;
|
|
102
|
-
/**
|
|
103
|
-
* visual state of component
|
|
104
|
-
*/
|
|
105
|
-
state?: 'normal' | 'valid' | 'invalid';
|
|
106
|
-
/**
|
|
107
|
-
* shows spinner in `InlineInput.ConfirmControl` and disables other interactive elements
|
|
108
|
-
*/
|
|
109
|
-
loading?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* disables interactive elements
|
|
112
|
-
*/
|
|
113
|
-
disabled?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* gray text in empty input tag
|
|
116
|
-
*/
|
|
117
|
-
placeholder?: string;
|
|
118
|
-
}
|
|
119
|
-
export interface IInlineInputConfirmControlProps extends IBoxProps {
|
|
120
|
-
/**
|
|
121
|
-
* Text of tooltip
|
|
122
|
-
* @default Confirm
|
|
123
|
-
*/
|
|
124
|
-
title?: string;
|
|
125
|
-
/**
|
|
126
|
-
* Icon component
|
|
127
|
-
* @default CheckM
|
|
128
|
-
*/
|
|
129
|
-
icon?: React.FC;
|
|
130
|
-
}
|
|
131
|
-
export interface IInlineInputCancelControlProps extends IBoxProps {
|
|
132
|
-
/**
|
|
133
|
-
* Text of tooltip
|
|
134
|
-
* @default Cancel
|
|
135
|
-
*/
|
|
136
|
-
title?: string;
|
|
137
|
-
/**
|
|
138
|
-
* Icon component
|
|
139
|
-
* @default CloseM
|
|
140
|
-
*/
|
|
141
|
-
icon?: React.FC;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
interface IInlineInputCtx {
|
|
145
|
-
geAddonProps: PropGetterFn;
|
|
146
|
-
getConfirmControlProps: PropGetterFn;
|
|
147
|
-
getCancelControlProps: PropGetterFn;
|
|
148
|
-
getValueProps: PropGetterFn;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
declare const InlineInput: (<T>(
|
|
152
|
-
props: CProps<IInlineInputProps & T, IInlineInputCtx>,
|
|
153
|
-
) => React.ReactElement) & {
|
|
154
|
-
Addon: <T>(props: CProps<IInlineInputAddonProps & T, IInlineInputProps>) => React.ReactElement;
|
|
155
|
-
Value: <T>(props: CProps<IInlineInputValueProps & T, IInlineInputProps>) => React.ReactElement;
|
|
156
|
-
ConfirmControl: <T>(
|
|
157
|
-
props: CProps<IInlineInputConfirmControlProps & T, IInlineInputProps>,
|
|
158
|
-
) => React.ReactElement;
|
|
159
|
-
CancelControl: <T>(
|
|
160
|
-
props: CProps<IInlineInputCancelControlProps & T, IInlineInputProps>,
|
|
161
|
-
) => React.ReactElement;
|
|
162
|
-
};
|
|
163
|
-
export default InlineInput;
|
package/src/index.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
@import '@semcore/utils/style/var.css';
|
|
2
|
-
|
|
3
|
-
SInlineInput {
|
|
4
|
-
display: inline-flex;
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100%;
|
|
7
|
-
align-items: center;
|
|
8
|
-
position: relative;
|
|
9
|
-
z-index: 0;
|
|
10
|
-
vertical-align: middle;
|
|
11
|
-
padding: 1px;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
|
|
14
|
-
background-color: var(--white);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
SInlineInput[disabled] {
|
|
18
|
-
cursor: default;
|
|
19
|
-
pointer-events: none;
|
|
20
|
-
opacity: var(--disabled-opacity);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
SValue {
|
|
24
|
-
/* hack for firefox */
|
|
25
|
-
min-width: 0;
|
|
26
|
-
|
|
27
|
-
width: 100%;
|
|
28
|
-
height: 100%;
|
|
29
|
-
padding: 0px 4px;
|
|
30
|
-
border: none;
|
|
31
|
-
box-sizing: border-box;
|
|
32
|
-
color: var(--gray-800);
|
|
33
|
-
font-size: inherit;
|
|
34
|
-
line-height: 1.2;
|
|
35
|
-
text-overflow: ellipsis;
|
|
36
|
-
font-family: inherit;
|
|
37
|
-
background: transparent;
|
|
38
|
-
min-height: 1em;
|
|
39
|
-
|
|
40
|
-
&:focus {
|
|
41
|
-
outline: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&::placeholder {
|
|
45
|
-
color: var(--gray-300);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&[disabled] {
|
|
49
|
-
user-select: none;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
SUnderline {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: row;
|
|
56
|
-
align-items: center;
|
|
57
|
-
flex-grow: 1;
|
|
58
|
-
width: 100%;
|
|
59
|
-
height: 100%;
|
|
60
|
-
min-height: 1em;
|
|
61
|
-
border: 1px solid transparent;
|
|
62
|
-
border-bottom: 1px solid var(--gray-200);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
SAddon {
|
|
66
|
-
display: inline-flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
align-items: center;
|
|
69
|
-
flex: 0 0 auto;
|
|
70
|
-
height: 100%;
|
|
71
|
-
color: var(--gray-300);
|
|
72
|
-
padding: 0 4px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
SAddon[disabled] {
|
|
76
|
-
opacity: var(--disabled-opacity);
|
|
77
|
-
cursor: default;
|
|
78
|
-
pointer-events: none;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
SConfirmIcon {
|
|
82
|
-
color: var(--green-300);
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
}
|
|
85
|
-
SConfirmIcon:hover {
|
|
86
|
-
color: var(--green-400);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
SCancelIcon {
|
|
90
|
-
color: var(--gray-300);
|
|
91
|
-
cursor: pointer;
|
|
92
|
-
}
|
|
93
|
-
SCancelIcon:hover {
|
|
94
|
-
color: var(--gray-400);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
SInlineInput[focused] {
|
|
98
|
-
z-index: 1;
|
|
99
|
-
}
|
|
100
|
-
SInlineInput[focused] SUnderline {
|
|
101
|
-
border-bottom-color: var(--blue-400);
|
|
102
|
-
box-shadow: var(--keyboard-focus);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
SInlineInput[state='valid'] SUnderline {
|
|
106
|
-
border-bottom-color: var(--green-200);
|
|
107
|
-
}
|
|
108
|
-
SInlineInput[state='valid'][focused] SUnderline {
|
|
109
|
-
border-bottom-color: var(--green-400);
|
|
110
|
-
box-shadow: var(--keyboard-focus-valid);
|
|
111
|
-
}
|
|
112
|
-
SInlineInput[state='invalid'] SUnderline {
|
|
113
|
-
border-bottom-color: var(--red-200);
|
|
114
|
-
}
|
|
115
|
-
SInlineInput[state='invalid'][focused] SUnderline {
|
|
116
|
-
border-bottom-color: var(--red-400);
|
|
117
|
-
box-shadow: var(--keyboard-focus-invalid);
|
|
118
|
-
}
|