Skip to content

Commit

Permalink
Update Tabulator to 6.2.1 (holoviz#6840)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jun 10, 2024
1 parent 68749eb commit 681ddc9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
12 changes: 12 additions & 0 deletions panel/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def bundle_icons(verbose=False, external=True, download_list=None):
for icon in glob.glob(str(icon_dir / '*')):
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.2.1' / 'dist' / 'js' / 'tabulator.min.js'
text = path.read_text()
old = '"focus"!==this.options("editTriggerEvent")&&"click"!==this.options("editTriggerEvent")'
new = '"click"!==this.options("editTriggerEvent")'
assert text.count(old) == 1
text = text.replace(old, new)
path.write_text(text)

def bundle_resources(verbose=False, external=True):
download_list = []
bundle_resource_urls(verbose=verbose, external=external, download_list=download_list)
Expand All @@ -363,3 +373,5 @@ def bundle_resources(verbose=False, external=True):
for future in futures:
if future:
future.result()

patch_tabulator()
2 changes: 1 addition & 1 deletion panel/models/tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..util import classproperty
from .layout import HTMLBox

TABULATOR_VERSION = "5.5.0"
TABULATOR_VERSION = "6.2.1"

JS_SRC = f"{config.npm_cdn}/tabulator-tables@{TABULATOR_VERSION}/dist/js/tabulator.min.js"
MOMENT_SRC = f"{config.npm_cdn}/luxon/build/global/luxon.min.js"
Expand Down
6 changes: 3 additions & 3 deletions panel/models/tabulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export class DataTabulatorView extends HTMLBoxView {
this.tabulator.on("tableBuilt", () => this.tableBuilt())

// Rendering callbacks
this.tabulator.on("selectableCheck", (row: any) => {
this.tabulator.on("selectableRowsCheck", (row: any) => {
const selectable = this.model.selectable_rows
return (selectable == null) || selectable.includes(row._row.data._index)
})
Expand Down Expand Up @@ -652,13 +652,13 @@ export class DataTabulatorView extends HTMLBoxView {

getConfiguration(): any {
// Only use selectable mode if explicitly requested otherwise manually handle selections
const selectable = this.model.select_mode === "toggle" ? true : NaN
const selectableRows = this.model.select_mode === "toggle" ? true : NaN
const configuration = {
...this.model.configuration,
index: "_index",
nestedFieldSeparator: false,
movableColumns: false,
selectable,
selectableRows,
columns: this.getColumns(),
initialSort: this.sorters,
layout: this.getLayout(),
Expand Down
20 changes: 11 additions & 9 deletions panel/tests/io/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
resolve_stylesheet, set_resource_mode,
)
from panel.io.state import set_curdoc
from panel.models.tabulator import TABULATOR_VERSION
from panel.theme.native import Native
from panel.widgets import Button

Expand Down Expand Up @@ -84,11 +85,11 @@ def test_resources_model_server(document):
with set_curdoc(document):
extension('tabulator')
assert resources.js_files[:2] == [
'static/extensions/panel/bundled/datatabulator/tabulator-tables@5.5.0/dist/js/tabulator.min.js',
f'static/extensions/panel/bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/js/tabulator.min.js',
'static/extensions/panel/bundled/datatabulator/luxon/build/global/luxon.min.js',
]
assert resources.css_files == [
f'static/extensions/panel/bundled/datatabulator/tabulator-tables@5.5.0/dist/css/tabulator_simple.min.css?v={JS_VERSION}'
f'static/extensions/panel/bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/css/tabulator_simple.min.css?v={JS_VERSION}'
]

def test_resources_model_cdn(document):
Expand All @@ -97,25 +98,26 @@ def test_resources_model_cdn(document):
with set_curdoc(document):
extension('tabulator')
assert resources.js_files[:2] == [
f'{CDN_DIST}bundled/datatabulator/tabulator-tables@5.5.0/dist/js/tabulator.min.js',
f'{CDN_DIST}bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/js/tabulator.min.js',
f'{CDN_DIST}bundled/datatabulator/luxon/build/global/luxon.min.js',
]
assert resources.css_files == [
f'{CDN_DIST}bundled/datatabulator/tabulator-tables@5.5.0/dist/css/tabulator_simple.min.css?v={JS_VERSION}'
f'{CDN_DIST}bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/css/tabulator_simple.min.css?v={JS_VERSION}'
]

def test_resources_model_inline(document):
resources = Resources(mode='inline')
with set_resource_mode('inline'):
with set_curdoc(document):
extension('tabulator')
tabulator_jsfile = f'bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/js/tabulator.min.js'
luxon_jsfile = 'bundled/datatabulator/luxon/build/global/luxon.min.js'
tabulator_cssfile = f'bundled/datatabulator/tabulator-tables@{TABULATOR_VERSION}/dist/css/tabulator_simple.min.css'
assert resources.js_raw[-2:] == [
(DIST_DIR / 'bundled/datatabulator/tabulator-tables@5.5.0/dist/js/tabulator.min.js').read_text(encoding='utf-8'),
(DIST_DIR / 'bundled/datatabulator/luxon/build/global/luxon.min.js').read_text(encoding='utf-8')
]
assert resources.css_raw == [
(DIST_DIR / 'bundled/datatabulator/tabulator-tables@5.5.0/dist/css/tabulator_simple.min.css').read_text(encoding='utf-8')
(DIST_DIR / tabulator_jsfile).read_text(encoding='utf-8'),
(DIST_DIR / luxon_jsfile).read_text(encoding='utf-8'),
]
assert resources.css_raw == [(DIST_DIR / tabulator_cssfile).read_text(encoding='utf-8')]

def test_resources_reactive_html_server(document):
resources = Resources(mode='server')
Expand Down

0 comments on commit 681ddc9

Please sign in to comment.