@semcore/inline-input 4.49.0-prerelease.5 → 4.49.0-prerelease.7
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/lib/cjs/InlineInput.js +139 -128
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/index.d.js +2 -0
- package/lib/cjs/index.d.js.map +1 -0
- package/lib/cjs/index.js +3 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/inline-input.shadow.css +55 -52
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +5 -4
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/InlineInput.js +130 -122
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/es6/index.d.js +2 -0
- package/lib/es6/index.d.js.map +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/inline-input.shadow.css +55 -52
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/InlineInput.mjs +133 -123
- package/lib/esm/style/inline-input.shadow.css +55 -52
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/types/index.d.ts +162 -4
- package/package.json +11 -11
- package/lib/cjs/index.type.js +0 -2
- package/lib/cjs/index.type.js.map +0 -1
- package/lib/es6/index.type.js +0 -2
- package/lib/es6/index.type.js.map +0 -1
- package/lib/types/InlineInput.d.ts +0 -4
- package/lib/types/index.type.d.ts +0 -107
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +0 -58
package/lib/esm/InlineInput.mjs
CHANGED
|
@@ -1,97 +1,115 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import { sstyled
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
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";
|
|
12
13
|
import CheckM from "@semcore/icon/Check/m";
|
|
13
14
|
import CloseM from "@semcore/icon/Close/m";
|
|
14
|
-
import InputNumber from "@semcore/input-number";
|
|
15
15
|
import Spin from "@semcore/spin";
|
|
16
|
-
import
|
|
16
|
+
import { ButtonLink } from "@semcore/button";
|
|
17
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";
|
|
18
21
|
/*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
19
22
|
var style = (
|
|
20
23
|
/*__reshadow_css_start__*/
|
|
21
24
|
(sstyled.insert(
|
|
22
25
|
/*__inner_css_start__*/
|
|
23
|
-
".
|
|
26
|
+
".___SInlineInput_ixtql_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, rgb(255, 255, 255))}.___SInlineInput_ixtql_gg_ .___SConfirmIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-success, rgb(0, 190, 142));cursor:pointer}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_ .___SConfirmIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-success, rgb(0, 190, 142))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_ .___SConfirmIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-success, color(display-p3 0.33388 0.7337 0.56959))}}}@media (hover:hover){.___SInlineInput_ixtql_gg_ .___SConfirmIcon_ixtql_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, rgb(1, 176, 131))}}.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385));cursor:pointer}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_{color:var(--intergalactic-icon-secondary-neutral, color(display-p3 0.0036 0.02041 0.00996 / 0.385))}}}@media (hover:hover){.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, rgba(0, 5, 2, 0.433))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, rgba(0, 5, 2, 0.433))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_ .___SCancelIcon_ixtql_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, color(display-p3 0.00333 0.01824 0.00791 / 0.433))}}}}.___SInlineInput_ixtql_gg_.__disabled_ixtql_gg_{cursor:default;pointer-events:none;opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SValue_ixtql_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, rgba(1, 5, 0, 0.899));font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:0 0;min-height:1em}.___SValue_ixtql_gg_:focus{outline:0}.___SValue_ixtql_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, rgba(0, 5, 2, 0.457))}.___SValue_ixtql_gg_::placeholder{color:var(--intergalactic-text-placeholder, rgba(0, 5, 2, 0.457))}.___SValue_ixtql_gg_.__disabled_ixtql_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SValue_ixtql_gg_::-webkit-inner-spin-button,.___SValue_ixtql_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SValue_ixtql_gg_._type_number_ixtql_gg_{-moz-appearance:textfield}.___SUnderline_ixtql_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, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0)){.___SUnderline_ixtql_gg_{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SUnderline_ixtql_gg_{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SAddon_ixtql_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385));padding:0 var(--intergalactic-spacing-1x, 4px)}@supports (color:color(display-p3 0 0 0)){.___SAddon_ixtql_gg_{color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385))}@media (color-gamut:p3){.___SAddon_ixtql_gg_{color:var(--intergalactic-icon-secondary-neutral, color(display-p3 0.0036 0.02041 0.00996 / 0.385))}}}.___SAddon_ixtql_gg_.__disabled_ixtql_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);cursor:default;pointer-events:none}.___SInlineInput_ixtql_gg_.__focused_ixtql_gg_{z-index:1}.___SInlineInput_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-info-active, rgba(0, 40, 230, 0.419));box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 33, 220, 0.469))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 33, 220, 0.469))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, color(display-p3 0.36013 0.78771 0.61714))}}}.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154));box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgb(0, 190, 142))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154));box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgb(0, 190, 142))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_._state_valid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-success-active, color(display-p3 0.36013 0.78771 0.61714));box-shadow:var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px color(display-p3 0.33388 0.7337 0.56959))}}}.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56));box-shadow:var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 2, 7, 0.652))}@supports (color:color(display-p3 0 0 0)){.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SInlineInput_ixtql_gg_._state_invalid_ixtql_gg_.__focused_ixtql_gg_ .___SUnderline_ixtql_gg_{border-bottom-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}.___SValue_ixtql_gg_:focus~.___SControls_ixtql_gg_{display:flex}.___SInvalidPattern_ixtql_gg_{margin-left:-1px;margin-top:-1px;border-radius:0;height:calc(100% - 3px)}",
|
|
24
27
|
/*__inner_css_end__*/
|
|
25
|
-
"
|
|
28
|
+
"ixtql_gg_"
|
|
26
29
|
), /*__reshadow_css_end__*/
|
|
27
30
|
{
|
|
28
|
-
"__SInlineInput": "
|
|
29
|
-
"_disabled": "
|
|
30
|
-
"__SUnderline": "
|
|
31
|
-
"__SAddon": "
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"__SCancelIcon": "
|
|
40
|
-
"_type_number": "
|
|
31
|
+
"__SInlineInput": "___SInlineInput_ixtql_gg_",
|
|
32
|
+
"_disabled": "__disabled_ixtql_gg_",
|
|
33
|
+
"__SUnderline": "___SUnderline_ixtql_gg_",
|
|
34
|
+
"__SAddon": "___SAddon_ixtql_gg_",
|
|
35
|
+
"_focused": "__focused_ixtql_gg_",
|
|
36
|
+
"_state_valid": "_state_valid_ixtql_gg_",
|
|
37
|
+
"_state_invalid": "_state_invalid_ixtql_gg_",
|
|
38
|
+
"__SValue": "___SValue_ixtql_gg_",
|
|
39
|
+
"__SControls": "___SControls_ixtql_gg_",
|
|
40
|
+
"__SInvalidPattern": "___SInvalidPattern_ixtql_gg_",
|
|
41
|
+
"__SConfirmIcon": "___SConfirmIcon_ixtql_gg_",
|
|
42
|
+
"__SCancelIcon": "___SCancelIcon_ixtql_gg_",
|
|
43
|
+
"_type_number": "_type_number_ixtql_gg_"
|
|
41
44
|
})
|
|
42
45
|
);
|
|
43
|
-
var pointInsideOfRect = function pointInsideOfRect2(
|
|
44
|
-
var x =
|
|
46
|
+
var pointInsideOfRect = function pointInsideOfRect2(_ref17) {
|
|
47
|
+
var x = _ref17.x, y = _ref17.y, rect = _ref17.rect;
|
|
45
48
|
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
46
49
|
};
|
|
47
|
-
var InlineInputBase = /* @__PURE__ */
|
|
50
|
+
var InlineInputBase = /* @__PURE__ */ function(_Component) {
|
|
51
|
+
_inherits(InlineInputBase2, _Component);
|
|
52
|
+
var _super = _createSuper(InlineInputBase2);
|
|
48
53
|
function InlineInputBase2() {
|
|
49
54
|
var _this;
|
|
50
55
|
_classCallCheck(this, InlineInputBase2);
|
|
51
56
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
57
|
args[_key] = arguments[_key];
|
|
53
58
|
}
|
|
54
|
-
_this =
|
|
55
|
-
_defineProperty(_this, "
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_defineProperty(_this, "
|
|
59
|
-
_defineProperty(_this, "
|
|
60
|
-
_defineProperty(_this, "
|
|
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) {
|
|
61
70
|
_this.lastMouseDownPosition = {
|
|
62
71
|
x: event.clientX,
|
|
63
72
|
y: event.clientY
|
|
64
73
|
};
|
|
65
74
|
_this.lastHandledKeyboardEvent = -1;
|
|
66
75
|
});
|
|
67
|
-
_defineProperty(_this, "handleDocumentKeyDown", function() {
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "handleDocumentKeyDown", function() {
|
|
68
77
|
_this.lastMouseDownPosition = null;
|
|
69
78
|
});
|
|
70
|
-
_defineProperty(_this, "increment", function(event) {
|
|
71
|
-
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3;
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "increment", function(event) {
|
|
80
|
+
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
|
|
72
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";
|
|
73
|
-
(_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 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);
|
|
74
84
|
});
|
|
75
|
-
_defineProperty(_this, "decrement", function(event) {
|
|
76
|
-
var _this$inputRef$
|
|
77
|
-
if (((_this$inputRef$
|
|
78
|
-
(_this$inputRef$
|
|
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);
|
|
79
90
|
});
|
|
80
|
-
_defineProperty(_this, "
|
|
81
|
-
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerValueFocused", function(focused) {
|
|
92
|
+
return function() {
|
|
93
|
+
_this.setState({
|
|
94
|
+
focused
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function(event) {
|
|
99
|
+
var _this$inputRef$curren9;
|
|
82
100
|
event.preventDefault();
|
|
83
|
-
(_this$inputRef$
|
|
101
|
+
(_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 ? void 0 : _this$inputRef$curren9.focus();
|
|
84
102
|
});
|
|
85
|
-
_defineProperty(_this, "handleConfirm", function(text, event) {
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleConfirm", function(text, event) {
|
|
86
104
|
var _this$asProps$onConfi, _this$asProps;
|
|
87
|
-
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0
|
|
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);
|
|
88
106
|
});
|
|
89
|
-
_defineProperty(_this, "handleCancel", function(prevText, event) {
|
|
107
|
+
_defineProperty(_assertThisInitialized(_this), "handleCancel", function(prevText, event) {
|
|
90
108
|
var _this$asProps$onCance, _this$asProps2;
|
|
91
|
-
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0
|
|
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);
|
|
92
110
|
});
|
|
93
|
-
_defineProperty(_this, "handleBlur", function(event) {
|
|
94
|
-
var _this$inputRef$
|
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function(event) {
|
|
112
|
+
var _this$inputRef$curren10, _this$inputRef$curren11;
|
|
95
113
|
var _this$asProps3 = _this.asProps, onConfirm = _this$asProps3.onConfirm, onCancel = _this$asProps3.onCancel, onBlurBehavior = _this$asProps3.onBlurBehavior;
|
|
96
114
|
if (!onBlurBehavior) return;
|
|
97
115
|
if (Date.now() - _this.lastHandledKeyboardEvent < 250) return;
|
|
@@ -107,39 +125,30 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
107
125
|
return;
|
|
108
126
|
}
|
|
109
127
|
}
|
|
110
|
-
if (onBlurBehavior === "confirm") onConfirm === null || onConfirm === void 0
|
|
111
|
-
if (onBlurBehavior === "cancel") onCancel === null || onCancel === void 0
|
|
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);
|
|
112
130
|
});
|
|
113
|
-
_defineProperty(_this, "handleKeyDown", function(event) {
|
|
131
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function(event) {
|
|
114
132
|
var _this$asProps4 = _this.asProps, onConfirm = _this$asProps4.onConfirm, onCancel = _this$asProps4.onCancel;
|
|
115
133
|
if (event.key === "Enter") {
|
|
116
|
-
var _this$inputRef$
|
|
117
|
-
onConfirm === null || onConfirm === void 0
|
|
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);
|
|
118
136
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
119
137
|
}
|
|
120
138
|
if (event.key === "Escape") {
|
|
121
|
-
onCancel === null || onCancel === void 0
|
|
139
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
122
140
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
123
141
|
}
|
|
124
142
|
});
|
|
125
143
|
return _this;
|
|
126
144
|
}
|
|
127
|
-
|
|
128
|
-
return _createClass(InlineInputBase2, [{
|
|
145
|
+
_createClass(InlineInputBase2, [{
|
|
129
146
|
key: "componentDidMount",
|
|
130
147
|
value: function componentDidMount() {
|
|
131
|
-
this.updateInert();
|
|
132
148
|
if (!this.asProps.onBlurBehavior) return;
|
|
133
149
|
document.body.addEventListener("mousedown", this.handleDocumentMouseDown);
|
|
134
150
|
document.body.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
135
151
|
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "componentDidUpdate",
|
|
138
|
-
value: function componentDidUpdate(prevProps) {
|
|
139
|
-
if (prevProps.disabled !== this.asProps.disabled) {
|
|
140
|
-
this.updateInert();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
152
|
}, {
|
|
144
153
|
key: "componentWillUnmount",
|
|
145
154
|
value: function componentWillUnmount() {
|
|
@@ -157,9 +166,10 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
157
166
|
}, {
|
|
158
167
|
key: "getConfirmControlProps",
|
|
159
168
|
value: function getConfirmControlProps() {
|
|
169
|
+
var _this$inputRef$curren14;
|
|
160
170
|
var _this$asProps5 = this.asProps, loading = _this$asProps5.loading, getI18nText = _this$asProps5.getI18nText;
|
|
161
171
|
return {
|
|
162
|
-
|
|
172
|
+
value: (_this$inputRef$curren14 = this.inputRef.current) === null || _this$inputRef$curren14 === void 0 ? void 0 : _this$inputRef$curren14.value,
|
|
163
173
|
loading,
|
|
164
174
|
onConfirm: this.handleConfirm,
|
|
165
175
|
getI18nText
|
|
@@ -184,7 +194,9 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
184
194
|
return {
|
|
185
195
|
ref: this.inputRef,
|
|
186
196
|
state,
|
|
187
|
-
onKeyDown: this.handleKeyDown
|
|
197
|
+
onKeyDown: this.handleKeyDown,
|
|
198
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
199
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
188
200
|
};
|
|
189
201
|
}
|
|
190
202
|
}, {
|
|
@@ -196,8 +208,11 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
196
208
|
return {
|
|
197
209
|
numberFormatter,
|
|
198
210
|
inputRef: this.inputRef,
|
|
211
|
+
inputHandlerRefs: this.inputHandlersRef,
|
|
199
212
|
increment: this.increment,
|
|
200
|
-
decrement: this.decrement
|
|
213
|
+
decrement: this.decrement,
|
|
214
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
215
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
201
216
|
};
|
|
202
217
|
}
|
|
203
218
|
}, {
|
|
@@ -210,17 +225,6 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
210
225
|
getI18nText
|
|
211
226
|
};
|
|
212
227
|
}
|
|
213
|
-
}, {
|
|
214
|
-
key: "updateInert",
|
|
215
|
-
value: function updateInert() {
|
|
216
|
-
var disabled = this.asProps.disabled;
|
|
217
|
-
if (!this.rootRef.current) return;
|
|
218
|
-
if (disabled) {
|
|
219
|
-
this.rootRef.current.setAttribute("inert", "");
|
|
220
|
-
} else {
|
|
221
|
-
this.rootRef.current.removeAttribute("inert");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
228
|
}, {
|
|
225
229
|
key: "render",
|
|
226
230
|
value: function render() {
|
|
@@ -229,13 +233,16 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
|
|
|
229
233
|
var SUnderline = "div";
|
|
230
234
|
var SInvalidPattern = InvalidStateBox;
|
|
231
235
|
var _this$asProps7 = this.asProps, Children = _this$asProps7.Children, styles = _this$asProps7.styles, state = _this$asProps7.state;
|
|
232
|
-
|
|
236
|
+
var focused = this.state.focused;
|
|
237
|
+
return _ref8 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SInlineInput, _ref8.cn("SInlineInput", _objectSpread({}, assignProps({
|
|
233
238
|
"ref": this.rootRef,
|
|
239
|
+
"focused": focused,
|
|
234
240
|
"onBlur": this.handleBlur
|
|
235
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", {}))));
|
|
236
242
|
}
|
|
237
243
|
}]);
|
|
238
|
-
|
|
244
|
+
return InlineInputBase2;
|
|
245
|
+
}(Component);
|
|
239
246
|
_defineProperty(InlineInputBase, "displayName", "InlineInput");
|
|
240
247
|
_defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
|
|
241
248
|
_defineProperty(InlineInputBase, "defaultProps", {
|
|
@@ -245,13 +252,14 @@ _defineProperty(InlineInputBase, "defaultProps", {
|
|
|
245
252
|
locale: "en"
|
|
246
253
|
});
|
|
247
254
|
_defineProperty(InlineInputBase, "style", style);
|
|
248
|
-
var Value = /* @__PURE__ */
|
|
255
|
+
var Value = /* @__PURE__ */ function(_Component2) {
|
|
256
|
+
_inherits(Value2, _Component2);
|
|
257
|
+
var _super2 = _createSuper(Value2);
|
|
249
258
|
function Value2() {
|
|
250
259
|
_classCallCheck(this, Value2);
|
|
251
|
-
return
|
|
260
|
+
return _super2.apply(this, arguments);
|
|
252
261
|
}
|
|
253
|
-
|
|
254
|
-
return _createClass(Value2, [{
|
|
262
|
+
_createClass(Value2, [{
|
|
255
263
|
key: "uncontrolledProps",
|
|
256
264
|
value: function uncontrolledProps() {
|
|
257
265
|
return {
|
|
@@ -265,30 +273,33 @@ var Value = /* @__PURE__ */ (function(_Component2) {
|
|
|
265
273
|
value: function render() {
|
|
266
274
|
var _ref2 = this.asProps, _ref9;
|
|
267
275
|
var SValue = Box;
|
|
268
|
-
return _ref9 = sstyled(this.asProps.styles), /* @__PURE__ */ React.createElement(SValue, _ref9.cn("SValue", _objectSpread({}, assignProps({
|
|
276
|
+
return _ref9 = sstyled$1(this.asProps.styles), /* @__PURE__ */ React.createElement(SValue, _ref9.cn("SValue", _objectSpread({}, assignProps({
|
|
269
277
|
"tag": "input",
|
|
270
278
|
"type": "text"
|
|
271
279
|
}, _ref2))));
|
|
272
280
|
}
|
|
273
281
|
}]);
|
|
274
|
-
|
|
282
|
+
return Value2;
|
|
283
|
+
}(Component);
|
|
275
284
|
_defineProperty(Value, "defaultProps", {
|
|
276
285
|
defaultValue: ""
|
|
277
286
|
});
|
|
278
|
-
|
|
279
|
-
|
|
287
|
+
_defineProperty(Value, "enhance", [autoFocusEnhance()]);
|
|
288
|
+
_defineProperty(Value, "hoistProps", ["disabled"]);
|
|
289
|
+
var Addon = function Addon2(props) {
|
|
290
|
+
var _ref3 = arguments[0], _ref10;
|
|
280
291
|
var SAddon = Box;
|
|
281
|
-
return
|
|
282
|
-
}
|
|
283
|
-
function
|
|
284
|
-
var _ref4 = arguments[0],
|
|
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;
|
|
285
296
|
var SAddon = Box;
|
|
286
|
-
var Children = props.Children, hasChildren = props.children
|
|
297
|
+
var Children = props.Children, hasChildren = props.children;
|
|
287
298
|
var title = (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : props.getI18nText("confirm");
|
|
288
299
|
var handleConfirm = React.useCallback(function(event) {
|
|
289
|
-
var _props$onConfirm,
|
|
290
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0
|
|
291
|
-
}, [props.onConfirm,
|
|
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]);
|
|
292
303
|
var handleKeydown = React.useCallback(function(event) {
|
|
293
304
|
if (event.key === "Enter" || event.key === " ") {
|
|
294
305
|
event.preventDefault();
|
|
@@ -297,32 +308,32 @@ function ConfirmControl(props) {
|
|
|
297
308
|
}
|
|
298
309
|
}, [handleConfirm]);
|
|
299
310
|
if (props.loading) {
|
|
300
|
-
var
|
|
301
|
-
return
|
|
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", {
|
|
302
313
|
"size": "xs"
|
|
303
314
|
})));
|
|
304
315
|
}
|
|
305
|
-
var sstyles = sstyled(props.styles);
|
|
316
|
+
var sstyles = sstyled$1(props.styles);
|
|
306
317
|
var sConfirmIconStyles = sstyles.cn("SConfirmIcon", {});
|
|
307
|
-
return
|
|
318
|
+
return _ref12 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, assignProps({
|
|
308
319
|
"onKeyDown": handleKeydown
|
|
309
|
-
}, _ref4))), hasChildren ? /* @__PURE__ */ React.createElement(Children,
|
|
310
|
-
"addonLeft": (
|
|
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,
|
|
311
322
|
"use": "secondary",
|
|
312
323
|
"onClick": handleConfirm,
|
|
313
324
|
"className": sConfirmIconStyles.className,
|
|
314
325
|
"style": sConfirmIconStyles.style,
|
|
315
326
|
"aria-label": title
|
|
316
327
|
})));
|
|
317
|
-
}
|
|
318
|
-
function
|
|
319
|
-
var _ref5 = arguments[0],
|
|
328
|
+
};
|
|
329
|
+
var CancelControl = function CancelControl2(props) {
|
|
330
|
+
var _ref5 = arguments[0], _ref14, _props$title2, _ref19;
|
|
320
331
|
var SAddon = Box;
|
|
321
332
|
var Children = props.Children, hasChildren = props.children;
|
|
322
333
|
var title = (_props$title2 = props.title) !== null && _props$title2 !== void 0 ? _props$title2 : props.getI18nText("discard");
|
|
323
334
|
var handleCancel = React.useCallback(function(event) {
|
|
324
|
-
var _props$onCancel, _props$
|
|
325
|
-
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0
|
|
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);
|
|
326
337
|
}, [props.onCancel, props.value]);
|
|
327
338
|
var handleKeydown = React.useCallback(function(event) {
|
|
328
339
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -332,32 +343,31 @@ function CancelControl(props) {
|
|
|
332
343
|
}
|
|
333
344
|
}, [handleCancel]);
|
|
334
345
|
if (props.disabled) {
|
|
335
|
-
var
|
|
336
|
-
return
|
|
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", {})));
|
|
337
348
|
}
|
|
338
|
-
var sstyles = sstyled(props.styles);
|
|
349
|
+
var sstyles = sstyled$1(props.styles);
|
|
339
350
|
var sCancelIconStyles = sstyles.cn("SCancelIcon", {});
|
|
340
|
-
return
|
|
351
|
+
return _ref14 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref14.cn("SAddon", _objectSpread({}, assignProps({
|
|
341
352
|
"onKeyDown": handleKeydown
|
|
342
|
-
}, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children,
|
|
353
|
+
}, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref14.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref14.cn("ButtonLink", {
|
|
343
354
|
"use": "secondary",
|
|
344
|
-
"addonLeft": (
|
|
355
|
+
"addonLeft": (_ref19 = props.icon) !== null && _ref19 !== void 0 ? _ref19 : CloseM,
|
|
345
356
|
"onClick": handleCancel,
|
|
346
357
|
"className": sCancelIconStyles.className,
|
|
347
358
|
"style": sCancelIconStyles.style,
|
|
348
359
|
"aria-label": title
|
|
349
360
|
})));
|
|
350
|
-
}
|
|
351
|
-
function
|
|
352
|
-
var _ref6 = arguments[0],
|
|
361
|
+
};
|
|
362
|
+
var NumberValue = function NumberValue2(props) {
|
|
363
|
+
var _ref6 = arguments[0], _ref15;
|
|
353
364
|
var SValue = InputNumber.Value;
|
|
354
|
-
return
|
|
355
|
-
}
|
|
356
|
-
;
|
|
365
|
+
return _ref15 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SValue, _ref15.cn("SValue", _objectSpread({}, assignProps({}, _ref6))));
|
|
366
|
+
};
|
|
357
367
|
function NumberControls(props) {
|
|
358
|
-
var _ref7 = arguments[0],
|
|
368
|
+
var _ref7 = arguments[0], _ref16;
|
|
359
369
|
var SControls = InputNumber.Controls;
|
|
360
|
-
return
|
|
370
|
+
return _ref16 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SControls, _ref16.cn("SControls", _objectSpread({}, assignProps({
|
|
361
371
|
"tag": InlineInput.Addon
|
|
362
372
|
}, _ref7))));
|
|
363
373
|
}
|