@blueprintui/grid 0.0.1 → 0.0.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.
@@ -1 +1 @@
1
- const t=new CSSStyleSheet;t.replaceSync(":host{--border-right:var(--cell-border-width) solid var(--bp-object-border-color-100);--border-left:0;--min-width:var(--bp-size-9);--min-height:var(--bp-size-9);--font-size:var(--bp-text-size-200);--justify-content:var(--cell-justify-content, start);--padding-block:var(--bp-size-4);--padding-inline:var(--bp-size-6);--color:var(--bp-text-color-500);display:block;height:100%;outline:0!important;position:sticky}slot{justify-content:var(--justify-content);border-left:var(--border-left);background:var(--background);background-image:linear-gradient(hsla(0deg,0%,0%,var(--bp-interaction-offset))0 0)!important;box-shadow:var(--box-shadow);border-right:var(--border-right);min-width:var(--min-width);min-height:var(--min-height);font-size:var(--font-size);padding-inline:var(--padding-inline);padding-block:var(--padding-block);color:var(--color);text-align:left;display:flex;gap:var(--bp-space-sm);line-height:1em;align-items:center;width:100%;height:100%;position:relative}:host([type='action']){--padding-block:0;--padding-inline-start:0;--padding-inline-end:0}:host([type='action']) slot{justify-content:center;min-width:var(--bp-size-8)}:host([highlight]) slot::after{display:block;position:absolute;inset:0;background:var(--bp-interaction-highlight-background);content:\"\";pointer-events:none}[focusable]{outline-offset:calc(var(--bp-size-2)*-1)!important}@media not all and (min-resolution:.001dpcm){@supports (-webkit-appearance:none) and (stroke-color:transparent){[focusable]{outline-offset:calc(var(--bp-size-3)*-1)!important}}}:host([type='action']:focus-within) [focusable]{outline:var(--bp-interaction-outline-webkit)!important;outline-offset:calc(var(--bp-size-2)*-1)!important}:host([type='action']:focus-within) ::slotted(*){outline:0!important;--bp-interaction-outline-webkit:none!important;--bp-interaction-outline-offset:none!important}:host(:focus) [focusable]{outline:var(--bp-interaction-outline-webkit);outline-offset:calc(var(--bp-size-2)*-1)!important}:host([role='rowheader']){--bp-interaction-offset:calc(var(--bp-interaction-selected-offset) * 0.9);--cell-border-width:var(--bp-size-1)}");export{t as default};
1
+ const t=new CSSStyleSheet;t.replaceSync(":host{--border-right:var(--cell-border-width) solid var(--bp-object-border-color-100);--border-left:0;--min-width:var(--bp-size-9);--min-height:var(--bp-size-9);--font-size:var(--bp-text-size-200);--justify-content:var(--cell-justify-content, start);--padding-block:var(--bp-size-4);--padding-inline:var(--bp-size-6);--color:var(--bp-text-color-500);display:block;height:100%;outline:0!important;position:sticky}slot{justify-content:var(--justify-content);border-left:var(--border-left);background:var(--background);background-image:linear-gradient(hsla(0deg,0%,0%,var(--bp-interaction-offset))0 0)!important;box-shadow:var(--box-shadow);border-right:var(--border-right);min-width:var(--min-width);min-height:var(--min-height);font-size:var(--font-size);padding-inline:var(--padding-inline);padding-block:var(--padding-block);color:var(--color);text-align:left;display:flex;gap:var(--bp-space-sm);line-height:1em;align-items:center;width:100%;height:100%;position:relative}:host([type='action']){--padding-block:0;--padding-inline-start:0;--padding-inline-end:0}:host([type='action']) slot{justify-content:center;min-width:var(--bp-size-8)}:host([highlight]) slot::after{display:block;position:absolute;inset:0;background:var(--bp-interaction-highlight-background);content:\"\";pointer-events:none}[focusable]{outline-offset:calc(var(--bp-size-2)*-1)!important}@media not all and (min-resolution:.001dpcm){@supports (-webkit-appearance:none) and (stroke-color:transparent){[focusable]{outline-offset:calc(var(--bp-size-3)*-1)!important}}}:host([type='action']:focus-within) [focusable]{outline:var(--bp-interaction-outline-webkit)!important;outline-offset:calc(var(--bp-size-2)*-1)!important}:host([type='action']:focus-within) ::slotted(*){outline:0!important;--bp-interaction-outline-webkit:none!important;--bp-interaction-outline-offset:none!important}:host(:focus) [focusable]{outline:var(--bp-interaction-outline-webkit);outline-offset:calc(var(--bp-size-2)*-1)!important}:host([role='rowheader']){--bp-interaction-offset:var(--bp-interaction-selected-offset);--cell-border-width:var(--bp-size-1)}");export{t as default};
@@ -19,8 +19,11 @@ import { LitElement } from 'lit';
19
19
  */
