@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.
@@ -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
- ".___SInlineInput_1yp60_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}.___SControls_1yp60_gg_{display:flex;flex-direction:row;flex-shrink:0}.___SConfirmControl_1yp60_gg_{color:#00c192;cursor:pointer}.___SConfirmControl_1yp60_gg_:hover{color:#009f81}.___SCancelControl_1yp60_gg_{color:#a9abb6;cursor:pointer}.___SCancelControl_1yp60_gg_:hover{color:#8a8e9b}.___SValue_1yp60_gg_{min-width:0;width:100%;height:100%;padding:0 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_1yp60_gg_:focus{outline:none}.___SValue_1yp60_gg_::placeholder{color:#aaaaaa}.___SValue_1yp60_gg_.__disabled_1yp60_gg_,.___SValue_1yp60_gg_.__loading_1yp60_gg_{opacity:0.3}.___SValue_1yp60_gg_.__disabled_1yp60_gg_{user-select:none}.___SValue_1yp60_gg_.__disabled_1yp60_gg_~.___SUnderline_1yp60_gg_{cursor:default;pointer-events:none}.___SUnderline_1yp60_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_1yp60_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:#a9abb6;padding:0 4px}.___SAddon_1yp60_gg_.__disabled_1yp60_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SInlineInput_1yp60_gg_.__focused_1yp60_gg_{z-index:1}.___SInlineInput_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#008ff8;box-shadow:0 0 0 3px rgba(43, 148, 225, 0.3)}.___SInlineInput_1yp60_gg_._state_valid_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#59ddaa}.___SInlineInput_1yp60_gg_._state_valid_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#009f81;box-shadow:0px 0px 0px 3px color-mod(var(--green-400_1aotv0j), a(20%))}.___SInlineInput_1yp60_gg_._state_invalid_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#ffaeb5}.___SInlineInput_1yp60_gg_._state_invalid_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#ff4953;box-shadow:0px 0px 0px 3px color-mod(var(--red-400_1aotv0j), a(20%))}.___SInlineInput_1yp60_gg_.__loading_1yp60_gg_,.___SInlineInput_1yp60_gg_._state_disabled_1yp60_gg_{cursor:default}.___CloseM_1yp60_gg_.__disabled_1yp60_gg_{cursor:default;opacity:0.3}.controls-icon{display:flex;align-items:center}.spin{min-width:16px;cursor:default}"
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
- , "1aotv0j_gg_")
38
+ , "hj0ctv_gg_")
42
39
  /*__reshadow_css_end__*/
