Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding full calendar #7356

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
019f015
start adding full calendar
ahuang11 Oct 3, 2024
458f8ed
add many view parrams
ahuang11 Oct 4, 2024
8687fe1
lint
ahuang11 Oct 4, 2024
47851cc
Update CHANGELOG
philippjfr Oct 3, 2024
d1a754f
Bump panel.js version to 1.5.2
philippjfr Oct 3, 2024
ca45454
chore: Update pre-commit (#7366)
hoxbro Oct 7, 2024
827fe64
Corrected styles in doc (#7371)
chryshumble Oct 8, 2024
2309bfe
Prevent pipeline network plot from linking with other plots (#7372)
TheoMathurin Oct 8, 2024
63f2d8d
docs: Update nested tabulator example (#7379)
hoxbro Oct 9, 2024
417e325
Bump django from 3.2.25 to 4.2.16 in /examples/apps/django_multi_apps…
dependabot[bot] Oct 9, 2024
3260b7e
ci: Update pixi channels (#7378)
hoxbro Oct 9, 2024
a172064
Fix oauth guest endpoint (#7385)
aktech Oct 10, 2024
ef5d0be
Fix type hint for `oauth_guest_endpoints` (#7383)
aktech Oct 10, 2024
2986f18
fix import map typing (#7392)
MarcSkovMadsen Oct 13, 2024
ae110a5
Ensure that autoreload records modules to watch before startup (#7399)
philippjfr Oct 14, 2024
2454da9
Various fixes for custom component compilation (#7381)
philippjfr Oct 15, 2024
c69b81d
Address issues with Tabulator embed_content and optimize row expansio…
philippjfr Oct 15, 2024
8bb20b8
Update components_overview.md with text fixes (#7335)
Coderambling Oct 15, 2024
2b981da
Prevent tabulator from overlapping when max_height is set (#7403)
ahuang11 Oct 15, 2024
e01e53e
docs: fix typo in panel.io.server docstring (#7405)
haojungc Oct 16, 2024
0f3f98d
Sync dark mode on browser_info object (#7382)
philippjfr Oct 16, 2024
6c3a9ce
Allow loading ESM bundles from URL (#7410)
philippjfr Oct 17, 2024
4fbf361
Only attempt loading ESM bundles from URL when running server (#7412)
philippjfr Oct 17, 2024
01529d6
Add CHANGELOG for 1.5.3 (#7409)
philippjfr Oct 17, 2024
7cb5436
Bump panel.js version to 1.5.3-a.1
philippjfr Oct 17, 2024
7ee8cd6
Add test (#7418)
philippjfr Oct 18, 2024
c931756
Bump Tabulator version to 6.3 (#7419)
philippjfr Oct 18, 2024
cc3ecc1
Set table null formatter to empty string (#7421)
philippjfr Oct 18, 2024
4c56f74
Bump django from 3.2.25 to 4.2.16 in /examples/apps/django (#7413)
dependabot[bot] Oct 18, 2024
5efff82
Do not mutate Children inplace (#7417)
philippjfr Oct 18, 2024
516b9e0
Update CHANGELOG for 1.5.3b1
philippjfr Oct 18, 2024
9237b13
Bump panel.js version to 1.5.3-b.1
philippjfr Oct 18, 2024
c509a44
add docstrings, allow triggering views, bugfixes
ahuang11 Oct 18, 2024
2ce0c19
Merge branch 'main' into add_full_calendar
ahuang11 Oct 18, 2024
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
104 changes: 104 additions & 0 deletions panel/models/fullcalendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import {Calendar} from "@fullcalendar/core"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I don't believe this component is "core" Panel. Optimally this would be in a separate package like panel-mermaid.

It increases the complexity of the Panel project. And the download size which is important in for example Pyodide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If loading plugins dynamically means loading modules dynamically then

I meant part of the compilation.

Is 136 KBs significant?
https://bundlephobia.com/package/@fullcalendar/core@6.1.15

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not the js I'm "worried" about. Its the panel python package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also leaning towards splitting this out. That said:

And the download size which is important in for example Pyodide

Pyodide bundles do not and will not ship with the JS bundles.

Copy link
Member

@philippjfr philippjfr Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess many people will get Panel directly from PyPI in pyodide. We probably should finally figure out how to split that package, so panel/dist is shipped separately. For backward compatibility we'd probably have to create a new package called panel-core and then make panel a metapackage that depends on panel-core and additionally ships panel/dist.


export function render({model, el}) {
function createCalendar(plugins) {
const calendar = new Calendar(el, {
businessHours: model.business_hours,
buttonIcons: model.button_icons,
buttonText: model.button_text,
contentHeight: model.content_height,
dateIncrement: model.date_increment,
events: model.value,
expandRows: model.expand_rows,
footerToolbar: model.footer_toolbar,
handleWindowResize: model.handle_window_resize,
headerToolbar: model.header_toolbar,
initialView: model.current_view,
navLinks: model.nav_links,
nowIndicator: model.now_indicator,
plugins,
showNonCurrentDates: model.show_non_current_dates,
stickyFooterScrollbar: model.sticky_footer_scrollbar,
stickyHeaderDates: model.sticky_header_dates,
titleFormat: model.title_format,
titleRangeSeparator: model.title_range_separator,
validRange: model.valid_range,
windowResizeDelay: model.window_resize_delay,
datesSet(info) {
model.send_msg({current_date: calendar.getDate().toISOString()})
},
viewClassNames(info) {
model.send_msg({current_view: info.view.type})
},
navLinkDayClick(date, jsEvent) {
calendar.changeView("timeGridDay", date)
},
navLinkWeekClick(weekStart, jsEvent) {
},
})

// there's initialDate, but if it's set, there's buggy behavior on re-renders
if (model.current_date) {
calendar.gotoDate(model.current_date)
}

// these cannot be set in the constructor if null
if (model.dateAlignment) {
calendar.setOption("dateAlignment", model.dateAlignment)
}

if (model.current_view == "multiMonth") {
calendar.setOption("multiMonthMaxColumns", model.multi_month_max_columns)
}

if (model.aspect_ratio) {
calendar.setOption("aspectRatio", model.aspect_ratio)
}

model.on("msg:custom", (event) => {
if (event.type === "next") {
calendar.next()
} else if (event.type === "prev") {
calendar.prev()
} else if (event.type === "prevYear") {
calendar.prevYear()
} else if (event.type === "nextYear") {
calendar.nextYear()
} else if (event.type === "today") {
calendar.today()
} else if (event.type === "gotoDate") {
calendar.gotoDate(event.date)
} else if (event.type === "incrementDate") {
calendar.incrementDate(event.increment)
} else if (event.type === "updateOption") {
calendar.setOption(event.key, event.value)
} else if (event.type === "changeView") {
calendar.changeView(event.view, event.date)
}
})
calendar.render()
}

const plugins = []
function loadPluginIfNeeded(viewName, pluginName) {
if (model.current_view.startsWith(viewName) ||
(model.header_toolbar && Object.values(model.header_toolbar).some(v => v.includes(viewName))) ||
(model.footer_toolbar && Object.values(model.footer_toolbar).some(v => v.includes(viewName)))) {
return import(`@fullcalendar/${pluginName}`).then(plugin => {
plugins.push(plugin.default)
return plugin.default
})
}
return Promise.resolve(null)
}

Promise.all([
loadPluginIfNeeded("dayGrid", "daygrid"),
loadPluginIfNeeded("timeGrid", "timegrid"),
loadPluginIfNeeded("list", "list"),
loadPluginIfNeeded("multiMonth", "multimonth"),
]).then(loadedPlugins => {
const filteredPlugins = loadedPlugins.filter(plugin => plugin !== null)
createCalendar(filteredPlugins)
})
}
2 changes: 2 additions & 0 deletions panel/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"""
from .base import CompositeWidget, Widget, WidgetBase # noqa
from .button import Button, MenuButton, Toggle # noqa
from .calendar import Calendar # noqa
from .codeeditor import CodeEditor # noqa
from .debugger import Debugger # noqa
from .file_selector import FileSelector # noqa
Expand Down Expand Up @@ -74,6 +75,7 @@
"BooleanStatus",
"Button",
"ButtonIcon",
"Calendar",
"Checkbox",
"CheckBoxGroup",
"CheckButtonGroup",
Expand Down
Loading
Loading