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