@genesislcap/foundation-workspace 15.90.1 → 15.90.3

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.
@@ -2156,7 +2156,7 @@
2156
2156
  "kind": "field",
2157
2157
  "name": "gridElement",
2158
2158
  "type": {
2159
- "text": "GridPro | GridProLegacy | null"
2159
+ "text": "Grid | null"
2160
2160
  },
2161
2161
  "privacy": "private",
2162
2162
  "default": "null",
@@ -2166,7 +2166,7 @@
2166
2166
  "kind": "field",
2167
2167
  "name": "gridApi",
2168
2168
  "type": {
2169
- "text": "GridPro['gridApi'] | GridProLegacy['gridApi'] | null"
2169
+ "text": "Grid['gridApi'] | null"
2170
2170
  },
2171
2171
  "privacy": "private",
2172
2172
  "default": "null"
@@ -2182,24 +2182,62 @@
2182
2182
  "description": "Only the v29 grid has a column API; on v36 the column state lives on `gridApi`."
2183
2183
  },
2184
2184
  {
2185
- "kind": "method",
2186
- "name": "findAndRegisterGrid",
2185
+ "kind": "field",
2186
+ "name": "registeredKey",
2187
+ "type": {
2188
+ "text": "string | null"
2189
+ },
2187
2190
  "privacy": "private",
2188
- "return": {
2189
- "type": {
2190
- "text": "void"
2191
- }
2192
- }
2191
+ "default": "null",
2192
+ "description": "The key the current grid is registered under, so a replaced or removed grid is unregistered."
2193
2193
  },
2194
2194
  {
2195
2195
  "kind": "field",
2196
- "name": "handleGridReady",
2196
+ "name": "connectedAt",
2197
+ "type": {
2198
+ "text": "number"
2199
+ },
2197
2200
  "privacy": "private",
2201
+ "default": "0"
2202
+ },
2203
+ {
2204
+ "kind": "field",
2205
+ "name": "gridTag",
2206
+ "type": {
2207
+ "text": "string"
2208
+ },
2209
+ "privacy": "private",
2210
+ "description": "Custom element names are lowercase, so a prefix like `Rapid` still matches `rapid-grid-pro`.",
2198
2211
  "readonly": true
2199
2212
  },
