@semcore/inline-input 4.48.0 → 4.48.1
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 +17 -15
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/es6/InlineInput.js +17 -15
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/esm/InlineInput.mjs +296 -217
- package/lib/esm/index.mjs +2 -2
- package/lib/esm/style/inline-input.shadow.css +145 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
- package/lib/esm/translations/de.json.mjs +8 -6
- package/lib/esm/translations/en.json.mjs +8 -6
- package/lib/esm/translations/es.json.mjs +8 -6
- package/lib/esm/translations/fr.json.mjs +8 -6
- package/lib/esm/translations/it.json.mjs +8 -6
- package/lib/esm/translations/ja.json.mjs +8 -6
- package/lib/esm/translations/ko.json.mjs +8 -6
- package/lib/esm/translations/nl.json.mjs +8 -6
- package/lib/esm/translations/pl.json.mjs +8 -6
- package/lib/esm/translations/pt.json.mjs +8 -6
- package/lib/esm/translations/sv.json.mjs +8 -6
- package/lib/esm/translations/tr.json.mjs +8 -6
- package/lib/esm/translations/vi.json.mjs +8 -6
- package/lib/esm/translations/zh.json.mjs +8 -6
- package/package.json +10 -10
package/lib/esm/InlineInput.mjs
CHANGED
|
@@ -1,305 +1,384 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { sstyled
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Box
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { ButtonLink
|
|
17
|
-
import { localizedMessages
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { hasParent
|
|
21
|
-
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
9
|
+
import createComponent, { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Box, InvalidStateBox } from "@semcore/flex-box";
|
|
12
|
+
import autoFocusEnhance from "@semcore/utils/lib/enhances/autoFocusEnhance";
|
|
13
|
+
import CheckM from "@semcore/icon/Check/m";
|
|
14
|
+
import CloseM from "@semcore/icon/Close/m";
|
|
15
|
+
import Spin from "@semcore/spin";
|
|
16
|
+
import { ButtonLink } from "@semcore/button";
|
|
17
|
+
import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
18
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
19
|
+
import InputNumber from "@semcore/input-number";
|
|
20
|
+
import { hasParent } from "@semcore/utils/lib/hasParent";
|
|
21
|
+
/*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
22
|
+
var style = (
|
|
22
23
|
/*__reshadow_css_start__*/
|
|
23
|
-
(
|
|
24
|
+
(sstyled.insert(
|
|
24
25
|
/*__inner_css_start__*/
|
|
25
|
-
".
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
".___SInlineInput_58kzi_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:var(--intergalactic-bg-primary-neutral, #ffffff)}.___SInlineInput_58kzi_gg_ .___SConfirmIcon_58kzi_gg_{color:var(--intergalactic-icon-secondary-success, #00c192);cursor:pointer}@media (hover:hover){.___SInlineInput_58kzi_gg_ .___SConfirmIcon_58kzi_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, #049B75)}}.___SInlineInput_58kzi_gg_ .___SCancelIcon_58kzi_gg_{color:var(--intergalactic-icon-secondary-neutral, #a9abb6);cursor:pointer}@media (hover:hover){.___SInlineInput_58kzi_gg_ .___SCancelIcon_58kzi_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SInlineInput_58kzi_gg_.__disabled_58kzi_gg_{cursor:default;pointer-events:none;opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SValue_58kzi_gg_{min-width:0;width:100%;height:100%;padding:0 var(--intergalactic-spacing-1x, 4px);border:0;box-sizing:border-box;color:var(--intergalactic-text-primary, #191b23);font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:0 0;min-height:1em}.___SValue_58kzi_gg_:focus{outline:0}.___SValue_58kzi_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_58kzi_gg_::placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SValue_58kzi_gg_.__disabled_58kzi_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SValue_58kzi_gg_::-webkit-inner-spin-button,.___SValue_58kzi_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_58kzi_gg_._type_number_58kzi_gg_{-moz-appearance:textfield}.___SUnderline_58kzi_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 var(--intergalactic-border-primary, #c4c7cf)}.___SAddon_58kzi_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:var(--intergalactic-icon-secondary-neutral, #a9abb6);padding:0 var(--intergalactic-spacing-1x, 4px)}.___SAddon_58kzi_gg_.__disabled_58kzi_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SInlineInput_58kzi_gg_.__focused_58kzi_gg_{z-index:1}.___SInlineInput_58kzi_gg_.__focused_58kzi_gg_ .___SUnderline_58kzi_gg_{border-bottom-color:var(--intergalactic-border-info-active, #006dca);box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SInlineInput_58kzi_gg_._state_valid_58kzi_gg_ .___SUnderline_58kzi_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65)}.___SInlineInput_58kzi_gg_._state_valid_58kzi_gg_.__focused_58kzi_gg_ .___SUnderline_58kzi_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65);box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgba(0, 159, 129, 0.5))}.___SInlineInput_58kzi_gg_._state_invalid_58kzi_gg_ .___SUnderline_58kzi_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f)}.___SInlineInput_58kzi_gg_._state_invalid_58kzi_gg_.__focused_58kzi_gg_ .___SUnderline_58kzi_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f);box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5))}.___SValue_58kzi_gg_:focus~.___SControls_58kzi_gg_{display:flex}.___SInvalidPattern_58kzi_gg_{margin-left:-1px;margin-top:-1px;border-radius:0;height:calc(100% - 3px)}",
|
|
27
|
+
/*__inner_css_end__*/
|
|
28
|
+
"58kzi_gg_"
|
|
29
|
+
), /*__reshadow_css_end__*/
|
|
30
|
+
{
|
|
31
|
+
"__SInlineInput": "___SInlineInput_58kzi_gg_",
|
|
32
|
+
"_disabled": "__disabled_58kzi_gg_",
|
|
33
|
+
"__SUnderline": "___SUnderline_58kzi_gg_",
|
|
34
|
+
"__SAddon": "___SAddon_58kzi_gg_",
|
|
35
|
+
"_focused": "__focused_58kzi_gg_",
|
|
36
|
+
"_state_valid": "_state_valid_58kzi_gg_",
|
|
37
|
+
"_state_invalid": "_state_invalid_58kzi_gg_",
|
|
38
|
+
"__SValue": "___SValue_58kzi_gg_",
|
|
39
|
+
"__SControls": "___SControls_58kzi_gg_",
|
|
40
|
+
"__SInvalidPattern": "___SInvalidPattern_58kzi_gg_",
|
|
41
|
+
"__SConfirmIcon": "___SConfirmIcon_58kzi_gg_",
|
|
42
|
+
"__SCancelIcon": "___SCancelIcon_58kzi_gg_",
|
|
43
|
+
"_type_number": "_type_number_58kzi_gg_"
|
|
41
44
|
})
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
);
|
|
46
|
+
var pointInsideOfRect = function pointInsideOfRect2(_ref17) {
|
|
47
|
+
var x = _ref17.x, y = _ref17.y, rect = _ref17.rect;
|
|
48
|
+
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
49
|
+
};
|
|
50
|
+
var InlineInputBase = /* @__PURE__ */ function(_Component) {
|
|
51
|
+
_inherits(InlineInputBase2, _Component);
|
|
52
|
+
var _super = _createSuper(InlineInputBase2);
|
|
53
|
+
function InlineInputBase2() {
|
|
54
|
+
var _this;
|
|
55
|
+
_classCallCheck(this, InlineInputBase2);
|
|
56
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
|
+
args[_key] = arguments[_key];
|
|
58
|
+
}
|
|
59
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
61
|
+
focused: false
|
|
62
|
+
});
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "rootRef", /* @__PURE__ */ React.createRef());
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "inputRef", /* @__PURE__ */ React.createRef());
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "inputHandlersRef", /* @__PURE__ */ React.createRef());
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "initValue", "");
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "lastMouseDownPosition", null);
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "lastHandledKeyboardEvent", -1);
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "handleDocumentMouseDown", function(event) {
|
|
70
|
+
_this.lastMouseDownPosition = {
|
|
71
|
+
x: event.clientX,
|
|
72
|
+
y: event.clientY
|
|
73
|
+
};
|
|
74
|
+
_this.lastHandledKeyboardEvent = -1;
|
|
75
|
+
});
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "handleDocumentKeyDown", function() {
|
|
77
|
+
_this.lastMouseDownPosition = null;
|
|
78
|
+
});
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "increment", function(event) {
|
|
80
|
+
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
|
|
81
|
+
if (((_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.value) === "") _this.inputRef.current.value = _this.inputRef.current.min || "0";
|
|
82
|
+
(_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : (_this$inputRef$curren3 = _this$inputRef$curren2.stepUp) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.call(_this$inputRef$curren2, event);
|
|
83
|
+
(_this$inputHandlersRe = _this.inputHandlersRef.current) === null || _this$inputHandlersRe === void 0 ? void 0 : _this$inputHandlersRe.value((_this$inputRef$curren4 = _this.inputRef.current) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.value, event);
|
|
84
|
+
});
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "decrement", function(event) {
|
|
86
|
+
var _this$inputRef$curren5, _this$inputRef$curren6, _this$inputRef$curren7, _this$inputHandlersRe2, _this$inputRef$curren8;
|
|
87
|
+
if (((_this$inputRef$curren5 = _this.inputRef.current) === null || _this$inputRef$curren5 === void 0 ? void 0 : _this$inputRef$curren5.value) === "") _this.inputRef.current.value = _this.inputRef.current.max || "0";
|
|
88
|
+
(_this$inputRef$curren6 = _this.inputRef.current) === null || _this$inputRef$curren6 === void 0 ? void 0 : (_this$inputRef$curren7 = _this$inputRef$curren6.stepDown) === null || _this$inputRef$curren7 === void 0 ? void 0 : _this$inputRef$curren7.call(_this$inputRef$curren6, event);
|
|
89
|
+
(_this$inputHandlersRe2 = _this.inputHandlersRef.current) === null || _this$inputHandlersRe2 === void 0 ? void 0 : _this$inputHandlersRe2.value((_this$inputRef$curren8 = _this.inputRef.current) === null || _this$inputRef$curren8 === void 0 ? void 0 : _this$inputRef$curren8.value, event);
|
|
90
|
+
});
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerValueFocused", function(focused) {
|
|
69
92
|
return function() {
|
|
70
|
-
|
|
71
|
-
focused
|
|
93
|
+
_this.setState({
|
|
94
|
+
focused
|
|
72
95
|
});
|
|
73
96
|
};
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
(
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function(event) {
|
|
99
|
+
var _this$inputRef$curren9;
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
(_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 ? void 0 : _this$inputRef$curren9.focus();
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleConfirm", function(text, event) {
|
|
104
|
+
var _this$asProps$onConfi, _this$asProps;
|
|
105
|
+
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 ? void 0 : _this$asProps$onConfi.call(_this$asProps, text, event);
|
|
106
|
+
});
|
|
107
|
+
_defineProperty(_assertThisInitialized(_this), "handleCancel", function(prevText, event) {
|
|
108
|
+
var _this$asProps$onCance, _this$asProps2;
|
|
109
|
+
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 ? void 0 : _this$asProps$onCance.call(_this$asProps2, prevText, event);
|
|
110
|
+
});
|
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function(event) {
|
|
112
|
+
var _this$inputRef$curren10, _this$inputRef$curren11;
|
|
113
|
+
var _this$asProps3 = _this.asProps, onConfirm = _this$asProps3.onConfirm, onCancel = _this$asProps3.onCancel, onBlurBehavior = _this$asProps3.onBlurBehavior;
|
|
114
|
+
if (!onBlurBehavior) return;
|
|
115
|
+
if (Date.now() - _this.lastHandledKeyboardEvent < 250) return;
|
|
116
|
+
if (hasParent(event.relatedTarget, _this.rootRef.current)) return;
|
|
117
|
+
if (_this.lastMouseDownPosition && _this.rootRef.current) {
|
|
118
|
+
var _this$lastMouseDownPo = _this.lastMouseDownPosition, x = _this$lastMouseDownPo.x, y = _this$lastMouseDownPo.y;
|
|
119
|
+
var rect = _this.rootRef.current.getBoundingClientRect();
|
|
120
|
+
if (pointInsideOfRect({
|
|
121
|
+
x,
|
|
122
|
+
y,
|
|
123
|
+
rect
|
|
124
|
+
})) {
|
|
125
|
+
return;
|
|
94
126
|
}
|
|
95
|
-
y === "confirm" && (d == null || d((i = (o = e.inputRef.current) === null || o === void 0 ? void 0 : o.value) !== null && i !== void 0 ? i : "", r)), y === "cancel" && (c == null || c(e.initValue, r));
|
|
96
127
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
if (onBlurBehavior === "confirm") onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren10 = (_this$inputRef$curren11 = _this.inputRef.current) === null || _this$inputRef$curren11 === void 0 ? void 0 : _this$inputRef$curren11.value) !== null && _this$inputRef$curren10 !== void 0 ? _this$inputRef$curren10 : "", event);
|
|
129
|
+
if (onBlurBehavior === "cancel") onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
130
|
+
});
|
|
131
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function(event) {
|
|
132
|
+
var _this$asProps4 = _this.asProps, onConfirm = _this$asProps4.onConfirm, onCancel = _this$asProps4.onCancel;
|
|
133
|
+
if (event.key === "Enter") {
|
|
134
|
+
var _this$inputRef$curren12, _this$inputRef$curren13;
|
|
135
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm((_this$inputRef$curren12 = (_this$inputRef$curren13 = _this.inputRef.current) === null || _this$inputRef$curren13 === void 0 ? void 0 : _this$inputRef$curren13.value) !== null && _this$inputRef$curren12 !== void 0 ? _this$inputRef$curren12 : "", event);
|
|
136
|
+
_this.lastHandledKeyboardEvent = Date.now();
|
|
102
137
|
}
|
|
103
|
-
|
|
104
|
-
|
|
138
|
+
if (event.key === "Escape") {
|
|
139
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
140
|
+
_this.lastHandledKeyboardEvent = Date.now();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return _this;
|
|
105
144
|
}
|
|
106
|
-
|
|
145
|
+
_createClass(InlineInputBase2, [{
|
|
107
146
|
key: "componentDidMount",
|
|
108
|
-
value: function() {
|
|
109
|
-
this.asProps.onBlurBehavior
|
|
147
|
+
value: function componentDidMount() {
|
|
148
|
+
if (!this.asProps.onBlurBehavior) return;
|
|
149
|
+
document.body.addEventListener("mousedown", this.handleDocumentMouseDown);
|
|
150
|
+
document.body.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
110
151
|
}
|
|
111
152
|
}, {
|
|
112
153
|
key: "componentWillUnmount",
|
|
113
|
-
value: function() {
|
|
114
|
-
this.asProps.onBlurBehavior
|
|
154
|
+
value: function componentWillUnmount() {
|
|
155
|
+
if (!this.asProps.onBlurBehavior) return;
|
|
156
|
+
document.body.removeEventListener("mousedown", this.handleDocumentMouseDown);
|
|
157
|
+
document.body.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
115
158
|
}
|
|
116
159
|
}, {
|
|
117
160
|
key: "getAddonProps",
|
|
118
|
-
value: function() {
|
|
161
|
+
value: function getAddonProps() {
|
|
119
162
|
return {
|
|
120
163
|
onMouseDown: this.handleMouseDownAddon
|
|
121
164
|
};
|
|
122
165
|
}
|
|
123
166
|
}, {
|
|
124
167
|
key: "getConfirmControlProps",
|
|
125
|
-
value: function() {
|
|
126
|
-
var
|
|
168
|
+
value: function getConfirmControlProps() {
|
|
169
|
+
var _this$inputRef$curren14;
|
|
170
|
+
var _this$asProps5 = this.asProps, loading = _this$asProps5.loading, getI18nText = _this$asProps5.getI18nText;
|
|
127
171
|
return {
|
|
128
|
-
value: (
|
|
129
|
-
loading
|
|
172
|
+
value: (_this$inputRef$curren14 = this.inputRef.current) === null || _this$inputRef$curren14 === void 0 ? void 0 : _this$inputRef$curren14.value,
|
|
173
|
+
loading,
|
|
130
174
|
onConfirm: this.handleConfirm,
|
|
131
|
-
getI18nText
|
|
175
|
+
getI18nText
|
|
132
176
|
};
|
|
133
177
|
}
|
|
134
178
|
}, {
|
|
135
179
|
key: "getCancelControlProps",
|
|
136
|
-
value: function() {
|
|
137
|
-
var
|
|
180
|
+
value: function getCancelControlProps() {
|
|
181
|
+
var _this$asProps6 = this.asProps, loading = _this$asProps6.loading, disabled = _this$asProps6.disabled, getI18nText = _this$asProps6.getI18nText;
|
|
138
182
|
return {
|
|
139
183
|
value: this.initValue,
|
|
140
184
|
// because double disabled(root disabled and addon disabled)
|
|
141
|
-
disabled:
|
|
185
|
+
disabled: loading && !disabled,
|
|
142
186
|
onCancel: this.handleCancel,
|
|
143
|
-
getI18nText
|
|
187
|
+
getI18nText
|
|
144
188
|
};
|
|
145
189
|
}
|
|
146
190
|
}, {
|
|
147
191
|
key: "getValueProps",
|
|
148
|
-
value: function() {
|
|
149
|
-
var
|
|
192
|
+
value: function getValueProps() {
|
|
193
|
+
var state = this.asProps.state;
|
|
150
194
|
return {
|
|
151
195
|
ref: this.inputRef,
|
|
152
|
-
state
|
|
196
|
+
state,
|
|
153
197
|
onKeyDown: this.handleKeyDown,
|
|
154
|
-
onFocus: this.bindHandlerValueFocused(
|
|
155
|
-
onBlur: this.bindHandlerValueFocused(
|
|
198
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
199
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
156
200
|
};
|
|
157
201
|
}
|
|
158
202
|
}, {
|
|
159
203
|
key: "getNumberValueProps",
|
|
160
|
-
value: function() {
|
|
161
|
-
var
|
|
204
|
+
value: function getNumberValueProps() {
|
|
205
|
+
var numberFormatter = new Intl.NumberFormat(this.asProps.locale, {
|
|
162
206
|
style: "decimal"
|
|
163
207
|
});
|
|
164
208
|
return {
|
|
165
|
-
numberFormatter
|
|
209
|
+
numberFormatter,
|
|
166
210
|
inputRef: this.inputRef,
|
|
167
211
|
inputHandlerRefs: this.inputHandlersRef,
|
|
168
212
|
increment: this.increment,
|
|
169
213
|
decrement: this.decrement,
|
|
170
|
-
onFocus: this.bindHandlerValueFocused(
|
|
171
|
-
onBlur: this.bindHandlerValueFocused(
|
|
214
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
215
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
172
216
|
};
|
|
173
217
|
}
|
|
174
218
|
}, {
|
|
175
219
|
key: "getNumberControlsProps",
|
|
176
|
-
value: function() {
|
|
177
|
-
var
|
|
220
|
+
value: function getNumberControlsProps() {
|
|
221
|
+
var getI18nText = this.asProps.getI18nText;
|
|
178
222
|
return {
|
|
179
223
|
increment: this.increment,
|
|
180
224
|
decrement: this.decrement,
|
|
181
|
-
getI18nText
|
|
225
|
+
getI18nText
|
|
182
226
|
};
|
|
183
227
|
}
|
|
184
228
|
}, {
|
|
185
229
|
key: "render",
|
|
186
|
-
value: function() {
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
230
|
+
value: function render() {
|
|
231
|
+
var _ref = this.asProps, _ref8;
|
|
232
|
+
var SInlineInput = Box;
|
|
233
|
+
var SUnderline = "div";
|
|
234
|
+
var SInvalidPattern = InvalidStateBox;
|
|
235
|
+
var _this$asProps7 = this.asProps, Children = _this$asProps7.Children, styles = _this$asProps7.styles, state = _this$asProps7.state;
|
|
236
|
+
var focused = this.state.focused;
|
|
237
|
+
return _ref8 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SInlineInput, _ref8.cn("SInlineInput", _objectSpread({}, assignProps({
|
|
238
|
+
"ref": this.rootRef,
|
|
239
|
+
"focused": focused,
|
|
240
|
+
"onBlur": this.handleBlur
|
|
241
|
+
}, _ref))), /* @__PURE__ */ React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === "invalid" && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}))));
|
|
193
242
|
}
|
|
194
|
-
}])
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
243
|
+
}]);
|
|
244
|
+
return InlineInputBase2;
|
|
245
|
+
}(Component);
|
|
246
|
+
_defineProperty(InlineInputBase, "displayName", "InlineInput");
|
|
247
|
+
_defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
|
|
248
|
+
_defineProperty(InlineInputBase, "defaultProps", {
|
|
199
249
|
state: "normal",
|
|
200
250
|
onBlurBehavior: "confirm",
|
|
201
|
-
i18n:
|
|
251
|
+
i18n: localizedMessages,
|
|
202
252
|
locale: "en"
|
|
203
253
|
});
|
|
204
|
-
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
function
|
|
209
|
-
|
|
254
|
+
_defineProperty(InlineInputBase, "style", style);
|
|
255
|
+
var Value = /* @__PURE__ */ function(_Component2) {
|
|
256
|
+
_inherits(Value2, _Component2);
|
|
257
|
+
var _super2 = _createSuper(Value2);
|
|
258
|
+
function Value2() {
|
|
259
|
+
_classCallCheck(this, Value2);
|
|
260
|
+
return _super2.apply(this, arguments);
|
|
210
261
|
}
|
|
211
|
-
|
|
262
|
+
_createClass(Value2, [{
|
|
212
263
|
key: "uncontrolledProps",
|
|
213
|
-
value: function() {
|
|
264
|
+
value: function uncontrolledProps() {
|
|
214
265
|
return {
|
|
215
|
-
value: function(
|
|
216
|
-
return
|
|
266
|
+
value: function value(event) {
|
|
267
|
+
return event.target.value;
|
|
217
268
|
}
|
|
218
269
|
};
|
|
219
270
|
}
|
|
220
271
|
}, {
|
|
221
272
|
key: "render",
|
|
222
|
-
value: function() {
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
273
|
+
value: function render() {
|
|
274
|
+
var _ref2 = this.asProps, _ref9;
|
|
275
|
+
var SValue = Box;
|
|
276
|
+
return _ref9 = sstyled$1(this.asProps.styles), /* @__PURE__ */ React.createElement(SValue, _ref9.cn("SValue", _objectSpread({}, assignProps({
|
|
277
|
+
"tag": "input",
|
|
278
|
+
"type": "text"
|
|
279
|
+
}, _ref2))));
|
|
228
280
|
}
|
|
229
|
-
}])
|
|
230
|
-
|
|
231
|
-
|
|
281
|
+
}]);
|
|
282
|
+
return Value2;
|
|
283
|
+
}(Component);
|
|
284
|
+
_defineProperty(Value, "defaultProps", {
|
|
232
285
|
defaultValue: ""
|
|
233
286
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
var
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
-
|
|
249
|
-
|
|
287
|
+
_defineProperty(Value, "enhance", [autoFocusEnhance()]);
|
|
288
|
+
_defineProperty(Value, "hoistProps", ["disabled"]);
|
|
289
|
+
var Addon = function Addon2(props) {
|
|
290
|
+
var _ref3 = arguments[0], _ref10;
|
|
291
|
+
var SAddon = Box;
|
|
292
|
+
return _ref10 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, assignProps({}, _ref3))));
|
|
293
|
+
};
|
|
294
|
+
var ConfirmControl = function ConfirmControl2(props) {
|
|
295
|
+
var _ref4 = arguments[0], _ref12, _props$title, _ref18;
|
|
296
|
+
var SAddon = Box;
|
|
297
|
+
var Children = props.Children, hasChildren = props.children;
|
|
298
|
+
var title = (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : props.getI18nText("confirm");
|
|
299
|
+
var handleConfirm = React.useCallback(function(event) {
|
|
300
|
+
var _props$onConfirm, _props$value;
|
|
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);
|
|
302
|
+
}, [props.onConfirm, props.value]);
|
|
303
|
+
var handleKeydown = React.useCallback(function(event) {
|
|
304
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
event.stopPropagation();
|
|
307
|
+
handleConfirm(event);
|
|
308
|
+
}
|
|
309
|
+
}, [handleConfirm]);
|
|
310
|
+
if (props.loading) {
|
|
311
|
+
var _ref11;
|
|
312
|
+
return _ref11 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, assignProps({}, _ref4))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref11.cn("Children", {})) : /* @__PURE__ */ React.createElement(Spin, _ref11.cn("Spin", {
|
|
313
|
+
"size": "xs"
|
|
250
314
|
})));
|
|
251
315
|
}
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
"
|
|
316
|
+
var sstyles = sstyled$1(props.styles);
|
|
317
|
+
var sConfirmIconStyles = sstyles.cn("SConfirmIcon", {});
|
|
318
|
+
return _ref12 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, assignProps({
|
|
319
|
+
"onKeyDown": handleKeydown
|
|
320
|
+
}, _ref4))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref12.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
|
|
321
|
+
"addonLeft": (_ref18 = props.icon) !== null && _ref18 !== void 0 ? _ref18 : CheckM,
|
|
322
|
+
"use": "secondary",
|
|
323
|
+
"onClick": handleConfirm,
|
|
324
|
+
"className": sConfirmIconStyles.className,
|
|
325
|
+
"style": sConfirmIconStyles.style,
|
|
326
|
+
"aria-label": title
|
|
262
327
|
})));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
328
|
+
};
|
|
329
|
+
var CancelControl = function CancelControl2(props) {
|
|
330
|
+
var _ref5 = arguments[0], _ref14, _props$title2, _ref19;
|
|
331
|
+
var SAddon = Box;
|
|
332
|
+
var Children = props.Children, hasChildren = props.children;
|
|
333
|
+
var title = (_props$title2 = props.title) !== null && _props$title2 !== void 0 ? _props$title2 : props.getI18nText("discard");
|
|
334
|
+
var handleCancel = React.useCallback(function(event) {
|
|
335
|
+
var _props$onCancel, _props$value2;
|
|
336
|
+
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, (_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : "", event);
|
|
337
|
+
}, [props.onCancel, props.value]);
|
|
338
|
+
var handleKeydown = React.useCallback(function(event) {
|
|
339
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
event.stopPropagation();
|
|
342
|
+
handleCancel(event);
|
|
343
|
+
}
|
|
344
|
+
}, [handleCancel]);
|
|
345
|
+
if (props.disabled) {
|
|
346
|
+
var _ref13;
|
|
347
|
+
return _ref13 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref13.cn("SAddon", _objectSpread({}, assignProps({}, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref13.cn("Children", {})) : /* @__PURE__ */ React.createElement(CloseM, _ref13.cn("CloseM", {})));
|
|
273
348
|
}
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
"
|
|
349
|
+
var sstyles = sstyled$1(props.styles);
|
|
350
|
+
var sCancelIconStyles = sstyles.cn("SCancelIcon", {});
|
|
351
|
+
return _ref14 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref14.cn("SAddon", _objectSpread({}, assignProps({
|
|
352
|
+
"onKeyDown": handleKeydown
|
|
353
|
+
}, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref14.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref14.cn("ButtonLink", {
|
|
354
|
+
"use": "secondary",
|
|
355
|
+
"addonLeft": (_ref19 = props.icon) !== null && _ref19 !== void 0 ? _ref19 : CloseM,
|
|
356
|
+
"onClick": handleCancel,
|
|
357
|
+
"className": sCancelIconStyles.className,
|
|
358
|
+
"style": sCancelIconStyles.style,
|
|
359
|
+
"aria-label": title
|
|
284
360
|
})));
|
|
285
|
-
}, q = function(n) {
|
|
286
|
-
var l = arguments[0], e, t = A.Value;
|
|
287
|
-
return e = m(n.styles), /* @__PURE__ */ _.createElement(t, e.cn("SValue", b({}, C({}, l))));
|
|
288
361
|
};
|
|
289
|
-
function
|
|
290
|
-
var
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
362
|
+
var NumberValue = function NumberValue2(props) {
|
|
363
|
+
var _ref6 = arguments[0], _ref15;
|
|
364
|
+
var SValue = InputNumber.Value;
|
|
365
|
+
return _ref15 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SValue, _ref15.cn("SValue", _objectSpread({}, assignProps({}, _ref6))));
|
|
366
|
+
};
|
|
367
|
+
function NumberControls(props) {
|
|
368
|
+
var _ref7 = arguments[0], _ref16;
|
|
369
|
+
var SControls = InputNumber.Controls;
|
|
370
|
+
return _ref16 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SControls, _ref16.cn("SControls", _objectSpread({}, assignProps({
|
|
371
|
+
"tag": InlineInput.Addon
|
|
372
|
+
}, _ref7))));
|
|
294
373
|
}
|
|
295
|
-
var
|
|
296
|
-
Addon
|
|
297
|
-
Value
|
|
298
|
-
ConfirmControl
|
|
299
|
-
CancelControl
|
|
300
|
-
NumberValue
|
|
301
|
-
NumberControls
|
|
374
|
+
var InlineInput = createComponent(InlineInputBase, {
|
|
375
|
+
Addon,
|
|
376
|
+
Value,
|
|
377
|
+
ConfirmControl,
|
|
378
|
+
CancelControl,
|
|
379
|
+
NumberValue,
|
|
380
|
+
NumberControls
|
|
302
381
|
});
|
|
303
382
|
export {
|
|
304
|
-
|
|
383
|
+
InlineInput as default
|
|
305
384
|
};
|