wini-web-components 0.9.6 → 0.9.8
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/dist/component/checkbox/checkbox.js +9 -5
- package/dist/component/input-multi-select/input-multi-select.d.ts +5 -1
- package/dist/component/input-multi-select/input-multi-select.js +127 -61
- package/dist/component/select1/select1.d.ts +3 -2
- package/dist/component/select1/select1.js +0 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ var Checkbox = /** @class */ (function (_super) {
|
|
|
50
50
|
};
|
|
51
51
|
Checkbox.prototype.render = function () {
|
|
52
52
|
var _this = this;
|
|
53
|
-
var _a, _b, _c;
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
54
|
var convertStyle = {
|
|
55
55
|
width: (_a = this.props.size) !== null && _a !== void 0 ? _a : '2.4rem',
|
|
56
56
|
height: (_b = this.props.size) !== null && _b !== void 0 ? _b : '2.4rem',
|
|
@@ -64,16 +64,20 @@ var Checkbox = /** @class */ (function (_super) {
|
|
|
64
64
|
delete this.props.style.maxHeight;
|
|
65
65
|
convertStyle = __assign(__assign({}, this.props.style), convertStyle);
|
|
66
66
|
}
|
|
67
|
-
return react_1.default.createElement("label", { className: "checkbox-container row", style: convertStyle },
|
|
68
|
-
react_1.default.createElement("input", { type: "checkbox", checked: this.state.value, disabled: this.props.disabled, onChange: function () {
|
|
67
|
+
return react_1.default.createElement("label", { className: "checkbox-container row", style: convertStyle, "is-null-value": "".concat(this.state.value == undefined) },
|
|
68
|
+
react_1.default.createElement("input", { type: "checkbox", checked: this.state.value, disabled: this.props.disabled, onChange: function (ev) {
|
|
69
|
+
ev.stopPropagation();
|
|
69
70
|
var newValue = !_this.state.value;
|
|
70
71
|
_this.setState({ value: newValue });
|
|
71
72
|
if (_this.props.onChange)
|
|
72
73
|
_this.props.onChange(newValue);
|
|
73
74
|
} }),
|
|
74
|
-
react_1.default.createElement("svg", { width: "
|
|
75
|
-
react_1.default.createElement("path", { d: "
|
|
75
|
+
react_1.default.createElement("svg", { width: "100%", height: "100%", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, this.state.value == undefined ?
|
|
76
|
+
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4.79199 9.95298C4.79199 9.69148 5.00398 9.47949 5.26548 9.47949H14.7352C14.9967 9.47949 15.2087 9.69148 15.2087 9.95298C15.2087 10.2145 14.9967 10.4265 14.7352 10.4265H5.26548C5.00398 10.4265 4.79199 10.2145 4.79199 9.95298Z", fill: (_c = this.props.checkColor) !== null && _c !== void 0 ? _c : '#ffffff' }) :
|
|
77
|
+
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M15.07 6.49317C15.2549 6.67808 15.2549 6.97787 15.07 7.16278L8.91467 13.3181C8.72977 13.503 8.42997 13.503 8.24507 13.3181L4.93067 10.0037C4.74577 9.81878 4.74577 9.51899 4.93067 9.33408C5.11558 9.14917 5.41537 9.14917 5.60028 9.33408L8.57987 12.3137L14.4004 6.49317C14.5853 6.30827 14.8851 6.30827 15.07 6.49317Z", fill: (_d = this.props.checkColor) !== null && _d !== void 0 ? _d : '#ffffff' })));
|
|
76
78
|
};
|
|
77
79
|
return Checkbox;
|
|
78
80
|
}(react_1.default.Component));
|
|
79
81
|
exports.Checkbox = Checkbox;
|
|
82
|
+
react_1.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
83
|
+
react_1.default.createElement("rect", { width: "20", height: "20", rx: "4", fill: "#366AE2" }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import './input-multi-select.css';
|
|
3
|
-
import { OptionsItem } from '
|
|
3
|
+
import { OptionsItem } from '../select1/select1';
|
|
4
4
|
interface SelectMultipleProps {
|
|
5
5
|
value?: Array<string | number>;
|
|
6
6
|
options: Required<Array<OptionsItem>>;
|
|
@@ -15,6 +15,7 @@ interface SelectMultipleProps {
|
|
|
15
15
|
}
|
|
16
16
|
interface SelectMultipleState {
|
|
17
17
|
value: Array<string | number>;
|
|
18
|
+
options: Required<Array<OptionsItem>>;
|
|
18
19
|
offset: DOMRect;
|
|
19
20
|
isOpen: boolean;
|
|
20
21
|
onSelect: any;
|
|
@@ -22,9 +23,12 @@ interface SelectMultipleState {
|
|
|
22
23
|
style?: Object;
|
|
23
24
|
}
|
|
24
25
|
export declare class SelectMultiple extends React.Component<SelectMultipleProps, SelectMultipleState> {
|
|
26
|
+
private containerRef;
|
|
25
27
|
constructor(props: SelectMultipleProps);
|
|
26
28
|
private onCheck;
|
|
27
29
|
private search;
|
|
30
|
+
private onClickItem;
|
|
31
|
+
private renderOptions;
|
|
28
32
|
componentDidUpdate(prevProps: SelectMultipleProps, prevState: SelectMultipleState): void;
|
|
29
33
|
render(): React.JSX.Element;
|
|
30
34
|
}
|
|
@@ -25,6 +25,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
};
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
28
51
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
52
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
53
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -77,10 +100,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
77
100
|
exports.SelectMultiple = void 0;
|
|
78
101
|
var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
79
102
|
var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
80
|
-
var react_1 =
|
|
103
|
+
var react_1 = __importStar(require("react"));
|
|
81
104
|
var react_dom_1 = __importDefault(require("react-dom"));
|
|
82
105
|
require("./input-multi-select.css");
|
|
83
|
-
var
|
|
106
|
+
var checkbox_1 = require("../checkbox/checkbox");
|
|
107
|
+
var text_1 = require("../text/text");
|
|
84
108
|
;
|
|
85
109
|
var SelectMultiple = /** @class */ (function (_super) {
|
|
86
110
|
__extends(SelectMultiple, _super);
|
|
@@ -88,8 +112,10 @@ var SelectMultiple = /** @class */ (function (_super) {
|
|
|
88
112
|
var _this = this;
|
|
89
113
|
var _a;
|
|
90
114
|
_this = _super.call(this, props) || this;
|
|
115
|
+
_this.containerRef = (0, react_1.createRef)();
|
|
91
116
|
_this.state = {
|
|
92
117
|
value: (_a = props.value) !== null && _a !== void 0 ? _a : [],
|
|
118
|
+
options: props.options,
|
|
93
119
|
offset: {
|
|
94
120
|
x: 0,
|
|
95
121
|
y: 0,
|
|
@@ -108,15 +134,16 @@ var SelectMultiple = /** @class */ (function (_super) {
|
|
|
108
134
|
};
|
|
109
135
|
_this.onCheck = _this.onCheck.bind(_this);
|
|
110
136
|
_this.search = _this.search.bind(_this);
|
|
137
|
+
_this.onClickItem = _this.onClickItem.bind(_this);
|
|
111
138
|
return _this;
|
|
112
139
|
}
|
|
113
|
-
SelectMultiple.prototype.onCheck = function (
|
|
140
|
+
SelectMultiple.prototype.onCheck = function (value, list) {
|
|
114
141
|
var newValue = [];
|
|
115
|
-
if (
|
|
116
|
-
newValue = this.state.value.
|
|
142
|
+
if (value) {
|
|
143
|
+
newValue = __spreadArray(__spreadArray([], this.state.value, true), list.map(function (e) { return e.id; }), true);
|
|
117
144
|
}
|
|
118
145
|
else {
|
|
119
|
-
newValue =
|
|
146
|
+
newValue = this.state.value.filter(function (vl) { return list.every(function (e) { return vl !== e.id; }); });
|
|
120
147
|
}
|
|
121
148
|
this.setState(__assign(__assign({}, this.state), { value: newValue }));
|
|
122
149
|
if (this.props.onChange)
|
|
@@ -148,82 +175,123 @@ var SelectMultiple = /** @class */ (function (_super) {
|
|
|
148
175
|
});
|
|
149
176
|
});
|
|
150
177
|
};
|
|
151
|
-
SelectMultiple.prototype.
|
|
178
|
+
SelectMultiple.prototype.onClickItem = function (ev, item) {
|
|
152
179
|
var _a, _b;
|
|
153
|
-
|
|
180
|
+
ev.stopPropagation();
|
|
181
|
+
var newValue = this.state.value.filter(function (vl) { return vl !== item; });
|
|
182
|
+
this.setState(__assign(__assign(__assign({}, this.state), { value: newValue }), (this.state.isOpen ? {} : {
|
|
183
|
+
isOpen: true,
|
|
184
|
+
style: undefined,
|
|
185
|
+
offset: (_b = (_a = this.containerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect(),
|
|
186
|
+
})));
|
|
187
|
+
if (this.props.onChange)
|
|
188
|
+
this.props.onChange(newValue);
|
|
189
|
+
};
|
|
190
|
+
SelectMultiple.prototype.renderOptions = function (item) {
|
|
191
|
+
var _this = this;
|
|
192
|
+
var _a, _b;
|
|
193
|
+
var children = [];
|
|
194
|
+
if (!item.parentId)
|
|
195
|
+
children = ((_a = this.state.search) !== null && _a !== void 0 ? _a : this.state.options).filter(function (e) { return e.parentId === item.id; });
|
|
196
|
+
//
|
|
197
|
+
return react_1.default.createElement("div", { key: item.id, className: 'col', style: { width: '100%' } },
|
|
198
|
+
react_1.default.createElement("div", { className: 'select-tile row', style: { paddingLeft: item.parentId ? '4.4rem' : undefined }, onClick: children.length ? function () {
|
|
199
|
+
if (_this.state.search) {
|
|
200
|
+
_this.setState(__assign(__assign({}, _this.state), { search: _this.state.search.map(function (e) {
|
|
201
|
+
if (e.id === item.id)
|
|
202
|
+
return __assign(__assign({}, e), { isOpen: !item.isOpen });
|
|
203
|
+
else
|
|
204
|
+
return e;
|
|
205
|
+
}) }));
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
_this.setState(__assign(__assign({}, _this.state), { options: _this.state.options.map(function (e) {
|
|
209
|
+
if (e.id === item.id)
|
|
210
|
+
return __assign(__assign({}, e), { isOpen: !item.isOpen });
|
|
211
|
+
else
|
|
212
|
+
return e;
|
|
213
|
+
}) }));
|
|
214
|
+
}
|
|
215
|
+
} : undefined },
|
|
216
|
+
((_b = this.state.search) !== null && _b !== void 0 ? _b : this.state.options).some(function (e) { return e.parentId; }) && react_1.default.createElement("div", { className: 'row', style: { width: '1.4rem', height: '1.4rem' } }, children.length ? react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: item.isOpen ? free_solid_svg_icons_1.faCaretDown : free_solid_svg_icons_1.faCaretRight, style: { fontSize: '1.2rem', color: '#161C2499' } }) : null),
|
|
217
|
+
react_1.default.createElement(checkbox_1.Checkbox, { value: children.length ? (children.every(function (e) { return _this.state.value.includes(e.id); }) ? true : children.some(function (e) { return _this.state.value.includes(e.id); }) ? undefined : false) : this.state.value.includes(item.id), onChange: function (v) { _this.onCheck(v, __spreadArray([item], children, true)); }, size: '2rem' }),
|
|
218
|
+
react_1.default.createElement(text_1.Text, { className: 'body-3' }, item.name)),
|
|
219
|
+
react_1.default.createElement("div", { className: 'col', style: { display: item.isOpen ? "flex" : "none", width: '100%' } }, children.map(function (e) { return _this.renderOptions(e); })));
|
|
220
|
+
};
|
|
221
|
+
SelectMultiple.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
222
|
+
var _a, _b, _c, _d, _e;
|
|
223
|
+
if (prevProps.options !== this.props.options)
|
|
224
|
+
this.setState(__assign(__assign({}, this.state), { options: this.props.options }));
|
|
225
|
+
if (prevProps.value !== this.props.value)
|
|
154
226
|
this.setState(__assign(__assign({}, this.state), { value: (_a = this.props.value) !== null && _a !== void 0 ? _a : [] }));
|
|
155
|
-
|
|
156
|
-
if (prevState.isOpen !== this.state.isOpen
|
|
227
|
+
//
|
|
228
|
+
if (this.state.isOpen && (prevState.isOpen !== this.state.isOpen || prevState.value.length !== this.state.value.length)) {
|
|
157
229
|
var thisPopupRect = (_b = document.body.querySelector('.select-multi-popup')) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
158
230
|
if (thisPopupRect) {
|
|
159
231
|
var style = void 0;
|
|
160
|
-
if (thisPopupRect.right > document.body.offsetWidth) {
|
|
232
|
+
if (prevState.isOpen !== this.state.isOpen && thisPopupRect.right > document.body.offsetWidth) {
|
|
161
233
|
style = {
|
|
162
234
|
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
163
|
-
width: "".concat(this.state.offset.width, "px"),
|
|
164
235
|
right: document.body.offsetWidth - this.state.offset.right + 'px'
|
|
165
236
|
};
|
|
166
237
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
238
|
+
var _bottom = thisPopupRect.bottom - 8;
|
|
239
|
+
var thisContainerRect = (_c = this.containerRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
240
|
+
if (thisContainerRect) {
|
|
241
|
+
if (prevState.value.length !== this.state.value.length) {
|
|
242
|
+
_bottom = thisContainerRect.bottom + 2 + thisPopupRect.height;
|
|
243
|
+
style = __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { top: "".concat(thisContainerRect.bottom + 2, "px") });
|
|
244
|
+
}
|
|
245
|
+
if (_bottom > document.body.offsetHeight) {
|
|
246
|
+
style = __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { top: "".concat(thisContainerRect.y - 2 - thisPopupRect.height, "px") });
|
|
247
|
+
}
|
|
173
248
|
}
|
|
174
|
-
if (style)
|
|
249
|
+
if (style) {
|
|
250
|
+
(_d = style.left) !== null && _d !== void 0 ? _d : (style.left = style.right ? undefined : "".concat(this.state.offset.x, "px"));
|
|
251
|
+
(_e = style.width) !== null && _e !== void 0 ? _e : (style.width = "".concat(this.state.offset.width, "px"));
|
|
175
252
|
this.setState(__assign(__assign({}, this.state), { style: style }));
|
|
253
|
+
}
|
|
176
254
|
}
|
|
177
255
|
}
|
|
178
256
|
};
|
|
179
257
|
SelectMultiple.prototype.render = function () {
|
|
180
258
|
var _this = this;
|
|
181
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
182
|
-
return react_1.default.createElement("div", { className: "select-multi-container row ".concat(this.props.disabled ? 'disabled' : '', " ").concat(((_a = this.props.helperText) === null || _a === void 0 ? void 0 : _a.length) && 'helper-text'), "helper-text": this.props.helperText, style: this.props.style ? __assign(__assign({}, { '--helper-text-color': (
|
|
183
|
-
var _a;
|
|
184
|
-
if (!_this.state.isOpen)
|
|
185
|
-
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, style: undefined, offset: ((_a =
|
|
186
|
-
}
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
260
|
+
return react_1.default.createElement("div", { ref: this.containerRef, className: "select-multi-container row ".concat(this.props.disabled ? 'disabled' : '', " ").concat(((_a = this.props.helperText) === null || _a === void 0 ? void 0 : _a.length) && 'helper-text', " ").concat((_b = this.props.className) !== null && _b !== void 0 ? _b : 'body-3'), "helper-text": this.props.helperText, style: this.props.style ? __assign(__assign({}, { '--helper-text-color': (_c = this.props.helperTextColor) !== null && _c !== void 0 ? _c : '#e14337' }), this.props.style) : { '--helper-text-color': (_d = this.props.helperTextColor) !== null && _d !== void 0 ? _d : '#e14337' }, onClick: function () {
|
|
261
|
+
var _a, _b;
|
|
262
|
+
if (!_this.state.isOpen)
|
|
263
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, style: undefined, offset: (_b = (_a = _this.containerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect() }));
|
|
187
264
|
} },
|
|
188
|
-
react_1.default.createElement("div", { className: 'row', style: {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
react_1.default.createElement(
|
|
265
|
+
react_1.default.createElement("div", { className: 'row', style: { flexWrap: 'wrap', flex: 1, width: '100%', gap: '0.6rem 0.4rem' } },
|
|
266
|
+
this.state.value.map(function (item) {
|
|
267
|
+
var optionItem = _this.props.options.find(function (e) { return e.id === item; });
|
|
268
|
+
return react_1.default.createElement("div", { key: item, className: 'selected-item-value row', onClick: function (ev) { return _this.onClickItem(ev, item); } },
|
|
269
|
+
react_1.default.createElement(text_1.Text, null, optionItem === null || optionItem === void 0 ? void 0 : optionItem.name),
|
|
270
|
+
react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faClose, style: { color: '#161D24E5', fontSize: '1.2rem' } }));
|
|
271
|
+
}),
|
|
272
|
+
(!this.state.value.length || this.state.isOpen) && react_1.default.createElement("input", { autoFocus: this.state.isOpen, onChange: this.search, placeholder: this.state.value.length ? undefined : this.props.placeholder, onBlur: function (ev) {
|
|
273
|
+
if (_this.state.onSelect)
|
|
274
|
+
ev.target.focus();
|
|
275
|
+
else
|
|
276
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, onSelect: null }));
|
|
277
|
+
} })),
|
|
278
|
+
react_1.default.createElement("button", { type: 'button', className: 'row', style: { padding: '0.4rem' }, onClick: function (ev) {
|
|
279
|
+
ev.stopPropagation();
|
|
280
|
+
if (_this.state.value.length)
|
|
281
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, value: [] }));
|
|
282
|
+
} },
|
|
283
|
+
react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faXmarkCircle, style: { fontSize: '1.6rem', color: '#161C24' } })),
|
|
202
284
|
this.state.isOpen &&
|
|
203
285
|
react_dom_1.default.createPortal(react_1.default.createElement("div", { className: 'select-multi-popup col', style: (_e = this.state.style) !== null && _e !== void 0 ? _e : {
|
|
204
286
|
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
205
287
|
left: this.state.offset.x + 'px',
|
|
206
288
|
width: this.state.offset.width,
|
|
207
|
-
}, onMouseOver: function (ev) {
|
|
208
|
-
|
|
209
|
-
}, onMouseOut: function () {
|
|
210
|
-
return _this.setState(__assign(__assign({}, _this.state), { onSelect: null }));
|
|
211
|
-
} },
|
|
212
|
-
react_1.default.createElement("div", { className: 'row header-search' },
|
|
213
|
-
react_1.default.createElement("input", { autoFocus: true, placeholder: 'Tìm kiếm', onChange: this.search, onBlur: function (ev) {
|
|
214
|
-
if (_this.state.onSelect) {
|
|
215
|
-
ev.target.focus();
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, onSelect: null }));
|
|
219
|
-
}
|
|
220
|
-
} }),
|
|
221
|
-
react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faSearch, style: { fontSize: '1.2rem', color: '#161D24D9' } })),
|
|
222
|
-
react_1.default.createElement("div", { style: { padding: '1.2rem 1.6rem', width: '100%', borderTop: '1px solid #161D2414', borderBottom: '1px solid #161D2414' } }, (function () {
|
|
289
|
+
}, onMouseOver: function (ev) { return _this.setState(__assign(__assign({}, _this.state), { onSelect: ev.target })); }, onMouseOut: function () { return _this.setState(__assign(__assign({}, _this.state), { onSelect: null })); } },
|
|
290
|
+
react_1.default.createElement("div", { style: { padding: '1.2rem 1.6rem', width: '100%', borderBottom: '1px solid #161D2414' } }, (function () {
|
|
223
291
|
var _a, _b;
|
|
224
292
|
var _list = ((_b = (_a = _this.state.search) !== null && _a !== void 0 ? _a : _this.props.options) !== null && _b !== void 0 ? _b : []);
|
|
225
293
|
var isSelectedAll = _list.every(function (item) { return _this.state.value.some(function (vl) { return vl === item.id; }); });
|
|
226
|
-
return react_1.default.createElement(
|
|
294
|
+
return react_1.default.createElement(text_1.Text, { onClick: function () {
|
|
227
295
|
var newValue = [];
|
|
228
296
|
if (_list.length) {
|
|
229
297
|
if (isSelectedAll) {
|
|
@@ -236,13 +304,11 @@ var SelectMultiple = /** @class */ (function (_super) {
|
|
|
236
304
|
_this.setState(__assign(__assign({}, _this.state), { value: newValue }));
|
|
237
305
|
if (_this.props.onChange)
|
|
238
306
|
_this.props.onChange(newValue);
|
|
239
|
-
}, className: 'button-text-3', style: { color: _list.length ? 'var(--
|
|
307
|
+
}, className: 'button-text-3', style: { color: _list.length ? 'var(--infor-color)' : '#00204D99', } }, _list.length && isSelectedAll ? 'Bỏ chọn tất cả' : 'Chọn tất cả');
|
|
240
308
|
})()),
|
|
241
309
|
react_1.default.createElement("div", { className: 'col select-body' },
|
|
242
|
-
((
|
|
243
|
-
|
|
244
|
-
react_1.default.createElement("div", { className: 'label-3' }, item.name))); }),
|
|
245
|
-
(((_h = this.state.search) === null || _h === void 0 ? void 0 : _h.length) === 0 || ((_j = this.props.options) === null || _j === void 0 ? void 0 : _j.length) === 0) && (react_1.default.createElement("div", { className: 'no-results-found' }, "No result found")))), document.body));
|
|
310
|
+
((_f = this.state.search) !== null && _f !== void 0 ? _f : this.state.options).filter(function (e) { return !e.parentId; }).map(function (item) { return _this.renderOptions(item); }),
|
|
311
|
+
(((_g = this.state.search) === null || _g === void 0 ? void 0 : _g.length) === 0 || ((_h = this.props.options) === null || _h === void 0 ? void 0 : _h.length) === 0) && (react_1.default.createElement("div", { className: 'no-results-found' }, "No result found")))), document.body));
|
|
246
312
|
};
|
|
247
313
|
return SelectMultiple;
|
|
248
314
|
}(react_1.default.Component));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import './select1.css';
|
|
3
3
|
export interface OptionsItem {
|
|
4
|
-
id: string
|
|
4
|
+
id: string;
|
|
5
|
+
parentId?: string;
|
|
5
6
|
name: string | ReactNode;
|
|
6
|
-
title
|
|
7
|
+
title: string | ReactNode;
|
|
7
8
|
}
|
|
8
9
|
interface Select1Props {
|
|
9
10
|
value?: any;
|
|
@@ -35,8 +35,6 @@ var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
|
35
35
|
var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
36
36
|
var react_dom_1 = __importDefault(require("react-dom"));
|
|
37
37
|
require("./select1.css");
|
|
38
|
-
;
|
|
39
|
-
;
|
|
40
38
|
var Select1 = /** @class */ (function (_super) {
|
|
41
39
|
__extends(Select1, _super);
|
|
42
40
|
function Select1(props) {
|