ywana-core8 0.0.558 → 0.0.561

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.558",
3
+ "version": "0.0.561",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -71,7 +71,7 @@ export const CollectionPage = (props) => {
71
71
  {levels ? <CollectionTree icon={icon} levels={levels} onSelect={onSelect} sorter={sorter} searchBy={searchBy} /> : <CollectionList groupBy={groupBy} onSelect={onSelect} searchBy={searchBy} />}
72
72
  </menu>
73
73
  <main key={id} className={`collection-page ${className}`}>
74
- <CollectionEditor icon={icon} schema={schema} layout={editor} autosave={autosave} delay={delay} canDelete={canDelete} canEdit={canEdit} />
74
+ <CollectionEditor icon={icon} schema={schema} layout={editor} autosave={autosave} delay={delay} canDelete={canDelete} canEdit={canEdit} onReload={reload}/>
75
75
  {children ? <article>{children}</article> : null}
76
76
  </main>
77
77
  </Fragment>
@@ -283,7 +283,7 @@ export const CollectionTree = (props) => {
283
283
  const CollectionEditor = (props) => {
284
284
  const [pageContext, setPageContext] = useContext(PageContext)
285
285
  const { selected } = pageContext
286
- const { icon, schema, layout, autosave = false, delay = 1000, canDelete, canEdit } = props
286
+ const { icon, schema, layout, autosave = false, delay = 1000, canDelete, canEdit, onReload } = props
287
287
  const timer = useRef(null)
288
288
  const [form, setForm] = useState(selected)
289
289
 
@@ -328,9 +328,9 @@ const CollectionEditor = (props) => {
328
328
  function renderEditor() {
329
329
  const content = new Content(schema, form)
330
330
  switch (layout) {
331
- case 'TABBED': return <TabbedContentEditor {...props} content={content} onChange={change} />
332
- case 'TREEDED': return <TreededContentEditor {...props} content={content} onChange={change} />
333
- default: return <ContentEditor {...props} content={content} onChange={change} />
331
+ case 'TABBED': return <TabbedContentEditor {...props} content={content} onChange={change} onReload={reload}/>
332
+ case 'TREEDED': return <TreededContentEditor {...props} content={content} onChange={change} onReload={reload}/>
333
+ default: return <ContentEditor {...props} content={content} onChange={change} onReload={reload}/>
334
334
  }
335
335
  }
336
336
 
@@ -8,13 +8,17 @@ import './ContentEditor.css';
8
8
  /**
9
9
  * Content Editor
10
10
  */
11
- export const ContentEditor = ({ content, filter, outlined = true, className, onChange }) => {
11
+ export const ContentEditor = ({ content, filter, outlined = true, className, onChange, onReload }) => {
12
12
 
13
13
  function change(id, value) {
14
14
  const nextValue = Object.assign({}, content.value(), { [id]: value })
15
15
  if (onChange) onChange(nextValue)
16
16
  }
17
17
 
18
+ function reload() {
19
+ if (onReload) onReload()
20
+ }
21
+
18
22
  const sections = content.sections()
19
23
 
20
24
  return (
@@ -30,7 +34,7 @@ export const ContentEditor = ({ content, filter, outlined = true, className, onC
30
34
  <section key={title}>
31
35
  {title && title.length > 0 ? <header>{title}</header> : null}
32
36
  <main>
33
- {filtered.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={outlined} content={content} />)}
37
+ {filtered.map((field) => <FieldEditor key={field.id} field={field} onChange={change} onReload={reload} outlined={outlined} content={content} />)}
34
38
  </main>
35
39
  </section>
36
40
  ) : null
@@ -43,7 +47,7 @@ export const ContentEditor = ({ content, filter, outlined = true, className, onC
43
47
  /**
44
48
  * Tabbed Content Editor
45
49
  */
46
- export const TabbedContentEditor = ({ content, filter, grouped = false, onChange }) => {
50
+ export const TabbedContentEditor = ({ content, filter, grouped = false, onChange, onReload }) => {
47
51
 
48
52
  const [tab, setTab] = useState(0)
49
53
 
@@ -91,7 +95,7 @@ export const TabbedContentEditor = ({ content, filter, grouped = false, onChange
91
95
  group.fields
92
96
  .filter(field => field.id !== 'id')
93
97
  .filter(field => filter ? filter(field) : true)
94
- .map((field) => <FieldEditor key={field.id} field={field} onChange={change} content={content} />)
98
+ .map((field) => <FieldEditor key={field.id} field={field} onChange={change} content={content} onReload={onReload} />)
95
99
  }
96
100
  </Fragment>
97
101
  )
@@ -100,7 +104,7 @@ export const TabbedContentEditor = ({ content, filter, grouped = false, onChange
100
104
  fields
101
105
  .filter(field => field.id !== 'id')
102
106
  .filter(field => filter ? filter(field) : true)
103
- .map((field) => <FieldEditor key={field.id} field={field} onChange={change} content={content} />)
107
+ .map((field) => <FieldEditor key={field.id} field={field} onChange={change} content={content} onReload={onReload}/>)
104
108
  }
105
109
  </section>
106
110
  )
@@ -152,7 +156,7 @@ export const TreededContentEditor = ({ content, filter, onChange }) => {
152
156
  </Tree>
153
157
  </menu>
154
158
  <div>
155
- {selected ? <TabbedContentEditor content={selected.item} onChange={change} /> : "select"}
159
+ {selected ? <TabbedContentEditor content={selected.item} onChange={change} onReload={reload}/> : "select"}
156
160
  </div>
157
161
  </div>
158
162
  )
@@ -161,13 +165,17 @@ export const TreededContentEditor = ({ content, filter, onChange }) => {
161
165
  /**
162
166
  * FieldEditor
163
167
  */
164
- export const FieldEditor = ({ field, onChange, content, outlined = false }) => {
168
+ export const FieldEditor = ({ field, onChange, content, outlined = false, onReload }) => {
165
169
  const { id, type, item, label, editable, options, hidden = false } = field
166
170
 
167
171
  function change(id, value) {
168
172
  if (onChange) onChange(id, value)
169
173
  }
170
174
 
175
+ function reload() {
176
+ onReload()
177
+ }
178
+
171
179
  function renderField() {
172
180
  const value1 = field.value || field.value === "" ? field.value : field.default
173
181
  const isHidden = CHECK['isFunction'](hidden) ? hidden(field, value1) : hidden
@@ -186,7 +194,7 @@ export const FieldEditor = ({ field, onChange, content, outlined = false }) => {
186
194
  case TYPES.ARRAY:
187
195
  return item === TYPES.STRING ?
188
196
  options ? <MultiSelectionEditor content={content} field={field} value={value1} onChange={change} /> : <ListEditor field={field} value={value1} onChange={change} />
189
- : <CollectionEditor field={field} value={value1} onChange={change} />
197
+ : <CollectionEditor field={field} value={value1} onChange={change} onReload={reload}/>
190
198
  default:
191
199
  return <div>{label}</div>
192
200
  }
@@ -372,7 +380,7 @@ export const MultiSelectionEditor = ({ field, value = [], content, onChange }) =
372
380
  /**
373
381
  * Collection Editor
374
382
  */
375
- export const CollectionEditor = ({ field, value = [], onChange }) => {
383
+ export const CollectionEditor = ({ field, value = [], onChange, onReload }) => {
376
384
 
377
385
  const { id, item, label, Feeder, Renderer, Adder = true, editable = true } = field
378
386
 
@@ -398,6 +406,10 @@ export const CollectionEditor = ({ field, value = [], onChange }) => {
398
406
  }
399
407
  }
400
408
 
409
+ function reload() {
410
+ if (onReload) onReload()
411
+ }
412
+
401
413
  const columns = Object.values(item)
402
414
  .filter(field => field.column === true)
403
415
  .map((item) => ({ ...item, onChange: change }))
@@ -423,7 +435,7 @@ export const CollectionEditor = ({ field, value = [], onChange }) => {
423
435
 
424
436
  }
425
437
  <footer>
426
- {Feeder ? <Feeder onAdd={add} /> : null}
438
+ {Feeder ? <Feeder onAdd={add} onReload={reload} /> : null}
427
439
  {Adder ? <CollectionAdder item={item} onAdd={add} /> : null}
428
440
  </footer>
429
441
  </div>
package/src/html/table.js CHANGED
@@ -134,12 +134,11 @@ export const DataTable = (props) => {
134
134
  * DataTable Row
135
135
  */
136
136
  const DataTableRow = (props) => {
137
-
138
137
  const { index, row, columns = [], onSelect, editable, expanded = false } = props
139
138
  const { className } = row
140
139
  const [isInfoOpen, toggleInfo] = useState(expanded)
141
140
  const infoIcon = isInfoOpen ? 'expand_more' : 'expand_less'
142
- const style = expanded ? "expanded" : ""
141
+ const style = isInfoOpen ? "expanded" : ""
143
142
  return (
144
143
  <Fragment>
145
144
  <tr className={`${style} ${className}`} onClick={ev => onSelect(row, ev)}>