2213
+ {
2214
+ "kind": "field",
2215
+ "name": "handleGridReady",
2216
+ "privacy": "private",
2217
+ "readonly": true,
2218
+ "description": "`gridReady` bubbles and is composed, so it reaches this host from a grid in any shadow root."
2219
+ },
2220
+ {
2221
+ "kind": "method",
2222
+ "name": "useGrid",
2223
+ "privacy": "private",
2224
+ "return": {
2225
+ "type": {
2226
+ "text": "void"
2227
+ }
2228
+ },
2229
+ "parameters": [
2230
+ {
2231
+ "name": "grid",
2232
+ "type": {
2233
+ "text": "Grid"
2234
+ }
2235
+ }
2236
+ ]
2237
+ },
2200
2238
  {
2201
2239
  "kind": "method",
2202
- "name": "attachToGridApis",
2240
+ "name": "attachToGridApi",
2203
2241
  "privacy": "private",
2204
2242
  "return": {
2205
2243
  "type": {
@@ -2209,7 +2247,7 @@
2209
2247
  },
2210
2248
  {
2211
2249
  "kind": "method",
2212
- "name": "detachFromGridApis",
2250
+ "name": "unregister",
2213
2251
  "privacy": "private",
2214
2252
  "return": {
2215
2253
  "type": {
@@ -4,6 +4,10 @@ import { GridRegistry } from '../grid-registry';
4
4
  * Registers an AG Grid instance so workspace state can apply/load it. Registering applies the
5
5
  * grid's stored column state (from the loaded workspace, or its last state this session) — see
6
6
  * `DefaultGridRegistry`.
7
+ * @remarks
8
+ * The grid may be a light-DOM child or rendered inside a descendant's open shadow root (e.g.
9
+ * `<entity-management>`). A grid that becomes ready later, or replaces a removed one, is picked up
10
+ * from its composed `gridReady` event. A grid inside a nested `grid-register` belongs to that one.
7
11
  * @alpha
8
12
  */
9
13
  export declare class GridRegister extends FoundationElement {
@@ -15,11 +19,17 @@ export declare class GridRegister extends FoundationElement {
15
19
  private gridApi;
16
20
  /** Only the v29 grid has a column API; on v36 the column state lives on `gridApi`. */
17
21
  private columnApi;
22
+ /** The key the current grid is registered under, so a replaced or removed grid is unregistered. */
23
+ private registeredKey;
24
+ private connectedAt;
25
+ /** Custom element names are lowercase, so a prefix like `Rapid` still matches `rapid-grid-pro`. */
26
+ private get gridTag();
18
27
  connectedCallback(): void;
19
28
  disconnectedCallback(): void;
20
- private findAndRegisterGrid;
29
+ /** `gridReady` bubbles and is composed, so it reaches this host from a grid in any shadow root. */
21
30
  private readonly handleGridReady;
22
- private attachToGridApis;
23
- private detachFromGridApis;
31
+ private useGrid;
32
+ private attachToGridApi;
33
+ private unregister;
24
34
  }
25
35
  //# sourceMappingURL=grid-register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid-register.d.ts","sourceRoot":"","sources":["../../../../src/workspace/grid-register/grid-register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD;;;;;GAKG;AACH,qBAIa,YAAa,SAAQ,iBAAiB;IAChB,OAAO,EAAE,MAAM,CAAC;IACJ,kBAAkB,EAAE,MAAM,CAAW;IAEpE,YAAY,EAAE,YAAY,CAAC;IAEzC,oGAAoG;IACpG,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,OAAO,CAA8D;IAC7E,sFAAsF;IACtF,OAAO,CAAC,SAAS,CAA0B;IAE3C,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAS5B,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAE9B;IAEF,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,kBAAkB;CAS3B"}
1
+ {"version":3,"file":"grid-register.d.ts","sourceRoot":"","sources":["../../../../src/workspace/grid-register/grid-register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiEhD;;;;;;;;;GASG;AACH,qBAIa,YAAa,SAAQ,iBAAiB;IAChB,OAAO,EAAE,MAAM,CAAC;IACJ,kBAAkB,EAAE,MAAM,CAAW;IAEpE,YAAY,EAAE,YAAY,CAAC;IAEzC,oGAAoG;IACpG,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAgC;IAC/C,sFAAsF;IACtF,OAAO,CAAC,SAAS,CAA0B;IAC3C,mGAAmG;IACnG,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,WAAW,CAAK;IAExB,mGAAmG;IACnG,OAAO,KAAK,OAAO,GAElB;IAED,iBAAiB,IAAI,IAAI;IAYzB,oBAAoB,IAAI,IAAI;IAc5B,mGAAmG;IACnG,OAAO,CAAC,QAAQ,CAAC,eAAe,CAY9B;IAEF,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,UAAU;CASnB"}
@@ -2,10 +2,62 @@ import { __decorate } from "tslib";
2
2
  import { FoundationElement, attr, customElement } from '@genesislcap/web-core';
3
3
  import { GridRegistry } from '../grid-registry';
4
4
  import { GridRegisterTemplate as template } from './grid-register.template';
5
+ /**
6
+ * How long a register must stay connected without finding a grid before disconnecting warns.
7
+ * Layouts create throwaway copies of their panes (rapid-layout does), which disconnect before a
8
+ * late grid such as entity-management's has rendered; a misconfigured register stays mounted.
9
+ */
10
+ const MISSING_GRID_WARNING_GRACE_MS = 2000;
11
+ /** Up one step in the flat tree: to the assigned slot, else the parent, else a shadow root's host. */
12
+ const flatParent = (node) => {
13
+ var _a, _b, _c;
14
+ return (_c = (_b = (_a = node.assignedSlot) !== null && _a !== void 0 ? _a : node.parentNode) !== null && _b !== void 0 ? _b : (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.host : null)) !== null && _c !== void 0 ? _c : null;
15
+ };
16
+ /**
17
+ * The `grid-register` that owns `node`: the nearest one above it in the flat tree, the same order
18
+ * as a composed event's path. A grid slotted into a nested register belongs to that register, so
19
+ * nested registers never share a grid.
20
+ */
21
+ const owningRegister = (node) => {
22
+ for (let current = flatParent(node); current; current = flatParent(current)) {
23
+ if (current.localName === 'grid-register') {
24
+ return current;
25
+ }
26
+ }
27
+ return null;
28
+ };
29
+ /**
30
+ * Finds the first grid `owner` owns, a tree scope at a time: the light DOM first, natively, then
31
+ * the open shadow roots beneath it. So a light-DOM grid wins over one in a descendant's shadow root.
32
+ */
33
+ const findOwnedGrid = (root, gridTag, owner) => {
34
+ const isOwned = (element) => owningRegister(element) === owner;
35
+ // `getElementsByTagName` matches the tag exactly, without parsing the prefix as a selector.
36
+ const candidates = root === owner ? root.getElementsByTagName(gridTag) : root.querySelectorAll('*');
37
+ for (const element of candidates) {
38
+ if (element.localName === gridTag && isOwned(element)) {
39
+ return element;
40
+ }
41
+ }
42
+ for (const element of root.querySelectorAll('*')) {
43
+ // A host another register owns can only hold grids that register (or a deeper one) owns.
44
+ if (element.shadowRoot && isOwned(element)) {
45
+ const found = findOwnedGrid(element.shadowRoot, gridTag, owner);
46
+ if (found) {
47
+ return found;
48
+ }
49
+ }
50
+ }
51
+ return null;
52
+ };
5
53
  /**
6
54
  * Registers an AG Grid instance so workspace state can apply/load it. Registering applies the
7
55
  * grid's stored column state (from the loaded workspace, or its last state this session) — see
8
56
  * `DefaultGridRegistry`.
57
+ * @remarks
58
+ * The grid may be a light-DOM child or rendered inside a descendant's open shadow root (e.g.
59
+ * `<entity-management>`). A grid that becomes ready later, or replaces a removed one, is picked up
60
+ * from its composed `gridReady` event. A grid inside a nested `grid-register` belongs to that one.
9
61
  * @alpha
10
62
  */
11
63
  let GridRegister = class GridRegister extends FoundationElement {
@@ -17,70 +69,80 @@ let GridRegister = class GridRegister extends FoundationElement {
17
69
  this.gridApi = null;
18
70
  /** Only the v29 grid has a column API; on v36 the column state lives on `gridApi`. */
19
71
  this.columnApi = null;
20
- this.handleGridReady = () => {
21
- this.attachToGridApis();
72
+ /** The key the current grid is registered under, so a replaced or removed grid is unregistered. */
73
+ this.registeredKey = null;
74
+ this.connectedAt = 0;
75
+ /** `gridReady` bubbles and is composed, so it reaches this host from a grid in any shadow root. */
76
+ this.handleGridReady = (event) => {
77
+ var _a;
78
+ const path = event.composedPath();
79
+ const grid = path.find((target) => target.localName === this.gridTag);
80
+ if (!grid || owningRegister(grid) !== this) {
81
+ return;
82
+ }
83
+ // Stay with the first grid while it is mounted, but take over from one that was removed
84
+ // (e.g. a grid re-rendered by `when(...)`), whose API grid-pro has destroyed.
85
+ if (grid === this.gridElement || !((_a = this.gridElement) === null || _a === void 0 ? void 0 : _a.isConnected)) {
86
+ this.useGrid(grid);
87
+ }
22
88
  };
23
89
  }
90
+ /** Custom element names are lowercase, so a prefix like `Rapid` still matches `rapid-grid-pro`. */
91
+ get gridTag() {
92
+ return `${this.designSystemPrefix}-grid-pro`.toLowerCase();
93
+ }
24
94
  connectedCallback() {
25
95
  super.connectedCallback();
26
- this.findAndRegisterGrid();
96
+ this.connectedAt = Date.now();
97
+ this.addEventListener('gridReady', this.handleGridReady);
98
+ // A grid that is already ready (e.g. a layout move reconnecting this register) fires no
99
+ // `gridReady`; any grid that becomes ready later does, and is registered from it.
100
+ const found = findOwnedGrid(this, this.gridTag, this);
101
+ if (found) {
102
+ this.useGrid(found);
103
+ }
27
104
  }
28
105
  disconnectedCallback() {
29
106
  super.disconnectedCallback();
30
- if (this.gridKey) {
31
- this.gridRegistry.unregisterGrid(this.gridKey);
107
+ this.removeEventListener('gridReady', this.handleGridReady);
108
+ this.unregister();
109
+ // Nothing else reports a prefix mismatch, a closed shadow root or a tag typo.
110
+ if (!this.gridElement && Date.now() - this.connectedAt >= MISSING_GRID_WARNING_GRACE_MS) {
111
+ console.warn(`grid-register: no ${this.gridTag} element found for grid-key "${this.gridKey}"`);
32
112
  }
33
- this.detachFromGridApis();
113
+ this.gridElement = null;
34
114
  }
35
- findAndRegisterGrid() {
36
- const gridTag = `${this.designSystemPrefix}-grid-pro`;
37
- this.gridElement = this.querySelector(gridTag);
38
- if (this.gridElement) {
39
- this.gridElement.addEventListener('gridReady', this.handleGridReady);
40
- this.attachToGridApis();
41
- }
42
- else {
43
- setTimeout(() => {
44
- this.gridElement = this.querySelector(gridTag);
45
- if (this.gridElement) {
46
- this.gridElement.addEventListener('gridReady', this.handleGridReady);
47
- this.attachToGridApis();
48
- }
49
- else {
50
- console.warn(`grid-register: ${gridTag} element not found`);
51
- }
52
- }, 100);
53
- }
115
+ useGrid(grid) {
116
+ this.gridElement = grid;
117
+ this.attachToGridApi();
54
118
  }
55
- attachToGridApis() {
56
- var _a;
57
- if (!this.gridElement) {
58
- return;
59
- }
60
- const anyGrid = this.gridElement;
61
- const gridApi = anyGrid.gridApi || null;
62
- const columnApi = ('columnApi' in anyGrid && anyGrid.columnApi) || null;
63
- const persistKey = ((_a = anyGrid === null || anyGrid === void 0 ? void 0 : anyGrid.getAttribute) === null || _a === void 0 ? void 0 : _a.call(anyGrid, 'persist-column-state-key')) || this.gridKey;
119
+ attachToGridApi() {
120
+ const grid = this.gridElement;
121
+ const gridApi = grid.gridApi || null;
64
122
  if (!gridApi || this.gridApi === gridApi) {
65
123
  return;
66
124
  }
67
125
  this.gridApi = gridApi;
68
- this.columnApi = columnApi;
126
+ this.columnApi = ('columnApi' in grid && grid.columnApi) || null;
127
+ const persistKey = grid.getAttribute('persist-column-state-key') || this.gridKey;
128
+ // Re-registering the same key keeps the outgoing grid's state; a different key must let go of it.
129
+ if (this.registeredKey && this.registeredKey !== persistKey) {
130
+ this.unregister();
131
+ }
69
132
  if (!persistKey) {
70
133
  console.warn('grid-register: missing persist-column-state-key; grid state will not be saved');
134
+ return;
71
135
  }
72
- else {
73
- this.gridKey = persistKey;
74
- // The element is grid-pro's own filter persistence (`setFilterModel`), so a workspace's
75
- // filters survive grid-pro restoring its persisted filter model after registration.
76
- this.gridRegistry.registerGrid(persistKey, gridApi, columnApi, anyGrid);
77
- }
136
+ // The element is grid-pro's own filter persistence (`setFilterModel`), so a workspace's
137
+ // filters survive grid-pro restoring its persisted filter model after registration.
138
+ this.gridRegistry.registerGrid(persistKey, gridApi, this.columnApi, grid);
139
+ this.registeredKey = persistKey;
78
140
  }
79
- detachFromGridApis() {
80
- if (this.gridElement && this.handleGridReady) {
81
- this.gridElement.removeEventListener('gridReady', this.handleGridReady);
141
+ unregister() {
142
+ if (this.registeredKey) {
143
+ this.gridRegistry.unregisterGrid(this.registeredKey);
82
144
  }
83
- this.gridElement = null;
145
+ this.registeredKey = null;
84
146
  this.gridApi = null;
85
147
  this.columnApi = null;
86
148
  }
@@ -956,7 +956,7 @@
956
956
  {
957
957
  "kind": "Class",
958
958
  "canonicalReference": "@genesislcap/foundation-workspace!GridRegister:class",
959
- "docComment": "/**\n * Registers an AG Grid instance so workspace state can apply/load it. Registering applies the grid's stored column state (from the loaded workspace, or its last state this session) — see `DefaultGridRegistry`.\n *\n * @alpha\n */\n",
959
+ "docComment": "/**\n * Registers an AG Grid instance so workspace state can apply/load it. Registering applies the grid's stored column state (from the loaded workspace, or its last state this session) — see `DefaultGridRegistry`.\n *\n * @remarks\n *\n * The grid may be a light-DOM child or rendered inside a descendant's open shadow root (e.g. `<entity-management>`). A grid that becomes ready later, or replaces a removed one, is picked up from its composed `gridReady` event. A grid inside a nested `grid-register` belongs to that one.\n *\n * @alpha\n */\n",
960
960
  "excerptTokens": [
961
961
  {
962
962
  "kind": "Content",
@@ -232,6 +232,10 @@ export declare interface GridFilterPersistence {
232
232
  * Registers an AG Grid instance so workspace state can apply/load it. Registering applies the
233
233
  * grid's stored column state (from the loaded workspace, or its last state this session) — see
234
234
  * `DefaultGridRegistry`.
235
+ * @remarks
236
+ * The grid may be a light-DOM child or rendered inside a descendant's open shadow root (e.g.
237
+ * `<entity-management>`). A grid that becomes ready later, or replaces a removed one, is picked up
238
+ * from its composed `gridReady` event. A grid inside a nested `grid-register` belongs to that one.
235
239
  * @alpha
236
240
  */
237
241
  export declare class GridRegister extends FoundationElement {
@@ -243,12 +247,18 @@ export declare class GridRegister extends FoundationElement {
243
247
  private gridApi;
244
248
  /** Only the v29 grid has a column API; on v36 the column state lives on `gridApi`. */
245
249
  private columnApi;
250
+ /** The key the current grid is registered under, so a replaced or removed grid is unregistered. */
251
+ private registeredKey;
252
+ private connectedAt;
253
+ /** Custom element names are lowercase, so a prefix like `Rapid` still matches `rapid-grid-pro`. */
254
+ private get gridTag();
246
255
  connectedCallback(): void;
247
256
  disconnectedCallback(): void;
248
- private findAndRegisterGrid;
257
+ /** `gridReady` bubbles and is composed, so it reaches this host from a grid in any shadow root. */
249
258
  private readonly handleGridReady;
250
- private attachToGridApis;
251
- private detachFromGridApis;
259
+ private useGrid;
260
+ private attachToGridApi;
261
+ private unregister;
252
262
  }
253
263
 
254
264
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-workspace",
3
3
  "description": "Genesis Foundation Workspace Components and State",
4
- "version": "15.90.1",
4
+ "version": "15.90.3",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -48,22 +48,22 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
- "@genesislcap/foundation-testing": "15.90.1",
52
- "@genesislcap/genx": "15.90.1",
53
- "@genesislcap/ts-builder": "15.90.1",
54
- "@genesislcap/uvu-playwright-builder": "15.90.1",
55
- "@genesislcap/vite-builder": "15.90.1",
56
- "@genesislcap/webpack-builder": "15.90.1"
51
+ "@genesislcap/foundation-testing": "15.90.3",
52
+ "@genesislcap/genx": "15.90.3",
53
+ "@genesislcap/ts-builder": "15.90.3",
54
+ "@genesislcap/uvu-playwright-builder": "15.90.3",
55
+ "@genesislcap/vite-builder": "15.90.3",
56
+ "@genesislcap/webpack-builder": "15.90.3"
57
57
  },
58
58
  "dependencies": {
59
59
  "@ag-grid-community/core": "29.2.0",
60
- "@genesislcap/foundation-comms": "15.90.1",
61
- "@genesislcap/foundation-layout": "15.90.1",
62
- "@genesislcap/foundation-notifications": "15.90.1",
63
- "@genesislcap/foundation-ui": "15.90.1",
64
- "@genesislcap/foundation-utils": "15.90.1",
65
- "@genesislcap/grid-pro": "15.90.1",
66
- "@genesislcap/web-core": "15.90.1"
60
+ "@genesislcap/foundation-comms": "15.90.3",
61
+ "@genesislcap/foundation-layout": "15.90.3",
62
+ "@genesislcap/foundation-notifications": "15.90.3",
63
+ "@genesislcap/foundation-ui": "15.90.3",
64
+ "@genesislcap/foundation-utils": "15.90.3",
65
+ "@genesislcap/grid-pro": "15.90.3",
66
+ "@genesislcap/web-core": "15.90.3"
67
67
  },
68
68
  "repository": {
69
69
  "type": "git",