@semcore/inline-input 1.0.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.
- package/CHANGELOG.md +9 -0
- package/README.md +0 -0
- package/lib/cjs/InlineInput.js +488 -0
- package/lib/cjs/InlineInput.js.map +1 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/style/inline-input.shadow.css +150 -0
- package/lib/es6/InlineInput.js +475 -0
- package/lib/es6/InlineInput.js.map +1 -0
- package/lib/es6/index.js +3 -0
- package/lib/es6/index.js.map +1 -0
- package/lib/es6/style/inline-input.shadow.css +150 -0
- package/lib/types/index.d.ts +199 -0
- package/package.json +40 -0
- package/src/InlineInput.tsx +387 -0
- package/src/index.d.ts +199 -0
- package/src/index.ts +2 -0
- package/src/style/inline-input.shadow.css +150 -0
- package/yarn-error.log +21221 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":["InlineInputBase"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,eAA5B;AACA,eAAeA,eAAf","sourcesContent":["import InlineInputBase from './InlineInput';\nexport default InlineInputBase;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
SControls {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SConfirmControl {
|
|
24
|
+
color: var(--green-300);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
SConfirmControl:hover {
|
|
28
|
+
color: var(--green-400);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SCancelControl {
|
|
32
|
+
color: var(--gray-300);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
SCancelControl:hover {
|
|
36
|
+
color: var(--gray-400);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SValue {
|
|
40
|
+
/* hack for firefox */
|
|
41
|
+
min-width: 0;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
padding: 0 4px;
|
|
45
|
+
border: none;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
color: var(--gray20);
|
|
48
|
+
font-size: inherit;
|
|
49
|
+
line-height: 1.2;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
font-family: inherit;
|
|
52
|
+
background: transparent;
|
|
53
|
+
min-height: 1em;
|
|
54
|
+
|
|
55
|
+
&:focus {
|
|
56
|
+
outline: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&::placeholder {
|
|
60
|
+
color: var(--gray70);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:read-only ~ SUnderline {
|
|
64
|
+
/* background: var(--gray96); */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&[disabled],
|
|
68
|
+
&[loading] {
|
|
69
|
+
opacity: var(--disabled-opacity);
|
|
70
|
+
}
|
|
71
|
+
&[disabled] {
|
|
72
|
+
user-select: none;
|
|
73
|
+
|
|
74
|
+
& ~ SUnderline {
|
|
75
|
+
cursor: default;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
SUnderline {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
align-items: center;
|
|
85
|
+
flex-grow: 1;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
min-height: 1em;
|
|
89
|
+
border: 1px solid transparent;
|
|
90
|
+
border-bottom: 1px solid var(--gray-200);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
SAddon {
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
align-items: center;
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
height: 100%;
|
|
99
|
+
color: var(--gray-300);
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
SAddon[disabled] {
|
|
104
|
+
opacity: var(--disabled-opacity);
|
|
105
|
+
cursor: default;
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
SInlineInput[focused] {
|
|
110
|
+
z-index: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
SInlineInput[focused] SUnderline {
|
|
114
|
+
border-color: var(--blue-400);
|
|
115
|
+
box-shadow: var(--keyborad-focus);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
SInlineInput[state='valid'] SUnderline {
|
|
119
|
+
border-color: var(--green-200);
|
|
120
|
+
}
|
|
121
|
+
SInlineInput[state='valid'][focused] SUnderline {
|
|
122
|
+
border-color: var(--green-400);
|
|
123
|
+
box-shadow: var(--keyboard-focus-valid);
|
|
124
|
+
}
|
|
125
|
+
SInlineInput[state='invalid'] SUnderline {
|
|
126
|
+
border-color: var(--red-200);
|
|
127
|
+
}
|
|
128
|
+
SInlineInput[state='invalid'][focused] SUnderline {
|
|
129
|
+
border-color: var(--red-400);
|
|
130
|
+
box-shadow: var(--keyboard-focus-invalid);
|
|
131
|
+
}
|
|
132
|
+
SInlineInput[state='disabled'],
|
|
133
|
+
SInlineInput[loading] {
|
|
134
|
+
cursor: default;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CloseM[disabled] {
|
|
138
|
+
cursor: default;
|
|
139
|
+
opacity: var(--disabled-opacity);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.controls-icon {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.spin {
|
|
148
|
+
min-width: 16px;
|
|
149
|
+
cursor: default;
|
|
150
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PropGetterFn } from '@semcore/core';
|
|
3
|
+
import { ITooltipProps } from '@semcore/tooltip';
|
|
4
|
+
import { IBoxProps } from '@semcore/flex-box';
|
|
5
|
+
|
|
6
|
+
/* utils type */
|
|
7
|
+
type CProps<Props, Ctx = {}, UCProps = {}> = Props & {
|
|
8
|
+
children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactElement) | React.ReactElement;
|
|
9
|
+
};
|
|
10
|
+
/* utils type */
|
|
11
|
+
|
|
12
|
+
export interface IInlineInputProps extends IBoxProps {
|
|
13
|
+
/**
|
|
14
|
+
* Visual state of inline input
|
|
15
|
+
* @default normal
|
|
16
|
+
*/
|
|
17
|
+
state?: 'normal' | 'valid' | 'invalid' | 'disabled';
|
|
18
|
+
/**
|
|
19
|
+
* Disabled inputs and shows spinner instead of confirm control
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
loading?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Fired with entered value when user clicks confirm control or hits `Enter` or `Space`
|
|
25
|
+
*/
|
|
26
|
+
onConfirm?: (value: string, event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Fired with value (or defaultValue) that was provided during component mount when user clicks cancel control or hits `Escape`
|
|
29
|
+
*/
|
|
30
|
+
onCancel?: (prevValue: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Text value of input. Should be used with `onChange` property together
|
|
33
|
+
*/
|
|
34
|
+
value?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Initial text value of input
|
|
37
|
+
*/
|
|
38
|
+
defaultValue?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Tooltip and aria-label text of the confirm control
|
|
41
|
+
* @default Confirm
|
|
42
|
+
*/
|
|
43
|
+
confirmText?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Tooltip and aria-label text of the cancel control
|
|
46
|
+
* @default Cancel
|
|
47
|
+
*/
|
|
48
|
+
cancelText?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Properties of control's tooltips
|
|
51
|
+
*/
|
|
52
|
+
tooltipsProps?: ITooltipProps;
|
|
53
|
+
/**
|
|
54
|
+
* Makes component to catch browser focus on component mount
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
autoFocus?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Gray text displayed in empty input
|
|
60
|
+
*/
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
/**
|
|
63
|
+
* `id` attribute of `<input />` dom tag. Use it to attach `<label />` via `htmlFor` attribute to `<input />` tag
|
|
64
|
+
*/
|
|
65
|
+
inputId?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Fired on every input value change. Should be used with `value` property together
|
|
68
|
+
*/
|
|
69
|
+
onChange?: (value: string, event: React.ChangeEvent) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Fired when browser focus leaves component.
|
|
72
|
+
*/
|
|
73
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Fired when browser focus enters component.
|
|
76
|
+
*/
|
|
77
|
+
onFocus?: (event: React.FocusEvent) => void;
|
|
78
|
+
/**
|
|
79
|
+
* @description defines callback (`onCancel` or `onConfirm`) triggered when `blur` event out of container fired
|
|
80
|
+
* Triggered after all previous macrotasks completed (internally called inside of `setTimeout`)
|
|
81
|
+
*/
|
|
82
|
+
onBlurBehavior?: 'cancel' | 'confirm';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface IInlineInputAddonProps extends IBoxProps {
|
|
86
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
87
|
+
}
|
|
88
|
+
export interface IInlineInputUnderlineProps extends IBoxProps {}
|
|
89
|
+
export interface IInlineInputValueProps extends IBoxProps {
|
|
90
|
+
id?: string;
|
|
91
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
92
|
+
autoFocus?: boolean;
|
|
93
|
+
value?: string;
|
|
94
|
+
defaultValue?: string;
|
|
95
|
+
onChange?: (value: string, event: React.ChangeEvent) => void;
|
|
96
|
+
state?: 'normal' | 'valid' | 'invalid' | 'disabled';
|
|
97
|
+
loading?: boolean;
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface IInlineInputConfirmIconProps extends IBoxProps {
|
|
101
|
+
onConfirm?: (value: string) => void;
|
|
102
|
+
/**
|
|
103
|
+
* @default "Confirm"
|
|
104
|
+
*/
|
|
105
|
+
confirmText?: string;
|
|
106
|
+
tooltipsProps?: ITooltipProps;
|
|
107
|
+
}
|
|
108
|
+
export interface IInlineInputCancelIconProps extends IBoxProps {
|
|
109
|
+
onCancel?: (prevValue: string) => void;
|
|
110
|
+
/**
|
|
111
|
+
* @default "Cancel"
|
|
112
|
+
*/
|
|
113
|
+
cancelText?: string;
|
|
114
|
+
tooltipsProps?: ITooltipProps;
|
|
115
|
+
}
|
|
116
|
+
export interface IInlineInputControlIconsProps extends IBoxProps {
|
|
117
|
+
onConfirm?: (value: string) => void;
|
|
118
|
+
onCancel?: (prevValue: string) => void;
|
|
119
|
+
/**
|
|
120
|
+
* @default "Confirm"
|
|
121
|
+
*/
|
|
122
|
+
confirmText?: string;
|
|
123
|
+
/**
|
|
124
|
+
* @default "Cancel"
|
|
125
|
+
*/
|
|
126
|
+
cancelText?: string;
|
|
127
|
+
tooltipsProps?: ITooltipProps;
|
|
128
|
+
}
|
|
129
|
+
export interface IInlineInputConfirmButtonProps extends IBoxProps {
|
|
130
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
131
|
+
|
|
132
|
+
onConfirm?: (value: string) => void;
|
|
133
|
+
/**
|
|
134
|
+
* @default "Confirm"
|
|
135
|
+
*/
|
|
136
|
+
confirmText?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface IInlineInputCancelButtonProps extends IBoxProps {
|
|
139
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
140
|
+
|
|
141
|
+
onCancel?: (prevValue: string) => void;
|
|
142
|
+
/**
|
|
143
|
+
* @default "Confirm"
|
|
144
|
+
*/
|
|
145
|
+
cancelText?: string;
|
|
146
|
+
}
|
|
147
|
+
export interface IInlineInputControlButtonsProps extends IBoxProps {
|
|
148
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
149
|
+
|
|
150
|
+
onConfirm?: (value: string) => void;
|
|
151
|
+
onCancel?: (prevValue: string) => void;
|
|
152
|
+
/**
|
|
153
|
+
* @default "Confirm"
|
|
154
|
+
*/
|
|
155
|
+
confirmText?: string;
|
|
156
|
+
/**
|
|
157
|
+
* @default "Cancel"
|
|
158
|
+
*/
|
|
159
|
+
cancelText?: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface IInlineInputCtx {
|
|
163
|
+
geAddonProps: PropGetterFn;
|
|
164
|
+
getConfirmIconProps: PropGetterFn;
|
|
165
|
+
getCancelIconProps: PropGetterFn;
|
|
166
|
+
getControlIconsProps: PropGetterFn;
|
|
167
|
+
getConfirmButtonProps: PropGetterFn;
|
|
168
|
+
getCancelButtonProps: PropGetterFn;
|
|
169
|
+
getControlButtonsProps: PropGetterFn;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare const InlineInput: (<T>(
|
|
173
|
+
props: CProps<IInlineInputProps & T, IInlineInputCtx>,
|
|
174
|
+
) => React.ReactElement) & {
|
|
175
|
+
Addon: <T>(props: CProps<IInlineInputAddonProps & T, IInlineInputProps>) => React.ReactElement;
|
|
176
|
+
Underline: <T>(
|
|
177
|
+
props: CProps<IInlineInputUnderlineProps & T, IInlineInputProps>,
|
|
178
|
+
) => React.ReactElement;
|
|
179
|
+
Value: <T>(props: CProps<IInlineInputValueProps & T, IInlineInputProps>) => React.ReactElement;
|
|
180
|
+
ConfirmIcon: <T>(
|
|
181
|
+
props: CProps<IInlineInputConfirmIconProps & T, IInlineInputProps>,
|
|
182
|
+
) => React.ReactElement;
|
|
183
|
+
CancelIcon: <T>(
|
|
184
|
+
props: CProps<IInlineInputCancelIconProps & T, IInlineInputProps>,
|
|
185
|
+
) => React.ReactElement;
|
|
186
|
+
ControlIcons: <T>(
|
|
187
|
+
props: CProps<IInlineInputControlIconsProps & T, IInlineInputProps>,
|
|
188
|
+
) => React.ReactElement;
|
|
189
|
+
ConfirmButton: <T>(
|
|
190
|
+
props: CProps<IInlineInputConfirmButtonProps & T, IInlineInputProps>,
|
|
191
|
+
) => React.ReactElement;
|
|
192
|
+
CancelButton: <T>(
|
|
193
|
+
props: CProps<IInlineInputCancelButtonProps & T, IInlineInputProps>,
|
|
194
|
+
) => React.ReactElement;
|
|
195
|
+
ControlButtons: <T>(
|
|
196
|
+
props: CProps<IInlineInputControlButtonsProps & T, IInlineInputProps>,
|
|
197
|
+
) => React.ReactElement;
|
|
198
|
+
};
|
|
199
|
+
export default InlineInput;
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@semcore/inline-input",
|
|
3
|
+
"description": "SEMRush Input Component",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "lib/cjs/index.js",
|
|
6
|
+
"module": "lib/es6/index.js",
|
|
7
|
+
"typings": "lib/types/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"author": "SEMRush UI-Kit team <ui-kit-team@semrush.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "build --source=js",
|
|
13
|
+
"test": "jest"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@semcore/flex-box": "^4.5.0",
|
|
17
|
+
"@semcore/icon": "^2.19.3",
|
|
18
|
+
"@semcore/spin": "^3.4.0",
|
|
19
|
+
"@semcore/tooltip": "^4.3.5",
|
|
20
|
+
"@semcore/utils": "^3.31.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@semcore/button": "^3.3.7",
|
|
24
|
+
"@semcore/jest-preset-ui": "1.0.0",
|
|
25
|
+
"@semcore/spin": "^3.4.1",
|
|
26
|
+
"@semcore/tooltip": "^4.3.5"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@semcore/core": "^1.11",
|
|
30
|
+
"react": "16.8 - 17"
|
|
31
|
+
},
|
|
32
|
+
"jest": {
|
|
33
|
+
"preset": "@semcore/jest-preset-ui"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/semrush/intergalactic.git",
|
|
38
|
+
"directory": "semcore/inline-input"
|
|
39
|
+
}
|
|
40
|
+
}
|