@ember-lattice/ember 0.0.0-stage → 1.1.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE.md +21 -0
  3. package/NOTICE +30 -0
  4. package/README.md +176 -2
  5. package/addon-main.cjs +4 -0
  6. package/declarations/board/declarations.d.ts +129 -0
  7. package/declarations/board/declarations.d.ts.map +1 -0
  8. package/declarations/board/lattice-board.d.ts +153 -0
  9. package/declarations/board/lattice-board.d.ts.map +1 -0
  10. package/declarations/grid/alignment.d.ts +30 -0
  11. package/declarations/grid/alignment.d.ts.map +1 -0
  12. package/declarations/grid/auto-columns.d.ts +22 -0
  13. package/declarations/grid/auto-columns.d.ts.map +1 -0
  14. package/declarations/grid/cell-state.d.ts +17 -0
  15. package/declarations/grid/cell-state.d.ts.map +1 -0
  16. package/declarations/grid/clipboard.d.ts +7 -0
  17. package/declarations/grid/clipboard.d.ts.map +1 -0
  18. package/declarations/grid/columns/column-def.d.ts +120 -0
  19. package/declarations/grid/columns/column-def.d.ts.map +1 -0
  20. package/declarations/grid/columns/declarations.d.ts +212 -0
  21. package/declarations/grid/columns/declarations.d.ts.map +1 -0
  22. package/declarations/grid/columns/memo.d.ts +32 -0
  23. package/declarations/grid/columns/memo.d.ts.map +1 -0
  24. package/declarations/grid/columns/owned-table.d.ts +40 -0
  25. package/declarations/grid/columns/owned-table.d.ts.map +1 -0
  26. package/declarations/grid/columns/registry.d.ts +13 -0
  27. package/declarations/grid/columns/registry.d.ts.map +1 -0
  28. package/declarations/grid/keyboard.d.ts +24 -0
  29. package/declarations/grid/keyboard.d.ts.map +1 -0
  30. package/declarations/grid/lattice-grid.d.ts +854 -0
  31. package/declarations/grid/lattice-grid.d.ts.map +1 -0
  32. package/declarations/grid/row-number.d.ts +24 -0
  33. package/declarations/grid/row-number.d.ts.map +1 -0
  34. package/declarations/grid/selection.d.ts +24 -0
  35. package/declarations/grid/selection.d.ts.map +1 -0
  36. package/declarations/grid/state-host.d.ts +66 -0
  37. package/declarations/grid/state-host.d.ts.map +1 -0
  38. package/declarations/grid/types.d.ts +417 -0
  39. package/declarations/grid/types.d.ts.map +1 -0
  40. package/declarations/index.d.ts +27 -0
  41. package/declarations/index.d.ts.map +1 -0
  42. package/declarations/list/lattice-list.d.ts +184 -0
  43. package/declarations/list/lattice-list.d.ts.map +1 -0
  44. package/dist/index.js +5031 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +92 -3
