ywana-core8 0.0.547 → 0.0.550
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 +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +17 -7
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +17 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +3 -3
- package/src/domain/ContentEditor.js +4 -4
- package/src/html/tree.css +5 -0
- package/src/site/site.js +0 -2
- package/src/widgets/calendar/Calendar.css +83 -0
- package/src/widgets/calendar/Calendar.js +110 -0
- package/src/widgets/calendar/Calendar.test.js +28 -0
package/package.json
CHANGED
@@ -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} />
|
74
|
+
<CollectionEditor icon={icon} schema={schema} layout={editor} autosave={autosave} delay={delay} canDelete={canDelete} canEdit={canEdit} />
|
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 } = props
|
286
|
+
const { icon, schema, layout, autosave = false, delay = 1000, canDelete, canEdit } = props
|
287
287
|
const timer = useRef(null)
|
288
288
|
const [form, setForm] = useState(selected)
|
289
289
|
|
@@ -340,7 +340,7 @@ const CollectionEditor = (props) => {
|
|
340
340
|
<Icon icon="close" clickable action={clear} />
|
341
341
|
<MenuIcon align="alignRight">
|
342
342
|
<Menu>
|
343
|
-
<MenuItem label="Eliminar" onSelect={remove} />
|
343
|
+
{ canDelete ? <MenuItem label="Eliminar" onSelect={remove} /> : null }
|
344
344
|
</Menu>
|
345
345
|
</MenuIcon>
|
346
346
|
{autosave === true ? null : <Button icon="save" label="Guardar Cambios" raised disabled={!canSave()} action={save} />}
|
@@ -419,7 +419,7 @@ export const CollectionEditor = ({ field, value = [], onChange }) => {
|
|
419
419
|
Renderer ?
|
420
420
|
<Renderer field={field} value={value} onRemove={remove} onChange={onChange} />
|
421
421
|
// : <DataTable {...table} editable={editable} />
|
422
|
-
: <TableEditor icon={"info"} title={label} data={value} schema={item} groupBy={"field1"} />
|
422
|
+
: <TableEditor icon={"info"} title={label} data={value} schema={item} groupBy={"field1"} canDelete={true} remove={remove}/>
|
423
423
|
|
424
424
|
}
|
425
425
|
<footer>
|
@@ -475,7 +475,7 @@ const CollectionAdder = ({ item, onAdd }) => {
|
|
475
475
|
*/
|
476
476
|
const TableEditor = (props) => {
|
477
477
|
|
478
|
-
const { data = [], icon, title, schema, editable, canDelete, filter, actions, className } = props
|
478
|
+
const { data = [], icon, title, schema, editable, canDelete, remove, filter, actions, className } = props
|
479
479
|
const [groupBy, setGroupBy] = useState(props.groupBy)
|
480
480
|
|
481
481
|
function changeGroup(id, value) {
|
@@ -536,13 +536,13 @@ const TableEditor = (props) => {
|
|
536
536
|
}
|
537
537
|
}),
|
538
538
|
rows: groups[groupName]
|
539
|
-
.map(item => {
|
539
|
+
.map((item, index) => {
|
540
540
|
item.actions = actions ? actions.map(action => {
|
541
541
|
return action.filter ?
|
542
542
|
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} /> : null
|
543
543
|
: <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} />
|
544
544
|
}) : []
|
545
|
-
if (canDelete) item.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(
|
545
|
+
if (canDelete) item.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(index)} />)
|
546
546
|
return item
|
547
547
|
})
|
548
548
|
}
|
package/src/html/tree.css
CHANGED
package/src/site/site.js
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
.calendar {
|
3
|
+
margin: 0rem;
|
4
|
+
overflow: hidden;
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
padding: .5rem;
|
8
|
+
}
|
9
|
+
|
10
|
+
.calendar>nav {
|
11
|
+
display: flex;
|
12
|
+
padding: .5rem;
|
13
|
+
display: flex;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
.calendar>nav>label {
|
18
|
+
flex: 1;
|
19
|
+
font-size: 1.3rem;
|
20
|
+
font-weight: 500;
|
21
|
+
}
|
22
|
+
|
23
|
+
.calendar>nav>button {
|
24
|
+
margin-left: 1px;
|
25
|
+
}
|
26
|
+
|
27
|
+
.calendar>header {
|
28
|
+
border: solid 1px var(--divider-color);
|
29
|
+
border-width: 1px 1px 0 0px;
|
30
|
+
display: grid;
|
31
|
+
grid-template-columns: repeat(7, 1fr);
|
32
|
+
font-size: .8rem;
|
33
|
+
}
|
34
|
+
|
35
|
+
.calendar>main {
|
36
|
+
flex: 1;
|
37
|
+
border: solid 1px var(--divider-color);
|
38
|
+
border-width: 1px 1px 0 0;
|
39
|
+
display: grid;
|
40
|
+
grid-template-columns: repeat(7, 1fr);
|
41
|
+
grid-gap: 0px;
|
42
|
+
grid-auto-rows: minmax(5rem, auto);
|
43
|
+
overflow: hidden;
|
44
|
+
font-size: .8rem;
|
45
|
+
}
|
46
|
+
|
47
|
+
.week-day-cell {
|
48
|
+
border-left: solid 1px var(--divider-color);
|
49
|
+
padding: 2px;
|
50
|
+
text-align: center;
|
51
|
+
min-width: 5rem;
|
52
|
+
}
|
53
|
+
|
54
|
+
.day-cell {
|
55
|
+
border: solid 1px var(--divider-color);
|
56
|
+
border-width: 0 0 1px 1px;
|
57
|
+
padding: .5rem;
|
58
|
+
text-align: right;
|
59
|
+
min-height: 5rem;
|
60
|
+
min-width: 5rem;
|
61
|
+
}
|
62
|
+
|
63
|
+
.day-cell.today>header {
|
64
|
+
background-color: var(--primary-color-lighter);
|
65
|
+
padding: .3rem
|
66
|
+
}
|
67
|
+
|
68
|
+
.day-cell:hover {
|
69
|
+
background-color: rgba(200,200,200,.1);
|
70
|
+
cursor: pointer;
|
71
|
+
}
|
72
|
+
|
73
|
+
.day-cell.today:hover {
|
74
|
+
background-color: var(--primary-color-lighter);
|
75
|
+
}
|
76
|
+
|
77
|
+
.day-cell .event {
|
78
|
+
background-color: var(--primary-color);
|
79
|
+
color: var(--primary-color-text);
|
80
|
+
padding: .3rem;
|
81
|
+
border-radius: 3px;
|
82
|
+
margin: 3px 1px;
|
83
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
2
|
+
import { Button } from '../../html'
|
3
|
+
import Moment from 'moment'
|
4
|
+
import { extendMoment } from 'moment-range';
|
5
|
+
import 'moment/locale/es'
|
6
|
+
import './Calendar.css'
|
7
|
+
|
8
|
+
Moment.locale('es')
|
9
|
+
const moment = extendMoment(Moment)
|
10
|
+
|
11
|
+
export const Calendar = (props) => {
|
12
|
+
|
13
|
+
const { events = [], children} = props
|
14
|
+
const [position, setPosition] = useState()
|
15
|
+
|
16
|
+
useEffect(() => {
|
17
|
+
const today = moment()
|
18
|
+
setPosition(today)
|
19
|
+
}, [])
|
20
|
+
|
21
|
+
function next() {
|
22
|
+
const next = position.clone().add(1, 'month')
|
23
|
+
setPosition(next)
|
24
|
+
}
|
25
|
+
|
26
|
+
function prev() {
|
27
|
+
const prev = position.clone().subtract(1, 'month')
|
28
|
+
setPosition(prev)
|
29
|
+
}
|
30
|
+
|
31
|
+
function today() {
|
32
|
+
const today = moment()
|
33
|
+
setPosition(today)
|
34
|
+
}
|
35
|
+
|
36
|
+
if (!position) return "..."
|
37
|
+
|
38
|
+
const monthName = position.format("MMMM")
|
39
|
+
const year = position.format("YYYY")
|
40
|
+
const firstDayOfMonth = position.clone().startOf('month');
|
41
|
+
const firstDayOfRange = firstDayOfMonth.clone().startOf('isoweek');
|
42
|
+
const lastDayOfMonth = position.clone().endOf('month');
|
43
|
+
const lastDayOfRange = lastDayOfMonth.clone().endOf('isoweek');
|
44
|
+
const range = moment.range(firstDayOfRange, lastDayOfRange)
|
45
|
+
const days = Array.from(range.by('days'))
|
46
|
+
|
47
|
+
const cells = days.map(day => {
|
48
|
+
const dayEvents = events.filter(event => {
|
49
|
+
const eventDate = moment(event.date, "YYYY-MM-DD")
|
50
|
+
return eventDate.isSame(day, 'day')
|
51
|
+
})
|
52
|
+
return { day, events: dayEvents }
|
53
|
+
})
|
54
|
+
|
55
|
+
return (
|
56
|
+
<div className="calendar">
|
57
|
+
<nav>
|
58
|
+
<label> {monthName} {year}</label>
|
59
|
+
<Button icon="chevron_left" raised action={prev} />
|
60
|
+
<Button label="Hoy" outlined action={today}/>
|
61
|
+
<Button icon="chevron_right" raised action={next} />
|
62
|
+
</nav>
|
63
|
+
<header>
|
64
|
+
<div className='week-day-cell'>Lun</div>
|
65
|
+
<div className='week-day-cell'>Mar</div>
|
66
|
+
<div className='week-day-cell'>Mié</div>
|
67
|
+
<div className='week-day-cell'>Jue</div>
|
68
|
+
<div className='week-day-cell'>Vie</div>
|
69
|
+
<div className='week-day-cell'>Sab</div>
|
70
|
+
<div className='week-day-cell'>Dom</div>
|
71
|
+
</header>
|
72
|
+
<main>
|
73
|
+
{cells.map(cell => <DayCell cell={cell} >{children}</DayCell>)}
|
74
|
+
</main>
|
75
|
+
</div>
|
76
|
+
)
|
77
|
+
}
|
78
|
+
|
79
|
+
const DayCell = (props) => {
|
80
|
+
const { cell = [], children } = props
|
81
|
+
const {day, events} = cell
|
82
|
+
const todayStyle = day.isSame(moment(), 'day') ? 'today' : ''
|
83
|
+
|
84
|
+
return (
|
85
|
+
<div className={`day-cell ${todayStyle}`}>
|
86
|
+
<header>
|
87
|
+
{day.format("DD")}
|
88
|
+
</header>
|
89
|
+
<main>
|
90
|
+
{events.map(event => <Event key={event.id} event={event} >{children}</Event>)}
|
91
|
+
</main>
|
92
|
+
</div>
|
93
|
+
)
|
94
|
+
}
|
95
|
+
|
96
|
+
const Event = (props) => {
|
97
|
+
const { event, children } = props
|
98
|
+
if (children) {
|
99
|
+
const element = React.Children.toArray(children)[0]
|
100
|
+
return React.cloneElement(element, { event })
|
101
|
+
} else {
|
102
|
+
return (
|
103
|
+
<div className="event">
|
104
|
+
<div className="event-name">
|
105
|
+
{event.title}
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
)
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Calendar } from './Calendar'
|
3
|
+
import moment from 'moment'
|
4
|
+
|
5
|
+
const CalendarTest = (prop) => {
|
6
|
+
|
7
|
+
const events = [
|
8
|
+
{ id: 1, date: "2022-05-26", title: 'Event 1' },
|
9
|
+
{ id: 1, date: "2022-05-27", title: 'Event 1' },
|
10
|
+
{ id: 1, date: "2022-05-28", title: 'Event 1' },
|
11
|
+
{ id: 1, date: "2022-05-29", title: 'Event 1' },
|
12
|
+
]
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Calendar events={events} >
|
16
|
+
<CustomEvent />
|
17
|
+
</Calendar>
|
18
|
+
)
|
19
|
+
}
|
20
|
+
|
21
|
+
const CustomEvent = (props) => {
|
22
|
+
const { event } = props
|
23
|
+
return (
|
24
|
+
<div className="custom-event" onClick={() => alert("!xxx")}>
|
25
|
+
C {event.title}
|
26
|
+
</div>
|
27
|
+
)
|
28
|
+
}
|