@semcore/inline-input 16.2.2-prerelease.1 → 17.0.0-prerelease.17

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,15 +1,9 @@
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 _callSuper from "@babel/runtime/helpers/esm/callSuper";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
2
+ import { createComponent, sstyled, Component, assignProps } from "@semcore/core";
3
+ import { Box, InvalidStateBox } from "@semcore/base-components";
8
4
  import { ButtonLink } from "@semcore/button";
9
- import autoFocusEnhance from "@semcore/core/lib/utils/enhances/autoFocusEnhance";
10
5
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
11
6
  import { hasParent } from "@semcore/core/lib/utils/hasParent";
12
- import { Box, InvalidStateBox } from "@semcore/flex-box";
13
7
  import CheckM from "@semcore/icon/Check/m";
14
8
  import CloseM from "@semcore/icon/Close/m";
15
9
  import InputNumber from "@semcore/input-number";
@@ -17,91 +11,93 @@ import Spin from "@semcore/spin";
17
11
  import React from "react";
18
12
  import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
19
13
  /*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
20
- var style = (
14
+ const style = (
21
15
  /*__reshadow_css_start__*/
22
16
  (sstyled.insert(
23
17
  /*__inner_css_start__*/
24
- ".___SInlineInput_10nzu_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_10nzu_gg_ .___SConfirmIcon_10nzu_gg_{color:var(--intergalactic-icon-secondary-success, #00c192);cursor:pointer}@media (hover:hover){.___SInlineInput_10nzu_gg_ .___SConfirmIcon_10nzu_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, #049B75)}}.___SInlineInput_10nzu_gg_ .___SCancelIcon_10nzu_gg_{color:var(--intergalactic-icon-secondary-neutral, #a9abb6);cursor:pointer}@media (hover:hover){.___SInlineInput_10nzu_gg_ .___SCancelIcon_10nzu_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_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}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_:focus,.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_:focus-visible{outline:0}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_::placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_.__disabled_10nzu_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_::-webkit-inner-spin-button,.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SInlineInput_10nzu_gg_ .___SValue_10nzu_gg_._type_number_10nzu_gg_{-moz-appearance:textfield}.___SUnderline_10nzu_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_10nzu_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_10nzu_gg_.__disabled_10nzu_gg_,.___SInlineInput_10nzu_gg_.__disabled_10nzu_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SUnderline_10nzu_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-info-active, #006dca);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}.___SInlineInput_10nzu_gg_._state_valid_10nzu_gg_ .___SUnderline_10nzu_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65)}.___SInlineInput_10nzu_gg_._state_valid_10nzu_gg_ .___SUnderline_10nzu_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-success-active, #007c65);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;outline-color:var(--intergalactic-keyboard-focus-valid-outline, #009f81)}.___SInlineInput_10nzu_gg_._state_invalid_10nzu_gg_ .___SUnderline_10nzu_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f)}.___SInlineInput_10nzu_gg_._state_invalid_10nzu_gg_ .___SUnderline_10nzu_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-critical-active, #d1002f);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;outline-color:var(--intergalactic-keyboard-focus-invalid-outline, #ff4953)}.___SValue_10nzu_gg_:focus~.___SControls_10nzu_gg_{display:flex}.___SInvalidPattern_10nzu_gg_{margin-left:-1px;margin-top:-1px;border-radius:0;height:calc(100% - 3px)}",
18
+ ".___SInlineInput_mw77c_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_mw77c_gg_ .___SConfirmIcon_mw77c_gg_{color:var(--intergalactic-icon-secondary-success, #00c192);cursor:pointer}@media (hover:hover){.___SInlineInput_mw77c_gg_ .___SConfirmIcon_mw77c_gg_:hover{color:var(--intergalactic-icon-secondary-success-hover-active, #049B75)}}.___SInlineInput_mw77c_gg_ .___SCancelIcon_mw77c_gg_{color:var(--intergalactic-icon-secondary-neutral, #a9abb6);cursor:pointer}@media (hover:hover){.___SInlineInput_mw77c_gg_ .___SCancelIcon_mw77c_gg_:hover{color:var(--intergalactic-icon-secondary-neutral-hover-active, #878992)}}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_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}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_:focus,.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_:focus-visible{outline:0}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_::-moz-placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_::placeholder{color:var(--intergalactic-text-placeholder, #8a8e9b)}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_.__disabled_mw77c_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_::-webkit-inner-spin-button,.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.___SInlineInput_mw77c_gg_ .___SValue_mw77c_gg_._type_number_mw77c_gg_{-moz-appearance:textfield}.___SUnderline_mw77c_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_mw77c_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_mw77c_gg_.__disabled_mw77c_gg_,.___SInlineInput_mw77c_gg_.__disabled_mw77c_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SUnderline_mw77c_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-info-active, #006dca);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}.___SInlineInput_mw77c_gg_._state_valid_mw77c_gg_ .___SUnderline_mw77c_gg_{border-bottom-color:var(--intergalactic-border-success-active, #007c65)}.___SInlineInput_mw77c_gg_._state_valid_mw77c_gg_ .___SUnderline_mw77c_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-success-active, #007c65);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;outline-color:var(--intergalactic-keyboard-focus-valid-outline, #009f81)}.___SInlineInput_mw77c_gg_._state_invalid_mw77c_gg_ .___SUnderline_mw77c_gg_{border-bottom-color:var(--intergalactic-border-critical-active, #d1002f)}.___SInlineInput_mw77c_gg_._state_invalid_mw77c_gg_ .___SUnderline_mw77c_gg_:has(input:focus-visible){border-bottom-color:var(--intergalactic-border-critical-active, #d1002f);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;outline-color:var(--intergalactic-keyboard-focus-invalid-outline, #ff4953)}.___SValue_mw77c_gg_:focus~.___SControls_mw77c_gg_{display:flex}.___SInvalidPattern_mw77c_gg_{margin-left:-1px;margin-top:-1px;border-radius:0;height:calc(100% - 3px)}",
25
19
  /*__inner_css_end__*/
26
- "10nzu_gg_"
20
+ "mw77c_gg_"
27
21
  ), /*__reshadow_css_end__*/
28
22
  {
29
- "__SInlineInput": "___SInlineInput_10nzu_gg_",
30
- "_disabled": "__disabled_10nzu_gg_",
31
- "__SUnderline": "___SUnderline_10nzu_gg_",
32
- "__SAddon": "___SAddon_10nzu_gg_",
33
- "_state_valid": "_state_valid_10nzu_gg_",
34
- "_state_invalid": "_state_invalid_10nzu_gg_",
35
- "__SValue": "___SValue_10nzu_gg_",
36
- "__SControls": "___SControls_10nzu_gg_",
37
- "__SInvalidPattern": "___SInvalidPattern_10nzu_gg_",
38
- "__SConfirmIcon": "___SConfirmIcon_10nzu_gg_",
39
- "__SCancelIcon": "___SCancelIcon_10nzu_gg_",
40
- "_type_number": "_type_number_10nzu_gg_"
23
+ "__SInlineInput": "___SInlineInput_mw77c_gg_",
24
+ "_disabled": "__disabled_mw77c_gg_",
25
+ "__SUnderline": "___SUnderline_mw77c_gg_",
26
+ "__SAddon": "___SAddon_mw77c_gg_",
27
+ "_state_valid": "_state_valid_mw77c_gg_",
28
+ "_state_invalid": "_state_invalid_mw77c_gg_",
29
+ "__SValue": "___SValue_mw77c_gg_",
30
+ "__SControls": "___SControls_mw77c_gg_",
31
+ "__SInvalidPattern": "___SInvalidPattern_mw77c_gg_",
32
+ "__SConfirmIcon": "___SConfirmIcon_mw77c_gg_",
33
+ "__SCancelIcon": "___SCancelIcon_mw77c_gg_",
34
+ "_type_number": "_type_number_mw77c_gg_"
41
35
  })
