wini-web-components 0.5.0 → 0.5.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/calendar/calendar.d.ts +46 -0
- package/dist/component/calendar/calendar.js +426 -0
- package/dist/component/checkbox/checkbox.d.ts +20 -0
- package/dist/component/checkbox/checkbox.js +79 -0
- package/dist/component/component-status.d.ts +8 -0
- package/dist/component/component-status.js +32 -0
- package/dist/component/date-picker/date-picker.d.ts +31 -0
- package/dist/component/date-picker/date-picker.js +358 -0
- package/dist/component/dialog/dialog.d.ts +33 -0
- package/dist/component/dialog/dialog.js +96 -0
- package/dist/component/import-file/import-file.d.ts +35 -0
- package/dist/component/import-file/import-file.js +117 -0
- package/dist/component/infinite-scroll/infinite-scroll.d.ts +16 -0
- package/dist/component/infinite-scroll/infinite-scroll.js +102 -0
- package/dist/component/input-multi-select/input-multi-select.d.ts +39 -0
- package/dist/component/input-multi-select/input-multi-select.js +249 -0
- package/dist/component/pagination/pagination.d.ts +11 -0
- package/dist/component/pagination/pagination.js +46 -0
- package/dist/component/popup/popup.d.ts +31 -0
- package/dist/component/popup/popup.js +105 -0
- package/dist/component/progress-bar/progress-bar.d.ts +16 -0
- package/dist/component/progress-bar/progress-bar.js +39 -0
- package/dist/component/progress-circle/progress-circle.d.ts +13 -0
- package/dist/component/progress-circle/progress-circle.js +31 -0
- package/dist/component/radio-button/radio-button.d.ts +20 -0
- package/dist/component/radio-button/radio-button.js +64 -0
- package/dist/component/rating/rating.d.ts +23 -0
- package/dist/component/rating/rating.js +76 -0
- package/dist/component/select1/select1.d.ts +38 -0
- package/dist/component/select1/select1.js +185 -0
- package/dist/component/slider/slider.d.ts +31 -0
- package/dist/component/slider/slider.js +83 -0
- package/dist/component/switch/switch.d.ts +23 -0
- package/dist/component/switch/switch.js +81 -0
- package/dist/component/table/table.d.ts +46 -0
- package/dist/component/table/table.js +119 -0
- package/dist/component/text/text.d.ts +14 -0
- package/dist/component/text/text.js +50 -0
- package/dist/component/text-area/text-area.d.ts +25 -0
- package/dist/component/text-area/text-area.js +47 -0
- package/dist/component/text-field/text-field.d.ts +28 -0
- package/dist/component/text-field/text-field.js +50 -0
- package/dist/component/toast-noti/toast-noti.d.ts +4 -0
- package/dist/component/toast-noti/toast-noti.js +27 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +59 -1
- package/dist/skin/color.css +17 -0
- package/dist/skin/layout.css +601 -0
- package/dist/skin/typography.css +378 -0
- package/package.json +4 -2
|
@@ -0,0 +1,117 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ImportFile = void 0;
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
require("./import-file.css");
|
|
35
|
+
var index_1 = require("../../index");
|
|
36
|
+
var cloudSvg = (react_1.default.createElement("svg", { width: '100%', height: '100%', style: { width: '3rem', height: '3rem' }, viewBox: '0 0 36 36', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
37
|
+
react_1.default.createElement("path", { d: 'M22.5312 6.51941C20.3258 6.12929 18.0555 6.35518 15.9702 7.1722C13.8849 7.98923 12.0654 9.36573 10.712 11.1502C9.53042 12.7081 8.74407 14.5243 8.41412 16.4432C6.99557 16.9154 5.7486 17.8144 4.85059 19.0274C3.77621 20.4786 3.27749 22.2764 3.45068 24.0737C3.62388 25.871 4.45672 27.5405 5.78845 28.7599C7.12018 29.9792 8.85639 30.6621 10.662 30.6766H13.1063C13.7786 30.6766 14.3236 30.1316 14.3236 29.4594C14.3236 28.7871 13.7786 28.2421 13.1063 28.2421H10.6769C9.47485 28.2313 8.31921 27.7762 7.43253 26.9643C6.54471 26.1514 5.98948 25.0384 5.87402 23.8402C5.75855 22.642 6.09103 21.4435 6.80729 20.476C7.52354 19.5085 8.57279 18.8406 9.75252 18.6013C10.2753 18.4952 10.6682 18.061 10.7216 17.5303C10.9012 15.7476 11.5691 14.049 12.6518 12.6214C13.7345 11.1938 15.1901 10.0926 16.8583 9.43899C18.5266 8.78536 20.3428 8.60466 22.1071 8.91675C23.8715 9.22884 25.5155 10.0216 26.8583 11.2079C28.2011 12.3941 29.1905 13.9278 29.7178 15.6402C30.2451 17.3526 30.2898 19.1772 29.8469 20.9134C29.404 22.6495 28.4907 24.2297 27.2075 25.4802C25.9244 26.7308 24.3211 27.603 22.5742 28.001C21.9187 28.1504 21.5084 28.8028 21.6577 29.4583C21.807 30.1138 22.4595 30.5241 23.115 30.3748C25.2987 29.8772 27.3028 28.7869 28.9067 27.2238C30.5107 25.6606 31.6523 23.6853 32.2059 21.5152C32.7595 19.345 32.7037 17.0642 32.0446 14.9237C31.3855 12.7833 30.1486 10.8661 28.4701 9.38333C26.7916 7.90052 24.7366 6.90953 22.5312 6.51941Z', fill: '#366AE2' }),
|
|
38
|
+
react_1.default.createElement("path", { d: 'M17.1146 17.6431C17.2313 17.5264 17.3658 17.4384 17.5094 17.379C17.6513 17.3201 17.8067 17.2874 17.9697 17.2866L17.9753 17.2866L17.9809 17.2866C18.2906 17.288 18.5998 17.4069 18.8361 17.6431L23.7052 22.5123C24.1806 22.9876 24.1806 23.7584 23.7052 24.2338C23.2298 24.7091 22.4591 24.7091 21.9837 24.2338L19.1926 21.4427V29.4594C19.1926 30.1317 18.6476 30.6767 17.9753 30.6767C17.303 30.6767 16.758 30.1317 16.758 29.4594V21.4427L13.9669 24.2338C13.4916 24.7091 12.7208 24.7091 12.2455 24.2338C11.7701 23.7584 11.7701 22.9876 12.2455 22.5123L17.1146 17.6431Z', fill: '#366AE2' })));
|
|
39
|
+
var fileSvg = (react_1.default.createElement("svg", { className: 'preview-icon', width: '100%', height: '100%', style: { width: '3rem', height: '3rem' }, viewBox: '0 0 36 36', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
40
|
+
react_1.default.createElement("path", { d: 'M20.9163 3.41669H7.54829C7.22597 3.41669 6.91686 3.54472 6.68895 3.77263C6.46105 4.00054 6.33301 4.30965 6.33301 4.63196V31.3681C6.33301 31.6904 6.46105 31.9995 6.68895 32.2274C6.91686 32.4553 7.22597 32.5834 7.54829 32.5834H29.4233C29.7456 32.5834 30.0547 32.4553 30.2826 32.2274C30.5105 31.9995 30.6386 31.6904 30.6386 31.3681V13.1389H22.1316C21.8093 13.1389 21.5002 13.0109 21.2723 12.783C21.0444 12.5551 20.9163 12.2459 20.9163 11.9236V3.41669Z', fill: '#366AE2' }),
|
|
41
|
+
react_1.default.createElement("path", { d: 'M29.9264 10.7084H23.3469V4.12884L29.9264 10.7084Z', fill: '#366AE2' })));
|
|
42
|
+
var closeSvg = (react_1.default.createElement("svg", { width: '100%', height: '100%', style: { width: '2.4rem', height: '2.4rem' }, fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
43
|
+
react_1.default.createElement("path", { d: 'M13.4144 12.0002L20.4144 5.00015L19.0002 3.58594L12.0002 10.5859L5.00015 3.58594L3.58594 5.00015L10.5859 12.0002L3.58594 19.0002L5.00015 20.4144L12.0002 13.4144L19.0002 20.4144L20.4144 19.0002L13.4144 12.0002Z', fill: '#E60012FF' })));
|
|
44
|
+
var uploadSvg = (react_1.default.createElement("svg", { width: '100%', height: '100%', style: { width: '1.4rem', height: '1.4rem' }, fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
45
|
+
react_1.default.createElement("path", { d: 'M3.66732 3.88889L7.00065 0L10.334 3.88889H7.55621V8.88889H6.4451V3.88889H3.66732Z', fill: '#262626' }),
|
|
46
|
+
react_1.default.createElement("path", { d: 'M12.5562 11.1111H1.4451V7.77778H0.333984V11.6667C0.333984 11.9733 0.582873 12.2222 0.88954 12.2222H13.1118C13.4184 12.2222 13.6673 11.9733 13.6673 11.6667V7.77778H12.5562V11.1111Z', fill: '#262626' })));
|
|
47
|
+
var ImportFile = /** @class */ (function (_super) {
|
|
48
|
+
__extends(ImportFile, _super);
|
|
49
|
+
function ImportFile(props) {
|
|
50
|
+
var _this = _super.call(this, props) || this;
|
|
51
|
+
_this.state = {
|
|
52
|
+
preview: _this.props.value
|
|
53
|
+
};
|
|
54
|
+
_this.fileRef = react_1.default.createRef();
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
ImportFile.prototype.showFilePicker = function () {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = this.fileRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
60
|
+
};
|
|
61
|
+
ImportFile.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
62
|
+
if (prevProps.value !== this.props.value || prevProps.status !== this.props.status) {
|
|
63
|
+
this.setState(__assign(__assign({}, this.state), { status: this.props.status, preview: this.props.value }));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
ImportFile.prototype.render = function () {
|
|
67
|
+
var _this = this;
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
69
|
+
var sizeTitle;
|
|
70
|
+
if (this.props.maxSize) {
|
|
71
|
+
sizeTitle = this.props.maxSize > Math.pow(1024, 3) ? "".concat(Math.round(this.props.maxSize / Math.pow(1024, 3)), "TB") : this.props.maxSize > Math.pow(1024, 2) ? "".concat(Math.round(this.props.maxSize / Math.pow(1024, 2)), "GB") : this.props.maxSize > 1024 ? "".concat(Math.round(this.props.maxSize / 1024), "MB") : "".concat(this.props.maxSize, "KB");
|
|
72
|
+
}
|
|
73
|
+
return react_1.default.createElement("div", { className: "import-file-container ".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : 'row', " ").concat(this.props.buttonOnly ? 'button-only' : ''), style: this.state.preview ? this.props.style : __assign({ cursor: 'pointer' }, this.props.style), onClick: function () {
|
|
74
|
+
if (!_this.state.preview && !_this.props.buttonOnly)
|
|
75
|
+
_this.showFilePicker();
|
|
76
|
+
} },
|
|
77
|
+
react_1.default.createElement("input", { type: 'file', accept: ((_b = this.props.allowType) !== null && _b !== void 0 ? _b : []).join(','), ref: this.fileRef, onChange: function (ev) {
|
|
78
|
+
var file;
|
|
79
|
+
if (ev.target.files && ev.target.files[0]) {
|
|
80
|
+
file = ev.target.files[0];
|
|
81
|
+
if (_this.props.maxSize) {
|
|
82
|
+
if (file.size > (_this.props.maxSize * 1024)) {
|
|
83
|
+
index_1.ToastMessage.errors("T\u1EC7p ".concat(file.name, " v\u01B0\u1EE3t qua k\u00EDch th\u01B0\u1EDBc cho ph\u00E9p"));
|
|
84
|
+
file = undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (file) {
|
|
89
|
+
_this.setState(__assign(__assign({}, _this.state), { preview: file }));
|
|
90
|
+
if (_this.props.onChange)
|
|
91
|
+
_this.props.onChange(file);
|
|
92
|
+
}
|
|
93
|
+
} }),
|
|
94
|
+
this.props.buttonOnly
|
|
95
|
+
? null
|
|
96
|
+
: [
|
|
97
|
+
react_1.default.createElement("div", { key: 'import-file-prefix', className: 'import-file-prefix row' }, this.state.preview ? ((_c = this.state.preview.type) === null || _c === void 0 ? void 0 : _c.includes('image')) ? react_1.default.createElement("img", { src: this.state.preview instanceof File ? URL.createObjectURL(this.state.preview) : this.state.preview.url }) : fileSvg : cloudSvg),
|
|
98
|
+
react_1.default.createElement("div", { key: 'file-preview-content', className: 'file-preview-content col' },
|
|
99
|
+
react_1.default.createElement(index_1.Text, { className: 'title-file heading-8', style: { maxWidth: '100%' } }, (_e = (_d = this.state.preview) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : ((_f = this.props.label) !== null && _f !== void 0 ? _f : 'Nhấp hoặc kéo tệp vào đây để tải lên')),
|
|
100
|
+
react_1.default.createElement(index_1.Text, { className: 'subtitle-file subtitle-3', style: { maxWidth: '100%' } }, ((_g = this.state.preview) === null || _g === void 0 ? void 0 : _g.size)
|
|
101
|
+
? "".concat((_h = this.state.preview) === null || _h === void 0 ? void 0 : _h.size, "KB")
|
|
102
|
+
: ((_j = this.props.subTitle) !== null && _j !== void 0 ? _j : (sizeTitle ? "K\u00EDch th\u01B0\u1EDBc t\u1EC7p nh\u1ECF h\u01A1n ".concat(sizeTitle, ".") : ''))))
|
|
103
|
+
],
|
|
104
|
+
this.state.preview && this.props.buttonOnly ? (react_1.default.createElement("div", { className: 'row', style: {} },
|
|
105
|
+
react_1.default.createElement(index_1.Text, { className: 'preview-file-link' }, (_l = (_k = this.state.preview) === null || _k === void 0 ? void 0 : _k.name) !== null && _l !== void 0 ? _l : ''),
|
|
106
|
+
react_1.default.createElement("button", { type: 'button', className: 'remove-preview-file', onClick: function () {
|
|
107
|
+
_this.setState(__assign(__assign({}, _this.state), { preview: null }));
|
|
108
|
+
} }, closeSvg))) : (react_1.default.createElement("button", { type: 'button', className: 'import-file-suffix row', onClick: function () {
|
|
109
|
+
if (_this.props.buttonOnly || _this.state.preview)
|
|
110
|
+
_this.showFilePicker();
|
|
111
|
+
} },
|
|
112
|
+
this.props.buttonOnly ? uploadSvg : null,
|
|
113
|
+
react_1.default.createElement("span", null, this.state.preview ? 'Thay tệp' : 'Chọn tệp'))));
|
|
114
|
+
};
|
|
115
|
+
return ImportFile;
|
|
116
|
+
}(react_1.default.Component));
|
|
117
|
+
exports.ImportFile = ImportFile;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
interface InfiniteScrollProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
handleScroll?: (onLoadMore: boolean, ev: React.UIEvent<HTMLDivElement, UIEvent>) => Promise<any> | null;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
totalCount?: number;
|
|
8
|
+
}
|
|
9
|
+
interface InfiniteScrollState {
|
|
10
|
+
loading: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class InfiniteScroll extends React.Component<InfiniteScrollProps, InfiniteScrollState> {
|
|
13
|
+
state: Readonly<InfiniteScrollState>;
|
|
14
|
+
render(): React.JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
exports.InfiniteScroll = void 0;
|
|
69
|
+
var react_1 = __importDefault(require("react"));
|
|
70
|
+
var InfiniteScroll = /** @class */ (function (_super) {
|
|
71
|
+
__extends(InfiniteScroll, _super);
|
|
72
|
+
function InfiniteScroll() {
|
|
73
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
74
|
+
_this.state = {
|
|
75
|
+
loading: false
|
|
76
|
+
};
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
InfiniteScroll.prototype.render = function () {
|
|
80
|
+
var _this = this;
|
|
81
|
+
var _a, _b;
|
|
82
|
+
return react_1.default.createElement("div", { onScroll: function (ev) { return __awaiter(_this, void 0, void 0, function () {
|
|
83
|
+
var scrollElement;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!this.props.handleScroll) return [3 /*break*/, 2];
|
|
88
|
+
this.setState(__assign(__assign({}, this.state), { loading: true }));
|
|
89
|
+
scrollElement = ev.target;
|
|
90
|
+
return [4 /*yield*/, this.props.handleScroll(Math.round(scrollElement.offsetHeight + scrollElement.scrollTop) >= (scrollElement.scrollHeight - 1), ev)];
|
|
91
|
+
case 1:
|
|
92
|
+
_a.sent();
|
|
93
|
+
this.setState({ loading: false });
|
|
94
|
+
_a.label = 2;
|
|
95
|
+
case 2: return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); }, className: "infinite-scroll ".concat(this.state.loading ? 'loading' : '', " ").concat((_a = this.props.className) !== null && _a !== void 0 ? _a : 'col'), style: (_b = this.props.style) !== null && _b !== void 0 ? _b : { 'overflow': 'hidden auto' } }, this.props.children);
|
|
99
|
+
};
|
|
100
|
+
return InfiniteScroll;
|
|
101
|
+
}(react_1.default.Component));
|
|
102
|
+
exports.InfiniteScroll = InfiniteScroll;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import './input-multi-select.css';
|
|
3
|
+
interface SelectMultipleProps {
|
|
4
|
+
value?: Array<string | number>;
|
|
5
|
+
options: Required<Array<{
|
|
6
|
+
id: string | number;
|
|
7
|
+
name: string;
|
|
8
|
+
}>>;
|
|
9
|
+
onChange?: (value?: Array<string | number>) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
helperText?: string;
|
|
14
|
+
helperTextColor?: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
handleSearch?: (e: string) => Promise<Array<{
|
|
17
|
+
id: string | number;
|
|
18
|
+
name: string;
|
|
19
|
+
}>>;
|
|
20
|
+
}
|
|
21
|
+
interface SelectMultipleState {
|
|
22
|
+
value: Array<string | number>;
|
|
23
|
+
offset: DOMRect;
|
|
24
|
+
isOpen: boolean;
|
|
25
|
+
onSelect: any;
|
|
26
|
+
search?: Array<{
|
|
27
|
+
id: string | number;
|
|
28
|
+
name: string;
|
|
29
|
+
}>;
|
|
30
|
+
style?: Object;
|
|
31
|
+
}
|
|
32
|
+
export declare class SelectMultiple extends React.Component<SelectMultipleProps, SelectMultipleState> {
|
|
33
|
+
constructor(props: SelectMultipleProps);
|
|
34
|
+
private onCheck;
|
|
35
|
+
private search;
|
|
36
|
+
componentDidUpdate(prevProps: SelectMultipleProps, prevState: SelectMultipleState): void;
|
|
37
|
+
render(): React.JSX.Element;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,249 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
73
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
74
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
75
|
+
};
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
exports.SelectMultiple = void 0;
|
|
78
|
+
var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
79
|
+
var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
80
|
+
var react_1 = __importDefault(require("react"));
|
|
81
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
82
|
+
require("./input-multi-select.css");
|
|
83
|
+
var index_1 = require("../../index");
|
|
84
|
+
;
|
|
85
|
+
var SelectMultiple = /** @class */ (function (_super) {
|
|
86
|
+
__extends(SelectMultiple, _super);
|
|
87
|
+
function SelectMultiple(props) {
|
|
88
|
+
var _this = this;
|
|
89
|
+
var _a;
|
|
90
|
+
_this = _super.call(this, props) || this;
|
|
91
|
+
_this.state = {
|
|
92
|
+
value: (_a = props.value) !== null && _a !== void 0 ? _a : [],
|
|
93
|
+
offset: {
|
|
94
|
+
x: 0,
|
|
95
|
+
y: 0,
|
|
96
|
+
height: 0,
|
|
97
|
+
width: 0,
|
|
98
|
+
bottom: 0,
|
|
99
|
+
left: 0,
|
|
100
|
+
right: 0,
|
|
101
|
+
top: 0,
|
|
102
|
+
toJSON: function () {
|
|
103
|
+
throw new Error('Function not implemented.');
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
isOpen: false,
|
|
107
|
+
onSelect: null,
|
|
108
|
+
};
|
|
109
|
+
_this.onCheck = _this.onCheck.bind(_this);
|
|
110
|
+
_this.search = _this.search.bind(_this);
|
|
111
|
+
return _this;
|
|
112
|
+
}
|
|
113
|
+
SelectMultiple.prototype.onCheck = function (item) {
|
|
114
|
+
var newValue = [];
|
|
115
|
+
if (this.state.value.includes(item.id)) {
|
|
116
|
+
newValue = this.state.value.filter(function (vl) { return vl !== item.id; });
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
newValue = __spreadArray(__spreadArray([], this.state.value, true), [item.id], false);
|
|
120
|
+
}
|
|
121
|
+
this.setState(__assign(__assign({}, this.state), { value: newValue }));
|
|
122
|
+
if (this.props.onChange)
|
|
123
|
+
this.props.onChange(newValue);
|
|
124
|
+
};
|
|
125
|
+
SelectMultiple.prototype.search = function (ev) {
|
|
126
|
+
var _a;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var res;
|
|
129
|
+
return __generator(this, function (_b) {
|
|
130
|
+
switch (_b.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
if (!ev.target.value.trim().length) return [3 /*break*/, 4];
|
|
133
|
+
if (!((_a = this.props) === null || _a === void 0 ? void 0 : _a.handleSearch)) return [3 /*break*/, 2];
|
|
134
|
+
return [4 /*yield*/, this.props.handleSearch(ev.target.value.trim())];
|
|
135
|
+
case 1:
|
|
136
|
+
res = _b.sent();
|
|
137
|
+
this.setState(__assign(__assign({}, this.state), { search: res }));
|
|
138
|
+
return [3 /*break*/, 3];
|
|
139
|
+
case 2:
|
|
140
|
+
this.setState(__assign(__assign({}, this.state), { search: this.props.options.filter(function (e) { return e.name.toLowerCase().includes(ev.target.value.trim().toLowerCase()); }) }));
|
|
141
|
+
_b.label = 3;
|
|
142
|
+
case 3: return [3 /*break*/, 5];
|
|
143
|
+
case 4:
|
|
144
|
+
this.setState(__assign(__assign({}, this.state), { search: undefined }));
|
|
145
|
+
_b.label = 5;
|
|
146
|
+
case 5: return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
SelectMultiple.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
if (prevProps.value !== this.props.value) {
|
|
154
|
+
this.setState(__assign(__assign({}, this.state), { value: (_a = this.props.value) !== null && _a !== void 0 ? _a : [] }));
|
|
155
|
+
}
|
|
156
|
+
if (prevState.isOpen !== this.state.isOpen && this.state.isOpen) {
|
|
157
|
+
var thisPopupRect = (_b = document.body.querySelector('.select-multi-popup')) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
158
|
+
if (thisPopupRect) {
|
|
159
|
+
var style = void 0;
|
|
160
|
+
if (thisPopupRect.right > document.body.offsetWidth) {
|
|
161
|
+
style = {
|
|
162
|
+
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
163
|
+
width: "".concat(this.state.offset.width, "px"),
|
|
164
|
+
right: document.body.offsetWidth - this.state.offset.right + 'px'
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (thisPopupRect.bottom - 12 > document.body.offsetHeight) {
|
|
168
|
+
style = style ? __assign(__assign({}, style), { top: undefined, bottom: document.body.offsetHeight - this.state.offset.bottom + 'px' }) : {
|
|
169
|
+
left: this.state.offset.x + 'px',
|
|
170
|
+
width: "".concat(this.state.offset.width, "px"),
|
|
171
|
+
bottom: document.body.offsetHeight - this.state.offset.bottom + 'px'
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (style)
|
|
175
|
+
this.setState(__assign(__assign({}, this.state), { style: style }));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
SelectMultiple.prototype.render = function () {
|
|
180
|
+
var _this = this;
|
|
181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
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': (_b = this.props.helperTextColor) !== null && _b !== void 0 ? _b : '#e14337' }), this.props.style) : { '--helper-text-color': (_c = this.props.helperTextColor) !== null && _c !== void 0 ? _c : '#e14337' }, onClick: function (ev) {
|
|
183
|
+
var _a;
|
|
184
|
+
if (!_this.state.isOpen) {
|
|
185
|
+
_this.setState(__assign(__assign({}, _this.state), { isOpen: true, style: undefined, offset: ((_a = ev.target.closest('.select-multi-container')) !== null && _a !== void 0 ? _a : ev.target).getBoundingClientRect() }));
|
|
186
|
+
}
|
|
187
|
+
} },
|
|
188
|
+
react_1.default.createElement("div", { className: 'row', style: { overflow: 'auto hidden', flex: 1, width: '100%', gap: '0.8rem' } }, ((_d = this.state.value) === null || _d === void 0 ? void 0 : _d.length) ? (this.state.value.map(function (item) {
|
|
189
|
+
var optionItem = _this.props.options.find(function (e) { return e.id === item; });
|
|
190
|
+
return react_1.default.createElement("div", { key: item, className: 'selected-item-value row', onClick: function (ev) {
|
|
191
|
+
var _a;
|
|
192
|
+
ev.stopPropagation();
|
|
193
|
+
var newValue = _this.state.value.filter(function (vl) { return vl !== item; });
|
|
194
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue, isOpen: true, style: undefined, offset: ((_a = ev.target.closest('.select-multi-container')) !== null && _a !== void 0 ? _a : ev.target).getBoundingClientRect() }));
|
|
195
|
+
if (_this.props.onChange)
|
|
196
|
+
_this.props.onChange(newValue);
|
|
197
|
+
} },
|
|
198
|
+
react_1.default.createElement("div", { className: 'selected-value-title' }, optionItem === null || optionItem === void 0 ? void 0 : optionItem.name),
|
|
199
|
+
react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faClose, style: { color: '#161D24E5', fontSize: '1.2rem' } }));
|
|
200
|
+
})) : (react_1.default.createElement("div", { className: 'select-multi-placeholder' }, this.props.placeholder))),
|
|
201
|
+
react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: this.state.isOpen ? free_solid_svg_icons_1.faChevronUp : free_solid_svg_icons_1.faChevronDown, style: { fontSize: '1.2rem', color: '#888' } }),
|
|
202
|
+
this.state.isOpen &&
|
|
203
|
+
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
|
+
top: this.state.offset.y + this.state.offset.height + 2 + 'px',
|
|
205
|
+
left: this.state.offset.x + 'px',
|
|
206
|
+
width: this.state.offset.width,
|
|
207
|
+
}, onMouseOver: function (ev) {
|
|
208
|
+
_this.setState(__assign(__assign({}, _this.state), { onSelect: ev.target }));
|
|
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 () {
|
|
223
|
+
var _a, _b;
|
|
224
|
+
var _list = ((_b = (_a = _this.state.search) !== null && _a !== void 0 ? _a : _this.props.options) !== null && _b !== void 0 ? _b : []);
|
|
225
|
+
var isSelectedAll = _list.every(function (item) { return _this.state.value.some(function (vl) { return vl === item.id; }); });
|
|
226
|
+
return react_1.default.createElement(index_1.Text, { onClick: function () {
|
|
227
|
+
var newValue = [];
|
|
228
|
+
if (_list.length) {
|
|
229
|
+
if (isSelectedAll) {
|
|
230
|
+
newValue = _this.state.value.filter(function (vl) { return _list.every(function (item) { return vl !== item.id; }); });
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
newValue = __spreadArray(__spreadArray([], _this.state.value, true), _list.filter(function (item) { return _this.state.value.every(function (vl) { return vl !== item.id; }); }).map(function (e) { return e.id; }), true);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_this.setState(__assign(__assign({}, _this.state), { value: newValue }));
|
|
237
|
+
if (_this.props.onChange)
|
|
238
|
+
_this.props.onChange(newValue);
|
|
239
|
+
}, className: 'button-text-3', style: { color: _list.length ? 'var(--primary-color)' : '#00204D99', } }, _list.length && isSelectedAll ? 'Bỏ chọn tất cả' : 'Chọn tất cả');
|
|
240
|
+
})()),
|
|
241
|
+
react_1.default.createElement("div", { className: 'col select-body' },
|
|
242
|
+
((_g = (_f = this.state.search) !== null && _f !== void 0 ? _f : this.props.options) !== null && _g !== void 0 ? _g : []).map(function (item) { return (react_1.default.createElement("div", { key: item.id, className: 'select-tile row' },
|
|
243
|
+
react_1.default.createElement(index_1.Checkbox, { value: _this.state.value.some(function (vl) { return vl === item.id; }), onChange: function () { _this.onCheck(item); }, size: '2rem' }),
|
|
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));
|
|
246
|
+
};
|
|
247
|
+
return SelectMultiple;
|
|
248
|
+
}(react_1.default.Component));
|
|
249
|
+
exports.SelectMultiple = SelectMultiple;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { CSSProperties } from "react";
|
|
2
|
+
import './pagination.css';
|
|
3
|
+
export declare function Pagination({ currentPage, itemPerPage, totalItem, onChangePage, hiddenPageSize, hiddenTotal, style }: {
|
|
4
|
+
currentPage: number;
|
|
5
|
+
itemPerPage: number;
|
|
6
|
+
totalItem: number;
|
|
7
|
+
onChangePage: Function;
|
|
8
|
+
hiddenPageSize: boolean;
|
|
9
|
+
hiddenTotal: boolean;
|
|
10
|
+
style: CSSProperties;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Pagination = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var react_paginate_1 = __importDefault(require("react-paginate"));
|
|
9
|
+
require("./pagination.css");
|
|
10
|
+
var index_1 = require("../../index");
|
|
11
|
+
function Pagination(_a) {
|
|
12
|
+
var currentPage = _a.currentPage, itemPerPage = _a.itemPerPage, totalItem = _a.totalItem, onChangePage = _a.onChangePage, _b = _a.hiddenPageSize, hiddenPageSize = _b === void 0 ? false : _b, _c = _a.hiddenTotal, hiddenTotal = _c === void 0 ? false : _c, style = _a.style;
|
|
13
|
+
if (currentPage > 1 && (totalItem === 0 || (Math.floor(totalItem / itemPerPage) + (totalItem % itemPerPage === 0 ? 0 : 1)) < currentPage)) {
|
|
14
|
+
onChangePage(1, itemPerPage);
|
|
15
|
+
return react_1.default.createElement("div", null);
|
|
16
|
+
}
|
|
17
|
+
if (totalItem > 0) {
|
|
18
|
+
return (react_1.default.createElement("div", { className: "row custom-pagination", style: style },
|
|
19
|
+
hiddenTotal ? null : react_1.default.createElement(index_1.Text, { className: "regular2" },
|
|
20
|
+
"Hi\u1EC3n th\u1ECB ",
|
|
21
|
+
itemPerPage * (currentPage - 1) + 1,
|
|
22
|
+
"-",
|
|
23
|
+
((itemPerPage * (currentPage - 1) + itemPerPage) > totalItem) ? totalItem : (itemPerPage * (currentPage - 1) + itemPerPage),
|
|
24
|
+
" trong t\u1ED5ng s\u1ED1 ",
|
|
25
|
+
totalItem,
|
|
26
|
+
" b\u1EA3n ghi"),
|
|
27
|
+
react_1.default.createElement("div", { className: "row " },
|
|
28
|
+
hiddenPageSize ? null : react_1.default.createElement("div", { className: "row items-per-page-container" },
|
|
29
|
+
react_1.default.createElement(index_1.Text, { className: "regular2" }, "Items/page"),
|
|
30
|
+
react_1.default.createElement("div", { className: "row" },
|
|
31
|
+
react_1.default.createElement(index_1.Select1, { searchPlaceholder: 'Search', style: { width: '8.6rem' }, placeholder: itemPerPage.toString(), options: [10, 20, 50, 100, 200].map(function (item, _) { return { id: item, name: item }; }), onChange: function (ev) {
|
|
32
|
+
onChangePage(currentPage, isNaN(parseInt(ev.id)) ? itemPerPage : parseInt(ev.id));
|
|
33
|
+
} }))),
|
|
34
|
+
react_1.default.createElement(react_paginate_1.default, { breakLabel: "...", nextLabel: "Next", onPageChange: function (ev) {
|
|
35
|
+
onChangePage(ev.selected + 1, itemPerPage);
|
|
36
|
+
}, forcePage: currentPage - 1,
|
|
37
|
+
// initialPage={currentPage - 1}
|
|
38
|
+
pageCount: Math.ceil(totalItem / itemPerPage), previousLabel: "Previous", containerClassName: "pagination row", pageClassName: "", pageLinkClassName: "nav-link", previousClassName: "nav-link", previousLinkClassName: "nav-link", nextClassName: "nav-link regular2", nextLinkClassName: "nav-link", activeClassName: "active", hrefBuilder: function (pageIndex) {
|
|
39
|
+
return pageIndex >= 1 && pageIndex <= Math.ceil(totalItem / itemPerPage) ? "/page/".concat(pageIndex) : '#';
|
|
40
|
+
}, renderOnZeroPageCount: null }))));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return (react_1.default.createElement("div", null));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Pagination = Pagination;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import './popup.css';
|
|
3
|
+
interface PopupState {
|
|
4
|
+
readonly open?: boolean;
|
|
5
|
+
heading?: ReactNode;
|
|
6
|
+
content?: ReactNode;
|
|
7
|
+
footer?: ReactNode;
|
|
8
|
+
clickOverlayClosePopup?: boolean;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
hideButtonClose?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const showPopup: ({ ref, heading, content, footer, clickOverlayClosePopup, style, hideButtonClose }: {
|
|
13
|
+
ref: React.MutableRefObject<Popup | undefined>;
|
|
14
|
+
heading?: ReactNode;
|
|
15
|
+
content?: ReactNode;
|
|
16
|
+
footer?: ReactNode;
|
|
17
|
+
clickOverlayClosePopup?: boolean | undefined;
|
|
18
|
+
style?: React.CSSProperties | undefined;
|
|
19
|
+
hideButtonClose?: boolean | undefined;
|
|
20
|
+
}) => void;
|
|
21
|
+
export declare const closePopup: (ref: React.MutableRefObject<Popup>) => void;
|
|
22
|
+
export declare class Popup extends React.Component<Object, PopupState> {
|
|
23
|
+
private ref;
|
|
24
|
+
constructor(props: Object | Readonly<Object>);
|
|
25
|
+
state: Readonly<PopupState>;
|
|
26
|
+
onOpen(data: PopupState): void;
|
|
27
|
+
onClose(): void;
|
|
28
|
+
componentDidUpdate(prevProps: Readonly<Object>, prevState: Readonly<PopupState>): void;
|
|
29
|
+
render(): React.JSX.Element;
|
|
30
|
+
}
|
|
31
|
+
export {};
|