@semcore/inline-input 1.0.0 → 2.0.2
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/lib/cjs/InlineInput.js +150 -261
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/index.d.ts +163 -0
- package/lib/cjs/style/inline-input.shadow.css +5 -49
- package/lib/es6/InlineInput.js +156 -261
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/es6/index.d.ts +163 -0
- package/lib/es6/style/inline-input.shadow.css +5 -49
- package/lib/types/index.d.ts +65 -101
- package/package.json +1 -1
- package/src/InlineInput.tsx +146 -211
- package/src/index.d.ts +65 -101
- package/src/style/inline-input.shadow.css +5 -49
- package/yarn-error.log +0 -21221
package/lib/es6/InlineInput.js
CHANGED
|
@@ -6,7 +6,6 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
|
-
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
10
9
|
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
11
10
|
import { assignProps as _assignProps6 } from "@semcore/core";
|
|
12
11
|
import { assignProps as _assignProps5 } from "@semcore/core";
|
|
@@ -15,8 +14,6 @@ import { assignProps as _assignProps3 } from "@semcore/core";
|
|
|
15
14
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
16
15
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
17
16
|
|
|
18
|
-
var _this3 = this;
|
|
19
|
-
|
|
20
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
18
|
|
|
22
19
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -36,27 +33,19 @@ var style = (
|
|
|
36
33
|
/*__reshadow_css_start__*/
|
|
37
34
|
_sstyled.insert(
|
|
38
35
|
/*__inner_css_start__*/
|
|
39
|
-
".
|
|
36
|
+
".___SInlineInput_8s9nq_gg_{display:inline-flex;width:100%;height:100%;align-items:center;position:relative;z-index:0;vertical-align:middle;padding:1px;box-sizing:border-box;background-color:#fff}.___SInlineInput_8s9nq_gg_.__disabled_8s9nq_gg_{cursor:default;pointer-events:none;opacity:0.3}.___SValue_8s9nq_gg_{min-width:0;width:100%;height:100%;padding:4px;border:none;box-sizing:border-box;color:#333333;font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:transparent;min-height:1em}.___SValue_8s9nq_gg_:focus{outline:none}.___SValue_8s9nq_gg_::-moz-placeholder{color:#aaaaaa}.___SValue_8s9nq_gg_:-ms-input-placeholder{color:#aaaaaa}.___SValue_8s9nq_gg_::placeholder{color:#aaaaaa}.___SValue_8s9nq_gg_.__disabled_8s9nq_gg_{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.___SUnderline_8s9nq_gg_{display:flex;flex-direction:row;align-items:center;flex-grow:1;width:100%;height:100%;min-height:1em;border:1px solid transparent;border-bottom:1px solid #c4c7cf}.___SAddon_8s9nq_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:#a9abb6;padding:0 4px}.___SAddon_8s9nq_gg_.__disabled_8s9nq_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SInlineInput_8s9nq_gg_.__focused_8s9nq_gg_{z-index:1}.___SInlineInput_8s9nq_gg_.__focused_8s9nq_gg_ .___SUnderline_8s9nq_gg_{border-color:#008ff8;box-shadow:0 0 0 3px rgba(43, 148, 225, 0.3)}.___SInlineInput_8s9nq_gg_._state_valid_8s9nq_gg_ .___SUnderline_8s9nq_gg_{border-color:#59ddaa}.___SInlineInput_8s9nq_gg_._state_valid_8s9nq_gg_.__focused_8s9nq_gg_ .___SUnderline_8s9nq_gg_{border-color:#009f81;box-shadow:0px 0px 0px 3px rgba(0, 159, 129, 0.2)}.___SInlineInput_8s9nq_gg_._state_invalid_8s9nq_gg_ .___SUnderline_8s9nq_gg_{border-color:#ffaeb5}.___SInlineInput_8s9nq_gg_._state_invalid_8s9nq_gg_.__focused_8s9nq_gg_ .___SUnderline_8s9nq_gg_{border-color:#ff4953;box-shadow:0px 0px 0px 3px rgba(255, 73, 83, 0.2)}"
|
|
40
37
|
/*__inner_css_end__*/
|
|
41
|
-
, "
|
|
38
|
+
, "hj0ctv_gg_")
|
|
42
39
|
/*__reshadow_css_end__*/
|
|
43
40
|
, {
|
|
44
|
-
"__SInlineInput": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"__SAddon": "___SAddon_1yp60_gg_",
|
|
53
|
-
"_focused": "__focused_1yp60_gg_",
|
|
54
|
-
"_state_valid": "_state_valid_1yp60_gg_",
|
|
55
|
-
"--green-400": "--green-400_1aotv0j",
|
|
56
|
-
"_state_invalid": "_state_invalid_1yp60_gg_",
|
|
57
|
-
"--red-400": "--red-400_1aotv0j",
|
|
58
|
-
"_state_disabled": "_state_disabled_1yp60_gg_",
|
|
59
|
-
"__CloseM": "___CloseM_1yp60_gg_"
|
|
41
|
+
"__SInlineInput": "___SInlineInput_8s9nq_gg_",
|
|
42
|
+
"_disabled": "__disabled_8s9nq_gg_",
|
|
43
|
+
"__SValue": "___SValue_8s9nq_gg_",
|
|
44
|
+
"__SUnderline": "___SUnderline_8s9nq_gg_",
|
|
45
|
+
"__SAddon": "___SAddon_8s9nq_gg_",
|
|
46
|
+
"_focused": "__focused_8s9nq_gg_",
|
|
47
|
+
"_state_valid": "_state_valid_8s9nq_gg_",
|
|
48
|
+
"_state_invalid": "_state_invalid_8s9nq_gg_"
|
|
60
49
|
});
|
|
61
50
|
import CheckM from '@semcore/icon/Check/m';
|
|
62
51
|
import CloseM from '@semcore/icon/Close/m';
|
|
@@ -68,10 +57,10 @@ var isFocusOutsideOf = function isFocusOutsideOf(element) {
|
|
|
68
57
|
for (var i = 0; i < 1000000; i++) {
|
|
69
58
|
if (traversed === element) return false;
|
|
70
59
|
if (traversed === document.body) return true;
|
|
71
|
-
traversed = traversed
|
|
60
|
+
traversed = traversed?.parentElement;
|
|
72
61
|
}
|
|
73
62
|
|
|
74
|
-
throw new Error('Failed to traverse parents chain in utilite `isFocusOutsideOf` 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.');
|
|
63
|
+
throw new Error('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.');
|
|
75
64
|
};
|
|
76
65
|
|
|
77
66
|
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
@@ -79,202 +68,139 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
79
68
|
|
|
80
69
|
var _super = _createSuper(InlineInputBase);
|
|
81
70
|
|
|
82
|
-
function InlineInputBase(
|
|
71
|
+
function InlineInputBase() {
|
|
83
72
|
var _this;
|
|
84
73
|
|
|
85
74
|
_classCallCheck(this, InlineInputBase);
|
|
86
75
|
|
|
87
|
-
|
|
76
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
|
+
args[_key] = arguments[_key];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
88
81
|
|
|
89
82
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
90
83
|
focused: false
|
|
91
84
|
});
|
|
92
85
|
|
|
93
|
-
_defineProperty(_assertThisInitialized(_this), "rootRef",
|
|
86
|
+
_defineProperty(_assertThisInitialized(_this), "rootRef", React.createRef());
|
|
94
87
|
|
|
95
|
-
_defineProperty(_assertThisInitialized(_this), "inputRef",
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "inputRef", React.createRef());
|
|
96
89
|
|
|
97
90
|
_defineProperty(_assertThisInitialized(_this), "initValue", '');
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerValueFocused", function (focused) {
|
|
93
|
+
return function () {
|
|
94
|
+
_this.setState({
|
|
95
|
+
focused: focused
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function (event) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
_this.inputRef.current?.focus();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
_defineProperty(_assertThisInitialized(_this), "handleConfirm", function (text, event) {
|
|
106
|
+
_this.asProps.onConfirm?.(text, event);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
_defineProperty(_assertThisInitialized(_this), "handleCancel", function (prevText, event) {
|
|
110
|
+
_this.asProps.onCancel?.(prevText, event);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (event) {
|
|
114
|
+
var _this$asProps = _this.asProps,
|
|
115
|
+
onConfirm = _this$asProps.onConfirm,
|
|
116
|
+
onCancel = _this$asProps.onCancel,
|
|
117
|
+
onBlurBehavior = _this$asProps.onBlurBehavior;
|
|
118
|
+
|
|
119
|
+
if (onBlurBehavior) {
|
|
120
|
+
setTimeout(function () {
|
|
121
|
+
if (_this.rootRef.current && isFocusOutsideOf(_this.rootRef.current)) {
|
|
122
|
+
if (onBlurBehavior === 'confirm') onConfirm?.(_this.inputRef.current?.value ?? '', event);
|
|
123
|
+
if (onBlurBehavior === 'cancel') onCancel?.(_this.initValue, event);
|
|
124
|
+
}
|
|
125
|
+
}, 0);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
|
|
130
|
+
var _this$asProps2 = _this.asProps,
|
|
131
|
+
onConfirm = _this$asProps2.onConfirm,
|
|
132
|
+
onCancel = _this$asProps2.onCancel;
|
|
133
|
+
if (event.code === 'Enter') onConfirm?.(_this.inputRef.current?.value ?? '', event);
|
|
134
|
+
if (event.code === 'Escape') onCancel?.(_this.initValue, event);
|
|
135
|
+
});
|
|
136
|
+
|
|
104
137
|
return _this;
|
|
105
138
|
}
|
|
106
139
|
|
|
107
140
|
_createClass(InlineInputBase, [{
|
|
108
|
-
key: "uncontrolledProps",
|
|
109
|
-
value: function uncontrolledProps() {
|
|
110
|
-
return {
|
|
111
|
-
value: null
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
141
|
key: "componentDidMount",
|
|
116
142
|
value: function componentDidMount() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.initValue = ((_this$asProps$value = this.asProps.value) !== null && _this$asProps$value !== void 0 ? _this$asProps$value : this.asProps.defaultValue) || '';
|
|
143
|
+
this.initValue = this.inputRef.current?.value || '';
|
|
120
144
|
}
|
|
121
145
|
}, {
|
|
122
|
-
key: "
|
|
123
|
-
value: function
|
|
124
|
-
var _this$asProps = this.asProps,
|
|
125
|
-
loading = _this$asProps.loading,
|
|
126
|
-
value = _this$asProps.value,
|
|
127
|
-
defaultValue = _this$asProps.defaultValue,
|
|
128
|
-
state = _this$asProps.state,
|
|
129
|
-
_this$asProps$confirm = _this$asProps.confirmText,
|
|
130
|
-
confirmText = _this$asProps$confirm === void 0 ? 'Confirm' : _this$asProps$confirm,
|
|
131
|
-
_this$asProps$cancelT = _this$asProps.cancelText,
|
|
132
|
-
cancelText = _this$asProps$cancelT === void 0 ? 'Cancel' : _this$asProps$cancelT,
|
|
133
|
-
_this$asProps$tooltip = _this$asProps.tooltipsProps,
|
|
134
|
-
tooltipsProps = _this$asProps$tooltip === void 0 ? {} : _this$asProps$tooltip;
|
|
146
|
+
key: "getAddonProps",
|
|
147
|
+
value: function getAddonProps() {
|
|
135
148
|
return {
|
|
136
|
-
|
|
137
|
-
onConfirm: this.handleConfirm,
|
|
138
|
-
onCancel: this.handleCancel,
|
|
139
|
-
value: value,
|
|
140
|
-
defaultValue: defaultValue,
|
|
141
|
-
state: state,
|
|
142
|
-
confirmText: confirmText,
|
|
143
|
-
cancelText: cancelText,
|
|
144
|
-
tooltipsProps: tooltipsProps
|
|
149
|
+
onMouseDown: this.handleMouseDownAddon
|
|
145
150
|
};
|
|
146
151
|
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "geAddonProps",
|
|
149
|
-
value: function geAddonProps() {
|
|
150
|
-
return this.getContextProps();
|
|
151
|
-
}
|
|
152
152
|
}, {
|
|
153
153
|
key: "getConfirmControlProps",
|
|
154
154
|
value: function getConfirmControlProps() {
|
|
155
|
-
|
|
155
|
+
var loading = this.asProps.loading;
|
|
156
|
+
return {
|
|
157
|
+
value: this.inputRef.current?.value,
|
|
158
|
+
loading: loading,
|
|
159
|
+
onConfirm: this.handleConfirm
|
|
160
|
+
};
|
|
156
161
|
}
|
|
157
162
|
}, {
|
|
158
163
|
key: "getCancelControlProps",
|
|
159
164
|
value: function getCancelControlProps() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
var _this$asProps3 = this.asProps,
|
|
166
|
+
loading = _this$asProps3.loading,
|
|
167
|
+
disabled = _this$asProps3.disabled;
|
|
168
|
+
return {
|
|
169
|
+
value: this.initValue,
|
|
170
|
+
// because double disabled(root disabled and addon disabled)
|
|
171
|
+
disabled: loading && !disabled,
|
|
172
|
+
onCancel: this.handleCancel
|
|
173
|
+
};
|
|
166
174
|
}
|
|
167
175
|
}, {
|
|
168
176
|
key: "getValueProps",
|
|
169
177
|
value: function getValueProps() {
|
|
170
|
-
var
|
|
171
|
-
autoFocus = _this$asProps2.autoFocus,
|
|
172
|
-
value = _this$asProps2.value,
|
|
173
|
-
inputId = _this$asProps2.inputId,
|
|
174
|
-
defaultValue = _this$asProps2.defaultValue,
|
|
175
|
-
onChange = _this$asProps2.onChange,
|
|
176
|
-
state = _this$asProps2.state,
|
|
177
|
-
loading = _this$asProps2.loading,
|
|
178
|
-
placeholder = _this$asProps2.placeholder;
|
|
178
|
+
var state = this.asProps.state;
|
|
179
179
|
return {
|
|
180
180
|
ref: this.inputRef,
|
|
181
|
-
autoFocus: autoFocus,
|
|
182
|
-
value: value,
|
|
183
|
-
defaultValue: defaultValue,
|
|
184
|
-
onChange: onChange,
|
|
185
181
|
state: state,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
onKeyDown: this.handleKeyDown,
|
|
183
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
184
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
189
185
|
};
|
|
190
186
|
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "handleConfirm",
|
|
193
|
-
value: function handleConfirm(text, event) {
|
|
194
|
-
var onConfirm = this.asProps.onConfirm;
|
|
195
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(text, event);
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "handleCancel",
|
|
200
|
-
value: function handleCancel(prevText, event) {
|
|
201
|
-
var onCancel = this.asProps.onCancel;
|
|
202
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel(prevText, event);
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
}, {
|
|
206
|
-
key: "handleFocus",
|
|
207
|
-
value: function handleFocus(event) {
|
|
208
|
-
var onFocus = this.asProps.onFocus;
|
|
209
|
-
this.setState({
|
|
210
|
-
focused: true
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
if (onFocus) {
|
|
214
|
-
onFocus(event);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}, {
|
|
218
|
-
key: "handleBlur",
|
|
219
|
-
value: function handleBlur(event) {
|
|
220
|
-
var _this2 = this;
|
|
221
|
-
|
|
222
|
-
var _this$asProps3 = this.asProps,
|
|
223
|
-
onConfirm = _this$asProps3.onConfirm,
|
|
224
|
-
onCancel = _this$asProps3.onCancel,
|
|
225
|
-
onBlur = _this$asProps3.onBlur,
|
|
226
|
-
onBlurBehavior = _this$asProps3.onBlurBehavior,
|
|
227
|
-
value = _this$asProps3.value;
|
|
228
|
-
this.setState({
|
|
229
|
-
focused: false
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
if (onBlurBehavior) {
|
|
233
|
-
setTimeout(function () {
|
|
234
|
-
if (isFocusOutsideOf(_this2.rootRef.current)) {
|
|
235
|
-
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
236
|
-
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this2.initValue, event);
|
|
237
|
-
}
|
|
238
|
-
}, 0);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (onBlur) {
|
|
242
|
-
onBlur(event);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "handleKeyDown",
|
|
247
|
-
value: function handleKeyDown(event) {
|
|
248
|
-
var _this$asProps4 = this.asProps,
|
|
249
|
-
onConfirm = _this$asProps4.onConfirm,
|
|
250
|
-
onCancel = _this$asProps4.onCancel,
|
|
251
|
-
value = _this$asProps4.value;
|
|
252
|
-
if (event.code === 'Enter') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
253
|
-
if (event.code === 'Escape') onCancel === null || onCancel === void 0 ? void 0 : onCancel(this.initValue, event);
|
|
254
|
-
}
|
|
255
187
|
}, {
|
|
256
188
|
key: "render",
|
|
257
189
|
value: function render() {
|
|
258
|
-
var _ref = this
|
|
259
|
-
|
|
190
|
+
var _ref = this.asProps,
|
|
191
|
+
_ref6;
|
|
260
192
|
|
|
261
193
|
var SInlineInput = Box;
|
|
262
194
|
var SUnderline = 'div';
|
|
263
|
-
var _this$
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
styles = _this$asProps5.styles,
|
|
267
|
-
loading = _this$asProps5.loading;
|
|
268
|
-
var Children = hasChildren ? providedChildren : DefaultChildren;
|
|
195
|
+
var _this$asProps4 = this.asProps,
|
|
196
|
+
Children = _this$asProps4.Children,
|
|
197
|
+
styles = _this$asProps4.styles;
|
|
269
198
|
var focused = this.state.focused;
|
|
270
|
-
return
|
|
199
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref6.cn("SInlineInput", _objectSpread({}, _assignProps({
|
|
271
200
|
"ref": this.rootRef,
|
|
272
|
-
"onFocus": this.handleFocus,
|
|
273
|
-
"onBlur": this.handleBlur,
|
|
274
|
-
"onKeyDown": this.handleKeyDown,
|
|
275
201
|
"focused": focused,
|
|
276
|
-
"
|
|
277
|
-
}, _ref))), /*#__PURE__*/React.createElement(SUnderline,
|
|
202
|
+
"onBlur": this.handleBlur
|
|
203
|
+
}, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref6.cn("SUnderline", {}), /*#__PURE__*/React.createElement(Children, _ref6.cn("Children", {}))));
|
|
278
204
|
}
|
|
279
205
|
}]);
|
|
280
206
|
|
|
@@ -285,9 +211,7 @@ _defineProperty(InlineInputBase, "displayName", 'InlineInput');
|
|
|
285
211
|
|
|
286
212
|
_defineProperty(InlineInputBase, "defaultProps", {
|
|
287
213
|
state: 'normal',
|
|
288
|
-
|
|
289
|
-
defaultValue: '',
|
|
290
|
-
__excludeProps: ['defaultValue', 'placeholder', 'tooltipsProps', 'confirmText', 'cancelText', 'autoFocus', 'inputId']
|
|
214
|
+
onBlurBehavior: 'confirm'
|
|
291
215
|
});
|
|
292
216
|
|
|
293
217
|
_defineProperty(InlineInputBase, "style", style);
|
|
@@ -308,7 +232,6 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
308
232
|
value: function uncontrolledProps() {
|
|
309
233
|
return {
|
|
310
234
|
value: function value(event) {
|
|
311
|
-
event.stopPropagation();
|
|
312
235
|
return event.target.value;
|
|
313
236
|
}
|
|
314
237
|
};
|
|
@@ -316,14 +239,13 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
316
239
|
}, {
|
|
317
240
|
key: "render",
|
|
318
241
|
value: function render() {
|
|
319
|
-
var _ref2 = this
|
|
320
|
-
|
|
242
|
+
var _ref2 = this.asProps,
|
|
243
|
+
_ref7;
|
|
321
244
|
|
|
322
245
|
var SValue = Box;
|
|
323
|
-
return
|
|
246
|
+
return _ref7 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref7.cn("SValue", _objectSpread({}, _assignProps2({
|
|
324
247
|
"tag": "input",
|
|
325
|
-
"type": "text"
|
|
326
|
-
"disabled": this.asProps.state === 'disabled' || this.asProps.loading
|
|
248
|
+
"type": "text"
|
|
327
249
|
}, _ref2))));
|
|
328
250
|
}
|
|
329
251
|
}]);
|
|
@@ -337,139 +259,112 @@ _defineProperty(Value, "defaultProps", {
|
|
|
337
259
|
|
|
338
260
|
_defineProperty(Value, "enhance", [autoFocusEnhance()]);
|
|
339
261
|
|
|
262
|
+
_defineProperty(Value, "hoistProps", ['disabled']);
|
|
263
|
+
|
|
340
264
|
var Addon = function Addon(props) {
|
|
341
|
-
var _ref3 =
|
|
342
|
-
|
|
265
|
+
var _ref3 = arguments[0],
|
|
266
|
+
_ref8;
|
|
343
267
|
|
|
344
268
|
var SAddon = Box;
|
|
345
|
-
return
|
|
269
|
+
return _ref8 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
346
270
|
};
|
|
347
271
|
|
|
348
272
|
var ConfirmControl = function ConfirmControl(props) {
|
|
349
|
-
var _ref4 =
|
|
350
|
-
|
|
351
|
-
_props$value;
|
|
273
|
+
var _ref4 = arguments[0],
|
|
274
|
+
_ref10;
|
|
352
275
|
|
|
353
|
-
var
|
|
276
|
+
var SAddon = Box;
|
|
354
277
|
var Children = props.Children,
|
|
355
|
-
hasChildren = props.children
|
|
278
|
+
hasChildren = props.children,
|
|
279
|
+
title = props.title;
|
|
356
280
|
var handleConfirm = React.useCallback(function (event) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, props.value, event);
|
|
281
|
+
props.onConfirm?.(props.value ?? '', event);
|
|
360
282
|
}, [props.onConfirm, props.value]);
|
|
361
283
|
var handleKeydown = React.useCallback(function (event) {
|
|
362
|
-
if (props.loading) return;
|
|
363
|
-
|
|
364
284
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
365
285
|
event.preventDefault();
|
|
366
286
|
event.stopPropagation();
|
|
367
287
|
handleConfirm(event);
|
|
368
288
|
}
|
|
369
|
-
}, [
|
|
289
|
+
}, [handleConfirm]);
|
|
370
290
|
|
|
371
291
|
if (props.loading) {
|
|
372
|
-
var
|
|
292
|
+
var _ref9;
|
|
373
293
|
|
|
374
|
-
return
|
|
375
|
-
"
|
|
376
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref10.cn("Spin", {
|
|
377
|
-
"size": "xxs",
|
|
378
|
-
"className": "spin"
|
|
294
|
+
return _ref9 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, _assignProps4({}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref9.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref9.cn("Spin", {
|
|
295
|
+
"size": "xxs"
|
|
379
296
|
})));
|
|
380
297
|
}
|
|
381
298
|
|
|
382
|
-
return
|
|
299
|
+
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, _assignProps5({
|
|
383
300
|
"onKeyDown": handleKeydown
|
|
384
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
"
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
})
|
|
392
|
-
p:
|
|
393
|
-
}, props.
|
|
301
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref10.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
|
|
302
|
+
tag: props.icon ?? CheckM,
|
|
303
|
+
"aria-label": "".concat(title, " ").concat(props.value ?? ''),
|
|
304
|
+
role: "button",
|
|
305
|
+
interactive: true,
|
|
306
|
+
color: "green-300",
|
|
307
|
+
onClick: handleConfirm
|
|
308
|
+
}), /*#__PURE__*/React.createElement(Tooltip.Popper, {
|
|
309
|
+
p: 3
|
|
310
|
+
}, props.title)));
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
ConfirmControl.defaultProps = {
|
|
314
|
+
title: 'Confirm'
|
|
394
315
|
};
|
|
395
316
|
|
|
396
317
|
var CancelControl = function CancelControl(props) {
|
|
397
|
-
var _ref5 =
|
|
398
|
-
|
|
399
|
-
_props$value2;
|
|
318
|
+
var _ref5 = arguments[0],
|
|
319
|
+
_ref12;
|
|
400
320
|
|
|
401
|
-
var
|
|
321
|
+
var SAddon = Box;
|
|
402
322
|
var Children = props.Children,
|
|
403
|
-
hasChildren = props.children
|
|
404
|
-
|
|
323
|
+
hasChildren = props.children,
|
|
324
|
+
title = props.title;
|
|
405
325
|
var handleCancel = React.useCallback(function (event) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (props.loading || !props.onCancel) return;
|
|
409
|
-
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, initValue.current, event);
|
|
410
|
-
}, [props.loading, props.onCancel]);
|
|
326
|
+
props.onCancel?.(props.value ?? '', event);
|
|
327
|
+
}, [props.onCancel, props.value]);
|
|
411
328
|
var handleKeydown = React.useCallback(function (event) {
|
|
412
|
-
if (props.loading) return;
|
|
413
|
-
|
|
414
329
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
415
330
|
event.preventDefault();
|
|
416
331
|
event.stopPropagation();
|
|
417
332
|
handleCancel(event);
|
|
418
333
|
}
|
|
419
|
-
}, [
|
|
334
|
+
}, [handleCancel]);
|
|
420
335
|
|
|
421
|
-
if (props.
|
|
422
|
-
var
|
|
336
|
+
if (props.disabled) {
|
|
337
|
+
var _ref11;
|
|
423
338
|
|
|
424
|
-
return
|
|
425
|
-
"className": "controls-icon"
|
|
426
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref12.cn("CloseM", {
|
|
339
|
+
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, _assignProps6({}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref11.cn("CloseM", {
|
|
427
340
|
"disabled": true
|
|
428
341
|
})));
|
|
429
342
|
}
|
|
430
343
|
|
|
431
|
-
return
|
|
344
|
+
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, _assignProps7({
|
|
432
345
|
"onKeyDown": handleKeydown
|
|
433
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
"
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
})
|
|
441
|
-
p:
|
|
442
|
-
},
|
|
346
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref12.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
|
|
347
|
+
tag: props.icon ?? CloseM,
|
|
348
|
+
"aria-label": title,
|
|
349
|
+
role: "button",
|
|
350
|
+
interactive: true,
|
|
351
|
+
color: "gray-300",
|
|
352
|
+
onClick: handleCancel
|
|
353
|
+
}), /*#__PURE__*/React.createElement(Tooltip.Popper, {
|
|
354
|
+
p: 3
|
|
355
|
+
}, title)));
|
|
443
356
|
};
|
|
444
357
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
_ref14;
|
|
448
|
-
|
|
449
|
-
var SControls = Box;
|
|
450
|
-
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref14.cn("SControls", _objectSpread({}, _assignProps8({}, _ref6))), /*#__PURE__*/React.createElement(InlineInput.ConfirmControl, {
|
|
451
|
-
tooltipsProps: props.tooltipsProps,
|
|
452
|
-
confirmText: props.confirmText,
|
|
453
|
-
onConfirm: props.onConfirm
|
|
454
|
-
}), /*#__PURE__*/React.createElement(InlineInput.CancelControl, {
|
|
455
|
-
tooltipsProps: props.tooltipsProps,
|
|
456
|
-
cancelText: props.cancelText,
|
|
457
|
-
onCancel: props.onCancel
|
|
458
|
-
}));
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
var DefaultChildren = function DefaultChildren(props) {
|
|
462
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InlineInput.Value, props), /*#__PURE__*/React.createElement(InlineInput.Controls, null));
|
|
358
|
+
CancelControl.defaultProps = {
|
|
359
|
+
title: 'Cancel'
|
|
463
360
|
};
|
|
464
361
|
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
465
362
|
|
|
466
|
-
|
|
467
363
|
var InlineInput = createComponent(InlineInputBase, {
|
|
468
364
|
Addon: Addon,
|
|
469
365
|
Value: Value,
|
|
470
366
|
ConfirmControl: ConfirmControl,
|
|
471
|
-
CancelControl: CancelControl
|
|
472
|
-
Controls: Controls
|
|
367
|
+
CancelControl: CancelControl
|
|
473
368
|
});
|
|
474
369
|
export default InlineInput;
|
|
475
370
|
//# sourceMappingURL=InlineInput.js.map
|