@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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [2.0.2] - 2022-05-16
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/icon` [2.21.0 ~> 2.24.0]).
|
|
10
|
+
|
|
11
|
+
## [2.0.1] - 2022-04-28
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Version patch update due to children dependencies update (`@semcore/icon` [2.20.0 ~> 2.21.0]).
|
|
16
|
+
|
|
17
|
+
## [2.0.0] - 2022-04-07
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Changed `<InlineInput />` api to make it more consistent with other components.
|
|
22
|
+
|
|
5
23
|
## [1.0.0] - 2022-03-30
|
|
6
24
|
|
|
7
25
|
### Added
|
package/lib/cjs/InlineInput.js
CHANGED
|
@@ -39,8 +39,6 @@ var _m2 = _interopRequireDefault(require("@semcore/icon/Close/m"));
|
|
|
39
39
|
|
|
40
40
|
var _spin = _interopRequireDefault(require("@semcore/spin"));
|
|
41
41
|
|
|
42
|
-
var _this3 = void 0;
|
|
43
|
-
|
|
44
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
43
|
|
|
46
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -58,27 +56,19 @@ var style = (
|
|
|
58
56
|
/*__reshadow_css_start__*/
|
|
59
57
|
_core.sstyled.insert(
|
|
60
58
|
/*__inner_css_start__*/
|
|
61
|
-
".
|
|
59
|
+
".___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)}"
|
|
62
60
|
/*__inner_css_end__*/
|
|
63
|
-
, "
|
|
61
|
+
, "hj0ctv_gg_")
|
|
64
62
|
/*__reshadow_css_end__*/
|
|
65
63
|
, {
|
|
66
|
-
"__SInlineInput": "
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"__SAddon": "___SAddon_1yp60_gg_",
|
|
75
|
-
"_focused": "__focused_1yp60_gg_",
|
|
76
|
-
"_state_valid": "_state_valid_1yp60_gg_",
|
|
77
|
-
"--green-400": "--green-400_1aotv0j",
|
|
78
|
-
"_state_invalid": "_state_invalid_1yp60_gg_",
|
|
79
|
-
"--red-400": "--red-400_1aotv0j",
|
|
80
|
-
"_state_disabled": "_state_disabled_1yp60_gg_",
|
|
81
|
-
"__CloseM": "___CloseM_1yp60_gg_"
|
|
64
|
+
"__SInlineInput": "___SInlineInput_8s9nq_gg_",
|
|
65
|
+
"_disabled": "__disabled_8s9nq_gg_",
|
|
66
|
+
"__SValue": "___SValue_8s9nq_gg_",
|
|
67
|
+
"__SUnderline": "___SUnderline_8s9nq_gg_",
|
|
68
|
+
"__SAddon": "___SAddon_8s9nq_gg_",
|
|
69
|
+
"_focused": "__focused_8s9nq_gg_",
|
|
70
|
+
"_state_valid": "_state_valid_8s9nq_gg_",
|
|
71
|
+
"_state_invalid": "_state_invalid_8s9nq_gg_"
|
|
82
72
|
});
|
|
83
73
|
|
|
84
74
|
var isFocusOutsideOf = function isFocusOutsideOf(element) {
|
|
@@ -87,10 +77,10 @@ var isFocusOutsideOf = function isFocusOutsideOf(element) {
|
|
|
87
77
|
for (var i = 0; i < 1000000; i++) {
|
|
88
78
|
if (traversed === element) return false;
|
|
89
79
|
if (traversed === document.body) return true;
|
|
90
|
-
traversed = traversed
|
|
80
|
+
traversed = traversed?.parentElement;
|
|
91
81
|
}
|
|
92
82
|
|
|
93
|
-
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.');
|
|
83
|
+
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.');
|
|
94
84
|
};
|
|
95
85
|
|
|
96
86
|
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
@@ -98,196 +88,128 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
98
88
|
|
|
99
89
|
var _super = _createSuper(InlineInputBase);
|
|
100
90
|
|
|
101
|
-
function InlineInputBase(
|
|
91
|
+
function InlineInputBase() {
|
|
102
92
|
var _this;
|
|
103
93
|
|
|
104
94
|
(0, _classCallCheck2["default"])(this, InlineInputBase);
|
|
105
|
-
|
|
95
|
+
|
|
96
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
97
|
+
args[_key] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
106
101
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
107
102
|
focused: false
|
|
108
103
|
});
|
|
109
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rootRef",
|
|
110
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef",
|
|
104
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rootRef", _react["default"].createRef());
|
|
105
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", _react["default"].createRef());
|
|
111
106
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "initValue", '');
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bindHandlerValueFocused", function (focused) {
|
|
108
|
+
return function () {
|
|
109
|
+
_this.setState({
|
|
110
|
+
focused: focused
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseDownAddon", function (event) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
_this.inputRef.current?.focus();
|
|
117
|
+
});
|
|
118
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleConfirm", function (text, event) {
|
|
119
|
+
_this.asProps.onConfirm?.(text, event);
|
|
120
|
+
});
|
|
121
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleCancel", function (prevText, event) {
|
|
122
|
+
_this.asProps.onCancel?.(prevText, event);
|
|
123
|
+
});
|
|
124
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (event) {
|
|
125
|
+
var _this$asProps = _this.asProps,
|
|
126
|
+
onConfirm = _this$asProps.onConfirm,
|
|
127
|
+
onCancel = _this$asProps.onCancel,
|
|
128
|
+
onBlurBehavior = _this$asProps.onBlurBehavior;
|
|
129
|
+
|
|
130
|
+
if (onBlurBehavior) {
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
if (_this.rootRef.current && isFocusOutsideOf(_this.rootRef.current)) {
|
|
133
|
+
if (onBlurBehavior === 'confirm') onConfirm?.(_this.inputRef.current?.value ?? '', event);
|
|
134
|
+
if (onBlurBehavior === 'cancel') onCancel?.(_this.initValue, event);
|
|
135
|
+
}
|
|
136
|
+
}, 0);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
|
|
140
|
+
var _this$asProps2 = _this.asProps,
|
|
141
|
+
onConfirm = _this$asProps2.onConfirm,
|
|
142
|
+
onCancel = _this$asProps2.onCancel;
|
|
143
|
+
if (event.code === 'Enter') onConfirm?.(_this.inputRef.current?.value ?? '', event);
|
|
144
|
+
if (event.code === 'Escape') onCancel?.(_this.initValue, event);
|
|
145
|
+
});
|
|
117
146
|
return _this;
|
|
118
147
|
}
|
|
119
148
|
|
|
120
149
|
(0, _createClass2["default"])(InlineInputBase, [{
|
|
121
|
-
key: "uncontrolledProps",
|
|
122
|
-
value: function uncontrolledProps() {
|
|
123
|
-
return {
|
|
124
|
-
value: null
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
150
|
key: "componentDidMount",
|
|
129
151
|
value: function componentDidMount() {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.initValue = ((_this$asProps$value = this.asProps.value) !== null && _this$asProps$value !== void 0 ? _this$asProps$value : this.asProps.defaultValue) || '';
|
|
152
|
+
this.initValue = this.inputRef.current?.value || '';
|
|
133
153
|
}
|
|
134
154
|
}, {
|
|
135
|
-
key: "
|
|
136
|
-
value: function
|
|
137
|
-
var _this$asProps = this.asProps,
|
|
138
|
-
loading = _this$asProps.loading,
|
|
139
|
-
value = _this$asProps.value,
|
|
140
|
-
defaultValue = _this$asProps.defaultValue,
|
|
141
|
-
state = _this$asProps.state,
|
|
142
|
-
_this$asProps$confirm = _this$asProps.confirmText,
|
|
143
|
-
confirmText = _this$asProps$confirm === void 0 ? 'Confirm' : _this$asProps$confirm,
|
|
144
|
-
_this$asProps$cancelT = _this$asProps.cancelText,
|
|
145
|
-
cancelText = _this$asProps$cancelT === void 0 ? 'Cancel' : _this$asProps$cancelT,
|
|
146
|
-
_this$asProps$tooltip = _this$asProps.tooltipsProps,
|
|
147
|
-
tooltipsProps = _this$asProps$tooltip === void 0 ? {} : _this$asProps$tooltip;
|
|
155
|
+
key: "getAddonProps",
|
|
156
|
+
value: function getAddonProps() {
|
|
148
157
|
return {
|
|
149
|
-
|
|
150
|
-
onConfirm: this.handleConfirm,
|
|
151
|
-
onCancel: this.handleCancel,
|
|
152
|
-
value: value,
|
|
153
|
-
defaultValue: defaultValue,
|
|
154
|
-
state: state,
|
|
155
|
-
confirmText: confirmText,
|
|
156
|
-
cancelText: cancelText,
|
|
157
|
-
tooltipsProps: tooltipsProps
|
|
158
|
+
onMouseDown: this.handleMouseDownAddon
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "geAddonProps",
|
|
162
|
-
value: function geAddonProps() {
|
|
163
|
-
return this.getContextProps();
|
|
164
|
-
}
|
|
165
161
|
}, {
|
|
166
162
|
key: "getConfirmControlProps",
|
|
167
163
|
value: function getConfirmControlProps() {
|
|
168
|
-
|
|
164
|
+
var loading = this.asProps.loading;
|
|
165
|
+
return {
|
|
166
|
+
value: this.inputRef.current?.value,
|
|
167
|
+
loading: loading,
|
|
168
|
+
onConfirm: this.handleConfirm
|
|
169
|
+
};
|
|
169
170
|
}
|
|
170
171
|
}, {
|
|
171
172
|
key: "getCancelControlProps",
|
|
172
173
|
value: function getCancelControlProps() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
var _this$asProps3 = this.asProps,
|
|
175
|
+
loading = _this$asProps3.loading,
|
|
176
|
+
disabled = _this$asProps3.disabled;
|
|
177
|
+
return {
|
|
178
|
+
value: this.initValue,
|
|
179
|
+
// because double disabled(root disabled and addon disabled)
|
|
180
|
+
disabled: loading && !disabled,
|
|
181
|
+
onCancel: this.handleCancel
|
|
182
|
+
};
|
|
179
183
|
}
|
|
180
184
|
}, {
|
|
181
185
|
key: "getValueProps",
|
|
182
186
|
value: function getValueProps() {
|
|
183
|
-
var
|
|
184
|
-
autoFocus = _this$asProps2.autoFocus,
|
|
185
|
-
value = _this$asProps2.value,
|
|
186
|
-
inputId = _this$asProps2.inputId,
|
|
187
|
-
defaultValue = _this$asProps2.defaultValue,
|
|
188
|
-
onChange = _this$asProps2.onChange,
|
|
189
|
-
state = _this$asProps2.state,
|
|
190
|
-
loading = _this$asProps2.loading,
|
|
191
|
-
placeholder = _this$asProps2.placeholder;
|
|
187
|
+
var state = this.asProps.state;
|
|
192
188
|
return {
|
|
193
189
|
ref: this.inputRef,
|
|
194
|
-
autoFocus: autoFocus,
|
|
195
|
-
value: value,
|
|
196
|
-
defaultValue: defaultValue,
|
|
197
|
-
onChange: onChange,
|
|
198
190
|
state: state,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
onKeyDown: this.handleKeyDown,
|
|
192
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
193
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
202
194
|
};
|
|
203
195
|
}
|
|
204
|
-
}, {
|
|
205
|
-
key: "handleConfirm",
|
|
206
|
-
value: function handleConfirm(text, event) {
|
|
207
|
-
var onConfirm = this.asProps.onConfirm;
|
|
208
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(text, event);
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
}, {
|
|
212
|
-
key: "handleCancel",
|
|
213
|
-
value: function handleCancel(prevText, event) {
|
|
214
|
-
var onCancel = this.asProps.onCancel;
|
|
215
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel(prevText, event);
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
}, {
|
|
219
|
-
key: "handleFocus",
|
|
220
|
-
value: function handleFocus(event) {
|
|
221
|
-
var onFocus = this.asProps.onFocus;
|
|
222
|
-
this.setState({
|
|
223
|
-
focused: true
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
if (onFocus) {
|
|
227
|
-
onFocus(event);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
key: "handleBlur",
|
|
232
|
-
value: function handleBlur(event) {
|
|
233
|
-
var _this2 = this;
|
|
234
|
-
|
|
235
|
-
var _this$asProps3 = this.asProps,
|
|
236
|
-
onConfirm = _this$asProps3.onConfirm,
|
|
237
|
-
onCancel = _this$asProps3.onCancel,
|
|
238
|
-
onBlur = _this$asProps3.onBlur,
|
|
239
|
-
onBlurBehavior = _this$asProps3.onBlurBehavior,
|
|
240
|
-
value = _this$asProps3.value;
|
|
241
|
-
this.setState({
|
|
242
|
-
focused: false
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
if (onBlurBehavior) {
|
|
246
|
-
setTimeout(function () {
|
|
247
|
-
if (isFocusOutsideOf(_this2.rootRef.current)) {
|
|
248
|
-
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
249
|
-
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this2.initValue, event);
|
|
250
|
-
}
|
|
251
|
-
}, 0);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (onBlur) {
|
|
255
|
-
onBlur(event);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}, {
|
|
259
|
-
key: "handleKeyDown",
|
|
260
|
-
value: function handleKeyDown(event) {
|
|
261
|
-
var _this$asProps4 = this.asProps,
|
|
262
|
-
onConfirm = _this$asProps4.onConfirm,
|
|
263
|
-
onCancel = _this$asProps4.onCancel,
|
|
264
|
-
value = _this$asProps4.value;
|
|
265
|
-
if (event.code === 'Enter') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
266
|
-
if (event.code === 'Escape') onCancel === null || onCancel === void 0 ? void 0 : onCancel(this.initValue, event);
|
|
267
|
-
}
|
|
268
196
|
}, {
|
|
269
197
|
key: "render",
|
|
270
198
|
value: function render() {
|
|
271
|
-
var _ref = this
|
|
272
|
-
|
|
199
|
+
var _ref = this.asProps,
|
|
200
|
+
_ref6;
|
|
273
201
|
|
|
274
202
|
var SInlineInput = _flexBox.Box;
|
|
275
203
|
var SUnderline = 'div';
|
|
276
|
-
var _this$
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
styles = _this$asProps5.styles,
|
|
280
|
-
loading = _this$asProps5.loading;
|
|
281
|
-
var Children = hasChildren ? providedChildren : DefaultChildren;
|
|
204
|
+
var _this$asProps4 = this.asProps,
|
|
205
|
+
Children = _this$asProps4.Children,
|
|
206
|
+
styles = _this$asProps4.styles;
|
|
282
207
|
var focused = this.state.focused;
|
|
283
|
-
return
|
|
208
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInlineInput, _ref6.cn("SInlineInput", _objectSpread({}, (0, _core.assignProps)({
|
|
284
209
|
"ref": this.rootRef,
|
|
285
|
-
"onFocus": this.handleFocus,
|
|
286
|
-
"onBlur": this.handleBlur,
|
|
287
|
-
"onKeyDown": this.handleKeyDown,
|
|
288
210
|
"focused": focused,
|
|
289
|
-
"
|
|
290
|
-
}, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline,
|
|
211
|
+
"onBlur": this.handleBlur
|
|
212
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline, _ref6.cn("SUnderline", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref6.cn("Children", {}))));
|
|
291
213
|
}
|
|
292
214
|
}]);
|
|
293
215
|
return InlineInputBase;
|
|
@@ -296,9 +218,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
296
218
|
(0, _defineProperty2["default"])(InlineInputBase, "displayName", 'InlineInput');
|
|
297
219
|
(0, _defineProperty2["default"])(InlineInputBase, "defaultProps", {
|
|
298
220
|
state: 'normal',
|
|
299
|
-
|
|
300
|
-
defaultValue: '',
|
|
301
|
-
__excludeProps: ['defaultValue', 'placeholder', 'tooltipsProps', 'confirmText', 'cancelText', 'autoFocus', 'inputId']
|
|
221
|
+
onBlurBehavior: 'confirm'
|
|
302
222
|
});
|
|
303
223
|
(0, _defineProperty2["default"])(InlineInputBase, "style", style);
|
|
304
224
|
|
|
@@ -317,7 +237,6 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
317
237
|
value: function uncontrolledProps() {
|
|
318
238
|
return {
|
|
319
239
|
value: function value(event) {
|
|
320
|
-
event.stopPropagation();
|
|
321
240
|
return event.target.value;
|
|
322
241
|
}
|
|
323
242
|
};
|
|
@@ -325,14 +244,13 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
325
244
|
}, {
|
|
326
245
|
key: "render",
|
|
327
246
|
value: function render() {
|
|
328
|
-
var _ref2 = this
|
|
329
|
-
|
|
247
|
+
var _ref2 = this.asProps,
|
|
248
|
+
_ref7;
|
|
330
249
|
|
|
331
250
|
var SValue = _flexBox.Box;
|
|
332
|
-
return
|
|
251
|
+
return _ref7 = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SValue, _ref7.cn("SValue", _objectSpread({}, (0, _core.assignProps)({
|
|
333
252
|
"tag": "input",
|
|
334
|
-
"type": "text"
|
|
335
|
-
"disabled": this.asProps.state === 'disabled' || this.asProps.loading
|
|
253
|
+
"type": "text"
|
|
336
254
|
}, _ref2))));
|
|
337
255
|
}
|
|
338
256
|
}]);
|
|
@@ -343,145 +261,116 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
343
261
|
defaultValue: ''
|
|
344
262
|
});
|
|
345
263
|
(0, _defineProperty2["default"])(Value, "enhance", [(0, _autoFocusEnhance["default"])()]);
|
|
264
|
+
(0, _defineProperty2["default"])(Value, "hoistProps", ['disabled']);
|
|
346
265
|
|
|
347
266
|
var Addon = function Addon(props) {
|
|
348
|
-
var _ref3 =
|
|
349
|
-
|
|
267
|
+
var _ref3 = arguments[0],
|
|
268
|
+
_ref8;
|
|
350
269
|
|
|
351
270
|
var SAddon = _flexBox.Box;
|
|
352
|
-
return
|
|
271
|
+
return _ref8 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({}, _ref3))));
|
|
353
272
|
};
|
|
354
273
|
|
|
355
274
|
var ConfirmControl = function ConfirmControl(props) {
|
|
356
|
-
var _ref4 =
|
|
357
|
-
|
|
358
|
-
_props$value;
|
|
275
|
+
var _ref4 = arguments[0],
|
|
276
|
+
_ref10;
|
|
359
277
|
|
|
360
|
-
var
|
|
278
|
+
var SAddon = _flexBox.Box;
|
|
361
279
|
var Children = props.Children,
|
|
362
|
-
hasChildren = props.children
|
|
280
|
+
hasChildren = props.children,
|
|
281
|
+
title = props.title;
|
|
363
282
|
|
|
364
283
|
var handleConfirm = _react["default"].useCallback(function (event) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, props.value, event);
|
|
284
|
+
props.onConfirm?.(props.value ?? '', event);
|
|
368
285
|
}, [props.onConfirm, props.value]);
|
|
369
286
|
|
|
370
287
|
var handleKeydown = _react["default"].useCallback(function (event) {
|
|
371
|
-
if (props.loading) return;
|
|
372
|
-
|
|
373
288
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
374
289
|
event.preventDefault();
|
|
375
290
|
event.stopPropagation();
|
|
376
291
|
handleConfirm(event);
|
|
377
292
|
}
|
|
378
|
-
}, [
|
|
293
|
+
}, [handleConfirm]);
|
|
379
294
|
|
|
380
295
|
if (props.loading) {
|
|
381
|
-
var
|
|
296
|
+
var _ref9;
|
|
382
297
|
|
|
383
|
-
return
|
|
384
|
-
"
|
|
385
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_spin["default"], _ref10.cn("Spin", {
|
|
386
|
-
"size": "xxs",
|
|
387
|
-
"className": "spin"
|
|
298
|
+
return _ref9 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref9.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_spin["default"], _ref9.cn("Spin", {
|
|
299
|
+
"size": "xxs"
|
|
388
300
|
})));
|
|
389
301
|
}
|
|
390
302
|
|
|
391
|
-
return
|
|
303
|
+
return _ref10 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({
|
|
392
304
|
"onKeyDown": handleKeydown
|
|
393
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
})
|
|
401
|
-
p:
|
|
402
|
-
}, props.
|
|
305
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref10.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
|
|
306
|
+
tag: props.icon ?? _m["default"],
|
|
307
|
+
"aria-label": "".concat(title, " ").concat(props.value ?? ''),
|
|
308
|
+
role: "button",
|
|
309
|
+
interactive: true,
|
|
310
|
+
color: "green-300",
|
|
311
|
+
onClick: handleConfirm
|
|
312
|
+
}), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Popper, {
|
|
313
|
+
p: 3
|
|
314
|
+
}, props.title)));
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
ConfirmControl.defaultProps = {
|
|
318
|
+
title: 'Confirm'
|
|
403
319
|
};
|
|
404
320
|
|
|
405
321
|
var CancelControl = function CancelControl(props) {
|
|
406
|
-
var _ref5 =
|
|
407
|
-
|
|
408
|
-
_props$value2;
|
|
322
|
+
var _ref5 = arguments[0],
|
|
323
|
+
_ref12;
|
|
409
324
|
|
|
410
|
-
var
|
|
325
|
+
var SAddon = _flexBox.Box;
|
|
411
326
|
var Children = props.Children,
|
|
412
|
-
hasChildren = props.children
|
|
413
|
-
|
|
414
|
-
var initValue = _react["default"].useRef((_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : props.defaultValue);
|
|
327
|
+
hasChildren = props.children,
|
|
328
|
+
title = props.title;
|
|
415
329
|
|
|
416
330
|
var handleCancel = _react["default"].useCallback(function (event) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
if (props.loading || !props.onCancel) return;
|
|
420
|
-
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, initValue.current, event);
|
|
421
|
-
}, [props.loading, props.onCancel]);
|
|
331
|
+
props.onCancel?.(props.value ?? '', event);
|
|
332
|
+
}, [props.onCancel, props.value]);
|
|
422
333
|
|
|
423
334
|
var handleKeydown = _react["default"].useCallback(function (event) {
|
|
424
|
-
if (props.loading) return;
|
|
425
|
-
|
|
426
335
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
427
336
|
event.preventDefault();
|
|
428
337
|
event.stopPropagation();
|
|
429
338
|
handleCancel(event);
|
|
430
339
|
}
|
|
431
|
-
}, [
|
|
340
|
+
}, [handleCancel]);
|
|
432
341
|
|
|
433
|
-
if (props.
|
|
434
|
-
var
|
|
342
|
+
if (props.disabled) {
|
|
343
|
+
var _ref11;
|
|
435
344
|
|
|
436
|
-
return
|
|
437
|
-
"className": "controls-icon"
|
|
438
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_m2["default"], _ref12.cn("CloseM", {
|
|
345
|
+
return _ref11 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_m2["default"], _ref11.cn("CloseM", {
|
|
439
346
|
"disabled": true
|
|
440
347
|
})));
|
|
441
348
|
}
|
|
442
349
|
|
|
443
|
-
return
|
|
350
|
+
return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({
|
|
444
351
|
"onKeyDown": handleKeydown
|
|
445
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
"
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
})
|
|
453
|
-
p:
|
|
454
|
-
},
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
var Controls = function Controls(props) {
|
|
458
|
-
var _ref6 = _this3 ? _this3.asProps : arguments[0],
|
|
459
|
-
_ref14;
|
|
460
|
-
|
|
461
|
-
var SControls = _flexBox.Box;
|
|
462
|
-
return _ref14 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SControls, _ref14.cn("SControls", _objectSpread({}, (0, _core.assignProps)({}, _ref6))), /*#__PURE__*/_react["default"].createElement(InlineInput.ConfirmControl, {
|
|
463
|
-
tooltipsProps: props.tooltipsProps,
|
|
464
|
-
confirmText: props.confirmText,
|
|
465
|
-
onConfirm: props.onConfirm
|
|
466
|
-
}), /*#__PURE__*/_react["default"].createElement(InlineInput.CancelControl, {
|
|
467
|
-
tooltipsProps: props.tooltipsProps,
|
|
468
|
-
cancelText: props.cancelText,
|
|
469
|
-
onCancel: props.onCancel
|
|
470
|
-
}));
|
|
352
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(_tooltip["default"], _ref12.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Trigger, {
|
|
353
|
+
tag: props.icon ?? _m2["default"],
|
|
354
|
+
"aria-label": title,
|
|
355
|
+
role: "button",
|
|
356
|
+
interactive: true,
|
|
357
|
+
color: "gray-300",
|
|
358
|
+
onClick: handleCancel
|
|
359
|
+
}), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Popper, {
|
|
360
|
+
p: 3
|
|
361
|
+
}, title)));
|
|
471
362
|
};
|
|
472
363
|
|
|
473
|
-
|
|
474
|
-
|
|
364
|
+
CancelControl.defaultProps = {
|
|
365
|
+
title: 'Cancel'
|
|
475
366
|
};
|
|
476
367
|
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
477
368
|
|
|
478
|
-
|
|
479
369
|
var InlineInput = (0, _core["default"])(InlineInputBase, {
|
|
480
370
|
Addon: Addon,
|
|
481
371
|
Value: Value,
|
|
482
372
|
ConfirmControl: ConfirmControl,
|
|
483
|
-
CancelControl: CancelControl
|
|
484
|
-
Controls: Controls
|
|
373
|
+
CancelControl: CancelControl
|
|
485
374
|
});
|
|
486
375
|
var _default = InlineInput;
|
|
487
376
|
exports["default"] = _default;
|