ywana-core8 0.0.157 → 0.0.161

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.157",
3
+ "version": "0.0.161",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import React, { Fragment, useState } from 'react';
2
2
  import { Button, CheckBox, DataTable, DropDown, Icon, Stack, Tab, Tabs, Text, TextField, Tree, TreeNode, TreeItem, TokenField, Property } from '../html';
3
- import { Content, TYPES } from './ContentType';
3
+ import { CHECK, Content, TYPES } from './ContentType';
4
4
  import './ContentEditor.css';
5
5
  import { FORMATS } from './ContentType';
6
6
 
@@ -28,7 +28,7 @@ export const ContentEditor = ({ content, filter, onChange }) => {
28
28
 
29
29
  return filtered.length > 0 ? (
30
30
  <section key={title}>
31
- { title && title.length > 0 ? <header>{title}</header> : null }
31
+ {title && title.length > 0 ? <header>{title}</header> : null}
32
32
  <main>
33
33
  {filtered.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={true} />)}
34
34
  </main>
@@ -168,7 +168,7 @@ export const TreededContentEditor = ({ content, filter, onChange }) => {
168
168
  * FieldEditor
169
169
  */
170
170
  export const FieldEditor = ({ field, onChange, content, outlined = false }) => {
171
- const { id, type, item, label, editable, options } = field
171
+ const { id, type, item, label, editable, options, hidden = false } = field
172
172
 
173
173
  function change(id, value) {
174
174
  if (onChange) onChange(id, value)
@@ -176,21 +176,26 @@ export const FieldEditor = ({ field, onChange, content, outlined = false }) => {
176
176
 
177
177
  function renderField() {
178
178
  const value1 = field.value ? field.value : field.default
179
- switch (type) {
180
- case TYPES.ENTITY:
181
- return <EntityEditor field={field} value={value1} onChange={change} />
182
- case TYPES.STRING:
183
- return <StringEditor outlined={outlined} field={field} value={value1} onChange={change} content={content} />
184
- case TYPES.BOOLEAN:
185
- return <CheckBox outlined id={id} label={label} value={value1} onChange={change} />
186
- case TYPES.NUMBER:
187
- return <NumberEditor outlined={outlined} field={field} value={value1} onChange={change} />
188
- case TYPES.ARRAY:
189
- return item === TYPES.STRING ?
190
- options ? <MultiSelectionEditor content={content} field={field} value={value1} onChange={change} /> : <ListEditor field={field} value={value1} onChange={change} />
191
- : <CollectionEditor field={field} value={value1} onChange={change} />
192
- default:
193
- return <div>{label}</div>
179
+ const isHidden = CHECK['isFunction'](hidden) ? hidden(field, value1) : hidden
180
+ if (isHidden) {
181
+ return null
182
+ } else {
183
+ switch (type) {
184
+ case TYPES.ENTITY:
185
+ return <EntityEditor field={field} value={value1} onChange={change} />
186
+ case TYPES.STRING:
187
+ return <StringEditor outlined={outlined} field={field} value={value1} onChange={change} content={content} />
188
+ case TYPES.BOOLEAN:
189
+ return <CheckBox outlined id={id} label={label} value={value1} onChange={change} />
190
+ case TYPES.NUMBER:
191
+ return <NumberEditor outlined={outlined} field={field} value={value1} onChange={change} />
192
+ case TYPES.ARRAY:
193
+ return item === TYPES.STRING ?
194
+ options ? <MultiSelectionEditor content={content} field={field} value={value1} onChange={change} /> : <ListEditor field={field} value={value1} onChange={change} />
195
+ : <CollectionEditor field={field} value={value1} onChange={change} />
196
+ default:
197
+ return <div>{label}</div>
198
+ }
194
199
  }
195
200
  }
196
201
  return renderField()
@@ -229,7 +234,7 @@ const EntityEditor = ({ field, value = {}, onChange }) => {
229
234
  * String Editor
230
235
  */
231
236
  export const StringEditor = ({ field, value = '', onChange, content, outlined }) => {
232
- const { id, format, label, options, editable = true } = field
237
+ const { id, format, label, options, editable = true, predictive = false } = field
233
238
 
234
239
  function change(id, value) {
235
240
  if (onChange) onChange(id, value)
@@ -244,7 +249,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
244
249
  <div className='field-editor string-editor'>
245
250
  {
246
251
  format === FORMATS.DATE ? <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} /> :
247
- options ? <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} canFilter={false}/> :
252
+ options ? <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} canFilter={predictive} /> :
248
253
  <TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={!editable} />
249
254
  }
250
255
  </div>
@@ -161,7 +161,10 @@ const TableSelector = (props) => {
161
161
  rows: rows || []
162
162
  }
163
163
  const buttons = actions.map(({ label, action }) => {
164
- return <Button label={label} raised action={() => action(checked)} />
164
+ return <Button label={label} raised action={() => action(checked, pageContext, async () => {
165
+ await pageContext.load()
166
+ setPageContext(Object.assign({}, pageContext))
167
+ })} />
165
168
  })
166
169
 
167
170
  return (