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