wini-web-components 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ import React, { CSSProperties, ReactNode } from 'react';
2
+ interface ButtonProps {
3
+ id?: string;
4
+ label: string;
5
+ prefix?: ReactNode;
6
+ suffix?: ReactNode;
7
+ disabled?: boolean;
8
+ style?: CSSProperties;
9
+ type?: "button" | "reset" | "submit";
10
+ className?: string;
11
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
12
+ }
13
+ export declare class Button extends React.Component<ButtonProps> {
14
+ render(): React.JSX.Element;
15
+ }
16
+ export {};
@@ -0,0 +1,37 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Button = void 0;
22
+ var react_1 = __importDefault(require("react"));
23
+ var text_1 = require("../text/text");
24
+ var button_module_css_1 = __importDefault(require("./button.module.css"));
25
+ var Button = /** @class */ (function (_super) {
26
+ __extends(Button, _super);
27
+ function Button() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ Button.prototype.render = function () {
31
+ var _a, _b;
32
+ return react_1.default.createElement("button", { id: this.props.id, type: (_a = this.props.type) !== null && _a !== void 0 ? _a : "button", disabled: this.props.disabled, className: "".concat(button_module_css_1.default['button-container'], " row ").concat((_b = this.props.className) !== null && _b !== void 0 ? _b : "button-text-3"), style: this.props.style, onClick: this.props.onClick },
33
+ react_1.default.createElement(text_1.Text, { maxLine: 1, className: button_module_css_1.default['button-label'] }, this.props.label));
34
+ };
35
+ return Button;
36
+ }(react_1.default.Component));
37
+ exports.Button = Button;
@@ -1,5 +1,4 @@
1
1
  import React, { CSSProperties } from 'react';
