ywana-core8 0.0.602 → 0.0.605

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.602",
3
+ "version": "0.0.605",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
- import { Icon, Property } from '../html'
2
+ import { Icon, Property, TokenField } from '../html'
3
+ import { EmptyMessage } from '../widgets'
3
4
  import { Content, FORMATS, TYPES } from './ContentType'
4
5
  import './ContentViewer.css'
5
6
 
@@ -27,7 +28,7 @@ export const ContentViewer = (props) => {
27
28
  {title}
28
29
  </header>
29
30
  <main>
30
- {fields.map(field => <FieldViewer key={field.id} field={field} value={value[field.id]} />)}
31
+ { fields.length > 0 ? fields.map(field => <FieldViewer key={field.id} field={field} value={value[field.id]} />) : <EmptyMessage" text="..."/> }
31
32
  </main>
32
33
  </section>
33
34
  )
@@ -53,13 +54,13 @@ const FieldViewer = (props) => {
53
54
 
54
55
  switch (type) {
55
56
  case TYPES.BOOLEAN:
56
- return <Property label={label} value={value} />
57
+ return <BooleanViewer field={field} value={value} />
57
58
  case TYPES.STRING:
58
59
  return <StringViewer field={field} value={value} />
59
60
  case TYPES.ENTITY:
60
61
  return <EntityViewer field={field} value={value} />
61
62
  case TYPES.ARRAY:
62
- return <ArrayViewer label={label} item={item} value={value} />
63
+ return item === TYPES.STRING ? <ListViewer label={label} value={value} /> : <ArrayViewer label={label} item={item} value={value} />
63
64
  default:
64
65
  return <div>{label}</div>
65
66
  }
@@ -89,9 +90,11 @@ const EntityViewer = (props) => {
89
90
  /**
90
91
  * Boolean Viewer
91
92
  */
92
- const BooleanViewer = ({ id, value = false }) => {
93
+ const BooleanViewer = (props) => {
94
+ const { field, value } = props
95
+ const { label, options } = field
93
96
  const iconName = value === true ? "check_box" : "check_box_outline_blank"
94
- const icon <Icon icon={iconName} />
97
+ const icon = <Icon icon={iconName} />
95
98
  return <Property label={label} value={icon} options={options} />
96
99
  }
97
100
 
@@ -130,13 +133,27 @@ const ArrayViewer = (props) => {
130
133
  {columns.map(column => <th key={column}>{column}</th>)}
131
134
  </thead>
132
135
  <tbody>
133
- {value.map(v => (
136
+ {value.length >0 ? value.map(v => (
134
137
  <tr>
135
138
  {Object.keys(item).map(key => <td key={v[key]}>{v[key]}</td>)}
136
139
  </tr>
137
- ))}
140
+ )) : <EmptyMessage text="..."/>}
138
141
  </tbody>
139
142
  </table>
140
143
  </div>
141
144
  )
142
145
  }
146
+
147
+ /**
148
+ * List Viewer
149
+ */
150
+ export const ListViewer = ({ field, value = [] }) => {
151
+
152
+ const { label } = field
153
+
154
+ return (
155
+ <div className="list-editor">
156
+ <TokenField id={field.id} label={label} tokens={value} />
157
+ </div>
158
+ )
159
+ }
@@ -0,0 +1,14 @@
1
+ .empty {
2
+ width: 100%;
3
+ height: 100%;
4
+ flex: 1 1;
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: center;
8
+ align-items: center;
9
+ color: var(--text-color-lighter);
10
+ }
11
+
12
+ .empty i {
13
+ width: 4rem
14
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { Icon, Text } from '../../html'
3
+ import './EmptyMessage.css'
4
+
5
+ /**
6
+ * Empty Message
7
+ */
8
+ export const EmptyMessage = ({ icon, text }) => {
9
+
10
+ return (
11
+ <div className="empty">
12
+ <span><Icon icon={icon} /></span>
13
+ <br />
14
+ <Text use="subtitle2">{text}</Text>
15
+ </div>
16
+ )
17
+ }
@@ -7,4 +7,5 @@ export * from './waiter'
7
7
  export * from './calendar/Calendar'
8
8
  export * from './planner/Planner'
9
9
  export * from './upload'
10
- export * from './explorer/Explorer'
10
+ export * from './explorer/Explorer'
11
+ export * from './empty/EmptyMessage'