ywana-core8 0.1.11 → 0.1.13
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 +70 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +70 -27
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +70 -27
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/TablePage2.js +14 -3
- package/src/incubator/planner.css +5 -0
- package/src/incubator/planner.js +36 -20
- package/src/site/site.css +2 -0
package/package.json
CHANGED
package/src/domain/TablePage2.js
CHANGED
@@ -27,6 +27,7 @@ export const TablePage2 = (props) => {
|
|
27
27
|
groupBy, validator,
|
28
28
|
formFilter, tableFilter, editorFilter = false,
|
29
29
|
tabbedBy,
|
30
|
+
sortedBy,
|
30
31
|
tableClassName,
|
31
32
|
children,
|
32
33
|
onSelect,
|
@@ -139,7 +140,7 @@ export const TablePage2 = (props) => {
|
|
139
140
|
</menu>
|
140
141
|
) : null}
|
141
142
|
<main key={id} className={`table-page ${className}`}>
|
142
|
-
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} tabbedBy={tabbedBy} groupBy={groupBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} className={tableClassName} />
|
143
|
+
<TableEditor icon={icon} title={name} schema={schema} delay={delay} editable={editable} tabbedBy={tabbedBy} groupBy={groupBy} sortedBy={sortedBy} filter={tableFilter} actions={tableActions} canDelete={canDelete} className={tableClassName} />
|
143
144
|
{children ? <article>{children}</article> : null}
|
144
145
|
</main>
|
145
146
|
{renderAside()}
|
@@ -331,7 +332,7 @@ export const TableEditor = (props) => {
|
|
331
332
|
const site = useContext(SiteContext)
|
332
333
|
const [pageContext, setPageContext] = useContext(PageContext)
|
333
334
|
const { all = [], filters } = pageContext
|
334
|
-
const { icon, title, schema, editable, canDelete, filter, actions, className, tabbedBy } = props
|
335
|
+
const { icon, title, schema, editable, canDelete, filter, actions, className, tabbedBy, sortedBy } = props
|
335
336
|
const [groupBy, setGroupBy] = useState(props.groupBy)
|
336
337
|
const [tab, setTab] = useState(0)
|
337
338
|
|
@@ -456,7 +457,7 @@ export const TableEditor = (props) => {
|
|
456
457
|
return groups
|
457
458
|
}, {})
|
458
459
|
|
459
|
-
const sections = Object.keys(groups).map(groupName => {
|
460
|
+
const sections = Object.keys(groups).sort().map(groupName => {
|
460
461
|
|
461
462
|
const rows = groups[groupName].map(item => {
|
462
463
|
item.checked = pageContext.checked ? pageContext.checked.has(item.id) : false
|
@@ -469,6 +470,16 @@ export const TableEditor = (props) => {
|
|
469
470
|
return item
|
470
471
|
})
|
471
472
|
|
473
|
+
if (sortedBy) {
|
474
|
+
rows.sort((a, b) => {
|
475
|
+
const valueA = a[sortedBy]
|
476
|
+
const valueB = b[sortedBy]
|
477
|
+
if (valueA < valueB) return -1
|
478
|
+
if (valueA > valueB) return 1
|
479
|
+
return 0
|
480
|
+
})
|
481
|
+
}
|
482
|
+
|
472
483
|
table.rows = rows
|
473
484
|
|
474
485
|
return ({
|
package/src/incubator/planner.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
2
2
|
import "./planner.css"
|
3
3
|
|
4
|
-
export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, rowHeaderWidth = 10, rowHeaderTitle, EventRenderer, onSelectCell, hideEmptyRows=false}) => {
|
4
|
+
export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, rowHeaderWidth = 10, rowHeaderTitle, EventRenderer, onSelectCell, onCellDrop, hideEmptyRows=false}) => {
|
5
5
|
|
6
6
|
const [days, setDays] = useState([]);
|
7
7
|
const lastDay = new Date(to);
|
8
8
|
const today = new Date();
|
9
|
+
const [dragOverCell, setDragOverCell] = useState(null);
|
9
10
|
|
10
11
|
useEffect(() => {
|
11
12
|
const day = new Date(from);
|
@@ -41,10 +42,24 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
41
42
|
if (onSelectCell) onSelectCell(cell)
|
42
43
|
}
|
43
44
|
|
44
|
-
function
|
45
|
-
|
45
|
+
function onDragOver(event) {
|
46
|
+
event.preventDefault();
|
47
|
+
setDragOverCell(event.target.id);
|
46
48
|
}
|
47
49
|
|
50
|
+
function onDragLeave(event) {
|
51
|
+
event.preventDefault();
|
52
|
+
setDragOverCell(null);
|
53
|
+
}
|
54
|
+
|
55
|
+
function drop(event, { lane, date }) {
|
56
|
+
event.preventDefault();
|
57
|
+
const data = event.dataTransfer.getData("text");
|
58
|
+
if (onCellDrop) onCellDrop({ data, lane, date });
|
59
|
+
setDragOverCell(null);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
48
63
|
const uniqueMonths = Array.from(
|
49
64
|
new Set(days.map(({ month }) => month))
|
50
65
|
);
|
@@ -119,7 +134,9 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
119
134
|
}
|
120
135
|
|
121
136
|
return (
|
122
|
-
<div
|
137
|
+
<div
|
138
|
+
key={`content-row-${index}`}
|
139
|
+
className={`content-row ${lane.className}`} style={{ width: `${totalDaysWidth}rem` }}>
|
123
140
|
<div className="row-header" style={{ minWidth: `${rowHeaderWidth}rem`, maxWidth: `${rowHeaderWidth}rem` }} >
|
124
141
|
{lane.title}
|
125
142
|
</div>
|
@@ -132,12 +149,15 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
132
149
|
eventDate.getFullYear() === dayDate.getFullYear();
|
133
150
|
});
|
134
151
|
const weekendClass = isWeekend ? 'weekend' : '';
|
152
|
+
const dragOverStyle = dragOverCell === `cell${index}_${year}-${month}-${day}` ? 'drag-over' : '';
|
135
153
|
return (
|
136
154
|
<div
|
155
|
+
id={`cell${index}_${year}-${month}-${day}`}
|
137
156
|
key={`content${index}_${year}-${month}-${day}`}
|
138
|
-
className={`content-cell ${weekendClass}`} style={{ minWidth: dayWidth, maxWidth: dayWidth }}
|
157
|
+
className={`content-cell ${weekendClass} ${dragOverStyle}`} style={{ minWidth: dayWidth, maxWidth: dayWidth }}
|
139
158
|
onClick={() => selectCell({ lane: lane.id, date: dayDate })}
|
140
|
-
|
159
|
+
onDragOver={onDragOver} onDragLeave={onDragLeave}
|
160
|
+
onDrop={(event) => drop(event, { lane: lane.id, date: dayDate })}
|
141
161
|
>
|
142
162
|
{dayEvents.map((event, index) => <EventRenderer key={`${event.id}-${index}`} event={event} />)}
|
143
163
|
</div>
|
@@ -155,7 +175,7 @@ const EventCard = (props) => {
|
|
155
175
|
const { id, title, color } = event
|
156
176
|
|
157
177
|
function drag(ev) {
|
158
|
-
ev.dataTransfer.setData("text",
|
178
|
+
ev.dataTransfer.setData("text", title);
|
159
179
|
}
|
160
180
|
|
161
181
|
let style = { backgroundColor: event.color, color: "white" }
|
@@ -181,23 +201,19 @@ const CalendarTest = (props) => {
|
|
181
201
|
|
182
202
|
const events = [
|
183
203
|
{ id: "1", lane: "1", date: "2024-01-04", color: "yellow", title: "Event One" },
|
184
|
-
{ id: "
|
185
|
-
{ id: "
|
186
|
-
{ id: "
|
187
|
-
{ id: "
|
188
|
-
{ id: "4", lane: "1", date: "2024-01-05", color: "red", title: "Event One" },
|
189
|
-
{ id: "5", lane: "2", date: "2024-01-04", color: "yellow", title: "Event One" },
|
190
|
-
{ id: "6", lane: "2", date: "2024-01-05", color: "red", title: "Event One" },
|
191
|
-
{ id: "7", lane: "2", date: "2024-01-06", color: "blue", title: "Event One" },
|
192
|
-
{ id: "8", lane: "2", date: "2024-01-07", color: "red", title: "Event One" },
|
193
|
-
{ id: "9", lane: "3", date: "2024-01-04", color: "yellow", title: "Event One" },
|
194
|
-
{ id: "10", lane: "3", date: "2024-01-05", color: "red", title: "Event One" },
|
195
|
-
{ id: "11", lane: "3", date: "2024-01-06", color: "blue", title: "Event One" },
|
204
|
+
{ id: "2", lane: "1", date: "2024-01-05", color: "green", title: "Event Two" },
|
205
|
+
{ id: "3", lane: "2", date: "2024-01-06", color: "blue", title: "Event Three" },
|
206
|
+
{ id: "4", lane: "2", date: "2024-01-07", color: "red", title: "Event Four" },
|
207
|
+
{ id: "5", lane: "3", date: "2024-01-08", color: "purple", title: "Event Five" },
|
196
208
|
]
|
197
209
|
|
210
|
+
function onDrop({ data, lane, date }) {
|
211
|
+
console.log(`Dropped ${data} on lane ${lane} date ${date}`);
|
212
|
+
}
|
213
|
+
|
198
214
|
return (
|
199
215
|
<>
|
200
|
-
<Planner2 from="2024-01-01" to="2024-02-01" lanes={lanes} events={events} EventRenderer={EventCard} hideEmptyRows />
|
216
|
+
<Planner2 from="2024-01-01" to="2024-02-01" lanes={lanes} events={events} EventRenderer={EventCard} hideEmptyRows onCellDrop={onDrop} />
|
201
217
|
</>
|
202
218
|
)
|
203
219
|
}
|
package/src/site/site.css
CHANGED
@@ -42,6 +42,7 @@
|
|
42
42
|
flex-direction: column;
|
43
43
|
overflow: hidden;
|
44
44
|
width: var(--site-menu-width);
|
45
|
+
transition: width 0.3s ease-in-out;
|
45
46
|
}
|
46
47
|
|
47
48
|
.site6>menu>header {
|
@@ -53,6 +54,7 @@
|
|
53
54
|
}
|
54
55
|
|
55
56
|
.site6>menu.min {
|
57
|
+
width: var(--site-menu-width);
|
56
58
|
overflow: visible;
|
57
59
|
}
|
58
60
|
|