20
20
  export declare class BpGridColumn extends LitElement {
21
21
  #private;
22
+ /** control width of grid column via numeric or CSS value types */
22
23
  width: string;
24
+ /** determine if given column type for various action features */
23
25
  type: '' | 'action';
26
+ /** position individual column relative to the grid scroll container */
24
27
  position: '' | 'sticky' | 'fixed';
25
28
  static styles: CSSStyleSheet[];
26
29
  render(): import("lit-html").TemplateResult<1>;
@@ -141,6 +141,7 @@
141
141
  "type": {
142
142
  "text": "string"
143
143
  },
144
+ "description": "control width of grid column via numeric or CSS value types",
144
145
  "attribute": "width"
145
146
  },
146
147
  {
@@ -149,6 +150,7 @@
149
150
  "type": {
150
151
  "text": "'' | 'action'"
151
152
  },
153
+ "description": "determine if given column type for various action features",
152
154
  "attribute": "type",
153
155
  "reflects": true
154
156
  },
@@ -159,6 +161,7 @@
159
161
  "text": "'' | 'sticky' | 'fixed'"
160
162
  },
161
163
  "default": "''",
164
+ "description": "position individual column relative to the grid scroll container",
162
165
  "attribute": "position",
163
166
  "reflects": true
164
167
  },
@@ -190,6 +193,7 @@
190
193
  "type": {
191
194
  "text": "string"
192
195
  },
196
+ "description": "control width of grid column via numeric or CSS value types",
193
197
  "fieldName": "width"
194
198
  },
195
199
  {
@@ -197,6 +201,7 @@
197
201
  "type": {
198
202
  "text": "'' | 'action'"
199
203
  },
204
+ "description": "determine if given column type for various action features",
200
205
  "fieldName": "type"
201
206
  },
202
207
  {
@@ -205,6 +210,7 @@
205
210
  "text": "'' | 'sticky' | 'fixed'"
206
211
  },
207
212
  "default": "''",
213
+ "description": "position individual column relative to the grid scroll container",
208
214
  "fieldName": "position"
209
215
  }
210
216
  ],
@@ -654,11 +660,6 @@
654
660
  "default": "new Set()",
655
661
  "privacy": "private"
656
662
  },
657
- {
658
- "kind": "field",
659
- "name": "keyGridControllerConfig",
660
- "privacy": "private"
661
- },
662
663
  {
663
664
  "kind": "field",
664
665
  "name": "gridLayoutControllerConfig",
@@ -674,11 +675,6 @@
674
675
  "name": "#columns",
675
676
  "privacy": "private"
676
677
  },
677
- {
678
- "kind": "field",
679
- "name": "#columnRow",
680
- "privacy": "private"
681
- },
682
678
  {
683
679
  "kind": "field",
684
680
  "name": "#rows",
@@ -701,7 +697,16 @@
701
697
  },
702
698
  {
703
699
  "kind": "field",
704
- "name": "keyNavGrid"
700
+ "name": "keyNavGrid",
701
+ "privacy": "private"
702
+ },
703
+ {
704
+ "kind": "field",
705
+ "name": "grid",
706
+ "type": {
707
+ "text": "HTMLElement[][]"
708
+ },
709
+ "privacy": "private"
705
710
  },
706
711
  {
707
712
  "kind": "field",
@@ -1163,178 +1168,6 @@
1163
1168
  }
1164
1169
  ]
1165
1170
  },
