wini-web-components 2.2.8 → 2.3.2
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/button/button.d.ts +16 -16
- package/dist/component/button/button.js +39 -39
- package/dist/component/calendar/calendar.d.ts +30 -46
- package/dist/component/calendar/calendar.js +437 -432
- package/dist/component/checkbox/checkbox.d.ts +24 -22
- package/dist/component/checkbox/checkbox.js +120 -81
- package/dist/component/component-status.d.ts +8 -8
- package/dist/component/component-status.js +39 -39
- package/dist/component/date-picker/date-picker.d.ts +25 -36
- package/dist/component/date-picker/date-picker.js +362 -359
- package/dist/component/dialog/dialog.d.ts +36 -34
- package/dist/component/dialog/dialog.js +99 -97
- package/dist/component/import-file/import-file.d.ts +24 -36
- package/dist/component/import-file/import-file.js +154 -119
- package/dist/component/infinite-scroll/infinite-scroll.d.ts +17 -17
- package/dist/component/infinite-scroll/infinite-scroll.js +103 -103
- package/dist/component/input-multi-select/input-multi-select.d.ts +21 -38
- package/dist/component/input-multi-select/input-multi-select.js +334 -323
- package/dist/component/input-opt/input-opt.d.ts +21 -21
- package/dist/component/input-opt/input-opt.js +157 -147
- package/dist/component/number-picker/number-picker.d.ts +19 -19
- package/dist/component/number-picker/number-picker.js +137 -127
- package/dist/component/pagination/pagination.d.ts +13 -13
- package/dist/component/pagination/pagination.js +93 -82
- package/dist/component/popup/popup.d.ts +33 -33
- package/dist/component/popup/popup.js +138 -105
- package/dist/component/progress-bar/progress-bar.d.ts +16 -16
- package/dist/component/progress-bar/progress-bar.js +35 -36
- package/dist/component/progress-circle/progress-circle.d.ts +14 -14
- package/dist/component/progress-circle/progress-circle.js +30 -31
- package/dist/component/radio-button/radio-button.d.ts +20 -20
- package/dist/component/radio-button/radio-button.js +64 -64
- package/dist/component/rating/rating.d.ts +23 -23
- package/dist/component/rating/rating.js +73 -74
- package/dist/component/select1/select1.d.ts +31 -50
- package/dist/component/select1/select1.js +320 -309
- package/dist/component/slider/slider.d.ts +31 -31
- package/dist/component/slider/slider.js +80 -81
- package/dist/component/switch/switch.d.ts +23 -23
- package/dist/component/switch/switch.js +80 -81
- package/dist/component/table/table.d.ts +51 -51
- package/dist/component/table/table.js +119 -119
- package/dist/component/tag/tag.d.ts +17 -17
- package/dist/component/tag/tag.js +39 -39
- package/dist/component/text/text.d.ts +16 -16
- package/dist/component/text/text.js +51 -51
- package/dist/component/text-area/text-area.d.ts +28 -28
- package/dist/component/text-area/text-area.js +83 -73
- package/dist/component/text-field/text-field.d.ts +33 -33
- package/dist/component/text-field/text-field.js +107 -97
- package/dist/component/toast-noti/toast-noti.d.ts +5 -5
- package/dist/component/toast-noti/toast-noti.js +28 -28
- package/dist/component/wini-icon/winicon.d.ts +16 -16
- package/dist/component/wini-icon/winicon.js +121 -112
- package/dist/form/login/view.d.ts +40 -40
- package/dist/form/login/view.js +66 -65
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +125 -0
- package/dist/index.d.ts +32 -31
- package/dist/index.js +1 -1
- package/dist/language/i18n.d.ts +2 -0
- package/dist/language/i18n.js +125 -0
- package/package.json +5 -3
|
@@ -1,309 +1,320 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
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 (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.setState(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
this.
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
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 () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
62
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
63
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
64
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
65
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
66
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
67
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
71
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
73
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
74
|
+
function step(op) {
|
|
75
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
76
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
77
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
78
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
79
|
+
switch (op[0]) {
|
|
80
|
+
case 0: case 1: t = op; break;
|
|
81
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
82
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
83
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
84
|
+
default:
|
|
85
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
86
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
87
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
88
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
89
|
+
if (t[2]) _.ops.pop();
|
|
90
|
+
_.trys.pop(); continue;
|
|
91
|
+
}
|
|
92
|
+
op = body.call(thisArg, _);
|
|
93
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
94
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
98
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
99
|
+
};
|
|
100
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
101
|
+
exports.Select1 = void 0;
|
|
102
|
+
var select1_module_css_1 = __importDefault(require("./select1.module.css"));
|
|
103
|
+
var react_1 = __importStar(require("react"));
|
|
104
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
105
|
+
var winicon_1 = require("../wini-icon/winicon");
|
|
106
|
+
var text_1 = require("../text/text");
|
|
107
|
+
var react_i18next_1 = require("react-i18next");
|
|
108
|
+
;
|
|
109
|
+
var TSelect1 = /** @class */ (function (_super) {
|
|
110
|
+
__extends(TSelect1, _super);
|
|
111
|
+
function TSelect1(props) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
var _this = _super.call(this, props) || this;
|
|
114
|
+
_this.containerRef = (0, react_1.createRef)();
|
|
115
|
+
_this.inputRef = (0, react_1.createRef)();
|
|
116
|
+
_this.onKeyDown = function (ev) {
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
118
|
+
if ((((_a = _this.state.options) === null || _a === void 0 ? void 0 : _a.length) || ((_b = _this.state.search) === null || _b === void 0 ? void 0 : _b.length)) && _this.state.isOpen) {
|
|
119
|
+
switch (ev.key.toLowerCase()) {
|
|
120
|
+
case "enter":
|
|
121
|
+
ev.preventDefault();
|
|
122
|
+
var _selectItem = ((_c = _this.state.search) !== null && _c !== void 0 ? _c : _this.state.options).find(function (e) { return e.id === _this.state.selected; });
|
|
123
|
+
if (_selectItem)
|
|
124
|
+
_this.onSelect(_selectItem);
|
|
125
|
+
break;
|
|
126
|
+
case "arrowup":
|
|
127
|
+
ev.preventDefault();
|
|
128
|
+
if (_this.state.selected) {
|
|
129
|
+
var _index = ((_d = _this.state.search) !== null && _d !== void 0 ? _d : _this.state.options).findIndex(function (e) { return e.id === _this.state.selected; });
|
|
130
|
+
_index = ((_index === 0) ? _this.props.options.length : _index) - 1;
|
|
131
|
+
_this.setState(__assign(__assign({}, _this.state), { selected: (_e = _this.props.options[_index]) === null || _e === void 0 ? void 0 : _e.id }));
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
case "arrowdown":
|
|
135
|
+
ev.preventDefault();
|
|
136
|
+
if (_this.state.selected) {
|
|
137
|
+
var _index = ((_f = _this.state.search) !== null && _f !== void 0 ? _f : _this.state.options).findIndex(function (e) { return e.id === _this.state.selected; });
|
|
138
|
+
_index = ((_index + 1 === _this.props.options.length) ? -1 : _index) + 1;
|
|
139
|
+
_this.setState(__assign(__assign({}, _this.state), { selected: (_g = _this.props.options[_index]) === null || _g === void 0 ? void 0 : _g.id }));
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
_this.state = {
|
|
148
|
+
value: props.value,
|
|
149
|
+
options: props.options,
|
|
150
|
+
offset: {
|
|
151
|
+
x: 0,
|
|
152
|
+
y: 0,
|
|
153
|
+
height: 0,
|
|
154
|
+
width: 0,
|
|
155
|
+
bottom: 0,
|
|
156
|
+
left: 0,
|
|
157
|
+
right: 0,
|
|
158
|
+
top: 0,
|
|
159
|
+
toJSON: function () {
|
|
160
|
+
throw new Error('Function not implemented.');
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
isOpen: false,
|
|
164
|
+
onSelect: null,
|
|
165
|
+
};
|
|
166
|
+
_this.search = _this.search.bind(_this);
|
|
167
|
+
_this.onSelect = _this.onSelect.bind(_this);
|
|
168
|
+
_this.onKeyDown = _this.onKeyDown.bind(_this);
|
|
169
|
+
if (_this.inputRef.current)
|
|
170
|
+
_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 : "");
|
|
171
|
+
return _this;
|
|
172
|
+
}
|
|
173
|
+
TSelect1.prototype.search = function (ev) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var res;
|
|
176
|
+
var _a;
|
|
177
|
+
return __generator(this, function (_b) {
|
|
178
|
+
switch (_b.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
if (!ev.target.value.trim().length) return [3 /*break*/, 4];
|
|
181
|
+
if (!((_a = this.props) === null || _a === void 0 ? void 0 : _a.handleSearch)) return [3 /*break*/, 2];
|
|
182
|
+
return [4 /*yield*/, this.props.handleSearch(ev.target.value.trim())];
|
|
183
|
+
case 1:
|
|
184
|
+
res = _b.sent();
|
|
185
|
+
this.setState(__assign(__assign({}, this.state), { search: res }));
|
|
186
|
+
return [3 /*break*/, 3];
|
|
187
|
+
case 2:
|
|
188
|
+
this.setState(__assign(__assign({}, this.state), { search: this.props.options.filter(function (e) { return typeof e.name === "string" && e.name.toLowerCase().includes(ev.target.value.trim().toLowerCase()); }) }));
|
|
189
|
+
_b.label = 3;
|
|
190
|
+
case 3: return [3 /*break*/, 5];
|
|
191
|
+
case 4:
|
|
192
|
+
this.setState(__assign(__assign({}, this.state), { search: undefined }));
|
|
193
|
+
_b.label = 5;
|
|
194
|
+
case 5: return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
TSelect1.prototype.onSelect = function (item) {
|
|
200
|
+
var _a, _b;
|
|
201
|
+
if (item.disabled) {
|
|
202
|
+
this.setState(__assign(__assign({}, this.state), { isOpen: false, onSelect: undefined, selected: undefined }));
|
|
203
|
+
(_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
var newState = __assign(__assign({}, this.state), { isOpen: false, value: item.id, onSelect: undefined, selected: undefined });
|
|
207
|
+
if (!newState.options.some(function (e) { return e.id === item.id; }))
|
|
208
|
+
newState.options.push(item);
|
|
209
|
+
this.setState(newState);
|
|
210
|
+
(_b = this.inputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
211
|
+
}
|
|
212
|
+
if (this.props.onChange)
|
|
213
|
+
this.props.onChange(item);
|
|
214
|
+
};
|
|
215
|
+
TSelect1.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
216
|
+
var _this = this;
|
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
218
|
+
if (prevProps.options !== this.props.options) {
|
|
219
|
+
this.setState(__assign(__assign({}, this.state), { options: this.props.options }));
|
|
220
|
+
if (this.inputRef.current)
|
|
221
|
+
this.inputRef.current.value = "".concat((_b = (_a = this.props.options.find(function (e) { return e.id === _this.state.value; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "");
|
|
222
|
+
}
|
|
223
|
+
if (prevProps.value !== this.props.value)
|
|
224
|
+
this.setState(__assign(__assign({}, this.state), { value: this.props.value }));
|
|
225
|
+
if (prevState.value !== this.state.value && this.inputRef.current)
|
|
226
|
+
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 : "");
|
|
227
|
+
//
|
|
228
|
+
if (this.state.isOpen && prevState.isOpen !== this.state.isOpen) {
|
|
229
|
+
var thisPopupRect = (_e = document.body.querySelector(":scope > .select1-popup")) === null || _e === void 0 ? void 0 : _e.getBoundingClientRect();
|
|
230
|
+
if (thisPopupRect) {
|
|
231
|
+
var style = void 0;
|
|
232
|
+
if (thisPopupRect.right > document.body.offsetWidth) {
|
|
233
|
+
style = {
|
|
234
|
+
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
235
|
+
right: document.body.offsetWidth - this.state.offset.right + 'px'
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
var _bottom = thisPopupRect.bottom - 8;
|
|
239
|
+
var thisContainerRect = (_f = this.containerRef.current) === null || _f === void 0 ? void 0 : _f.getBoundingClientRect();
|
|
240
|
+
if (thisContainerRect) {
|
|
241
|
+
if (_bottom > document.body.offsetHeight) {
|
|
242
|
+
style = __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { top: "".concat(thisContainerRect.y - 2 - thisPopupRect.height, "px") });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (style) {
|
|
246
|
+
(_g = style.left) !== null && _g !== void 0 ? _g : (style.left = style.right ? undefined : "".concat(this.state.offset.x, "px"));
|
|
247
|
+
(_h = style.width) !== null && _h !== void 0 ? _h : (style.width = "".concat(this.state.offset.width, "px"));
|
|
248
|
+
this.setState(__assign(__assign({}, this.state), { style: style }));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
TSelect1.prototype.componentDidMount = function () {
|
|
254
|
+
var _this = this;
|
|
255
|
+
var _a, _b;
|
|
256
|
+
if (this.inputRef.current)
|
|
257
|
+
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 : "");
|
|
258
|
+
};
|
|
259
|
+
TSelect1.prototype.render = function () {
|
|
260
|
+
var _this = this;
|
|
261
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
262
|
+
var t = this.props.t;
|
|
263
|
+
var _value = this.state.options.find(function (e) { return e.id === _this.state.value; });
|
|
264
|
+
return react_1.default.createElement("div", { id: this.props.id, ref: this.containerRef, className: "".concat(select1_module_css_1.default['select1-container'], " row ").concat(this.props.disabled ? select1_module_css_1.default['disabled'] : '', " ").concat(((_a = this.props.helperText) === null || _a === void 0 ? void 0 : _a.length) && select1_module_css_1.default['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 () {
|
|
265
|
+
var _a, _b, _c;
|
|
266
|
+
if (!_this.state.isOpen) {
|
|
267
|
+
_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() }));
|
|
268
|
+
(_c = _this.inputRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
269
|
+
}
|
|
270
|
+
} },
|
|
271
|
+
this.props.prefix,
|
|
272
|
+
(!_value || typeof _value.name === "string" || typeof _value.name === "number") ? react_1.default.createElement("input", { ref: this.inputRef, readOnly: this.props.readOnly, onChange: this.search, placeholder: this.props.placeholder, onKeyDown: this.onKeyDown, onBlur: function (ev) {
|
|
273
|
+
if (_this.state.onSelect && !_this.props.readOnly)
|
|
274
|
+
ev.target.focus();
|
|
275
|
+
else if (!_this.state.onSelect)
|
|
276
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: false, onSelect: null }));
|
|
277
|
+
} }) : _value.name, (_e = this.props.suffix) !== null && _e !== void 0 ? _e : react_1.default.createElement("div", { ref: function (iconRef) {
|
|
278
|
+
if ((iconRef === null || iconRef === void 0 ? void 0 : iconRef.parentElement) && iconRef.parentElement.getBoundingClientRect().width < 88)
|
|
279
|
+
iconRef.style.display = "none";
|
|
280
|
+
}, className: 'row' },
|
|
281
|
+
react_1.default.createElement(winicon_1.Winicon, { src: this.state.isOpen ? "fill/arrows/up-arrow" : "fill/arrows/down-arrow", size: "1.2rem" })),
|
|
282
|
+
this.state.isOpen &&
|
|
283
|
+
react_dom_1.default.createPortal(react_1.default.createElement("div", { ref: function (popupRef) {
|
|
284
|
+
if (popupRef && _this.props.onOpenOptions)
|
|
285
|
+
_this.props.onOpenOptions(popupRef);
|
|
286
|
+
}, className: "".concat(select1_module_css_1.default['select1-popup'], " select1-popup col ").concat((_f = this.props.popupClassName) !== null && _f !== void 0 ? _f : ""), style: (_g = this.state.style) !== null && _g !== void 0 ? _g : {
|
|
287
|
+
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
288
|
+
left: this.state.offset.x + 'px',
|
|
289
|
+
width: this.state.offset.width,
|
|
290
|
+
}, onMouseOver: function (ev) { return _this.setState(__assign(__assign({}, _this.state), { onSelect: ev.target })); }, onMouseOut: function () { return _this.setState(__assign(__assign({}, _this.state), { onSelect: null })); } },
|
|
291
|
+
react_1.default.createElement("div", { className: "col ".concat(select1_module_css_1.default['select-body']), onScroll: this.props.handleLoadmore ? function (ev) {
|
|
292
|
+
if (_this.props.handleLoadmore) {
|
|
293
|
+
var scrollElement = ev.target;
|
|
294
|
+
_this.props.handleLoadmore(Math.round(scrollElement.offsetHeight + scrollElement.scrollTop) >= (scrollElement.scrollHeight - 1), ev);
|
|
295
|
+
}
|
|
296
|
+
} : undefined },
|
|
297
|
+
((_h = this.state.search) !== null && _h !== void 0 ? _h : this.state.options).filter(function (e) { return !e.parentId; }).map(function (item) {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
return react_1.default.createElement(OptionsItemTile, { key: item.id, item: item, children: ((_a = _this.state.search) !== null && _a !== void 0 ? _a : _this.state.options).filter(function (e) { return e.parentId === item.id; }), selected: _this.state.selected === item.id, onClick: _this.onSelect, treeData: ((_b = _this.state.search) !== null && _b !== void 0 ? _b : _this.state.options).some(function (e) { return e.parentId; }) });
|
|
300
|
+
}),
|
|
301
|
+
(((_j = this.state.search) === null || _j === void 0 ? void 0 : _j.length) === 0 || ((_k = this.props.options) === null || _k === void 0 ? void 0 : _k.length) === 0) && (react_1.default.createElement("div", { className: select1_module_css_1.default['no-results-found'] }, t("noResultFound"))))), document.body));
|
|
302
|
+
};
|
|
303
|
+
return TSelect1;
|
|
304
|
+
}(react_1.default.Component));
|
|
305
|
+
function OptionsItemTile(_a) {
|
|
306
|
+
var item = _a.item, children = _a.children, selected = _a.selected, onClick = _a.onClick, treeData = _a.treeData;
|
|
307
|
+
var _b = (0, react_1.useState)(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
308
|
+
return item.title && typeof item.title !== "string" ? react_1.default.createElement(react_1.default.Fragment, null, item.title(onClick)) : react_1.default.createElement("div", { className: 'col', style: { width: '100%' } },
|
|
309
|
+
react_1.default.createElement("div", { className: "".concat(select1_module_css_1.default['select-tile'], " row ").concat(item.disabled ? select1_module_css_1.default["disabled"] : ""), style: { paddingLeft: item.parentId ? '4.4rem' : undefined, backgroundColor: selected ? "var(--neutral-selected-background-color)" : undefined }, onClick: function () {
|
|
310
|
+
if (children === null || children === void 0 ? void 0 : children.length) {
|
|
311
|
+
setIsOpen(!isOpen);
|
|
312
|
+
}
|
|
313
|
+
else
|
|
314
|
+
onClick(item);
|
|
315
|
+
} },
|
|
316
|
+
treeData ? react_1.default.createElement("div", { className: 'row', style: { width: '1.4rem', height: '1.4rem' } }, (children === null || children === void 0 ? void 0 : children.length) ? react_1.default.createElement(winicon_1.Winicon, { src: isOpen ? "fill/arrows/triangle-down" : "fill/arrows/triangle-right", size: "1.2rem" }) : null) : undefined,
|
|
317
|
+
react_1.default.createElement(text_1.Text, { className: 'body-3' }, item.title && typeof item.title === "string" ? item.title : item.name)),
|
|
318
|
+
(children === null || children === void 0 ? void 0 : children.length) ? react_1.default.createElement("div", { className: 'col', style: { display: isOpen ? "flex" : "none", width: '100%' } }, children.map(function (e) { return react_1.default.createElement(OptionsItemTile, { key: e.id, item: e, onClick: onClick }); })) : undefined);
|
|
319
|
+
}
|
|
320
|
+
exports.Select1 = (0, react_i18next_1.withTranslation)()(TSelect1);
|