Skip to content

Commit

Permalink
Merge branch 'main' into add_full_calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Oct 25, 2024
2 parents fa1fa10 + 26c2e7a commit f5c8482
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
exclude: \.min\.js$
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.7.0
hooks:
- id: ruff
files: panel/
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
- id: oxipng
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.12.0
rev: v9.13.0
hooks:
- id: eslint
args: ['-c', 'panel/.eslintrc.js', 'panel/*.ts', 'panel/models/**/*.ts', '--fix']
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This release fixes a number of smaller regressions related to `Tabulator` `row_c
- Prevent `Tabulator` from overlapping when `max_height` is set ([#7403](https://github.com/holoviz/panel/pull/7403))
- Do not mutate layout `Children` inplace ([#7417](https://github.com/holoviz/panel/pull/7403))
- Set `Tabulator` null formatter to empty string ([#7421](https://github.com/holoviz/panel/pull/7421))
- Ensure Tabulator table content does not overflow ([#7425](https://github.com/holoviz/panel/pull/7425))


### Compatibility

Expand Down
1 change: 1 addition & 0 deletions doc/about/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This release fixes a number of smaller regressions related to `Tabulator` `row_c
- Prevent `Tabulator` from overlapping when `max_height` is set ([#7403](https://github.com/holoviz/panel/pull/7403))
- Do not mutate layout `Children` inplace ([#7417](https://github.com/holoviz/panel/pull/7403))
- Set `Tabulator` null formatter to empty string ([#7421](https://github.com/holoviz/panel/pull/7421))
- Ensure Tabulator table content does not overflow ([#7425](https://github.com/holoviz/panel/pull/7425), [#7431](https://github.com/holoviz/panel/pull/7431))

### Compatibility

Expand Down
5 changes: 5 additions & 0 deletions panel/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,5 +670,10 @@ def invoke(self, args: argparse.Namespace):
# Empty layout are valid and the Bokeh warning is silenced as usually
# not relevant to Panel users.
silence(EMPTY_LAYOUT, True)
# dask.distributed changes the logging level of Bokeh, we will overwrite it
# if the environment variable is not set to the default Bokeh level
# See https://github.com/holoviz/panel/issues/2302
if "DASK_DISTRIBUTED__LOGGING__BOKEH" not in os.environ:
os.environ["DASK_DISTRIBUTED__LOGGING__BOKEH"] = "info"
args.dev = None
super().invoke(args)
3 changes: 2 additions & 1 deletion panel/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,14 @@ def bundle_icons(verbose=False, external=True, download_list=None):
shutil.copyfile(icon, dest_dir / os.path.basename(icon))

def patch_tabulator():
# https://github.com/olifolkerd/tabulator/issues/4421
path = BUNDLE_DIR / 'datatabulator' / 'tabulator-tables@6.3.0' / 'dist' / 'js' / 'tabulator.min.js'
text = path.read_text()
# https://github.com/olifolkerd/tabulator/issues/4421
old = '"focus"!==this.options("editTriggerEvent")&&"click"!==this.options("editTriggerEvent")'
new = '"click"!==this.options("editTriggerEvent")'
assert text.count(old) == 1
text = text.replace(old, new)
# https://github.com/olifolkerd/tabulator/pull/4598
old = '(i=!0,this.subscribed("table-resize")?this.dispatch("table-resize"):this.redraw())'
new = '(i=!0,this.redrawing||(this.redrawing=!0,this.subscribed("table-resize")?this.dispatch("table-resize"):this.redraw(),this.redrawing=!1))'
assert text.count(old) == 1
Expand Down
3 changes: 3 additions & 0 deletions panel/io/jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ async def open(self, path, *args, **kwargs) -> None:
self.session_id = get_session_id(token)
if self.session_id not in state._kernels:
self.close()
msg = f"Session ID '{self.session_id}' does not correspond to any active kernel."
raise RuntimeError(msg)

kernel_info = state._kernels[self.session_id]
self.kernel, self.comm_id, self.kernel_id, _ = kernel_info
state._kernels[self.session_id] = kernel_info[:-1] + (True,)
Expand Down
7 changes: 7 additions & 0 deletions panel/models/tabulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {display, undisplay} from "@bokehjs/core/dom"
import {sum} from "@bokehjs/core/util/arrayable"
import {isArray, isBoolean, isString, isNumber} from "@bokehjs/core/util/types"
import {ModelEvent} from "@bokehjs/core/bokeh_events"
import type {StyleSheetLike} from "@bokehjs/core/dom"
import {div} from "@bokehjs/core/dom"
import {Enum} from "@bokehjs/core/kinds"
import type * as p from "@bokehjs/core/properties"
Expand All @@ -17,6 +18,8 @@ import {transform_cds_to_records} from "./data"
import {HTMLBox, HTMLBoxView} from "./layout"
import {schedule_when} from "./util"

import tabulator_css from "styles/models/tabulator.css"

export class TableEditEvent extends ModelEvent {
constructor(readonly column: string, readonly row: number, readonly pre: boolean) {
super()
Expand Down Expand Up @@ -547,6 +550,10 @@ export class DataTabulatorView extends HTMLBoxView {
this.restore_scroll()
}

override stylesheets(): StyleSheetLike[] {
return [...super.stylesheets(), tabulator_css]
}

setCSSClasses(el: HTMLDivElement): void {
el.className = "pnx-tabulator tabulator"
for (const cls of this.model.theme_classes) {
Expand Down
4 changes: 2 additions & 2 deletions panel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion panel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holoviz/panel",
"version": "1.5.3-b.1",
"version": "1.5.3",
"description": "The powerful data exploration & web app framework for Python.",
"license": "BSD-3-Clause",
"repository": {
Expand Down
30 changes: 23 additions & 7 deletions panel/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,16 +1582,32 @@ def _process_param_change(self, params):
def _set_on_model(self, msg: Mapping[str, Any], root: Model, model: Model) -> None:
if not msg:
return
old = self._changing.get(root.ref['id'], [])
self._changing[root.ref['id']] = [
attr for attr, value in msg.items()
if not model.lookup(attr).property.matches(getattr(model, attr), value)
]
prev_changing = self._changing.get(root.ref['id'], [])
changing = []
transformed = {}
for attr, value in msg.items():
prop = model.lookup(attr).property
old = getattr(model, attr)
try:
matches = bool(prop.matches(old, value))
except Exception:
for tp, converter in prop.alternatives:
if tp.is_valid(value):
value = converter(value)
break
try:
matches = bool(prop.matches(old, value))
except Exception:
matches = False
if not matches:
transformed[attr] = value
changing.append(attr)
self._changing[root.ref['id']] = changing
try:
model.update(**msg)
model.update(**transformed)
finally:
if old:
self._changing[root.ref['id']] = old
self._changing[root.ref['id']] = prev_changing
else:
del self._changing[root.ref['id']]

Expand Down
7 changes: 7 additions & 0 deletions panel/styles/models/tabulator.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.tabulator-table {
max-width: 100%;

.tabulator-row .row-content .bk-panel-models-markup-HTML {
white-space: normal;
}
}
21 changes: 21 additions & 0 deletions panel/tests/test_custom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np
import pandas as pd
import param

from panel.custom import PyComponent, ReactiveESM
Expand Down Expand Up @@ -44,6 +46,25 @@ def test_py_component_cleanup(document, comm):
assert not spy._view__._models


class ESMDataFrame(ReactiveESM):

df = param.DataFrame()


def test_reactive_esm_sync_dataframe(document, comm):
esm_df = ESMDataFrame()

model = esm_df.get_root(document, comm)

esm_df.df = pd.DataFrame({"1": [2]})

assert isinstance(model.data.df, dict)
assert len(model.data.df) == 2
expected = {"index": np.array([0]), "1": np.array([2])}
for col, values in model.data.df.items():
np.testing.assert_array_equal(values, expected.get(col))


class ESMWithChildren(ReactiveESM):

child = param.ClassSelector(class_=Viewable)
Expand Down
15 changes: 15 additions & 0 deletions panel/tests/ui/widgets/test_tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from panel.io.state import state
from panel.layout.base import Column
from panel.models.tabulator import _TABULATOR_THEMES_MAPPING
from panel.pane import Markdown
from panel.tests.util import get_ctrl_modifier, serve_component, wait_until
from panel.util import BOKEH_GE_3_6
from panel.widgets import Select, Tabulator, TextInput
Expand Down Expand Up @@ -4079,3 +4080,17 @@ def test_tabulator_header_tooltips(page):
page.wait_for_timeout(200)

expect(page.locator('.tabulator-tooltip')).to_have_text("Test")


def test_tabulator_row_content_markup_wrap(page):
# https://github.com/holoviz/panel/issues/7388

df = pd.DataFrame({"col": ["foo"]})
long_markdown = Markdown("xxxx " * 50)
widget = Tabulator(df, row_content=lambda row: long_markdown, expanded=[0], width=200)

serve_component(page, widget)

md = page.locator('.row-content .bk-panel-models-markup-HTML')

assert md.bounding_box()['height'] >= 130
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ channels = ["microsoft"]

[feature.test-ui.dependencies]
playwright = { version = "*", channel = "microsoft" }
pytest-playwright = "*"
pytest-playwright = { version = "*", channel = "microsoft" }
pytest-asyncio = "*"
jupyter_server = "*"
esbuild = "*"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ HoloViz = "https://holoviz.org/"
[project.optional-dependencies]
recommended = [
'jupyterlab',
'holoviews >=1.16.0',
'holoviews >=1.18.0',
'matplotlib',
'pillow',
'plotly',
]
fastapi = [
'bokeh-fastapi >= 0.1.0',
'bokeh-fastapi >= 0.1.2',
'fastapi[standard]',
]
dev = [
Expand Down

0 comments on commit f5c8482

Please sign in to comment.