@semcore/inline-input 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +0 -0
- package/lib/cjs/InlineInput.js +488 -0
- package/lib/cjs/InlineInput.js.map +1 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/style/inline-input.shadow.css +150 -0
- package/lib/es6/InlineInput.js +475 -0
- package/lib/es6/InlineInput.js.map +1 -0
- package/lib/es6/index.js +3 -0
- package/lib/es6/index.js.map +1 -0
- package/lib/es6/style/inline-input.shadow.css +150 -0
- package/lib/types/index.d.ts +199 -0
- package/package.json +40 -0
- package/src/InlineInput.tsx +387 -0
- package/src/index.d.ts +199 -0
- package/src/index.ts +2 -0
- package/src/style/inline-input.shadow.css +150 -0
- package/yarn-error.log +21221 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
@import '@semcore/utils/style/var.css';
|
|
2
|
+
|
|
3
|
+
SInlineInput {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
align-items: center;
|
|
8
|
+
position: relative;
|
|
9
|
+
z-index: 0;
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
padding: 1px;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
|
|
14
|
+
background-color: var(--white);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
SControls {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SConfirmControl {
|
|
24
|
+
color: var(--green-300);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
SConfirmControl:hover {
|
|
28
|
+
color: var(--green-400);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SCancelControl {
|
|
32
|
+
color: var(--gray-300);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
SCancelControl:hover {
|
|
36
|
+
color: var(--gray-400);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SValue {
|
|
40
|
+
/* hack for firefox */
|
|
41
|
+
min-width: 0;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
padding: 0 4px;
|
|
45
|
+
border: none;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
color: var(--gray20);
|
|
48
|
+
font-size: inherit;
|
|
49
|
+
line-height: 1.2;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
font-family: inherit;
|
|
52
|
+
background: transparent;
|
|
53
|
+
min-height: 1em;
|
|
54
|
+
|
|
55
|
+
&:focus {
|
|
56
|
+
outline: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&::placeholder {
|
|
60
|
+
color: var(--gray70);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:read-only ~ SUnderline {
|
|
64
|
+
/* background: var(--gray96); */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&[disabled],
|
|
68
|
+
&[loading] {
|
|
69
|
+
opacity: var(--disabled-opacity);
|
|
70
|
+
}
|
|
71
|
+
&[disabled] {
|
|
72
|
+
user-select: none;
|
|
73
|
+
|
|
74
|
+
& ~ SUnderline {
|
|
75
|
+
cursor: default;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
SUnderline {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
align-items: center;
|
|
85
|
+
flex-grow: 1;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
min-height: 1em;
|
|
89
|
+
border: 1px solid transparent;
|
|
90
|
+
border-bottom: 1px solid var(--gray-200);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
SAddon {
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
align-items: center;
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
height: 100%;
|
|
99
|
+
color: var(--gray-300);
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
SAddon[disabled] {
|
|
104
|
+
opacity: var(--disabled-opacity);
|
|
105
|
+
cursor: default;
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
SInlineInput[focused] {
|
|
110
|
+
z-index: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
SInlineInput[focused] SUnderline {
|
|
114
|
+
border-color: var(--blue-400);
|
|
115
|
+
box-shadow: var(--keyborad-focus);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
SInlineInput[state='valid'] SUnderline {
|
|
119
|
+
border-color: var(--green-200);
|
|
120
|
+
}
|
|
121
|
+
SInlineInput[state='valid'][focused] SUnderline {
|
|
122
|
+
border-color: var(--green-400);
|
|
123
|
+
box-shadow: var(--keyboard-focus-valid);
|
|
124
|
+
}
|
|
125
|
+
SInlineInput[state='invalid'] SUnderline {
|
|
126
|
+
border-color: var(--red-200);
|
|
127
|
+
}
|
|
128
|
+
SInlineInput[state='invalid'][focused] SUnderline {
|
|
129
|
+
border-color: var(--red-400);
|
|
130
|
+
box-shadow: var(--keyboard-focus-invalid);
|
|
131
|
+
}
|
|
132
|
+
SInlineInput[state='disabled'],
|
|
133
|
+
SInlineInput[loading] {
|
|
134
|
+
cursor: default;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CloseM[disabled] {
|
|
138
|
+
cursor: default;
|
|
139
|
+
opacity: var(--disabled-opacity);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.controls-icon {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.spin {
|
|
148
|
+
min-width: 16px;
|
|
149
|
+
cursor: default;
|
|
150
|
+
}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
|
+
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
10
|
+
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
11
|
+
import { assignProps as _assignProps6 } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps5 } from "@semcore/core";
|
|
13
|
+
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
14
|
+
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
15
|
+
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
16
|
+
import { assignProps as _assignProps } from "@semcore/core";
|
|
17
|
+
|
|
18
|
+
var _this3 = this;
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
+
|
|
26
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
+
|
|
28
|
+
import React from 'react';
|
|
29
|
+
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
30
|
+
import { Box } from '@semcore/flex-box';
|
|
31
|
+
import autoFocusEnhance from '@semcore/utils/lib/enhances/autoFocusEnhance';
|
|
32
|
+
import Tooltip from '@semcore/tooltip';
|
|
33
|
+
|
|
34
|
+
/*__reshadow-styles__:"./style/inline-input.shadow.css"*/
|
|
35
|
+
var style = (
|
|
36
|
+
/*__reshadow_css_start__*/
|
|
37
|
+
_sstyled.insert(
|
|
38
|
+
/*__inner_css_start__*/
|
|
39
|
+
".___SInlineInput_1yp60_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:#fff}.___SControls_1yp60_gg_{display:flex;flex-direction:row;flex-shrink:0}.___SConfirmControl_1yp60_gg_{color:#00c192;cursor:pointer}.___SConfirmControl_1yp60_gg_:hover{color:#009f81}.___SCancelControl_1yp60_gg_{color:#a9abb6;cursor:pointer}.___SCancelControl_1yp60_gg_:hover{color:#8a8e9b}.___SValue_1yp60_gg_{min-width:0;width:100%;height:100%;padding:0 4px;border:none;box-sizing:border-box;color:#333333;font-size:inherit;line-height:1.2;text-overflow:ellipsis;font-family:inherit;background:transparent;min-height:1em}.___SValue_1yp60_gg_:focus{outline:none}.___SValue_1yp60_gg_::placeholder{color:#aaaaaa}.___SValue_1yp60_gg_.__disabled_1yp60_gg_,.___SValue_1yp60_gg_.__loading_1yp60_gg_{opacity:0.3}.___SValue_1yp60_gg_.__disabled_1yp60_gg_{user-select:none}.___SValue_1yp60_gg_.__disabled_1yp60_gg_~.___SUnderline_1yp60_gg_{cursor:default;pointer-events:none}.___SUnderline_1yp60_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 #c4c7cf}.___SAddon_1yp60_gg_{display:inline-flex;justify-content:center;align-items:center;flex:0 0 auto;height:100%;color:#a9abb6;padding:0 4px}.___SAddon_1yp60_gg_.__disabled_1yp60_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SInlineInput_1yp60_gg_.__focused_1yp60_gg_{z-index:1}.___SInlineInput_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#008ff8;box-shadow:0 0 0 3px rgba(43, 148, 225, 0.3)}.___SInlineInput_1yp60_gg_._state_valid_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#59ddaa}.___SInlineInput_1yp60_gg_._state_valid_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#009f81;box-shadow:0px 0px 0px 3px color-mod(var(--green-400_1aotv0j), a(20%))}.___SInlineInput_1yp60_gg_._state_invalid_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#ffaeb5}.___SInlineInput_1yp60_gg_._state_invalid_1yp60_gg_.__focused_1yp60_gg_ .___SUnderline_1yp60_gg_{border-color:#ff4953;box-shadow:0px 0px 0px 3px color-mod(var(--red-400_1aotv0j), a(20%))}.___SInlineInput_1yp60_gg_.__loading_1yp60_gg_,.___SInlineInput_1yp60_gg_._state_disabled_1yp60_gg_{cursor:default}.___CloseM_1yp60_gg_.__disabled_1yp60_gg_{cursor:default;opacity:0.3}.controls-icon{display:flex;align-items:center}.spin{min-width:16px;cursor:default}"
|
|
40
|
+
/*__inner_css_end__*/
|
|
41
|
+
, "1aotv0j_gg_")
|
|
42
|
+
/*__reshadow_css_end__*/
|
|
43
|
+
, {
|
|
44
|
+
"__SInlineInput": "___SInlineInput_1yp60_gg_",
|
|
45
|
+
"__SControls": "___SControls_1yp60_gg_",
|
|
46
|
+
"__SConfirmControl": "___SConfirmControl_1yp60_gg_",
|
|
47
|
+
"__SCancelControl": "___SCancelControl_1yp60_gg_",
|
|
48
|
+
"__SValue": "___SValue_1yp60_gg_",
|
|
49
|
+
"_disabled": "__disabled_1yp60_gg_",
|
|
50
|
+
"_loading": "__loading_1yp60_gg_",
|
|
51
|
+
"__SUnderline": "___SUnderline_1yp60_gg_",
|
|
52
|
+
"__SAddon": "___SAddon_1yp60_gg_",
|
|
53
|
+
"_focused": "__focused_1yp60_gg_",
|
|
54
|
+
"_state_valid": "_state_valid_1yp60_gg_",
|
|
55
|
+
"--green-400": "--green-400_1aotv0j",
|
|
56
|
+
"_state_invalid": "_state_invalid_1yp60_gg_",
|
|
57
|
+
"--red-400": "--red-400_1aotv0j",
|
|
58
|
+
"_state_disabled": "_state_disabled_1yp60_gg_",
|
|
59
|
+
"__CloseM": "___CloseM_1yp60_gg_"
|
|
60
|
+
});
|
|
61
|
+
import CheckM from '@semcore/icon/Check/m';
|
|
62
|
+
import CloseM from '@semcore/icon/Close/m';
|
|
63
|
+
import Spin from '@semcore/spin';
|
|
64
|
+
|
|
65
|
+
var isFocusOutsideOf = function isFocusOutsideOf(element) {
|
|
66
|
+
var traversed = document.activeElement;
|
|
67
|
+
|
|
68
|
+
for (var i = 0; i < 1000000; i++) {
|
|
69
|
+
if (traversed === element) return false;
|
|
70
|
+
if (traversed === document.body) return true;
|
|
71
|
+
traversed = traversed.parentElement;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
throw new Error('Failed to traverse parents chain in utilite `isFocusOutsideOf` reasonable count of iterations. Possibly Shadow DOM or come other uncommon DOM-way is used, that is not supported by utilite yet. If you are not doing weird things or that is reasonable, contact developers team for yours case support.');
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var InlineInputBase = /*#__PURE__*/function (_Component) {
|
|
78
|
+
_inherits(InlineInputBase, _Component);
|
|
79
|
+
|
|
80
|
+
var _super = _createSuper(InlineInputBase);
|
|
81
|
+
|
|
82
|
+
function InlineInputBase(props) {
|
|
83
|
+
var _this;
|
|
84
|
+
|
|
85
|
+
_classCallCheck(this, InlineInputBase);
|
|
86
|
+
|
|
87
|
+
_this = _super.call(this, props);
|
|
88
|
+
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
90
|
+
focused: false
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "rootRef", /*#__PURE__*/React.createRef());
|
|
94
|
+
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "inputRef", /*#__PURE__*/React.createRef());
|
|
96
|
+
|
|
97
|
+
_defineProperty(_assertThisInitialized(_this), "initValue", '');
|
|
98
|
+
|
|
99
|
+
_this.handleConfirm = _this.handleConfirm.bind(_assertThisInitialized(_this));
|
|
100
|
+
_this.handleCancel = _this.handleCancel.bind(_assertThisInitialized(_this));
|
|
101
|
+
_this.handleFocus = _this.handleFocus.bind(_assertThisInitialized(_this));
|
|
102
|
+
_this.handleBlur = _this.handleBlur.bind(_assertThisInitialized(_this));
|
|
103
|
+
_this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_createClass(InlineInputBase, [{
|
|
108
|
+
key: "uncontrolledProps",
|
|
109
|
+
value: function uncontrolledProps() {
|
|
110
|
+
return {
|
|
111
|
+
value: null
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "componentDidMount",
|
|
116
|
+
value: function componentDidMount() {
|
|
117
|
+
var _this$asProps$value;
|
|
118
|
+
|
|
119
|
+
this.initValue = ((_this$asProps$value = this.asProps.value) !== null && _this$asProps$value !== void 0 ? _this$asProps$value : this.asProps.defaultValue) || '';
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "getContextProps",
|
|
123
|
+
value: function getContextProps() {
|
|
124
|
+
var _this$asProps = this.asProps,
|
|
125
|
+
loading = _this$asProps.loading,
|
|
126
|
+
value = _this$asProps.value,
|
|
127
|
+
defaultValue = _this$asProps.defaultValue,
|
|
128
|
+
state = _this$asProps.state,
|
|
129
|
+
_this$asProps$confirm = _this$asProps.confirmText,
|
|
130
|
+
confirmText = _this$asProps$confirm === void 0 ? 'Confirm' : _this$asProps$confirm,
|
|
131
|
+
_this$asProps$cancelT = _this$asProps.cancelText,
|
|
132
|
+
cancelText = _this$asProps$cancelT === void 0 ? 'Cancel' : _this$asProps$cancelT,
|
|
133
|
+
_this$asProps$tooltip = _this$asProps.tooltipsProps,
|
|
134
|
+
tooltipsProps = _this$asProps$tooltip === void 0 ? {} : _this$asProps$tooltip;
|
|
135
|
+
return {
|
|
136
|
+
loading: loading,
|
|
137
|
+
onConfirm: this.handleConfirm,
|
|
138
|
+
onCancel: this.handleCancel,
|
|
139
|
+
value: value,
|
|
140
|
+
defaultValue: defaultValue,
|
|
141
|
+
state: state,
|
|
142
|
+
confirmText: confirmText,
|
|
143
|
+
cancelText: cancelText,
|
|
144
|
+
tooltipsProps: tooltipsProps
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "geAddonProps",
|
|
149
|
+
value: function geAddonProps() {
|
|
150
|
+
return this.getContextProps();
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "getConfirmControlProps",
|
|
154
|
+
value: function getConfirmControlProps() {
|
|
155
|
+
return this.getContextProps();
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "getCancelControlProps",
|
|
159
|
+
value: function getCancelControlProps() {
|
|
160
|
+
return this.getContextProps();
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "getControlsProps",
|
|
164
|
+
value: function getControlsProps() {
|
|
165
|
+
return this.getContextProps();
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "getValueProps",
|
|
169
|
+
value: function getValueProps() {
|
|
170
|
+
var _this$asProps2 = this.asProps,
|
|
171
|
+
autoFocus = _this$asProps2.autoFocus,
|
|
172
|
+
value = _this$asProps2.value,
|
|
173
|
+
inputId = _this$asProps2.inputId,
|
|
174
|
+
defaultValue = _this$asProps2.defaultValue,
|
|
175
|
+
onChange = _this$asProps2.onChange,
|
|
176
|
+
state = _this$asProps2.state,
|
|
177
|
+
loading = _this$asProps2.loading,
|
|
178
|
+
placeholder = _this$asProps2.placeholder;
|
|
179
|
+
return {
|
|
180
|
+
ref: this.inputRef,
|
|
181
|
+
autoFocus: autoFocus,
|
|
182
|
+
value: value,
|
|
183
|
+
defaultValue: defaultValue,
|
|
184
|
+
onChange: onChange,
|
|
185
|
+
state: state,
|
|
186
|
+
loading: loading,
|
|
187
|
+
placeholder: placeholder,
|
|
188
|
+
id: inputId
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "handleConfirm",
|
|
193
|
+
value: function handleConfirm(text, event) {
|
|
194
|
+
var onConfirm = this.asProps.onConfirm;
|
|
195
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(text, event);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "handleCancel",
|
|
200
|
+
value: function handleCancel(prevText, event) {
|
|
201
|
+
var onCancel = this.asProps.onCancel;
|
|
202
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(prevText, event);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "handleFocus",
|
|
207
|
+
value: function handleFocus(event) {
|
|
208
|
+
var onFocus = this.asProps.onFocus;
|
|
209
|
+
this.setState({
|
|
210
|
+
focused: true
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
if (onFocus) {
|
|
214
|
+
onFocus(event);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "handleBlur",
|
|
219
|
+
value: function handleBlur(event) {
|
|
220
|
+
var _this2 = this;
|
|
221
|
+
|
|
222
|
+
var _this$asProps3 = this.asProps,
|
|
223
|
+
onConfirm = _this$asProps3.onConfirm,
|
|
224
|
+
onCancel = _this$asProps3.onCancel,
|
|
225
|
+
onBlur = _this$asProps3.onBlur,
|
|
226
|
+
onBlurBehavior = _this$asProps3.onBlurBehavior,
|
|
227
|
+
value = _this$asProps3.value;
|
|
228
|
+
this.setState({
|
|
229
|
+
focused: false
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
if (onBlurBehavior) {
|
|
233
|
+
setTimeout(function () {
|
|
234
|
+
if (isFocusOutsideOf(_this2.rootRef.current)) {
|
|
235
|
+
if (onBlurBehavior === 'confirm') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
236
|
+
if (onBlurBehavior === 'cancel') onCancel === null || onCancel === void 0 ? void 0 : onCancel(_this2.initValue, event);
|
|
237
|
+
}
|
|
238
|
+
}, 0);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (onBlur) {
|
|
242
|
+
onBlur(event);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "handleKeyDown",
|
|
247
|
+
value: function handleKeyDown(event) {
|
|
248
|
+
var _this$asProps4 = this.asProps,
|
|
249
|
+
onConfirm = _this$asProps4.onConfirm,
|
|
250
|
+
onCancel = _this$asProps4.onCancel,
|
|
251
|
+
value = _this$asProps4.value;
|
|
252
|
+
if (event.code === 'Enter') onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(value, event);
|
|
253
|
+
if (event.code === 'Escape') onCancel === null || onCancel === void 0 ? void 0 : onCancel(this.initValue, event);
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "render",
|
|
257
|
+
value: function render() {
|
|
258
|
+
var _ref = this ? this.asProps : arguments[0],
|
|
259
|
+
_ref7;
|
|
260
|
+
|
|
261
|
+
var SInlineInput = Box;
|
|
262
|
+
var SUnderline = 'div';
|
|
263
|
+
var _this$asProps5 = this.asProps,
|
|
264
|
+
providedChildren = _this$asProps5.Children,
|
|
265
|
+
hasChildren = _this$asProps5.children,
|
|
266
|
+
styles = _this$asProps5.styles,
|
|
267
|
+
loading = _this$asProps5.loading;
|
|
268
|
+
var Children = hasChildren ? providedChildren : DefaultChildren;
|
|
269
|
+
var focused = this.state.focused;
|
|
270
|
+
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SInlineInput, _ref7.cn("SInlineInput", _objectSpread({}, _assignProps({
|
|
271
|
+
"ref": this.rootRef,
|
|
272
|
+
"onFocus": this.handleFocus,
|
|
273
|
+
"onBlur": this.handleBlur,
|
|
274
|
+
"onKeyDown": this.handleKeyDown,
|
|
275
|
+
"focused": focused,
|
|
276
|
+
"loading": loading
|
|
277
|
+
}, _ref))), /*#__PURE__*/React.createElement(SUnderline, _ref7.cn("SUnderline", {}), /*#__PURE__*/React.createElement(Children, _ref7.cn("Children", {}))));
|
|
278
|
+
}
|
|
279
|
+
}]);
|
|
280
|
+
|
|
281
|
+
return InlineInputBase;
|
|
282
|
+
}(Component);
|
|
283
|
+
|
|
284
|
+
_defineProperty(InlineInputBase, "displayName", 'InlineInput');
|
|
285
|
+
|
|
286
|
+
_defineProperty(InlineInputBase, "defaultProps", {
|
|
287
|
+
state: 'normal',
|
|
288
|
+
loading: false,
|
|
289
|
+
defaultValue: '',
|
|
290
|
+
__excludeProps: ['defaultValue', 'placeholder', 'tooltipsProps', 'confirmText', 'cancelText', 'autoFocus', 'inputId']
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
_defineProperty(InlineInputBase, "style", style);
|
|
294
|
+
|
|
295
|
+
var Value = /*#__PURE__*/function (_Component2) {
|
|
296
|
+
_inherits(Value, _Component2);
|
|
297
|
+
|
|
298
|
+
var _super2 = _createSuper(Value);
|
|
299
|
+
|
|
300
|
+
function Value() {
|
|
301
|
+
_classCallCheck(this, Value);
|
|
302
|
+
|
|
303
|
+
return _super2.apply(this, arguments);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
_createClass(Value, [{
|
|
307
|
+
key: "uncontrolledProps",
|
|
308
|
+
value: function uncontrolledProps() {
|
|
309
|
+
return {
|
|
310
|
+
value: function value(event) {
|
|
311
|
+
event.stopPropagation();
|
|
312
|
+
return event.target.value;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
key: "render",
|
|
318
|
+
value: function render() {
|
|
319
|
+
var _ref2 = this ? this.asProps : arguments[0],
|
|
320
|
+
_ref8;
|
|
321
|
+
|
|
322
|
+
var SValue = Box;
|
|
323
|
+
return _ref8 = sstyled(this.asProps.styles), /*#__PURE__*/React.createElement(SValue, _ref8.cn("SValue", _objectSpread({}, _assignProps2({
|
|
324
|
+
"tag": "input",
|
|
325
|
+
"type": "text",
|
|
326
|
+
"disabled": this.asProps.state === 'disabled' || this.asProps.loading
|
|
327
|
+
}, _ref2))));
|
|
328
|
+
}
|
|
329
|
+
}]);
|
|
330
|
+
|
|
331
|
+
return Value;
|
|
332
|
+
}(Component);
|
|
333
|
+
|
|
334
|
+
_defineProperty(Value, "defaultProps", {
|
|
335
|
+
defaultValue: ''
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
_defineProperty(Value, "enhance", [autoFocusEnhance()]);
|
|
339
|
+
|
|
340
|
+
var Addon = function Addon(props) {
|
|
341
|
+
var _ref3 = _this3 ? _this3.asProps : arguments[0],
|
|
342
|
+
_ref9;
|
|
343
|
+
|
|
344
|
+
var SAddon = Box;
|
|
345
|
+
return _ref9 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
var ConfirmControl = function ConfirmControl(props) {
|
|
349
|
+
var _ref4 = _this3 ? _this3.asProps : arguments[0],
|
|
350
|
+
_ref11,
|
|
351
|
+
_props$value;
|
|
352
|
+
|
|
353
|
+
var SConfirmControl = Box;
|
|
354
|
+
var Children = props.Children,
|
|
355
|
+
hasChildren = props.children;
|
|
356
|
+
var handleConfirm = React.useCallback(function (event) {
|
|
357
|
+
var _props$onConfirm;
|
|
358
|
+
|
|
359
|
+
(_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, props.value, event);
|
|
360
|
+
}, [props.onConfirm, props.value]);
|
|
361
|
+
var handleKeydown = React.useCallback(function (event) {
|
|
362
|
+
if (props.loading) return;
|
|
363
|
+
|
|
364
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
365
|
+
event.preventDefault();
|
|
366
|
+
event.stopPropagation();
|
|
367
|
+
handleConfirm(event);
|
|
368
|
+
}
|
|
369
|
+
}, [props.loading, handleConfirm]);
|
|
370
|
+
|
|
371
|
+
if (props.loading) {
|
|
372
|
+
var _ref10;
|
|
373
|
+
|
|
374
|
+
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SConfirmControl, _ref10.cn("SConfirmControl", _objectSpread({}, _assignProps4({
|
|
375
|
+
"className": "controls-icon"
|
|
376
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})) : /*#__PURE__*/React.createElement(Spin, _ref10.cn("Spin", {
|
|
377
|
+
"size": "xxs",
|
|
378
|
+
"className": "spin"
|
|
379
|
+
})));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SConfirmControl, _ref11.cn("SConfirmControl", _objectSpread({}, _assignProps5({
|
|
383
|
+
"onKeyDown": handleKeydown
|
|
384
|
+
}, _ref4))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref11.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref11.cn("Tooltip", _objectSpread({}, props.tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
|
|
385
|
+
className: "controls-icon"
|
|
386
|
+
}, /*#__PURE__*/React.createElement(CheckM, _ref11.cn("CheckM", {
|
|
387
|
+
"tabIndex": 0,
|
|
388
|
+
"aria-label": "".concat(props.confirmText, " ").concat((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : ''),
|
|
389
|
+
"role": "button",
|
|
390
|
+
"onClick": handleConfirm
|
|
391
|
+
}))), /*#__PURE__*/React.createElement(Tooltip.Popper, {
|
|
392
|
+
p: 2
|
|
393
|
+
}, props.confirmText)));
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
var CancelControl = function CancelControl(props) {
|
|
397
|
+
var _ref5 = _this3 ? _this3.asProps : arguments[0],
|
|
398
|
+
_ref13,
|
|
399
|
+
_props$value2;
|
|
400
|
+
|
|
401
|
+
var SCancelControl = Box;
|
|
402
|
+
var Children = props.Children,
|
|
403
|
+
hasChildren = props.children;
|
|
404
|
+
var initValue = React.useRef((_props$value2 = props.value) !== null && _props$value2 !== void 0 ? _props$value2 : props.defaultValue);
|
|
405
|
+
var handleCancel = React.useCallback(function (event) {
|
|
406
|
+
var _props$onCancel;
|
|
407
|
+
|
|
408
|
+
if (props.loading || !props.onCancel) return;
|
|
409
|
+
(_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, initValue.current, event);
|
|
410
|
+
}, [props.loading, props.onCancel]);
|
|
411
|
+
var handleKeydown = React.useCallback(function (event) {
|
|
412
|
+
if (props.loading) return;
|
|
413
|
+
|
|
414
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
event.stopPropagation();
|
|
417
|
+
handleCancel(event);
|
|
418
|
+
}
|
|
419
|
+
}, [props.loading, handleCancel]);
|
|
420
|
+
|
|
421
|
+
if (props.loading) {
|
|
422
|
+
var _ref12;
|
|
423
|
+
|
|
424
|
+
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SCancelControl, _ref12.cn("SCancelControl", _objectSpread({}, _assignProps6({
|
|
425
|
+
"className": "controls-icon"
|
|
426
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref12.cn("Children", {})) : /*#__PURE__*/React.createElement(CloseM, _ref12.cn("CloseM", {
|
|
427
|
+
"disabled": true
|
|
428
|
+
})));
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SCancelControl, _ref13.cn("SCancelControl", _objectSpread({}, _assignProps7({
|
|
432
|
+
"onKeyDown": handleKeydown
|
|
433
|
+
}, _ref5))), hasChildren ? /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/React.createElement(Tooltip, _ref13.cn("Tooltip", _objectSpread({}, props.tooltipsProps)), /*#__PURE__*/React.createElement(Tooltip.Trigger, {
|
|
434
|
+
className: "controls-icon"
|
|
435
|
+
}, /*#__PURE__*/React.createElement(CloseM, _ref13.cn("CloseM", {
|
|
436
|
+
"tabIndex": 0,
|
|
437
|
+
"aria-label": props.cancelText,
|
|
438
|
+
"role": "button",
|
|
439
|
+
"onClick": handleCancel
|
|
440
|
+
}))), /*#__PURE__*/React.createElement(Tooltip.Popper, {
|
|
441
|
+
p: 2
|
|
442
|
+
}, props.cancelText)));
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
var Controls = function Controls(props) {
|
|
446
|
+
var _ref6 = _this3 ? _this3.asProps : arguments[0],
|
|
447
|
+
_ref14;
|
|
448
|
+
|
|
449
|
+
var SControls = Box;
|
|
450
|
+
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SControls, _ref14.cn("SControls", _objectSpread({}, _assignProps8({}, _ref6))), /*#__PURE__*/React.createElement(InlineInput.ConfirmControl, {
|
|
451
|
+
tooltipsProps: props.tooltipsProps,
|
|
452
|
+
confirmText: props.confirmText,
|
|
453
|
+
onConfirm: props.onConfirm
|
|
454
|
+
}), /*#__PURE__*/React.createElement(InlineInput.CancelControl, {
|
|
455
|
+
tooltipsProps: props.tooltipsProps,
|
|
456
|
+
cancelText: props.cancelText,
|
|
457
|
+
onCancel: props.onCancel
|
|
458
|
+
}));
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
var DefaultChildren = function DefaultChildren(props) {
|
|
462
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InlineInput.Value, props), /*#__PURE__*/React.createElement(InlineInput.Controls, null));
|
|
463
|
+
};
|
|
464
|
+
/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
var InlineInput = createComponent(InlineInputBase, {
|
|
468
|
+
Addon: Addon,
|
|
469
|
+
Value: Value,
|
|
470
|
+
ConfirmControl: ConfirmControl,
|
|
471
|
+
CancelControl: CancelControl,
|
|
472
|
+
Controls: Controls
|
|
473
|
+
});
|
|
474
|
+
export default InlineInput;
|
|
475
|
+
//# sourceMappingURL=InlineInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/InlineInput.tsx"],"names":["React","createComponent","Component","sstyled","Root","Box","autoFocusEnhance","Tooltip","CheckM","CloseM","Spin","isFocusOutsideOf","element","traversed","document","activeElement","i","body","parentElement","Error","InlineInputBase","props","focused","createRef","handleConfirm","bind","handleCancel","handleFocus","handleBlur","handleKeyDown","value","initValue","asProps","defaultValue","loading","state","confirmText","cancelText","tooltipsProps","onConfirm","onCancel","getContextProps","autoFocus","inputId","onChange","placeholder","ref","inputRef","id","text","event","prevText","onFocus","setState","onBlur","onBlurBehavior","setTimeout","rootRef","current","code","SInlineInput","SUnderline","providedChildren","Children","hasChildren","children","styles","DefaultChildren","__excludeProps","style","Value","stopPropagation","target","SValue","Addon","SAddon","ConfirmControl","SConfirmControl","useCallback","handleKeydown","preventDefault","CancelControl","SCancelControl","useRef","Controls","SControls","InlineInput"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,gBAAP,MAA6B,8CAA7B;AACA,OAAOC,OAAP,MAAuC,kBAAvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,MAAP,MAAmB,uBAAnB;AACA,OAAOC,MAAP,MAAmB,uBAAnB;AACA,OAAOC,IAAP,MAAiB,eAAjB;;AAEA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,OAAD,EAA0B;AACjD,MAAIC,SAAS,GAAGC,QAAQ,CAACC,aAAzB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,OAApB,EAA6BA,CAAC,EAA9B,EAAkC;AAChC,QAAIH,SAAS,KAAKD,OAAlB,EAA2B,OAAO,KAAP;AAC3B,QAAIC,SAAS,KAAKC,QAAQ,CAACG,IAA3B,EAAiC,OAAO,IAAP;AACjCJ,IAAAA,SAAS,GAAGA,SAAS,CAACK,aAAtB;AACD;;AAED,QAAM,IAAIC,KAAJ,CACJ,2SADI,CAAN;AAGD,CAXD;;IAwCMC,e;;;;;AAiCJ,2BAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,4DAdX;AACNC,MAAAA,OAAO,EAAE;AADH,KAcW;;AAAA,2EAVTtB,KAAK,CAACuB,SAAN,EAUS;;AAAA,4EATRvB,KAAK,CAACuB,SAAN,EASQ;;AAAA,gEARC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kC,GAAG,SAArCA,eAAqC,CAAC9C,KAAD,EAAW;AACpD,sBACE,uDACE,oBAAC,WAAD,CAAa,KAAb,EAAuBA,KAAvB,CADF,eAEE,oBAAC,WAAD,CAAa,QAAb,OAFF,CADF;AAMD,CAPD;AASA;;;AACA,IAAMiE,WAAW,GAAGrF,eAAe,CAACmB,eAAD,EAAkB;AACnDsD,EAAAA,KAAK,EAALA,KADmD;AAEnDJ,EAAAA,KAAK,EAALA,KAFmD;AAGnDM,EAAAA,cAAc,EAAdA,cAHmD;AAInDK,EAAAA,aAAa,EAAbA,aAJmD;AAKnDG,EAAAA,QAAQ,EAARA;AALmD,CAAlB,CAAnC;AAQA,eAAeE,WAAf","sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport autoFocusEnhance from '@semcore/utils/lib/enhances/autoFocusEnhance';\nimport Tooltip, { ITooltipProps } from '@semcore/tooltip';\nimport style from './style/inline-input.shadow.css';\nimport CheckM from '@semcore/icon/Check/m';\nimport CloseM from '@semcore/icon/Close/m';\nimport Spin from '@semcore/spin';\n\nconst isFocusOutsideOf = (element: HTMLElement) => {\n let traversed = document.activeElement;\n for (let i = 0; i < 1000000; i++) {\n if (traversed === element) return false;\n if (traversed === document.body) return true;\n traversed = traversed.parentElement;\n }\n\n throw new Error(\n 'Failed to traverse parents chain in utilite `isFocusOutsideOf` reasonable count of iterations. Possibly Shadow DOM or come other uncommon DOM-way is used, that is not supported by utilite yet. If you are not doing weird things or that is reasonable, contact developers team for yours case support.',\n );\n};\n\ntype AsProps = {\n state?: 'normal' | 'valid' | 'invalid' | 'disabled';\n loading?: boolean;\n onConfirm?: (\n value: string,\n event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,\n ) => void;\n onCancel?: (\n prevValue: string,\n event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent,\n ) => void;\n value?: string;\n defaultValue?: string;\n confirmText?: string;\n cancelText?: string;\n tooltipsProps?: ITooltipProps;\n autoFocus?: boolean;\n placeholder?: string;\n inputId?: string;\n onChange?: (value: string, event: React.ChangeEvent) => void;\n onBlur?: (event: React.FocusEvent) => void;\n onFocus?: (event: React.FocusEvent) => void;\n onBlurBehavior?: 'cancel' | 'confirm';\n styles?: React.CSSProperties;\n Children: React.FC;\n};\n\nclass InlineInputBase extends Component<AsProps> {\n static displayName = 'InlineInput';\n\n static defaultProps = {\n state: 'normal',\n loading: false,\n defaultValue: '',\n __excludeProps: [\n 'defaultValue',\n 'placeholder',\n 'tooltipsProps',\n 'confirmText',\n 'cancelText',\n 'autoFocus',\n 'inputId',\n ],\n };\n static style = style;\n\n state = {\n focused: false,\n };\n\n rootRef = React.createRef<HTMLElement>();\n inputRef = React.createRef();\n initValue: string = '';\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n constructor(props) {\n super(props);\n this.handleConfirm = this.handleConfirm.bind(this);\n this.handleCancel = this.handleCancel.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n componentDidMount() {\n this.initValue = ((this.asProps.value ?? this.asProps.defaultValue) as string) || '';\n }\n\n getContextProps() {\n const {\n loading,\n value,\n defaultValue,\n state,\n confirmText = 'Confirm',\n cancelText = 'Cancel',\n tooltipsProps = {},\n } = this.asProps;\n\n return {\n loading,\n onConfirm: this.handleConfirm,\n onCancel: this.handleCancel,\n value,\n defaultValue,\n state,\n confirmText,\n cancelText,\n tooltipsProps,\n };\n }\n\n geAddonProps() {\n return this.getContextProps();\n }\n getConfirmControlProps() {\n return this.getContextProps();\n }\n getCancelControlProps() {\n return this.getContextProps();\n }\n getControlsProps() {\n return this.getContextProps();\n }\n\n getValueProps() {\n const { autoFocus, value, inputId, defaultValue, onChange, state, loading, placeholder } =\n this.asProps;\n\n return {\n ref: this.inputRef,\n autoFocus,\n value,\n defaultValue,\n onChange,\n state,\n loading,\n placeholder,\n id: inputId,\n };\n }\n\n handleConfirm(text: string, event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent) {\n const { onConfirm } = this.asProps;\n onConfirm?.(text, event);\n return false;\n }\n handleCancel(prevText: string, event: React.MouseEvent | React.FocusEvent | React.KeyboardEvent) {\n const { onCancel } = this.asProps;\n onCancel?.(prevText, event);\n return false;\n }\n\n handleFocus(event: React.FocusEvent) {\n const { onFocus } = this.asProps;\n this.setState({ focused: true });\n if (onFocus) {\n onFocus(event);\n }\n }\n handleBlur(event: React.FocusEvent) {\n const { onConfirm, onCancel, onBlur, onBlurBehavior, value } = this.asProps;\n this.setState({ focused: false });\n if (onBlurBehavior) {\n setTimeout(() => {\n if (isFocusOutsideOf(this.rootRef.current)) {\n if (onBlurBehavior === 'confirm') onConfirm?.(value, event);\n if (onBlurBehavior === 'cancel') onCancel?.(this.initValue, event);\n }\n }, 0);\n }\n if (onBlur) {\n onBlur(event);\n }\n }\n handleKeyDown(event: React.KeyboardEvent) {\n const { onConfirm, onCancel, value } = this.asProps;\n if (event.code === 'Enter') onConfirm?.(value, event);\n if (event.code === 'Escape') onCancel?.(this.initValue, event);\n }\n\n render() {\n const SInlineInput = Root;\n const SUnderline = 'div';\n const { Children: providedChildren, children: hasChildren, styles, loading } = this.asProps;\n const Children = hasChildren ? providedChildren : DefaultChildren;\n const { focused } = this.state;\n\n return sstyled(styles)(\n <SInlineInput\n ref={this.rootRef}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n render={Box}\n focused={focused}\n loading={loading}\n >\n <SUnderline>\n <Children />\n </SUnderline>\n </SInlineInput>,\n );\n }\n}\n\nclass Value extends Component<AsProps> {\n static defaultProps = {\n defaultValue: '',\n };\n static enhance = [autoFocusEnhance()];\n\n uncontrolledProps() {\n return {\n value: (event) => {\n event.stopPropagation();\n return event.target.value;\n },\n };\n }\n\n render() {\n const SValue = Root;\n\n return sstyled(this.asProps.styles)(\n <SValue\n render={Box}\n tag=\"input\"\n type=\"text\"\n disabled={this.asProps.state === 'disabled' || this.asProps.loading}\n />,\n );\n }\n}\n\nconst Addon: React.FC<AsProps> = (props) => {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} />) as React.ReactElement;\n};\n\nconst ConfirmControl: React.FC<AsProps> = (props) => {\n const SConfirmControl = Root;\n const { Children, children: hasChildren } = props;\n\n const handleConfirm = React.useCallback(\n (event: React.MouseEvent | React.KeyboardEvent) => {\n props.onConfirm?.(props.value, event);\n },\n [props.onConfirm, props.value],\n );\n const handleKeydown = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (props.loading) return;\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n event.stopPropagation();\n handleConfirm(event);\n }\n },\n [props.loading, handleConfirm],\n );\n\n if (props.loading) {\n return sstyled(props.styles)(\n <SConfirmControl render={Box} className=\"controls-icon\">\n {hasChildren ? <Children /> : <Spin size=\"xxs\" className=\"spin\" />}\n </SConfirmControl>,\n ) as React.ReactElement;\n }\n\n return sstyled(props.styles)(\n <SConfirmControl render={Box} onKeyDown={handleKeydown}>\n {hasChildren ? (\n <Children />\n ) : (\n <Tooltip {...props.tooltipsProps}>\n <Tooltip.Trigger className=\"controls-icon\">\n <CheckM\n tabIndex={0}\n aria-label={`${props.confirmText} ${props.value ?? ''}`}\n role=\"button\"\n onClick={handleConfirm}\n />\n </Tooltip.Trigger>\n <Tooltip.Popper p={2}>{props.confirmText}</Tooltip.Popper>\n </Tooltip>\n )}\n </SConfirmControl>,\n ) as React.ReactElement;\n};\nconst CancelControl: React.FC<AsProps> = (props) => {\n const SCancelControl = Root;\n const { Children, children: hasChildren } = props;\n const initValue = React.useRef(props.value ?? props.defaultValue);\n const handleCancel = React.useCallback(\n (event: React.MouseEvent | React.KeyboardEvent) => {\n if (props.loading || !props.onCancel) return;\n props.onCancel?.(initValue.current, event);\n },\n [props.loading, props.onCancel],\n );\n const handleKeydown = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (props.loading) return;\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n event.stopPropagation();\n handleCancel(event);\n }\n },\n [props.loading, handleCancel],\n );\n\n if (props.loading) {\n return sstyled(props.styles)(\n <SCancelControl render={Box} className=\"controls-icon\">\n {hasChildren ? <Children /> : <CloseM disabled={true} />}\n </SCancelControl>,\n ) as React.ReactElement;\n }\n\n return sstyled(props.styles)(\n <SCancelControl render={Box} onKeyDown={handleKeydown}>\n {hasChildren ? (\n <Children />\n ) : (\n <Tooltip {...props.tooltipsProps}>\n <Tooltip.Trigger className=\"controls-icon\">\n <CloseM\n tabIndex={0}\n aria-label={props.cancelText}\n role=\"button\"\n onClick={handleCancel}\n />\n </Tooltip.Trigger>\n <Tooltip.Popper p={2}>{props.cancelText}</Tooltip.Popper>\n </Tooltip>\n )}\n </SCancelControl>,\n ) as React.ReactElement;\n};\n\nconst Controls: React.FC<AsProps> = (props) => {\n const SControls = Root;\n return sstyled(props.styles)(\n <SControls render={Box}>\n <InlineInput.ConfirmControl\n tooltipsProps={props.tooltipsProps}\n confirmText={props.confirmText}\n onConfirm={props.onConfirm}\n />\n <InlineInput.CancelControl\n tooltipsProps={props.tooltipsProps}\n cancelText={props.cancelText}\n onCancel={props.onCancel}\n />\n </SControls>,\n ) as React.ReactElement;\n};\n\nconst DefaultChildren: React.FC<AsProps> = (props) => {\n return (\n <>\n <InlineInput.Value {...props} />\n <InlineInput.Controls />\n </>\n ) as React.ReactElement;\n};\n\n/** `createComponent` currently exposes unrelated junk instead of typings, that the reason of to any cast */\nconst InlineInput = createComponent(InlineInputBase, {\n Addon,\n Value,\n ConfirmControl,\n CancelControl,\n Controls,\n}) as any;\n\nexport default InlineInput;\n"],"file":"InlineInput.js"}
|
package/lib/es6/index.js
ADDED