@semcore/inline-input 1.0.0 → 2.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 +6 -0
- package/lib/cjs/InlineInput.js +168 -256
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/style/inline-input.shadow.css +5 -49
- package/lib/es6/InlineInput.js +174 -256
- package/lib/es6/InlineInput.js.map +1 -1
- 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,12 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [2.0.0] - 2022-04-07
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Changed `<InlineInput />` api to make it more consistent with other components.
|
|
10
|
+
|
|
5
11
|
## [1.0.0] - 2022-03-30
|
|
6
12
|
|
|
7
13
|
### 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,39 +56,33 @@ 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) {
|
|
85
75
|
var traversed = document.activeElement;
|
|
86
76
|
|
|
87
77
|
for (var i = 0; i < 1000000; i++) {
|
|
78
|
+
var _traversed;
|
|
79
|
+
|
|
88
80
|
if (traversed === element) return false;
|
|
89
81
|
if (traversed === document.body) return true;
|
|
90
|
-
traversed = traversed.parentElement;
|
|
82
|
+
traversed = (_traversed = traversed) === null || _traversed === void 0 ? void 0 : _traversed.parentElement;
|
|
91
83
|
}
|
|
92
84
|
|
|
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.');
|
|
85
|
+
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
86
|
};
|
|
95
87
|
|
|
96
88
|
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
@@ -98,196 +90,142 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
98
90
|
|
|
99
91
|
var _super = _createSuper(InlineInputBase);
|
|
100
92
|
|
|
101
|
-
function InlineInputBase(
|
|
93
|
+
function InlineInputBase() {
|
|
102
94
|
var _this;
|
|
103
95
|
|
|
104
96
|
(0, _classCallCheck2["default"])(this, InlineInputBase);
|
|
105
|
-
|
|
97
|
+
|
|
98
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
99
|
+
args[_key] = arguments[_key];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
106
103
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
107
104
|
focused: false
|
|
108
105
|
});
|
|
109
106
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rootRef", /*#__PURE__*/_react["default"].createRef());
|
|
110
107
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", /*#__PURE__*/_react["default"].createRef());
|
|
111
108
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "initValue", '');
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bindHandlerValueFocused", function (focused) {
|
|
110
|
+
return function () {
|
|
111
|
+
_this.setState({
|
|
112
|
+
focused: focused
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseDownAddon", function (event) {
|
|
117
|
+
var _this$inputRef$curren;
|
|
118
|
+
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
(_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
|
|
121
|
+
});
|
|
122
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleConfirm", function (text, event) {
|
|
123
|
+
var _this$asProps$onConfi, _this$asProps;
|
|
124
|
+
|
|
125
|
+
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 ? void 0 : _this$asProps$onConfi.call(_this$asProps, text, event);
|
|
126
|
+
});
|
|
127
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleCancel", function (prevText, event) {
|
|
128
|
+
var _this$asProps$onCance, _this$asProps2;
|
|
129
|
+
|
|
130
|
+
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 ? void 0 : _this$asProps$onCance.call(_this$asProps2, prevText, event);
|
|
131
|
+
});
|
|
132
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (event) {
|
|
133
|
+
var _this$asProps3 = _this.asProps,
|
|
134
|
+
onConfirm = _this$asProps3.onConfirm,
|
|
135
|
+
onCancel = _this$asProps3.onCancel,
|
|
136
|
+
onBlurBehavior = _this$asProps3.onBlurBehavior;
|
|
137
|
+
|
|
138
|
+
if (onBlurBehavior) {
|
|
139
|
+
setTimeout(function () {
|
|
140
|
+
if (_this.rootRef.current && isFocusOutsideOf(_this.rootRef.current)) {
|
|
141
|
+
var _this$inputRef$curren2, _this$inputRef$curren3;
|
|
142
|
+
|
|
143
|
+
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren2 = (_this$inputRef$curren3 = _this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.value) !== null && _this$inputRef$curren2 !== void 0 ? _this$inputRef$curren2 : '', event);
|
|
144
|
+
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
145
|
+
}
|
|
146
|
+
}, 0);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
|
|
150
|
+
var _this$inputRef$curren4, _this$inputRef$curren5;
|
|
151
|
+
|
|
152
|
+
var _this$asProps4 = _this.asProps,
|
|
153
|
+
onConfirm = _this$asProps4.onConfirm,
|
|
154
|
+
onCancel = _this$asProps4.onCancel;
|
|
155
|
+
if (event.code === 'Enter') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren4 = (_this$inputRef$curren5 = _this.inputRef.current) === null || _this$inputRef$curren5 === void 0 ? void 0 : _this$inputRef$curren5.value) !== null && _this$inputRef$curren4 !== void 0 ? _this$inputRef$curren4 : '', event);
|
|
156
|
+
if (event.code === 'Escape') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
157
|
+
});
|
|
117
158
|
return _this;
|
|
118
159
|
}
|
|
119
160
|
|
|
120
161
|
(0, _createClass2["default"])(InlineInputBase, [{
|
|
121
|
-
key: "uncontrolledProps",
|
|
122
|
-
value: function uncontrolledProps() {
|
|
123
|
-
return {
|
|
124
|
-
value: null
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
162
|
key: "componentDidMount",
|
|
129
163
|
value: function componentDidMount() {
|
|
130
|
-
var _this$
|
|
164
|
+
var _this$inputRef$curren6;
|
|
131
165
|
|
|
132
|
-
this.initValue = ((_this$
|
|
166
|
+
this.initValue = ((_this$inputRef$curren6 = this.inputRef.current) === null || _this$inputRef$curren6 === void 0 ? void 0 : _this$inputRef$curren6.value) || '';
|
|
133
167
|
}
|
|
134
168
|
}, {
|
|
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;
|
|
169
|
+
key: "getAddonProps",
|
|
170
|
+
value: function getAddonProps() {
|
|
148
171
|
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
|
|
172
|
+
onMouseDown: this.handleMouseDownAddon
|
|
158
173
|
};
|
|
159
174
|
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "geAddonProps",
|
|
162
|
-
value: function geAddonProps() {
|
|
163
|
-
return this.getContextProps();
|
|
164
|
-
}
|
|
165
175
|
}, {
|
|
166
176
|
key: "getConfirmControlProps",
|
|
167
177
|
value: function getConfirmControlProps() {
|
|
168
|
-
|
|
178
|
+
var _this$inputRef$curren7;
|
|
179
|
+
|
|
180
|
+
var loading = this.asProps.loading;
|
|
181
|
+
return {
|
|
182
|
+
value: (_this$inputRef$curren7 = this.inputRef.current) === null || _this$inputRef$curren7 === void 0 ? void 0 : _this$inputRef$curren7.value,
|
|
183
|
+
loading: loading,
|
|
184
|
+
onConfirm: this.handleConfirm
|
|
185
|
+
};
|
|
169
186
|
}
|
|
170
187
|
}, {
|
|
171
188
|
key: "getCancelControlProps",
|
|
172
189
|
value: function getCancelControlProps() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
190
|
+
var _this$asProps5 = this.asProps,
|
|
191
|
+
loading = _this$asProps5.loading,
|
|
192
|
+
disabled = _this$asProps5.disabled;
|
|
193
|
+
return {
|
|
194
|
+
value: this.initValue,
|
|
195
|
+
// because double disabled(root disabled and addon disabled)
|
|
196
|
+
disabled: loading && !disabled,
|
|
197
|
+
onCancel: this.handleCancel
|
|
198
|
+
};
|
|
179
199
|
}
|
|
180
200
|
}, {
|
|
181
201
|
key: "getValueProps",
|
|
182
202
|
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;
|
|
203
|
+
var state = this.asProps.state;
|
|
192
204
|
return {
|
|
193
205
|
ref: this.inputRef,
|
|
194
|
-
autoFocus: autoFocus,
|
|
195
|
-
value: value,
|
|
196
|
-
defaultValue: defaultValue,
|
|
197
|
-
onChange: onChange,
|
|
198
206
|
state: state,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
onKeyDown: this.handleKeyDown,
|
|
208
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
209
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
202
210
|
};
|
|
203
211
|
}
|
|
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
212
|
}, {
|
|
269
213
|
key: "render",
|
|
270
214
|
value: function render() {
|
|
271
|
-
var _ref = this
|
|
272
|
-
|
|
215
|
+
var _ref = this.asProps,
|
|
216
|
+
_ref6;
|
|
273
217
|
|
|
274
218
|
var SInlineInput = _flexBox.Box;
|
|
275
219
|
var SUnderline = 'div';
|
|
276
|
-
var _this$
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
styles = _this$asProps5.styles,
|
|
280
|
-
loading = _this$asProps5.loading;
|
|
281
|
-
var Children = hasChildren ? providedChildren : DefaultChildren;
|
|
220
|
+
var _this$asProps6 = this.asProps,
|
|
221
|
+
Children = _this$asProps6.Children,
|
|
222
|
+
styles = _this$asProps6.styles;
|
|
282
223
|
var focused = this.state.focused;
|
|
283
|
-
return
|
|
224
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInlineInput, _ref6.cn("SInlineInput", _objectSpread({}, (0, _core.assignProps)({
|
|
284
225
|
"ref": this.rootRef,
|
|
285
|
-
"onFocus": this.handleFocus,
|
|
286
|
-
"onBlur": this.handleBlur,
|
|
287
|
-
"onKeyDown": this.handleKeyDown,
|
|
288
226
|
"focused": focused,
|
|
289
|
-
"
|
|
290
|
-
}, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline,
|
|
227
|
+
"onBlur": this.handleBlur
|
|
228
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(SUnderline, _ref6.cn("SUnderline", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref6.cn("Children", {}))));
|
|
291
229
|
}
|
|
292
230
|
}]);
|
|
293
231
|
return InlineInputBase;
|
|
@@ -296,9 +234,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
296
234
|
(0, _defineProperty2["default"])(InlineInputBase, "displayName", 'InlineInput');
|
|
297
235
|
(0, _defineProperty2["default"])(InlineInputBase, "defaultProps", {
|
|
298
236
|
state: 'normal',
|
|
299
|
-
|
|
300
|
-
defaultValue: '',
|
|
301
|
-
__excludeProps: ['defaultValue', 'placeholder', 'tooltipsProps', 'confirmText', 'cancelText', 'autoFocus', 'inputId']
|
|
237
|
+
onBlurBehavior: 'confirm'
|
|
302
238
|
});
|
|
303
239
|
(0, _defineProperty2["default"])(InlineInputBase, "style", style);
|
|
304
240
|
|
|
@@ -317,7 +253,6 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
317
253
|
value: function uncontrolledProps() {
|
|
318
254
|
return {
|
|
319
255
|
value: function value(event) {
|
|
320
|
-
event.stopPropagation();
|
|
321
256
|
return event.target.value;
|
|
322
257
|
}
|
|
323
258
|
};
|
|
@@ -325,14 +260,13 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
325
260
|
}, {
|
|
326
261
|
key: "render",
|
|
327
262
|
value: function render() {
|
|
328
|
-
var _ref2 = this
|
|
329
|
-
|
|
263
|
+
var _ref2 = this.asProps,
|
|
264
|
+
_ref7;
|
|
330
265
|
|
|
331
266
|
var SValue = _flexBox.Box;
|
|
332
|
-
return
|
|
267
|
+
return _ref7 = (0, _core.sstyled)(this.asProps.styles), /*#__PURE__*/_react["default"].createElement(SValue, _ref7.cn("SValue", _objectSpread({}, (0, _core.assignProps)({
|
|
333
268
|
"tag": "input",
|
|
334
|
-
"type": "text"
|
|
335
|
-
"disabled": this.asProps.state === 'disabled' || this.asProps.loading
|
|
269
|
+
"type": "text"
|
|
336
270
|
}, _ref2))));
|
|
337
271
|
}
|
|
338
272
|
}]);
|
|
@@ -343,145 +277,123 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
343
277
|
defaultValue: ''
|
|
344
278
|
});
|
|
345
279
|
(0, _defineProperty2["default"])(Value, "enhance", [(0, _autoFocusEnhance["default"])()]);
|
|
280
|
+
(0, _defineProperty2["default"])(Value, "hoistProps", ['disabled']);
|
|
346
281
|
|
|
347
282
|
var Addon = function Addon(props) {
|
|
348
|
-
var _ref3 =
|
|
349
|
-
|
|
283
|
+
var _ref3 = arguments[0],
|
|
284
|
+
_ref8;
|
|
350
285
|
|
|
351
286
|
var SAddon = _flexBox.Box;
|
|
352
|
-
return
|
|
287
|
+
return _ref8 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({}, _ref3))));
|
|
353
288
|
};
|
|
354
289
|
|
|
355
290
|
var ConfirmControl = function ConfirmControl(props) {
|
|
356
|
-
var _ref4 =
|
|
357
|
-
|
|
358
|
-
_props$
|
|
291
|
+
var _ref4 = arguments[0],
|
|
292
|
+
_ref10,
|
|
293
|
+
_props$icon,
|
|
294
|
+
_props$value2;
|
|
359
295
|
|
|
360
|
-
var
|
|
296
|
+
var SAddon = _flexBox.Box;
|
|
361
297
|
var Children = props.Children,
|
|
362
|
-
hasChildren = props.children
|
|
298
|
+
hasChildren = props.children,
|
|
299
|
+
title = props.title;
|
|
363
300
|
|
|
364
301
|
var handleConfirm = _react["default"].useCallback(function (event) {
|
|
365
|
-
var _props$onConfirm;
|
|
302
|
+
var _props$onConfirm, _props$value;
|
|
366
303
|
|
|
367
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, props.value, event);
|
|
304
|
+
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : '', event);
|
|
368
305
|
}, [props.onConfirm, props.value]);
|
|
369
306
|
|
|
370
307
|
var handleKeydown = _react["default"].useCallback(function (event) {
|
|
371
|
-
if (props.loading) return;
|
|
372
|
-
|
|
373
308
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
374
309
|
event.preventDefault();
|
|
375
310
|
event.stopPropagation();
|
|
376
311
|
handleConfirm(event);
|
|
377
312
|
}
|
|
378
|
-
}, [
|
|
313
|
+
}, [handleConfirm]);
|
|
379
314
|
|
|
380
315
|
if (props.loading) {
|
|
381
|
-
var
|
|
316
|
+
var _ref9;
|
|
382
317
|
|
|
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"
|
|
318
|
+
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", {
|
|
319
|
+
"size": "xxs"
|
|
388
320
|
})));
|
|
389
321
|
}
|
|
390
322
|
|
|
391
|
-
return
|
|
323
|
+
return _ref10 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({
|
|
392
324
|
"onKeyDown": handleKeydown
|
|
393
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
})
|
|
401
|
-
p:
|
|
402
|
-
}, props.
|
|
325
|
+
}, _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, {
|
|
326
|
+
tag: (_props$icon = props.icon) !== null && _props$icon !== void 0 ? _props$icon : _m["default"],
|
|
327
|
+
"aria-label": "".concat(title, " ").concat((_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : ''),
|
|
328
|
+
role: "button",
|
|
329
|
+
interactive: true,
|
|
330
|
+
color: "green-300",
|
|
331
|
+
onClick: handleConfirm
|
|
332
|
+
}), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Popper, {
|
|
333
|
+
p: 3
|
|
334
|
+
}, props.title)));
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
ConfirmControl.defaultProps = {
|
|
338
|
+
title: 'Confirm'
|
|
403
339
|
};
|
|
404
340
|
|
|
405
341
|
var CancelControl = function CancelControl(props) {
|
|
406
|
-
var _ref5 =
|
|
407
|
-
|
|
408
|
-
_props$
|
|
342
|
+
var _ref5 = arguments[0],
|
|
343
|
+
_ref12,
|
|
344
|
+
_props$icon2;
|
|
409
345
|
|
|
410
|
-
var
|
|
346
|
+
var SAddon = _flexBox.Box;
|
|
411
347
|
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);
|
|
348
|
+
hasChildren = props.children,
|
|
349
|
+
title = props.title;
|
|
415
350
|
|
|
416
351
|
var handleCancel = _react["default"].useCallback(function (event) {
|
|
417
|
-
var _props$onCancel;
|
|
352
|
+
var _props$onCancel, _props$value3;
|
|
418
353
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}, [props.loading, props.onCancel]);
|
|
354
|
+
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, (_props$value3 = props.value) !== null && _props$value3 !== void 0 ? _props$value3 : '', event);
|
|
355
|
+
}, [props.onCancel, props.value]);
|
|
422
356
|
|
|
423
357
|
var handleKeydown = _react["default"].useCallback(function (event) {
|
|
424
|
-
if (props.loading) return;
|
|
425
|
-
|
|
426
358
|
if (event.code === 'Enter' || event.code === 'Space') {
|
|
427
359
|
event.preventDefault();
|
|
428
360
|
event.stopPropagation();
|
|
429
361
|
handleCancel(event);
|
|
430
362
|
}
|
|
431
|
-
}, [
|
|
363
|
+
}, [handleCancel]);
|
|
432
364
|
|
|
433
|
-
if (props.
|
|
434
|
-
var
|
|
365
|
+
if (props.disabled) {
|
|
366
|
+
var _ref11;
|
|
435
367
|
|
|
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", {
|
|
368
|
+
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
369
|
"disabled": true
|
|
440
370
|
})));
|
|
441
371
|
}
|
|
442
372
|
|
|
443
|
-
return
|
|
373
|
+
return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, (0, _core.assignProps)({
|
|
444
374
|
"onKeyDown": handleKeydown
|
|
445
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/_react["default"].createElement(Children,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
"
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
})
|
|
453
|
-
p:
|
|
454
|
-
},
|
|
375
|
+
}, _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, {
|
|
376
|
+
tag: (_props$icon2 = props.icon) !== null && _props$icon2 !== void 0 ? _props$icon2 : _m2["default"],
|
|
377
|
+
"aria-label": title,
|
|
378
|
+
role: "button",
|
|
379
|
+
interactive: true,
|
|
380
|
+
color: "gray-300",
|
|
381
|
+
onClick: handleCancel
|
|
382
|
+
}), /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Popper, {
|
|
383
|
+
p: 3
|
|
384
|
+
}, title)));
|
|
455
385
|
};
|
|
456
386
|
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
}));
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
var DefaultChildren = function DefaultChildren(props) {
|
|
474
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(InlineInput.Value, props), /*#__PURE__*/_react["default"].createElement(InlineInput.Controls, null));
|
|
387
|
+
CancelControl.defaultProps = {
|
|
388
|
+
title: 'Cancel'
|
|
475
389
|
};
|
|
476
390
|
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
477
391
|
|
|
478
|
-
|
|
479
392
|
var InlineInput = (0, _core["default"])(InlineInputBase, {
|
|
480
393
|
Addon: Addon,
|
|
481
394
|
Value: Value,
|
|
482
395
|
ConfirmControl: ConfirmControl,
|
|
483
|
-
CancelControl: CancelControl
|
|
484
|
-
Controls: Controls
|
|
396
|
+
CancelControl: CancelControl
|
|
485
397
|
});
|
|
486
398
|
var _default = InlineInput;
|
|
487
399
|
exports["default"] = _default;
|