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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.865",
3
+ "version": "0.0.867",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
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
- function formatNumber(number) {
269
- // convert number to numeric
270
- if (number === null) return "null"
271
- const number2 = Number(number)
272
- let result = number2.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
273
- // thousands separator is a dot
274
- var parts = result.toString().split(",");
275
- const numberPart = parts[0];
276
- const decimalPart = parts[1];
277
- const thousands = /\B(?=(\d{3})+(?!\d))/g;
278
- return numberPart.replace(thousands, ".") + (decimalPart ? "," + decimalPart : "");
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 : "");