@@ -0,0 +1,184 @@
1
+ import Component from '@glimmer/component';
2
+ import type Owner from '@ember/owner';
3
+ import type { SafeString } from '@ember/template';
4
+ import type { LatticeLocale, LatticeLocaleTextOverride } from '@ember-lattice/core';
5
+ import { VirtualizerState } from '@ember-lattice/virtual';
6
+ export type ListRole = 'list' | 'feed' | 'listbox';
7
+ /** The source of `@table`: only its row model is read. */
8
+ export interface ListTable<T> {
9
+ getRowModel(): {
10
+ rows: ReadonlyArray<T>;
11
+ };
12
+ }
13
+ export interface LatticeListSignature<T> {
14
+ Element: HTMLDivElement;
15
+ Args: {
16
+ /** The items. Give this or `@table`. */
17
+ items?: ReadonlyArray<T>;
18
+ /** A Lattice table: the list shows the rows of its row model. */
19
+ table?: ListTable<T>;
20
+ /** The accessible name of the list. */
21
+ label: string;
22
+ /** `list` (default), `feed` or `listbox`. */
23
+ role?: ListRole;
24
+ /** The ID of an item. Required with `@items`. Default for table rows: `row.id`. */
25
+ getItemId?: (item: T) => string;
26
+ /** The estimated item height in px, before the item is measured. Default: 48. */
27
+ estimateSize?: number;
28
+ /** The number of items outside the view on each side. Default: 4. */
29
+ overscan?: number;
30
+ /** Listbox only: the IDs of the selected items. */
31
+ selection?: ReadonlySet<string>;
32
+ /** Listbox only: called with the new selection. The list does not keep it. */
33
+ onSelectionChange?: (selection: Set<string>) => void;
34
+ /** Listbox only: more than one item can be selected. */
35
+ multiselect?: boolean;
36
+ /** The number of lanes. More than 1: masonry, each item goes to the shortest lane. */
37
+ lanes?: number;
38
+ /** `rows` (default), or `cards`: equal-width cards, with the lanes from the width. */
39
+ layout?: 'rows' | 'cards';
40
+ /** The smallest card width in px, for `cards`. Default: 240. */
41
+ minCardWidth?: number;
42
+ /** `start` (default) or `end`: `end` starts at the bottom and stays there (chat). */
43
+ anchor?: 'start' | 'end';
44
+ /** Called when the end of the list comes into range. One call at a time. */
45
+ onLoadMore?: () => unknown;
46
+ /** Called when the start of the list comes into range. One call at a time. */
47
+ onLoadPrevious?: () => unknown;
48
+ /** Locale text that replaces the owner text and the English defaults for this list (ADR 0024). */
49
+ localeText?: LatticeLocaleTextOverride;
50
+ };
51
+ Blocks: {
52
+ default: [item: T, index: number];
53
+ };
54
+ }
55
+ interface ItemView<T> {
56
+ id: string;
57
+ item: T;
58
+ index: number;
59
+ held: boolean;
60
+ lane: number | undefined;
61
+ style: SafeString;
62
+ }
63
+ export default class LatticeList<T> extends Component<LatticeListSignature<T>> {
64
+ /** The ID of the item with the focus, or the listbox tab stop. It stays rendered. */
65
+ private _activeId;
66
+ state: VirtualizerState<HTMLElement>;
67
+ /** The width of the scroller, for the `cards` layout. */
68
+ private _width;
69
+ /** A load call is in progress at this edge. */
70
+ loadingStart: boolean;
71
+ loadingEnd: boolean;
72
+ private typeahead;
73
+ private _edgeCheckQueued;
74
+ /** False until a chat list has reached the bottom once: no load before that. */
75
+ private _ready;
76
+ private _root;
77
+ /** An item to focus when its element renders. */
78
+ private _focusId;
79
+ constructor(owner: Owner, args: LatticeListSignature<T>['Args']);
80
+ /** The locale text of this component (ADR 0024): `@localeText`, then the owner text. */
81
+ get l(): LatticeLocale;
82
+ get role(): ListRole;
83
+ get itemRole(): "option" | "article" | "listitem";
84
+ get estimate(): number;
85
+ get layout(): "rows" | "cards";
86
+ get isCards(): boolean;
87
+ get lanes(): number;
88
+ get overscan(): number;
89
+ get items(): ReadonlyArray<T>;
90
+ idOf(item: T): string;
91
+ get ids(): ReadonlyArray<string>;
92
+ get indexById(): Map<string, number>;
93
+ /** The listbox tab stop: the active option, else the first option. */
94
+ get tabStopId(): string | undefined;
95
+ /** The index of the item that stays rendered out of range (the focus or the tab stop), or -1. */
96
+ get heldIndex(): number;
97
+ get multiselect(): boolean;
98
+ tabIndexFor: (id: string) => 0 | -1 | undefined;
99
+ selectedFor: (id: string) => "true" | "false" | undefined;
100
+ private options;
101
+ get views(): Array<ItemView<T>>;
102
+ get busy(): boolean;
103
+ private queueEdgeCheck;
104
+ /**
105
+ * Call a load function when its edge is in the rendered range. It runs only on a range change,
106
+ * so a load that adds no items is not called again until the range changes.
107
+ */
108
+ private checkEdges;
109
+ private load;
110
+ private setLoading;
111
+ get sizerStyle(): import("@ember/template").TrustedHTML;
112
+ /** Give the virtualizer the current items. It runs after render, never during it. */
113
+ sync: import("ember-modifier").FunctionBasedModifier<{
114
+ Args: {
115
+ Positional: [readonly string[], number, number, number];
116
+ Named: import("ember-modifier/-private/signature").EmptyObject;
117
+ };
118
+ Element: HTMLElement;
119
+ }>;
120
+ /** The `cards` layout: read the width of the scroller when it changes. */
121
+ observeWidth: import("ember-modifier").FunctionBasedModifier<{
122
+ Args: {
123
+ Positional: [boolean];
124
+ Named: import("ember-modifier/-private/signature").EmptyObject;
125
+ };
126
+ Element: HTMLElement;
127
+ }>;
128
+ /** A chat list starts at the bottom. */
129
+ startAtEnd: import("ember-modifier").FunctionBasedModifier<{
130
+ Args: {
131
+ Positional: unknown[];
132
+ Named: import("ember-modifier/-private/signature").EmptyObject;
133
+ };
134
+ Element: Element;
135
+ }>;
136
+ /** Measure an item element (ResizeObserver, through the virtualizer). */
137
+ measure: import("ember-modifier").FunctionBasedModifier<{
138
+ Args: {
139
+ Positional: [string, number];
140
+ Named: import("ember-modifier/-private/signature").EmptyObject;
141
+ };
142
+ Element: HTMLElement;
143
+ }>;
144
+ /**
145
+ * A feed article is labelled by its title, when the item marks one with `data-lt-item-title`.
146
+ * shortcut: read when the item renders; a title that the item adds later is not seen.
147
+ */
148
+ private labelArticle;
149
+ setup: import("ember-modifier").FunctionBasedModifier<{
150
+ Args: {
151
+ Positional: unknown[];
152
+ Named: import("ember-modifier/-private/signature").EmptyObject;
153
+ };
154
+ Element: HTMLElement;
155
+ }>;
156
+ /** The time of the last pointer press on the page, to tell a click-out from a DOM move. */
157
+ private _pointerDownAt;
158
+ /**
159
+ * A keyed `{{#each}}` moves the focused item in the DOM when the items before it change, and
160
+ * the browser then blurs it with no `relatedTarget`. After the render, give the focus back to
161
+ * the active item. A blur from a pointer press, or to outside the page, is a real blur.
162
+ * shortcut: as in the Grid, a script call of `blur()` on an item also gets the focus back.
163
+ */
164
+ onFocusOut: (event: FocusEvent) => void;
165
+ private itemElement;
166
+ private itemOf;
167
+ /** Make an item active, scroll it into view, and focus it after the render. */
168
+ private activate;
169
+ private select;
170
+ onKeyDown: (event: KeyboardEvent) => void;
171
+ /** The APG feed keys: PageDown and PageUp move to the next and the previous article. */
172
+ private feedKey;
173
+ /** The APG listbox keys. */
174
+ private listboxKey;
175
+ /**
176
+ * shortcut: typeahead searches the rendered options only (their text is in the DOM); add an
177
+ * item text argument if a search must reach items out of range.
178
+ */
179
+ private typeaheadKey;
180
+ onClick: (event: MouseEvent) => void;
181
+ onFocusIn: (event: FocusEvent) => void;
182
+ }
183
+ export {};
184
+ //# sourceMappingURL=lattice-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lattice-list.d.ts","sourceRoot":"","sources":["../../src/list/lattice-list.gts"],"names":[],"mappings":"AA0lBA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAI1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACnF,OAAO,EAAiB,gBAAgB,EAAyB,MAAM,wBAAwB,CAAA;AAI/F,MAAM,MAAM,QAAQ,GAAG,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