@ember-lattice/ember 1.0.0 → 1.1.1
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/CHANGELOG.md +63 -0
- package/README.md +87 -50
- package/declarations/board/declarations.d.ts +129 -0
- package/declarations/board/declarations.d.ts.map +1 -0
- package/declarations/board/lattice-board.d.ts +41 -10
- package/declarations/board/lattice-board.d.ts.map +1 -1
- package/declarations/grid/columns/column-def.d.ts +120 -0
- package/declarations/grid/columns/column-def.d.ts.map +1 -0
- package/declarations/grid/columns/declarations.d.ts +212 -0
- package/declarations/grid/columns/declarations.d.ts.map +1 -0
- package/declarations/grid/columns/memo.d.ts +32 -0
- package/declarations/grid/columns/memo.d.ts.map +1 -0
- package/declarations/grid/columns/owned-table.d.ts +40 -0
- package/declarations/grid/columns/owned-table.d.ts.map +1 -0
- package/declarations/grid/columns/registry.d.ts +13 -0
- package/declarations/grid/columns/registry.d.ts.map +1 -0
- package/declarations/grid/lattice-grid.d.ts +126 -13
- package/declarations/grid/lattice-grid.d.ts.map +1 -1
- package/declarations/grid/state-host.d.ts +14 -0
- package/declarations/grid/state-host.d.ts.map +1 -1
- package/declarations/grid/types.d.ts +45 -4
- package/declarations/grid/types.d.ts.map +1 -1
- package/declarations/index.d.ts +10 -2
- package/declarations/index.d.ts.map +1 -1
- package/declarations/list/lattice-list.d.ts +1 -1
- package/dist/index.js +1167 -167
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @ember-lattice/ember
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ae3ec30: Publish through OIDC trusted publishing only, with the Ember Workbench release kit. Each version from this release on has npm provenance.
|
|
8
|
+
- Updated dependencies [ae3ec30]
|
|
9
|
+
- @ember-lattice/core@1.1.1
|
|
10
|
+
- @ember-lattice/data@1.1.1
|
|
11
|
+
- @ember-lattice/virtual@1.1.1
|
|
12
|
+
|
|
13
|
+
## 1.1.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- f931851: `LatticeBoard` has a template form (ADR 0028, FR-10). With no `@lanes`, the block declares the
|
|
18
|
+
lanes and the card: one `<b.Lane @key @label>` for each lane, in template order, and
|
|
19
|
+
`<b.Card as |item|>` for the content of each card. An optional `<:header as |lane|>` block in a
|
|
20
|
+
lane replaces the label and the count in the lane title. `@label` of a lane is the lane name:
|
|
21
|
+
the title, the name of the lane listbox and the text of the announcements. A lane in an
|
|
22
|
+
`{{#if}}` block takes its place in the template.
|
|
23
|
+
|
|
24
|
+
The engine form does not change: with `@lanes` and `@laneLabel`, the block is the content of
|
|
25
|
+
each card. `@getItemId` is now optional. The default is the `id` key of the item, as text.
|
|
26
|
+
|
|
27
|
+
The package also exports `DeclarationRegistry`, the registry of the declarations of the
|
|
28
|
+
template form, for the other Lattice packages.
|
|
29
|
+
|
|
30
|
+
- f931851: Configure a grid in its template (ADR 0028). `LatticeGrid` takes the rows as `@data` and makes the
|
|
31
|
+
table from the declarations in its block: `g.Column`, `g.ColumnGroup`, `g.SelectionColumn` and
|
|
32
|
+
`g.RowNumberColumn`. A column takes `<:cell>`, `<:header>`, `<:headerEnd>` and `<:editor>` blocks.
|
|
33
|
+
The grid also takes `@features`, `@initialState`, `@state`, `@onStateChange` and `@tableOptions`.
|
|
34
|
+
|
|
35
|
+
- `<:toolbar>`, `<:statusBar>` and `<:sideBar>` get the table and the grid root.
|
|
36
|
+
- `@rowModel` takes a function that makes the model from the table of the grid:
|
|
37
|
+
`ServerRowModel.forGrid({ source })`. The pivot columns of the server row model go after the
|
|
38
|
+
declared columns.
|
|
39
|
+
- `persistGridState` takes the `@stateHost` handle and waits for the table of the grid.
|
|
40
|
+
- The chrome blocks and the `@stateHost` handle give the table as `GridEngineTable`, the engine
|
|
41
|
+
table type. The components of `@ember-lattice/ui` and `persistGridState` take it.
|
|
42
|
+
- `GridRowModel<T>` has the row type, and `forGrid` of each row model keeps the row type of its
|
|
43
|
+
source. The grid gets its row type from `@rowModel`, as it does from `@data`.
|
|
44
|
+
- The grid disconnects a row model that it made from a `@rowModel` function: when the grid goes,
|
|
45
|
+
or when a new function replaces the model.
|
|
46
|
+
- `g.SelectionColumn` and `g.RowNumberColumn` take `@pinned` and `@hidden`.
|
|
47
|
+
- The editing args (`@editor`, `@editable`, `@schema`, `@parse`, `@options`) and the filter arg
|
|
48
|
+
(`@filter`) are args of `g.Column`.
|
|
49
|
+
|
|
50
|
+
`@table` and `constructTable` stay. Nothing is removed or deprecated.
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- f931851: A scroll restyles fewer elements. The theme wrapped the text of a measured row
|
|
55
|
+
(`@rowHeight="auto"`) by a rule on the `style` attribute of the row. The grid writes that attribute
|
|
56
|
+
on each scroll, so the browser restyled each cell of each row on each scroll. The grid now sets
|
|
57
|
+
`data-measured` on a measured row, and the theme selects the row by that attribute. A `<:cell>`
|
|
58
|
+
block of the template form keeps the anchor element of its slot, so a scroll adds no anchor
|
|
59
|
+
element. A full cell still renders its block again for a new row. Update `@ember-lattice/theme` and
|
|
60
|
+
`@ember-lattice/ember` together: the new theme needs `data-measured` from the grid.
|
|
61
|
+
- Updated dependencies [f931851]
|
|
62
|
+
- @ember-lattice/data@1.1.0
|
|
63
|
+
- @ember-lattice/core@1.1.0
|
|
64
|
+
- @ember-lattice/virtual@1.1.0
|
|
65
|
+
|
|
3
66
|
## 1.0.0
|
|
4
67
|
|
|
5
68
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -6,66 +6,65 @@ Part of [Lattice](https://joegaudet.com/ember-lattice/). Not released yet.
|
|
|
6
6
|
|
|
7
7
|
## The Grid
|
|
8
8
|
|
|
9
|
-
`LatticeGrid`
|
|
10
|
-
|
|
9
|
+
`LatticeGrid` shows rows in a grid. It virtualizes the rows and the columns, and it uses the
|
|
10
|
+
ARIA grid pattern. The contract is in `docs/prd/2026-12-01-m2-grid-contract/index.html`.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
columnPinningFeature,
|
|
15
|
-
columnResizingFeature,
|
|
16
|
-
columnSizingFeature,
|
|
17
|
-
constructTable,
|
|
18
|
-
createSortedRowModel,
|
|
19
|
-
emberReactivityBindings,
|
|
20
|
-
rowSelectionFeature,
|
|
21
|
-
rowSortingFeature,
|
|
22
|
-
sortFn_basic,
|
|
23
|
-
tableFeatures,
|
|
24
|
-
} from '@ember-lattice/core'
|
|
25
|
-
import { LatticeGrid, selectionColumn } from '@ember-lattice/ember'
|
|
26
|
-
|
|
27
|
-
const features = tableFeatures({
|
|
28
|
-
coreReactivityFeature: emberReactivityBindings(),
|
|
29
|
-
columnPinningFeature,
|
|
30
|
-
columnResizingFeature,
|
|
31
|
-
columnSizingFeature,
|
|
32
|
-
rowSelectionFeature,
|
|
33
|
-
rowSortingFeature,
|
|
34
|
-
sortedRowModel: createSortedRowModel(),
|
|
35
|
-
sortFns: { basic: sortFn_basic },
|
|
36
|
-
})
|
|
12
|
+
Configure the grid in its template (ADR 0028). Give it the rows as `@data`, and declare one
|
|
13
|
+
`g.Column` for each column in its block. The grid makes the table from the declarations:
|
|
37
14
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
data: orders,
|
|
41
|
-
columns: [
|
|
42
|
-
selectionColumn(),
|
|
43
|
-
{ id: 'id', accessorKey: 'id', header: 'Order', meta: { lattice: { align: 'end' } } },
|
|
44
|
-
{ id: 'customer', accessorKey: 'customer', header: 'Customer' },
|
|
45
|
-
],
|
|
46
|
-
})
|
|
15
|
+
```gts
|
|
16
|
+
import { LatticeGrid } from '@ember-lattice/ember'
|
|
47
17
|
|
|
48
18
|
<template>
|
|
49
|
-
<LatticeGrid @
|
|
19
|
+
<LatticeGrid @data={{orders}} @label='Orders' @rowHeight={{32}} @overscan={{4}} as |g|>
|
|
20
|
+
<g.SelectionColumn />
|
|
21
|
+
<g.Column @id='id' @label='Order' @align='end' @sortable={{true}} />
|
|
22
|
+
<g.Column @id='customer' @label='Customer' @sortable={{true}} @resizable={{true}} />
|
|
23
|
+
<g.Column @id='total' @label='Total' @align='end'>
|
|
24
|
+
<:cell as |c|>{{money c.value}}</:cell>
|
|
25
|
+
</g.Column>
|
|
26
|
+
</LatticeGrid>
|
|
50
27
|
</template>
|
|
51
28
|
```
|
|
52
29
|
|
|
53
30
|
### Arguments
|
|
54
31
|
|
|
55
|
-
- `@
|
|
32
|
+
- `@data`: the rows. The grid makes the table from the declarations in its block. With no
|
|
33
|
+
declarations, it makes one column for each key of the first rows.
|
|
34
|
+
- `@table`: a table from `constructTable`, in place of `@data` (the engine form, below).
|
|
56
35
|
- `@label` (required): the accessible name of the grid.
|
|
36
|
+
- `@features`: more table features, with their row models, for example grouping or filtering.
|
|
37
|
+
The grid has sizing, resizing, sorting, visibility, order, pinning and row selection.
|
|
38
|
+
- `@initialState`, `@state` and `@onStateChange`: the table state. `@onStateChange` gets the
|
|
39
|
+
whole state after each change.
|
|
40
|
+
- `@tableOptions`: more table options, for a feature that has no arg (`globalFilterFn`).
|
|
57
41
|
- `@rowHeight`: the row height in px. When you do not give it, the grid reads the
|
|
58
42
|
`--lt-row-height` CSS property, so the density presets of the theme work.
|
|
59
43
|
- `@overscan`: the number of rows outside the view on each side. Default: 4.
|
|
60
|
-
- `@getRowId`: the ID of a row. Default: the table row ID.
|
|
44
|
+
- `@getRowId`: the ID of a row. With `@data`, it gets the data row. Default: the table row ID.
|
|
61
45
|
- `@onCellActivate`: the grid calls it on Enter or a double click on a data cell, with
|
|
62
46
|
`{ row, column }`.
|
|
63
47
|
- `@rowModel`: a row model from `@ember-lattice/data` (infinite, cursor, server or viewport).
|
|
64
48
|
The grid then shows the rows of the model, not `table.getRowModel()`. Rows that are not
|
|
65
|
-
loaded show as skeleton rows.
|
|
49
|
+
loaded show as skeleton rows. With `@data` or no table, give a function that makes the model
|
|
50
|
+
from the table of the grid: `ServerRowModel.forGrid({ source })`. The grid then gives its
|
|
51
|
+
table the `manual*` options. Contract: `docs/prd/2026-12-01-m2-grid-contract/index.html`,
|
|
52
|
+
section 7.
|
|
66
53
|
- `@stateHost`: a handle from `LatticeGrid.stateHost()`. The grid saves and restores the
|
|
67
54
|
scroll offset and the active cell through it. Give the same handle to
|
|
68
|
-
`persistGridState({ host })`. Make it before the grid renders (ADR 0011).
|
|
55
|
+
`persistGridState({ host })`. Make it before the grid renders (ADR 0011). With `@data`,
|
|
56
|
+
`host.table` is the table of the grid, and `persistGridState(host, options)` waits for it.
|
|
57
|
+
|
|
58
|
+
### Blocks
|
|
59
|
+
|
|
60
|
+
- The default block, or `<:columns>` when the grid has other named blocks: the declarations.
|
|
61
|
+
It yields `g.Column`, `g.ColumnGroup`, `g.SelectionColumn` and `g.RowNumberColumn`.
|
|
62
|
+
- `<:cell as |c|>` of a `g.Column`: the content of each cell. `c` has `value`, `text`, `data`
|
|
63
|
+
(the data row), `row`, `column`, `cell` and `state`.
|
|
64
|
+
- `<:header>` and `<:headerEnd>` of a `g.Column`: the header content, in place of the label and
|
|
65
|
+
after it. `<:editor>` (with `@ember-lattice/editing`): the editor of the cell.
|
|
66
|
+
- `<:toolbar>` and `<:statusBar>`: before and after the grid root. `<:sideBar>`: in the grid
|
|
67
|
+
root. Each gets `{ table, root }`. `<:contextMenu>`: the context menu, with `table`.
|
|
69
68
|
|
|
70
69
|
### Size
|
|
71
70
|
|
|
@@ -77,7 +76,8 @@ height with CSS, or set `block-size` on `.lt-grid-root`. Load the styles of
|
|
|
77
76
|
### Features
|
|
78
77
|
|
|
79
78
|
The grid uses each table feature that the table has. A table without a feature does not show
|
|
80
|
-
that feature.
|
|
79
|
+
that feature. A column sorts or resizes only with `@sortable={{true}}` or
|
|
80
|
+
`@resizable={{true}}`.
|
|
81
81
|
|
|
82
82
|
- Sorting (`rowSortingFeature`): click a header. Shift+click adds a column to the sort. Enter
|
|
83
83
|
on a header also sorts.
|
|
@@ -86,19 +86,24 @@ that feature.
|
|
|
86
86
|
end of a header, or focus it and push ArrowLeft or ArrowRight (10 px).
|
|
87
87
|
- Column order (`columnOrderingFeature`): drag a header to a different header.
|
|
88
88
|
- Pinning (`columnPinningFeature`): pinned columns stay at the inline start or the inline end.
|
|
89
|
+
`@pinned='start'` pins a column in the first render.
|
|
89
90
|
- Visibility (`columnVisibilityFeature`): the grid shows only the visible columns.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
`@hidden={{true}}` hides a column in the first render.
|
|
92
|
+
- Row selection (`rowSelectionFeature`): add `<g.SelectionColumn />`. Space toggles the row,
|
|
93
|
+
Shift+Space selects it, and Ctrl+A selects all rows.
|
|
94
|
+
- Header groups: put columns in a `<g.ColumnGroup @id @label>` for a group header row.
|
|
93
95
|
|
|
94
96
|
### Column options
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
The args of `g.Column` are the grid options of a column:
|
|
97
99
|
|
|
98
|
-
- `
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
-
|
|
100
|
+
- `@field` (the key of the value, default `@id`) or `@value` (a function of the data row).
|
|
101
|
+
- `<:cell>`, or `@cell`: a component. It gets `@cell`, `@row`, `@column`, `@value` and
|
|
102
|
+
`@state`.
|
|
103
|
+
- `@cellKind`: `'full'` (the default for a block or a component) or `'cheap'`.
|
|
104
|
+
- `@format`: a function that gives the text of a cell with no block or component.
|
|
105
|
+
- `@align`: `'start'`, `'end'` or `'center'`.
|
|
106
|
+
- `@columnDef`: more column def options, for a feature that has no arg.
|
|
102
107
|
|
|
103
108
|
### Cell state
|
|
104
109
|
|
|
@@ -123,6 +128,38 @@ new row in view then makes new components. The warning does nothing in productio
|
|
|
123
128
|
A `'cheap'` cell component is not keyed: it gets a different row when its slot gets a
|
|
124
129
|
different row. Use `'cheap'` only for a component with no state of its own.
|
|
125
130
|
|
|
131
|
+
### The engine form
|
|
132
|
+
|
|
133
|
+
Make the table yourself with `constructTable` from `@ember-lattice/core`, and give it as
|
|
134
|
+
`@table`. Use it for generated columns (the pivot columns, `autoColumns`) and for a table that
|
|
135
|
+
two surfaces share. The column options are then in `meta.lattice` of each column def. The guide
|
|
136
|
+
page "Engine API" (`features/engine-api.md`) shows it.
|
|
137
|
+
|
|
138
|
+
```gts
|
|
139
|
+
import {
|
|
140
|
+
constructTable,
|
|
141
|
+
emberReactivityBindings,
|
|
142
|
+
rowSelectionFeature,
|
|
143
|
+
tableFeatures,
|
|
144
|
+
} from '@ember-lattice/core'
|
|
145
|
+
import { LatticeGrid, selectionColumn } from '@ember-lattice/ember'
|
|
146
|
+
|
|
147
|
+
const table = constructTable({
|
|
148
|
+
features: tableFeatures({
|
|
149
|
+
coreReactivityFeature: emberReactivityBindings(),
|
|
150
|
+
rowSelectionFeature,
|
|
151
|
+
}),
|
|
152
|
+
data: orders,
|
|
153
|
+
columns: [
|
|
154
|
+
selectionColumn(),
|
|
155
|
+
{ id: 'id', accessorKey: 'id', header: 'Order', meta: { lattice: { align: 'end' } } },
|
|
156
|
+
{ id: 'customer', accessorKey: 'customer', header: 'Customer' },
|
|
157
|
+
],
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
<template><LatticeGrid @table={{table}} @label='Orders' /></template>
|
|
161
|
+
```
|
|
162
|
+
|
|
126
163
|
### Keyboard
|
|
127
164
|
|
|
128
165
|
The grid has one tab stop: the active cell. The arrow keys, Home, End, Ctrl+Home, Ctrl+End,
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type { TOC } from '@ember/component/template-only';
|
|
3
|
+
import type Owner from '@ember/owner';
|
|
4
|
+
import type { ComponentLike, WithBoundArgs } from '@glint/template';
|
|
5
|
+
import { ColumnRegistry } from '../grid/columns/registry.ts';
|
|
6
|
+
/** What the `<:header>` block of a lane gets. */
|
|
7
|
+
export interface BoardLaneHeaderBlock<K> {
|
|
8
|
+
/** The lane key: `@key`. */
|
|
9
|
+
key: K;
|
|
10
|
+
/** The lane name: `@label`. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The number of cards in the lane. */
|
|
13
|
+
count: number;
|
|
14
|
+
}
|
|
15
|
+
export interface LatticeBoardLaneSignature<K> {
|
|
16
|
+
Args: {
|
|
17
|
+
/** The lane key: the value that `@laneOf` gives for the items of the lane. */
|
|
18
|
+
key: K;
|
|
19
|
+
/** The lane name: the title, the name of the lane listbox and the text of the announcements. */
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
Blocks: {
|
|
23
|
+
/** The content of the lane title, in place of the label and the count. */
|
|
24
|
+
header: [BoardLaneHeaderBlock<K>];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface LatticeBoardCardSignature<T> {
|
|
28
|
+
Blocks: {
|
|
29
|
+
/** The content of a card, for each item. */
|
|
30
|
+
default: [item: T];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** The declarations that the board yields in the template form. */
|
|
34
|
+
export interface BoardDeclarations<T, K> {
|
|
35
|
+
/** One lane. The lanes show in template order. */
|
|
36
|
+
Lane: ComponentLike<LatticeBoardLaneSignature<K>>;
|
|
37
|
+
/** The content of each card. */
|
|
38
|
+
Card: ComponentLike<LatticeBoardCardSignature<T>>;
|
|
39
|
+
}
|
|
40
|
+
/** A lane in the registry of a board. */
|
|
41
|
+
export interface DeclaredLane {
|
|
42
|
+
readonly marker: Node;
|
|
43
|
+
readonly key: unknown;
|
|
44
|
+
readonly label: string;
|
|
45
|
+
/** True when the declaration has a `<:header>` block. */
|
|
46
|
+
readonly hasHeader: boolean;
|
|
47
|
+
}
|
|
48
|
+
export type LaneRegistry = ColumnRegistry<DeclaredLane>;
|
|
49
|
+
export declare const laneRegistry: () => LaneRegistry;
|
|
50
|
+
type LaneArgs = LatticeBoardLaneSignature<unknown>['Args'];
|
|
51
|
+
export declare class LaneDeclaration extends Component<{
|
|
52
|
+
Args: LaneArgs & {
|
|
53
|
+
registry: LaneRegistry;
|
|
54
|
+
};
|
|
55
|
+
Blocks: LatticeBoardLaneSignature<unknown>['Blocks'];
|
|
56
|
+
}> implements DeclaredLane {
|
|
57
|
+
/** A comment node: the place of the declaration in the template. */
|
|
58
|
+
readonly marker: Comment;
|
|
59
|
+
/** A plain field: the template sets it before the board reads the lanes. */
|
|
60
|
+
hasHeader: boolean;
|
|
61
|
+
constructor(owner: Owner, args: LaneArgs & {
|
|
62
|
+
registry: LaneRegistry;
|
|
63
|
+
});
|
|
64
|
+
willDestroy(): void;
|
|
65
|
+
get key(): unknown;
|
|
66
|
+
get label(): string;
|
|
67
|
+
/** The blocks are fixed for one invocation, so the first render sets this once. */
|
|
68
|
+
noteHeader: (header: boolean) => void;
|
|
69
|
+
}
|
|
70
|
+
/** A declaration that renders nothing in this mode. */
|
|
71
|
+
declare const Nothing: TOC<{
|
|
72
|
+
Args: Partial<LaneArgs>;
|
|
73
|
+
}>;
|
|
74
|
+
/** The declarations of declare mode. */
|
|
75
|
+
export interface DeclareParts {
|
|
76
|
+
Lane: WithBoundArgs<typeof LaneDeclaration, 'registry'>;
|
|
77
|
+
Card: typeof Nothing;
|
|
78
|
+
}
|
|
79
|
+
/** Yields the declarations of declare mode: each lane adds itself to the registry. */
|
|
80
|
+
export declare const DeclareMode: TOC<{
|
|
81
|
+
Args: {
|
|
82
|
+
registry: LaneRegistry;
|
|
83
|
+
};
|
|
84
|
+
Blocks: {
|
|
85
|
+
default: [DeclareParts];
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
declare const HeaderLane: TOC<{
|
|
89
|
+
Args: LaneArgs & {
|
|
90
|
+
target: unknown;
|
|
91
|
+
ctx: BoardLaneHeaderBlock<unknown>;
|
|
92
|
+
};
|
|
93
|
+
Blocks: LatticeBoardLaneSignature<unknown>['Blocks'];
|
|
94
|
+
}>;
|
|
95
|
+
/** Yields the declarations of header mode: only the lane `@target` renders its `<:header>`. */
|
|
96
|
+
export declare const HeaderMode: TOC<{
|
|
97
|
+
Args: {
|
|
98
|
+
target: unknown;
|
|
99
|
+
ctx: BoardLaneHeaderBlock<unknown>;
|
|
100
|
+
};
|
|
101
|
+
Blocks: {
|
|
102
|
+
default: [{
|
|
103
|
+
Lane: WithBoundArgs<typeof HeaderLane, 'target' | 'ctx'>;
|
|
104
|
+
Card: typeof Nothing;
|
|
105
|
+
}];
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
declare const CardItem: TOC<{
|
|
109
|
+
Args: {
|
|
110
|
+
item: unknown;
|
|
111
|
+
};
|
|
112
|
+
Blocks: {
|
|
113
|
+
default: [unknown];
|
|
114
|
+
};
|
|
115
|
+
}>;
|
|
116
|
+
/** Yields the declarations of card mode: only `<b.Card>` renders its block, with `@item`. */
|
|
117
|
+
export declare const CardMode: TOC<{
|
|
118
|
+
Args: {
|
|
119
|
+
item: unknown;
|
|
120
|
+
};
|
|
121
|
+
Blocks: {
|
|
122
|
+
default: [{
|
|
123
|
+
Lane: typeof Nothing;
|
|
124
|
+
Card: WithBoundArgs<typeof CardItem, 'item'>;
|
|
125
|
+
}];
|
|
126
|
+
};
|
|
127
|
+
}>;
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/board/declarations.gts"],"names":[],"mappings":"AA8KA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,iDAAiD;AACjD,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,4BAA4B;IAC5B,GAAG,EAAE,CAAC,CAAA;IAC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AAC;IAC3B,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAAE,CAAA;IAC7D,MAAM,EAAE;QACN,OAAO,EAAE,CAAC;YAAE,IAAI,EAAE,aAAa,CAAC,OAAO,UAAU,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC;YAAC,IAAI,EAAE,OAAO,OAAO,CAAA;SAAE,CAAC,CAAA;KAC9F,CAAA;CACF,CAMC,CAAA;AAEF,QAAA,MAAM,QAAQ,EAAE,GAAG,CAAC;IAAE,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAA;KAAE,CAAA;CAAE,CAG7E,CAAA;AAEF,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,EAAE,GAAG,CAAC;IACzB,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAA;IACvB,MAAM,EAAE;QACN,OAAO,EAAE,CAAC;YAAE,IAAI,EAAE,OAAO,OAAO,CAAC;YAAC,IAAI,EAAE,aAAa,CAAC,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAA;SAAE,CAAC,CAAA;KAClF,CAAA;CACF,CAMC,CAAA"}
|
|
@@ -2,21 +2,34 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import type Owner from '@ember/owner';
|
|
3
3
|
import type { SafeString } from '@ember/template';
|
|
4
4
|
import type { LatticeLocale, LatticeLocaleTextOverride } from '@ember-lattice/core';
|
|
5
|
-
|
|
5
|
+
import type { BoardDeclarations, BoardLaneHeaderBlock } from './declarations';
|
|
6
|
+
/**
|
|
7
|
+
* What the default block gets: in the engine form (with `@lanes`), an item; in the template form
|
|
8
|
+
* (no `@lanes`), the declarations.
|
|
9
|
+
*/
|
|
10
|
+
export type LatticeBoardBlock<T, K, L> = [L] extends [undefined] ? BoardDeclarations<T, K> : T;
|
|
11
|
+
/**
|
|
12
|
+
* `L` is the type of `@lanes`: `undefined` in the template form. Glint infers it from the args,
|
|
13
|
+
* so the block gets the type of its form.
|
|
14
|
+
*/
|
|
15
|
+
export interface LatticeBoardSignature<T, K, L extends ReadonlyArray<unknown> | undefined = ReadonlyArray<K>> {
|
|
6
16
|
Element: HTMLDivElement;
|
|
7
17
|
Args: {
|
|
8
18
|
/** All the items of the board. */
|
|
9
19
|
items: ReadonlyArray<T>;
|
|
10
20
|
/** The accessible name of the board. */
|
|
11
21
|
label: string;
|
|
12
|
-
/** The ID of an item. */
|
|
13
|
-
getItemId
|
|
14
|
-
/**
|
|
15
|
-
|
|
22
|
+
/** The ID of an item. Default: the `id` key of the item, as text. */
|
|
23
|
+
getItemId?: (item: T) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The engine form: the lane keys, in order. With `@lanes`, the block is the content of each
|
|
26
|
+
* card. With no `@lanes`, the block declares the lanes (`<b.Lane>`) and the card (`<b.Card>`).
|
|
27
|
+
*/
|
|
28
|
+
lanes?: L & ReadonlyArray<K>;
|
|
16
29
|
/** The lane key of an item. */
|
|
17
30
|
laneOf: (item: T) => K;
|
|
18
|
-
/** The label of a lane. */
|
|
19
|
-
laneLabel
|
|
31
|
+
/** The engine form: the label of a lane. Default: the lane key as text. */
|
|
32
|
+
laneLabel?: (lane: K) => string;
|
|
20
33
|
/**
|
|
21
34
|
* Called when the user drops a card. `toIndex` is the index in `toLane` after the move.
|
|
22
35
|
* Return a promise: the card shows the new place until it settles, and goes back on reject.
|
|
@@ -32,7 +45,11 @@ export interface LatticeBoardSignature<T, K> {
|
|
|
32
45
|
localeText?: LatticeLocaleTextOverride;
|
|
33
46
|
};
|
|
34
47
|
Blocks: {
|
|
35
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The engine form (`@lanes`): the content of a card, for each item. The template form (no
|
|
50
|
+
* `@lanes`): the declarations, `<b.Lane>` for each lane and `<b.Card>` for the card content.
|
|
51
|
+
*/
|
|
52
|
+
default: [LatticeBoardBlock<T, K, L>];
|
|
36
53
|
};
|
|
37
54
|
}
|
|
38
55
|
interface LaneView<T, K> {
|
|
@@ -41,8 +58,10 @@ interface LaneView<T, K> {
|
|
|
41
58
|
label: string;
|
|
42
59
|
titleId: string;
|
|
43
60
|
items: ReadonlyArray<T>;
|
|
61
|
+
/** The template form: the context of the `<:header>` block of the lane, or null. */
|
|
62
|
+
header: BoardLaneHeaderBlock<K> | null;
|
|
44
63
|
}
|
|
45
|
-
export default class LatticeBoard<T, K> extends Component<LatticeBoardSignature<T, K>> {
|
|
64
|
+
export default class LatticeBoard<T, K, L extends ReadonlyArray<unknown> | undefined = undefined> extends Component<LatticeBoardSignature<T, K, L>> {
|
|
46
65
|
/** The cards out of their data place: picked up, or with a move in progress. */
|
|
47
66
|
private overrides;
|
|
48
67
|
private held;
|
|
@@ -53,8 +72,20 @@ export default class LatticeBoard<T, K> extends Component<LatticeBoardSignature<
|
|
|
53
72
|
private _focusId;
|
|
54
73
|
private _suppressClick;
|
|
55
74
|
private _endDrag;
|
|
56
|
-
|
|
75
|
+
/** The template form: the `<b.Lane>` declarations of the block. */
|
|
76
|
+
registry: import('./declarations').LaneRegistry;
|
|
77
|
+
constructor(owner: Owner, args: LatticeBoardSignature<T, K, L>['Args']);
|
|
57
78
|
private get boardId();
|
|
79
|
+
/** True in the template form: the block declares the lanes and the card. */
|
|
80
|
+
get declared(): boolean;
|
|
81
|
+
/** The block value of its form: the type of the block depends on `@lanes` (`L`). */
|
|
82
|
+
asBlock: (value: unknown) => LatticeBoardBlock<T, K, L>;
|
|
83
|
+
/** The lane keys, in order: `@lanes`, or the `<b.Lane>` declarations in template order. */
|
|
84
|
+
get laneKeys(): ReadonlyArray<K>;
|
|
85
|
+
/** The template form: the declared lanes by key. */
|
|
86
|
+
private get declaredLanes();
|
|
87
|
+
/** The label of a lane: `@laneLabel`, or the `@label` of its declaration. */
|
|
88
|
+
private labelOf;
|
|
58
89
|
private get itemById();
|
|
59
90
|
/** The items of each lane, from the data only. */
|
|
60
91
|
private get baseLanes();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lattice-board.d.ts","sourceRoot":"","sources":["../../src/board/lattice-board.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lattice-board.d.ts","sourceRoot":"","sources":["../../src/board/lattice-board.gts"],"names":[],"mappings":"AAwxBA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAK1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAKjD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAgB,MAAM,oBAAoB,CAAA;AAE/F;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AAE9F;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CACpC,CAAC,EACD,CAAC,EACD,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC;IAE/D,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE;QACJ,kCAAkC;QAClC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;QACvB,wCAAwC;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,qEAAqE;QACrE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAA;QAC/B;;;WAGG;QACH,KAAK,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;QAC5B,+BAA+B;QAC/B,MAAM,EAAE,CAAC,IAAI,E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OAAO,CAAC,OAAO;IAIf,2FAA2F;IAC3F,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,WAAW;IASnB,0FAA0F;IAC1F,OAAO,CAAC,MAAM;IAoCd,KAAK;;;;;;OAQH;IAEF,6FAA6F;IAE7F,IAAI;;;;;;OAeF;IAIF,oEAAoE;IACpE,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,WAAW;IAMnB,SAAS,GAAI,OAAO,aAAa,UA4BhC;IAED,kDAAkD;IAClD,OAAO,CAAC,MAAM;IAQd,2FAA2F;IAC3F,OAAO,CAAC,KAAK;IAUb,UAAU,GAAI,OAAO,UAAU,UAAoC;IAGnE,qBAAqB,GAAI,OAAO,YAAY,UAA6B;IAEzE,wFAAwF;IACxF,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,UAAU;IAOlB,oFAAoF;IACpF,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,MAAM;IAOd,aAAa,GAAI,OAAO,YAAY,UAoGnC;IAED,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,MAAM;IAId,4FAA4F;IAC5F,OAAO,CAAC,KAAK;IAMb,mFAAmF;IACnF,OAAO,CAAC,KAAK;IAkDb,OAAO,GAAI,OAAO,UAAU,UAI3B;CAmMF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ComponentLike } from '@glint/template';
|
|
2
|
+
import type { GridColumn, GridColumnType, GridEditTrigger, GridRow, LatticeCellSignature, LatticeColumnMeta, LatticeHeaderLabelSignature, LatticeHeaderSignature } from '../types.ts';
|
|
3
|
+
/** A column def that the grid gives to `constructTable`. A structural type, as `GridTable`. */
|
|
4
|
+
export interface GridColumnDef {
|
|
5
|
+
id: string;
|
|
6
|
+
header?: unknown;
|
|
7
|
+
accessorKey?: string;
|
|
8
|
+
accessorFn?: (row: never, index: number) => unknown;
|
|
9
|
+
columns?: ReadonlyArray<GridColumnDef>;
|
|
10
|
+
meta?: {
|
|
11
|
+
lattice?: LatticeColumnMeta;
|
|
12
|
+
columnType?: GridColumnType;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
[option: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The args of `<g.Column>`. Each arg maps to one option of the column def. The interface is open:
|
|
19
|
+
* `@ember-lattice/editing` and `@ember-lattice/ui` add their args to it (declaration merging),
|
|
20
|
+
* and `columnDefOf` puts them in the `meta` key of their package.
|
|
21
|
+
*/
|
|
22
|
+
export interface LatticeColumnArgs {
|
|
23
|
+
/** The column ID: the key of the column in the table state and in a saved view. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** The header text. Export, menus, filters, the editor and the wire request read it. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** The key of the value in a data row (`accessorKey`). Default: `@id`. */
|
|
28
|
+
field?: string;
|
|
29
|
+
/** The value of a data row (`accessorFn`), in place of `@field`. */
|
|
30
|
+
value?: (row: never, index: number) => unknown;
|
|
31
|
+
size?: number;
|
|
32
|
+
minSize?: number;
|
|
33
|
+
maxSize?: number;
|
|
34
|
+
/** The share of the free width (the flex column feature). */
|
|
35
|
+
flex?: number;
|
|
36
|
+
/** True: the user can sort the column (`enableSorting`). Default: false. */
|
|
37
|
+
sortable?: boolean;
|
|
38
|
+
/** The sort function, or the name of one in the `sortFns` of the features (`sortFn`). */
|
|
39
|
+
sortFn?: unknown;
|
|
40
|
+
/** True: the user can resize the column (`enableResizing`). Default: false. */
|
|
41
|
+
resizable?: boolean;
|
|
42
|
+
/** False: the user cannot hide the column (`enableHiding`). */
|
|
43
|
+
hideable?: boolean;
|
|
44
|
+
/** False: the user cannot pin the column (`enablePinning`). */
|
|
45
|
+
pinnable?: boolean;
|
|
46
|
+
/** The filter function, or the name of one in the `filterFns` of the features (`filterFn`). */
|
|
47
|
+
filterFn?: unknown;
|
|
48
|
+
/** False: the user cannot filter the column (`enableColumnFilter`). */
|
|
49
|
+
filterable?: boolean;
|
|
50
|
+
/** True: the user can group by the column (`enableGrouping`). */
|
|
51
|
+
groupable?: boolean;
|
|
52
|
+
/** The aggregation function, or the name of one (`aggregationFn`). */
|
|
53
|
+
aggregate?: unknown;
|
|
54
|
+
/** A column type of `@ember-lattice/column-types` (`meta.columnType`). */
|
|
55
|
+
type?: GridColumnType;
|
|
56
|
+
/** The pin of the column in the first render: `start` or `end`. */
|
|
57
|
+
pinned?: 'start' | 'end';
|
|
58
|
+
/** True: the column is hidden in the first render. */
|
|
59
|
+
hidden?: boolean;
|
|
60
|
+
/** The text of a cell with no cell block (`meta.lattice.format`). */
|
|
61
|
+
format?: (value: unknown) => string;
|
|
62
|
+
align?: 'start' | 'end' | 'center';
|
|
63
|
+
/** `cheap`: a cell reuses its row slot. `full` (default): a cell is keyed by row ID (ADR 0002). */
|
|
64
|
+
cellKind?: 'cheap' | 'full';
|
|
65
|
+
tooltip?: (value: unknown, row: GridRow) => string | undefined;
|
|
66
|
+
editMode?: 'cell' | 'popup';
|
|
67
|
+
editTrigger?: GridEditTrigger;
|
|
68
|
+
rowDrag?: boolean;
|
|
69
|
+
cellDescription?: (row: GridRow, column: GridColumn) => string | undefined;
|
|
70
|
+
cellInvalid?: (row: GridRow, column: GridColumn) => boolean;
|
|
71
|
+
/** A cell component, in place of a cell block (`meta.lattice.cell`). */
|
|
72
|
+
cell?: ComponentLike<LatticeCellSignature>;
|
|
73
|
+
/** A component in place of the header text (`meta.lattice.headerLabel`). */
|
|
74
|
+
headerLabel?: ComponentLike<LatticeHeaderLabelSignature>;
|
|
75
|
+
/** A component after the header text (`meta.lattice.header`). */
|
|
76
|
+
headerEnd?: ComponentLike<LatticeHeaderSignature>;
|
|
77
|
+
/** More `meta`: the keys of other packages. */
|
|
78
|
+
meta?: Record<string, unknown>;
|
|
79
|
+
/** More column def options, for a feature that has no arg. The args win. */
|
|
80
|
+
columnDef?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The key of a data row, for `@field`. With no row type (`unknown`, or `never` inside the grid),
|
|
84
|
+
* any text.
|
|
85
|
+
*/
|
|
86
|
+
export type FieldOf<T> = [T] extends [never] ? string : unknown extends T ? string : keyof T & string;
|
|
87
|
+
/**
|
|
88
|
+
* The args of `<g.Column>` for the rows of type `T`: `@field` is a key of `T`, and `@value` takes a
|
|
89
|
+
* `T`. `LatticeGrid` infers `T` from `@data`, so Glint checks a field name.
|
|
90
|
+
*/
|
|
91
|
+
export type TypedColumnArgs<T> = Omit<LatticeColumnArgs, 'field' | 'value'> & {
|
|
92
|
+
field?: FieldOf<T>;
|
|
93
|
+
value?: (row: T, index: number) => unknown;
|
|
94
|
+
};
|
|
95
|
+
/** The named blocks of a declaration. */
|
|
96
|
+
export interface DeclaredBlocks {
|
|
97
|
+
cell: boolean;
|
|
98
|
+
header: boolean;
|
|
99
|
+
headerEnd: boolean;
|
|
100
|
+
editor?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export declare const NO_BLOCKS: DeclaredBlocks;
|
|
103
|
+
/** The column def of one `<g.Column>`. An arg that the app does not give is not in the def. */
|
|
104
|
+
export declare function columnDefOf(args: LatticeColumnArgs, blocks: DeclaredBlocks): GridColumnDef;
|
|
105
|
+
/** The initial pinning and visibility of the declarations (`@pinned`, `@hidden`). */
|
|
106
|
+
export declare function initialStateOf(args: ReadonlyArray<LatticeColumnArgs>): Record<string, unknown>;
|
|
107
|
+
/** The IDs that two or more declarations have. */
|
|
108
|
+
export declare function duplicateIds(args: ReadonlyArray<LatticeColumnArgs>): string[];
|
|
109
|
+
/** A column arg whose engine feature the table does not have. */
|
|
110
|
+
export interface MissingFeature {
|
|
111
|
+
id: string;
|
|
112
|
+
arg: string;
|
|
113
|
+
feature: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The args of the declarations that need a feature that is not in `features` (the keys of the
|
|
117
|
+
* table features). With no feature, the engine ignores the option, so the grid warns.
|
|
118
|
+
*/
|
|
119
|
+
export declare function missingFeatures(args: ReadonlyArray<LatticeColumnArgs>, features: ReadonlyArray<string>): MissingFeature[];
|
|
120
|
+
//# sourceMappingURL=column-def.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-def.d.ts","sourceRoot":"","sources":["../../../src/grid/columns/column-def.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,OAAO,EACP,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,aAAa,CAAA;AAEpB,+FAA+F;AAC/F,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IACnD,OAAO,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;IACtC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAC,UAAU,CAAC,EAAE,cAAc,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;IAC3F,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,EAAE,EAAE,MAAM,CAAA;IACV,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IAC9C,IAAI,CAAC,EAAE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