@svgrid/grid 1.1.1 → 1.1.2
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/dist/FlexRender.svelte +96 -96
- package/dist/SvGrid.controller.svelte.js +17 -6
- package/dist/SvGrid.css +2012 -2012
- package/dist/SvGrid.svelte +2569 -2346
- package/dist/build-api.js +2 -2
- package/dist/cell-values.d.ts +1 -1
- package/dist/cell-values.js +7 -7
- package/dist/column-types.js +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +2 -2
- package/dist/summaries.js +4 -4
- package/package.json +1 -1
- package/src/FlexRender.svelte +96 -96
- package/src/SvGrid.controller.svelte.ts +2363 -2352
- package/src/SvGrid.css +2012 -2012
- package/src/SvGrid.svelte +2569 -2346
- package/src/SvGrid.types.ts +537 -537
- package/src/a11y.contract.test.ts +49 -49
- package/src/a11y.test.ts +59 -59
- package/src/a11y.ts +59 -59
- package/src/build-api.ts +683 -683
- package/src/cell-formatting.ts +169 -169
- package/src/cell-values.ts +4 -4
- package/src/column-types.ts +1 -1
- package/src/core.performance.test.ts +30 -30
- package/src/core.ts +1077 -1077
- package/src/createGrid.svelte.ts +42 -42
- package/src/createGrid.test.ts +10 -10
- package/src/createGridState.svelte.ts +17 -17
- package/src/editing.ts +669 -669
- package/src/flex-render.ts +3 -3
- package/src/index.ts +208 -208
- package/src/keyboard.test.ts +59 -59
- package/src/keyboard.ts +97 -97
- package/src/merge-objects.ts +48 -48
- package/src/render-component.ts +28 -28
- package/src/spreadsheet.test.ts +489 -489
- package/src/spreadsheet.ts +304 -304
- package/src/static-functions.ts +11 -11
- package/src/subscribe.ts +38 -38
- package/src/summaries.ts +4 -4
- package/src/svgrid-wrapper.types.ts +412 -412
- package/src/svgrid.features.test.ts +157 -157
- package/src/svgrid.wrapper.test.ts +40 -40
- package/src/virtualization/column-virtualizer.test.ts +27 -27
- package/src/virtualization/column-virtualizer.ts +30 -30
- package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
- package/src/virtualization/types.ts +30 -30
- package/src/virtualization/virtualizer.test.ts +47 -47
- package/src/virtualization/virtualizer.ts +296 -296
package/src/createGrid.svelte.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { createSvGridCore } from './core'
|
|
2
|
-
import type {
|
|
3
|
-
RowData,
|
|
4
|
-
SvGrid,
|
|
5
|
-
SvGridOptions,
|
|
6
|
-
TableFeatures,
|
|
7
|
-
} from './core'
|
|
8
|
-
|
|
9
|
-
export type SvelteGrid<
|
|
10
|
-
TFeatures extends TableFeatures,
|
|
11
|
-
TData extends RowData,
|
|
12
|
-
TSelected = {},
|
|
13
|
-
> = SvGrid<TData> & {
|
|
14
|
-
readonly state: Readonly<TSelected>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function createSvGrid<
|
|
18
|
-
TFeatures extends TableFeatures,
|
|
19
|
-
TData extends RowData,
|
|
20
|
-
TSelected = {},
|
|
21
|
-
>(
|
|
22
|
-
gridOptions: SvGridOptions<TFeatures, TData>,
|
|
23
|
-
selector: (state: Record<string, any>) => TSelected = () => ({}) as TSelected,
|
|
24
|
-
): SvelteGrid<TFeatures, TData, TSelected> {
|
|
25
|
-
const grid = createSvGridCore(gridOptions) as SvelteGrid<TFeatures, TData, TSelected>
|
|
26
|
-
let selected = $state(selector(grid.store.state))
|
|
27
|
-
grid.store.subscribe(() => {
|
|
28
|
-
selected = selector(grid.store.state)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(grid, 'state', {
|
|
32
|
-
get() {
|
|
33
|
-
return selected
|
|
34
|
-
},
|
|
35
|
-
configurable: true,
|
|
36
|
-
enumerable: true,
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
return grid
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const createGrid = createSvGrid
|
|
1
|
+
import { createSvGridCore } from './core'
|
|
2
|
+
import type {
|
|
3
|
+
RowData,
|
|
4
|
+
SvGrid,
|
|
5
|
+
SvGridOptions,
|
|
6
|
+
TableFeatures,
|
|
7
|
+
} from './core'
|
|
8
|
+
|
|
9
|
+
export type SvelteGrid<
|
|
10
|
+
TFeatures extends TableFeatures,
|
|
11
|
+
TData extends RowData,
|
|
12
|
+
TSelected = {},
|
|
13
|
+
> = SvGrid<TData> & {
|
|
14
|
+
readonly state: Readonly<TSelected>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createSvGrid<
|
|
18
|
+
TFeatures extends TableFeatures,
|
|
19
|
+
TData extends RowData,
|
|
20
|
+
TSelected = {},
|
|
21
|
+
>(
|
|
22
|
+
gridOptions: SvGridOptions<TFeatures, TData>,
|
|
23
|
+
selector: (state: Record<string, any>) => TSelected = () => ({}) as TSelected,
|
|
24
|
+
): SvelteGrid<TFeatures, TData, TSelected> {
|
|
25
|
+
const grid = createSvGridCore(gridOptions) as SvelteGrid<TFeatures, TData, TSelected>
|
|
26
|
+
let selected = $state(selector(grid.store.state))
|
|
27
|
+
grid.store.subscribe(() => {
|
|
28
|
+
selected = selector(grid.store.state)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(grid, 'state', {
|
|
32
|
+
get() {
|
|
33
|
+
return selected
|
|
34
|
+
},
|
|
35
|
+
configurable: true,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return grid
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const createGrid = createSvGrid
|
package/src/createGrid.test.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { createGridState } from './index'
|
|
3
|
-
|
|
4
|
-
describe('createGrid', () => {
|
|
5
|
-
it('createGridState updates controlled values', () => {
|
|
6
|
-
const [sorting, setSorting] = createGridState([{ id: 'age', desc: false }])
|
|
7
|
-
setSorting((prev) => prev.map((entry) => ({ ...entry, desc: true })))
|
|
8
|
-
expect(sorting()[0]?.desc).toBe(true)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { createGridState } from './index'
|
|
3
|
+
|
|
4
|
+
describe('createGrid', () => {
|
|
5
|
+
it('createGridState updates controlled values', () => {
|
|
6
|
+
const [sorting, setSorting] = createGridState([{ id: 'age', desc: false }])
|
|
7
|
+
setSorting((prev) => prev.map((entry) => ({ ...entry, desc: true })))
|
|
8
|
+
expect(sorting()[0]?.desc).toBe(true)
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { Updater } from './core'
|
|
2
|
-
|
|
3
|
-
export function createGridState<TState>(
|
|
4
|
-
initialValue: TState,
|
|
5
|
-
): [() => TState, (updater: Updater<TState>) => void] {
|
|
6
|
-
let value = $state(initialValue)
|
|
7
|
-
|
|
8
|
-
return [
|
|
9
|
-
() => value,
|
|
10
|
-
(updater: Updater<TState>) => {
|
|
11
|
-
if (updater instanceof Function) value = updater(value)
|
|
12
|
-
else value = updater
|
|
13
|
-
},
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const createSvGridState = createGridState
|
|
1
|
+
import type { Updater } from './core'
|
|
2
|
+
|
|
3
|
+
export function createGridState<TState>(
|
|
4
|
+
initialValue: TState,
|
|
5
|
+
): [() => TState, (updater: Updater<TState>) => void] {
|
|
6
|
+
let value = $state(initialValue)
|
|
7
|
+
|
|
8
|
+
return [
|
|
9
|
+
() => value,
|
|
10
|
+
(updater: Updater<TState>) => {
|
|
11
|
+
if (updater instanceof Function) value = updater(value)
|
|
12
|
+
else value = updater
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const createSvGridState = createGridState
|