@semcore/inline-input 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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