ywana-core8 0.0.16 → 0.0.20

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.16",
3
+ "version": "0.0.20",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
package/publish.sh CHANGED
@@ -1,3 +1,4 @@
1
+ npm run build
1
2
  git add --all
2
3
  git commit -m $0
3
4
  git push
@@ -5,7 +5,7 @@ import { PageContext } from '../site'
5
5
  import { Button, Header, Icon, List, Menu, MenuIcon, MenuItem, Text, Tree, TreeItem, TreeNode } from '../html'
6
6
  import { Content } from './ContentType'
7
7
  import { ContentEditor, TabbedContentEditor, TreededContentEditor } from './ContentEditor'
8
- import { EditContentDialog } from './EditContentDialog'
8
+ import { CreateContentDialog } from './CreateContentDialog_old'
9
9
  import { SiteContext } from '../site/siteContext'
10
10
  import "./CollectionPage.css"
11
11
 
@@ -37,7 +37,7 @@ export const CollectionPage = (props) => {
37
37
  await pageContext.create(form);
38
38
  setPageContext(Object.assign({}, pageContext))
39
39
  }
40
- site.openDialog(<EditContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} />);
40
+ site.openDialog(<CreateContentDialog label={`${name}`} type={schema} onOK={onOK} />);
41
41
  }
42
42
 