1166
- {
1167
- "kind": "javascript-module",
1168
- "path": "/internals/controllers/key-grid.controller.js",
1169
- "declarations": [
1170
- {
1171
- "kind": "function",
1172
- "name": "keyGrid",
1173
- "return": {
1174
- "type": {
1175
- "text": "ClassDecorator"
1176
- }
1177
- },
1178
- "description": "https://w3c.github.io/aria-practices/#gridNav_focus"
1179
- },
1180
- {
1181
- "kind": "class",
1182
- "description": "",
1183
- "name": "KeyGridController",
1184
- "members": [
1185
- {
1186
- "kind": "field",
1187
- "name": "#observers",
1188
- "privacy": "private",
1189
- "type": {
1190
- "text": "MutationObserver[]"
1191
- },
1192
- "default": "[]"
1193
- },
1194
- {
1195
- "kind": "field",
1196
- "name": "#grid",
1197
- "privacy": "private"
1198
- },
1199
- {
1200
- "kind": "field",
1201
- "name": "#rows",
1202
- "privacy": "private"
1203
- },
1204
- {
1205
- "kind": "field",
1206
- "name": "#cells",
1207
- "privacy": "private"
1208
- },
1209
- {
1210
- "kind": "field",
1211
- "name": "#activeCell",
1212
- "privacy": "private"
1213
- },
1214
- {
1215
- "kind": "method",
1216
- "name": "hostConnected"
1217
- },
1218
- {
1219
- "kind": "method",
1220
- "name": "hostDisconnected"
1221
- },
1222
- {
1223
- "kind": "method",
1224
- "name": "#clickCell",
1225
- "parameters": [
1226
- {
1227
- "name": "e",
1228
- "type": {
1229
- "text": "MouseEvent"
1230
- }
1231
- }
1232
- ]
1233
- },
1234
- {
1235
- "kind": "method",
1236
- "name": "#keynavCell",
1237
- "parameters": [
1238
- {
1239
- "name": "e",
1240
- "type": {
1241
- "text": "KeyboardEvent"
1242
- }
1243
- }
1244
- ]
1245
- },
1246
- {
1247
- "kind": "method",
1248
- "name": "#setActiveCell",
1249
- "parameters": [
1250
- {
1251
- "name": "e",
1252
- "type": {
1253
- "text": "any"
1254
- }
1255
- },
1256
- {
1257
- "name": "activeCell",
1258
- "type": {
1259
- "text": "HTMLElement"
1260
- }
1261
- }
1262
- ]
1263
- },
1264
- {
1265
- "kind": "method",
1266
- "name": "#updateCellActivation",
1267
- "parameters": [
1268
- {
1269
- "name": "e",
1270
- "type": {
1271
- "text": "KeyboardEvent"
1272
- }
1273
- }
1274
- ]
1275
- }
1276
- ]
1277
- }
1278
- ],
1279
- "exports": [
1280
- {
1281
- "kind": "js",
1282
- "name": "keyGrid",
1283
- "declaration": {
1284
- "name": "keyGrid",
1285
- "module": "/internals/controllers/key-grid.controller.js"
1286
- }
1287
- },
1288
- {
1289
- "kind": "js",
1290
- "name": "KeyGridController",
1291
- "declaration": {
1292
- "name": "KeyGridController",
1293
- "module": "/internals/controllers/key-grid.controller.js"
1294
- }
1295
- }
1296
- ]
1297
- },
1298
- {
1299
- "kind": "javascript-module",
1300
- "path": "/internals/controllers/key.utils.js",
1301
- "declarations": [
1302
- {
1303
- "kind": "function",
1304
- "name": "getNextKeyGridItem",
1305
- "parameters": [
1306
- {
1307
- "name": "cells",
1308
- "type": {
1309
- "text": "HTMLElement[]"
1310
- }
1311
- },
1312
- {
1313
- "name": "rows",
1314
- "type": {
1315
- "text": "HTMLElement[]"
1316
- }
1317
- },
1318
- {
1319
- "name": "config",
1320
- "type": {
1321
- "text": "{ code: KeyNavigationCode | string; ctrlKey: boolean; dir: string }"
1322
- }
1323
- }
1324
- ]
1325
- }
1326
- ],
1327
- "exports": [
1328
- {
1329
- "kind": "js",
1330
- "name": "getNextKeyGridItem",
1331
- "declaration": {
1332
- "name": "getNextKeyGridItem",
1333
- "module": "/internals/controllers/key.utils.js"
1334
- }
1335
- }
1336
- ]
1337
- },
1338
1171
  {
1339
1172
  "kind": "javascript-module",
1340
1173
  "path": "/internals/index.js",
@@ -1348,22 +1181,6 @@
1348
1181
  "package": "./controllers/interaction-scroll-visibility.controller.js"
1349
1182
  }
1350
1183
  },
1351
- {
1352
- "kind": "js",
1353
- "name": "*",
1354
- "declaration": {
1355
- "name": "*",
1356
- "package": "./controllers/key-grid.controller.js"
1357
- }
1358
- },
1359
- {
1360
- "kind": "js",
1361
- "name": "*",
1362
- "declaration": {
1363
- "name": "*",
1364
- "package": "./utils/dom.js"
1365
- }
1366
- },
1367
1184
  {
1368
1185
  "kind": "js",
1369
1186
  "name": "*",
@@ -1374,35 +1191,6 @@
1374
1191
  }
1375
1192
  ]
1376
1193
  },
1377
- {
1378
- "kind": "javascript-module",
1379
- "path": "/internals/utils/dom.js",
1380
- "declarations": [
1381
- {
1382
- "kind": "function",
1383
- "name": "contextMenuClick",
1384
- "parameters": [
1385
- {
1386
- "name": "event",
1387
- "type": {
1388
- "text": "MouseEvent"
1389
- }
1390
- }
1391
- ],
1392
- "description": "right click with context menus & keyboard mouse control https://apple.stackexchange.com/questions/32715/how-do-i-open-the-context-menu-from-a-mac-keyboard"
1393
- }
1394
- ],
1395
- "exports": [
1396
- {
1397
- "kind": "js",
1398
- "name": "contextMenuClick",
1399
- "declaration": {
1400
- "name": "contextMenuClick",
1401
- "module": "/internals/utils/dom.js"
1402
- }
1403
- }
1404
- ]
1405
- },
1406
1194
  {
1407
1195
  "kind": "javascript-module",
1408
1196
  "path": "/internals/utils/events.js",
@@ -1424,23 +1212,6 @@
1424
1212
  }
