ywana-core8 0.0.341 → 0.0.344

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.341",
3
+ "version": "0.0.344",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -7,7 +7,7 @@ import { FORMATS } from './ContentType';
7
7
  /**
8
8
  * Content Editor
9
9
  */
10
- export const ContentEditor = ({ content, filter, onChange }) => {
10
+ export const ContentEditor = ({ content, filter, outlined = true, className, onChange }) => {
11
11
 
12
12
  function change(id, value) {
13
13
  const nextValue = Object.assign({}, content.value(), { [id]: value })
@@ -17,25 +17,24 @@ export const ContentEditor = ({ content, filter, onChange }) => {
17
17
  const sections = content.sections()
18
18
 
19
19
  return (
20
- <div className='content-editor'>
21
- {sections
22
- .map((section) => {
23
- const { title, fields } = section
24
-
25
- const filtered = fields
26
- .filter(field => field.id !== 'id')
27
- .filter(field => filter ? filter(field, content) : true)
28
-
29
- return filtered.length > 0 ? (
30
- <section key={title}>
31
- {title && title.length > 0 ? <header>{title}</header> : null}
32
- <main>
33
- {filtered.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={true} content={content} />)}
34
- </main>
35
- </section>
36
- ) : null
20
+ <div className={`content-editor ${className}`}>
21
+ {sections.map((section) => {
22
+
23
+ const { title, fields } = section
24
+ const filtered = fields
25
+ .filter(field => field.id !== 'id')
26
+ .filter(field => filter ? filter(field, content) : true)
27
+
28
+ return filtered.length > 0 ? (
29
+ <section key={title}>
30
+ {title && title.length > 0 ? <header>{title}</header> : null}
31
+ <main>
32
+ {filtered.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={outlined} content={content} />)}
33
+ </main>
34
+ </section>
35
+ ) : null
37
36
 
38
- })}
37
+ })}
39
38
  </div>
40
39
  )
41
40
  }
@@ -120,7 +119,6 @@ export const TabbedContentEditor = ({ content, filter, grouped = false, onChange
120
119
  */
121
120
  export const TreededContentEditor = ({ content, filter, onChange }) => {
122
121
 
123
-
124
122
  const value = content.value()
125
123
  const nodes = Object.values(content.type).filter(field => field.type === TYPES.ARRAY)
126
124
  const [selected, setSelected] = useState()
@@ -259,7 +257,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
259
257
  }
260
258
 
261
259
  return (
262
- <div className='field-editor string-editor'>
260
+ <div className={`field-editor string-editor ${id}`}>
263
261
  {renderFormat(format, options)}
264
262
  </div>
265
263
  )
@@ -0,0 +1,24 @@
1
+ .grid1 {
2
+ }
3
+
4
+ .grid1 > section > main {
5
+ display: grid;
6
+ grid-template-columns: auto auto auto;
7
+ gap: 0 1rem
8
+ }
9
+
10
+ .grid1 .name {
11
+ grid-column: span 2;
12
+ }
13
+
14
+ .grid1 .field1 {
15
+ grid-column: span 1;
16
+ }
17
+
18
+ .grid1 .field2 {
19
+ grid-column: span 1;
20
+ }
21
+
22
+ .grid1 .field3 {
23
+ grid-column: span 2;
24
+ }
@@ -0,0 +1,31 @@
1
+ import React, { useState } from 'react'
2
+ import { ContentEditor } from './ContentEditor'
3
+ import { Content, TYPES } from './ContentType'
4
+ import './ContentEditor.test.css'
5
+
6
+ const schema = {
7
+ name: { id: "name", type: TYPES.STRING, required: true, label: "Name" },
8
+ field1: { id: "field1", type: TYPES.STRING, required: true, label: "field1" },
9
+ field2: { id: "field2", type: TYPES.STRING, required: true, label: "field2" },
10
+ field3: { id: "field3", type: TYPES.STRING, required: true, label: "field3" },
11
+ }
12
+
13
+ const value = {
14
+ name: "John Smith"
15
+ }
16
+
17
+ const ContentEditorTest = (prop) => {
18
+
19
+ const [form, setForm] = useState(value)
20
+
21
+ function change(form) {
22
+ setForm(form)
23
+ }
24
+
25
+ const content = new Content(schema, form)
26
+ return (
27
+ <>
28
+ <ContentEditor content={content} outlined={true} onChange={change} className="grid1"/>
29
+ </>
30
+ )
31
+ }
@@ -140,7 +140,7 @@ export const TablePage = (props) => {
140
140
  {canQuery || canFilter ? (
141
141
  <menu className="table-page">
142
142
  {canQuery ? <TableQueries schema={schema} user={user} /> : null}
143
- {canFilter ? <TableFilters schema={schema} onSave={saveQuery} /> : null}
143
+ {canFilter ? <TableFilters schema={schema} onSave={canQuery ? saveQuery : null} /> : null}
144
144
  </menu>
145
145
  ) : null}
146
146
  <main key={id} className="table-page">