wini-web-components 1.0.3 → 1.0.5
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.
|
@@ -12,7 +12,7 @@ interface SelectMultipleProps {
|
|
|
12
12
|
helperTextColor?: string;
|
|
13
13
|
style?: CSSProperties;
|
|
14
14
|
handleSearch?: (e: string) => Promise<Array<OptionsItem>>;
|
|
15
|
-
|
|
15
|
+
showClearValueButton?: boolean;
|
|
16
16
|
}
|
|
17
17
|
interface SelectMultipleState {
|
|
18
18
|
value: Array<string | number>;
|
|
@@ -275,7 +275,7 @@ var SelectMultiple = /** @class */ (function (_super) {
|
|
|
275
275
|
else
|
|
276
276
|
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, onSelect: null }));
|
|
277
277
|
} })),
|
|
278
|
-
this.props.
|
|
278
|
+
this.props.showClearValueButton && react_1.default.createElement("button", { type: 'button', className: 'row', style: { padding: '0.4rem' }, onClick: function (ev) {
|
|
279
279
|
ev.stopPropagation();
|
|
280
280
|
if (_this.state.value.length)
|
|
281
281
|
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, value: [] }));
|
|
@@ -17,7 +17,7 @@ interface Select1Props {
|
|
|
17
17
|
helperTextColor?: string;
|
|
18
18
|
style?: CSSProperties;
|
|
19
19
|
handleSearch?: (e: string) => Promise<Array<OptionsItem>>;
|
|
20
|
-
|
|
20
|
+
showClearValueButton?: boolean;
|
|
21
21
|
}
|
|
22
22
|
interface Select1State {
|
|
23
23
|
value?: string | number;
|
|
@@ -193,16 +193,19 @@ var Select1 = /** @class */ (function (_super) {
|
|
|
193
193
|
};
|
|
194
194
|
Select1.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
195
195
|
var _this = this;
|
|
196
|
-
var _a, _b, _c, _d, _e, _f;
|
|
197
|
-
if (prevProps.options !== this.props.options)
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
197
|
+
if (prevProps.options !== this.props.options) {
|
|
198
198
|
this.setState(__assign(__assign({}, this.state), { options: this.props.options }));
|
|
199
|
+
if (this.inputRef.current)
|
|
200
|
+
this.inputRef.current.value = "".concat((_b = (_a = this.state.options.find(function (e) { return e.id === _this.state.value; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "");
|
|
201
|
+
}
|
|
199
202
|
if (prevProps.value !== this.props.value)
|
|
200
203
|
this.setState(__assign(__assign({}, this.state), { value: this.props.value }));
|
|
201
204
|
if (prevState.value !== this.state.value && this.inputRef.current)
|
|
202
|
-
this.inputRef.current.value = "".concat((
|
|
205
|
+
this.inputRef.current.value = "".concat((_d = (_c = this.state.options.find(function (e) { return e.id === _this.state.value; })) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "");
|
|
203
206
|
//
|
|
204
207
|
if (this.state.isOpen && prevState.isOpen !== this.state.isOpen) {
|
|
205
|
-
var thisPopupRect = (
|
|
208
|
+
var thisPopupRect = (_e = document.body.querySelector('.select1-popup')) === null || _e === void 0 ? void 0 : _e.getBoundingClientRect();
|
|
206
209
|
if (thisPopupRect) {
|
|
207
210
|
var style = void 0;
|
|
208
211
|
if (thisPopupRect.right > document.body.offsetWidth) {
|
|
@@ -212,15 +215,15 @@ var Select1 = /** @class */ (function (_super) {
|
|
|
212
215
|
};
|
|
213
216
|
}
|
|
214
217
|
var _bottom = thisPopupRect.bottom - 8;
|
|
215
|
-
var thisContainerRect = (
|
|
218
|
+
var thisContainerRect = (_f = this.containerRef.current) === null || _f === void 0 ? void 0 : _f.getBoundingClientRect();
|
|
216
219
|
if (thisContainerRect) {
|
|
217
220
|
if (_bottom > document.body.offsetHeight) {
|
|
218
221
|
style = __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { top: "".concat(thisContainerRect.y - 2 - thisPopupRect.height, "px") });
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
if (style) {
|
|
222
|
-
(
|
|
223
|
-
(
|
|
225
|
+
(_g = style.left) !== null && _g !== void 0 ? _g : (style.left = style.right ? undefined : "".concat(this.state.offset.x, "px"));
|
|
226
|
+
(_h = style.width) !== null && _h !== void 0 ? _h : (style.width = "".concat(this.state.offset.width, "px"));
|
|
224
227
|
this.setState(__assign(__assign({}, this.state), { style: style }));
|
|
225
228
|
}
|
|
226
229
|
}
|
|
@@ -243,7 +246,7 @@ var Select1 = /** @class */ (function (_super) {
|
|
|
243
246
|
else
|
|
244
247
|
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, onSelect: null }));
|
|
245
248
|
} })),
|
|
246
|
-
this.props.
|
|
249
|
+
this.props.showClearValueButton && react_1.default.createElement("button", { type: 'button', className: 'row', style: { padding: '0.4rem' }, onClick: function (ev) {
|
|
247
250
|
ev.stopPropagation();
|
|
248
251
|
if (_this.state.value)
|
|
249
252
|
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, value: undefined }));
|