@mintplayer/react-bootstrap 19.21.0 → 19.22.0
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/datatable/index.mjs +14 -6
- package/datatable/src/BsDatatable.d.ts +37 -3
- package/package.json +2 -2
package/datatable/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
1
2
|
import * as a from "react";
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { MpDatatable as
|
|
4
|
-
const
|
|
3
|
+
import { createComponent as r } from "@lit/react";
|
|
4
|
+
import { MpDatatable as p } from "@mintplayer/web-components/datatable";
|
|
5
|
+
const m = r({
|
|
5
6
|
react: a,
|
|
6
7
|
tagName: "mp-datatable",
|
|
7
|
-
elementClass:
|
|
8
|
+
elementClass: p,
|
|
8
9
|
events: {
|
|
9
10
|
onPageChange: "mp-datatable-page-change",
|
|
10
11
|
onPerPageChange: "mp-datatable-per-page-change",
|
|
@@ -20,7 +21,14 @@ const l = e({
|
|
|
20
21
|
onFilterClose: "mp-datatable-filter-close",
|
|
21
22
|
onFilterChange: "mp-datatable-filter-change"
|
|
22
23
|
}
|
|
23
|
-
})
|
|
24
|
+
}), s = a.forwardRef(
|
|
25
|
+
function({ selectedRows: t, ...n }, o) {
|
|
26
|
+
const e = a.useRef(null);
|
|
27
|
+
return a.useImperativeHandle(o, () => e.current), a.useLayoutEffect(() => {
|
|
28
|
+
e.current && t !== void 0 && (e.current.selectedRows = t);
|
|
29
|
+
}, [t]), /* @__PURE__ */ l(m, { ref: e, ...n });
|
|
30
|
+
}
|
|
31
|
+
);
|
|
24
32
|
export {
|
|
25
|
-
|
|
33
|
+
s as BsDatatable
|
|
26
34
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventName } from '@lit/react';
|
|
2
2
|
import { MpDatatable, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, TreeRowExpandDetail, TreeExpandedIdsChangeDetail, FilterChangeDetail } from '@mintplayer/web-components/datatable';
|
|
3
|
+
import * as React from 'react';
|
|
3
4
|
/**
|
|
4
5
|
* React wrapper for `<mp-datatable>`. Side-effect-registers the WC via
|
|
5
6
|
* the import above. The `events` map surfaces each CustomEvent the WC
|
|
@@ -15,8 +16,27 @@ import { MpDatatable, RowEventDetail, SortChangeEventDetail, SelectionChangeEven
|
|
|
15
16
|
* `{ data, totalRecords }`. `createComponent` forwards it to the element's
|
|
16
17
|
* `fetch` property, and the web component owns the whole loop — initial page,
|
|
17
18
|
* on-demand windows, tree children, pagination, sort/perPage reloads. The
|
|
18
|
-
* consumer wires nothing else (no `totalRecords`, no event bridge).
|
|
19
|
-
*
|
|
19
|
+
* consumer wires nothing else (no `totalRecords`, no event bridge). To
|
|
20
|
+
* re-query with an unchanged callback, call `reload({ resetPage? })` on the
|
|
21
|
+
* element ref; `applyFetchState({ fetch, sortColumns, page, perPage })` applies
|
|
22
|
+
* several of those as one change (one request). Pass a stable `fetch`
|
|
23
|
+
* (`useCallback`): a new function is a new source and reloads.
|
|
24
|
+
*
|
|
25
|
+
* Selection: `selectionMode` is `'none' | 'single' | 'multiple' | 'checkbox'`
|
|
26
|
+
* (`'checkbox'` selects only through the checkbox column; a row click just
|
|
27
|
+
* opens the row). Act on `onSelectionChange`'s `detail.selectedIds` — it is
|
|
28
|
+
* authoritative and holds every selected key, across pages. `detail.selectedRows`
|
|
29
|
+
* is index-aligned with it and covers every key whose row the element has ever
|
|
30
|
+
* seen, off-page rows included; it is `undefined` where a key's row was never
|
|
31
|
+
* seen, so narrow before use. The `selectedRows` prop REPLACES the selection
|
|
32
|
+
* with the given rows (keys derived through `rowKey`, rows remembered even
|
|
33
|
+
* when not loaded) and emits no event; it is pushed when its reference changes,
|
|
34
|
+
* never on an unrelated re-render. **Memoise it** (`useMemo`, or state): an
|
|
35
|
+
* inline literal such as `selectedRows={[row]}` is a new array on every render,
|
|
36
|
+
* so every render pushes it again and reverts the user's clicks. `rowKey` is
|
|
37
|
+
* required to be stable too (an id-less row that is not loaded is keyed
|
|
38
|
+
* `rowKey(row, -1)`, so they all collapse onto `row--1`). `rowLabel: (row) => string` names each
|
|
39
|
+
* row's checkbox ("Select {label}"); it defaults to the first cell's text.
|
|
20
40
|
*
|
|
21
41
|
* Filtering: mark a column `filterable` and it gets the built-in panel — search,
|
|
22
42
|
* include/exclude, checkbox list, clear — with no wrapper code, because the
|
|
@@ -26,7 +46,7 @@ import { MpDatatable, RowEventDetail, SortChangeEventDetail, SelectionChangeEven
|
|
|
26
46
|
* entirely, and must return a STABLE node: it is mounted once per open, and
|
|
27
47
|
* repainting it is the renderer's job via `context.onChange`.
|
|
28
48
|
*/
|
|
29
|
-
|
|
49
|
+
declare const BsDatatableElement: import('@lit/react').ReactWebComponent<MpDatatable, {
|
|
30
50
|
onPageChange: EventName<CustomEvent<{
|
|
31
51
|
page: number;
|
|
32
52
|
}>>;
|
|
@@ -49,3 +69,17 @@ export declare const BsDatatable: import('@lit/react').ReactWebComponent<MpDatat
|
|
|
49
69
|
}>>;
|
|
50
70
|
onFilterChange: EventName<CustomEvent<FilterChangeDetail>>;
|
|
51
71
|
}>;
|
|
72
|
+
export type BsDatatableProps = Omit<React.ComponentProps<typeof BsDatatableElement>, 'ref'>;
|
|
73
|
+
/**
|
|
74
|
+
* `createComponent` re-assigns every element property on every render (it
|
|
75
|
+
* leaves dirty-checking to the element). That is harmless for every prop but
|
|
76
|
+
* `selectedRows`, whose setter REPLACES the selection: an unrelated re-render
|
|
77
|
+
* would revert the user's clicks to the stale prop. So `selectedRows` is held
|
|
78
|
+
* back and pushed only when its own reference changes (as the Vue wrapper does).
|
|
79
|
+
* That only helps a MEMOISED array: an inline `selectedRows={[row]}` is a new
|
|
80
|
+
* reference on every render and still reverts clicks.
|
|
81
|
+
* The effect runs after the inner element's, so `rowKey` and `data` are set
|
|
82
|
+
* before the keys are derived.
|
|
83
|
+
*/
|
|
84
|
+
export declare const BsDatatable: React.ForwardRefExoticComponent<BsDatatableProps & React.RefAttributes<MpDatatable>>;
|
|
85
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/react-bootstrap",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.22.0",
|
|
4
4
|
"description": "React 19 wrappers around @mintplayer/web-components. Each sub-entry maps one-to-one with a WC sub-entry and exposes typed React components via @lit/react's createComponent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
"react": "^19.0.0",
|
|
184
184
|
"react-dom": "^19.0.0",
|
|
185
185
|
"@lit/react": "^1.0.0",
|
|
186
|
-
"@mintplayer/web-components": "^2.
|
|
186
|
+
"@mintplayer/web-components": "^2.18.0"
|
|
187
187
|
},
|
|
188
188
|
"dependencies": {
|
|
189
189
|
"tslib": "^2.3.0"
|