1425
1213
  }
1426
1214
  ]
1427
- },
1428
- {
1429
- "kind": "function",
1430
- "name": "onFirstInteraction",
1431
- "return": {
1432
- "type": {
1433
- "text": "Promise<null>"
1434
- }
1435
- },
1436
- "parameters": [
1437
- {
1438
- "name": "element",
1439
- "type": {
1440
- "text": "HTMLElement"
1441
- }
1442
- }
1443
- ]
1444
1215
  }
1445
1216
  ],
1446
1217
  "exports": [
@@ -1451,14 +1222,6 @@
1451
1222
  "name": "onChildListMutation",
1452
1223
  "module": "/internals/utils/events.js"
1453
1224
  }
1454
- },
1455
- {
1456
- "kind": "js",
1457
- "name": "onFirstInteraction",
1458
- "declaration": {
1459
- "name": "onFirstInteraction",
1460
- "module": "/internals/utils/events.js"
1461
- }
1462
1225
  }
1463
1226
  ]
1464
1227
  },
@@ -1603,34 +1366,6 @@
1603
1366
  }
1604
1367
  ]
1605
1368
  },
1606
- {
1607
- "kind": "javascript-module",
1608
- "path": "/internals/utils/keynav.js",
1609
- "declarations": [
1610
- {
1611
- "kind": "function",
1612
- "name": "validKeyNavigationCode",
1613
- "parameters": [
1614
- {
1615
- "name": "e",
1616
- "type": {
1617
- "text": "KeyboardEvent"
1618
- }
1619
- }
1620
- ]
1621
- }
1622
- ],
1623
- "exports": [
1624
- {
1625
- "kind": "js",
1626
- "name": "validKeyNavigationCode",
1627
- "declaration": {
1628
- "name": "validKeyNavigationCode",
1629
- "module": "/internals/utils/keynav.js"
1630
- }
1631
- }
1632
- ]
1633
- },
1634
1369
  {
1635
1370
  "kind": "javascript-module",
1636
1371
  "path": "/internals/utils/traversal.js",
package/grid/element.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
2
  import { BpGridRow } from '../row/element.js';
3
- import { BpGridCell } from '../cell/element.js';
4
3
  import { BpGridColumn } from '../column/element.js';
5
4
  import { GridLayoutController } from './layout.controller.js';
6
5
  /**
@@ -71,12 +70,6 @@ export declare class BpGrid extends LitElement {
71
70
  /** @private */
72
71
  static controllers: Set<any>;
73
72
  /** @private */
74
- get keyGridControllerConfig(): {
75
- grid: HTMLElement;
76
- rows: HTMLElement[];
77
- cells: (BpGridCell | BpGridColumn)[];
78
- };
79
- /** @private */
80
73
  get gridLayoutControllerConfig(): {
81
74
  columns: BpGridColumn[];
82
75
  columnLayout: "fixed" | "flex";
@@ -87,7 +80,10 @@ export declare class BpGrid extends LitElement {
87
80
  columns: BpGridColumn[];
88
81
  rows: BpGridRow[];
89
82
  };
83
+ /** @private */
90
84
  get keyNavGrid(): HTMLElement;
85
+ /** @private */
86
+ get grid(): HTMLElement[][];
91
87
  _internals: ElementInternals;
92
88
  render(): import("lit-html").TemplateResult<1>;
93
89
  constructor();
package/grid/element.js CHANGED
@@ -1 +1 @@
1
- import{__decorate as t}from"tslib";import{LitElement as e,html as o}from"lit";import{baseStyles as i,elevationStyles as r,I18nService as l,createId as s,attachRootNodeStyles as n,i18n as a,ariaMultiSelectable as c}from"@blueprintui/components/internals";import{interactionScrollVisibility as h}from"../internals/controllers/interaction-scroll-visibility.controller.js";import{GridLayoutController as u}from"./layout.controller.js";import d from"./element.css.js";import p from"./global.css.js";var m;let g=m=class extends e{static properties={i18n:{type:Object},height:{type:String,reflect:!0},columnLayout:{type:String,reflect:!0,attribute:"column-layout"},borders:{type:String,reflect:!0},selectable:{type:String,reflect:!0},scrollLock:{type:Boolean,reflect:!0,attribute:"scroll-lock"},rangeSelection:{type:Boolean,reflect:!0,attribute:"range-selection"},elevation:{type:String,reflect:!0},_id:{type:String,reflect:!0}};gridLayoutController=new u(this);static styles=[i,r,d];static controllers=new Set;get keyGridControllerConfig(){return{grid:this.keyNavGrid,rows:[this.#t,...Array.from(this.#e)],cells:[...Array.from(this.#o),...Array.from(this.#i)]}}get gridLayoutControllerConfig(){return{columns:Array.from(this.#o),columnLayout:this.columnLayout,height:this.height}}get gridColumnSizeControllerConfig(){return{columns:Array.from(this.#o),rows:Array.from(this.#e)}}get#o(){return this.querySelectorAll("bp-grid-column")}get#t(){return this.shadowRoot.querySelector(".column-row-group")}get#e(){return this.querySelectorAll("bp-grid-row")}get#i(){return this.querySelectorAll("bp-grid-cell")}get#r(){return this.querySelector("bp-grid-placeholder")}get#l(){return this.querySelector("bp-grid-footer")}get keyNavGrid(){return this.shadowRoot.querySelector(".scroll-container")}_internals=this.attachInternals();render(){return o`<div role="presentation" elevation part="internal"><div role="presentation" class="scroll-container"><div role="presentation" class="column-row-group"><div role="row" aria-rowindex="1" class="column-row"><slot name="columns"><bp-grid-column draggable-hidden><span sr-only>${this.i18n.noData}</span></bp-grid-column></slot></div></div><slot role="presentation" class="body-row-group"></slot></div><slot name="footer"></slot><slot name="detail"></slot></div>`}constructor(){super();this._internals.role="grid",this.#s(),this.i18n=l.keys.actions,this.columnLayout="fixed",this.borders="row",this.scrollLock=!1,this.rangeSelection=!1,this._id=s()}async connectedCallback(){super.connectedCallback(),n(this.parentNode,[p]),await this.updateComplete,m.controllers.forEach((t=>new t(this))),this.#n(),this.shadowRoot.addEventListener("slotchange",(()=>this.updateComplete.then((()=>this.#n()))))}#s(){this.addEventListener("sort",(t=>{const e=t.composedPath().find((t=>"BP-GRID-COLUMN"===t.tagName));e&&(e.ariaSort=t.detail)}))}#a=0;get#c(){return this.#a++,1===this.#a&&!this.rangeSelection&&!Array.from(this.#o).find((t=>""!==t.position||void 0!==t.type))}async#n(){this.#c||(this.#h(),this.#u(),this.#d(),this.#p(),this.#m(),this.#g())}#h(){const t=Math.max(this.#e?.length,1),e=this.#l?1:0;this._internals.ariaRowCount=""+(1+t+e),this._internals.ariaColCount=""+this.#o.length}#u(){this.#o.forEach(((t,e)=>t.ariaColIndex=""+(e+1)))}#d(){this.#e?.forEach(((t,e)=>t.ariaRowIndex=""+(e+2)))}#p(){this.#i?.forEach(((t,e)=>t.ariaColIndex=""+(e%this.#o.length+1)))}#m(){this.#r&&(this.#r.ariaRowCount=""+(this.#e.length+1),this.#r._colSpan=this._internals.ariaColCount)}#g(){this.#l&&(this.#l.ariaRowCount=""+(this.#e.length+2),this.#l._colSpan=this._internals.ariaColCount)}};g=m=t([a({key:"actions"}),c(),h()],g);export{g as BpGrid};
1
+ import{__decorate as t}from"tslib";import{LitElement as e,html as i}from"lit";import{baseStyles as o,elevationStyles as r,I18nService as l,createId as s,attachRootNodeStyles as n,i18n as a,ariaMultiSelectable as c}from"@blueprintui/components/internals";import{interactionScrollVisibility as h}from"../internals/controllers/interaction-scroll-visibility.controller.js";import{GridLayoutController as u}from"./layout.controller.js";import d from"./element.css.js";import p from"./global.css.js";var m;let g=m=class extends e{static properties={i18n:{type:Object},height:{type:String,reflect:!0},columnLayout:{type:String,reflect:!0,attribute:"column-layout"},borders:{type:String,reflect:!0},selectable:{type:String,reflect:!0},scrollLock:{type:Boolean,reflect:!0,attribute:"scroll-lock"},rangeSelection:{type:Boolean,reflect:!0,attribute:"range-selection"},elevation:{type:String,reflect:!0},_id:{type:String,reflect:!0}};gridLayoutController=new u(this);static styles=[o,r,d];static controllers=new Set;get gridLayoutControllerConfig(){return{columns:Array.from(this.#t),columnLayout:this.columnLayout,height:this.height}}get gridColumnSizeControllerConfig(){return{columns:Array.from(this.#t),rows:Array.from(this.#e)}}get#t(){return this.querySelectorAll("bp-grid-column")}get#e(){return this.querySelectorAll("bp-grid-row")}get#i(){return this.querySelectorAll("bp-grid-cell")}get#o(){return this.querySelector("bp-grid-placeholder")}get#r(){return this.querySelector("bp-grid-footer")}get keyNavGrid(){return this.shadowRoot.querySelector(".scroll-container")}get grid(){const t=[...Array.from(this.#t),...Array.from(this.#i)],e=this.#t.length,i=[];for(;t.length;)i.push(t.splice(0,e));return i}_internals=this.attachInternals();render(){return i`<div role="presentation" elevation part="internal"><div role="presentation" class="scroll-container"><div role="presentation" class="column-row-group"><div role="row" aria-rowindex="1" class="column-row"><slot name="columns"><bp-grid-column draggable-hidden><span sr-only>${this.i18n.noData}</span></bp-grid-column></slot></div></div><slot role="presentation" class="body-row-group"></slot></div><slot name="footer"></slot><slot name="detail"></slot></div>`}constructor(){super();this._internals.role="grid",this.#l(),this.i18n=l.keys.actions,this.columnLayout="fixed",this.borders="row",this.scrollLock=!1,this.rangeSelection=!1,this._id=s()}async connectedCallback(){super.connectedCallback(),n(this.parentNode,[p]),await this.updateComplete,m.controllers.forEach((t=>new t(this))),this.#s(),this.shadowRoot.addEventListener("slotchange",(()=>this.updateComplete.then((()=>this.#s()))))}#l(){this.addEventListener("sort",(t=>{const e=t.composedPath().find((t=>"BP-GRID-COLUMN"===t.tagName));e&&(e.ariaSort=t.detail)}))}#n=0;get#a(){return this.#n++,1===this.#n&&!this.rangeSelection&&!Array.from(this.#t).find((t=>""!==t.position||void 0!==t.type))}async#s(){this.#a||(this.#c(),this.#h(),this.#u(),this.#d(),this.#p(),this.#m())}#c(){const t=Math.max(this.#e?.length,1),e=this.#r?1:0;this._internals.ariaRowCount=""+(1+t+e),this._internals.ariaColCount=""+this.#t.length}#h(){this.#t.forEach(((t,e)=>t.ariaColIndex=""+(e+1)))}#u(){this.#e?.forEach(((t,e)=>t.ariaRowIndex=""+(e+2)))}#d(){this.#i?.forEach(((t,e)=>t.ariaColIndex=""+(e%this.#t.length+1)))}#p(){this.#o&&(this.#o.ariaRowCount=""+(this.#e.length+1),this.#o._colSpan=this._internals.ariaColCount)}#m(){this.#r&&(this.#r.ariaRowCount=""+(this.#e.length+2),this.#r._colSpan=this._internals.ariaColCount)}};g=m=t([a({key:"actions"}),c(),h()],g);export{g as BpGrid};
package/include/keynav.js CHANGED
@@ -1 +1 @@
1
- import{KeyGridController as e}from"../internals/controllers/key-grid.controller.js";await customElements.whenDefined("bp-grid"),customElements.get("bp-grid").controllers.add(e);
1
+ import{KeynavController as e}from"@blueprintui/typewriter";await customElements.whenDefined("bp-grid"),customElements.get("bp-grid").controllers.add(class extends e{constructor(e){super(e,(()=>({host:e.keyNavGrid,grid:e.grid})))}});
@@ -1,4 +1,2 @@
1
1
  export * from './controllers/interaction-scroll-visibility.controller.js';
2
- export * from './controllers/key-grid.controller.js';
3
- export * from './utils/dom.js';
4
2
  export * from './utils/events.js';
@@ -1 +1 @@
1
- export{InteractionScrollVisibilityController,interactionScrollVisibility}from"./controllers/interaction-scroll-visibility.controller.js";export{KeyGridController,keyGrid}from"./controllers/key-grid.controller.js";export{contextMenuClick}from"./utils/dom.js";export{onChildListMutation,onFirstInteraction}from"./utils/events.js";
1
+ export{InteractionScrollVisibilityController,interactionScrollVisibility}from"./controllers/interaction-scroll-visibility.controller.js";export{onChildListMutation}from"./utils/events.js";
@@ -1,2 +1 @@
1
1
  export declare function onChildListMutation(element: HTMLElement, fn: (mutation?: MutationRecord) => void): MutationObserver;
2
- export declare function onFirstInteraction(element: HTMLElement): Promise<null>;
@@ -1 +1 @@
1
- function e(e,n){const t=new MutationObserver((e=>{for(const t of e)"childList"===t.type&&n(t)}));return t.observe(e,{childList:!0}),t}function n(e){return new Promise((n=>{const t=()=>{n(null),e.__bpTouched=!0};e.__bpTouched&&n(null),e.addEventListener("touchstart",t,{once:!0,passive:!0}),e.addEventListener("mouseover",t,{once:!0,passive:!0}),e.addEventListener("keydown",t,{once:!0,passive:!0}),e.addEventListener("focus",t,{once:!0,passive:!0})}))}export{e as onChildListMutation,n as onFirstInteraction};
1
+ function t(t,e){const o=new MutationObserver((t=>{for(const o of t)"childList"===o.type&&e(o)}));return o.observe(t,{childList:!0}),o}export{t as onChildListMutation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueprintui/grid",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "./index.js",
5
5
  "module": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -38,9 +38,10 @@
38
38
  "./*": "./*/index.js"
39
39
  },
40
40
  "dependencies": {
41
- "@blueprintui/components": "^0.0.33",
42
- "@blueprintui/icons": "^0.0.22",
43
- "@blueprintui/themes": "^0.0.12",
41
+ "@blueprintui/components": "^0.0.34",
42
+ "@blueprintui/icons": "^0.0.23",
43
+ "@blueprintui/themes": "^0.0.14",
44
+ "@blueprintui/typwriter": "^0.0.1",
44
45
  "lit": "^2.5.0",
45
46
  "tslib": "^2.4.1"
46
47
  }
@@ -1,19 +0,0 @@
1
- import { ReactiveController, ReactiveElement } from 'lit';
2
- export interface KeyGridConfig {
3
- keyGridControllerConfig: {
4
- grid?: HTMLElement;
5
- rows: NodeListOf<HTMLElement> | HTMLElement[];
6
- cells: NodeListOf<HTMLElement> | HTMLElement[];
7
- };
8
- }
9
- /**
10
- * https://w3c.github.io/aria-practices/#gridNav_focus
11
- */
12
- export declare function keyGrid<T extends ReactiveElement & KeyGridConfig>(): ClassDecorator;
13
- export declare class KeyGridController<T extends ReactiveElement & KeyGridConfig> implements ReactiveController {
14
- #private;
15
- private host;
16
- constructor(host: T);
17
- hostConnected(): Promise<void>;
18
- hostDisconnected(): void;
19
- }
@@ -1 +0,0 @@
1
- import{onFirstInteraction as t,onChildListMutation as e}from"../utils/events.js";import{getFlattenedDOMTree as s,getFlattenedFocusableItems as i}from"../utils/traversal.js";import{contextMenuClick as r}from"../utils/dom.js";import{validKeyNavigationCode as o}from"../utils/keynav.js";import{initializeKeyListItems as l,simpleFocusable as n,getActiveElement as h,setActiveKeyListItem as c,focusElement as d}from"../utils/focus.js";import{getNextKeyGridItem as a}from"./key.utils.js";function f(){return t=>t.addInitializer((t=>new u(t)))}class u{host;#t=[];get#e(){return this.host.keyGridControllerConfig.grid}get#s(){return Array.from(this.host.keyGridControllerConfig.rows)}get#i(){return Array.from(this.host.keyGridControllerConfig.cells)}get#r(){return Array.from(this.#i).find((t=>0===t.tabIndex))}constructor(t){this.host=t,this.host.addController(this)}async hostConnected(){await this.host.updateComplete,await t(this.host),l(this.#i),this.#e.addEventListener("mouseup",(t=>this.#o(t))),this.#e.addEventListener("keydown",(t=>this.#l(t))),this.#e.addEventListener("keyup",(t=>this.#n(t))),this.#t.push(e(this.#e,(()=>l(this.#i))))}hostDisconnected(){this.#t.forEach((t=>t.disconnect()))}#o(t){if(!r(t)){const e=t.composedPath().find((t=>this.#i.find((e=>e===t))));e&&this.#h(t,e)}}#l(t){if(o(t)&&n(h())){const{x:e,y:i}=a(this.#i,this.#s,{code:t.code,ctrlKey:t.ctrlKey,dir:this.host.dir}),r=Array.from(s(this.#s[i])).filter((t=>!!this.#i.find((e=>e===t))))[e];this.#h(t,r),t.preventDefault()}}#h(t,e){c(this.#i,e);const s=i(e).filter((t=>!t.hidden&&!t.ariaHidden)),r=s.filter((t=>n(t)));1===r.length&&1===s.length?d(r[0]):d(e),e.dispatchEvent(new CustomEvent("bpKeyChange",{bubbles:!0,detail:{code:t.code,shiftKey:t.shiftKey,activeItem:e}}))}#n(t){"Escape"===t.code&&this.#r?.focus(),"Enter"===t.code&&this.#r===t.composedPath()[0]&&i(this.#r)[0]?.focus()}}export{u as KeyGridController,f as keyGrid};
@@ -1,9 +0,0 @@
1
- import { KeyNavigationCode } from '../utils/keynav.js';
2
- export declare function getNextKeyGridItem(cells: HTMLElement[], rows: HTMLElement[], config: {
3
- code: KeyNavigationCode | string;
4
- ctrlKey: boolean;
5
- dir: string;
6
- }): {
7
- x: number;
8
- y: number;
9
- };
@@ -1 +0,0 @@
1
- import{KeyNavigationCode as r}from"../utils/keynav.js";import{getFlattenedDOMTree as t}from"../utils/traversal.js";function o(o,e,n){const i=o.find((r=>0===r.tabIndex)),f=e.find((r=>t(r).find((r=>r===i)))),d=Array.from(t(f)).filter((r=>!!o.find((t=>t===r)))),l=e.length-1,w=d.length-1,{code:a,ctrlKey:s,dir:A}=n;let g=d.indexOf(i),m=e.indexOf(f);const c="rtl"===A?r.ArrowRight:r.ArrowLeft,p="rtl"===A?r.ArrowLeft:r.ArrowRight;return a===r.ArrowUp&&0!==m?m-=1:a===r.ArrowDown&&m<l?m+=1:a===c&&0!==g?g-=1:a===p&&g<w?g+=1:a===r.End?(g=w,s&&(m=l)):a===r.Home?(g=0,s&&(m=0)):a===r.PageUp?m=m-4>0?m-4:0:a===r.PageDown&&(m=m+4<l?m+4:l),{x:g,y:m}}export{o as getNextKeyGridItem};
@@ -1,2 +0,0 @@
1
- /** right click with context menus & keyboard mouse control https://apple.stackexchange.com/questions/32715/how-do-i-open-the-context-menu-from-a-mac-keyboard */
2
- export declare function contextMenuClick(event: MouseEvent): boolean;
@@ -1 +0,0 @@
1
- function t(t){return 2===t.buttons&&!t.ctrlKey||1===t.buttons&&t.ctrlKey}export{t as contextMenuClick};
@@ -1 +0,0 @@
1
- function t(t){return t.matches("a[href],area[href],input:not([disabled]),button:not([disabled]),select:not([disabled]),textarea:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable=true],[role=button]:not([disabled])")}function e(t){return t.matches("a[href],button:not([disabled]),input[type=checkbox],input[type=radio],object,embed,*[tabindex],[role=button]:not([disabled])")}function n(t=document){return t.activeElement&&t.activeElement.shadowRoot?n(t.activeElement.shadowRoot)??t.activeElement:t.activeElement}function o(e){e&&!t(e)?(e.setAttribute("tabindex","-1"),e.focus(),e.addEventListener("blur",(()=>e.removeAttribute("tabindex")),{once:!0})):e?.focus()}function a(t,e){t.forEach((t=>t.tabIndex=-1)),e.tabIndex=0}function d(t){t.forEach((t=>t.tabIndex=-1)),t[0].tabIndex=0}export{o as focusElement,t as focusable,n as getActiveElement,d as initializeKeyListItems,a as setActiveKeyListItem,e as simpleFocusable};
@@ -1,11 +0,0 @@
1
- export declare function validKeyNavigationCode(e: KeyboardEvent): boolean;
2
- export declare enum KeyNavigationCode {
3
- ArrowUp = "ArrowUp",
4
- ArrowDown = "ArrowDown",
5
- ArrowLeft = "ArrowLeft",
6
- ArrowRight = "ArrowRight",
7
- End = "End",
8
- Home = "Home",
9
- PageUp = "PageUp",
10
- PageDown = "PageDown"
11
- }
@@ -1 +0,0 @@
1
- function o(o){return o.code===r.ArrowUp||o.code===r.ArrowDown||o.code===r.ArrowLeft||o.code===r.ArrowRight||o.code===r.End||o.code===r.Home||o.code===r.PageUp||o.code===r.PageDown}var r;!function(o){o.ArrowUp="ArrowUp",o.ArrowDown="ArrowDown",o.ArrowLeft="ArrowLeft",o.ArrowRight="ArrowRight",o.End="End",o.Home="Home",o.PageUp="PageUp",o.PageDown="PageDown"}(r||(r={}));export{r as KeyNavigationCode,o as validKeyNavigationCode};
@@ -1 +0,0 @@
1
- import{focusable as r}from"./focus.js";function n(n,e=10){return t(n,e).filter((n=>r(n)))}function t(r,n=10){return Array.from(e(r)).reduce(((r,o)=>[...r,[o,[...Array.from(e(o)).map((r=>[r,t(r,n)]))]]]),[]).flat(n)}function e(r){if(r.documentElement)return r.documentElement.children;if(r.shadowRoot)return r.shadowRoot.children;if(r.assignedElements){const n=r.assignedElements();return n.length?n:r.children}return r.children}function o(r){return r?.constructor===Object}function c(...r){const n={};return r.map((r=>o(r)?{...r}:{})).forEach((r=>{Object.keys(r).forEach((t=>{const e=r[t];Array.isArray(e)?n[t]=Array.from(e):o(e)?n[t]=c(n[t]||{},e):n[t]=e}))})),n}export{e as getChildren,t as getFlattenedDOMTree,n as getFlattenedFocusableItems,o as isObject,c as mergeObjects};