ywana-core8 0.0.759 → 0.0.761
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 +53 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +53 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +53 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.js +23 -1
- package/src/html/table.test.js +2 -1
package/package.json
CHANGED
package/src/html/table.js
CHANGED
@@ -178,7 +178,7 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
|
|
178
178
|
case "CHECKABLE": return cell && cell.value ? <CheckBox id={id} value={cell.checked || false} label={cell.value} onChange={(id, checked) => onChange(row.id, id, cell.value, checked, cell)} /> : ''
|
179
179
|
case "TEXTFIELD": return <TextField id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
180
180
|
case "String": return <StringCellEditor id={id} value={cell} options={options} onChange={(id, value) => onChange(row.id, id, value)} />
|
181
|
-
case "Number": return <TextField id={id} type="number" value={cell} min={min} max={max} onChange={(id, value) => onChange(row.id, id, value)} />
|
181
|
+
case "Number": return <TextField id={id} type="number" value={cell} min={min} max={max} maxDecimals={column.maxDecimals} onChange={(id, value) => onChange(row.id, id, value)} />
|
182
182
|
default: return cell
|
183
183
|
}
|
184
184
|
} else {
|
@@ -187,6 +187,7 @@ const DataTableCell = ({ index, row, column, cell, editable }) => {
|
|
187
187
|
case "ICON": return <Icon icon={cell} />
|
188
188
|
case "Boolean": return <BooleanCellViewer id={id} value={cell} />
|
189
189
|
case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} action={action} />
|
190
|
+
case "Number": return <NumberCellViewer id={id} value={cell} format={format} />
|
190
191
|
default: return cell
|
191
192
|
}
|
192
193
|
}
|
@@ -244,6 +245,27 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
244
245
|
return <Icon icon={icon} />
|
245
246
|
}
|
246
247
|
|
248
|
+
/**
|
249
|
+
* NumberCellViewer
|
250
|
+
*/
|
251
|
+
const NumberCellViewer = ({ id, value, format, maxDecimals }) => {
|
252
|
+
if (format) {
|
253
|
+
switch (format) {
|
254
|
+
case FORMATS.CURRENCY:
|
255
|
+
return <span>{value.toLocaleString('es-ES', { style: 'currency', currency: 'EUR' })}</span>
|
256
|
+
case FORMATS.PERCENT:
|
257
|
+
return <span>{value.toLocaleString('es-ES', { style: 'percent', minimumFractionDigits: 2 })}</span>
|
258
|
+
default:
|
259
|
+
return <span>{value}</span>
|
260
|
+
}
|
261
|
+
} else {
|
262
|
+
const decimals = maxDecimals ? maxDecimals : 2
|
263
|
+
// check value is a number
|
264
|
+
return (value && !isNaN(value)) ? <span>{value.toFixed(decimals)}</span> : ""
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
|
247
269
|
/**
|
248
270
|
* String Cell Viewer
|
249
271
|
*/
|
package/src/html/table.test.js
CHANGED
@@ -13,7 +13,7 @@ export const TableTest = (prop) => {
|
|
13
13
|
{ id: 5, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
14
14
|
{ id: 6, checked: false, name: "John Smith" , description: "lorem ipsum ", color: "#CCFFFF" },
|
15
15
|
{ id: 7, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
16
|
-
{ id: 8, checked: false, name: "Martin Freeman", description: "lorem ipsum ", color: "#CCFFFF" },
|
16
|
+
{ id: 8, checked: false, name: "Martin Freeman", description: "lorem ipsum ", color: "#CCFFFF" , num: 890.1234567890 },
|
17
17
|
{ id: 9, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF", date: new Date().toString() },
|
18
18
|
]
|
19
19
|
)
|
@@ -47,6 +47,7 @@ export const TableTest = (prop) => {
|
|
47
47
|
{ id: "description", label: "Description", type: "String" },
|
48
48
|
{ id: "color" , label: "Color" , type: "String", format: FORMATS.COLOR },
|
49
49
|
{ id: "date" , label: "Date" , type: "String", format: FORMATS.DATE },
|
50
|
+
{ id: "num" , label: "Num" , type: "Number", maxDecimals: 2 },
|
50
51
|
],
|
51
52
|
rows
|
52
53
|
}
|