ywana-core8 0.0.865 → 0.0.867
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/index.cjs +50 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +50 -30
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +50 -30
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +33 -16
package/package.json
CHANGED
package/src/html/table.js
CHANGED
@@ -13,7 +13,7 @@ const isFunction = value => value && (Object.prototype.toString.call(value) ===
|
|
13
13
|
*/
|
14
14
|
export const DataTable = (props) => {
|
15
15
|
|
16
|
-
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false, className, emptyMessage = "No Results Found", multisort = false } = props
|
16
|
+
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false, className, emptyMessage = "No Results Found", multisort = false, filterable = false } = props
|
17
17
|
const [sortDir, setSortDir] = useState({})
|
18
18
|
const [allChecked, setAllChecked] = useState(false)
|
19
19
|
|
@@ -122,6 +122,9 @@ export const DataTable = (props) => {
|
|
122
122
|
</tr>
|
123
123
|
</thead>
|
124
124
|
<tbody>
|
125
|
+
|
126
|
+
{filterable ? <DataTableFiltersRow columns={columns} /> : null}
|
127
|
+
|
125
128
|
{rows.length > 0 ?
|
126
129
|
multiSort(rows, sortDir).map((row, index) => (
|
127
130
|
<DataTableRow key={row.id} index={index} row={row} columns={columns} onSelect={select} onDrop={moveRow} editable={editable} expanded={expanded} />
|
@@ -142,6 +145,20 @@ export const DataTable = (props) => {
|
|
142
145
|
)
|
143
146
|
}
|
144
147
|
|
148
|
+
const DataTableFiltersRow = ({ columns }) => {
|
149
|
+
return (
|
150
|
+
<tr className="filters-row">
|
151
|
+
{columns.map(({ id, filterable, onFilter }) => {
|
152
|
+
return (
|
153
|
+
<td className='filter-cell'>
|
154
|
+
{filterable ? <TextField id={id} onChange={onFilter} /> : null}
|
155
|
+
</td>
|
156
|
+
)
|
157
|
+
})}
|
158
|
+
</tr>
|
159
|
+
)
|
160
|
+
}
|
161
|
+
|
145
162
|
/**
|
146
163
|
* DataTable Row
|
147
164
|
*/
|
@@ -264,20 +281,20 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
264
281
|
* NumberCellViewer
|
265
282
|
*/
|
266
283
|
const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
267
|
-
/*
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
*/
|
284
|
+
/*
|
285
|
+
function formatNumber(number) {
|
286
|
+
// convert number to numeric
|
287
|
+
if (number === null) return "null"
|
288
|
+
const number2 = Number(number)
|
289
|
+
let result = number2.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
290
|
+
// thousands separator is a dot
|
291
|
+
var parts = result.toString().split(",");
|
292
|
+
const numberPart = parts[0];
|
293
|
+
const decimalPart = parts[1];
|
294
|
+
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
295
|
+
return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
|
296
|
+
}
|
297
|
+
*/
|
281
298
|
function formatNumber(number, maxDecimals = 0) {
|
282
299
|
if (number === null) return "null"
|
283
300
|
let result = number.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
@@ -286,7 +303,7 @@ const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
|
286
303
|
const numberPart = parts[0];
|
287
304
|
const decimalPart = parts[1];
|
288
305
|
const thousands = /\B(?=(\d{3})+(?!\d))/g;
|
289
|
-
|
306
|
+
|
290
307
|
// limit decimal part to maxdecimals
|
291
308
|
const decimal = decimalPart ? decimalPart.substring(0, maxDecimals) : null;
|
292
309
|
return numberPart.replace(thousands, ".") + (decimal ? "," + decimal : "");
|