@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/es6/InlineInput.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
|
+
import { sstyled as _sstyled } from "@semcore/utils/lib/core/index";
|
|
8
9
|
import { assignProps as _assignProps9 } from "@semcore/core";
|
|
9
10
|
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
10
11
|
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
@@ -14,90 +15,106 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
14
15
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
15
16
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
16
17
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
17
|
-
import { Box, InvalidStateBox } from '@semcore/base-components';
|
|
18
|
-
import { ButtonLink } from '@semcore/button';
|
|
19
|
-
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
20
|
-
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
21
|
-
import { hasParent } from '@semcore/core/lib/utils/hasParent';
|
|
22
|
-
import CheckM from '@semcore/icon/Check/m';
|
|
23
|
-
import CloseM from '@semcore/icon/Close/m';
|
|
24
|
-
import InputNumber from '@semcore/input-number';
|
|
25
|
-
import Spin from '@semcore/spin';
|
|
26
18
|
import React from 'react';
|
|
19
|
+
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
20
|
+
import { Box, InvalidStateBox } from '@semcore/flex-box';
|
|
21
|
+
import autoFocusEnhance from '@semcore/utils/lib/enhances/autoFocusEnhance';
|
|
27
22
|
/*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
28
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
23
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___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)}", /*__inner_css_end__*/"ixtql_gg_"),
|
|
29
24
|
/*__reshadow_css_end__*/
|
|
30
25
|
{
|
|
31
|
-
"__SInlineInput": "
|
|
32
|
-
"_disabled": "
|
|
33
|
-
"__SUnderline": "
|
|
34
|
-
"__SAddon": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"__SCancelIcon": "
|
|
43
|
-
"_type_number": "
|
|
26
|
+
"__SInlineInput": "___SInlineInput_ixtql_gg_",
|
|
27
|
+
"_disabled": "__disabled_ixtql_gg_",
|
|
28
|
+
"__SUnderline": "___SUnderline_ixtql_gg_",
|
|
29
|
+
"__SAddon": "___SAddon_ixtql_gg_",
|
|
30
|
+
"_focused": "__focused_ixtql_gg_",
|
|
31
|
+
"_state_valid": "_state_valid_ixtql_gg_",
|
|
32
|
+
"_state_invalid": "_state_invalid_ixtql_gg_",
|
|
33
|
+
"__SValue": "___SValue_ixtql_gg_",
|
|
34
|
+
"__SControls": "___SControls_ixtql_gg_",
|
|
35
|
+
"__SInvalidPattern": "___SInvalidPattern_ixtql_gg_",
|
|
36
|
+
"__SConfirmIcon": "___SConfirmIcon_ixtql_gg_",
|
|
37
|
+
"__SCancelIcon": "___SCancelIcon_ixtql_gg_",
|
|
38
|
+
"_type_number": "_type_number_ixtql_gg_"
|
|
44
39
|
});
|
|
40
|
+
import CheckM from '@semcore/icon/Check/m';
|
|
41
|
+
import CloseM from '@semcore/icon/Close/m';
|
|
42
|
+
import Spin from '@semcore/spin';
|
|
43
|
+
import { ButtonLink } from '@semcore/button';
|
|
45
44
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
46
|
+
import InputNumber from '@semcore/input-number';
|
|
47
|
+
import { hasParent } from '@semcore/utils/lib/hasParent';
|
|
48
|
+
var pointInsideOfRect = function pointInsideOfRect(_ref17) {
|
|
49
|
+
var x = _ref17.x,
|
|
50
|
+
y = _ref17.y,
|
|
51
|
+
rect = _ref17.rect;
|
|
50
52
|
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
51
53
|
};
|
|
52
54
|
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
55
|
+
_inherits(InlineInputBase, _Component);
|
|
56
|
+
var _super = _createSuper(InlineInputBase);
|
|
53
57
|
function InlineInputBase() {
|
|
54
58
|
var _this;
|
|
55
59
|
_classCallCheck(this, InlineInputBase);
|
|
56
60
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
61
|
args[_key] = arguments[_key];
|
|
58
62
|
}
|
|
59
|
-
_this =
|
|
60
|
-
_defineProperty(_this, "
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_defineProperty(_this, "
|
|
64
|
-
_defineProperty(_this, "
|
|
65
|
-
_defineProperty(_this, "
|
|
63
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
65
|
+
focused: false
|
|
66
|
+
});
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "rootRef", /*#__PURE__*/React.createRef());
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "inputRef", /*#__PURE__*/React.createRef());
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "inputHandlersRef", /*#__PURE__*/React.createRef());
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "initValue", '');
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "lastMouseDownPosition", null);
|
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "lastHandledKeyboardEvent", -1);
|
|
73
|
+
_defineProperty(_assertThisInitialized(_this), "handleDocumentMouseDown", function (event) {
|
|
66
74
|
_this.lastMouseDownPosition = {
|
|
67
75
|
x: event.clientX,
|
|
68
76
|
y: event.clientY
|
|
69
77
|
};
|
|
70
78
|
_this.lastHandledKeyboardEvent = -1;
|
|
71
79
|
});
|
|
72
|
-
_defineProperty(_this, "handleDocumentKeyDown", function () {
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "handleDocumentKeyDown", function () {
|
|
73
81
|
_this.lastMouseDownPosition = null;
|
|
74
82
|
});
|
|
75
|
-
_defineProperty(_this, "increment", function (event) {
|
|
76
|
-
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3;
|
|
83
|
+
_defineProperty(_assertThisInitialized(_this), "increment", function (event) {
|
|
84
|
+
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
|
|
77
85
|
// https://stackoverflow.com/questions/68010124/safari-number-input-stepup-stepdown-not-functioning-with-empty-value
|
|
78
86
|
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';
|
|
79
|
-
(_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 0
|
|
87
|
+
(_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);
|
|
88
|
+
(_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);
|
|
80
89
|
});
|
|
81
|
-
_defineProperty(_this, "decrement", function (event) {
|
|
82
|
-
var _this$inputRef$
|
|
83
|
-
if (((_this$inputRef$
|
|
84
|
-
(_this$inputRef$
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "decrement", function (event) {
|
|
91
|
+
var _this$inputRef$curren5, _this$inputRef$curren6, _this$inputRef$curren7, _this$inputHandlersRe2, _this$inputRef$curren8;
|
|
92
|
+
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';
|
|
93
|
+
(_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);
|
|
94
|
+
(_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);
|
|
85
95
|
});
|
|
86
|
-
_defineProperty(_this, "
|
|
87
|
-
|
|
96
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerValueFocused", function (focused) {
|
|
97
|
+
return function () {
|
|
98
|
+
_this.setState({
|
|
99
|
+
focused: focused
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function (event) {
|
|
104
|
+
var _this$inputRef$curren9;
|
|
88
105
|
event.preventDefault();
|
|
89
|
-
(_this$inputRef$
|
|
106
|
+
(_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 ? void 0 : _this$inputRef$curren9.focus();
|
|
90
107
|
});
|
|
91
|
-
_defineProperty(_this, "handleConfirm", function (text, event) {
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "handleConfirm", function (text, event) {
|
|
92
109
|
var _this$asProps$onConfi, _this$asProps;
|
|
93
|
-
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0
|
|
110
|
+
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 ? void 0 : _this$asProps$onConfi.call(_this$asProps, text, event);
|
|
94
111
|
});
|
|
95
|
-
_defineProperty(_this, "handleCancel", function (prevText, event) {
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "handleCancel", function (prevText, event) {
|
|
96
113
|
var _this$asProps$onCance, _this$asProps2;
|
|
97
|
-
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0
|
|
114
|
+
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 ? void 0 : _this$asProps$onCance.call(_this$asProps2, prevText, event);
|
|
98
115
|
});
|
|
99
|
-
_defineProperty(_this, "handleBlur", function (event) {
|
|
100
|
-
var _this$inputRef$
|
|
116
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (event) {
|
|
117
|
+
var _this$inputRef$curren10, _this$inputRef$curren11;
|
|
101
118
|
var _this$asProps3 = _this.asProps,
|
|
102
119
|
onConfirm = _this$asProps3.onConfirm,
|
|
103
120
|
onCancel = _this$asProps3.onCancel,
|
|
@@ -118,41 +135,32 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
118
135
|
return;
|
|
119
136
|
}
|
|
120
137
|
}
|
|
121
|
-
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0
|
|
122
|
-
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0
|
|
138
|
+
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);
|
|
139
|
+
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
123
140
|
});
|
|
124
|
-
_defineProperty(_this, "handleKeyDown", function (event) {
|
|
141
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
|
|
125
142
|
var _this$asProps4 = _this.asProps,
|
|
126
143
|
onConfirm = _this$asProps4.onConfirm,
|
|
127
144
|
onCancel = _this$asProps4.onCancel;
|
|
128
145
|
if (event.key === 'Enter') {
|
|
129
|
-
var _this$inputRef$
|
|
130
|
-
onConfirm === null || onConfirm === void 0
|
|
146
|
+
var _this$inputRef$curren12, _this$inputRef$curren13;
|
|
147
|
+
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);
|
|
131
148
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
132
149
|
}
|
|
133
150
|
if (event.key === 'Escape') {
|
|
134
|
-
onCancel === null || onCancel === void 0
|
|
151
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this.initValue, event);
|
|
135
152
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
136
153
|
}
|
|
137
154
|
});
|
|
138
155
|
return _this;
|
|
139
156
|
}
|
|
140
|
-
|
|
141
|
-
return _createClass(InlineInputBase, [{
|
|
157
|
+
_createClass(InlineInputBase, [{
|
|
142
158
|
key: "componentDidMount",
|
|
143
159
|
value: function componentDidMount() {
|
|
144
|
-
this.updateInert();
|
|
145
160
|
if (!this.asProps.onBlurBehavior) return;
|
|
146
161
|
document.body.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
147
162
|
document.body.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
148
163
|
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "componentDidUpdate",
|
|
151
|
-
value: function componentDidUpdate(prevProps) {
|
|
152
|
-
if (prevProps.disabled !== this.asProps.disabled) {
|
|
153
|
-
this.updateInert();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
164
|
}, {
|
|
157
165
|
key: "componentWillUnmount",
|
|
158
166
|
value: function componentWillUnmount() {
|
|
@@ -170,11 +178,12 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
170
178
|
}, {
|
|
171
179
|
key: "getConfirmControlProps",
|
|
172
180
|
value: function getConfirmControlProps() {
|
|
181
|
+
var _this$inputRef$curren14;
|
|
173
182
|
var _this$asProps5 = this.asProps,
|
|
174
183
|
loading = _this$asProps5.loading,
|
|
175
184
|
getI18nText = _this$asProps5.getI18nText;
|
|
176
185
|
return {
|
|
177
|
-
|
|
186
|
+
value: (_this$inputRef$curren14 = this.inputRef.current) === null || _this$inputRef$curren14 === void 0 ? void 0 : _this$inputRef$curren14.value,
|
|
178
187
|
loading: loading,
|
|
179
188
|
onConfirm: this.handleConfirm,
|
|
180
189
|
getI18nText: getI18nText
|
|
@@ -202,7 +211,9 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
202
211
|
return {
|
|
203
212
|
ref: this.inputRef,
|
|
204
213
|
state: state,
|
|
205
|
-
onKeyDown: this.handleKeyDown
|
|
214
|
+
onKeyDown: this.handleKeyDown,
|
|
215
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
216
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
206
217
|
};
|
|
207
218
|
}
|
|
208
219
|
}, {
|
|
@@ -214,8 +225,11 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
214
225
|
return {
|
|
215
226
|
numberFormatter: numberFormatter,
|
|
216
227
|
inputRef: this.inputRef,
|
|
228
|
+
inputHandlerRefs: this.inputHandlersRef,
|
|
217
229
|
increment: this.increment,
|
|
218
|
-
decrement: this.decrement
|
|
230
|
+
decrement: this.decrement,
|
|
231
|
+
onFocus: this.bindHandlerValueFocused(true),
|
|
232
|
+
onBlur: this.bindHandlerValueFocused(false)
|
|
219
233
|
};
|
|
220
234
|
}
|
|
221
235
|
}, {
|
|
@@ -228,17 +242,6 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
228
242
|
getI18nText: getI18nText
|
|
229
243
|
};
|
|
230
244
|
}
|
|
231
|
-
}, {
|
|
232
|
-
key: "updateInert",
|
|
233
|
-
value: function updateInert() {
|
|
234
|
-
var disabled = this.asProps.disabled;
|
|
235
|
-
if (!this.rootRef.current) return;
|
|
236
|
-
if (disabled) {
|
|
237
|
-
this.rootRef.current.setAttribute('inert', '');
|
|
238
|
-
} else {
|
|
239
|
-
this.rootRef.current.removeAttribute('inert');
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
245
|
}, {
|
|
243
246
|
key: "render",
|
|
244
247
|
value: function render() {
|
|
@@ -251,12 +254,15 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
251
254
|
Children = _this$asProps7.Children,
|
|
252
255
|
styles = _this$asProps7.styles,
|
|
253
256
|
state = _this$asProps7.state;
|
|
257
|
+
var focused = this.state.focused;
|
|
254
258
|
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref8.cn("SInlineInput", _objectSpread({}, _assignProps({
|
|
255
259
|
"ref": this.rootRef,
|
|
260
|
+
"focused": focused,
|
|
256
261
|
"onBlur": this.handleBlur
|
|
257
262
|
}, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === 'invalid' && /*#__PURE__*/React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {}))));
|
|
258
263
|
}
|
|
259
264
|
}]);
|
|
265
|
+
return InlineInputBase;
|
|
260
266
|
}(Component);
|
|
261
267
|
_defineProperty(InlineInputBase, "displayName", 'InlineInput');
|
|
262
268
|
_defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
|
|
@@ -268,12 +274,13 @@ _defineProperty(InlineInputBase, "defaultProps", {
|
|
|
268
274
|
});
|
|
269
275
|
_defineProperty(InlineInputBase, "style", style);
|
|
270
276
|
var Value = /*#__PURE__*/function (_Component2) {
|
|
277
|
+
_inherits(Value, _Component2);
|
|
278
|
+
var _super2 = _createSuper(Value);
|
|
271
279
|
function Value() {
|
|
272
280
|
_classCallCheck(this, Value);
|
|
273
|
-
return
|
|
281
|
+
return _super2.apply(this, arguments);
|
|
274
282
|
}
|
|
275
|
-
|
|
276
|
-
return _createClass(Value, [{
|
|
283
|
+
_createClass(Value, [{
|
|
277
284
|
key: "uncontrolledProps",
|
|
278
285
|
value: function uncontrolledProps() {
|
|
279
286
|
return {
|
|
@@ -294,30 +301,32 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
294
301
|
}, _ref2))));
|
|
295
302
|
}
|
|
296
303
|
}]);
|
|
304
|
+
return Value;
|
|
297
305
|
}(Component);
|
|
298
306
|
_defineProperty(Value, "defaultProps", {
|
|
299
307
|
defaultValue: ''
|
|
300
308
|
});
|
|
301
|
-
|
|
309
|
+
_defineProperty(Value, "enhance", [autoFocusEnhance()]);
|
|
310
|
+
_defineProperty(Value, "hoistProps", ['disabled']);
|
|
311
|
+
var Addon = function Addon(props) {
|
|
302
312
|
var _ref3 = arguments[0],
|
|
303
|
-
|
|
313
|
+
_ref10;
|
|
304
314
|
var SAddon = Box;
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
function ConfirmControl(props) {
|
|
315
|
+
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
316
|
+
};
|
|
317
|
+
var ConfirmControl = function ConfirmControl(props) {
|
|
308
318
|
var _ref4 = arguments[0],
|
|
309
|
-
|
|
319
|
+
_ref12,
|
|
310
320
|
_props$title,
|
|
311
|
-
|
|
321
|
+
_ref18;
|
|
312
322
|
var SAddon = Box;
|
|
313
323
|
var Children = props.Children,
|
|
314
|
-
hasChildren = props.children
|
|
315
|
-
inputRef = props.inputRef;
|
|
324
|
+
hasChildren = props.children;
|
|
316
325
|
var title = (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : props.getI18nText('confirm');
|
|
317
326
|
var handleConfirm = React.useCallback(function (event) {
|
|
318
|
-
var _props$onConfirm,
|
|
319
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0
|
|
320
|
-
}, [props.onConfirm,
|
|
327
|
+
var _props$onConfirm, _props$value;
|
|
328
|
+
(_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);
|
|
329
|
+
}, [props.onConfirm, props.value]);
|
|
321
330
|
var handleKeydown = React.useCallback(function (event) {
|
|
322
331
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
323
332
|
event.preventDefault();
|
|
@@ -326,36 +335,36 @@ function ConfirmControl(props) {
|
|
|
326
335
|
}
|
|
327
336
|
}, [handleConfirm]);
|
|
328
337
|
if (props.loading) {
|
|
329
|
-
var
|
|
330
|
-
return
|
|
338
|
+
var _ref11;
|
|
339
|
+
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, _assignProps4({}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref11.cn("Spin", {
|
|
331
340
|
"size": 'xs'
|
|
332
341
|
})));
|
|
333
342
|
}
|
|
334
343
|
var sstyles = sstyled(props.styles);
|
|
335
344
|
var sConfirmIconStyles = sstyles.cn('SConfirmIcon', {});
|
|
336
|
-
return
|
|
345
|
+
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, _assignProps5({
|
|
337
346
|
"onKeyDown": handleKeydown
|
|
338
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
339
|
-
"addonLeft": (
|
|
347
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
|
|
348
|
+
"addonLeft": (_ref18 = props.icon) !== null && _ref18 !== void 0 ? _ref18 : CheckM,
|
|
340
349
|
"use": 'secondary',
|
|
341
350
|
"onClick": handleConfirm,
|
|
342
351
|
"className": sConfirmIconStyles.className,
|
|
343
352
|
"style": sConfirmIconStyles.style,
|
|
344
353
|
"aria-label": title
|
|
345
354
|
})));
|
|
346
|
-
}
|
|
347
|
-
function CancelControl(props) {
|
|
355
|
+
};
|
|
356
|
+
var CancelControl = function CancelControl(props) {
|
|
348
357
|
var _ref5 = arguments[0],
|
|
349
|
-
|
|
358
|
+
_ref14,
|
|
350
359
|
_props$title2,
|
|
351
|
-
|
|
360
|
+
_ref19;
|
|
352
361
|
var SAddon = Box;
|
|
353
362
|
var Children = props.Children,
|
|
354
363
|
hasChildren = props.children;
|
|
355
364
|
var title = (_props$title2 = props.title) !== null && _props$title2 !== void 0 ? _props$title2 : props.getI18nText('discard');
|
|
356
365
|
var handleCancel = React.useCallback(function (event) {
|
|
357
|
-
var _props$onCancel, _props$
|
|
358
|
-
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0
|
|
366
|
+
var _props$onCancel, _props$value2;
|
|
367
|
+
(_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);
|
|
359
368
|
}, [props.onCancel, props.value]);
|
|
360
369
|
var handleKeydown = React.useCallback(function (event) {
|
|
361
370
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
@@ -365,34 +374,33 @@ function CancelControl(props) {
|
|
|
365
374
|
}
|
|
366
375
|
}, [handleCancel]);
|
|
367
376
|
if (props.disabled) {
|
|
368
|
-
var
|
|
369
|
-
return
|
|
377
|
+
var _ref13;
|
|
378
|
+
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref13.cn("SAddon", _objectSpread({}, _assignProps6({}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref13.cn("CloseM", {})));
|
|
370
379
|
}
|
|
371
380
|
var sstyles = sstyled(props.styles);
|
|
372
381
|
var sCancelIconStyles = sstyles.cn('SCancelIcon', {});
|
|
373
|
-
return
|
|
382
|
+
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref14.cn("SAddon", _objectSpread({}, _assignProps7({
|
|
374
383
|
"onKeyDown": handleKeydown
|
|
375
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
384
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref14.cn("Children", {})) : /*#__PURE__*/React.createElement(ButtonLink, _ref14.cn("ButtonLink", {
|
|
376
385
|
"use": 'secondary',
|
|
377
|
-
"addonLeft": (
|
|
386
|
+
"addonLeft": (_ref19 = props.icon) !== null && _ref19 !== void 0 ? _ref19 : CloseM,
|
|
378
387
|
"onClick": handleCancel,
|
|
379
388
|
"className": sCancelIconStyles.className,
|
|
380
389
|
"style": sCancelIconStyles.style,
|
|
381
390
|
"aria-label": title
|
|
382
391
|
})));
|
|
383
|
-
}
|
|
384
|
-
function NumberValue(props) {
|
|
392
|
+
};
|
|
393
|
+
var NumberValue = function NumberValue(props) {
|
|
385
394
|
var _ref6 = arguments[0],
|
|
386
|
-
|
|
395
|
+
_ref15;
|
|
387
396
|
var SValue = InputNumber.Value;
|
|
388
|
-
return
|
|
389
|
-
}
|
|
390
|
-
;
|
|
397
|
+
return _ref15 = sstyled(props.styles), /*#__PURE__*/React.createElement(SValue, _ref15.cn("SValue", _objectSpread({}, _assignProps8({}, _ref6))));
|
|
398
|
+
};
|
|
391
399
|
function NumberControls(props) {
|
|
392
400
|
var _ref7 = arguments[0],
|
|
393
|
-
|
|
401
|
+
_ref16;
|
|
394
402
|
var SControls = InputNumber.Controls;
|
|
395
|
-
return
|
|
403
|
+
return _ref16 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref16.cn("SControls", _objectSpread({}, _assignProps9({
|
|
396
404
|
"tag": InlineInput.Addon
|
|
397
405
|
}, _ref7))));
|
|
398
406
|
}
|