bitys-react-components 0.1.8 → 0.1.10
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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
exports.injectDataGridViewStyles = injectDataGridViewStyles;
|
|
8
|
+
// Conteúdo do CSS em string para injeção no DOM (evita import de .css no build Babel)
|
|
9
|
+
var styleContent = "\nth.sortable {\n color: #2196F3;\n cursor: pointer;\n background-repeat: no-repeat;\n background-position: 95% 50%;\n background-size: 16px;\n}\n.as-react-table .input-group-text:empty{\n display: none;\n}\n.asrt-page-length{\n display: inline-block;\n}\n.asrt-page-length .input-group-addon{\n display: inline-block;\n width: auto;\n margin: 0;\n padding: 0;\n background: #fff;\n border: none;\n}\n.asrt-pagination {\n margin: 0;\n}\n.asrt-td-loading {\n background-color: #fff;\n}\n.asrt-loading-textwrap{\n padding: 5px 0px;\n}\n";
|
|
10
|
+
var STYLE_ID = 'bitys-datagridview-styles';
|
|
11
|
+
function injectDataGridViewStyles() {
|
|
12
|
+
if (typeof document === 'undefined') return;
|
|
13
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
14
|
+
var el = document.createElement('style');
|
|
15
|
+
el.id = STYLE_ID;
|
|
16
|
+
el.textContent = styleContent;
|
|
17
|
+
document.head.appendChild(el);
|
|
18
|
+
}
|
|
19
|
+
var _default = exports["default"] = styleContent;
|
|
@@ -7,10 +7,11 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
require("./assets/css/
|
|
10
|
+
var _styleContent = require("./assets/css/styleContent");
|
|
11
11
|
var _TableHeader = _interopRequireDefault(require("./components/TableHeader"));
|
|
12
12
|
var _TableFooter = _interopRequireDefault(require("./components/TableFooter"));
|
|
13
|
-
var
|
|
13
|
+
var _InputCheck = _interopRequireDefault(require("../InputCheck"));
|
|
14
|
+
var _style = _interopRequireDefault(require("./style"));
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -31,6 +32,9 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
31
32
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
32
33
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
33
34
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
35
|
+
function isCheckBoxColumn(column) {
|
|
36
|
+
return column.key === 'checkBox' || column.type === 'checkBox';
|
|
37
|
+
}
|
|
34
38
|
var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
35
39
|
function ReactDatatable(props) {
|
|
36
40
|
var _this;
|
|
@@ -82,38 +86,61 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
82
86
|
filter_value: '',
|
|
83
87
|
page_size: props.config.page_size ? props.config.page_size : 10,
|
|
84
88
|
page_number: 1,
|
|
85
|
-
sort: props.config && props.config.sort ? props.config.sort : false
|
|
89
|
+
sort: props.config && props.config.sort ? props.config.sort : false,
|
|
90
|
+
lastCheckBoxRowIndex: null
|
|
86
91
|
};
|
|
87
92
|
return _this;
|
|
88
93
|
}
|
|
89
94
|
_inherits(ReactDatatable, _Component);
|
|
90
95
|
return _createClass(ReactDatatable, [{
|
|
96
|
+
key: "handleCheckBoxRowChange",
|
|
97
|
+
value: function handleCheckBoxRowChange(record, checked, payload, rowIndex) {
|
|
98
|
+
var _this2 = this;
|
|
99
|
+
var ev = payload && (payload.event || payload.nativeEvent);
|
|
100
|
+
var shiftPressed = ev && ev.shiftKey;
|
|
101
|
+
var lastCheckBoxRowIndex = this.state.lastCheckBoxRowIndex;
|
|
102
|
+
var records = this.props.records;
|
|
103
|
+
if (shiftPressed && lastCheckBoxRowIndex !== null && records.length > 0) {
|
|
104
|
+
var start = Math.min(rowIndex, lastCheckBoxRowIndex);
|
|
105
|
+
var end = Math.max(rowIndex, lastCheckBoxRowIndex);
|
|
106
|
+
var recordsInRange = records.slice(start, end + 1);
|
|
107
|
+
recordsInRange.forEach(function (r) {
|
|
108
|
+
return _this2.props.onCheckRowChange(r[_this2.config.key_column], checked);
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
this.props.onCheckRowChange(record[this.config.key_column], checked);
|
|
112
|
+
this.setState({
|
|
113
|
+
lastCheckBoxRowIndex: rowIndex
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
91
118
|
key: "filterRecords",
|
|
92
119
|
value: function filterRecords(e) {
|
|
93
|
-
var
|
|
120
|
+
var _this3 = this;
|
|
94
121
|
var value = e.target.value;
|
|
95
122
|
this.setState({
|
|
96
123
|
page_number: 1,
|
|
97
124
|
filter_value: value
|
|
98
125
|
}, function () {
|
|
99
|
-
|
|
126
|
+
_this3.onChange();
|
|
100
127
|
});
|
|
101
128
|
}
|
|
102
129
|
}, {
|
|
103
130
|
key: "changePageSize",
|
|
104
131
|
value: function changePageSize(e) {
|
|
105
|
-
var
|
|
132
|
+
var _this4 = this;
|
|
106
133
|
var value = e.target.value;
|
|
107
134
|
this.setState({
|
|
108
135
|
page_size: value
|
|
109
136
|
}, function () {
|
|
110
|
-
|
|
137
|
+
_this4.onChange();
|
|
111
138
|
});
|
|
112
139
|
}
|
|
113
140
|
}, {
|
|
114
141
|
key: "sortColumn",
|
|
115
142
|
value: function sortColumn(event, column, sortOrder) {
|
|
116
|
-
var
|
|
143
|
+
var _this5 = this;
|
|
117
144
|
if (!column.sortable) return false;
|
|
118
145
|
var newSortOrder = sortOrder == 'asc' ? 'desc' : 'asc';
|
|
119
146
|
this.setState({
|
|
@@ -122,7 +149,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
122
149
|
order: newSortOrder
|
|
123
150
|
}
|
|
124
151
|
}, function () {
|
|
125
|
-
|
|
152
|
+
_this5.onChange();
|
|
126
153
|
});
|
|
127
154
|
}
|
|
128
155
|
}, {
|
|
@@ -163,7 +190,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
163
190
|
}, {
|
|
164
191
|
key: "goToPage",
|
|
165
192
|
value: function goToPage(e, pageNumber) {
|
|
166
|
-
var
|
|
193
|
+
var _this6 = this;
|
|
167
194
|
e.preventDefault();
|
|
168
195
|
if (this.state.page_number == pageNumber) {
|
|
169
196
|
return;
|
|
@@ -176,8 +203,8 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
176
203
|
is_temp_page: false,
|
|
177
204
|
page_number: pageNumber
|
|
178
205
|
}, function () {
|
|
179
|
-
|
|
180
|
-
|
|
206
|
+
_this6.props.onPageChange(pageState);
|
|
207
|
+
_this6.onChange();
|
|
181
208
|
});
|
|
182
209
|
}
|
|
183
210
|
}, {
|
|
@@ -230,6 +257,11 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
230
257
|
var pageNumber = e.target.value;
|
|
231
258
|
this.goToPage(e, pageNumber);
|
|
232
259
|
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "componentDidMount",
|
|
262
|
+
value: function componentDidMount() {
|
|
263
|
+
(0, _styleContent.injectDataGridViewStyles)();
|
|
264
|
+
}
|
|
233
265
|
}, {
|
|
234
266
|
key: "strip",
|
|
235
267
|
value: function strip(html) {
|
|
@@ -247,7 +279,9 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
247
279
|
try {
|
|
248
280
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
249
281
|
var _column = _step.value;
|
|
250
|
-
|
|
282
|
+
if (isCheckBoxColumn(_column)) continue;
|
|
283
|
+
var headerText = typeof _column.text === 'string' ? _column.text : _column.key || '';
|
|
284
|
+
tableHtml += '<th>' + headerText + '</th>';
|
|
251
285
|
}
|
|
252
286
|
} catch (err) {
|
|
253
287
|
_iterator.e(err);
|
|
@@ -276,6 +310,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
276
310
|
try {
|
|
277
311
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
278
312
|
var column = _step2.value;
|
|
313
|
+
if (isCheckBoxColumn(column)) continue;
|
|
279
314
|
if (column.cell && typeof column.cell === 'function') {
|
|
280
315
|
var cellData = _server["default"].renderToStaticMarkup(column.cell(record, i));
|
|
281
316
|
cellData = this.strip(cellData);
|
|
@@ -368,7 +403,9 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
368
403
|
try {
|
|
369
404
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
370
405
|
var _column2 = _step3.value;
|
|
371
|
-
|
|
406
|
+
if (isCheckBoxColumn(_column2)) continue;
|
|
407
|
+
var headerText = typeof _column2.text === 'string' ? _column2.text : _column2.key || '';
|
|
408
|
+
headers[_column2.key] = '"' + headerText + '"';
|
|
372
409
|
}
|
|
373
410
|
|
|
374
411
|
// Filter records before export
|
|
@@ -396,6 +433,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
396
433
|
try {
|
|
397
434
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
398
435
|
var column = _step4.value;
|
|
436
|
+
if (isCheckBoxColumn(column)) continue;
|
|
399
437
|
if (column.cell && typeof column.cell === 'function') {
|
|
400
438
|
var cellData = _server["default"].renderToStaticMarkup(column.cell(record, i));
|
|
401
439
|
cellData = this.strip(cellData);
|
|
@@ -457,11 +495,11 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
457
495
|
}, {
|
|
458
496
|
key: "filterData",
|
|
459
497
|
value: function filterData(records) {
|
|
460
|
-
var
|
|
498
|
+
var _this7 = this;
|
|
461
499
|
var filterValue = this.state.filter_value;
|
|
462
500
|
return records.filter(function (record) {
|
|
463
501
|
var allow = false;
|
|
464
|
-
_lodash["default"].each(
|
|
502
|
+
_lodash["default"].each(_this7.props.columns, function (column, key) {
|
|
465
503
|
if (record[column.key]) {
|
|
466
504
|
allow = _lodash["default"].includes(record[column.key].toString().toLowerCase(), filterValue.toString().toLowerCase()) ? true : allow;
|
|
467
505
|
}
|
|
@@ -472,10 +510,10 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
472
510
|
}, {
|
|
473
511
|
key: "sortRecords",
|
|
474
512
|
value: function sortRecords() {
|
|
475
|
-
var
|
|
513
|
+
var _this8 = this;
|
|
476
514
|
if (this.state.sort) {
|
|
477
515
|
return _lodash["default"].orderBy(this.props.records, function (o) {
|
|
478
|
-
var colVal = o[
|
|
516
|
+
var colVal = o[_this8.state.sort.column];
|
|
479
517
|
var typeofColVal = _typeof(colVal);
|
|
480
518
|
if (typeofColVal == 'string') {
|
|
481
519
|
if (isNaN(colVal)) {
|
|
@@ -494,7 +532,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
494
532
|
}, {
|
|
495
533
|
key: "render",
|
|
496
534
|
value: function render() {
|
|
497
|
-
var
|
|
535
|
+
var _this9 = this;
|
|
498
536
|
var filterRecords, totalRecords, pages, isFirst, isLast;
|
|
499
537
|
if (this.props.dynamic === false) {
|
|
500
538
|
var records = this.props.onSort ? this.props.onSort(this.state.sort.column, this.props.records, this.state.sort.order) : this.sortRecords(),
|
|
@@ -540,7 +578,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
540
578
|
extraButtons: this.props.extraButtons
|
|
541
579
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
542
580
|
className: "row table-body asrt-table-body",
|
|
543
|
-
style:
|
|
581
|
+
style: _style["default"].table_body,
|
|
544
582
|
id: this.props.id ? this.props.id + '-table-body' : '',
|
|
545
583
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
546
584
|
className: "col-md-12",
|
|
@@ -556,21 +594,37 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
556
594
|
align = column.align ? column.align : '',
|
|
557
595
|
sortOrder = '',
|
|
558
596
|
columnStyle = {};
|
|
559
|
-
if (column.sortable &&
|
|
560
|
-
sortOrder =
|
|
597
|
+
if (column.sortable && _this9.state.sort.column == column.key) {
|
|
598
|
+
sortOrder = _this9.state.sort.order;
|
|
561
599
|
classText += sortOrder ? ' ' + sortOrder : '';
|
|
562
|
-
columnStyle = sortOrder == 'asc' ?
|
|
600
|
+
columnStyle = sortOrder == 'asc' ? _style["default"].sort_asc : _style["default"].sort_desc;
|
|
563
601
|
}
|
|
564
602
|
classText += ' text-' + align;
|
|
565
603
|
if (column.TrOnlyClassName) classText += ' ' + column.TrOnlyClassName;
|
|
604
|
+
var isCheckBox = isCheckBoxColumn(column);
|
|
605
|
+
var allSelected = _this9.props.records.length > 0 && _this9.props.checkSelectedIds && _this9.props.checkSelectedIds.length === _this9.props.records.length;
|
|
566
606
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
567
607
|
className: classText,
|
|
568
608
|
width: width,
|
|
569
609
|
style: columnStyle,
|
|
570
610
|
onClick: function onClick(event) {
|
|
571
|
-
return
|
|
611
|
+
return _this9.sortColumn(event, column, sortOrder);
|
|
572
612
|
},
|
|
573
|
-
children:
|
|
613
|
+
children: isCheckBox ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
614
|
+
onClick: function onClick(e) {
|
|
615
|
+
return e.stopPropagation();
|
|
616
|
+
},
|
|
617
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputCheck["default"], {
|
|
618
|
+
name: "selectAll",
|
|
619
|
+
value: allSelected,
|
|
620
|
+
onChange: function onChange(ev) {
|
|
621
|
+
return _this9.props.onCheckRowChange(undefined, ev.target.value);
|
|
622
|
+
},
|
|
623
|
+
styleContainer: {
|
|
624
|
+
justifyContent: 'center'
|
|
625
|
+
}
|
|
626
|
+
})
|
|
627
|
+
}) : column.text
|
|
574
628
|
}, column.key ? column.key : column.text);
|
|
575
629
|
})
|
|
576
630
|
})
|
|
@@ -589,13 +643,33 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
589
643
|
})
|
|
590
644
|
})
|
|
591
645
|
}) : filterRecords.length ? filterRecords.map(function (record, rowIndex) {
|
|
592
|
-
|
|
593
|
-
|
|
646
|
+
rowIndex = _lodash["default"].indexOf(_this9.props.records, record);
|
|
647
|
+
var rowId = record[_this9.config.key_column];
|
|
594
648
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
595
649
|
onClick: function onClick(e) {
|
|
596
|
-
return
|
|
650
|
+
return _this9.props.onRowClicked(e, record, rowIndex);
|
|
597
651
|
},
|
|
598
|
-
children:
|
|
652
|
+
children: _this9.props.columns.map(function (column, colIndex) {
|
|
653
|
+
var isCheckBox = isCheckBoxColumn(column);
|
|
654
|
+
if (isCheckBox) {
|
|
655
|
+
var checked = _this9.props.checkSelectedIds && _this9.props.checkSelectedIds.includes(rowId);
|
|
656
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
657
|
+
className: column.className,
|
|
658
|
+
onClick: function onClick(e) {
|
|
659
|
+
return e.stopPropagation();
|
|
660
|
+
},
|
|
661
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputCheck["default"], {
|
|
662
|
+
name: String(rowId),
|
|
663
|
+
value: checked,
|
|
664
|
+
onChange: function onChange(payload) {
|
|
665
|
+
return _this9.handleCheckBoxRowChange(record, payload.target.value, payload.event, rowIndex);
|
|
666
|
+
},
|
|
667
|
+
styleContainer: {
|
|
668
|
+
justifyContent: 'center'
|
|
669
|
+
}
|
|
670
|
+
})
|
|
671
|
+
}, column.key ? column.key : column.text);
|
|
672
|
+
}
|
|
599
673
|
if (column.cell && typeof column.cell === 'function') {
|
|
600
674
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
601
675
|
className: column.className,
|
|
@@ -612,7 +686,7 @@ var ReactDatatable = /*#__PURE__*/function (_Component) {
|
|
|
612
686
|
}, column.key ? column.key : column.text);
|
|
613
687
|
}
|
|
614
688
|
})
|
|
615
|
-
},
|
|
689
|
+
}, rowId !== null && rowId !== void 0 ? rowId : rowIndex);
|
|
616
690
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
617
691
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
618
692
|
colSpan: this.props.columns.length,
|
|
@@ -696,6 +770,8 @@ ReactDatatable.defaultProps = {
|
|
|
696
770
|
total_record: 0,
|
|
697
771
|
onChange: function onChange() {},
|
|
698
772
|
onPageChange: function onPageChange() {},
|
|
699
|
-
onRowClicked: function onRowClicked() {}
|
|
773
|
+
onRowClicked: function onRowClicked() {},
|
|
774
|
+
checkSelectedIds: [],
|
|
775
|
+
onCheckRowChange: function onCheckRowChange() {}
|
|
700
776
|
};
|
|
701
777
|
var _default = exports["default"] = ReactDatatable;
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
// SVGs inline para evitar dependência de assets no build (Babel não copia PNG/CSS)
|
|
8
|
+
var upArrowSvg = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%232196F3' d='M8 4l-6 6h12L8 4z'/></svg>");
|
|
9
|
+
var downArrowSvg = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%232196F3' d='M8 12l6-6H2l6 6z'/></svg>");
|
|
10
10
|
var _default = exports["default"] = {
|
|
11
11
|
table_body: {
|
|
12
12
|
marginTop: '12px'
|
|
@@ -37,9 +37,9 @@ var _default = exports["default"] = {
|
|
|
37
37
|
marginRight: '5px'
|
|
38
38
|
},
|
|
39
39
|
sort_asc: {
|
|
40
|
-
backgroundImage: "url(".concat(
|
|
40
|
+
backgroundImage: "url(".concat(upArrowSvg, ")")
|
|
41
41
|
},
|
|
42
42
|
sort_desc: {
|
|
43
|
-
backgroundImage: "url(".concat(
|
|
43
|
+
backgroundImage: "url(".concat(downArrowSvg, ")")
|
|
44
44
|
}
|
|
45
45
|
};
|
package/dist/InputCheck/index.js
CHANGED
|
@@ -4,11 +4,14 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports["default"] =
|
|
7
|
+
exports["default"] = InputCheck;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _syles = require("./syles");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
var _excluded = ["value", "label", "onChange", "styleContainer", "styleLabel"];
|
|
11
|
+
var _excluded = ["value", "label", "onChange", "styleContainer", "styleLabel"]; //Exemplo de uso
|
|
12
|
+
//<InputCheck onChange={onSelectItem} name="isValido" value={values.isValido} />
|
|
13
|
+
//function onSelectItem(ev) { setValues({...values, [ev.target.name]: ev.target.value})}
|
|
14
|
+
//Compativel com a função onChange
|
|
12
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
14
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -24,7 +27,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
24
27
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
25
28
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
26
29
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
27
|
-
function
|
|
30
|
+
function InputCheck(_ref) {
|
|
28
31
|
var value = _ref.value,
|
|
29
32
|
label = _ref.label,
|
|
30
33
|
onChange = _ref.onChange,
|
|
@@ -46,18 +49,25 @@ function InputComponent(_ref) {
|
|
|
46
49
|
if (onChange) onChange({
|
|
47
50
|
target: _objectSpread({
|
|
48
51
|
value: checked
|
|
49
|
-
}, inputProps)
|
|
52
|
+
}, inputProps),
|
|
53
|
+
event: ev
|
|
50
54
|
});
|
|
51
55
|
};
|
|
52
56
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_syles.Container, {
|
|
53
57
|
style: styleContainer,
|
|
58
|
+
disabled: inputProps.disabled,
|
|
54
59
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
55
60
|
className: "checkbox",
|
|
56
61
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_syles.SelectBox, _objectSpread({
|
|
57
62
|
checked: state,
|
|
58
63
|
type: "checkbox",
|
|
59
64
|
onChange: onSelect
|
|
60
|
-
}, inputProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
65
|
+
}, inputProps)), inputProps.disabled && state ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
66
|
+
className: "checkmark",
|
|
67
|
+
style: {
|
|
68
|
+
backgroundColor: '#666666'
|
|
69
|
+
}
|
|
70
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
61
71
|
className: "checkmark"
|
|
62
72
|
})]
|
|
63
73
|
}), label && /*#__PURE__*/(0, _jsxRuntime.jsx)(_syles.Label, {
|
package/dist/InputCheck/syles.js
CHANGED
|
@@ -9,9 +9,17 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
9
9
|
var _templateObject, _templateObject2, _templateObject3;
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
11
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
12
|
-
var Container = exports.Container = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n margin: auto 0;\n\n .checkbox {\n display: block;\n position: relative;\n padding-left:
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var Container = exports.Container = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n margin: auto 0;\n\n .checkbox {\n display: block;\n position: relative;\n padding-left: 30px;\n margin-bottom: 20px;\n font-size: 22px;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n cursor: ", ";\n }\n\n .checkmark {\n position: absolute;\n top: 0;\n left: 0;\n height: 20px;\n width: 20px;\n border-radius: 3px;\n\n background-color: ", ";\n }\n .checkbox:hover input ~ .checkmark {\n background-color: ", ";\n }\n .checkbox input:checked ~ .checkmark {\n background-color: var(--blue);\n }\n .checkmark:after {\n content: '';\n position: absolute;\n display: none;\n }\n .checkbox input:checked ~ .checkmark:after {\n display: block;\n }\n .checkbox .checkmark:after {\n left: 9px;\n top: 5px;\n width: 5px;\n height: 10px;\n border: solid white;\n border-width: 0 3px 3px 0;\n -webkit-transform: rotate(45deg);\n -ms-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n"])), function (props) {
|
|
13
|
+
return !props.disabled ? 'pointer' : 'unset';
|
|
14
|
+
}, function (props) {
|
|
15
|
+
return props.disabled ? '#ccc' : '#eee';
|
|
16
|
+
}, function (props) {
|
|
17
|
+
return !props.disabled && '#ccc';
|
|
18
|
+
});
|
|
19
|
+
var SelectBox = exports.SelectBox = (0, _styledComponents["default"])(_reactstrap.Input)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n opacity: 0;\n height: 0;\n width: 0;\n\n cursor: ", ";\n"])), function (props) {
|
|
20
|
+
return !props.disabled ? 'pointer' : 'unset';
|
|
21
|
+
});
|
|
22
|
+
var Label = exports.Label = _styledComponents["default"].label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
15
23
|
return props.isHighlight && 'var(--primary)';
|
|
16
24
|
}, function (props) {
|
|
17
25
|
return props.isHighlight && '1.5rem';
|