43
40
  , {
44
- "__SInlineInput": "___SInlineInput_1yp60_gg_",
45
- "__SControls": "___SControls_1yp60_gg_",
46
- "__SConfirmControl": "___SConfirmControl_1yp60_gg_",
47
- "__SCancelControl": "___SCancelControl_1yp60_gg_",
48
- "__SValue": "___SValue_1yp60_gg_",
49
- "_disabled": "__disabled_1yp60_gg_",
50
- "_loading": "__loading_1yp60_gg_",
51
- "__SUnderline": "___SUnderline_1yp60_gg_",
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';
@@ -66,12 +55,14 @@ var isFocusOutsideOf = function isFocusOutsideOf(element) {
66
55
  var traversed = document.activeElement;
67
56
 
68
57
  for (var i = 0; i < 1000000; i++) {
58
+ var _traversed;
59
+
69
60
  if (traversed === element) return false;
70
61
  if (traversed === document.body) return true;
71
- traversed = traversed.parentElement;
62
+ traversed = (_traversed = traversed) === null || _traversed === void 0 ? void 0 : _traversed.parentElement;
72
63
  }
73
64
 
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.');
65
+ 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
66
  };
76
67
 
77
68
  var InlineInputBase = /*#__PURE__*/function (_Component) {
@@ -79,12 +70,16 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
79
70
 
80
71
  var _super = _createSuper(InlineInputBase);
81
72
 
82
- function InlineInputBase(props) {
73
+ function InlineInputBase() {
83
74
  var _this;
84
75
 
85
76
  _classCallCheck(this, InlineInputBase);
86
77
 
87
- _this = _super.call(this, props);
78
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
79
+ args[_key] = arguments[_key];
80
+ }
81
+
82
+ _this = _super.call.apply(_super, [this].concat(args));
88
83
 
89
84
  _defineProperty(_assertThisInitialized(_this), "state", {
90
85
  focused: false
@@ -96,185 +91,132 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
96
91
 
97
92
  _defineProperty(_assertThisInitialized(_this), "initValue", '');
98
93
 
99
- _this.handleConfirm = _this.handleConfirm.bind(_assertThisInitialized(_this));
100
- _this.handleCancel = _this.handleCancel.bind(_assertThisInitialized(_this));
101
- _this.handleFocus = _this.handleFocus.bind(_assertThisInitialized(_this));
102
- _this.handleBlur = _this.handleBlur.bind(_assertThisInitialized(_this));
103
- _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
94
+ _defineProperty(_assertThisInitialized(_this), "bindHandlerValueFocused", function (focused) {
95
+ return function () {
96
+ _this.setState({
97
+ focused: focused
98
+ });
99
+ };
100
+ });
101
+
102
+ _defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function (event) {
103
+ var _this$inputRef$curren;
104
+
105
+ event.preventDefault();
106
+ (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
107
+ });
108
+
109
+ _defineProperty(_assertThisInitialized(_this), "handleConfirm", function (text, event) {
110
+ var _this$asProps$onConfi, _this$asProps;
111
+
112
+ (_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 ? void 0 : _this$asProps$onConfi.call(_this$asProps, text, event);
113
+ });
114
+
115
+ _defineProperty(_assertThisInitialized(_this), "handleCancel", function (prevText, event) {
116
+ var _this$asProps$onCance, _this$asProps2;
117
+
118
+ (_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 ? void 0 : _this$asProps$onCance.call(_this$asProps2, prevText, event);
119
+ });
120
+
121
+ _defineProperty(_assertThisInitialized(_this), "handleBlur", function (event) {
122
+ var _this$asProps3 = _this.asProps,
123
+ onConfirm = _this$asProps3.onConfirm,
124
+ onCancel = _this$asProps3.onCancel,
125
+ onBlurBehavior = _this$asProps3.onBlurBehavior;
126
+
127
+ if (onBlurBehavior) {
128
+ setTimeout(function () {
129
+ if (_this.rootRef.current && isFocusOutsideOf(_this.rootRef.current)) {
130
+ var _this$inputRef$curren2, _this$inputRef$curren3;
131
+
132
+ 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);
133
+ if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
134
+ }
135
+ }, 0);
136
+ }
137
+ });
138
+
139
+ _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
140
+ var _this$inputRef$curren4, _this$inputRef$curren5;
141
+
142
+ var _this$asProps4 = _this.asProps,
143
+ onConfirm = _this$asProps4.onConfirm,
144
+ onCancel = _this$asProps4.onCancel;
145
+ 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);
146
+ if (event.code === 'Escape') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
147
+ });
148
+
104
149
  return _this;
105
150
  }
106
151
 
107
152
  _createClass(InlineInputBase, [{
108
- key: "uncontrolledProps",
109
- value: function uncontrolledProps() {
110
- return {
111
- value: null
112
- };
113
- }
114
- }, {
115
153
  key: "componentDidMount",
116
154
  value: function componentDidMount() {
117
- var _this$asProps$value;
155
+ var _this$inputRef$curren6;
118
156
 
119
- this.initValue = ((_this$asProps$value = this.asProps.value) !== null && _this$asProps$value !== void 0 ? _this$asProps$value : this.asProps.defaultValue) || '';
157
+ this.initValue = ((_this$inputRef$curren6 = this.inputRef.current) === null || _this$inputRef$curren6 === void 0 ? void 0 : _this$inputRef$curren6.value) || '';
120
158
  }
121
159
  }, {
122
- key: "getContextProps",
123
- value: function getContextProps() {
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;
160
+ key: "getAddonProps",
161
+ value: function getAddonProps() {
135
162
  return {
136
- loading: loading,
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
163
+ onMouseDown: this.handleMouseDownAddon
145
164
  };
146
165
  }
147
- }, {
148
- key: "geAddonProps",
149
- value: function geAddonProps() {
150
- return this.getContextProps();
151
- }
152
166
  }, {
153
167
  key: "getConfirmControlProps",
154
168
  value: function getConfirmControlProps() {
155
- return this.getContextProps();
169
+ var _this$inputRef$curren7;
170
+
171
+ var loading = this.asProps.loading;
172
+ return {
173
+ value: (_this$inputRef$curren7 = this.inputRef.current) === null || _this$inputRef$curren7 === void 0 ? void 0 : _this$inputRef$curren7.value,
174
+ loading: loading,
175
+ onConfirm: this.handleConfirm
176
+ };
156
177
  }
157
178
  }, {
158
179
  key: "getCancelControlProps",
159
180
  value: function getCancelControlProps() {
160
- return this.getContextProps();
161
- }
162
- }, {
163
- key: "getControlsProps",
164
- value: function getControlsProps() {
165
- return this.getContextProps();
181
+ var _this$asProps5 = this.asProps,
182
+ loading = _this$asProps5.loading,
183
+ disabled = _this$asProps5.disabled;
184
+ return {
185
+ value: this.initValue,
186
+ // because double disabled(root disabled and addon disabled)
187
+ disabled: loading && !disabled,
188
+ onCancel: this.handleCancel
189
+ };
166
190
  }
167
191
  }, {
168
192
  key: "getValueProps",
169
193
  value: function getValueProps() {
170
- var _this$asProps2 = this.asProps,
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;
194
+ var state = this.asProps.state;
179
195
  return {
180
196
  ref: this.inputRef,
181
- autoFocus: autoFocus,
182
- value: value,
183
- defaultValue: defaultValue,
184
- onChange: onChange,
185
197
  state: state,
186
- loading: loading,
187
- placeholder: placeholder,
188
- id: inputId
198
+ onKeyDown: this.handleKeyDown,
199
+ onFocus: this.bindHandlerValueFocused(true),
200
+ onBlur: this.bindHandlerValueFocused(false)
189
201
  };
190
202
  }
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
203
  }, {
256
204
  key: "render",
257
205
  value: function render() {
258
- var _ref = this ? this.asProps : arguments[0],
259
- _ref7;
206
+ var _ref = this.asProps,
207
+ _ref6;
260
208
 
261
209
  var SInlineInput = Box;
262
210
  var SUnderline = 'div';
263
- var _this$asProps5 = this.asProps,
264
- providedChildren = _this$asProps5.Children,
265
- hasChildren = _this$asProps5.children,
266
- styles = _this$asProps5.styles,
267
- loading = _this$asProps5.loading;
268
- var Children = hasChildren ? providedChildren : DefaultChildren;
211
+ var _this$asProps6 = this.asProps,
212
+ Children = _this$asProps6.Children,
213
+ styles = _this$asProps6.styles;
269
214
  var focused = this.state.focused;
270
- return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref7.cn("SInlineInput", _objectSpread({}, _assignProps({
215
+ return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref6.cn("SInlineInput", _objectSpread({}, _assignProps({
271
216
  "ref": this.rootRef,
272
- "onFocus": this.handleFocus,
273
- "onBlur": this.handleBlur,
274
- "onKeyDown": this.handleKeyDown,
275
217
  "focused": focused,
276
- "loading": loading
277
- }, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref7.cn("SUnderline", {}), /*#__PURE__*/React.createElement(Children, _ref7.cn("Children", {}))));
218
+ "onBlur": this.handleBlur
219
+ }, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref6.cn("SUnderline", {}), /*#__PURE__*/React.createElement(Children, _ref6.cn("Children", {}))));
278
220
  }
279
221
  }]);
280
222
 
@@ -285,9 +227,7 @@ _defineProperty(InlineInputBase, "displayName", 'InlineInput');
285
227
 
286
228
  _defineProperty(InlineInputBase, "defaultProps", {
287
229
  state: 'normal',
288
- loading: false,
289
- defaultValue: '',
290
- __excludeProps: ['defaultValue', 'placeholder', 'tooltipsProps', 'confirmText', 'cancelText', 'autoFocus', 'inputId']
230
+ onBlurBehavior: 'confirm'
291
231
  });
292
232
 
293
233
  _defineProperty(InlineInputBase, "style", style);
@@ -308,7 +248,6 @@ var Value = /*#__PURE__*/function (_Component2) {
308
248
  value: function uncontrolledProps() {
309
249
  return {
310
250
  value: function value(event) {
311
- event.stopPropagation();
312
251
  return event.target.value;
313
252
  }
314
253
  };
@@ -316,14 +255,13 @@ var Value = /*#__PURE__*/function (_Component2) {
316
255
  }, {
317
256
  key: "render",
318
257
  value: function render() {
319
- var _ref2 = this ? this.asProps : arguments[0],
320
- _ref8;
258
+ var _ref2 = this.asProps,
259
+ _ref7;
321
260
 
322
261
  var SValue = Box;
323
- return _ref8 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref8.cn("SValue", _objectSpread({}, _assignProps2({
262
+ return _ref7 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref7.cn("SValue", _objectSpread({}, _assignProps2({
324
263
  "tag": "input",
325
- "type": "text",
326
- "disabled": this.asProps.state === 'disabled' || this.asProps.loading
264
+ "type": "text"
327
265
  }, _ref2))));
328
266
  }
329
267
  }]);
@@ -337,139 +275,119 @@ _defineProperty(Value, "defaultProps", {
337
275
 
338
276
  _defineProperty(Value, "enhance", [autoFocusEnhance()]);
339
277
 
278
+ _defineProperty(Value, "hoistProps", ['disabled']);
279
+
340
280
  var Addon = function Addon(props) {
341
- var _ref3 = _this3 ? _this3.asProps : arguments[0],
342
- _ref9;
281
+ var _ref3 = arguments[0],
282
+ _ref8;
343
283
 
344
284
  var SAddon = Box;
345
- return _ref9 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
285
+ return _ref8 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
346
286
  };
347
287
 
348
288
  var ConfirmControl = function ConfirmControl(props) {
349
- var _ref4 = _this3 ? _this3.asProps : arguments[0],
350
- _ref11,
351
- _props$value;
289
+ var _ref4 = arguments[0],
290
+ _ref10,
291
+ _props$icon,
292
+ _props$value2;
352
293
 
353
- var SConfirmControl = Box;
294
+ var SAddon = Box;
354
295
  var Children = props.Children,
355
- hasChildren = props.children;
296
+ hasChildren = props.children,
297
+ title = props.title;
356
298
  var handleConfirm = React.useCallback(function (event) {
357
- var _props$onConfirm;
299
+ var _props$onConfirm, _props$value;
358
300
 
359
- (_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, props.value, event);
301
+ (_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);
360
302
  }, [props.onConfirm, props.value]);
361
303
  var handleKeydown = React.useCallback(function (event) {
362
- if (props.loading) return;
363
-
364
304
  if (event.code === 'Enter' || event.code === 'Space') {
365
305
  event.preventDefault();
366
306
  event.stopPropagation();
367
307
  handleConfirm(event);
368
308
  }
369
- }, [props.loading, handleConfirm]);
309
+ }, [handleConfirm]);
370
310
 
371
311
  if (props.loading) {
372
- var _ref10;
312
+ var _ref9;
373
313
 
374
- return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SConfirmControl, _ref10.cn("SConfirmControl", _objectSpread({}, _assignProps4({
375
- "className": "controls-icon"
376
- }, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref10.cn("Spin", {
377
- "size": "xxs",
378
- "className": "spin"
314
+ 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", {
315
+ "size": "xxs"
379
316
  })));
380
317
  }
381
318
 
382
- return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SConfirmControl, _ref11.cn("SConfirmControl", _objectSpread({}, _assignProps5({
319
+ return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, _assignProps5({
383
320
  "onKeyDown": handleKeydown
384
- }, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref11.cn("Tooltip", _objectSpread({}, props.tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
385
- className: "controls-icon"
386
- }, /*#__PURE__*/React.createElement(CheckM, _ref11.cn("CheckM", {
387
- "tabIndex": 0,
388
- "aria-label": "".concat(props.confirmText, " ").concat((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : ''),
389
- "role": "button",
390
- "onClick": handleConfirm
391
- }))), /*#__PURE__*/React.createElement(Tooltip.Popper, {
392
- p: 2
393
- }, props.confirmText)));
321
+ }, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref10.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
322
+ tag: (_props$icon = props.icon) !== null && _props$icon !== void 0 ? _props$icon : CheckM,
323
+ "aria-label": "".concat(title, " ").concat((_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : ''),
324
+ role: "button",
325
+ interactive: true,
326
+ color: "green-300",
327
+ onClick: handleConfirm
328
+ }), /*#__PURE__*/React.createElement(Tooltip.Popper, {
329
+ p: 3
330
+ }, props.title)));
331
+ };
332
+
333
+ ConfirmControl.defaultProps = {
334
+ title: 'Confirm'
394
335
  };
395
336
 
396
337
  var CancelControl = function CancelControl(props) {
397
- var _ref5 = _this3 ? _this3.asProps : arguments[0],
398
- _ref13,
399
- _props$value2;
338
+ var _ref5 = arguments[0],
339
+ _ref12,
340
+ _props$icon2;
400
341
 
401
- var SCancelControl = Box;
342
+ var SAddon = Box;
402
343
  var Children = props.Children,
403
- hasChildren = props.children;
404
- var initValue = React.useRef((_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : props.defaultValue);
344
+ hasChildren = props.children,
345
+ title = props.title;
405
346
  var handleCancel = React.useCallback(function (event) {
406
- var _props$onCancel;
347
+ var _props$onCancel, _props$value3;
407
348
 
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]);
349
+ (_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);
350
+ }, [props.onCancel, props.value]);
411
351
  var handleKeydown = React.useCallback(function (event) {
412
- if (props.loading) return;
413
-
414
352
  if (event.code === 'Enter' || event.code === 'Space') {
415
353
  event.preventDefault();
416
354
  event.stopPropagation();
417
355
  handleCancel(event);
418
356
  }
419
- }, [props.loading, handleCancel]);
357
+ }, [handleCancel]);
420
358
 
421
- if (props.loading) {
422
- var _ref12;
359
+ if (props.disabled) {
360
+ var _ref11;
423
361
 
424
- return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SCancelControl, _ref12.cn("SCancelControl", _objectSpread({}, _assignProps6({
425
- "className": "controls-icon"
426
- }, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref12.cn("CloseM", {
362
+ 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
363
  "disabled": true
428
364
  })));
429
365
  }
430
366
 
431
- return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SCancelControl, _ref13.cn("SCancelControl", _objectSpread({}, _assignProps7({
367
+ return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, _assignProps7({
432
368
  "onKeyDown": handleKeydown
433
- }, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref13.cn("Tooltip", _objectSpread({}, props.tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
434
- className: "controls-icon"
435
- }, /*#__PURE__*/React.createElement(CloseM, _ref13.cn("CloseM", {
436
- "tabIndex": 0,
437
- "aria-label": props.cancelText,
438
- "role": "button",
439
- "onClick": handleCancel
440
- }))), /*#__PURE__*/React.createElement(Tooltip.Popper, {
441
- p: 2
442
- }, props.cancelText)));
369
+ }, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref12.cn("Tooltip", _objectSpread({}, props.$tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
370
+ tag: (_props$icon2 = props.icon) !== null && _props$icon2 !== void 0 ? _props$icon2 : CloseM,
371
+ "aria-label": title,
372
+ role: "button",
373
+ interactive: true,
374
+ color: "gray-300",
375
+ onClick: handleCancel
376
+ }), /*#__PURE__*/React.createElement(Tooltip.Popper, {
377
+ p: 3
378
+ }, title)));
443
379
  };
444
380
 
445
- var Controls = function Controls(props) {
446
- var _ref6 = _this3 ? _this3.asProps : arguments[0],
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));
381
+ CancelControl.defaultProps = {
382
+ title: 'Cancel'
463
383
  };
464
384
  /** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
465
385
 
466
-
467
386
  var InlineInput = createComponent(InlineInputBase, {
468
387
  Addon: Addon,
469
388
  Value: Value,
470
389
  ConfirmControl: ConfirmControl,
471
- CancelControl: CancelControl,
472
- Controls: Controls
390
+ CancelControl: CancelControl
473
391
  });
474
392
  export default InlineInput;
475
393
  //# sourceMappingURL=InlineInput.js.map