@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/es6/InlineInput.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
2
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
3
|
import { assignProps as _assignProps9 } from "@semcore/core";
|
|
@@ -14,254 +9,227 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
14
9
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
15
10
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
16
11
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
|
+
import { Box, InvalidStateBox } from '@semcore/base-components';
|
|
17
13
|
import { ButtonLink } from '@semcore/button';
|
|
18
14
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
19
|
-
import autoFocusEnhance from '@semcore/core/lib/utils/enhances/autoFocusEnhance';
|
|
20
15
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
21
16
|
import { hasParent } from '@semcore/core/lib/utils/hasParent';
|
|
22
|
-
import { Box, InvalidStateBox } from '@semcore/flex-box';
|
|
23
17
|
import CheckM from '@semcore/icon/Check/m';
|
|
24
18
|
import CloseM from '@semcore/icon/Close/m';
|
|
25
19
|
import InputNumber from '@semcore/input-number';
|
|
26
20
|
import Spin from '@semcore/spin';
|
|
27
21
|
import React from 'react';
|
|
28
22
|
/*!__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
29
|
-
|
|
23
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___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)}", /*__inner_css_end__*/"mw77c_gg_"),
|
|
30
24
|
/*__reshadow_css_end__*/
|
|
31
25
|
{
|
|
32
|
-
"__SInlineInput": "
|
|
33
|
-
"_disabled": "
|
|
34
|
-
"__SUnderline": "
|
|
35
|
-
"__SAddon": "
|
|
36
|
-
"_state_valid": "
|
|
37
|
-
"_state_invalid": "
|
|
38
|
-
"__SValue": "
|
|
39
|
-
"__SControls": "
|
|
40
|
-
"__SInvalidPattern": "
|
|
41
|
-
"__SConfirmIcon": "
|
|
42
|
-
"__SCancelIcon": "
|
|
43
|
-
"_type_number": "
|
|
26
|
+
"__SInlineInput": "___SInlineInput_mw77c_gg_",
|
|
27
|
+
"_disabled": "__disabled_mw77c_gg_",
|
|
28
|
+
"__SUnderline": "___SUnderline_mw77c_gg_",
|
|
29
|
+
"__SAddon": "___SAddon_mw77c_gg_",
|
|
30
|
+
"_state_valid": "_state_valid_mw77c_gg_",
|
|
31
|
+
"_state_invalid": "_state_invalid_mw77c_gg_",
|
|
32
|
+
"__SValue": "___SValue_mw77c_gg_",
|
|
33
|
+
"__SControls": "___SControls_mw77c_gg_",
|
|
34
|
+
"__SInvalidPattern": "___SInvalidPattern_mw77c_gg_",
|
|
35
|
+
"__SConfirmIcon": "___SConfirmIcon_mw77c_gg_",
|
|
36
|
+
"__SCancelIcon": "___SCancelIcon_mw77c_gg_",
|
|
37
|
+
"_type_number": "_type_number_mw77c_gg_"
|
|
44
38
|
});
|
|
45
39
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
const pointInsideOfRect = ({
|
|
41
|
+
x,
|
|
42
|
+
y,
|
|
43
|
+
rect
|
|
44
|
+
}) => {
|
|
50
45
|
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
51
46
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_defineProperty(
|
|
61
|
-
|
|
62
|
-
_defineProperty(_this, "inputHandlersRef", /*#__PURE__*/React.createRef());
|
|
63
|
-
_defineProperty(_this, "initValue", '');
|
|
64
|
-
_defineProperty(_this, "lastMouseDownPosition", null);
|
|
65
|
-
_defineProperty(_this, "lastHandledKeyboardEvent", -1);
|
|
66
|
-
_defineProperty(_this, "handleDocumentMouseDown", function (event) {
|
|
67
|
-
_this.lastMouseDownPosition = {
|
|
47
|
+
class InlineInputBase extends Component {
|
|
48
|
+
constructor(...args) {
|
|
49
|
+
super(...args);
|
|
50
|
+
_defineProperty(this, "rootRef", /*#__PURE__*/React.createRef());
|
|
51
|
+
_defineProperty(this, "inputRef", /*#__PURE__*/React.createRef());
|
|
52
|
+
_defineProperty(this, "initValue", '');
|
|
53
|
+
_defineProperty(this, "lastMouseDownPosition", null);
|
|
54
|
+
_defineProperty(this, "lastHandledKeyboardEvent", -1);
|
|
55
|
+
_defineProperty(this, "handleDocumentMouseDown", event => {
|
|
56
|
+
this.lastMouseDownPosition = {
|
|
68
57
|
x: event.clientX,
|
|
69
58
|
y: event.clientY
|
|
70
59
|
};
|
|
71
|
-
|
|
60
|
+
this.lastHandledKeyboardEvent = -1;
|
|
72
61
|
});
|
|
73
|
-
_defineProperty(
|
|
74
|
-
|
|
62
|
+
_defineProperty(this, "handleDocumentKeyDown", () => {
|
|
63
|
+
this.lastMouseDownPosition = null;
|
|
75
64
|
});
|
|
76
|
-
_defineProperty(
|
|
77
|
-
var _this$inputRef$curren, _this$inputRef$curren2, _this$inputRef$curren3, _this$inputHandlersRe, _this$inputRef$curren4;
|
|
65
|
+
_defineProperty(this, "increment", event => {
|
|
78
66
|
// https://stackoverflow.com/questions/68010124/safari-number-input-stepup-stepdown-not-functioning-with-empty-value
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
(_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);
|
|
67
|
+
if (this.inputRef.current?.value === '') this.inputRef.current.value = this.inputRef.current.min || '0';
|
|
68
|
+
this.inputRef.current?.stepUp?.(event);
|
|
82
69
|
});
|
|
83
|
-
_defineProperty(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(_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);
|
|
87
|
-
(_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);
|
|
70
|
+
_defineProperty(this, "decrement", event => {
|
|
71
|
+
if (this.inputRef.current?.value === '') this.inputRef.current.value = this.inputRef.current.max || '0';
|
|
72
|
+
this.inputRef.current?.stepDown?.(event);
|
|
88
73
|
});
|
|
89
|
-
_defineProperty(
|
|
90
|
-
var _this$inputRef$curren9;
|
|
74
|
+
_defineProperty(this, "handleMouseDownAddon", event => {
|
|
91
75
|
event.preventDefault();
|
|
92
|
-
|
|
76
|
+
this.inputRef.current?.focus();
|
|
93
77
|
});
|
|
94
|
-
_defineProperty(
|
|
95
|
-
|
|
96
|
-
(_this$asProps$onConfi = (_this$asProps = _this.asProps).onConfirm) === null || _this$asProps$onConfi === void 0 || _this$asProps$onConfi.call(_this$asProps, text, event);
|
|
78
|
+
_defineProperty(this, "handleConfirm", (text, event) => {
|
|
79
|
+
this.asProps.onConfirm?.(text, event);
|
|
97
80
|
});
|
|
98
|
-
_defineProperty(
|
|
99
|
-
|
|
100
|
-
(_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
|
+
this.asProps.onCancel?.(prevText, event);
|
|
101
83
|
});
|
|
102
|
-
_defineProperty(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
84
|
+
_defineProperty(this, "handleBlur", event => {
|
|
85
|
+
const {
|
|
86
|
+
onConfirm,
|
|
87
|
+
onCancel,
|
|
88
|
+
onBlurBehavior
|
|
89
|
+
} = this.asProps;
|
|
108
90
|
if (!onBlurBehavior) return;
|
|
109
|
-
if (Date.now() -
|
|
110
|
-
if (hasParent(event.relatedTarget,
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
x
|
|
114
|
-
y
|
|
115
|
-
|
|
91
|
+
if (Date.now() - this.lastHandledKeyboardEvent < 250) return;
|
|
92
|
+
if (hasParent(event.relatedTarget, this.rootRef.current)) return;
|
|
93
|
+
if (this.lastMouseDownPosition && this.rootRef.current) {
|
|
94
|
+
const {
|
|
95
|
+
x,
|
|
96
|
+
y
|
|
97
|
+
} = this.lastMouseDownPosition;
|
|
98
|
+
const rect = this.rootRef.current.getBoundingClientRect();
|
|
116
99
|
if (pointInsideOfRect({
|
|
117
|
-
x
|
|
118
|
-
y
|
|
119
|
-
rect
|
|
100
|
+
x,
|
|
101
|
+
y,
|
|
102
|
+
rect
|
|
120
103
|
})) {
|
|
121
104
|
return;
|
|
122
105
|
}
|
|
123
106
|
}
|
|
124
|
-
if (onBlurBehavior === 'confirm') onConfirm
|
|
125
|
-
if (onBlurBehavior === 'cancel') onCancel
|
|
107
|
+
if (onBlurBehavior === 'confirm') onConfirm?.(this.inputRef.current?.value ?? '', event);
|
|
108
|
+
if (onBlurBehavior === 'cancel') onCancel?.(this.initValue, event);
|
|
126
109
|
});
|
|
127
|
-
_defineProperty(
|
|
128
|
-
|
|
129
|
-
onConfirm
|
|
130
|
-
onCancel
|
|
110
|
+
_defineProperty(this, "handleKeyDown", event => {
|
|
111
|
+
const {
|
|
112
|
+
onConfirm,
|
|
113
|
+
onCancel
|
|
114
|
+
} = this.asProps;
|
|
131
115
|
if (event.key === 'Enter') {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
_this.lastHandledKeyboardEvent = Date.now();
|
|
116
|
+
onConfirm?.(this.inputRef.current?.value ?? '', event);
|
|
117
|
+
this.lastHandledKeyboardEvent = Date.now();
|
|
135
118
|
}
|
|
136
119
|
if (event.key === 'Escape') {
|
|
137
|
-
onCancel
|
|
138
|
-
|
|
120
|
+
onCancel?.(this.initValue, event);
|
|
121
|
+
this.lastHandledKeyboardEvent = Date.now();
|
|
139
122
|
}
|
|
140
123
|
});
|
|
141
|
-
return _this;
|
|
142
124
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
125
|
+
componentDidMount() {
|
|
126
|
+
this.updateInert();
|
|
127
|
+
if (!this.asProps.onBlurBehavior) return;
|
|
128
|
+
document.body.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
129
|
+
document.body.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
130
|
+
}
|
|
131
|
+
componentDidUpdate(prevProps) {
|
|
132
|
+
if (prevProps.disabled !== this.asProps.disabled) {
|
|
147
133
|
this.updateInert();
|
|
148
|
-
if (!this.asProps.onBlurBehavior) return;
|
|
149
|
-
document.body.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
150
|
-
document.body.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
151
|
-
}
|
|
152
|
-
}, {
|
|
153
|
-
key: "componentDidUpdate",
|
|
154
|
-
value: function componentDidUpdate(prevProps) {
|
|
155
|
-
if (prevProps.disabled !== this.asProps.disabled) {
|
|
156
|
-
this.updateInert();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "componentWillUnmount",
|
|
161
|
-
value: function componentWillUnmount() {
|
|
162
|
-
if (!this.asProps.onBlurBehavior) return;
|
|
163
|
-
document.body.removeEventListener('mousedown', this.handleDocumentMouseDown);
|
|
164
|
-
document.body.removeEventListener('keydown', this.handleDocumentKeyDown);
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "getAddonProps",
|
|
168
|
-
value: function getAddonProps() {
|
|
169
|
-
return {
|
|
170
|
-
onMouseDown: this.handleMouseDownAddon
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "getConfirmControlProps",
|
|
175
|
-
value: function getConfirmControlProps() {
|
|
176
|
-
var _this$asProps5 = this.asProps,
|
|
177
|
-
loading = _this$asProps5.loading,
|
|
178
|
-
getI18nText = _this$asProps5.getI18nText;
|
|
179
|
-
return {
|
|
180
|
-
inputRef: this.inputRef,
|
|
181
|
-
loading: loading,
|
|
182
|
-
onConfirm: this.handleConfirm,
|
|
183
|
-
getI18nText: getI18nText
|
|
184
|
-
};
|
|
185
134
|
}
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
135
|
+
}
|
|
136
|
+
componentWillUnmount() {
|
|
137
|
+
if (!this.asProps.onBlurBehavior) return;
|
|
138
|
+
document.body.removeEventListener('mousedown', this.handleDocumentMouseDown);
|
|
139
|
+
document.body.removeEventListener('keydown', this.handleDocumentKeyDown);
|
|
140
|
+
}
|
|
141
|
+
getAddonProps() {
|
|
142
|
+
return {
|
|
143
|
+
onMouseDown: this.handleMouseDownAddon
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
getConfirmControlProps() {
|
|
147
|
+
const {
|
|
148
|
+
loading,
|
|
149
|
+
getI18nText
|
|
150
|
+
} = this.asProps;
|
|
151
|
+
return {
|
|
152
|
+
inputRef: this.inputRef,
|
|
153
|
+
loading,
|
|
154
|
+
onConfirm: this.handleConfirm,
|
|
155
|
+
getI18nText
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
getCancelControlProps() {
|
|
159
|
+
const {
|
|
160
|
+
loading,
|
|
161
|
+
disabled,
|
|
162
|
+
getI18nText
|
|
163
|
+
} = this.asProps;
|
|
164
|
+
return {
|
|
165
|
+
value: this.initValue,
|
|
166
|
+
// because double disabled(root disabled and addon disabled)
|
|
167
|
+
disabled: loading && !disabled,
|
|
168
|
+
onCancel: this.handleCancel,
|
|
169
|
+
getI18nText
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
getValueProps() {
|
|
173
|
+
const {
|
|
174
|
+
state
|
|
175
|
+
} = this.asProps;
|
|
176
|
+
return {
|
|
177
|
+
ref: this.inputRef,
|
|
178
|
+
state,
|
|
179
|
+
onKeyDown: this.handleKeyDown
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
getNumberValueProps() {
|
|
183
|
+
const numberFormatter = new Intl.NumberFormat(this.asProps.locale, {
|
|
184
|
+
style: 'decimal'
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
numberFormatter,
|
|
188
|
+
inputRef: this.inputRef,
|
|
189
|
+
increment: this.increment,
|
|
190
|
+
decrement: this.decrement
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
getNumberControlsProps() {
|
|
194
|
+
const {
|
|
195
|
+
getI18nText
|
|
196
|
+
} = this.asProps;
|
|
197
|
+
return {
|
|
198
|
+
increment: this.increment,
|
|
199
|
+
decrement: this.decrement,
|
|
200
|
+
getI18nText
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
updateInert() {
|
|
204
|
+
const {
|
|
205
|
+
disabled
|
|
206
|
+
} = this.asProps;
|
|
207
|
+
if (!this.rootRef.current) return;
|
|
208
|
+
if (disabled) {
|
|
209
|
+
this.rootRef.current.setAttribute('inert', '');
|
|
210
|
+
} else {
|
|
211
|
+
this.rootRef.current.removeAttribute('inert');
|
|
245
212
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
213
|
+
}
|
|
214
|
+
render() {
|
|
215
|
+
var _ref = this.asProps,
|
|
216
|
+
_ref8;
|
|
217
|
+
const SInlineInput = Box;
|
|
218
|
+
const SUnderline = 'div';
|
|
219
|
+
const SInvalidPattern = InvalidStateBox;
|
|
220
|
+
const {
|
|
221
|
+
Children,
|
|
222
|
+
styles,
|
|
223
|
+
state
|
|
224
|
+
} = this.asProps;
|
|
225
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref8.cn("SInlineInput", {
|
|
226
|
+
..._assignProps({
|
|
259
227
|
"ref": this.rootRef,
|
|
260
228
|
"onBlur": this.handleBlur
|
|
261
|
-
}, _ref)
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
229
|
+
}, _ref)
|
|
230
|
+
}), /*#__PURE__*/React.createElement(SUnderline, _ref8.cn("SUnderline", {}), state === 'invalid' && /*#__PURE__*/React.createElement(SInvalidPattern, _ref8.cn("SInvalidPattern", {})), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {}))));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
265
233
|
_defineProperty(InlineInputBase, "displayName", 'InlineInput');
|
|
266
234
|
_defineProperty(InlineInputBase, "enhance", [i18nEnhance(localizedMessages)]);
|
|
267
235
|
_defineProperty(InlineInputBase, "defaultProps", {
|
|
@@ -271,60 +239,49 @@ _defineProperty(InlineInputBase, "defaultProps", {
|
|
|
271
239
|
locale: 'en'
|
|
272
240
|
});
|
|
273
241
|
_defineProperty(InlineInputBase, "style", style);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
242
|
+
class Value extends Component {
|
|
243
|
+
uncontrolledProps() {
|
|
244
|
+
return {
|
|
245
|
+
value: event => event.target.value
|
|
246
|
+
};
|
|
278
247
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return event.target.value;
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}, {
|
|
290
|
-
key: "render",
|
|
291
|
-
value: function render() {
|
|
292
|
-
var _ref2 = this.asProps,
|
|
293
|
-
_ref9;
|
|
294
|
-
var SValue = Box;
|
|
295
|
-
return _ref9 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref9.cn("SValue", _objectSpread({}, _assignProps2({
|
|
248
|
+
render() {
|
|
249
|
+
var _ref2 = this.asProps,
|
|
250
|
+
_ref9;
|
|
251
|
+
const SValue = Box;
|
|
252
|
+
return _ref9 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref9.cn("SValue", {
|
|
253
|
+
..._assignProps2({
|
|
296
254
|
"tag": 'input',
|
|
297
255
|
"type": 'text'
|
|
298
|
-
}, _ref2)
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
256
|
+
}, _ref2)
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
302
260
|
_defineProperty(Value, "defaultProps", {
|
|
303
261
|
defaultValue: ''
|
|
304
262
|
});
|
|
305
|
-
|
|
306
|
-
_defineProperty(Value, "hoistProps", ['disabled']);
|
|
307
|
-
var Addon = function Addon(props) {
|
|
263
|
+
function Addon(props) {
|
|
308
264
|
var _ref3 = arguments[0],
|
|
309
265
|
_ref0;
|
|
310
|
-
|
|
311
|
-
return _ref0 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref0.cn("SAddon",
|
|
312
|
-
}
|
|
313
|
-
|
|
266
|
+
const SAddon = Box;
|
|
267
|
+
return _ref0 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref0.cn("SAddon", {
|
|
268
|
+
..._assignProps3({}, _ref3)
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
function ConfirmControl(props) {
|
|
314
272
|
var _ref4 = arguments[0],
|
|
315
|
-
_ref10
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
var handleKeydown = React.useCallback(function (event) {
|
|
273
|
+
_ref10;
|
|
274
|
+
const SAddon = Box;
|
|
275
|
+
const {
|
|
276
|
+
Children,
|
|
277
|
+
children: hasChildren,
|
|
278
|
+
inputRef
|
|
279
|
+
} = props;
|
|
280
|
+
const title = props.title ?? props.getI18nText('confirm');
|
|
281
|
+
const handleConfirm = React.useCallback(event => {
|
|
282
|
+
props.onConfirm?.(inputRef?.current?.value ?? '', event);
|
|
283
|
+
}, [props.onConfirm, inputRef?.current]);
|
|
284
|
+
const handleKeydown = React.useCallback(event => {
|
|
328
285
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
329
286
|
event.preventDefault();
|
|
330
287
|
event.stopPropagation();
|
|
@@ -333,37 +290,40 @@ var ConfirmControl = function ConfirmControl(props) {
|
|
|
333
290
|
}, [handleConfirm]);
|
|
334
291
|
if (props.loading) {
|
|
335
292
|
var _ref1;
|
|
336
|
-
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
|
+
..._assignProps4({}, _ref4)
|
|
295
|
+
}), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref1.cn("Spin", {
|
|
337
296
|
"size": 'xs'
|
|
338
297
|
})));
|
|
339
298
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref10.cn("SAddon",
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
+
..._assignProps5({
|
|
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,
|
|
346
307
|
"use": 'secondary',
|
|
347
308
|
"onClick": handleConfirm,
|
|
348
309
|
"className": sConfirmIconStyles.className,
|
|
349
310
|
"style": sConfirmIconStyles.style,
|
|
350
311
|
"aria-label": title
|
|
351
312
|
})));
|
|
352
|
-
}
|
|
353
|
-
|
|
313
|
+
}
|
|
314
|
+
function CancelControl(props) {
|
|
354
315
|
var _ref5 = arguments[0],
|
|
355
|
-
_ref12
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
(_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);
|
|
316
|
+
_ref12;
|
|
317
|
+
const SAddon = Box;
|
|
318
|
+
const {
|
|
319
|
+
Children,
|
|
320
|
+
children: hasChildren
|
|
321
|
+
} = props;
|
|
322
|
+
const title = props.title ?? props.getI18nText('discard');
|
|
323
|
+
const handleCancel = React.useCallback(event => {
|
|
324
|
+
props.onCancel?.(props.value ?? '', event);
|
|
365
325
|
}, [props.onCancel, props.value]);
|
|
366
|
-
|
|
326
|
+
const handleKeydown = React.useCallback(event => {
|
|
367
327
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
368
328
|
event.preventDefault();
|
|
369
329
|
event.stopPropagation();
|
|
@@ -372,44 +332,53 @@ var CancelControl = function CancelControl(props) {
|
|
|
372
332
|
}, [handleCancel]);
|
|
373
333
|
if (props.disabled) {
|
|
374
334
|
var _ref11;
|
|
375
|
-
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
|
+
..._assignProps6({}, _ref5)
|
|
337
|
+
}), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref11.cn("CloseM", {})));
|
|
376
338
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref12.cn("SAddon",
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
..._assignProps7({
|
|
343
|
+
"onKeyDown": handleKeydown
|
|
344
|
+
}, _ref5)
|
|
345
|
+
}), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(ButtonLink, _ref12.cn("ButtonLink", {
|
|
382
346
|
"use": 'secondary',
|
|
383
|
-
"addonLeft":
|
|
347
|
+
"addonLeft": props.icon ?? CloseM,
|
|
384
348
|
"onClick": handleCancel,
|
|
385
349
|
"className": sCancelIconStyles.className,
|
|
386
350
|
"style": sCancelIconStyles.style,
|
|
387
351
|
"aria-label": title
|
|
388
352
|
})));
|
|
389
|
-
}
|
|
390
|
-
|
|
353
|
+
}
|
|
354
|
+
function NumberValue(props) {
|
|
391
355
|
var _ref6 = arguments[0],
|
|
392
356
|
_ref13;
|
|
393
|
-
|
|
394
|
-
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SValue, _ref13.cn("SValue",
|
|
395
|
-
}
|
|
357
|
+
const SValue = InputNumber.Value;
|
|
358
|
+
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SValue, _ref13.cn("SValue", {
|
|
359
|
+
..._assignProps8({}, _ref6)
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
362
|
+
;
|
|
396
363
|
function NumberControls(props) {
|
|
397
364
|
var _ref7 = arguments[0],
|
|
398
365
|
_ref14;
|
|
399
|
-
|
|
400
|
-
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref14.cn("SControls",
|
|
401
|
-
|
|
402
|
-
|
|
366
|
+
const SControls = InputNumber.Controls;
|
|
367
|
+
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref14.cn("SControls", {
|
|
368
|
+
..._assignProps9({
|
|
369
|
+
"tag": InlineInput.Addon
|
|
370
|
+
}, _ref7)
|
|
371
|
+
}));
|
|
403
372
|
}
|
|
404
373
|
|
|
405
374
|
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
406
|
-
|
|
407
|
-
Addon
|
|
408
|
-
Value
|
|
409
|
-
ConfirmControl
|
|
410
|
-
CancelControl
|
|
411
|
-
NumberValue
|
|
412
|
-
NumberControls
|
|
375
|
+
const InlineInput = createComponent(InlineInputBase, {
|
|
376
|
+
Addon,
|
|
377
|
+
Value,
|
|
378
|
+
ConfirmControl,
|
|
379
|
+
CancelControl,
|
|
380
|
+
NumberValue,
|
|
381
|
+
NumberControls
|
|
413
382
|
});
|
|
414
383
|
export default InlineInput;
|
|
415
384
|
//# sourceMappingURL=InlineInput.js.map
|