2
- import './checkbox.css';
3
2
  interface CheckboxProps {
4
3
  id?: string;
5
4
  onChange?: (value: boolean) => void;
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.Checkbox = void 0;
33
33
  var react_1 = __importDefault(require("react"));
34
- require("./checkbox.css");
34
+ var checkbox_module_css_1 = __importDefault(require("./checkbox.module.css"));
35
35
  var Checkbox = /** @class */ (function (_super) {
36
36
  __extends(Checkbox, _super);
37
37
  function Checkbox() {
@@ -64,7 +64,7 @@ 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", { id: this.props.id, className: "checkbox-container row", style: convertStyle, "is-null-value": "".concat(this.state.value == undefined), onClick: this.props.onClick },
67
+ return react_1.default.createElement("label", { id: this.props.id, className: "".concat(checkbox_module_css_1.default['checkbox-container'], " row"), style: convertStyle, "is-null-value": "".concat(this.state.value == undefined), onClick: this.props.onClick },
68
68
  react_1.default.createElement("input", { type: "checkbox", checked: this.state.value, disabled: this.props.disabled, onChange: function (ev) {
69
69
  ev.stopPropagation();
70
70
  var newValue = !_this.state.value;
@@ -79,5 +79,3 @@ var Checkbox = /** @class */ (function (_super) {
79
79
  return Checkbox;
80
80
  }(react_1.default.Component));
81
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,12 +1,11 @@
1
1
  import React, { CSSProperties } from "react";
2
- import './pagination.css';
3
- export declare function Pagination({ id, currentPage, itemPerPage, totalItem, onChangePage, hiddenPageSize, hiddenTotal, style }: {
2
+ export declare function Pagination({ id, currentPage, itemPerPage, totalItem, onChangePage, hidePageSize, hideGoToPage, style }: {
4
3
  id?: string;
5
4
  currentPage: number;
6
5
  itemPerPage: number;
7
6
  totalItem: number;
8
7
  onChangePage: Function;
9
- hiddenPageSize: boolean;
10
- hiddenTotal: boolean;
8
+ hideGoToPage?: boolean;
9
+ hidePageSize?: boolean;
11
10
  style: CSSProperties;
12
11
  }): React.JSX.Element;
@@ -1,46 +1,85 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.Pagination = void 0;
7
- var react_1 = __importDefault(require("react"));
30
+ var react_1 = __importStar(require("react"));
8
31
  var react_paginate_1 = __importDefault(require("react-paginate"));
9
- require("./pagination.css");
10
- var index_1 = require("../../index");
32
+ var pagination_module_css_1 = __importDefault(require("./pagination.module.css"));
33
+ var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
34
+ var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
35
+ var select1_1 = require("../select1/select1");
36
+ var text_1 = require("../text/text");
37
+ var text_field_1 = require("../text-field/text-field");
11
38
  function Pagination(_a) {
12
- var id = _a.id, 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;
39
+ var id = _a.id, currentPage = _a.currentPage, itemPerPage = _a.itemPerPage, totalItem = _a.totalItem, onChangePage = _a.onChangePage, _b = _a.hidePageSize, hidePageSize = _b === void 0 ? false : _b, _c = _a.hideGoToPage, hideGoToPage = _c === void 0 ? false : _c, style = _a.style;
40
+ var goToPageRef = (0, react_1.useRef)();
13
41
  if (currentPage > 1 && (totalItem === 0 || (Math.floor(totalItem / itemPerPage) + (totalItem % itemPerPage === 0 ? 0 : 1)) < currentPage)) {
14
42
  onChangePage(1, itemPerPage);
15
43
  return react_1.default.createElement("div", null);
16
44
  }
45
+ (0, react_1.useEffect)(function () {
46
+ if (goToPageRef.current) {
47
+ var _inputPage = goToPageRef.current.getInput();
48
+ if (_inputPage)
49
+ _inputPage.value = currentPage.toString();
50
+ }
51
+ }, [currentPage]);
17
52
  if (totalItem > 0) {
18
- return (react_1.default.createElement("div", { id: id, 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, { readOnly: true, 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", { id: id }));
53
+ return react_1.default.createElement("div", { id: id, className: "".concat(pagination_module_css_1.default['custom-pagination'], " row"), style: style },
54
+ hidePageSize ? null : react_1.default.createElement("div", { className: "row", style: { gap: '0.8rem' } },
55
+ react_1.default.createElement(select1_1.Select1, { readOnly: true, placeholder: itemPerPage.toString(), options: [10, 20, 50, 80, 100, 150, 200].map(function (item, _) { return { id: item, name: item }; }), style: { borderRadius: '0.4rem', width: '5.6rem', padding: '0 0.8rem', height: '2.4rem' }, onChange: function (ev) {
56
+ onChangePage(currentPage, isNaN(parseInt(ev.id)) ? itemPerPage : parseInt(ev.id));
57
+ } }),
58
+ react_1.default.createElement(text_1.Text, { className: "body-3" },
59
+ "of ",
60
+ totalItem,
61
+ " items")),
62
+ react_1.default.createElement("div", { style: { flex: 1 } }),
63
+ react_1.default.createElement(react_paginate_1.default, { onPageChange: function (ev) {
64
+ onChangePage(ev.selected + 1, itemPerPage);
65
+ }, forcePage: currentPage - 1,
66
+ // initialPage={currentPage - 1}
67
+ breakClassName: "row button-text-3", breakLabel: "...", pageCount: Math.ceil(totalItem / itemPerPage), previousClassName: "row", previousLabel: react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faChevronLeft, style: { fontSize: '1.4rem' } }), nextClassName: "row", nextLabel: react_1.default.createElement(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faChevronRight, style: { fontSize: '1.4rem' } }), containerClassName: "".concat(pagination_module_css_1.default['pagination'], " row"), pageClassName: "row button-text-3", activeClassName: pagination_module_css_1.default['active'], hrefBuilder: function (pageIndex) {
68
+ return pageIndex >= 1 && pageIndex <= Math.ceil(totalItem / itemPerPage) ? "/page/".concat(pageIndex) : '#';
69
+ }, renderOnZeroPageCount: null }),
70
+ hideGoToPage ? null : react_1.default.createElement(react_1.default.Fragment, null,
71
+ react_1.default.createElement("div", { style: { height: '1.6rem', backgroundColor: "#00358033", width: 1 } }),
72
+ react_1.default.createElement(text_1.Text, { className: "label-3", style: { color: "#161C2499" } }, "Go to page"),
73
+ react_1.default.createElement(text_field_1.TextField, { ref: goToPageRef, style: { width: '4.8rem', textAlign: "center", padding: 0, height: '2.4rem', borderRadius: '0.4rem' }, className: "body-3", type: "number", onBlur: function (ev) {
74
+ var _tmp = ev.target.value.trim().length ? parseInt(ev.target.value.trim()) : undefined;
75
+ if (_tmp && !isNaN(_tmp) && _tmp > 0 && _tmp <= Math.ceil(totalItem / itemPerPage)) {
76
+ onChangePage(_tmp, itemPerPage);
77
+ }
78
+ else
79
+ ev.target.value = "";
80
+ } })));
44
81
  }
82
+ else
83
+ return react_1.default.createElement("div", { id: id });
45
84
  }
46
85
  exports.Pagination = Pagination;
@@ -1,5 +1,4 @@
1
1
  import React, { CSSProperties } from 'react';
2
- import './switch.css';
3
2
  interface SwitchProps {
4
3
  id?: string;
5
4
  onChange?: (value: boolean) => void;
@@ -11,7 +10,6 @@ interface SwitchProps {
11
10
  onBackground?: string;
12
11
  offBackground?: string;
13
12
  name?: string;
14
- className?: string;
15
13
  }
16
14
  interface SwitchState {
17
15
  value?: boolean;
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.Switch = void 0;
33
33
  var react_1 = __importDefault(require("react"));
34
- require("./switch.css");
34
+ var switch_module_css_1 = __importDefault(require("./switch.module.css"));
35
35
  var Switch = /** @class */ (function (_super) {
36
36
  __extends(Switch, _super);
37
37
  function Switch() {
@@ -50,7 +50,7 @@ var Switch = /** @class */ (function (_super) {
50
50
  };
51
51
  Switch.prototype.render = function () {
52
52
  var _this = this;
53
- var _a, _b, _c, _d, _e;
53
+ var _a, _b, _c, _d;
54
54
  var propStyle = {
55
55
  '--off-bg': (_a = this.props.offBackground) !== null && _a !== void 0 ? _a : 'var(--background)',
56
56
  '--on-bg': (_b = this.props.onBackground) !== null && _b !== void 0 ? _b : 'var(--infor-color)',
@@ -67,14 +67,14 @@ var Switch = /** @class */ (function (_super) {
67
67
  delete this.props.style.maxHeight;
68
68
  convertStyle = __assign(__assign({}, this.props.style), convertStyle);
69
69
  }
70
- return react_1.default.createElement("label", { id: this.props.id, className: "switch-container row ".concat((_e = this.props.className) !== null && _e !== void 0 ? _e : ''), style: convertStyle },
70
+ return react_1.default.createElement("label", { id: this.props.id, className: "".concat(switch_module_css_1.default['switch-container'], " row"), style: convertStyle },
71
71
  react_1.default.createElement("input", { type: "checkbox", checked: this.state.value, name: this.props.name, disabled: this.props.disabled, onChange: function () {
72
72
  var newValue = !_this.state.value;
73
73
  _this.setState({ value: newValue });
74
74
  if (_this.props.onChange)
75
75
  _this.props.onChange(newValue);
76
76
  } }),
77
- react_1.default.createElement("span", { className: "slider" }));
77
+ react_1.default.createElement("span", { className: switch_module_css_1.default['slider'] }));
78
78
  };
79
79
  return Switch;
80
80
  }(react_1.default.Component));
@@ -24,6 +24,8 @@ interface TextFieldProps {
24
24
  register?: UseFormRegister<{}>;
25
25
  }
26
26
  export declare class TextField extends React.Component<TextFieldProps> {
27
+ private containerRef;
28
+ getInput: () => HTMLInputElement | null | undefined;
27
29
  render(): React.ReactNode;
28
30
  }
29
31
  export {};
@@ -25,21 +25,47 @@ var __assign = (this && this.__assign) || function () {
25
25
  };
26
26
  return __assign.apply(this, arguments);
27
27
  };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
30
50
  };
31
51
  Object.defineProperty(exports, "__esModule", { value: true });
32
52
  exports.TextField = void 0;
33
- var react_1 = __importDefault(require("react"));
53
+ var react_1 = __importStar(require("react"));
34
54
  require("./text-field.css");
35
55
  var TextField = /** @class */ (function (_super) {
36
56
  __extends(TextField, _super);
37
57
  function TextField() {
38
- return _super !== null && _super.apply(this, arguments) || this;
58
+ var _this = _super !== null && _super.apply(this, arguments) || this;
59
+ _this.containerRef = (0, react_1.createRef)();
60
+ _this.getInput = function () {
61
+ var _a;
62
+ return (_a = _this.containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("input");
63
+ };
64
+ return _this;
39
65
  }
40
66
  TextField.prototype.render = function () {
41
67
  var _a, _b, _c, _d, _e, _f;
42
- return react_1.default.createElement("div", { id: this.props.id, className: "text-field-container row ".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : 'body-3', " ").concat(((_b = this.props.helperText) === null || _b === void 0 ? void 0 : _b.length) && 'helper-text'), "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' } },
68
+ return react_1.default.createElement("div", { ref: this.containerRef, id: this.props.id, className: "text-field-container row ".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : 'body-3', " ").concat(((_b = this.props.helperText) === null || _b === void 0 ? void 0 : _b.length) && 'helper-text'), "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' } },
43
69
  this.props.prefix,
44
70
  this.props.register ?
45
71
  react_1.default.createElement("input", __assign({}, this.props.register, { autoFocus: this.props.autoFocus, maxLength: this.props.maxLength, name: this.props.name, type: (_e = this.props.type) !== null && _e !== void 0 ? _e : 'text', placeholder: this.props.placeholder, readOnly: this.props.readOnly, disabled: this.props.disabled, onFocus: this.props.onFocus })) : react_1.default.createElement("input", { autoFocus: this.props.autoFocus, maxLength: this.props.maxLength, name: this.props.name, type: (_f = this.props.type) !== null && _f !== void 0 ? _f : 'text', defaultValue: this.props.defaultValue, value: this.props.value, placeholder: this.props.placeholder, readOnly: this.props.readOnly, disabled: this.props.disabled, onChange: this.props.onChange, onFocus: this.props.onFocus, onBlur: this.props.onBlur }),
package/dist/index.d.ts CHANGED
@@ -25,4 +25,5 @@ import { ProgressCircle } from './component/progress-circle/progress-circle';
25
25
  import { CustomSlider } from './component/slider/slider';
26
26
  import { ToastContainer } from 'react-toastify';
27
27
  import { CardInfo } from './component/card/card';
28
- export { Calendar, CalendarType, ComponentStatus, getStatusIcon, Checkbox, Select1, OptionsItem, Switch, Popup, showPopup, closePopup, Dialog, showDialog, DialogAlignment, DatePicker, SelectMultiple, ProgressBar, Text, Pagination, Table, TbCell, TbHeader, TbBody, TbRow, CellAlignItems, TextField, RadioButton, TextArea, ImportFile, ToastMessage, InfiniteScroll, Rating, ProgressCircle, CustomSlider, ToastContainer, CardInfo };
28
+ import { Button } from './component/button/button';
29
+ export { Calendar, CalendarType, ComponentStatus, getStatusIcon, Checkbox, Select1, OptionsItem, Switch, Popup, showPopup, closePopup, Dialog, showDialog, DialogAlignment, DatePicker, SelectMultiple, ProgressBar, Text, Pagination, Table, TbCell, TbHeader, TbBody, TbRow, CellAlignItems, TextField, RadioButton, TextArea, ImportFile, ToastMessage, InfiniteScroll, Rating, ProgressCircle, CustomSlider, ToastContainer, CardInfo, Button };