ywana-core8 0.0.72 → 0.0.76
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/dist/index.cjs +19 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +19 -22
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +19 -22
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/css/html.css +4 -0
- package/src/domain/ContentEditor.js +6 -12
- package/src/domain/ContentForm.js +0 -3
- package/src/domain/TablePage.js +10 -12
- package/src/html/textfield.js +1 -1
- package/src/site/site.js +2 -1
package/package.json
CHANGED
package/src/css/html.css
CHANGED
@@ -2,6 +2,7 @@ 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
3
|
import { Content, TYPES } from './ContentType';
|
4
4
|
import './ContentEditor.css';
|
5
|
+
import { FORMATS } from '.';
|
5
6
|
|
6
7
|
/**
|
7
8
|
* Content Editor
|
@@ -25,7 +26,7 @@ export const ContentEditor = ({ content, filter, onChange }) => {
|
|
25
26
|
{fields
|
26
27
|
.filter(field => field.id !== 'id')
|
27
28
|
.filter(field => filter ? filter(field, content) : true)
|
28
|
-
.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={true}/>)}
|
29
|
+
.map((field) => <FieldEditor key={field.id} field={field} onChange={change} outlined={true} />)}
|
29
30
|
</main>
|
30
31
|
</section>
|
31
32
|
)
|
@@ -177,8 +178,6 @@ export const FieldEditor = ({ field, onChange, content, outlined = false }) => {
|
|
177
178
|
return <StringEditor outlined={outlined} field={field} value={value1} onChange={change} content={content} />
|
178
179
|
case TYPES.BOOLEAN:
|
179
180
|
return <CheckBox outlined id={id} label={label} value={value1} onChange={change} />
|
180
|
-
case TYPES.DATE:
|
181
|
-
return <TextField outlined={outlined} id={id} type='date' label={label} value={value1} onChange={change} disabled={editable} />
|
182
181
|
case TYPES.NUMBER:
|
183
182
|
return <NumberEditor outlined={outlined} field={field} value={value1} onChange={change} />
|
184
183
|
case TYPES.ARRAY:
|
@@ -225,7 +224,7 @@ const EntityEditor = ({ field, value = {}, onChange }) => {
|
|
225
224
|
* String Editor
|
226
225
|
*/
|
227
226
|
export const StringEditor = ({ field, value = '', onChange, content, outlined }) => {
|
228
|
-
const { id, label, options, editable = true, filter } = field
|
227
|
+
const { id, format, label, options, editable = true, filter } = field
|
229
228
|
|
230
229
|
function change(id, value) {
|
231
230
|
if (onChange) onChange(id, value)
|
@@ -239,14 +238,9 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
|
|
239
238
|
return (
|
240
239
|
<div className='field-editor string-editor'>
|
241
240
|
{
|
242
|
-
editable
|
243
|
-
options ? (
|
244
|
-
<
|
245
|
-
) : (
|
246
|
-
<TextField outlined={outlined} id={id} label={label} value={value} onChange={change} />
|
247
|
-
) : (
|
248
|
-
<TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={true} />
|
249
|
-
)
|
241
|
+
format === FORMATS.DATE ? <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} /> :
|
242
|
+
options ? <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} /> :
|
243
|
+
<TextField outlined={outlined} id={id} label={label} value={value} onChange={change} readOnly={!editable} />
|
250
244
|
}
|
251
245
|
</div>
|
252
246
|
)
|
@@ -8,14 +8,11 @@ import { TextField, CheckBox, DropDown, Form } from '../html';
|
|
8
8
|
export const ContentForm = ({ content, columns = 1, filter, rules, onChange }) => {
|
9
9
|
|
10
10
|
const form = content.form()
|
11
|
-
console.log(form)
|
12
11
|
|
13
12
|
const fields = Object.keys(form)
|
14
13
|
.map(key => form[key])
|
15
14
|
.filter( field => filter ? filter(field) : true)
|
16
15
|
|
17
|
-
console.log(fields)
|
18
|
-
|
19
16
|
return (
|
20
17
|
<Form className="content-form" columns={columns} outlined={true} onChange={onChange}>
|
21
18
|
{ fields.map(field => <ContentFormField key={field.id} {...field} />)}
|
package/src/domain/TablePage.js
CHANGED
@@ -16,7 +16,7 @@ const http = HTTPClient(window.API || process.env.REACT_APP_API, Session);
|
|
16
16
|
export const TablePage = (props) => {
|
17
17
|
|
18
18
|
const site = useContext(SiteContext)
|
19
|
-
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canAdd = true, canDelete = true, dev = false, autosave = true, groupBy, validator, scenario, formFilter, tableFilter, tableActions } = props
|
19
|
+
const { id = "table", icon, title, name = "table 1", schema, url, field, delay = 1000, actions, editable, canFilter=false, canAdd = true, canDelete = true, dev = false, autosave = true, groupBy, validator, scenario, formFilter, tableFilter, tableActions } = props
|
20
20
|
const [pageContext, setPageContext] = useContext(PageContext)
|
21
21
|
const { selected } = pageContext
|
22
22
|
const timer = useRef(null)
|
@@ -46,7 +46,7 @@ export const TablePage = (props) => {
|
|
46
46
|
await pageContext.create(form);
|
47
47
|
setPageContext(Object.assign({}, pageContext))
|
48
48
|
}
|
49
|
-
site.openDialog(<CreateContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} filter={formFilter}/>);
|
49
|
+
site.openDialog(<CreateContentDialog label={`Crear ${name}`} type={schema} onOK={onOK} validator={validator} filter={formFilter} />);
|
50
50
|
}
|
51
51
|
|
52
52
|
function change(next) {
|
@@ -106,11 +106,9 @@ export const TablePage = (props) => {
|
|
106
106
|
) : null}
|
107
107
|
{actions}
|
108
108
|
</Header>
|
109
|
-
<menu className="table-page">
|
110
|
-
<TableFilters schema={schema} />
|
111
|
-
</menu>
|
109
|
+
{canFilter ? <menu className="table-page"><TableFilters schema={schema} /></menu> : null}
|
112
110
|
<main key={id} className="table-page">
|
113
|
-
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete}/>
|
111
|
+
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} />
|
114
112
|
</main>
|
115
113
|
{renderAside()}
|
116
114
|
</Fragment>
|
@@ -241,10 +239,10 @@ const TableEditor = (props) => {
|
|
241
239
|
}),
|
242
240
|
rows: groups[groupName]
|
243
241
|
.map(item => {
|
244
|
-
item.actions =
|
245
|
-
return action.filter ?
|
246
|
-
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item)
|
247
|
-
|
242
|
+
item.actions = actions ? actions.map(action => {
|
243
|
+
return action.filter ?
|
244
|
+
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} /> : null
|
245
|
+
: <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} />
|
248
246
|
}) : []
|
249
247
|
if (canDelete) item.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(item.id)} />)
|
250
248
|
return item
|
@@ -253,7 +251,7 @@ const TableEditor = (props) => {
|
|
253
251
|
|
254
252
|
table.columns.push({ id: "actions" })
|
255
253
|
const groupSize = groups[groupName].length
|
256
|
-
|
254
|
+
|
257
255
|
return (
|
258
256
|
<Fragment key={groupName}>
|
259
257
|
<Header title={groupName} >
|
@@ -372,7 +370,7 @@ const TableAPI = (url) => {
|
|
372
370
|
if (typeof (value) === 'boolean') {
|
373
371
|
return query.concat(`${key}=${value}&`)
|
374
372
|
} else if (Array.isArray(value)) {
|
375
|
-
const param = value.length === 0 ? '' : value.reduce((param,item) => {
|
373
|
+
const param = value.length === 0 ? '' : value.reduce((param, item) => {
|
376
374
|
param = param.concat(`${key}=${item}&`)
|
377
375
|
return param
|
378
376
|
}, "")
|
package/src/html/textfield.js
CHANGED
@@ -41,7 +41,7 @@ export const TextField = (props) => {
|
|
41
41
|
const labelTxt = <Text>{label}</Text>
|
42
42
|
return (
|
43
43
|
<div className={`${style}`} onClick={onClick}>
|
44
|
-
<input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} readOnly={readOnly}/>
|
44
|
+
<input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} readOnly={readOnly} onfocus="(this.type='date')" onfocusout="(this.type='text')"/>
|
45
45
|
<span className="bar"></span>
|
46
46
|
{ label ? <label>{labelTxt}</label> : null }
|
47
47
|
</div>
|
package/src/site/site.js
CHANGED
@@ -64,8 +64,9 @@ export const SiteProvider = ({ children, siteLang, siteDictionary, showConsole }
|
|
64
64
|
|
65
65
|
preview,
|
66
66
|
openPreview: (preview) => { setPreview(preview) },
|
67
|
-
closePreview: () => { setPreview(null) }
|
67
|
+
closePreview: () => { setPreview(null) },
|
68
68
|
|
69
|
+
confirm: (message) => window.confirm(message)
|
69
70
|
}
|
70
71
|
|
71
72
|
return (
|