ywana-core8 0.0.571 → 0.0.574

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.
@@ -0,0 +1,33 @@
1
+ import { FORMATS } from "./FORMATS";
2
+
3
+ /**
4
+ * Content
5
+ */
6
+ class Content {
7
+
8
+ constructor(schema, value) {
9
+ this.schema = schema;
10
+ this.value = value;
11
+ }
12
+
13
+ }
14
+
15
+ const ADDRESS_SCHEMA = {
16
+ id : { type: TYPES.STRING },
17
+ street : { type: TYPES.STRING, default: '' },
18
+ city : { type: TYPES.STRING, default: '' },
19
+ state : { type: TYPES.STRING, default: '' },
20
+ zip : { type: TYPES.STRING, default: '' },
21
+ country: { type: TYPES.STRING, default: '' },
22
+ }
23
+
24
+ const PERSON_SCHEMA = {
25
+ id : { type: TYPES.STRING },
26
+ name : { type: TYPES.STRING , format: FORMATS.NONE, label: 'Name' },
27
+ address : { type: TYPES.ENTITY, item: ADDRESS_SCHEMA, format: FORMATS.NONE, label: 'Address' },
28
+ age : { type: TYPES.NUMBER , format: FORMATS.NONE, label: 'Age' , default: 0 },
29
+ married : { type: TYPES.BOOLEAN , format: FORMATS.NONE, label: 'Married' , default: false },
30
+ children: { type: TYPES.ARRAY , item: TYPES.STRING , format: FORMATS.NONE, label: 'Children', default: [] },
31
+ }
32
+
33
+ const person = new Content(PERSON_SCHEMA, {})
@@ -0,0 +1,74 @@
1
+ export const ContentFilters = (props) => {
2
+
3
+ const [pageContext, setPageContext] = useContext(PageContext)
4
+ const { filters } = pageContext
5
+ const { schema, onSave } = props
6
+ const [form, setForm] = useState({})
7
+
8
+ const filterSchema = useMemo(() => {
9
+ const filterSchema = Object.assign({}, schema)
10
+ for (var key in filterSchema) {
11
+ if (filterSchema[key].filter === false) {
12
+ delete filterSchema[key]
13
+ } else {
14
+ if (filterSchema[key].type === TYPES.ENTITY) {
15
+ const fs = filterSchema[key].item
16
+ for (var key in fs) {
17
+ if (fs[key].filter === false) delete fs[key]
18
+ }
19
+ }
20
+ }
21
+ }
22
+ //Object.values(filterSchema).forEach(field => field.section = null)
23
+ delete filterSchema.flows
24
+ return filterSchema
25
+ }, [schema])
26
+
27
+ const likes = useMemo(() => {
28
+ const fields = Object.values(schema)
29
+ return fields.reduce((likes, field) => {
30
+ if (field.like === true) likes.push(field.id)
31
+ return likes
32
+ }, [])
33
+ }, [schema])
34
+
35
+ useEffect(() => {
36
+ if (filters) setForm(filters)
37
+ }, [filters])
38
+
39
+ useEffect(() => {
40
+ reload()
41
+ }, [form])
42
+
43
+ async function change(next) {
44
+ setForm(next)
45
+ }
46
+
47
+ async function reload() {
48
+ await pageContext.load(form, likes)
49
+ setPageContext(Object.assign({}, pageContext))
50
+ }
51
+
52
+ function clear() {
53
+ change({})
54
+ }
55
+
56
+ function save() {
57
+ if (onSave) {
58
+ onSave(form)
59
+ }
60
+ }
61
+
62
+ const content = new Content(filterSchema, form)
63
+ return (
64
+ <Fragment>
65
+ <Header className="table-filters" title={<Text>Filters</Text>} >
66
+ <Icon icon="filter_list_off" size="small" clickable action={clear} />
67
+ {onSave ? <Icon icon="save" size="small" clickable action={save} /> : null}
68
+ </Header>
69
+ <main className="table-filters">
70
+ <ContentEditor content={content} onChange={change} />
71
+ </main>
72
+ </Fragment>
73
+ )
74
+ }
@@ -0,0 +1,96 @@
1
+ export const ContentPage = (props) => {
2
+
3
+ const {
4
+ icon, title, className,
5
+ schema, url,
6
+ } = props
7
+
8
+ return (
9
+ <>
10
+ <header className="content-page"></header>
11
+ <nav className="content-page"></nav>
12
+ <menu className="content-page">
13
+
14
+ </menu>
15
+ <main className="content-page">
16
+
17
+ </main>
18
+ <aside className="content-page"></aside>
19
+ <footer className="content-page"></footer>
20
+ </>
21
+ )
22
+ }
23
+
24
+
25
+
26
+ /**
27
+ * Content API
28
+ */
29
+ const ContentAPI = (url, host) => {
30
+
31
+ const http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
32
+
33
+ return {
34
+ all(filters = [], likes = [], page) {
35
+ let queryParams = page ? `?page=${page}&` : "?"
36
+ const filterQuery = Object.keys(filters).reduce((query, key) => {
37
+ const value = filters[key]
38
+ if (typeof (value) === 'boolean') return query.concat(`${key}=${value}&`)
39
+ if (Array.isArray(value)) {
40
+ const param = value.length === 0 ? '' : value.reduce((param, item) => {
41
+ param = param.concat(`${key}=${item}&`)
42
+ return param
43
+ }, "")
44
+ return query.concat(param)
45
+ }
46
+ const likeSymbol = likes.includes(key) ? '%' : ''
47
+ return query.concat(`${key}=${likeSymbol}${value}${likeSymbol}&`)
48
+ }, "")
49
+ queryParams = queryParams.concat(filterQuery)
50
+ return http.GET(url + queryParams)
51
+ },
52
+
53
+ find(id) {
54
+ return http.GET(`${url}/${id}`)
55
+ },
56
+
57
+ create(form) {
58
+ const body = JSON.stringify(form)
59
+ return http.POST(url, body)
60
+ },
61
+
62
+ update(form) {
63
+ const body = JSON.stringify(form)
64
+ return http.PUT(`${url}/${form.id}`, body)
65
+ },
66
+
67
+ updateProperty(id, propertyName, form) {
68
+ const body = JSON.stringify(form)
69
+ return http.PUT(`${url}/${id}/${propertyName}`, body)
70
+ },
71
+
72
+ patch(id, form) {
73
+ const body = JSON.stringify(form)
74
+ return http.PATCH(`${url}/${id}`, body)
75
+ },
76
+
77
+ remove(id) {
78
+ return http.DELETE(`${url}/${id}`)
79
+ },
80
+
81
+ queries(user) {
82
+ const queryParams = user ? `?user=${user}` : ""
83
+ return http.GET(`/queries/${url}${queryParams}`)
84
+ },
85
+
86
+ createQuery(form) {
87
+ const body = JSON.stringify(form)
88
+ return http.POST(`/queries/${url}`, body)
89
+ },
90
+
91
+ removeQuery(id) {
92
+ return http.DELETE(`/queries/${url}/${id}`)
93
+ },
94
+
95
+ }
96
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * FORMATS
3
+ */
4
+ export const FORMATS = {
5
+ NONE: '',
6
+ DATE: 'date',
7
+ DATERANGE: 'DATERANGE',
8
+ TIME: 'time',
9
+ EMAIL: 'email',
10
+ HTML: 'HTML',
11
+ URL: 'URL',
12
+ IMG: 'IMG',
13
+ COLOR: 'COLOR',
14
+ TOKENS: 'TOKENS'
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * TYPES
3
+ */
4
+ export const TYPES = {
5
+ STRING: 'String',
6
+ NUMBER: 'Number',
7
+ BOOLEAN: 'Boolean',
8
+ ARRAY: 'Array',
9
+ ENTITY: 'Object',
10
+ FUNCTION: 'Function',
11
+ }
@@ -0,0 +1,36 @@
1
+ .accordion {
2
+ display: flex;
3
+ flex-direction: column;
4
+ overflow: auto;
5
+ }
6
+
7
+ .accordion-section {
8
+ }
9
+
10
+ .accordion-section>header {
11
+ display: flex;
12
+ align-items: center;
13
+ }
14
+
15
+ .accordion-section>main {
16
+ }
17
+
18
+ .accordion-section--title {
19
+ flex: 1;
20
+ }
21
+
22
+ .accordion-section--subtitle {
23
+ }
24
+
25
+ .accordion-section--toolbar {
26
+ display: flex;
27
+ align-items: center;
28
+ padding: 0 1rem;
29
+ }
30
+
31
+ .accordion-section--info {
32
+ flex: 1;
33
+ display: flex;
34
+ justify-content: flex-end;
35
+ align-items: center;
36
+ }
@@ -0,0 +1,58 @@
1
+ import React, {useState} from 'react'
2
+ import { Icon } from './icon'
3
+ import './accordion.css'
4
+
5
+ export const Accordion = (props) => {
6
+
7
+ const { className, sections = [], onCheck } = props
8
+
9
+ const [openSections, setOpenSections] = useState(sections.map(section => section.open))
10
+ const [checkedSections, setCheckedSections] = useState(sections.map(section => section.checked))
11
+
12
+ function toggle(index) {
13
+ const next = openSections.map((open, i) => i === index ? !open : open)
14
+ setOpenSections(next)
15
+ }
16
+
17
+ function check(index) {
18
+ const next = checkedSections.map((checked, i) => i === index ? !checked : checked)
19
+ setCheckedSections(next)
20
+ if (onCheck) onCheck(index, next[index], sections[index].id)
21
+ }
22
+
23
+ return (
24
+ <div className={`accordion ${className}`}>
25
+ {sections.map((section, index) => {
26
+ const isOpen = openSections[index]
27
+ const isChecked = checkedSections[index]
28
+ return (
29
+ <AccordionSection key={index} {...section} open={isOpen} checked={isChecked} onToggle={() => toggle(index)} onCheck={() => check(index)}>
30
+ {section.children}
31
+ </AccordionSection>
32
+ )
33
+ })}
34
+ </div>
35
+ )
36
+ }
37
+
38
+ const AccordionSection = (props) => {
39
+
40
+ const { checked, icon, title, subtitle, open = false, onToggle, onCheck, toolbar, info, children } = props
41
+ const togglerIcon = open ? "expand_less" : "expand_more"
42
+ const checkedIcon = checked === undefined || checked === null ? null : checked === false ? "check_box_outline_blank" : "check_box"
43
+
44
+ return (
45
+ <section className={`accordion-section`}>
46
+ <header>
47
+ { checkedIcon ? <Icon className="accordion-section-checker" icon={checkedIcon} clickable action={onCheck}/> : '' }
48
+ { icon ? <Icon className="accordion-section-icon" icon={icon} /> : '' }
49
+ { title ? <div className="accordion-section--title">{title}</div> : '' }
50
+ { subtitle ? <div className="accordion-section--subtitle">{subtitle}</div> : '' }
51
+ { info ? <div className="accordion-section--info">{info}</div> : '' }
52
+ { toolbar ? <div className="accordion-section--toolbar">{toolbar}</div> : '' }
53
+ <Icon className="accordion-section-toggler" icon={togglerIcon} clickable action={onToggle} />
54
+ </header>
55
+ {open ? <main>{children}</main> : ''}
56
+ </section>
57
+ )
58
+ }
@@ -0,0 +1,37 @@
1
+ import React, { useState } from 'react'
2
+ import { Accordion } from './accordion'
3
+ import { Icon } from './icon'
4
+
5
+ const AccordionTest = (prop) => {
6
+
7
+ const info = <div>50 Unidades</div>
8
+
9
+ const toolbar = [<Icon icon="edit" size="small" clickable />, <Icon icon="delete" size="small" clickable />]
10
+
11
+ const sections = [
12
+ { id: 1 , checked: false, icon: 'star', title: 'Section 1' , subtitle: 'Subtitle 1' , info, toolbar, open: true , children: <div>Section 1 content</div> },
13
+ { id: 2 , checked: false, icon: 'star', title: 'Section 2' , subtitle: 'Subtitle 2' , info, toolbar, open: true , children: <div>Section 2 content</div> },
14
+ { id: 3 , checked: false, icon: 'star', title: 'Section 3' , subtitle: 'Subtitle 3' , info, toolbar, open: false, children: <div>Section 3 content</div> },
15
+ { id: 4 , checked: false, icon: 'star', title: 'Section 4' , subtitle: 'Subtitle 4' , info, toolbar, open: false, children: <div>Section 4 content</div> },
16
+ { id: 5 , checked: false, icon: 'star', title: 'Section 5' , subtitle: 'Subtitle 5' , info, toolbar, open: false, children: <div>Section 5 content</div> },
17
+ { id: 6 , checked: false, icon: 'star', title: 'Section 6' , subtitle: 'Subtitle 6' , info, toolbar, open: false, children: <div>Section 6 content</div> },
18
+ { id: 7 , checked: false, icon: 'star', title: 'Section 7' , subtitle: 'Subtitle 7' , info, toolbar, open: false, children: <div>Section 7 content</div> },
19
+ { id: 8 , checked: false, icon: 'star', title: 'Section 8' , subtitle: 'Subtitle 8' , info, toolbar, open: false, children: <div>Section 8 content</div> },
20
+ { id: 9 , checked: false, icon: 'star', title: 'Section 9' , subtitle: 'Subtitle 9' , info, toolbar, open: false, children: <div>Section 9 content</div> },
21
+ { id: 10, checked: false, icon: 'star', title: 'Section 10', subtitle: 'Subtitle 10', info, toolbar, open: false, children: <div>Section 10 content</div> },
22
+ { id: 11, checked: false, icon: 'star', title: 'Section 11', subtitle: 'Subtitle 11', info, toolbar, open: false, children: <div>Section 11 content</div> },
23
+ { id: 12, checked: false, icon: 'star', title: 'Section 12', subtitle: 'Subtitle 12', info, toolbar, open: false, children: <div>Section 12 content</div> },
24
+ { id: 13, checked: false, icon: 'star', title: 'Section 13', subtitle: 'Subtitle 13', info, toolbar, open: false, children: <div>Section 13 content</div> },
25
+ { id: 14, checked: false, icon: 'star', title: 'Section 14', subtitle: 'Subtitle 14', info, toolbar, open: false, children: <div>Section 14 content</div> },
26
+ { id: 15, checked: false, icon: 'star', title: 'Section 15', subtitle: 'Subtitle 15', info, toolbar, open: false, children: <div>Section 15 content</div> },
27
+ { id: 16, checked: false, icon: 'star', title: 'Section 16', subtitle: 'Subtitle 16', info, toolbar, open: false, children: <div>Section 16 content</div> },
28
+ { id: 17, checked: false, icon: 'star', title: 'Section 17', subtitle: 'Subtitle 17', info, toolbar, open: false, children: <div>Section 17 content</div> },
29
+ ]
30
+
31
+
32
+ return (
33
+ <>
34
+ <Accordion sections={sections} onCheck={console.log} />
35
+ </>
36
+ )
37
+ }
package/src/html/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { Accordion } from './accordion'
1
2
  export { Button } from './button'
2
3
  export { CheckBox } from './checkbox'
3
4
  export { Chips, Chip } from './chip'
@@ -1,4 +1,4 @@
1
- .section2>header {
1
+ .section>header {
2
2
  background-color: rgba(200,200,200,.1);
3
3
  padding: 0 1rem;
4
4
  min-height: 3rem;
@@ -20,7 +20,7 @@ export const Section = (props) => {
20
20
  }
21
21
 
22
22
  return (
23
- <section className={`section2 ${className}`}>
23
+ <section className={`section ${className}`}>
24
24
  <Header icon={icon} title={title}>
25
25
  {actions}
26
26
  {canCollapse ? <Icon icon="expand_more" onIcon="expand_less" clickable action={toggle} /> : ''}
@@ -42,7 +42,6 @@ export const TableTest = (prop) => {
42
42
  { id: "index", type: "INDEX", label: "#"},
43
43
  { id: "checked", onChange: check },
44
44
  { id: "name", label: "Name", type: "String", onChange: editCell },
45
- { id: "name", label: "Name", type: "String", sortable: true },
46
45
  { id: "thumb", label: "Thumb", type: "String", format: FORMATS.IMG },
47
46
  { id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
48
47
  { id: "date", label: "Date", type: "String", format: FORMATS.DATE },
@@ -55,7 +54,6 @@ export const TableTest = (prop) => {
55
54
  editable: true,
56
55
  columns : [
57
56
  { id: "checked", onChange: check },
58
- { id: "name", label: "Name", type: "String", onChange: editCell },
59
57
  { id: "name", label: "Name", type: "String", sortable: true },
60
58
  { id: "thumb", label: "Thumb", type: "String", format: FORMATS.IMG },
61
59
  { id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
@@ -67,6 +65,8 @@ export const TableTest = (prop) => {
67
65
  return (
68
66
  <div style={{ maxHeight: "20rem", overflow: "hidden", border: "solid 1px red", margin: "2rem" }}>
69
67
  <DataTable {...table1} onRowSelection={select} onCheckAll={checkAll}/>
68
+ x
69
+ <DataTable {...table2} onRowSelection={select} onCheckAll={checkAll}/>
70
70
  </div>
71
71
  )
72
72
  }
@@ -10,6 +10,7 @@ import { UploadDialog } from '../widgets/upload/UploadDialog'
10
10
  import { Uploader } from '../widgets/upload/Uploader'
11
11
  import { TabbedTablePage } from '../domain/TabbedTablePage'
12
12
  import { TablePage } from '../domain/TablePage'
13
+ import { TablePage2 } from '../domain/TablePage2'
13
14
  import { CollectionPage } from '../domain/CollectionPage'
14
15
  import { FORMATS, TYPES } from '../domain/ContentType'
15
16
  import { TableTest } from '../html/table.test'
@@ -19,7 +20,7 @@ const SiteTest = (prop) => {
19
20
  const footer = <div>FOOTER</div>
20
21
 
21
22
  return (
22
- <Site icon="star" title="Site Test" init={"PAGE5"} footer={footer}>
23
+ <Site icon="star" title="Site Test" init={"PAGE3"} footer={footer}>
23
24
  <Page id="PAGE1" section="SECTION1" icon="description" title="Page 1" layout="workspace">
24
25
  <Page1 />
25
26
  </Page>
@@ -131,10 +132,10 @@ const Page2 = (props) => {
131
132
  const Page3 = (props) => {
132
133
 
133
134
  const ENTITYTYPE = {
134
- name : { id: "name" , section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
135
- field1: { id: "field1", section: "E-INFO1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field1" },
136
- field2: { id: "field2", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field2" },
137
- field3: { id: "field3", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
135
+ name : { id: "name" , section: "" , type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
136
+ field1: { id: "field01", section: "E-INFO1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field1" },
137
+ field2: { id: "field02", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field2" },
138
+ field3: { id: "field03", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
138
139
 
139
140
  }
140
141
 
@@ -153,7 +154,7 @@ const Page3 = (props) => {
153
154
 
154
155
  return (
155
156
  <Fragment>
156
- <TablePage title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canFilter={true} tableClassName="condensed"/>
157
+ <TablePage2 title="Referencias" schema={schema} host="http://localhost:3000" url="/references" canFilter={true} tableClassName="condensed" groupBy="state"/>
157
158
  </Fragment>
158
159
  )
159
160
  }
@@ -166,18 +167,17 @@ const Page4 = (props) => {
166
167
  field1: { id: "field1", section: "E-INFO1", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field1" },
167
168
  field2: { id: "field2", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field2" },
168
169
  field3: { id: "field3", section: "E-INFO2", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
169
-
170
170
  }
171
171
 
172
172
  const schema = {
173
- name : { id: "name" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
174
- state : { id: "state" , section: "A", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
173
+ name : { id: "name" , section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true , label: "Name" },
174
+ state : { id: "state" , section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: true , grouper: true , column: true , filter: false , label: "State" , options: [
175
175
  { label: "Pendiente", value: "NOT_CLASSIFIED" },
176
176
  { label: "Clasificada", value: "CLASSIFIED"},
177
177
  ]},
178
- field1: { id: "field1", section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field1" },
179
- field2: { id: "field2", section: "B", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field2" },
180
- field4: { id: "field4", section: "B", type: TYPES.STRING , format: FORMATS.COLOR, required: true, tab: false, grouper: true , column: true , filter: true , label: "Color" },
178
+ field1: { id: "field1", section: "A", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field1" },
179
+ field2: { id: "field2", section: "B", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "field2" },
180
+ field4: { id: "field4", section: "B", type: TYPES.STRING , format: FORMATS.COLOR, required: true, tab: false, grouper: true , column: true , filter: true , label: "Color" },
181
181
  field5: { id: "field5", section: "B", type: TYPES.ENTITY, item: ENTITYTYPE, format: FORMATS.NONE , editable: true, tab: false, grouper: false, column: true , filter: true , like: false, label: "Entity5"},
182
182
 
183
183
  }
@@ -192,10 +192,10 @@ const Page4 = (props) => {
192
192
  const Page5 = (props) => {
193
193
 
194
194
  const ENTITYTYPE = {
195
- name : { id: "name" , section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
196
- field1: { id: "field1", section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: false, filter: true , label: "E field1" },
197
- field2: { id: "field2", section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: false, filter: true , label: "E field2" },
198
- field3: { id: "field3", section: "", type: TYPES.STRING, format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
195
+ name : { id: "name" , section: "", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , like: true, label: "Name" },
196
+ field1: { id: "field1", section: "", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: false, filter: true , label: "E field1" },
197
+ field2: { id: "field2", section: "", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: false, filter: true , label: "E field2" },
198
+ field3: { id: "field3", section: "", type: TYPES.STRING , format: FORMATS.NONE , required: true, tab: false, grouper: true , column: true , filter: true , label: "E field3" },
199
199
  }
200
200
 
201
201
  const schema = {
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from "react";
1
+ import React, { useEffect, useMemo, useState, useRef } from "react";
2
2
  import { DropDown, Header, Icon, Text, TextField, Button } from "../../html";
3
3
  import moment from "moment";
4
4
  import { extendMoment } from "moment-range";
@@ -15,15 +15,17 @@ const DATE_RANGE = [
15
15
  /**
16
16
  * Planner
17
17
  */
18
- export const Planner = ({ title, events = [], lanes = [], navigation = true, onSelectCell, focusEvent, config = { range: "year", from: "2022-01-01", to: "2022-12-30"}, onChange }) => {
18
+ export const Planner = ({ title, events = [], lanes = [], navigation = true, onSelectCell, focusEvent, config = { range: "year", from: "2022-01-01", to: "2022-12-30" }, onChange }) => {
19
19
 
20
20
  const [dateRange, setDateRange] = useState(config.range);
21
21
  const [from, setFrom] = useState(config.from);
22
22
  const [to, setTo] = useState(config.to);
23
-
23
+ const thisMondayElement = useRef(null)
24
+
24
25
  useEffect(() => {
25
- showThisWeek()
26
- }, [])
26
+ console.log(thisMondayElement.current)
27
+ if (thisMondayElement.current) { showThisWeek() }
28
+ })
27
29
 
28
30
  useEffect(() => {
29
31
  const element = document.getElementById(focusEvent)
@@ -93,7 +95,7 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
93
95
  {navigation ? (
94
96
  <Header title={label}>
95
97
  &nbsp;&nbsp;
96
- <Button label="Esta Semana" outlined action={showThisWeek}/>
98
+ <Button label="Esta Semana" outlined action={showThisWeek} />
97
99
  <Icon icon="chevron_right" clickable action={next} />
98
100
  <TextField id="to" type="date" label="Hasta" value={to} onChange={(id, value) => setTo(value)} />
99
101
  <div className="expand"></div>
@@ -108,11 +110,7 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
108
110
 
109
111
  <div className="column0">
110
112
  <div className="column-header"></div>
111
- {lanes.map((lane) => (
112
- <div className="row-header">
113
- {lane.label}
114
- </div>
115
- ))}
113
+ {lanes.map((lane) => <div className="row-header">{lane.label}</div>)}
116
114
  </div>
117
115
 
118
116
  <div className="rows">
@@ -145,7 +143,7 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
145
143
  })}
146
144
  </div>
147
145
 
148
- {lanes.map((lane) => <PlannerRow key={lane.id} lane={lane} events={events} period={period} onSelectCell={selectCell} onChange={onChange}/>)}
146
+ {lanes.map((lane) => <PlannerRow key={lane.id} lane={lane} events={events} period={period} onSelectCell={selectCell} onChange={onChange} thisMondayRef={thisMondayElement} />)}
149
147
 
150
148
  </div>
151
149
  </main>
@@ -158,7 +156,7 @@ export const Planner = ({ title, events = [], lanes = [], navigation = true, onS
158
156
  */
159
157
  const PlannerRow = (props) => {
160
158
 
161
- const { lane, events = [], period, onSelectCell, onChange } = props
159
+ const { lane, events = [], period, onSelectCell, onChange, thisMondayRef } = props
162
160
  const rowEvents = events.filter(event => event.lane === lane.id)
163
161
 
164
162
 
@@ -177,7 +175,7 @@ const PlannerRow = (props) => {
177
175
  return eventDate.getTime() === slotDate.getTime();
178
176
  })
179
177
  return (
180
- <PlannerCell key={`${lane.id}-${slotDate.toString()}`} lane={lane} date={date} events={cellEvents} onSelect={onSelectCell} onDrop={change}/>
178
+ <PlannerCell key={`${lane.id}-${slotDate.toString()}`} lane={lane} date={date} events={cellEvents} onSelect={onSelectCell} onDrop={change} thisMondayRef={thisMondayRef} />
181
179
  );
182
180
  })}
183
181
  </div>
@@ -187,7 +185,7 @@ const PlannerRow = (props) => {
187
185
  /**
188
186
  * Planner Cell
189
187
  */
190
- const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, onSelect, onDrop, editable = false }) => {
188
+ const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, onSelect, onDrop, editable = false, thisMondayRef }) => {
191
189
 
192
190
  const [dragOver, setDragOver] = useState(false);
193
191
 
@@ -225,10 +223,11 @@ const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, on
225
223
 
226
224
  const today = moment()
227
225
  var weekStart = today.clone().startOf('week')
226
+ const isThisMonday = (date.moment.isSame(weekStart))
228
227
  const thisMonday = (date.moment.isSame(weekStart)) ? "thisMonday" : ""
229
228
  const dragOverStyle = dragOver ? "drag-over" : ""
230
- return (
231
- <div className={`cell ${thisMonday} ${weekend} ${dragOverStyle}`} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop} onClick={select}>
229
+ return (
230
+ <div className={`cell ${thisMonday} ${weekend} ${dragOverStyle}`} ref={isThisMonday ? thisMondayRef : null} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop} onClick={select}>
232
231
  {events.map(event => {
233
232
  const { Renderer = EventCard } = event
234
233
  return <Renderer key={event.id} event={event} />