griddle-effect 0.0.0-stage → 2.0.0-alpha.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/LICENSE +21 -0
- package/README.md +34 -2
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/dist/compose.d.ts +58 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +144 -0
- package/dist/compose.js.map +1 -0
- package/dist/core/actions.d.ts +31 -0
- package/dist/core/actions.d.ts.map +1 -0
- package/dist/core/actions.js +28 -0
- package/dist/core/actions.js.map +1 -0
- package/dist/core/math.d.ts +42 -0
- package/dist/core/math.d.ts.map +1 -0
- package/dist/core/math.js +76 -0
- package/dist/core/math.js.map +1 -0
- package/dist/core/plugin.d.ts +8 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/plugin.js +131 -0
- package/dist/core/plugin.js.map +1 -0
- package/dist/core/state.d.ts +88 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/state.js +69 -0
- package/dist/core/state.js.map +1 -0
- package/dist/definition.d.ts +61 -0
- package/dist/definition.d.ts.map +1 -0
- package/dist/definition.js +63 -0
- package/dist/definition.js.map +1 -0
- package/dist/headless.d.ts +26 -0
- package/dist/headless.d.ts.map +1 -0
- package/dist/headless.js +35 -0
- package/dist/headless.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +136 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/local.d.ts +7 -0
- package/dist/plugins/local.d.ts.map +1 -0
- package/dist/plugins/local.js +26 -0
- package/dist/plugins/local.js.map +1 -0
- package/dist/plugins/virtual.d.ts +19 -0
- package/dist/plugins/virtual.d.ts.map +1 -0
- package/dist/plugins/virtual.js +42 -0
- package/dist/plugins/virtual.js.map +1 -0
- package/dist/store.d.ts +41 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +57 -0
- package/dist/store.js.map +1 -0
- package/dist/ui/Griddle.d.ts +198 -0
- package/dist/ui/Griddle.d.ts.map +1 -0
- package/dist/ui/Griddle.js +66 -0
- package/dist/ui/Griddle.js.map +1 -0
- package/dist/ui/components.d.ts +4 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +69 -0
- package/dist/ui/components.js.map +1 -0
- package/package.json +56 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 DynamicTyped
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Griddle v2 · Effect UI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Griddle as an [Effect UI](https://ui.effect.website/) component (`effect` 4.2.0, which ships Effect UI as `effect/ui`, `effect/ui/html` and `effect/ui/kit`), with a headless core and v1-style plugins.
|
|
4
|
+
|
|
5
|
+
The React version (Griddle v1, `griddle-react`) lives on the `v1` branch. Its docs are archived at https://griddlegriddle.github.io/Griddle/docs/ (older v0: https://griddlegriddle.github.io/v0-docs/). See the migration page on the docs site for what matches v1.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
// Headless, no Effect needed
|
|
9
|
+
const g = createGriddle({ data, pageSize: 20, plugins: [VirtualScrollPlugin({ rowHeight: 28, viewportHeight: 280 })] })
|
|
10
|
+
g.handlers.toggleSort("name"); g.getView() // { rows, columns, pagination, window, filter, ... } plain data
|
|
11
|
+
|
|
12
|
+
// Headless, Effect
|
|
13
|
+
const g = yield* makeHeadless({ data }) // or GriddleService.layer({ data })
|
|
14
|
+
yield* g.actions.setPage(2); const view = yield* g.view; g.changes // Stream<GriddleView>
|
|
15
|
+
|
|
16
|
+
// Effect UI
|
|
17
|
+
const Grid = makeGriddle({ plugins: [LocalPlugin(), MyPlugin] })
|
|
18
|
+
Grid(h, { props: { data, config: { pageSize: 10 } } })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Plugin shape (all fields optional, composed in order, later wins): `initialState`, `components`, `styles`, `reducers`, `selectors`, `events`. `LocalPlugin` (client-side sort/filter/page) is included by default; pass `local: false` for server-side data.
|
|
22
|
+
|
|
23
|
+
`pnpm install && pnpm test && pnpm typecheck`; `pnpm dev` runs the demo (`demo/main.ts`).
|
|
24
|
+
|
|
25
|
+
## Docs site
|
|
26
|
+
|
|
27
|
+
`pnpm site:dev` runs the docs site with live examples (port 5392). `pnpm site:build` builds it to `site/dist`, `pnpm site:preview` serves the build, and `pnpm site:check` clicks through every page in headless Chromium and fails on console errors. Source is in `site/`.
|
|
28
|
+
|
|
29
|
+
## Performance
|
|
30
|
+
|
|
31
|
+
`pnpm bench` runs a headless benchmark (10k and 100k rows). The pipeline is memoized per stage by dependency identity and the virtual scroll plugin uses Effect UI's `VirtualList`.
|
|
32
|
+
|
|
33
|
+
## Prior art and credits
|
|
34
|
+
|
|
35
|
+
The memoization and windowing ideas follow [TanStack Table](https://github.com/TanStack/table) (MIT, Copyright (c) 2016 Tanner Linsley, read at commit `6d48b56`) and [TanStack Virtual](https://github.com/TanStack/virtual) (MIT, Copyright (c) 2021-present Tanner Linsley, read at commit `35112b8`). They were reimplemented here; no TanStack code was copied and there is no TanStack dependency. See [`THIRD_PARTY_NOTICES.md`](https://github.com/GriddleGriddle/Griddle/blob/master/THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
No third-party source code has been copied or adapted into this repository. No license text beyond the dependencies declared in `package.json` and their own licenses is required.
|
|
4
|
+
|
|
5
|
+
## Design references (ideas only, no code)
|
|
6
|
+
|
|
7
|
+
The memoized row-model pipeline (`selectorDeps`, `src/compose.ts`) and the choice to window rows with a dependency-checked, overscanned range follow ideas from:
|
|
8
|
+
|
|
9
|
+
- TanStack Table, https://github.com/TanStack/table, MIT, Copyright (c) 2016 Tanner Linsley. Read at commit `6d48b56fa6391526b9e38214e13b46e90d5e9501`.
|
|
10
|
+
- TanStack Virtual, https://github.com/TanStack/virtual, MIT, Copyright (c) 2021-present Tanner Linsley. Read at commit `35112b84bb857917925c47486ecc294a43f185aa`.
|
|
11
|
+
|
|
12
|
+
These ideas were reimplemented from scratch with a different structure and API. No TanStack code was copied or adapted, so the MIT license text is not reproduced here. If code from either project (or any other) is adapted later, add before committing it: the full MIT license text of that project with its copyright line, the files in this repo that contain the adapted code, and a link to the source file at the exact commit used.
|
|
13
|
+
|
|
14
|
+
## Dependencies
|
|
15
|
+
|
|
16
|
+
Virtual scrolling uses `VirtualList` from `effect/ui/kit`, part of the `effect` package (MIT), declared in `package.json`.
|
|
17
|
+
|
|
18
|
+
The original Griddle v1 source lives on the `v1` branch and keeps its own license (MIT, same as this repository).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import type { Action, GriddleState } from "./core/state.ts";
|
|
3
|
+
import type { Row } from "./core/math.ts";
|
|
4
|
+
import type { ComposedPlugins, PluginInput, Selectors } from "./plugin.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Compose plugins in order. The core plugin always goes first, so user plugins
|
|
7
|
+
* layer over it: later components/reducers/selectors win, styles are joined,
|
|
8
|
+
* settings are merged, events are unioned.
|
|
9
|
+
*/
|
|
10
|
+
export declare const composePlugins: (inputs?: ReadonlyArray<PluginInput>) => ComposedPlugins;
|
|
11
|
+
/** Run a reducer by action type; unknown types are ignored. */
|
|
12
|
+
export declare const reduce: (composed: ComposedPlugins, state: GriddleState, action: Action, data: ReadonlyArray<Row>, memo?: SelectorMemo) => GriddleState;
|
|
13
|
+
interface MemoSlot {
|
|
14
|
+
deps: ReadonlyArray<unknown>;
|
|
15
|
+
value: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One slot per selector name, holding the last result and the deps it was computed from.
|
|
19
|
+
* Keep one per grid instance and pass it to `resolveSelectors` and `reduce`.
|
|
20
|
+
*
|
|
21
|
+
* Design reference: the dependency-identity memo used by TanStack Table's row-model stages and
|
|
22
|
+
* TanStack Virtual's `memo`. Reimplemented here, no TanStack code is used. See THIRD_PARTY_NOTICES.md.
|
|
23
|
+
*/
|
|
24
|
+
export type SelectorMemo = Map<string, MemoSlot>;
|
|
25
|
+
export declare const createSelectorMemo: () => SelectorMemo;
|
|
26
|
+
/** Memo for components that have no instance to hang one on: keyed by plugin set, then by the data array. */
|
|
27
|
+
export declare const memoFor: (composed: ComposedPlugins, data: ReadonlyArray<Row>) => SelectorMemo;
|
|
28
|
+
/**
|
|
29
|
+
* Lazily resolve selectors for one (data, state) pair. Each selector runs at most once per call.
|
|
30
|
+
* With a `memo`, selectors that declare deps are also skipped when their deps are unchanged since
|
|
31
|
+
* the previous call, so a sort change does not refilter and a scroll does not resort.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveSelectors: (composed: ComposedPlugins, data: ReadonlyArray<Row>, state: GriddleState, memo?: SelectorMemo) => Selectors;
|
|
34
|
+
export declare const resolveView: (composed: ComposedPlugins, data: ReadonlyArray<Row>, state: GriddleState, memo?: SelectorMemo) => import("./plugin.ts").GriddleView;
|
|
35
|
+
/** Initial state: composed defaults, then the caller's config, then page clamping happens on read. */
|
|
36
|
+
export declare const initialStateFor: (composed: ComposedPlugins, config?: Partial<Omit<GriddleState, "settings">> & {
|
|
37
|
+
settings?: Record<string, unknown>;
|
|
38
|
+
}) => GriddleState;
|
|
39
|
+
declare const GriddlePlugins_base: Context.ServiceClass<GriddlePlugins, "griddle/Plugins", ComposedPlugins>;
|
|
40
|
+
/** Effect service holding a composed plugin set, for apps that prefer Layers. */
|
|
41
|
+
export declare class GriddlePlugins extends GriddlePlugins_base {
|
|
42
|
+
static layer: (plugins?: ReadonlyArray<PluginInput>) => Layer.Layer<GriddlePlugins, never, never>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* v1's `events` prop. Callbacks run synchronously, right after the reducer produced the new state
|
|
46
|
+
* (so `onSort` sees the sort that is now in effect). They are for side effects such as fetching
|
|
47
|
+
* server data; they cannot change the state.
|
|
48
|
+
*/
|
|
49
|
+
export interface GriddleEvents {
|
|
50
|
+
readonly onFilter?: (filter: string) => void;
|
|
51
|
+
readonly onSort?: (sort: GriddleState["sort"]) => void;
|
|
52
|
+
readonly onNext?: (page: number) => void;
|
|
53
|
+
readonly onPrevious?: (page: number) => void;
|
|
54
|
+
readonly onGetPage?: (page: number) => void;
|
|
55
|
+
}
|
|
56
|
+
export declare const notifyEvents: (events: GriddleEvents | undefined, action: Action, after: GriddleState) => void;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EACoB,eAAe,EAAiB,WAAW,EAAuC,SAAS,EAC1H,MAAM,aAAa,CAAA;AAIpB;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,SAAQ,aAAa,CAAC,WAAW,CAAM,KAAG,eAgDxE,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,MAAM,GACjB,UAAU,eAAe,EACzB,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,MAAM,aAAa,CAAC,GAAG,CAAC,EACxB,OAAO,YAAY,KAClB,YAQF,CAAA;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IAC5B,KAAK,EAAE,OAAO,CAAA;CACf;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAChD,eAAO,MAAM,kBAAkB,QAAO,YAAyB,CAAA;AAO/D,6GAA6G;AAC7G,eAAO,MAAM,OAAO,GAAI,UAAU,eAAe,EAAE,MAAM,aAAa,CAAC,GAAG,CAAC,KAAG,YAM7E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,eAAe,EACzB,MAAM,aAAa,CAAC,G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+
import { CorePlugin } from "./core/plugin.js";
|
|
4
|
+
import { defaultState } from "./core/state.js";
|
|
5
|
+
const resolvePlugin = (p) => (typeof p === "function" ? p() : p);
|
|
6
|
+
/**
|
|
7
|
+
* Compose plugins in order. The core plugin always goes first, so user plugins
|
|
8
|
+
* layer over it: later components/reducers/selectors win, styles are joined,
|
|
9
|
+
* settings are merged, events are unioned.
|
|
10
|
+
*/
|
|
11
|
+
export const composePlugins = (inputs = []) => {
|
|
12
|
+
const plugins = [CorePlugin, ...inputs.map(resolvePlugin)];
|
|
13
|
+
const components = {};
|
|
14
|
+
const styleParts = {};
|
|
15
|
+
const reducers = {};
|
|
16
|
+
const selectors = {};
|
|
17
|
+
const selectorDeps = {};
|
|
18
|
+
const events = {};
|
|
19
|
+
let initialState = defaultState;
|
|
20
|
+
for (const p of plugins) {
|
|
21
|
+
if (p.initialState) {
|
|
22
|
+
const { settings, ...rest } = p.initialState;
|
|
23
|
+
initialState = { ...initialState, ...rest, settings: { ...initialState.settings, ...settings } };
|
|
24
|
+
}
|
|
25
|
+
Object.assign(components, p.components);
|
|
26
|
+
for (const [name, wrap] of Object.entries(p.wrapComponents ?? {})) {
|
|
27
|
+
const base = components[name];
|
|
28
|
+
if (base && wrap)
|
|
29
|
+
components[name] = wrap(base);
|
|
30
|
+
}
|
|
31
|
+
for (const [k, v] of Object.entries(p.styles ?? {}))
|
|
32
|
+
if (v)
|
|
33
|
+
(styleParts[k] ??= []).push(v);
|
|
34
|
+
for (const [type, r] of Object.entries(p.reducers ?? {})) {
|
|
35
|
+
const prev = reducers[type];
|
|
36
|
+
reducers[type] = prev
|
|
37
|
+
? (state, payload, env) => r(state, payload, { ...env, base: (s, pl) => prev(s, pl ?? payload, env) })
|
|
38
|
+
: r;
|
|
39
|
+
}
|
|
40
|
+
for (const [name, s] of Object.entries(p.selectors ?? {})) {
|
|
41
|
+
const prev = selectors[name];
|
|
42
|
+
selectors[name] = prev ? (ctx, sel, _base) => s(ctx, sel, () => prev(ctx, sel, _base)) : s;
|
|
43
|
+
const deps = p.selectorDeps?.[name];
|
|
44
|
+
if (deps === "inherit")
|
|
45
|
+
continue;
|
|
46
|
+
if (deps)
|
|
47
|
+
selectorDeps[name] = deps;
|
|
48
|
+
else
|
|
49
|
+
delete selectorDeps[name];
|
|
50
|
+
}
|
|
51
|
+
Object.assign(events, p.events);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
plugins,
|
|
55
|
+
initialState,
|
|
56
|
+
components: components,
|
|
57
|
+
styles: Object.fromEntries(Object.entries(styleParts).map(([k, v]) => [k, v.join(" ")])),
|
|
58
|
+
reducers,
|
|
59
|
+
selectors,
|
|
60
|
+
selectorDeps,
|
|
61
|
+
events
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** Run a reducer by action type; unknown types are ignored. */
|
|
65
|
+
export const reduce = (composed, state, action, data, memo) => {
|
|
66
|
+
const r = composed.reducers[action.type];
|
|
67
|
+
if (!r)
|
|
68
|
+
return state;
|
|
69
|
+
return r(state, action.payload, {
|
|
70
|
+
data,
|
|
71
|
+
sel: resolveSelectors(composed, data, state, memo),
|
|
72
|
+
base: (s) => s
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export const createSelectorMemo = () => new Map();
|
|
76
|
+
const sameDeps = (a, b) => a.length === b.length && a.every((x, i) => Object.is(x, b[i]));
|
|
77
|
+
const memos = new WeakMap();
|
|
78
|
+
/** Memo for components that have no instance to hang one on: keyed by plugin set, then by the data array. */
|
|
79
|
+
export const memoFor = (composed, data) => {
|
|
80
|
+
let byData = memos.get(composed);
|
|
81
|
+
if (!byData)
|
|
82
|
+
memos.set(composed, (byData = new WeakMap()));
|
|
83
|
+
let memo = byData.get(data);
|
|
84
|
+
if (!memo)
|
|
85
|
+
byData.set(data, (memo = createSelectorMemo()));
|
|
86
|
+
return memo;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Lazily resolve selectors for one (data, state) pair. Each selector runs at most once per call.
|
|
90
|
+
* With a `memo`, selectors that declare deps are also skipped when their deps are unchanged since
|
|
91
|
+
* the previous call, so a sort change does not refilter and a scroll does not resort.
|
|
92
|
+
*/
|
|
93
|
+
export const resolveSelectors = (composed, data, state, memo) => {
|
|
94
|
+
const ctx = { data, state };
|
|
95
|
+
const cache = new Map();
|
|
96
|
+
const out = {};
|
|
97
|
+
const compute = (name) => {
|
|
98
|
+
const depsOf = memo ? composed.selectorDeps[name] : undefined;
|
|
99
|
+
if (!memo || !depsOf)
|
|
100
|
+
return composed.selectors[name](ctx, out, () => undefined);
|
|
101
|
+
const deps = depsOf(ctx, out);
|
|
102
|
+
const slot = memo.get(name);
|
|
103
|
+
if (slot && sameDeps(slot.deps, deps))
|
|
104
|
+
return slot.value;
|
|
105
|
+
const value = composed.selectors[name](ctx, out, () => undefined);
|
|
106
|
+
memo.set(name, { deps, value });
|
|
107
|
+
return value;
|
|
108
|
+
};
|
|
109
|
+
for (const name of Object.keys(composed.selectors)) {
|
|
110
|
+
Object.defineProperty(out, name, {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: () => {
|
|
113
|
+
if (!cache.has(name))
|
|
114
|
+
cache.set(name, compute(name));
|
|
115
|
+
return cache.get(name);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
};
|
|
121
|
+
export const resolveView = (composed, data, state, memo) => resolveSelectors(composed, data, state, memo).view;
|
|
122
|
+
/** Initial state: composed defaults, then the caller's config, then page clamping happens on read. */
|
|
123
|
+
export const initialStateFor = (composed, config = {}) => {
|
|
124
|
+
const { settings, ...rest } = config;
|
|
125
|
+
const defined = Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== undefined));
|
|
126
|
+
return { ...composed.initialState, ...defined, settings: { ...composed.initialState.settings, ...settings } };
|
|
127
|
+
};
|
|
128
|
+
/** Effect service holding a composed plugin set, for apps that prefer Layers. */
|
|
129
|
+
export class GriddlePlugins extends Context.Service()("griddle/Plugins") {
|
|
130
|
+
static layer = (plugins = []) => Layer.succeed(GriddlePlugins, composePlugins(plugins));
|
|
131
|
+
}
|
|
132
|
+
export const notifyEvents = (events, action, after) => {
|
|
133
|
+
if (!events)
|
|
134
|
+
return;
|
|
135
|
+
switch (action.type) {
|
|
136
|
+
case A.SET_FILTER: return events.onFilter?.(after.filter);
|
|
137
|
+
case A.TOGGLE_SORT:
|
|
138
|
+
case A.SET_SORT: return events.onSort?.(after.sort);
|
|
139
|
+
case A.NEXT_PAGE: return events.onNext?.(after.page);
|
|
140
|
+
case A.PREVIOUS_PAGE: return events.onPrevious?.(after.page);
|
|
141
|
+
case A.SET_PAGE: return events.onGetPage?.(after.page);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,CAAC,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAO9C,MAAM,aAAa,GAAG,CAAC,CAAc,EAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAqC,EAAE,EAAmB,EAAE;IACzF,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAA;IAC1D,MAAM,UAAU,GAAkD,EAAE,CAAA;IACpE,MAAM,UAAU,GAA6B,EAAE,CAAA;IAC/C,MAAM,QAAQ,GAA4B,EAA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AA;IACxD,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Action, GriddleState } from "./state.ts";
|
|
2
|
+
import type { SortSpec } from "./math.ts";
|
|
3
|
+
export declare const SET_FILTER = "GRIDDLE_SET_FILTER";
|
|
4
|
+
export declare const SET_PAGE = "GRIDDLE_SET_PAGE";
|
|
5
|
+
export declare const NEXT_PAGE = "GRIDDLE_NEXT_PAGE";
|
|
6
|
+
export declare const PREVIOUS_PAGE = "GRIDDLE_PREVIOUS_PAGE";
|
|
7
|
+
export declare const SET_PAGE_SIZE = "GRIDDLE_SET_PAGE_SIZE";
|
|
8
|
+
export declare const TOGGLE_SORT = "GRIDDLE_TOGGLE_SORT";
|
|
9
|
+
export declare const SET_SORT = "GRIDDLE_SET_SORT";
|
|
10
|
+
export declare const SCROLLED = "GRIDDLE_SCROLLED";
|
|
11
|
+
export declare const SET_VIEWPORT = "GRIDDLE_SET_VIEWPORT";
|
|
12
|
+
export declare const TOGGLE_COLUMN = "GRIDDLE_TOGGLE_COLUMN";
|
|
13
|
+
export declare const TOGGLE_SETTINGS = "GRIDDLE_TOGGLE_SETTINGS";
|
|
14
|
+
export declare const SET_SETTING = "GRIDDLE_SET_SETTING";
|
|
15
|
+
/** The core action creators. Plugin `events` are added next to these. */
|
|
16
|
+
export declare const coreActions: {
|
|
17
|
+
setFilter: (filter: string) => Action;
|
|
18
|
+
setPage: (page: number) => Action;
|
|
19
|
+
nextPage: () => Action;
|
|
20
|
+
previousPage: () => Action;
|
|
21
|
+
setPageSize: (pageSize: number) => Action;
|
|
22
|
+
toggleSort: (column: string) => Action;
|
|
23
|
+
setSort: (sort: ReadonlyArray<SortSpec>) => Action;
|
|
24
|
+
scrolled: (top: number) => Action;
|
|
25
|
+
setViewport: (height: number) => Action;
|
|
26
|
+
toggleColumn: (id: string) => Action;
|
|
27
|
+
toggleSettings: () => Action;
|
|
28
|
+
setSetting: (key: string, value: unknown) => Action;
|
|
29
|
+
};
|
|
30
|
+
export type PatchState = Partial<GriddleState>;
|
|
31
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/core/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,eAAO,MAAM,UAAU,uBAAuB,CAAA;AAC9C,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AAC1C,eAAO,MAAM,SAAS,sBAAsB,CAAA;AAC5C,eAAO,MAAM,aAAa,0BAA0B,CAAA;AACpD,eAAO,MAAM,aAAa,0BAA0B,CAAA;AACpD,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAChD,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AAC1C,eAAO,MAAM,QAAQ,qBAAqB,CAAA;AAC1C,eAAO,MAAM,YAAY,yBAAyB,CAAA;AAClD,eAAO,MAAM,aAAa,0BAA0B,CAAA;AACpD,eAAO,MAAM,eAAe,4BAA4B,CAAA;AACxD,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAEhD,yEAAyE;AACzE,eAAO,MAAM,WAAW;wBACF,MAAM,KAAG,MAAM;oBACnB,MAAM,KAAG,MAAM;oBACjB,MAAM;wBACF,MAAM;4BACA,MAAM,KAAG,MAAM;yBAClB,MAAM,KAAG,MAAM;oBACpB,aAAa,CAAC,QAAQ,CAAC,KAAG,MAAM;oBAChC,MAAM,KAAG,MAAM;0BACT,MAAM,KAAG,MAAM;uBAClB,MAAM,KAAG,MAAM;0BACd,MAAM;sBACR,MAAM,SAAS,OAAO,KAAG,MAAM;CAClD,CAAA;AACD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const SET_FILTER = "GRIDDLE_SET_FILTER";
|
|
2
|
+
export const SET_PAGE = "GRIDDLE_SET_PAGE";
|
|
3
|
+
export const NEXT_PAGE = "GRIDDLE_NEXT_PAGE";
|
|
4
|
+
export const PREVIOUS_PAGE = "GRIDDLE_PREVIOUS_PAGE";
|
|
5
|
+
export const SET_PAGE_SIZE = "GRIDDLE_SET_PAGE_SIZE";
|
|
6
|
+
export const TOGGLE_SORT = "GRIDDLE_TOGGLE_SORT";
|
|
7
|
+
export const SET_SORT = "GRIDDLE_SET_SORT";
|
|
8
|
+
export const SCROLLED = "GRIDDLE_SCROLLED";
|
|
9
|
+
export const SET_VIEWPORT = "GRIDDLE_SET_VIEWPORT";
|
|
10
|
+
export const TOGGLE_COLUMN = "GRIDDLE_TOGGLE_COLUMN";
|
|
11
|
+
export const TOGGLE_SETTINGS = "GRIDDLE_TOGGLE_SETTINGS";
|
|
12
|
+
export const SET_SETTING = "GRIDDLE_SET_SETTING";
|
|
13
|
+
/** The core action creators. Plugin `events` are added next to these. */
|
|
14
|
+
export const coreActions = {
|
|
15
|
+
setFilter: (filter) => ({ type: SET_FILTER, payload: { filter } }),
|
|
16
|
+
setPage: (page) => ({ type: SET_PAGE, payload: { page } }),
|
|
17
|
+
nextPage: () => ({ type: NEXT_PAGE }),
|
|
18
|
+
previousPage: () => ({ type: PREVIOUS_PAGE }),
|
|
19
|
+
setPageSize: (pageSize) => ({ type: SET_PAGE_SIZE, payload: { pageSize } }),
|
|
20
|
+
toggleSort: (column) => ({ type: TOGGLE_SORT, payload: { column } }),
|
|
21
|
+
setSort: (sort) => ({ type: SET_SORT, payload: { sort } }),
|
|
22
|
+
scrolled: (top) => ({ type: SCROLLED, payload: { top } }),
|
|
23
|
+
setViewport: (height) => ({ type: SET_VIEWPORT, payload: { height } }),
|
|
24
|
+
toggleColumn: (id) => ({ type: TOGGLE_COLUMN, payload: { id } }),
|
|
25
|
+
toggleSettings: () => ({ type: TOGGLE_SETTINGS }),
|
|
26
|
+
setSetting: (key, value) => ({ type: SET_SETTING, payload: { key, value } })
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/core/actions.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAA;AAC9C,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAAA;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAA;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAA;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAA;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAA;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAA;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,yBAAyB,CAAA;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAA;AAEhD,yEAAyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,CAAC,MAAc,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;IAClF,OAAO,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAC1E,QAAQ,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC7C,YAAY,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACrD,WAAW,EAAE,CAAC,QAAgB,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC;IAC3F,UAAU,EAAE,CAAC,MAAc,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;IACpF,OAAO,EAAE,CAAC,IAA6B,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAC3F,QAAQ,EAAE,CAAC,GAAW,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;IACzE,WAAW,EAAE,CAAC,MAAc,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;IACtF,YAAY,EAAE,CAAC,EAAU,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAChF,cAAc,EAAE,GAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,CAAC,GAAW,EAAE,KAAc,EAAU,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;CACtG,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type Row = Readonly<Record<string, unknown>>;
|
|
2
|
+
export type SortDirection = "asc" | "desc";
|
|
3
|
+
export interface SortSpec {
|
|
4
|
+
readonly column: string;
|
|
5
|
+
readonly direction: SortDirection;
|
|
6
|
+
}
|
|
7
|
+
export type RowFilter = string | ((row: Row, index: number) => boolean) | Readonly<Record<string, string>>;
|
|
8
|
+
/** Stable multi-column sort. Returns a new array; the input is untouched. */
|
|
9
|
+
export declare const sortRows: <R extends Row>(rows: ReadonlyArray<R>, sort: ReadonlyArray<SortSpec>, compares?: Readonly<Record<string, (a: unknown, b: unknown, rowA: Row, rowB: Row) => number>>) => ReadonlyArray<R>;
|
|
10
|
+
/**
|
|
11
|
+
* Text filter: a row matches when any filterable column contains the text.
|
|
12
|
+
* Object filter: every listed column must contain its text.
|
|
13
|
+
* Function filter: the predicate decides.
|
|
14
|
+
*/
|
|
15
|
+
export declare const filterRows: <R extends Row>(rows: ReadonlyArray<R>, filter: RowFilter | undefined, filterable?: (column: string) => boolean) => ReadonlyArray<R>;
|
|
16
|
+
/** Number of pages. Always at least 1, like Griddle v1. */
|
|
17
|
+
export declare const maxPage: (total: number, pageSize: number) => number;
|
|
18
|
+
/** Clamp a 1-based page into `[1, maxPage]`. */
|
|
19
|
+
export declare const clampPage: (page: number, max: number) => number;
|
|
20
|
+
/** 1-based page slice. `pageSize <= 0` means "everything". */
|
|
21
|
+
export declare const paginate: <R>(rows: ReadonlyArray<R>, page: number, pageSize: number) => ReadonlyArray<R>;
|
|
22
|
+
export interface WindowInput {
|
|
23
|
+
readonly total: number;
|
|
24
|
+
readonly scrollTop: number;
|
|
25
|
+
readonly viewportHeight: number;
|
|
26
|
+
readonly rowHeight: number;
|
|
27
|
+
readonly overscan?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface RowWindow {
|
|
30
|
+
/** First rendered row index (inclusive). */
|
|
31
|
+
readonly start: number;
|
|
32
|
+
/** Last rendered row index (exclusive). */
|
|
33
|
+
readonly end: number;
|
|
34
|
+
/** Height of the spacer above the rendered rows. */
|
|
35
|
+
readonly offsetTop: number;
|
|
36
|
+
/** Height of the spacer below the rendered rows. */
|
|
37
|
+
readonly offsetBottom: number;
|
|
38
|
+
readonly totalHeight: number;
|
|
39
|
+
}
|
|
40
|
+
/** Which rows to render for a scroll offset, with `overscan` extra rows on each side. */
|
|
41
|
+
export declare const windowRange: ({ total, scrollTop, viewportHeight, rowHeight, overscan }: WindowInput) => RowWindow;
|
|
42
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/core/math.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AACnD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;AAC1C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;CAClC;AACD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAc1G,6EAA6E;AAC7E,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,GAAG,EACpC,MAAM,aAAa,CAAC,CAAC,CAAC,EACtB,MAAM,aAAa,CAAC,QAAQ,CAAC,EAC7B,WAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,CAAM,KAChG,aAAa,CAAC,CAAC,CAYjB,CAAA;AAMD;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,EACtC,MAAM,aAAa,CAAC,CAAC,CAAC,EACtB,QAAQ,SAAS,GAAG,SAAS,EAC7B,aAAY,CAAC,MAAM,EAAE,MAAM,KAAK,OAAoB,KACnD,aAAa,CAAC,CAAC,CASjB,CAAA;AAED,2DAA2D;AAC3D,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,MACG,CAAA;AAE7D,gDAAgD;AAChD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,KAAG,MAA2D,CAAA;AAEjH,8DAA8D;AAC9D,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,EAAE,UAAU,MAAM,KAAG,aAAa,CAAC,CAAC,CAInG,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AACD,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,WAAW,GAAI,2DAA+D,WAAW,KAAG,SAUxG,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Pure sort / filter / page / window math. No Effect, no UI, no state.
|
|
2
|
+
// One collator for every comparison: `localeCompare` with options builds a new one per call.
|
|
3
|
+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
|
|
4
|
+
const compareValues = (a, b) => {
|
|
5
|
+
if (a === b)
|
|
6
|
+
return 0;
|
|
7
|
+
if (a === undefined || a === null)
|
|
8
|
+
return 1;
|
|
9
|
+
if (b === undefined || b === null)
|
|
10
|
+
return -1;
|
|
11
|
+
if (typeof a === "number" && typeof b === "number")
|
|
12
|
+
return a - b;
|
|
13
|
+
if (a instanceof Date && b instanceof Date)
|
|
14
|
+
return a.getTime() - b.getTime();
|
|
15
|
+
return collator.compare(String(a), String(b));
|
|
16
|
+
};
|
|
17
|
+
/** Stable multi-column sort. Returns a new array; the input is untouched. */
|
|
18
|
+
export const sortRows = (rows, sort, compares = {}) => {
|
|
19
|
+
if (sort.length === 0)
|
|
20
|
+
return rows;
|
|
21
|
+
return rows
|
|
22
|
+
.map((row, index) => ({ row, index }))
|
|
23
|
+
.sort((a, b) => {
|
|
24
|
+
for (const { column, direction } of sort) {
|
|
25
|
+
const c = (compares[column] ?? compares["*"] ?? compareValues)(a.row[column], b.row[column], a.row, b.row);
|
|
26
|
+
if (c !== 0)
|
|
27
|
+
return direction === "desc" ? -c : c;
|
|
28
|
+
}
|
|
29
|
+
return a.index - b.index;
|
|
30
|
+
})
|
|
31
|
+
.map(({ row }) => row);
|
|
32
|
+
};
|
|
33
|
+
// `lowered` is the needle already lowercased, so it is not redone for every cell.
|
|
34
|
+
const includesText = (value, lowered) => value !== undefined && value !== null && String(value).toLowerCase().includes(lowered);
|
|
35
|
+
/**
|
|
36
|
+
* Text filter: a row matches when any filterable column contains the text.
|
|
37
|
+
* Object filter: every listed column must contain its text.
|
|
38
|
+
* Function filter: the predicate decides.
|
|
39
|
+
*/
|
|
40
|
+
export const filterRows = (rows, filter, filterable = () => true) => {
|
|
41
|
+
if (filter === undefined || filter === "")
|
|
42
|
+
return rows;
|
|
43
|
+
if (typeof filter === "function")
|
|
44
|
+
return rows.filter(filter);
|
|
45
|
+
if (typeof filter === "string") {
|
|
46
|
+
const lowered = filter.toLowerCase();
|
|
47
|
+
return rows.filter((row) => Object.keys(row).some((k) => filterable(k) && includesText(row[k], lowered)));
|
|
48
|
+
}
|
|
49
|
+
const entries = Object.entries(filter).filter(([, text]) => text !== "").map(([k, text]) => [k, text.toLowerCase()]);
|
|
50
|
+
return rows.filter((row) => entries.every(([k, text]) => !filterable(k) || includesText(row[k], text)));
|
|
51
|
+
};
|
|
52
|
+
/** Number of pages. Always at least 1, like Griddle v1. */
|
|
53
|
+
export const maxPage = (total, pageSize) => pageSize > 0 ? Math.max(1, Math.ceil(total / pageSize)) : 1;
|
|
54
|
+
/** Clamp a 1-based page into `[1, maxPage]`. */
|
|
55
|
+
export const clampPage = (page, max) => Math.min(Math.max(1, Math.trunc(page) || 1), max);
|
|
56
|
+
/** 1-based page slice. `pageSize <= 0` means "everything". */
|
|
57
|
+
export const paginate = (rows, page, pageSize) => {
|
|
58
|
+
if (pageSize <= 0)
|
|
59
|
+
return rows;
|
|
60
|
+
const start = (clampPage(page, maxPage(rows.length, pageSize)) - 1) * pageSize;
|
|
61
|
+
return rows.slice(start, start + pageSize);
|
|
62
|
+
};
|
|
63
|
+
/** Which rows to render for a scroll offset, with `overscan` extra rows on each side. */
|
|
64
|
+
export const windowRange = ({ total, scrollTop, viewportHeight, rowHeight, overscan = 3 }) => {
|
|
65
|
+
const totalHeight = total * rowHeight;
|
|
66
|
+
if (total <= 0 || rowHeight <= 0)
|
|
67
|
+
return { start: 0, end: 0, offsetTop: 0, offsetBottom: 0, totalHeight: 0 };
|
|
68
|
+
const maxTop = Math.max(0, totalHeight - viewportHeight);
|
|
69
|
+
const top = Math.min(Math.max(0, scrollTop), maxTop);
|
|
70
|
+
const first = Math.floor(top / rowHeight);
|
|
71
|
+
const last = Math.ceil((top + viewportHeight) / rowHeight);
|
|
72
|
+
const start = Math.max(0, first - overscan);
|
|
73
|
+
const end = Math.min(total, last + overscan);
|
|
74
|
+
return { start, end, offsetTop: start * rowHeight, offsetBottom: (total - end) * rowHeight, totalHeight };
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=math.js.map
|
|
@@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AC,CAAC,GAAG,GAAG,cAAc,CAAC,GAAG,SAAS,CAAC,CAAA;IAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAA;IAC5C,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,SAAS,EAAE,WAAW,EAAE,CAAA;AAC3G,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GriddlePlugin } from "../plugin.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The headless base layer. Like Griddle v1 without LocalPlugin, it is a pass-through:
|
|
4
|
+
* `data` is treated as the already-sorted, already-filtered page. Add `LocalPlugin`
|
|
5
|
+
* to compute those client-side.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CorePlugin: GriddlePlugin;
|
|
8
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAwC,MAAM,cAAc,CAAA;AAMvF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,aAqHxB,CAAA"}
|