42
36
  );
43
- var pointInsideOfRect = function pointInsideOfRect2(_ref15) {
44
- var x = _ref15.x, y = _ref15.y, rect = _ref15.rect;
37
+ const pointInsideOfRect = ({
38
+ x,
39
+ y,
40
+ rect
41
+ }) => {
45
42
  return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
46
43
  };
47
- var InlineInputBase = /* @__PURE__ */ (function(_Component) {
48
- function InlineInputBase2() {
49
- var _this;
50
- _classCallCheck(this, InlineInputBase2);
51
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
52
- args[_key] = arguments[_key];
53
- }
54
- _this = _callSuper(this, InlineInputBase2, [].concat(args));
55
- _defineProperty(_this, "rootRef", /* @__PURE__ */ React.createRef());
56
- _defineProperty(_this, "inputRef", /* @__PURE__ */ React.createRef());
57
- _defineProperty(_this, "inputHandlersRef", /* @__PURE__ */ React.createRef());
58
- _defineProperty(_this, "initValue", "");
59
- _defineProperty(_this, "lastMouseDownPosition", null);
60
- _defineProperty(_this, "lastHandledKeyboardEvent", -1);
61
- _defineProperty(_this, "handleDocumentMouseDown", function(event) {
62
- _this.lastMouseDownPosition = {
44
+ class InlineInputBase extends Component {
45
+ constructor(...args) {
46
+ super(...args);
47
+ _defineProperty(this, "rootRef", /* @__PURE__ */ React.createRef());
48
+ _defineProperty(this, "inputRef", /* @__PURE__ */ React.createRef());
49
+ _defineProperty(this, "initValue", "");
50
+ _defineProperty(this, "lastMouseDownPosition", null);
51
+ _defineProperty(this, "lastHandledKeyboardEvent", -1);
52
+ _defineProperty(this, "handleDocumentMouseDown", (event) => {
53
+ this.lastMouseDownPosition = {
63
54
  x: event.clientX,
64
55
  y: event.clientY
65
56
  };
66
- _this.lastHandledKeyboardEvent = -1;
57
+ this.lastHandledKeyboardEvent = -1;
67
58
  });
68
- _defineProperty(_this, "handleDocumentKeyDown", function() {
69
- _this.lastMouseDownPosition = null;
59
+ _defineProperty(this, "handleDocumentKeyDown", () => {
60
+ this.lastMouseDownPosition = null;
70
61
  });
71
- _defineProperty(_this, "increment", function(event) {
72
- var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
73
- 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";
74
- (_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);
75
- (_this$inputHandlersRe = _this.inputHandlersRef.current) === null || _this$inputHandlersRe === void 0 || _this$inputHandlersRe.value((_this$inputRef$curren4 = _this.inputRef.current) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.value, event);
62
+ _defineProperty(this, "increment", (event) => {
63
+ var _a, _b, _c;
64
+ if (((_a = this.inputRef.current) == null ? void 0 : _a.value) === "") this.inputRef.current.value = this.inputRef.current.min || "0";
65
+ (_c = (_b = this.inputRef.current) == null ? void 0 : _b.stepUp) == null ? void 0 : _c.call(_b, event);
76
66
  });
77
- _defineProperty(_this, "decrement", function(event) {
78
- var _this$inputRef$curren5, _this$inputRef$curren6, _this$inputRef$curren7, _this$inputHandlersRe2, _this$inputRef$curren8;
79
- 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";
80
- (_this$inputRef$curren6 = _this.inputRef.current) === null || _this$inputRef$curren6 === void 0 || (_this$inputRef$curren7 = _this$inputRef$curren6.stepDown) === null || _this$inputRef$curren7 === void 0 || _this$inputRef$curren7.call(_this$inputRef$curren6, event);
81
- (_this$inputHandlersRe2 = _this.inputHandlersRef.current) === null || _this$inputHandlersRe2 === void 0 || _this$inputHandlersRe2.value((_this$inputRef$curren8 = _this.inputRef.current) === null || _this$inputRef$curren8 === void 0 ? void 0 : _this$inputRef$curren8.value, event);
67
+ _defineProperty(this, "decrement", (event) => {
68
+ var _a, _b, _c;
69
+ if (((_a = this.inputRef.current) == null ? void 0 : _a.value) === "") this.inputRef.current.value = this.inputRef.current.max || "0";
70
+ (_c = (_b = this.inputRef.current) == null ? void 0 : _b.stepDown) == null ? void 0 : _c.call(_b, event);
82
71
  });
83
- _defineProperty(_this, "handleMouseDownAddon", function(event) {
84
- var _this$inputRef$curren9;
72
+ _defineProperty(this, "handleMouseDownAddon", (event) => {
73
+ var _a;
85
74
  event.preventDefault();
86
- (_this$inputRef$curren9 = _this.inputRef.current) === null || _this$inputRef$curren9 === void 0 || _this$inputRef$curren9.focus();
75
+ (_a = this.inputRef.current) == null ? void 0 : _a.focus();
87
76
  });
88
- _defineProperty(_this, "handleConfirm", function(text, event) {
89
- var _this$asProps$onConfi, _this$asProps;
90
- (_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 || _this$asProps$onConfi.call(_this$asProps, text, event);
77
+ _defineProperty(this, "handleConfirm", (text, event) => {
78
+ var _a, _b;
79
+ (_b = (_a = this.asProps).onConfirm) == null ? void 0 : _b.call(_a, text, event);
91
80
  });
92
- _defineProperty(_this, "handleCancel", function(prevText, event) {
93
- var _this$asProps$onCance, _this$asProps2;
94
- (_this$asProps$onCance = (_this$asProps2 = _this.asProps).onCancel) === null || _this$asProps$onCance === void 0 || _this$asProps$onCance.call(_this$asProps2, prevText, event);
81
+ _defineProperty(this, "handleCancel", (prevText, event) => {
82
+ var _a, _b;
83
+ (_b = (_a = this.asProps).onCancel) == null ? void 0 : _b.call(_a, prevText, event);
95
84
  });
96
- _defineProperty(_this, "handleBlur", function(event) {
97
- var _this$inputRef$curren0, _this$inputRef$curren1;
98
- var _this$asProps3 = _this.asProps, onConfirm = _this$asProps3.onConfirm, onCancel = _this$asProps3.onCancel, onBlurBehavior = _this$asProps3.onBlurBehavior;
85
+ _defineProperty(this, "handleBlur", (event) => {
86
+ var _a;
87
+ const {
88
+ onConfirm,
89
+ onCancel,
90
+ onBlurBehavior
91
+ } = this.asProps;
99
92
  if (!onBlurBehavior) return;
100
- if (Date.now() - _this.lastHandledKeyboardEvent < 250) return;
101
- if (hasParent(event.relatedTarget, _this.rootRef.current)) return;
102
- if (_this.lastMouseDownPosition && _this.rootRef.current) {
103
- var _this$lastMouseDownPo = _this.lastMouseDownPosition, x = _this$lastMouseDownPo.x, y = _this$lastMouseDownPo.y;
104
- var rect = _this.rootRef.current.getBoundingClientRect();
93
+ if (Date.now() - this.lastHandledKeyboardEvent < 250) return;
94
+ if (hasParent(event.relatedTarget, this.rootRef.current)) return;
95
+ if (this.lastMouseDownPosition && this.rootRef.current) {
96
+ const {
97
+ x,
98
+ y
99
+ } = this.lastMouseDownPosition;
100
+ const rect = this.rootRef.current.getBoundingClientRect();
105
101
  if (pointInsideOfRect({
106
102
  x,
107
103
  y,
@@ -110,136 +106,132 @@ var InlineInputBase = /* @__PURE__ */ (function(_Component) {
110
106
  return;
111
107
  }
112
108
  }
113
- if (onBlurBehavior === "confirm") 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);
114
- if (onBlurBehavior === "cancel") onCancel === null || onCancel === void 0 || onCancel(_this.initValue, event);
109
+ if (onBlurBehavior === "confirm") onConfirm == null ? void 0 : onConfirm(((_a = this.inputRef.current) == null ? void 0 : _a.value) ?? "", event);
110
+ if (onBlurBehavior === "cancel") onCancel == null ? void 0 : onCancel(this.initValue, event);
115
111
  });
116
- _defineProperty(_this, "handleKeyDown", function(event) {
117
- var _this$asProps4 = _this.asProps, onConfirm = _this$asProps4.onConfirm, onCancel = _this$asProps4.onCancel;
112
+ _defineProperty(this, "handleKeyDown", (event) => {
113
+ var _a;
114
+ const {
115
+ onConfirm,
116
+ onCancel
117
+ } = this.asProps;
118
118
  if (event.key === "Enter") {
119
- var _this$inputRef$curren10, _this$inputRef$curren11;
120
- onConfirm === null || onConfirm === 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);
121
- _this.lastHandledKeyboardEvent = Date.now();
119
+ onConfirm == null ? void 0 : onConfirm(((_a = this.inputRef.current) == null ? void 0 : _a.value) ?? "", event);
120
+ this.lastHandledKeyboardEvent = Date.now();
122
121
  }
123
122
  if (event.key === "Escape") {
124
- onCancel === null || onCancel === void 0 || onCancel(_this.initValue, event);
125
- _this.lastHandledKeyboardEvent = Date.now();
123
+ onCancel == null ? void 0 : onCancel(this.initValue, event);
124
+ this.lastHandledKeyboardEvent = Date.now();
126
125
  }
127
126
  });
128
- return _this;
129
127
  }
130
- _inherits(InlineInputBase2, _Component);
131
- return _createClass(InlineInputBase2, [{
132
- key: "componentDidMount",
133
- value: function componentDidMount() {
128
+ componentDidMount() {
129
+ this.updateInert();
130
+ if (!this.asProps.onBlurBehavior) return;
131
+ document.body.addEventListener("mousedown", this.handleDocumentMouseDown);
132
+ document.body.addEventListener("keydown", this.handleDocumentKeyDown);
133
+ }
134
+ componentDidUpdate(prevProps) {
135
+ if (prevProps.disabled !== this.asProps.disabled) {
134
136
  this.updateInert();
135
- if (!this.asProps.onBlurBehavior) return;
136
- document.body.addEventListener("mousedown", this.handleDocumentMouseDown);
137
- document.body.addEventListener("keydown", this.handleDocumentKeyDown);
138
- }
139
- }, {
140
- key: "componentDidUpdate",
141
- value: function componentDidUpdate(prevProps) {
142
- if (prevProps.disabled !== this.asProps.disabled) {
143
- this.updateInert();
144
- }
145
- }
146
- }, {
147
- key: "componentWillUnmount",
148
- value: function componentWillUnmount() {
149
- if (!this.asProps.onBlurBehavior) return;
150
- document.body.removeEventListener("mousedown", this.handleDocumentMouseDown);
151
- document.body.removeEventListener("keydown", this.handleDocumentKeyDown);
152
- }
153
- }, {
154
- key: "getAddonProps",
155
- value: function getAddonProps() {
156
- return {
157
- onMouseDown: this.handleMouseDownAddon
158
- };
159
- }
160
- }, {
161
- key: "getConfirmControlProps",
162
- value: function getConfirmControlProps() {
163
- var _this$asProps5 = this.asProps, loading = _this$asProps5.loading, getI18nText = _this$asProps5.getI18nText;
164
- return {
165
- inputRef: this.inputRef,
166
- loading,
167
- onConfirm: this.handleConfirm,
168
- getI18nText
169
- };
170
- }
171
- }, {
172
- key: "getCancelControlProps",
173
- value: function getCancelControlProps() {
174
- var _this$asProps6 = this.asProps, loading = _this$asProps6.loading, disabled = _this$asProps6.disabled, getI18nText = _this$asProps6.getI18nText;
175
- return {
176
- value: this.initValue,
177
- // because double disabled(root disabled and addon disabled)
178
- disabled: loading && !disabled,
179
- onCancel: this.handleCancel,
180
- getI18nText
181
- };
182
137
  }
183
- }, {
184
- key: "getValueProps",
185
- value: function getValueProps() {
186
- var state = this.asProps.state;
187
- return {
188
- ref: this.inputRef,
189
- state,
190
- onKeyDown: this.handleKeyDown
191
- };
192
- }
193
- }, {
194
- key: "getNumberValueProps",
195
- value: function getNumberValueProps() {
196
- var numberFormatter = new Intl.NumberFormat(this.asProps.locale, {
197
- style: "decimal"
198
- });
199
- return {
200
- numberFormatter,
201
- inputRef: this.inputRef,
202
- inputHandlerRefs: this.inputHandlersRef,
203
- increment: this.increment,
204
- decrement: this.decrement
205
- };
206
- }
207
- }, {
208
- key: "getNumberControlsProps",
209
- value: function getNumberControlsProps() {
210
- var getI18nText = this.asProps.getI18nText;
211
- return {
212
- increment: this.increment,
213
- decrement: this.decrement,
214
- getI18nText
215
- };
216
- }
217
- }, {
218
- key: "updateInert",
219
- value: function updateInert() {
220
- var disabled = this.asProps.disabled;
221
- if (!this.rootRef.current) return;
222
- if (disabled) {
223
- this.rootRef.current.setAttribute("inert", "");
224
- } else {
225
- this.rootRef.current.removeAttribute("inert");
226
- }
138
+ }
139
+ componentWillUnmount() {
140
+ if (!this.asProps.onBlurBehavior) return;
141
+ document.body.removeEventListener("mousedown", this.handleDocumentMouseDown);
142
+ document.body.removeEventListener("keydown", this.handleDocumentKeyDown);
143
+ }
144
+ getAddonProps() {
145
+ return {
146
+ onMouseDown: this.handleMouseDownAddon
147
+ };
148
+ }
149
+ getConfirmControlProps() {
150
+ const {
151
+ loading,
152
+ getI18nText
153
+ } = this.asProps;
154
+ return {
155
+ inputRef: this.inputRef,
156
+ loading,
157
+ onConfirm: this.handleConfirm,
158
+ getI18nText
159
+ };
160
+ }
161
+ getCancelControlProps() {
162
+ const {
163
+ loading,
164
+ disabled,
165
+ getI18nText
166
+ } = this.asProps;
167
+ return {
168
+ value: this.initValue,
169
+ // because double disabled(root disabled and addon disabled)
170
+ disabled: loading && !disabled,
171
+ onCancel: this.handleCancel,
172
+ getI18nText
173
+ };
174
+ }
175
+ getValueProps() {
176
+ const {
177
+ state
178
+ } = this.asProps;
179
+ return {
180
+ ref: this.inputRef,
181
+ state,
182
+ onKeyDown: this.handleKeyDown
183
+ };
184
+ }
185
+ getNumberValueProps() {
186
+ const numberFormatter = new Intl.NumberFormat(this.asProps.locale, {
187
+ style: "decimal"
188
+ });
189
+ return {
190
+ numberFormatter,
191
+ inputRef: this.inputRef,
192
+ increment: this.increment,
193
+ decrement: this.decrement
194
+ };
195
+ }
196
+ getNumberControlsProps() {
197
+ const {
198
+ getI18nText
199
+ } = this.asProps;
200
+ return {
201
+ increment: this.increment,
202
+ decrement: this.decrement,
203
+ getI18nText
204
+ };
205
+ }
206
+ updateInert() {
207
+ const {
208
+ disabled
209
+ } = this.asProps;
210
+ if (!this.rootRef.current) return;
211
+ if (disabled) {
212
+ this.rootRef.current.setAttribute("inert", "");
213
+ } else {
214
+ this.rootRef.current.removeAttribute("inert");
227
215
  }
228
- }, {
229
- key: "render",
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
- return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SInlineInput, _ref8.cn("SInlineInput", _objectSpread({}, assignProps({
216
+ }
217
+ render() {
218
+ var _ref = this.asProps, _ref8;
219
+ const SInlineInput = Box;
220
+ const SUnderline = "div";
221
+ const SInvalidPattern = InvalidStateBox;
222
+ const {
223
+ Children,
224
+ styles,
225
+ state
226
+ } = this.asProps;
227
+ return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SInlineInput, _ref8.cn("SInlineInput", {
228
+ ...assignProps({
237
229
  "ref": this.rootRef,
238
230
  "onBlur": this.handleBlur
239
- }, _ref))), /* @__PURE__ */ React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === "invalid" && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}))));
240
- }
241
- }]);
242
- })(Component);
231
+ }, _ref)
232
+ }), /* @__PURE__ */ React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === "invalid" && /* @__PURE__ */ React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {}))));
233
+ }
234
+ }
243
235
  _defineProperty(InlineInputBase, "displayName", "InlineInput");
244
236
  _defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
245
237
  _defineProperty(InlineInputBase, "defaultProps", {
@@ -249,53 +241,47 @@ _defineProperty(InlineInputBase, "defaultProps", {
249
241
  locale: "en"
250
242
  });
251
243
  _defineProperty(InlineInputBase, "style", style);
252
- var Value = /* @__PURE__ */ (function(_Component2) {
253
- function Value2() {
254
- _classCallCheck(this, Value2);
255
- return _callSuper(this, Value2, arguments);
244
+ class Value extends Component {
245
+ uncontrolledProps() {
246
+ return {
247
+ value: (event) => event.target.value
248
+ };
256
249
  }
257
- _inherits(Value2, _Component2);
258
- return _createClass(Value2, [{
259
- key: "uncontrolledProps",
260
- value: function uncontrolledProps() {
261
- return {
262
- value: function value(event) {
263
- return event.target.value;
264
- }
265
- };
266
- }
267
- }, {
268
- key: "render",
269
- value: function render() {
270
- var _ref2 = this.asProps, _ref9;
271
- var SValue = Box;
272
- return _ref9 = sstyled(this.asProps.styles), /* @__PURE__ */ React.createElement(SValue, _ref9.cn("SValue", _objectSpread({}, assignProps({
250
+ render() {
251
+ var _ref2 = this.asProps, _ref9;
252
+ const SValue = Box;
253
+ return _ref9 = sstyled(this.asProps.styles), /* @__PURE__ */ React.createElement(SValue, _ref9.cn("SValue", {
254
+ ...assignProps({
273
255
  "tag": "input",
274
256
  "type": "text"
275
- }, _ref2))));
276
- }
277
- }]);
278
- })(Component);
257
+ }, _ref2)
258
+ }));
259
+ }
260
+ }
279
261
  _defineProperty(Value, "defaultProps", {
280
262
  defaultValue: ""
281
263
  });
282
- _defineProperty(Value, "enhance", [autoFocusEnhance()]);
283
- _defineProperty(Value, "hoistProps", ["disabled"]);
284
- var Addon = function Addon2(props) {
264
+ function Addon(props) {
285
265
  var _ref3 = arguments[0], _ref0;
286
- var SAddon = Box;
287
- return _ref0 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref0.cn("SAddon", _objectSpread({}, assignProps({}, _ref3))));
288
- };
289
- var ConfirmControl = function ConfirmControl2(props) {
290
- var _ref4 = arguments[0], _ref10, _props$title, _ref16;
291
- var SAddon = Box;
292
- var Children = props.Children, hasChildren = props.children, inputRef = props.inputRef;
293
- var title = (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : props.getI18nText("confirm");
294
- var handleConfirm = React.useCallback(function(event) {
295
- var _props$onConfirm, _inputRef$current$val, _inputRef$current;
296
- (_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);
297
- }, [props.onConfirm, inputRef === null || inputRef === void 0 ? void 0 : inputRef.current]);
298
- var handleKeydown = React.useCallback(function(event) {
266
+ const SAddon = Box;
267
+ return _ref0 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref0.cn("SAddon", {
268
+ ...assignProps({}, _ref3)
269
+ }));
270
+ }
271
+ function ConfirmControl(props) {
272
+ var _ref4 = arguments[0], _ref10;
273
+ const SAddon = Box;
274
+ const {
275
+ Children,
276
+ children: hasChildren,
277
+ inputRef
278
+ } = props;
279
+ const title = props.title ?? props.getI18nText("confirm");
280
+ const handleConfirm = React.useCallback((event) => {
281
+ var _a, _b;
282
+ (_b = props.onConfirm) == null ? void 0 : _b.call(props, ((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) ?? "", event);
283
+ }, [props.onConfirm, inputRef == null ? void 0 : inputRef.current]);
284
+ const handleKeydown = React.useCallback((event) => {
299
285
  if (event.key === "Enter" || event.key === " ") {
300
286
  event.preventDefault();
301
287
  event.stopPropagation();
@@ -304,33 +290,40 @@ var ConfirmControl = function ConfirmControl2(props) {
304
290
  }, [handleConfirm]);
305
291
  if (props.loading) {
306
292
  var _ref1;
307
- return _ref1 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref1.cn("SAddon", _objectSpread({}, assignProps({}, _ref4))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref1.cn("Children", {})) : /* @__PURE__ */ React.createElement(Spin, _ref1.cn("Spin", {
293
+ return _ref1 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref1.cn("SAddon", {
294
+ ...assignProps({}, _ref4)
295
+ }), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref1.cn("Children", {})) : /* @__PURE__ */ React.createElement(Spin, _ref1.cn("Spin", {
308
296
  "size": "xs"
309
297
  })));
310
298
  }
311
- var sstyles = sstyled(props.styles);
312
- var sConfirmIconStyles = sstyles.cn("SConfirmIcon", {});
313
- return _ref10 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref10.cn("SAddon", _objectSpread({}, assignProps({
314
- "onKeyDown": handleKeydown
315
- }, _ref4))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref10.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref10.cn("ButtonLink", {
316
- "addonLeft": (_ref16 = props.icon) !== null && _ref16 !== void 0 ? _ref16 : CheckM,
299
+ const sstyles = sstyled(props.styles);
300
+ const sConfirmIconStyles = sstyles.cn("SConfirmIcon", {});
301
+ return _ref10 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref10.cn("SAddon", {
302
+ ...assignProps({
303
+ "onKeyDown": handleKeydown
304
+ }, _ref4)
305
+ }), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref10.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref10.cn("ButtonLink", {
306
+ "addonLeft": props.icon ?? CheckM,
317
307
  "use": "secondary",
318
308
  "onClick": handleConfirm,
319
309
  "className": sConfirmIconStyles.className,
320
310
  "style": sConfirmIconStyles.style,
321
311
  "aria-label": title
322
312
  })));
323
- };
324
- var CancelControl = function CancelControl2(props) {
325
- var _ref5 = arguments[0], _ref12, _props$title2, _ref17;
326
- var SAddon = Box;
327
- var Children = props.Children, hasChildren = props.children;
328
- var title = (_props$title2 = props.title) !== null && _props$title2 !== void 0 ? _props$title2 : props.getI18nText("discard");
329
- var handleCancel = React.useCallback(function(event) {
330
- var _props$onCancel, _props$value;
331
- (_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);
313
+ }
314
+ function CancelControl(props) {
315
+ var _ref5 = arguments[0], _ref12;
316
+ const SAddon = Box;
317
+ const {
318
+ Children,
319
+ children: hasChildren
320
+ } = props;
321
+ const title = props.title ?? props.getI18nText("discard");
322
+ const handleCancel = React.useCallback((event) => {
323
+ var _a;
324
+ (_a = props.onCancel) == null ? void 0 : _a.call(props, props.value ?? "", event);
332
325
  }, [props.onCancel, props.value]);
333
- var handleKeydown = React.useCallback(function(event) {
326
+ const handleKeydown = React.useCallback((event) => {
334
327
  if (event.key === "Enter" || event.key === " ") {
335
328
  event.preventDefault();
336
329
  event.stopPropagation();
@@ -339,34 +332,42 @@ var CancelControl = function CancelControl2(props) {
339
332
  }, [handleCancel]);
340
333
  if (props.disabled) {
341
334
  var _ref11;
342
- return _ref11 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref11.cn("SAddon", _objectSpread({}, assignProps({}, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref11.cn("Children", {})) : /* @__PURE__ */ React.createElement(CloseM, _ref11.cn("CloseM", {})));
335
+ return _ref11 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref11.cn("SAddon", {
336
+ ...assignProps({}, _ref5)
337
+ }), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref11.cn("Children", {})) : /* @__PURE__ */ React.createElement(CloseM, _ref11.cn("CloseM", {})));
343
338
  }
344
- var sstyles = sstyled(props.styles);
345
- var sCancelIconStyles = sstyles.cn("SCancelIcon", {});
346
- return _ref12 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref12.cn("SAddon", _objectSpread({}, assignProps({
347
- "onKeyDown": handleKeydown
348
- }, _ref5))), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref12.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
339
+ const sstyles = sstyled(props.styles);
340
+ const sCancelIconStyles = sstyles.cn("SCancelIcon", {});
341
+ return _ref12 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref12.cn("SAddon", {
342
+ ...assignProps({
343
+ "onKeyDown": handleKeydown
344
+ }, _ref5)
345
+ }), hasChildren ? /* @__PURE__ */ React.createElement(Children, _ref12.cn("Children", {})) : /* @__PURE__ */ React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
349
346
  "use": "secondary",
350
- "addonLeft": (_ref17 = props.icon) !== null && _ref17 !== void 0 ? _ref17 : CloseM,
347
+ "addonLeft": props.icon ?? CloseM,
351
348
  "onClick": handleCancel,
352
349
  "className": sCancelIconStyles.className,
353
350
  "style": sCancelIconStyles.style,
354
351
  "aria-label": title
355
352
  })));
356
- };
357
- var NumberValue = function NumberValue2(props) {
353
+ }
354
+ function NumberValue(props) {
358
355
  var _ref6 = arguments[0], _ref13;
359
- var SValue = InputNumber.Value;
360
- return _ref13 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SValue, _ref13.cn("SValue", _objectSpread({}, assignProps({}, _ref6))));
361
- };
356
+ const SValue = InputNumber.Value;
357
+ return _ref13 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SValue, _ref13.cn("SValue", {
358
+ ...assignProps({}, _ref6)
359
+ }));
360
+ }
362
361
  function NumberControls(props) {
363
362
  var _ref7 = arguments[0], _ref14;
364
- var SControls = InputNumber.Controls;
365
- return _ref14 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SControls, _ref14.cn("SControls", _objectSpread({}, assignProps({
366
- "tag": InlineInput.Addon
367
- }, _ref7))));
363
+ const SControls = InputNumber.Controls;
364
+ return _ref14 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SControls, _ref14.cn("SControls", {
365
+ ...assignProps({
366
+ "tag": InlineInput.Addon
367
+ }, _ref7)
368
+ }));
368
369
  }
369
- var InlineInput = createComponent(InlineInputBase, {
370
+ const InlineInput = createComponent(InlineInputBase, {
370
371
  Addon,
371
372
  Value,
372
373
  ConfirmControl,