@semcore/inline-input 4.48.2-prerelease.0 → 4.49.0-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/InlineInput.js +128 -139
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/index.js +2 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/index.type.js +2 -0
- package/lib/cjs/index.type.js.map +1 -0
- package/lib/cjs/style/inline-input.shadow.css +66 -69
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/InlineInput.js +122 -130
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/index.type.js +2 -0
- package/lib/es6/index.type.js.map +1 -0
- package/lib/es6/style/inline-input.shadow.css +66 -69
- 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 +123 -133
- package/lib/esm/style/inline-input.shadow.css +66 -69
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/types/InlineInput.d.ts +4 -0
- package/lib/types/index.d.ts +4 -162
- package/lib/types/index.type.d.ts +107 -0
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +58 -0
- package/package.json +11 -11
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
package/lib/es6/InlineInput.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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 _callSuper from "@babel/runtime/helpers/callSuper";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import { sstyled as _sstyled } from "@semcore/
|
|
7
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
8
|
import { assignProps as _assignProps9 } from "@semcore/core";
|
|
10
9
|
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
11
10
|
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
@@ -15,106 +14,90 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
15
14
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
16
15
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
17
16
|
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';
|
|
18
26
|
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';
|
|
22
27
|
/*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
23
|
-
var style = (
|
|
28
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SInlineInput_t1wpj_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_t1wpj_gg_ .___SConfirmIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-success, rgb(0, 190, 142));cursor:pointer}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_ .___SConfirmIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-success, rgb(0, 190, 142))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_ .___SConfirmIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-success, color(display-p3 0.33388 0.7337 0.56959))}}}@media (hover:hover){.___SInlineInput_t1wpj_gg_ .___SConfirmIcon_t1wpj_gg_:not(.__color_t1wpj_gg_):hover{color:var(--intergalactic-icon-secondary-success-hover-active, rgb(1, 176, 131))}}.___SInlineInput_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385));cursor:pointer}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_gg_){color:var(--intergalactic-icon-secondary-neutral, color(display-p3 0.0036 0.02041 0.00996 / 0.385))}}}@media (hover:hover){.___SInlineInput_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_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_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_gg_):hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, rgba(0, 5, 2, 0.433))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_ .___SCancelIcon_t1wpj_gg_:not(.__color_t1wpj_gg_):hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, color(display-p3 0.00333 0.01824 0.00791 / 0.433))}}}}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_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}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_:focus,.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_:focus-visible{outline:0}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, rgba(0, 5, 2, 0.457))}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_::placeholder{color:var(--intergalactic-text-placeholder, rgba(0, 5, 2, 0.457))}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_.__disabled_t1wpj_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_::-webkit-inner-spin-button,.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SInlineInput_t1wpj_gg_ .___SValue_t1wpj_gg_._type_number_t1wpj_gg_{-moz-appearance:textfield}.___SUnderline_t1wpj_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_t1wpj_gg_{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SUnderline_t1wpj_gg_{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SAddon_t1wpj_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_t1wpj_gg_{color:var(--intergalactic-icon-secondary-neutral, rgba(0, 5, 2, 0.385))}@media (color-gamut:p3){.___SAddon_t1wpj_gg_{color:var(--intergalactic-icon-secondary-neutral, color(display-p3 0.0036 0.02041 0.00996 / 0.385))}}}.___SAddon_t1wpj_gg_.__disabled_t1wpj_gg_,.___SInlineInput_t1wpj_gg_.__disabled_t1wpj_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);cursor:default;pointer-events:none}.___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386));outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}@supports (color:color(display-p3 0 0 0%)){.___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386))}@media (color-gamut:p3){.___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-info-active, color(display-p3 0.01805 0.08334 0.73488 / 0.386))}}}.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154))}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-success-active, color(display-p3 0.36013 0.78771 0.61714))}}}.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154));outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-success-active, rgb(0, 204, 154))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-success-active, color(display-p3 0.36013 0.78771 0.61714))}}}@supports (color:oklab(0%0 0%)){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){outline-color:var(--intergalactic-keyboard-focus-valid-outline, rgb(0, 190, 142))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_._state_valid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){outline-color:var(--intergalactic-keyboard-focus-valid-outline, oklch(0.711 0.146 166.9))}}}.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_{border-bottom-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56));outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}@supports (color:color(display-p3 0 0 0%)){.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-critical-active, rgba(255, 0, 4, 0.56))}@media (color-gamut:p3){.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-critical-active, color(display-p3 0.918 0.19866 0.14259 / 0.56))}}}@supports (color:oklab(0%0 0%)){.___SInlineInput_t1wpj_gg_._state_invalid_t1wpj_gg_ .___SUnderline_t1wpj_gg_:has(input:focus-visible){outline-color:var(--intergalactic-keyboard-focus-invalid-outline, oklch(0.628 0.257 28.9 / 0.652))}}.___SValue_t1wpj_gg_:focus~.___SControls_t1wpj_gg_{display:flex}.___SInvalidPattern_t1wpj_gg_{margin-left:-1px;margin-top:-1px;border-radius:0;height:calc(100% - 3px)}", /*__inner_css_end__*/"t1wpj_gg_"),
|
|
24
29
|
/*__reshadow_css_end__*/
|
|
25
30
|
{
|
|
26
|
-
"__SInlineInput": "
|
|
27
|
-
"_disabled": "
|
|
28
|
-
"__SUnderline": "
|
|
29
|
-
"__SAddon": "
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"__SCancelIcon": "
|
|
38
|
-
"_type_number": "
|
|
31
|
+
"__SInlineInput": "___SInlineInput_t1wpj_gg_",
|
|
32
|
+
"_disabled": "__disabled_t1wpj_gg_",
|
|
33
|
+
"__SUnderline": "___SUnderline_t1wpj_gg_",
|
|
34
|
+
"__SAddon": "___SAddon_t1wpj_gg_",
|
|
35
|
+
"_state_valid": "_state_valid_t1wpj_gg_",
|
|
36
|
+
"_state_invalid": "_state_invalid_t1wpj_gg_",
|
|
37
|
+
"__SValue": "___SValue_t1wpj_gg_",
|
|
38
|
+
"__SControls": "___SControls_t1wpj_gg_",
|
|
39
|
+
"__SInvalidPattern": "___SInvalidPattern_t1wpj_gg_",
|
|
40
|
+
"__SConfirmIcon": "___SConfirmIcon_t1wpj_gg_",
|
|
41
|
+
"_color": "__color_t1wpj_gg_",
|
|
42
|
+
"__SCancelIcon": "___SCancelIcon_t1wpj_gg_",
|
|
43
|
+
"_type_number": "_type_number_t1wpj_gg_"
|
|
39
44
|
});
|
|
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';
|
|
44
45
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var x = _ref17.x,
|
|
50
|
-
y = _ref17.y,
|
|
51
|
-
rect = _ref17.rect;
|
|
46
|
+
var pointInsideOfRect = function pointInsideOfRect(_ref15) {
|
|
47
|
+
var x = _ref15.x,
|
|
48
|
+
y = _ref15.y,
|
|
49
|
+
rect = _ref15.rect;
|
|
52
50
|
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
53
51
|
};
|
|
54
52
|
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
55
|
-
_inherits(InlineInputBase, _Component);
|
|
56
|
-
var _super = _createSuper(InlineInputBase);
|
|
57
53
|
function InlineInputBase() {
|
|
58
54
|
var _this;
|
|
59
55
|
_classCallCheck(this, InlineInputBase);
|
|
60
56
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
61
57
|
args[_key] = arguments[_key];
|
|
62
58
|
}
|
|
63
|
-
_this =
|
|
64
|
-
_defineProperty(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
_defineProperty(
|
|
68
|
-
_defineProperty(
|
|
69
|
-
_defineProperty(
|
|
70
|
-
_defineProperty(_assertThisInitialized(_this), "initValue", '');
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "lastMouseDownPosition", null);
|
|
72
|
-
_defineProperty(_assertThisInitialized(_this), "lastHandledKeyboardEvent", -1);
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "handleDocumentMouseDown", function (event) {
|
|
59
|
+
_this = _callSuper(this, InlineInputBase, [].concat(args));
|
|
60
|
+
_defineProperty(_this, "rootRef", /*#__PURE__*/React.createRef());
|
|
61
|
+
_defineProperty(_this, "inputRef", /*#__PURE__*/React.createRef());
|
|
62
|
+
_defineProperty(_this, "initValue", '');
|
|
63
|
+
_defineProperty(_this, "lastMouseDownPosition", null);
|
|
64
|
+
_defineProperty(_this, "lastHandledKeyboardEvent", -1);
|
|
65
|
+
_defineProperty(_this, "handleDocumentMouseDown", function (event) {
|
|
74
66
|
_this.lastMouseDownPosition = {
|
|
75
67
|
x: event.clientX,
|
|
76
68
|
y: event.clientY
|
|
77
69
|
};
|
|
78
70
|
_this.lastHandledKeyboardEvent = -1;
|
|
79
71
|
});
|
|
80
|
-
_defineProperty(
|
|
72
|
+
_defineProperty(_this, "handleDocumentKeyDown", function () {
|
|
81
73
|
_this.lastMouseDownPosition = null;
|
|
82
74
|
});
|
|
83
|
-
_defineProperty(
|
|
84
|
-
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3
|
|
75
|
+
_defineProperty(_this, "increment", function (event) {
|
|
76
|
+
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3;
|
|
85
77
|
// https://stackoverflow.com/questions/68010124/safari-number-input-stepup-stepdown-not-functioning-with-empty-value
|
|
86
78
|
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';
|
|
87
|
-
(_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 0
|
|
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);
|
|
79
|
+
(_this$inputRef$curren2 = _this.inputRef.current) === null || _this$inputRef$curren2 === void 0 || (_this$inputRef$curren3 = _this$inputRef$curren2.stepUp) === null || _this$inputRef$curren3 === void 0 || _this$inputRef$curren3.call(_this$inputRef$curren2, event);
|
|
89
80
|
});
|
|
90
|
-
_defineProperty(
|
|
91
|
-
var _this$inputRef$
|
|
92
|
-
if (((_this$inputRef$
|
|
93
|
-
(_this$inputRef$
|
|
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);
|
|
81
|
+
_defineProperty(_this, "decrement", function (event) {
|
|
82
|
+
var _this$inputRef$curren4, _this$inputRef$curren5, _this$inputRef$curren6;
|
|
83
|
+
if (((_this$inputRef$curren4 = _this.inputRef.current) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.value) === '') _this.inputRef.current.value = _this.inputRef.current.max || '0';
|
|
84
|
+
(_this$inputRef$curren5 = _this.inputRef.current) === null || _this$inputRef$curren5 === void 0 || (_this$inputRef$curren6 = _this$inputRef$curren5.stepDown) === null || _this$inputRef$curren6 === void 0 || _this$inputRef$curren6.call(_this$inputRef$curren5, event);
|
|
95
85
|
});
|
|
96
|
-
_defineProperty(
|
|
97
|
-
|
|
98
|
-
_this.setState({
|
|
99
|
-
focused: focused
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseDownAddon", function (event) {
|
|
104
|
-
var _this$inputRef$curren9;
|
|
86
|
+
_defineProperty(_this, "handleMouseDownAddon", function (event) {
|
|
87
|
+
var _this$inputRef$curren7;
|
|
105
88
|
event.preventDefault();
|
|
106
|
-
(_this$inputRef$
|
|
89
|
+
(_this$inputRef$curren7 = _this.inputRef.current) === null || _this$inputRef$curren7 === void 0 || _this$inputRef$curren7.focus();
|
|
107
90
|
});
|
|
108
|
-
_defineProperty(
|
|
91
|
+
_defineProperty(_this, "handleConfirm", function (text, event) {
|
|
109
92
|
var _this$asProps$onConfi, _this$asProps;
|
|
110
|
-
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0
|
|
93
|
+
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 || _this$asProps$onConfi.call(_this$asProps, text, event);
|
|
111
94
|
});
|
|
112
|
-
_defineProperty(
|
|
95
|
+
_defineProperty(_this, "handleCancel", function (prevText, event) {
|
|
113
96
|
var _this$asProps$onCance, _this$asProps2;
|
|
114
|
-
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0
|
|
97
|
+
(_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 || _this$asProps$onCance.call(_this$asProps2, prevText, event);
|
|
115
98
|
});
|
|
116
|
-
_defineProperty(
|
|
117
|
-
var _this$inputRef$
|
|
99
|
+
_defineProperty(_this, "handleBlur", function (event) {
|
|
100
|
+
var _this$inputRef$curren8, _this$inputRef$curren9;
|
|
118
101
|
var _this$asProps3 = _this.asProps,
|
|
119
102
|
onConfirm = _this$asProps3.onConfirm,
|
|
120
103
|
onCancel = _this$asProps3.onCancel,
|
|
@@ -135,32 +118,41 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
135
118
|
return;
|
|
136
119
|
}
|
|
137
120
|
}
|
|
138
|
-
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0
|
|
139
|
-
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0
|
|
121
|
+
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 || onConfirm((_this$inputRef$curren8 = (_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 ? void 0 : _this$inputRef$curren9.value) !== null && _this$inputRef$curren8 !== void 0 ? _this$inputRef$curren8 : '', event);
|
|
122
|
+
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 || onCancel(_this.initValue, event);
|
|
140
123
|
});
|
|
141
|
-
_defineProperty(
|
|
124
|
+
_defineProperty(_this, "handleKeyDown", function (event) {
|
|
142
125
|
var _this$asProps4 = _this.asProps,
|
|
143
126
|
onConfirm = _this$asProps4.onConfirm,
|
|
144
127
|
onCancel = _this$asProps4.onCancel;
|
|
145
128
|
if (event.key === 'Enter') {
|
|
146
|
-
var _this$inputRef$
|
|
147
|
-
onConfirm === null || onConfirm === void 0
|
|
129
|
+
var _this$inputRef$curren0, _this$inputRef$curren1;
|
|
130
|
+
onConfirm === null || onConfirm === void 0 || onConfirm((_this$inputRef$curren0 = (_this$inputRef$curren1 = _this.inputRef.current) === null || _this$inputRef$curren1 === void 0 ? void 0 : _this$inputRef$curren1.value) !== null && _this$inputRef$curren0 !== void 0 ? _this$inputRef$curren0 : '', event);
|
|
148
131
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
149
132
|
}
|
|
150
133
|
if (event.key === 'Escape') {
|
|
151
|
-
onCancel === null || onCancel === void 0
|
|
134
|
+
onCancel === null || onCancel === void 0 || onCancel(_this.initValue, event);
|
|
152
135
|
_this.lastHandledKeyboardEvent = Date.now();
|
|
153
136
|
}
|
|
154
137
|
});
|
|
155
138
|
return _this;
|
|
156
139
|
}
|
|
157
|
-
|
|
140
|
+
_inherits(InlineInputBase, _Component);
|
|
141
|
+
return _createClass(InlineInputBase, [{
|
|
158
142
|
key: "componentDidMount",
|
|
159
143
|
value: function componentDidMount() {
|
|
144
|
+
this.updateInert();
|
|
160
145
|
if (!this.asProps.onBlurBehavior) return;
|
|
161
146
|
document.body.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
162
147
|
document.body.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
163
148
|
}
|
|
149
|
+
}, {
|
|
150
|
+
key: "componentDidUpdate",
|
|
151
|
+
value: function componentDidUpdate(prevProps) {
|
|
152
|
+
if (prevProps.disabled !== this.asProps.disabled) {
|
|
153
|
+
this.updateInert();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
164
156
|
}, {
|
|
165
157
|
key: "componentWillUnmount",
|
|
166
158
|
value: function componentWillUnmount() {
|
|
@@ -178,12 +170,11 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
178
170
|
}, {
|
|
179
171
|
key: "getConfirmControlProps",
|
|
180
172
|
value: function getConfirmControlProps() {
|
|
181
|
-
var _this$inputRef$curren14;
|
|
182
173
|
var _this$asProps5 = this.asProps,
|
|
183
174
|
loading = _this$asProps5.loading,
|
|
184
175
|
getI18nText = _this$asProps5.getI18nText;
|
|
185
176
|
return {
|
|
186
|
-
|
|
177
|
+
inputRef: this.inputRef,
|
|
187
178
|
loading: loading,
|
|
188
179
|
onConfirm: this.handleConfirm,
|
|
189
180
|
getI18nText: getI18nText
|
|
@@ -211,9 +202,7 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
211
202
|
return {
|
|
212
203
|
ref: this.inputRef,
|
|
213
204
|
state: state,
|
|
214
|
-
onKeyDown: this.handleKeyDown
|
|
215
|
-
onFocus: this.bindHandlerValueFocused(true),
|
|
216
|
-
onBlur: this.bindHandlerValueFocused(false)
|
|
205
|
+
onKeyDown: this.handleKeyDown
|
|
217
206
|
};
|
|
218
207
|
}
|
|
219
208
|
}, {
|
|
@@ -225,11 +214,8 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
225
214
|
return {
|
|
226
215
|
numberFormatter: numberFormatter,
|
|
227
216
|
inputRef: this.inputRef,
|
|
228
|
-
inputHandlerRefs: this.inputHandlersRef,
|
|
229
217
|
increment: this.increment,
|
|
230
|
-
decrement: this.decrement
|
|
231
|
-
onFocus: this.bindHandlerValueFocused(true),
|
|
232
|
-
onBlur: this.bindHandlerValueFocused(false)
|
|
218
|
+
decrement: this.decrement
|
|
233
219
|
};
|
|
234
220
|
}
|
|
235
221
|
}, {
|
|
@@ -242,6 +228,17 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
242
228
|
getI18nText: getI18nText
|
|
243
229
|
};
|
|
244
230
|
}
|
|
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
|
+
}
|
|
245
242
|
}, {
|
|
246
243
|
key: "render",
|
|
247
244
|
value: function render() {
|
|
@@ -254,15 +251,12 @@ var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
|
254
251
|
Children = _this$asProps7.Children,
|
|
255
252
|
styles = _this$asProps7.styles,
|
|
256
253
|
state = _this$asProps7.state;
|
|
257
|
-
var focused = this.state.focused;
|
|
258
254
|
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref8.cn("SInlineInput", _objectSpread({}, _assignProps({
|
|
259
255
|
"ref": this.rootRef,
|
|
260
|
-
"focused": focused,
|
|
261
256
|
"onBlur": this.handleBlur
|
|
262
257
|
}, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === 'invalid' && /*#__PURE__*/React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {}))));
|
|
263
258
|
}
|
|
264
259
|
}]);
|
|
265
|
-
return InlineInputBase;
|
|
266
260
|
}(Component);
|
|
267
261
|
_defineProperty(InlineInputBase, "displayName", 'InlineInput');
|
|
268
262
|
_defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
|
|
@@ -274,13 +268,12 @@ _defineProperty(InlineInputBase, "defaultProps", {
|
|
|
274
268
|
});
|
|
275
269
|
_defineProperty(InlineInputBase, "style", style);
|
|
276
270
|
var Value = /*#__PURE__*/function (_Component2) {
|
|
277
|
-
_inherits(Value, _Component2);
|
|
278
|
-
var _super2 = _createSuper(Value);
|
|
279
271
|
function Value() {
|
|
280
272
|
_classCallCheck(this, Value);
|
|
281
|
-
return
|
|
273
|
+
return _callSuper(this, Value, arguments);
|
|
282
274
|
}
|
|
283
|
-
|
|
275
|
+
_inherits(Value, _Component2);
|
|
276
|
+
return _createClass(Value, [{
|
|
284
277
|
key: "uncontrolledProps",
|
|
285
278
|
value: function uncontrolledProps() {
|
|
286
279
|
return {
|
|
@@ -301,32 +294,30 @@ var Value = /*#__PURE__*/function (_Component2) {
|
|
|
301
294
|
}, _ref2))));
|
|
302
295
|
}
|
|
303
296
|
}]);
|
|
304
|
-
return Value;
|
|
305
297
|
}(Component);
|
|
306
298
|
_defineProperty(Value, "defaultProps", {
|
|
307
299
|
defaultValue: ''
|
|
308
300
|
});
|
|
309
|
-
|
|
310
|
-
_defineProperty(Value, "hoistProps", ['disabled']);
|
|
311
|
-
var Addon = function Addon(props) {
|
|
301
|
+
function Addon(props) {
|
|
312
302
|
var _ref3 = arguments[0],
|
|
313
|
-
|
|
303
|
+
_ref0;
|
|
314
304
|
var SAddon = Box;
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
|
|
305
|
+
return _ref0 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref0.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
306
|
+
}
|
|
307
|
+
function ConfirmControl(props) {
|
|
318
308
|
var _ref4 = arguments[0],
|
|
319
|
-
|
|
309
|
+
_ref10,
|
|
320
310
|
_props$title,
|
|
321
|
-
|
|
311
|
+
_ref16;
|
|
322
312
|
var SAddon = Box;
|
|
323
313
|
var Children = props.Children,
|
|
324
|
-
hasChildren = props.children
|
|
314
|
+
hasChildren = props.children,
|
|
315
|
+
inputRef = props.inputRef;
|
|
325
316
|
var title = (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : props.getI18nText('confirm');
|
|
326
317
|
var handleConfirm = React.useCallback(function (event) {
|
|
327
|
-
var _props$onConfirm,
|
|
328
|
-
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0
|
|
329
|
-
}, [props.onConfirm,
|
|
318
|
+
var _props$onConfirm, _inputRef$current$val, _inputRef$current;
|
|
319
|
+
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 || _props$onConfirm.call(props, (_inputRef$current$val = inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) !== null && _inputRef$current$val !== void 0 ? _inputRef$current$val : '', event);
|
|
320
|
+
}, [props.onConfirm, inputRef === null || inputRef === void 0 ? void 0 : inputRef.current]);
|
|
330
321
|
var handleKeydown = React.useCallback(function (event) {
|
|
331
322
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
332
323
|
event.preventDefault();
|
|
@@ -335,36 +326,36 @@ var ConfirmControl = function ConfirmControl(props) {
|
|
|
335
326
|
}
|
|
336
327
|
}, [handleConfirm]);
|
|
337
328
|
if (props.loading) {
|
|
338
|
-
var
|
|
339
|
-
return
|
|
329
|
+
var _ref1;
|
|
330
|
+
return _ref1 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref1.cn("SAddon", _objectSpread({}, _assignProps4({}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref1.cn("Spin", {
|
|
340
331
|
"size": 'xs'
|
|
341
332
|
})));
|
|
342
333
|
}
|
|
343
334
|
var sstyles = sstyled(props.styles);
|
|
344
335
|
var sConfirmIconStyles = sstyles.cn('SConfirmIcon', {});
|
|
345
|
-
return
|
|
336
|
+
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, _assignProps5({
|
|
346
337
|
"onKeyDown": handleKeydown
|
|
347
|
-
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
348
|
-
"addonLeft": (
|
|
338
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(ButtonLink, _ref10.cn("ButtonLink", {
|
|
339
|
+
"addonLeft": (_ref16 = props.icon) !== null && _ref16 !== void 0 ? _ref16 : CheckM,
|
|
349
340
|
"use": 'secondary',
|
|
350
341
|
"onClick": handleConfirm,
|
|
351
342
|
"className": sConfirmIconStyles.className,
|
|
352
343
|
"style": sConfirmIconStyles.style,
|
|
353
344
|
"aria-label": title
|
|
354
345
|
})));
|
|
355
|
-
}
|
|
356
|
-
|
|
346
|
+
}
|
|
347
|
+
function CancelControl(props) {
|
|
357
348
|
var _ref5 = arguments[0],
|
|
358
|
-
|
|
349
|
+
_ref12,
|
|
359
350
|
_props$title2,
|
|
360
|
-
|
|
351
|
+
_ref17;
|
|
361
352
|
var SAddon = Box;
|
|
362
353
|
var Children = props.Children,
|
|
363
354
|
hasChildren = props.children;
|
|
364
355
|
var title = (_props$title2 = props.title) !== null && _props$title2 !== void 0 ? _props$title2 : props.getI18nText('discard');
|
|
365
356
|
var handleCancel = React.useCallback(function (event) {
|
|
366
|
-
var _props$onCancel, _props$
|
|
367
|
-
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0
|
|
357
|
+
var _props$onCancel, _props$value;
|
|
358
|
+
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 || _props$onCancel.call(props, (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : '', event);
|
|
368
359
|
}, [props.onCancel, props.value]);
|
|
369
360
|
var handleKeydown = React.useCallback(function (event) {
|
|
370
361
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
@@ -374,33 +365,34 @@ var CancelControl = function CancelControl(props) {
|
|
|
374
365
|
}
|
|
375
366
|
}, [handleCancel]);
|
|
376
367
|
if (props.disabled) {
|
|
377
|
-
var
|
|
378
|
-
return
|
|
368
|
+
var _ref11;
|
|
369
|
+
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, _assignProps6({}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref11.cn("CloseM", {})));
|
|
379
370
|
}
|
|
380
371
|
var sstyles = sstyled(props.styles);
|
|
381
372
|
var sCancelIconStyles = sstyles.cn('SCancelIcon', {});
|
|
382
|
-
return
|
|
373
|
+
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, _assignProps7({
|
|
383
374
|
"onKeyDown": handleKeydown
|
|
384
|
-
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children,
|
|
375
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
|
|
385
376
|
"use": 'secondary',
|
|
386
|
-
"addonLeft": (
|
|
377
|
+
"addonLeft": (_ref17 = props.icon) !== null && _ref17 !== void 0 ? _ref17 : CloseM,
|
|
387
378
|
"onClick": handleCancel,
|
|
388
379
|
"className": sCancelIconStyles.className,
|
|
389
380
|
"style": sCancelIconStyles.style,
|
|
390
381
|
"aria-label": title
|
|
391
382
|
})));
|
|
392
|
-
}
|
|
393
|
-
|
|
383
|
+
}
|
|
384
|
+
function NumberValue(props) {
|
|
394
385
|
var _ref6 = arguments[0],
|
|
395
|
-
|
|
386
|
+
_ref13;
|
|
396
387
|
var SValue = InputNumber.Value;
|
|
397
|
-
return
|
|
398
|
-
}
|
|
388
|
+
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SValue, _ref13.cn("SValue", _objectSpread({}, _assignProps8({}, _ref6))));
|
|
389
|
+
}
|
|
390
|
+
;
|
|
399
391
|
function NumberControls(props) {
|
|
400
392
|
var _ref7 = arguments[0],
|
|
401
|
-
|
|
393
|
+
_ref14;
|
|
402
394
|
var SControls = InputNumber.Controls;
|
|
403
|
-
return
|
|
395
|
+
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref14.cn("SControls", _objectSpread({}, _assignProps9({
|
|
404
396
|
"tag": InlineInput.Addon
|
|
405
397
|
}, _ref7))));
|
|
406
398
|
}
|