ywana-core8 0.0.194 → 0.0.198
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 +278 -230
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +8 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +278 -230
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +278 -230
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +1 -1
- package/src/domain/ContentViewer.css +8 -0
- package/src/domain/ContentViewer.js +32 -2
- package/src/domain/TablePage.js +1 -0
- package/src/html/table.js +8 -4
package/package.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Property } from '../html'
|
3
|
-
import { TYPES } from './ContentType'
|
3
|
+
import { Content, TYPES } from './ContentType'
|
4
|
+
import './ContentViewer.css'
|
4
5
|
|
5
6
|
/**
|
6
7
|
* Content Viewer
|
@@ -22,7 +23,7 @@ export const ContentViewer = (props) => {
|
|
22
23
|
{sections.map(section => {
|
23
24
|
const { title, fields } = section
|
24
25
|
return (
|
25
|
-
<section key={title}>
|
26
|
+
<section key={title} className="content-viewer">
|
26
27
|
<header>
|
27
28
|
{title}
|
28
29
|
</header>
|
@@ -36,6 +37,12 @@ export const ContentViewer = (props) => {
|
|
36
37
|
)
|
37
38
|
}
|
38
39
|
|
40
|
+
/**
|
41
|
+
* Field Viewer
|
42
|
+
*
|
43
|
+
* @param {} props
|
44
|
+
* @returns
|
45
|
+
*/
|
39
46
|
const FieldViewer = (props) => {
|
40
47
|
|
41
48
|
const { field, value } = props
|
@@ -46,7 +53,30 @@ const FieldViewer = (props) => {
|
|
46
53
|
switch(type) {
|
47
54
|
case TYPES.STRING:
|
48
55
|
return <Property label={label} value={value} />
|
56
|
+
case TYPES.ENTITY:
|
57
|
+
return <EntityViewer field={field} value={value} />
|
49
58
|
default:
|
50
59
|
return <div>{label}</div>
|
51
60
|
}
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* EntityViewer
|
65
|
+
*/
|
66
|
+
const EntityViewer = (props) => {
|
67
|
+
const { field, value } = props
|
68
|
+
const { item, label } = field
|
69
|
+
const content = new Content(item, value)
|
70
|
+
const form = content.form()
|
71
|
+
const fields = Object.keys(form).map(key => form[key])
|
72
|
+
return (
|
73
|
+
<div className='entity-viewer'>
|
74
|
+
<header>
|
75
|
+
{label}
|
76
|
+
</header>
|
77
|
+
<main>
|
78
|
+
{ fields.map( field => <FieldViewer field={field} value={value[field.id]} /> )}
|
79
|
+
</main>
|
80
|
+
</div>
|
81
|
+
)
|
52
82
|
}
|
package/src/domain/TablePage.js
CHANGED
@@ -334,6 +334,7 @@ const TableEditor = (props) => {
|
|
334
334
|
id: field.id,
|
335
335
|
label: field.label,
|
336
336
|
type: field.type,
|
337
|
+
format: field.format,
|
337
338
|
onChange: field.id === "checked" ? checkOne : field.editable ? change : null, /* checked has it´s own handler */
|
338
339
|
options
|
339
340
|
}
|
package/src/html/table.js
CHANGED
@@ -4,6 +4,7 @@ import { CheckBox } from './checkbox'
|
|
4
4
|
import { Icon } from './icon'
|
5
5
|
import { Text } from './text'
|
6
6
|
import './table.css'
|
7
|
+
import { FORMATS } from '../domain/ContentType'
|
7
8
|
|
8
9
|
const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
9
10
|
|
@@ -130,7 +131,7 @@ const DataTableRow = (props) => {
|
|
130
131
|
const DataTableCell = ({ row, column, cell, editable }) => {
|
131
132
|
|
132
133
|
const render = (type) => {
|
133
|
-
const { id, disabled = false, min, max, onChange, options } = column
|
134
|
+
const { id, disabled = false, min, max, onChange, format, options } = column
|
134
135
|
if (id === "checked") {
|
135
136
|
return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
136
137
|
} else if (editable && onChange) {
|
@@ -150,7 +151,7 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
150
151
|
switch (type) {
|
151
152
|
case "ICON": return <Icon icon={cell} />
|
152
153
|
case "Boolean": return <BooleanCellViewer id={id} value={cell} />
|
153
|
-
case "String": return <StringCellViewer id={id} value={cell} options={options} />
|
154
|
+
case "String": return <StringCellViewer id={id} value={cell} format={format} options={options} />
|
154
155
|
default: return cell
|
155
156
|
}
|
156
157
|
}
|
@@ -172,9 +173,12 @@ const BooleanCellViewer = ({ id, value = false }) => {
|
|
172
173
|
/**
|
173
174
|
* String Cell Viewer
|
174
175
|
*/
|
175
|
-
const StringCellViewer = ({ id, value, options }) => {
|
176
|
+
const StringCellViewer = ({ id, value, format, options }) => {
|
176
177
|
const option = options ? options.find(o => o.value === value) : null
|
177
|
-
|
178
|
+
let text = option ? option.label : value
|
179
|
+
switch (format) {
|
180
|
+
case FORMATS.DATE: text = new Date(text).toLocaleDateString(); break;
|
181
|
+
}
|
178
182
|
return (<div className="field-editor string-viewer">{text}</div>)
|
179
183
|
}
|
180
184
|
|