43
43
  return (
@@ -1,59 +1,55 @@
1
- import React, { Fragment, useContext, useMemo, useState } from 'react';
2
- import { Button, Text } from '../html';
3
- import { Dialog } from '../site/dialog'
4
- import { SiteContext } from '../site/siteContext';
5
- import { ContentForm } from './ContentForm';
6
- import { Content } from './ContentType';
1
+ import React, { Fragment, useState, useContext, useMemo } from 'react';
2
+ import { Dialog } from '../site'
3
+ import { SiteContext } from '../site/siteContext'
4
+ import { Text, Button } from '../html';
5
+ import { Content } from './ContentType'
6
+ import { ContentEditor } from './ContentEditor'
7
7
 
8
8
  /**
9
9
  * Create Content Dialog
10
10
  */
11
- export const CreateContentDialog = ({ label, type, validator, onOK, onError, onActionClose = true }) => {
11
+ export const CreateContentDialog = ({ label, type, value = {}, filter, validator, onOK, onError }) => {
12
12
 
13
13
  const site = useContext(SiteContext);
14
- const [form, setForm] = useState({})
14
+ const [form, setForm] = useState(value)
15
15
  const [isValid, setValid] = useState(false)
16
16
  const [errors, setErrors] = useState([])
17
17
 
18
- function change(form, validForm) {
18
+ function change(form) {
19
19
  setForm(form)
20
20
  if (validator) {
21
21
  const { validation, errors = [] } = validator(form)
22
- setValid(validForm && validation)
23
- setErrors(errors)
22
+ setValid(validation)
23
+ setErrors(errors)
24
24
  } else {
25
- setValid(validForm)
25
+ setValid(true)
26
26
  }
27
27
  }
28
-
28
+
29
29
  function onAction(action) {
30
- if (action === 'OK' && onOK) onOK(form)
31
- if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
32
- }
33
-
34
- function isRequired(field) {
35
- const { required = false } = field
36
- return required
30
+ if (action === 'OK' && onOK) onOK(Object.assign({}, value, form))
31
+ site.closeDialog();
37
32
  }
38
33
 
39
- function isOptional(field) {
40
- const { creation = false } = field
41
- return creation
34
+ function createFilter(field, content) {
35
+ return field.required === true || field.optional === true
36
+ // TODO: execute props.filter
42
37
  }
43
-
38
+
44
39
  const actions = (
45
40
  <Fragment>
46
- <Button label="CLOSE" action={() => onAction("CLOSE")}/>
41
+ <Button label="CLOSE" action={() => onAction("CLOSE")} />
42
+ <div className="expand" />
47
43
  <Button label="OK" action={() => onAction("OK")} disabled={!isValid} raised />
48
44
  </Fragment>
49
45
  )
50
-
51
- const title = <Text use="headline6">{label}</Text>
52
- const content = new Content(type, form)
46
+
47
+ const title = <Text use="headline6">{label}</Text>
48
+ const content = new Content(type, form)
53
49
  return (
54
50
  <Dialog title={title} open={true} onAction={onAction} actions={actions}>
55
- <ContentForm content={content} filter={(field) => isRequired(field) || isOptional(field)} onChange={change} />
56
- { errors.map ( error => <Text use="overline" tag="div" className="error">{error}</Text> )}
51
+ <ContentEditor content={content} onChange={change} filter={createFilter} />
52
+ {errors.map(error => <Text use="overline" tag="div" className="error">{error}</Text>)}
57
53
  </Dialog>
58
54
  )
59
55
  }
@@ -0,0 +1,59 @@
1
+ import React, { Fragment, useContext, useMemo, useState } from 'react';
2
+ import { Button, Text } from '../html';
3
+ import { Dialog } from '../site/dialog'
4
+ import { SiteContext } from '../site/siteContext';
5
+ import { ContentForm } from './ContentForm';
6
+ import { Content } from './ContentType';
7
+
8
+ /**
9
+ * Create Content Dialog
10
+ */
11
+ export const CreateContentDialog = ({ label, type, validator, onOK, onError, onActionClose = true }) => {
12
+
13
+ const site = useContext(SiteContext);
14
+ const [form, setForm] = useState({})
15
+ const [isValid, setValid] = useState(false)
16
+ const [errors, setErrors] = useState([])
17
+
18
+ function change(form, validForm) {
19
+ setForm(form)
20
+ if (validator) {
21
+ const { validation, errors = [] } = validator(form)
22
+ setValid(validForm && validation)
23
+ setErrors(errors)
24
+ } else {
25
+ setValid(validForm)
26
+ }
27
+ }
28
+
29
+ function onAction(action) {
30
+ if (action === 'OK' && onOK) onOK(form)
31
+ if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
32
+ }
33
+
34
+ function isRequired(field) {
35
+ const { required = false } = field
36
+ return required
37
+ }
38
+
39
+ function isOptional(field) {
40
+ const { creation = false } = field
41
+ return creation
42
+ }
43
+
44
+ const actions = (
45
+ <Fragment>
46
+ <Button label="CLOSE" action={() => onAction("CLOSE")}/>
47
+ <Button label="OK" action={() => onAction("OK")} disabled={!isValid} raised />
48
+ </Fragment>
49
+ )
50
+
51
+ const title = <Text use="headline6">{label}</Text>
52
+ const content = new Content(type, form)
53
+ return (
54
+ <Dialog title={title} open={true} onAction={onAction} actions={actions}>
55
+ <ContentForm content={content} filter={(field) => isRequired(field) || isOptional(field)} onChange={change} />
56
+ { errors.map ( error => <Text use="overline" tag="div" className="error">{error}</Text> )}
57
+ </Dialog>
58
+ )
59
+ }
@@ -2,8 +2,6 @@ import equal from 'deep-equal'
2
2
  import React, { Fragment, useContext, useEffect, useMemo, useRef, useState } from 'react'
3
3
  import { EditContentDialog } from '.'
4
4
  import { Content, ContentEditor, HTTPClient, PageContext, Session, SiteContext } from '..'
5
- import { SCENARIO1 } from '../../dev/scenario1'
6
- import { BuildGroupOptions } from '../../pages/kinds/options'
7
5
  import { Button, DataTable, DropDown, Header, Icon, MenuIcon, MenuItem, Text } from '../html'
8
6
  import "./TablePage.css"
9
7
 
@@ -15,7 +13,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
15
13
  export const TablePage = (props) => {
16
14
 
17
15
  const site = useContext(SiteContext)
18
- const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = true, autosave = true, groupBy, validator, scenario } = props
16
+ const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, dev = false, autosave = true, groupBy, validator, scenario } = props
19
17
  const [pageContext, setPageContext] = useContext(PageContext)
20
18
  const { selected } = pageContext
21
19
  const timer = useRef(null)
@@ -66,7 +64,7 @@ export const TablePage = (props) => {
66
64
  async function playScenario() {
67
65
  const promises1 = pageContext.all.map(async item => await pageContext.remove(item.id))
68
66
  Promise.all(promises1).then(async () => {
69
- const promises2 = SCENARIO1.map(async (item) => await pageContext.create(item))
67
+ const promises2 = scenario.map(async (item) => await pageContext.create(item))
70
68
  Promise.all(promises2).then(async () => {
71
69
  await pageContext.load()
72
70
  setPageContext(Object.assign({}, pageContext))
@@ -266,10 +264,16 @@ const TableEditor = (props) => {
266
264
 
267
265
  table.columns.push({ id: "actions" })
268
266
 
267
+ function buildGroupOptions(schema) {
268
+ return Object.values(schema)
269
+ .filter(field => field.grouper === true)
270
+ .map(field => ({ label: field.label, value: field.id }))
271
+ }
272
+
269
273
  return (
270
274
  <Fragment>
271
275
  <Header icon={icon} title={<Text>{title}</Text>}>
272
- <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={BuildGroupOptions(schema)} onChange={changeGroup} />
276
+ <DropDown id="groupBy" label="Agrupar Por" value={groupBy} options={buildGroupOptions(schema)} onChange={changeGroup} />
273
277
  </Header>
274
278
  <main className="table-editor">
275
279
  {renderGroups()}
@@ -4,3 +4,4 @@ export { ContentEditor, TabbedContentEditor, CollectionEditor, TreededContentEdi
4
4
  export { CreateContentDialog } from './CreateContentDialog'
5
5
  export { EditContentDialog } from './EditContentDialog'
6
6
  export { CollectionPage, CollectionContext } from './CollectionPage'
7
+ export { TablePage } from './TablePage'
package/src/css/fonts.css DELETED
@@ -1,162 +0,0 @@
1
- /* hebrew */
2
- @font-face {
3
- font-family: 'Assistant';
4
- font-style: normal;
5
- font-weight: 200;
6
- font-display: swap;
7
- src: url(../fonts/Assistant-ExtraLight.ttf) format('woff2');
8
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
9
- }
10
- /* latin-ext */
11
- @font-face {
12
- font-family: 'Assistant';
13
- font-style: normal;
14
- font-weight: 200;
15
- font-display: swap;
16
- src: url(../fonts/Assistant-ExtraLight.ttf) format('woff2');
17
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
18
- }
19
- /* latin */
20
- @font-face {
21
- font-family: 'Assistant';
22
- font-style: normal;
23
- font-weight: 200;
24
- font-display: swap;
25
- src: url(../fonts/Assistant-ExtraLight.ttf) format('woff2');
26
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
27
- }
28
- /* hebrew */
29
- @font-face {
30
- font-family: 'Assistant';
31
- font-style: normal;
32
- font-weight: 300;
33
- font-display: swap;
34
- src: url(../fonts/Assistant-Light.ttf) format('woff2');
35
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
36
- }
37
- /* latin-ext */
38
- @font-face {
39
- font-family: 'Assistant';
40
- font-style: normal;
41
- font-weight: 300;
42
- font-display: swap;
43
- src: url(../fonts/Assistant-Light.ttf) format('woff2');
44
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
45
- }
46
- /* latin */
47
- @font-face {
48
- font-family: 'Assistant';
49
- font-style: normal;
50
- font-weight: 300;
51
- font-display: swap;
52
- src: url(../fonts/Assistant-Light.ttf) format('woff2');
53
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
54
- }
55
- /* hebrew */
56
- @font-face {
57
- font-family: 'Assistant';
58
- font-style: normal;
59
- font-weight: 400;
60
- font-display: swap;
61
- src: url(../fonts/Assistant-Medium.ttf) format('woff2');
62
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
63
- }
64
- /* latin-ext */
65
- @font-face {
66
- font-family: 'Assistant';
67
- font-style: normal;
68
- font-weight: 400;
69
- font-display: swap;
70
- src: url(../fonts/Assistant-Medium.ttf) format('woff2');
71
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
72
- }
73
- /* latin */
74
- @font-face {
75
- font-family: 'Assistant';
76
- font-style: normal;
77
- font-weight: 400;
78
- font-display: swap;
79
- src: url(../fonts/Assistant-Medium.ttf) format('woff2');
80
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
81
- }
82
- /* hebrew */
83
- @font-face {
84
- font-family: 'Assistant';
85
- font-style: normal;
86
- font-weight: 500;
87
- font-display: swap;
88
- src: url(../fonts/Assistant-SemiBold.ttf) format('woff2');
89
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
90
- }
91
- /* latin-ext */
92
- @font-face {
93
- font-family: 'Assistant';
94
- font-style: normal;
95
- font-weight: 500;
96
- font-display: swap;
97
- src: url(../fonts/Assistant-SemiBold.ttf) format('woff2');
98
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
99
- }
100
- /* latin */
101
- @font-face {
102
- font-family: 'Assistant';
103
- font-style: normal;
104
- font-weight: 500;
105
- font-display: swap;
106
- src: url(../fonts/Assistant-SemiBold.ttf) format('woff2');
107
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
108
- }
109
- /* hebrew */
110
- @font-face {
111
- font-family: 'Assistant';
112
- font-style: normal;
113
- font-weight: 600;
114
- font-display: swap;
115
- src: url(../fonts/Assistant-Bold.ttf) format('woff2');
116
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
117
- }
118
- /* latin-ext */
119
- @font-face {
120
- font-family: 'Assistant';
121
- font-style: normal;
122
- font-weight: 600;
123
- font-display: swap;
124
- src: url(../fonts/Assistant-Bold.ttf) format('woff2');
125
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
126
- }
127
- /* latin */
128
- @font-face {
129
- font-family: 'Assistant';
130
- font-style: normal;
131
- font-weight: 600;
132
- font-display: swap;
133
- src: url(../fonts/Assistant-Bold.ttf) format('woff2');
134
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
135
- }
136
- /* hebrew */
137
- @font-face {
138
- font-family: 'Assistant';
139
- font-style: normal;
140
- font-weight: 700;
141
- font-display: swap;
142
- src: url(../fonts/Assistant-ExtraBold.ttf) format('woff2');
143
- unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
144
- }
145
- /* latin-ext */
146
- @font-face {
147
- font-family: 'Assistant';
148
- font-style: normal;
149
- font-weight: 700;
150
- font-display: swap;
151
- src: url(../fonts/Assistant-ExtraBold.ttf) format('woff2');
152
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
153
- }
154
- /* latin */
155
- @font-face {
156
- font-family: 'Assistant';
157
- font-style: normal;
158
- font-weight: 700;
159
- font-display: swap;
160
- src: url(../fonts/Assistant-ExtraBold.ttf) format('woff2');
161
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
162
- }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file