ywana-core8 0.0.548 → 0.0.551
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 +126 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +83 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +131 -10
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +128 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +2 -2
- 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/src/widgets/index.js +1 -0
package/package.json
CHANGED
@@ -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/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
|
+
}
|
package/src/widgets/index.js
CHANGED