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