@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.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/lib/cjs/InlineInput.js +272 -303
- package/lib/cjs/InlineInput.js.map +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/index.type.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/InlineInput.js +264 -295
- package/lib/es6/InlineInput.js.map +1 -1
- package/lib/es6/index.type.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/InlineInput.mjs +264 -263
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/index.type.d.ts +2 -17
- package/package.json +13 -12
package/lib/esm/InlineInput.mjs
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
14
|
+
const style = (
|
|
21
15
|
/*__reshadow_css_start__*/
|
|
22
16
|
(sstyled.insert(
|
|
23
17
|
/*__inner_css_start__*/
|
|
24
|
-
".
|
|
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
|
-
"
|
|
20
|
+
"mw77c_gg_"
|
|
27
21
|
), /*__reshadow_css_end__*/
|
|
28
22
|
{
|
|
29
|
-
"__SInlineInput": "
|
|
30
|
-
"_disabled": "
|
|
31
|
-
"__SUnderline": "
|
|
32
|
-
"__SAddon": "
|
|
33
|
-
"_state_valid": "
|
|
34
|
-
"_state_invalid": "
|
|
35
|
-
"__SValue": "
|
|
36
|
-
"__SControls": "
|
|
37
|
-
"__SInvalidPattern": "
|
|
38
|
-
"__SConfirmIcon": "
|
|
39
|
-
"__SCancelIcon": "
|
|
40
|
-
"_type_number": "
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_defineProperty(
|
|
56
|
-
|
|
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
|
-
|
|
57
|
+
this.lastHandledKeyboardEvent = -1;
|
|
67
58
|
});
|
|
68
|
-
_defineProperty(
|
|
69
|
-
|
|
59
|
+
_defineProperty(this, "handleDocumentKeyDown", () => {
|
|
60
|
+
this.lastMouseDownPosition = null;
|
|
70
61
|
});
|
|
71
|
-
_defineProperty(
|
|
72
|
-
var
|
|
73
|
-
if (((
|
|
74
|
-
(
|
|
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(
|
|
78
|
-
var
|
|
79
|
-
if (((
|
|
80
|
-
(
|
|
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(
|
|
84
|
-
var
|
|
72
|
+
_defineProperty(this, "handleMouseDownAddon", (event) => {
|
|
73
|
+
var _a;
|
|
85
74
|
event.preventDefault();
|
|
86
|
-
(
|
|
75
|
+
(_a = this.inputRef.current) == null ? void 0 : _a.focus();
|
|
87
76
|
});
|
|
88
|
-
_defineProperty(
|
|
89
|
-
var
|
|
90
|
-
(
|
|
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(
|
|
93
|
-
var
|
|
94
|
-
(
|
|
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(
|
|
97
|
-
var
|
|
98
|
-
|
|
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() -
|
|
101
|
-
if (hasParent(event.relatedTarget,
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
114
|
-
if (onBlurBehavior === "cancel") onCancel
|
|
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(
|
|
117
|
-
var
|
|
112
|
+
_defineProperty(this, "handleKeyDown", (event) => {
|
|
113
|
+
var _a;
|
|
114
|
+
const {
|
|
115
|
+
onConfirm,
|
|
116
|
+
onCancel
|
|
117
|
+
} = this.asProps;
|
|
118
118
|
if (event.key === "Enter") {
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
125
|
-
|
|
123
|
+
onCancel == null ? void 0 : onCancel(this.initValue, event);
|
|
124
|
+
this.lastHandledKeyboardEvent = Date.now();
|
|
126
125
|
}
|
|
127
126
|
});
|
|
128
|
-
return _this;
|
|
129
127
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
244
|
+
class Value extends Component {
|
|
245
|
+
uncontrolledProps() {
|
|
246
|
+
return {
|
|
247
|
+
value: (event) => event.target.value
|
|
248
|
+
};
|
|
256
249
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
}
|
|
257
|
+
}, _ref2)
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
279
261
|
_defineProperty(Value, "defaultProps", {
|
|
280
262
|
defaultValue: ""
|
|
281
263
|
});
|
|
282
|
-
|
|
283
|
-
_defineProperty(Value, "hoistProps", ["disabled"]);
|
|
284
|
-
var Addon = function Addon2(props) {
|
|
264
|
+
function Addon(props) {
|
|
285
265
|
var _ref3 = arguments[0], _ref0;
|
|
286
|
-
|
|
287
|
-
return _ref0 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref0.cn("SAddon",
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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",
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
return _ref10 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref10.cn("SAddon",
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
325
|
-
var _ref5 = arguments[0], _ref12
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
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",
|
|
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
|
-
|
|
345
|
-
|
|
346
|
-
return _ref12 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref12.cn("SAddon",
|
|
347
|
-
|
|
348
|
-
|
|
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":
|
|
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
|
-
|
|
353
|
+
}
|
|
354
|
+
function NumberValue(props) {
|
|
358
355
|
var _ref6 = arguments[0], _ref13;
|
|
359
|
-
|
|
360
|
-
return _ref13 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SValue, _ref13.cn("SValue",
|
|
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
|
-
|
|
365
|
-
return _ref14 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SControls, _ref14.cn("SControls",
|
|
366
|
-
|
|
367
|
-
|
|
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
|
-
|
|
370
|
+
const InlineInput = createComponent(InlineInputBase, {
|
|
370
371
|
Addon,
|
|
371
372
|
Value,
|
|
372
373
|
ConfirmControl,
|