Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/src/components/timetable/TimeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export interface LPTimeTableProps<

/** custom header row */
customHeaderRow?: {
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => JSX.Element
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => React.ReactNode
header: (props: CustomHeaderRowHeaderProps<G, I>) => JSX.Element
}

Expand Down
8 changes: 4 additions & 4 deletions library/src/components/timetable/TimeTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ type TimeTableHeaderProps<

entries: TimeTableEntry<G, I>[]
customHeaderRow?: {
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => JSX.Element
header: (props: CustomHeaderRowHeaderProps<G, I>) => JSX.Element
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => React.ReactNode
header: (props: CustomHeaderRowHeaderProps<G, I>) => React.ReactNode
}

tableHeaderRef: React.Ref<HTMLTableSectionElement>
Expand Down Expand Up @@ -356,8 +356,8 @@ function CustomHeaderRowCell<
slotsArray: readonly Dayjs[]
showTimeSlotHeader: boolean
customHeaderRow: {
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => JSX.Element
header: (props: CustomHeaderRowHeaderProps<G, I>) => JSX.Element
timeSlot: (props: CustomHeaderRowTimeSlotProps<G, I>) => React.ReactNode
header: (props: CustomHeaderRowHeaderProps<G, I>) => React.ReactNode
}
}) {
// this is the same as in the TableCell component
Expand Down
28 changes: 19 additions & 9 deletions showcase/public/showcase-sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7718,7 +7718,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
},
items: [],
},
{
/*{
group: {
id: "group-1",
title: "Group 1",
Expand Down Expand Up @@ -8017,7 +8017,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
title: "Item 7-1",
},
],
},
},*/
]

function createTestItems(
Expand Down Expand Up @@ -8093,8 +8093,8 @@ function createMoreTestGroups(
return newGroups
}

const startDateInitial = dayjs().startOf("day").add(-1, "day").add(8, "hours")
const endDateInitial = dayjs().startOf("day").add(5, "days").add(23, "hours")
const startDateInitial = dayjs().startOf("day").add(-1, "day")
const endDateInitial = dayjs().startOf("day").add(6, "days")

function TestCustomHeaderRowTimeSlot<
G extends TimeTableTypes.TimeTableGroup,
Expand All @@ -8109,10 +8109,13 @@ function TestCustomHeaderRowTimeSlot<
entries,
tableCellRef,
}: TimeTableTypes.CustomHeaderRowTimeSlotProps<G, I>) {
const groupItems = entries[1].items
const groupItems = entries[0].items
if (!groupItems.length) {
return null
}

const groupItemsOfCell: I[] = []
const startAndEndInSlow: {
const startAndEndInSlot: {
status: "in" | "before" | "after"
startSlot: number
endSlot: number
Expand All @@ -8128,12 +8131,15 @@ function TestCustomHeaderRowTimeSlot<
)
if (slotsArray[startAndEnd.startSlot] === timeSlot) {
groupItemsOfCell.push(item)
startAndEndInSlow.push(startAndEnd)
startAndEndInSlot.push(startAndEnd)
}
}
if (!groupItemsOfCell.length) {
return null
}

const leftAndWidths = groupItemsOfCell.map((it, i) => {
const startAndEnd = startAndEndInSlow[i]
const startAndEnd = startAndEndInSlot[i]
if (startAndEnd.status === "before" || startAndEnd.status === "after") {
return null
}
Expand All @@ -8148,6 +8154,10 @@ function TestCustomHeaderRowTimeSlot<
)
})

if (entries[0].items.length) {
console.log("LEFT", entries[0].items, leftAndWidths, startAndEndInSlot)
}

const cellWidth = tableCellRef.current?.offsetWidth ?? 70

const ret = leftAndWidths.map((it, i) =>
Expand Down Expand Up @@ -8180,7 +8190,7 @@ function CustomHeaderRowHeader<
}: TimeTableTypes.CustomHeaderRowHeaderProps<G, I>) {
return (
<div className="bg-surface-pressed">
{entries[1].group.title} has {entries.length} entries
{entries[0].group.title} has {entries.length} entries
</div>
)
}
Expand Down
16 changes: 6 additions & 10 deletions showcase/src/components/showcase/wrapper/TimeTableShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
},
items: [],
},
/*{
{
group: {
id: "group-1",
title: "Group 1",
Expand Down Expand Up @@ -343,7 +343,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
title: "Item 7-1",
},
],
},*/
},
]

function createTestItems(
Expand Down Expand Up @@ -435,7 +435,7 @@ function TestCustomHeaderRowTimeSlot<
entries,
tableCellRef,
}: TimeTableTypes.CustomHeaderRowTimeSlotProps<G, I>) {
const groupItems = entries[0].items
const groupItems = entries[1].items
if (!groupItems.length) {
return null
}
Expand Down Expand Up @@ -480,10 +480,6 @@ function TestCustomHeaderRowTimeSlot<
)
})

if (entries[0].items.length) {
console.log("LEFT", entries[0].items, leftAndWidths, startAndEndInSlot)
}

const cellWidth = tableCellRef.current?.offsetWidth ?? 70

const ret = leftAndWidths.map((it, i) =>
Expand Down Expand Up @@ -516,7 +512,7 @@ function CustomHeaderRowHeader<
}: TimeTableTypes.CustomHeaderRowHeaderProps<G, I>) {
return (
<div className="bg-surface-pressed">
{entries[0].group.title} has {entries.length} entries
{entries[1].group.title} has {entries.length} entries
</div>
)
}
Expand Down Expand Up @@ -657,7 +653,6 @@ function Example() {
)

useEffect(() => {
/*requestMoreEntriesCB()
requestMoreEntriesCB()
requestMoreEntriesCB()
requestMoreEntriesCB()
Expand All @@ -669,7 +664,8 @@ function Example() {
requestMoreEntriesCB()
requestMoreEntriesCB()
requestMoreEntriesCB()
requestMoreEntriesCB()*/
requestMoreEntriesCB()
requestMoreEntriesCB()
/*requestMoreEntriesCB()
requestMoreEntriesCB()
requestMoreEntriesCB()
Expand Down