ywana-core8 0.0.917 → 0.0.919
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 +145 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +106 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +146 -7
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +145 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/button.js +4 -4
- package/src/incubator/index.js +1 -0
- package/src/incubator/planner.css +106 -0
- package/src/incubator/planner.js +148 -0
- package/src/incubator/task.js +1 -1
- package/src/incubator/calendar.css +0 -41
- package/src/incubator/calendar.js +0 -66
package/package.json
CHANGED
package/src/html/button.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
1
|
+
import React, { useEffect, useState, useCallback } from 'react'
|
2
2
|
import { Icon } from './icon'
|
3
3
|
import { Text } from './text'
|
4
4
|
import './button.css'
|
@@ -8,19 +8,19 @@ import './button.css'
|
|
8
8
|
*/
|
9
9
|
export const Button = ({ label, icon, action, disabled = false, outlined, raised, className, progress = 0 }) => {
|
10
10
|
|
11
|
-
|
11
|
+
const click = useCallback((event) => {
|
12
12
|
if (!disabled) {
|
13
13
|
event.stopPropagation();
|
14
14
|
event.preventDefault();
|
15
15
|
if (action) action()
|
16
16
|
}
|
17
|
-
}
|
17
|
+
}, [disabled, action]);
|
18
18
|
|
19
19
|
let style = raised ? 'raised' : outlined ? 'outlined' : 'normal'
|
20
20
|
if (disabled) style = `${style} disabled`
|
21
21
|
return (
|
22
22
|
<button className={`btn ${style} ${className}`} onClick={click}>
|
23
|
-
{icon
|
23
|
+
{icon && <Icon icon={icon} size="small" clickable action={click} /> }
|
24
24
|
<Text>{label}</Text>
|
25
25
|
</button>
|
26
26
|
)
|
package/src/incubator/index.js
CHANGED
@@ -0,0 +1,106 @@
|
|
1
|
+
.planner2-row {
|
2
|
+
overflow-x: auto;
|
3
|
+
}
|
4
|
+
|
5
|
+
.months-row {
|
6
|
+
position: sticky;
|
7
|
+
top: 0px;
|
8
|
+
background-color: var(--paper-color);
|
9
|
+
z-index: 2;
|
10
|
+
}
|
11
|
+
|
12
|
+
.month-cell {
|
13
|
+
border: solid 1px rgb(220, 220, 220);
|
14
|
+
border-width: 0 1px 1px 0;
|
15
|
+
min-width: 3rem;
|
16
|
+
height: 1.4rem;
|
17
|
+
}
|
18
|
+
|
19
|
+
.month-name{
|
20
|
+
width: 10rem;
|
21
|
+
position: sticky;
|
22
|
+
left: 12rem;
|
23
|
+
}
|
24
|
+
|
25
|
+
.days-row {
|
26
|
+
position: sticky;
|
27
|
+
top: 1.4rem;
|
28
|
+
background-color: var(--paper-color);
|
29
|
+
z-index: 2;
|
30
|
+
}
|
31
|
+
|
32
|
+
.day-cell {
|
33
|
+
padding: .5rem 0;
|
34
|
+
border: solid 1px rgb(220, 220, 220);
|
35
|
+
border-width: 0 1px 1px 0;
|
36
|
+
display: flex;
|
37
|
+
flex-direction: column;
|
38
|
+
align-items: center;
|
39
|
+
justify-content: center;
|
40
|
+
}
|
41
|
+
|
42
|
+
.weekday {
|
43
|
+
font-size: .6rem;
|
44
|
+
font-weight: 400;
|
45
|
+
color:rgb(143, 143, 143)
|
46
|
+
}
|
47
|
+
|
48
|
+
.daynum {
|
49
|
+
font-size: .8rem;
|
50
|
+
font-weight: 600;
|
51
|
+
padding: .2rem 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
.content-rows {
|
55
|
+
}
|
56
|
+
|
57
|
+
.content-row {
|
58
|
+
display: flex;
|
59
|
+
}
|
60
|
+
|
61
|
+
.content-cell {
|
62
|
+
border: solid 1px rgb(220, 220, 220);
|
63
|
+
border-width: 0 1px 1px 0;
|
64
|
+
display: flex;
|
65
|
+
flex-direction: column;
|
66
|
+
align-items: center;
|
67
|
+
justify-content: center;
|
68
|
+
background-color: var(--background-color);
|
69
|
+
padding: .5rem;
|
70
|
+
}
|
71
|
+
|
72
|
+
.row-header {
|
73
|
+
position: sticky;
|
74
|
+
left: 0px;
|
75
|
+
display: flex;
|
76
|
+
flex-direction: column;
|
77
|
+
align-items: center;
|
78
|
+
justify-content: center;
|
79
|
+
border: solid 1px rgb(220, 220, 220);
|
80
|
+
border-width: 0 1px 1px 0;
|
81
|
+
background-color: var(--paper-color);
|
82
|
+
z-index: 1;
|
83
|
+
}
|
84
|
+
|
85
|
+
.event-card {
|
86
|
+
width: 100%;
|
87
|
+
height: 5rem;
|
88
|
+
display: flex;
|
89
|
+
flex-direction: column;
|
90
|
+
align-items: center;
|
91
|
+
justify-content: flex-start;
|
92
|
+
margin: .2rem;
|
93
|
+
border: solid 1px black;
|
94
|
+
}
|
95
|
+
|
96
|
+
.event-card.compact {
|
97
|
+
width: 100%;
|
98
|
+
height: 2rem;
|
99
|
+
display: flex;
|
100
|
+
flex-direction: column;
|
101
|
+
align-items: center;
|
102
|
+
justify-content: flex-start;
|
103
|
+
margin: .5rem 0;
|
104
|
+
border: solid 1px var(--divider-color);
|
105
|
+
border-radius: 4px;
|
106
|
+
}
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
2
|
+
import "./planner.css"
|
3
|
+
|
4
|
+
export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, rowHeaderWidth = 10, EventRenderer }) => {
|
5
|
+
|
6
|
+
const [days, setDays] = useState([]);
|
7
|
+
const lastDay = new Date(to);
|
8
|
+
|
9
|
+
useEffect(() => {
|
10
|
+
const day = new Date(from);
|
11
|
+
const nextDays = [];
|
12
|
+
while (day <= lastDay) {
|
13
|
+
nextDays.push({
|
14
|
+
day: day.getDate(),
|
15
|
+
weekday: day.toLocaleString('en-US', { weekday: 'short' }),
|
16
|
+
month: day.toLocaleString('en-US', { month: 'short' }),
|
17
|
+
monthNum: day.getMonth() + 1,
|
18
|
+
year: day.getFullYear(),
|
19
|
+
});
|
20
|
+
day.setDate(day.getDate() + 1);
|
21
|
+
}
|
22
|
+
setDays(nextDays);
|
23
|
+
}, [from, to])
|
24
|
+
|
25
|
+
const uniqueMonths = Array.from(
|
26
|
+
new Set(days.map(({ month }) => month))
|
27
|
+
);
|
28
|
+
|
29
|
+
const monthWidths = uniqueMonths.map((month) => {
|
30
|
+
const monthDays = days.filter((day) => day.month === month);
|
31
|
+
return `${monthDays.length * cellWidth}rem`;
|
32
|
+
});
|
33
|
+
|
34
|
+
const dayWidth = `${cellWidth}rem`;
|
35
|
+
const totalDaysWidth = (days.length * (cellWidth)) + rowHeaderWidth;
|
36
|
+
|
37
|
+
return (
|
38
|
+
<div className='planner2-row'>
|
39
|
+
|
40
|
+
<div className="months-row" style={{ display: 'flex', width: `${totalDaysWidth}rem` }}>
|
41
|
+
<div className="row-header" style={{ width: `${rowHeaderWidth}rem` }} >
|
42
|
+
</div>
|
43
|
+
{uniqueMonths.map((month, index) => (
|
44
|
+
<div
|
45
|
+
className="month-cell"
|
46
|
+
key={month}
|
47
|
+
style={{
|
48
|
+
fontWeight: 'bold',
|
49
|
+
minWidth: monthWidths[index],
|
50
|
+
}}
|
51
|
+
>
|
52
|
+
<div className="month-name">
|
53
|
+
{month} {new Date(from).getFullYear()}
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
))}
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div className="days-row" style={{ display: 'flex', width: `${totalDaysWidth}rem` }}>
|
60
|
+
<div className="row-header" style={{ width: `${rowHeaderWidth}rem` }}>
|
61
|
+
</div>
|
62
|
+
{days.map(({ day, weekday, month }) => (
|
63
|
+
<div className='day-cell' style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`day_${month}-${day}`}>
|
64
|
+
<div className="weekday">{weekday.substring(0, 2)}</div>
|
65
|
+
<div className="daynum">{day}</div>
|
66
|
+
</div>
|
67
|
+
))}
|
68
|
+
</div>
|
69
|
+
|
70
|
+
{lanes.map((lane, index) => {
|
71
|
+
const laneEvents = events.filter((event) => event.lane === lane.id);
|
72
|
+
return (
|
73
|
+
<div className="content-row" style={{ width: `${totalDaysWidth}rem` }}>
|
74
|
+
<div className="row-header" style={{ width: `${rowHeaderWidth}rem` }}>
|
75
|
+
{lane.title}
|
76
|
+
</div>
|
77
|
+
{days.map(({ day, weekday, month, monthNum, year }) => {
|
78
|
+
const dayDate = new Date(year, monthNum - 1, day);
|
79
|
+
const dayEvents = laneEvents.filter((event) => {
|
80
|
+
const eventDate = new Date(event.date);
|
81
|
+
return eventDate.getDate() === dayDate.getDate() &&
|
82
|
+
eventDate.getMonth() === dayDate.getMonth() &&
|
83
|
+
eventDate.getFullYear() === dayDate.getFullYear();
|
84
|
+
});
|
85
|
+
return (
|
86
|
+
<div className="content-cell" style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`content${index}_${month}-${day}`}>
|
87
|
+
{dayEvents.map((event) => <EventRenderer key={event.id} event={event} />)}
|
88
|
+
</div>
|
89
|
+
)
|
90
|
+
})}
|
91
|
+
</div>
|
92
|
+
)
|
93
|
+
})}
|
94
|
+
</div>
|
95
|
+
);
|
96
|
+
};
|
97
|
+
|
98
|
+
const EventCard = (props) => {
|
99
|
+
const { event = {} } = props
|
100
|
+
const { id, title, color } = event
|
101
|
+
|
102
|
+
function drag(ev) {
|
103
|
+
ev.dataTransfer.setData("text", id);
|
104
|
+
}
|
105
|
+
|
106
|
+
let style = { backgroundColor: event.color, color: "white" }
|
107
|
+
return (
|
108
|
+
<div draggable onDragStart={drag} id={id} className={`event-card compact`} style={style}>
|
109
|
+
{title}
|
110
|
+
</div>
|
111
|
+
)
|
112
|
+
}
|
113
|
+
|
114
|
+
const CalendarTest = (props) => {
|
115
|
+
|
116
|
+
const lanes = [
|
117
|
+
{ id: "1", title: "Lane 1" },
|
118
|
+
{ id: "2", title: "Lane 2" },
|
119
|
+
{ id: "3", title: "Lane 3" },
|
120
|
+
{ id: "4", title: "Lane 4" },
|
121
|
+
{ id: "5", title: "Lane 5" },
|
122
|
+
{ id: "6", title: "Lane 6" },
|
123
|
+
{ id: "7", title: "Lane 7" },
|
124
|
+
{ id: "8", title: "Lane 8" },
|
125
|
+
]
|
126
|
+
|
127
|
+
const events = [
|
128
|
+
{ id: "1", lane: "1", date: "2023-01-04", color: "yellow", title: "Event One" },
|
129
|
+
{ id: "1", lane: "1", date: "2023-01-04", color: "yellow", title: "Event One" },
|
130
|
+
{ id: "1", lane: "1", date: "2023-01-05", color: "yellow", title: "Event One" },
|
131
|
+
{ id: "2", lane: "1", date: "2023-01-05", color: "red", title: "Event One" },
|
132
|
+
{ id: "3", lane: "1", date: "2023-01-05", color: "blue", title: "Event One" },
|
133
|
+
{ id: "4", lane: "1", date: "2023-01-05", color: "red", title: "Event One" },
|
134
|
+
{ id: "5", lane: "2", date: "2023-01-04", color: "yellow", title: "Event One" },
|
135
|
+
{ id: "6", lane: "2", date: "2023-01-05", color: "red", title: "Event One" },
|
136
|
+
{ id: "7", lane: "2", date: "2023-01-06", color: "blue", title: "Event One" },
|
137
|
+
{ id: "8", lane: "2", date: "2023-01-07", color: "red", title: "Event One" },
|
138
|
+
{ id: "9", lane: "3", date: "2023-01-04", color: "yellow", title: "Event One" },
|
139
|
+
{ id: "10", lane: "3", date: "2023-01-05", color: "red", title: "Event One" },
|
140
|
+
{ id: "11", lane: "3", date: "2023-01-06", color: "blue", title: "Event One" },
|
141
|
+
]
|
142
|
+
|
143
|
+
return (
|
144
|
+
<>
|
145
|
+
<Planner2 from="2023-01-03" to="2023-01-13" lanes={lanes} events={events} EventRenderer={EventCard} />
|
146
|
+
</>
|
147
|
+
)
|
148
|
+
}
|
package/src/incubator/task.js
CHANGED
@@ -14,7 +14,7 @@ export const TaskContext = React.createContext({})
|
|
14
14
|
export const TaskContextProvider = (props) => {
|
15
15
|
|
16
16
|
const { host, url = "/tasks", frequency = 1000, children } = props
|
17
|
-
const API = CollectionAPI(url, host,
|
17
|
+
const API = CollectionAPI(url, host, "")
|
18
18
|
const [ listeners, setListeners ] = useState({})
|
19
19
|
|
20
20
|
useEffect(() => {
|
@@ -1,41 +0,0 @@
|
|
1
|
-
.calendar-row {
|
2
|
-
border: solid 1px rgb(0, 0, 0);
|
3
|
-
overflow-x: auto;
|
4
|
-
}
|
5
|
-
|
6
|
-
.months-row {
|
7
|
-
display: flex;
|
8
|
-
overflow: visible;
|
9
|
-
}
|
10
|
-
|
11
|
-
.month-cell {
|
12
|
-
border: solid 1px rgb(220, 220, 220);
|
13
|
-
min-width: 3rem;
|
14
|
-
height: 1.4rem;
|
15
|
-
display: flex;
|
16
|
-
flex-direction: column;
|
17
|
-
align-items: center;
|
18
|
-
justify-content: center;
|
19
|
-
}
|
20
|
-
|
21
|
-
.day-cell {
|
22
|
-
padding: .5rem 0;
|
23
|
-
border: solid 1px rgb(220, 220, 220);
|
24
|
-
display: flex;
|
25
|
-
flex-direction: column;
|
26
|
-
align-items: center;
|
27
|
-
justify-content: center;
|
28
|
-
|
29
|
-
}
|
30
|
-
|
31
|
-
.weekday {
|
32
|
-
font-size: .6rem;
|
33
|
-
font-weight: 400;
|
34
|
-
color:rgb(143, 143, 143)
|
35
|
-
}
|
36
|
-
|
37
|
-
.daynum {
|
38
|
-
font-size: .8rem;
|
39
|
-
font-weight: 600;
|
40
|
-
padding: .2rem 0;
|
41
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import "./calendar.css"
|
3
|
-
|
4
|
-
|
5
|
-
export const Calendar = ({ from, to }) => {
|
6
|
-
const days = [];
|
7
|
-
const day = new Date(from);
|
8
|
-
const lastDay = new Date(to);
|
9
|
-
while (day <= lastDay) {
|
10
|
-
days.push({
|
11
|
-
day: day.getDate(),
|
12
|
-
weekday: day.toLocaleString('en-US', { weekday: 'short' }),
|
13
|
-
month: day.toLocaleString('en-US', { month: 'short' }),
|
14
|
-
});
|
15
|
-
day.setDate(day.getDate() + 1);
|
16
|
-
}
|
17
|
-
|
18
|
-
const uniqueMonths = Array.from(
|
19
|
-
new Set(days.map(({ month }) => month))
|
20
|
-
);
|
21
|
-
|
22
|
-
const monthWidths = uniqueMonths.map((month) => {
|
23
|
-
const monthDays = days.filter((day) => day.month === month);
|
24
|
-
return `${monthDays.length * 2}rem`;
|
25
|
-
});
|
26
|
-
|
27
|
-
const dayWidth = '2rem';
|
28
|
-
|
29
|
-
return (
|
30
|
-
<div className='calendar-row'>
|
31
|
-
<div className="months-row" style={{ display: 'flex' }}>
|
32
|
-
{uniqueMonths.map((month, index) => (
|
33
|
-
<div
|
34
|
-
className="month-cell"
|
35
|
-
key={month}
|
36
|
-
style={{
|
37
|
-
flex: '0 0 auto',
|
38
|
-
textAlign: 'center',
|
39
|
-
fontWeight: 'bold',
|
40
|
-
width: monthWidths[index],
|
41
|
-
}}
|
42
|
-
>
|
43
|
-
{month} {new Date(from).getFullYear()}
|
44
|
-
</div>
|
45
|
-
))}
|
46
|
-
</div>
|
47
|
-
<div style={{ display: 'flex' }}>
|
48
|
-
{days.map(({ day, weekday, month }) => (
|
49
|
-
<div className='day-cell' key={day} style={{ flex: 1, textAlign: 'center', minWidth: dayWidth }}>
|
50
|
-
<div className="weekday">{weekday.substring(0,2)}</div>
|
51
|
-
<div className="daynum">{day}</div>
|
52
|
-
</div>
|
53
|
-
))}
|
54
|
-
</div>
|
55
|
-
</div>
|
56
|
-
);
|
57
|
-
};
|
58
|
-
|
59
|
-
|
60
|
-
const CalendarTest = (props) => {
|
61
|
-
return (
|
62
|
-
<>
|
63
|
-
<Calendar from="2023-01-01" to="2023-03-03" />
|
64
|
-
</>
|
65
|
-
)
|
66
|
-
}
|