@helpdice/ui 1.3.4 → 1.3.6
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/checkbox/checkbox.d.ts +2 -2
- package/dist/checkbox/index.js +2 -2
- package/dist/index.js +548 -561
- package/dist/table/index.js +1314 -1327
- package/esm/checkbox/checkbox.d.ts +2 -2
- package/esm/checkbox/checkbox.js +2 -2
- package/esm/form/FormPersist.js +56 -0
- package/esm/table/data-table.js +3 -31
- package/esm/table/table-body.js +23 -7
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { InputHTMLAttributes } from 'react';
|
|
2
2
|
import { NormalTypes } from '../utils/prop-types';
|
|
3
3
|
export type CheckboxTypes = NormalTypes;
|
|
4
4
|
export interface CheckboxEventTarget {
|
|
5
5
|
checked: boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface CheckboxEvent {
|
|
7
|
+
export interface CheckboxEvent extends InputHTMLAttributes<any> {
|
|
8
8
|
target: CheckboxEventTarget;
|
|
9
9
|
stopPropagation: () => void;
|
|
10
10
|
preventDefault: () => void;
|
package/esm/checkbox/checkbox.js
CHANGED
|
@@ -60,9 +60,9 @@ var CheckboxComponent = function CheckboxComponent(_ref) {
|
|
|
60
60
|
var changeHandle = useCallback(function (ev) {
|
|
61
61
|
if (isDisabled) return;
|
|
62
62
|
var selfEvent = {
|
|
63
|
-
target: {
|
|
63
|
+
target: _extends({}, ev.target, {
|
|
64
64
|
checked: !selfChecked
|
|
65
|
-
},
|
|
65
|
+
}),
|
|
66
66
|
stopPropagation: ev.stopPropagation,
|
|
67
67
|
preventDefault: ev.preventDefault,
|
|
68
68
|
nativeEvent: ev
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import connect from './connect';
|
|
11
|
+
import { debounce } from 'lodash';
|
|
12
|
+
import isEqual from 'react-fast-compare';
|
|
13
|
+
var PersistImpl = /*#__PURE__*/function (_React$Component) {
|
|
14
|
+
function PersistImpl() {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, PersistImpl);
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
_this = _callSuper(this, PersistImpl, [].concat(args));
|
|
21
|
+
_defineProperty(_this, "saveForm", debounce(function (data) {
|
|
22
|
+
if (_this.props.isSessionStorage) {
|
|
23
|
+
window.sessionStorage.setItem(_this.props.name, JSON.stringify(data));
|
|
24
|
+
} else {
|
|
25
|
+
window.localStorage.setItem(_this.props.name, JSON.stringify(data));
|
|
26
|
+
}
|
|
27
|
+
}, _this.props.debounce));
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
_inherits(PersistImpl, _React$Component);
|
|
31
|
+
return _createClass(PersistImpl, [{
|
|
32
|
+
key: "componentDidUpdate",
|
|
33
|
+
value: function componentDidUpdate(prevProps) {
|
|
34
|
+
if (!isEqual(prevProps.formik, this.props.formik)) {
|
|
35
|
+
this.saveForm(this.props.formik);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "componentDidMount",
|
|
40
|
+
value: function componentDidMount() {
|
|
41
|
+
var maybeState = this.props.isSessionStorage ? window.sessionStorage.getItem(this.props.name) : window.localStorage.getItem(this.props.name);
|
|
42
|
+
if (maybeState && maybeState !== null) {
|
|
43
|
+
this.props.formik.setFormikState(JSON.parse(maybeState));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "render",
|
|
48
|
+
value: function render() {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}]);
|
|
52
|
+
}(React.Component);
|
|
53
|
+
_defineProperty(PersistImpl, "defaultProps", {
|
|
54
|
+
debounce: 300
|
|
55
|
+
});
|
|
56
|
+
export var FormPersist = connect(PersistImpl);
|
package/esm/table/data-table.js
CHANGED
|
@@ -96,34 +96,6 @@ function DataTable(_ref) {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
}, [hideColumn, cols, rows]);
|
|
99
|
-
|
|
100
|
-
// const handleClick = (event: React.MouseEvent<HTMLTableRowElement, MouseEvent>, id: any) => {
|
|
101
|
-
// if (readOnly) {
|
|
102
|
-
// return true;
|
|
103
|
-
// }
|
|
104
|
-
// const selectedIndex = selected.indexOf(id as never);
|
|
105
|
-
// let newSelected: never[] | ((prevState: never[]) => never[]) = [];
|
|
106
|
-
// if (selectedIndex === -1) {
|
|
107
|
-
// newSelected = newSelected.concat(selected, id);
|
|
108
|
-
// } else if (selectedIndex === 0) {
|
|
109
|
-
// newSelected = newSelected.concat(selected.slice(1));
|
|
110
|
-
// } else if (selectedIndex === selected.length - 1) {
|
|
111
|
-
// newSelected = newSelected.concat(selected.slice(0, -1));
|
|
112
|
-
// } else if (selectedIndex > 0) {
|
|
113
|
-
// newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
|
|
114
|
-
// }
|
|
115
|
-
// setSelected(newSelected);
|
|
116
|
-
// };
|
|
117
|
-
|
|
118
|
-
// const handleSelectAllClick = (event: { target: { checked: any } }) => {
|
|
119
|
-
// if (event.target.checked) {
|
|
120
|
-
// const newSelecteds = rows.map((n: { _id: any }) => n._id);
|
|
121
|
-
// setSelected(newSelecteds as never[]);
|
|
122
|
-
// return;
|
|
123
|
-
// }
|
|
124
|
-
// setSelected([]);
|
|
125
|
-
// };
|
|
126
|
-
|
|
127
99
|
var handleHideColumnClick = function handleHideColumnClick(_event, id) {
|
|
128
100
|
var selectedIndex = hideColumn.indexOf(id);
|
|
129
101
|
var newSelected = [];
|
|
@@ -222,7 +194,7 @@ function DataTable(_ref) {
|
|
|
222
194
|
},
|
|
223
195
|
justify: "flex-end",
|
|
224
196
|
alignContent: "center"
|
|
225
|
-
}, menu, !children && !readOnly ? /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
197
|
+
}, menu, !children && !readOnly ? /*#__PURE__*/React.createElement(React.Fragment, null, onSelectedEdit && selected.length === 1 ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
226
198
|
text: "Edit Selected",
|
|
227
199
|
placement: "bottom",
|
|
228
200
|
font: 0.8,
|
|
@@ -237,7 +209,7 @@ function DataTable(_ref) {
|
|
|
237
209
|
auto: true,
|
|
238
210
|
scale: 2 / 3,
|
|
239
211
|
px: 0.6
|
|
240
|
-
})) : null, onSelectedDelete ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
212
|
+
})) : null, onSelectedDelete && selected.length > 1 ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
241
213
|
text: "Delete Selected",
|
|
242
214
|
placement: "bottom",
|
|
243
215
|
font: 0.8,
|
|
@@ -252,7 +224,7 @@ function DataTable(_ref) {
|
|
|
252
224
|
scale: 2 / 3,
|
|
253
225
|
px: 0.6,
|
|
254
226
|
iconRight: /*#__PURE__*/React.createElement(Delete, null)
|
|
255
|
-
})) : null
|
|
227
|
+
})) : null, onRefresh ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
256
228
|
text: "Refresh",
|
|
257
229
|
placement: "bottom",
|
|
258
230
|
font: 0.8,
|
package/esm/table/table-body.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
5
|
import useTheme from '../use-theme';
|
|
6
6
|
import TableCell from './table-cell';
|
|
7
7
|
import { useTableContext } from './table-context';
|
|
8
8
|
import useClasses from '../use-classes';
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import Placeholder from '../Placeholder';
|
|
11
|
+
import DataTable from './data-table';
|
|
11
12
|
var TableBody = function TableBody(_ref) {
|
|
12
13
|
var data = _ref.data,
|
|
13
14
|
emptyText = _ref.emptyText,
|
|
@@ -46,6 +47,9 @@ var TableBody = function TableBody(_ref) {
|
|
|
46
47
|
newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
|
|
47
48
|
}
|
|
48
49
|
setSelected(newSelected);
|
|
50
|
+
if (newSelected.length > 0 && onSelected) {
|
|
51
|
+
onSelected(newSelected);
|
|
52
|
+
}
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
// const handleSelectAllClick = (event: { target: { checked: any } }) => {
|
|
@@ -58,11 +62,12 @@ var TableBody = function TableBody(_ref) {
|
|
|
58
62
|
// };
|
|
59
63
|
|
|
60
64
|
// Push Selected Rows
|
|
61
|
-
useEffect(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, [selected]);
|
|
65
|
+
// useEffect(() => {
|
|
66
|
+
// if (selected.length > 0 && onSelected) {
|
|
67
|
+
// onSelected(selected);
|
|
68
|
+
// }
|
|
69
|
+
// }, [selected]);
|
|
70
|
+
|
|
66
71
|
function renderRow(cols, row, index) {
|
|
67
72
|
var _row$style;
|
|
68
73
|
var urid = _.uniqueId();
|
|
@@ -122,6 +127,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
122
127
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
123
128
|
className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
|
|
124
129
|
}, data.map(function (row, index) {
|
|
130
|
+
var _row$table, _row$table2, _row$table3, _row$table4, _row$table5;
|
|
125
131
|
var qid = _.uniqueId();
|
|
126
132
|
if (row === null || row === undefined) {
|
|
127
133
|
var uid = _.uniqueId();
|
|
@@ -142,7 +148,17 @@ var TableBody = function TableBody(_ref) {
|
|
|
142
148
|
},
|
|
143
149
|
colSpan: columns.length,
|
|
144
150
|
className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
|
|
145
|
-
}
|
|
151
|
+
}, /*#__PURE__*/React.createElement(DataTable, {
|
|
152
|
+
readOnly: true,
|
|
153
|
+
stickyHeader: false,
|
|
154
|
+
style: _extends({
|
|
155
|
+
height: 'auto !important'
|
|
156
|
+
}, row === null || row === void 0 || (_row$table = row.table) === null || _row$table === void 0 ? void 0 : _row$table.style),
|
|
157
|
+
menu: (_row$table2 = row.table) === null || _row$table2 === void 0 ? void 0 : _row$table2.menu,
|
|
158
|
+
rows: (_row$table3 = row.table) === null || _row$table3 === void 0 ? void 0 : _row$table3.rows,
|
|
159
|
+
heading: (_row$table4 = row.table) === null || _row$table4 === void 0 ? void 0 : _row$table4.heading,
|
|
160
|
+
cols: (_row$table5 = row.table) === null || _row$table5 === void 0 ? void 0 : _row$table5.cols
|
|
161
|
+
}))));
|
|
146
162
|
|
|
147
163
|
// return (
|
|
148
164
|
// <tr
|