@lion/ui 0.18.0-menu-system.6 → 0.18.0-menu-system.7

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 (115) hide show
  1. package/components/menu/src/InteractiveListMixin.js +9 -10
  2. package/components/menu/src/LionMenu.js +1 -1
  3. package/components/menu/src/LionTree.js +1 -1
  4. package/components/menu/src/MultiLevelListMixin.js +46 -9
  5. package/components/menu/test/InteractiveListMixin.test.js +3 -0
  6. package/components/menu/test/MoreButtonMenuMixin.test.js +4 -0
  7. package/components/menu/test/MultiLevelListMixin.test.js +3 -0
  8. package/components/menu/test/lion-menu-hybrid.test.js +3 -0
  9. package/components/menu/test/lion-menu.test.js +7 -2
  10. package/components/menu/test/lion-toolbar.test.js +8 -0
  11. package/components/menu/test/lion-tree.test.js +7 -0
  12. package/components/menu/test-helpers/mimicKeyPress.js +9 -0
  13. package/components/menu/test-suites/InteractiveListMixin.suite.js +154 -342
  14. package/components/menu/test-suites/LionMenu.suite.js +113 -0
  15. package/components/menu/test-suites/LionMenuHybrid.suite.js +1 -1
  16. package/components/menu/test-suites/MoreButtonMenuMixin.suite.js +372 -0
  17. package/components/menu/test-suites/MultiLevelListMixin.suite.js +303 -0
  18. package/components/menu/types/InteractiveListMixinTypes.d.ts +2 -0
  19. package/components/overlays/types/OverlayMixinTypes.ts +2 -0
  20. package/custom-elements.json +245 -153
  21. package/dist-types/components/combobox/src/LionCombobox.d.ts +1 -1
  22. package/dist-types/components/dialog/src/LionDialog.d.ts +1 -1
  23. package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +1 -1
  24. package/dist-types/components/menu/src/InteractiveListMixin.d.ts +3 -3
  25. package/dist-types/components/menu/src/InteractiveListMixin.d.ts.map +1 -1
  26. package/dist-types/components/menu/src/LionMenu.d.ts +75 -5
  27. package/dist-types/components/menu/src/LionMenu.d.ts.map +1 -1
  28. package/dist-types/components/menu/src/LionMenuOverlay.d.ts +4 -2
  29. package/dist-types/components/menu/src/LionMenuOverlay.d.ts.map +1 -1
  30. package/dist-types/components/menu/src/LionTree.d.ts +2 -2
  31. package/dist-types/components/menu/src/MultiLevelListMixin.d.ts +10 -2
  32. package/dist-types/components/menu/src/MultiLevelListMixin.d.ts.map +1 -1
  33. package/dist-types/components/menu/test/InteractiveListMixin.test.d.ts +2 -0
  34. package/dist-types/components/menu/test/InteractiveListMixin.test.d.ts.map +1 -0
  35. package/dist-types/components/menu/test/MoreButtonMenuMixin.test.d.ts +2 -0
  36. package/dist-types/components/menu/test/MoreButtonMenuMixin.test.d.ts.map +1 -0
  37. package/dist-types/components/menu/test/MultiLevelListMixin.test.d.ts +2 -0
  38. package/dist-types/components/menu/test/MultiLevelListMixin.test.d.ts.map +1 -0
  39. package/dist-types/components/menu/test/lion-menu-hybrid.test.d.ts +2 -0
  40. package/dist-types/components/menu/test/lion-menu-hybrid.test.d.ts.map +1 -0
  41. package/dist-types/components/menu/test/lion-toolbar.test.d.ts +2 -0
  42. package/dist-types/components/menu/test/lion-toolbar.test.d.ts.map +1 -0
  43. package/dist-types/components/menu/test/lion-tree.test.d.ts +2 -0
  44. package/dist-types/components/menu/test/lion-tree.test.d.ts.map +1 -0
  45. package/dist-types/components/menu/test-helpers/mimicKeyPress.d.ts +7 -0
  46. package/dist-types/components/menu/test-helpers/mimicKeyPress.d.ts.map +1 -0
  47. package/dist-types/components/menu/test-suites/InteractiveListMixin.suite.d.ts.map +1 -1
  48. package/dist-types/components/menu/test-suites/LionMenu.suite.d.ts +9 -0
  49. package/dist-types/components/menu/test-suites/LionMenu.suite.d.ts.map +1 -0
  50. package/dist-types/components/menu/test-suites/MoreButtonMenuMixin.suite.d.ts +14 -0
  51. package/dist-types/components/menu/test-suites/MoreButtonMenuMixin.suite.d.ts.map +1 -0
  52. package/dist-types/components/menu/test-suites/MultiLevelListMixin.suite.d.ts +11 -0
  53. package/dist-types/components/menu/test-suites/MultiLevelListMixin.suite.d.ts.map +1 -0
  54. package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts +1 -0
  55. package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts.map +1 -1
  56. package/dist-types/components/select-rich/src/LionSelectRich.d.ts +1 -1
  57. package/dist-types/components/tooltip/src/LionTooltip.d.ts +1 -1
  58. package/dist-types/exports/menu-test-suites.d.ts +2 -0
  59. package/dist-types/tsconfig.tsbuildinfo +1 -1
  60. package/docs/components/checkbox-group/overview.md +2 -2
  61. package/docs/components/collapsible/overview.md +1 -1
  62. package/docs/components/combobox/overview.md +1 -1
  63. package/docs/components/combobox/use-cases.md +1 -1
  64. package/docs/components/dialog/overview.md +1 -1
  65. package/docs/components/fieldset/overview.md +5 -5
  66. package/docs/components/form/overview.md +3 -3
  67. package/docs/components/form/use-cases.md +2 -2
  68. package/docs/components/icon/use-cases.md +1 -1
  69. package/docs/components/input/overview.md +1 -1
  70. package/docs/components/input-amount/overview.md +3 -3
  71. package/docs/components/input-date/overview.md +3 -3
  72. package/docs/components/input-datepicker/overview.md +5 -5
  73. package/docs/components/input-email/overview.md +2 -2
  74. package/docs/components/input-file/overview.md +1 -1
  75. package/docs/components/input-iban/overview.md +2 -2
  76. package/docs/components/input-range/overview.md +2 -2
  77. package/docs/components/input-stepper/overview.md +1 -1
  78. package/docs/components/input-tel/overview.md +1 -1
  79. package/docs/components/input-tel/use-cases.md +6 -6
  80. package/docs/components/input-tel-dropdown/overview.md +1 -1
  81. package/docs/components/listbox/use-cases.md +1 -1
  82. package/docs/components/menu/api-table.md +44 -39
  83. package/docs/components/radio-group/overview.md +3 -3
  84. package/docs/components/select/use-cases.md +1 -1
  85. package/docs/components/select-rich/use-cases.md +2 -2
  86. package/docs/components/tabs/examples.md +1 -1
  87. package/docs/fundamentals/index.md +4 -4
  88. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  89. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  90. package/docs/fundamentals/rationales/accessibility.md +1 -1
  91. package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
  92. package/docs/fundamentals/systems/core/overview.md +1 -1
  93. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  94. package/docs/fundamentals/systems/form/model-value.md +1 -1
  95. package/docs/fundamentals/systems/form/overview.md +28 -28
  96. package/docs/fundamentals/systems/form/validate.md +2 -2
  97. package/docs/fundamentals/systems/localize/overview.md +4 -4
  98. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  99. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  100. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  101. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  102. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  103. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  104. package/docs/guides/how-to/create-a-form.md +4 -4
  105. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  106. package/docs/guides/how-to/index.md +1 -1
  107. package/docs/guides/index.md +8 -8
  108. package/docs/guides/principles/index.md +5 -5
  109. package/docs/guides/principles/styling.md +1 -1
  110. package/exports/menu-test-suites.js +2 -0
  111. package/menu-test-suites.js +2 -0
  112. package/package.json +1 -1
  113. package/components/menu/src/utils/uuid.js +0 -3
  114. package/dist-types/components/menu/src/utils/uuid.d.ts +0 -2
  115. package/dist-types/components/menu/src/utils/uuid.d.ts.map +0 -1
@@ -1,10 +1,9 @@
1
1
  /* eslint-disable max-classes-per-file */
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
3
  import { html, css, LitElement } from 'lit';
4
- import { SlotMixin, DisabledMixin } from '@lion/ui/core.js';
4
+ import { SlotMixin, DisabledMixin, uuid } from '@lion/ui/core.js';
5
5
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
6
6
  import { MoreButtonMenuMixin } from './MoreButtonMenuMixin.js';
7
- import { uuid } from './utils/uuid.js';
8
7
  import { isInView } from './utils/isInView.js';
9
8
  import {
10
9
  isDisabled,
@@ -167,7 +166,7 @@ const InteractiveListMixinImplementation = superclass =>
167
166
  multipleChoice: { type: Boolean, attribute: 'multiple-choice' },
168
167
  // TODO: align with name of open-ui
169
168
  selectionFollowsFocus: { type: Boolean, attribute: 'selection-follows-focus' },
170
- // TODO: align with name of open-ui => "wrap" in focsugroup
169
+ // TODO: align with name of open-ui => "wrap" in focusgroup
171
170
  rotateKeyboardNavigation: { type: Boolean, attribute: 'rotate-keyboard-navigation' },
172
171
  // TODO: align with name of open-ui
173
172
  noPreselect: { type: Boolean, attribute: 'no-preselect' },
@@ -556,7 +555,7 @@ const InteractiveListMixinImplementation = superclass =>
556
555
  // having hideVisually as hide mechanism (opening on focus, closing on blur).
557
556
  // N.B. this._listNode has `display:flex`. This means we need to add `text-wrap: nowrap;`
558
557
  // to avoid elems going over two lines, or give them a max-height based on measuring the height of one item.
559
- // 2. N.B. hideVisually needs to be implementd in OverlayController.
558
+ // 2. N.B. hideVisually needs to be implemented in OverlayController.
560
559
  // 3. when the more menu opens a next level, MultiLevelListMixin will be applied to the host as well.
561
560
  // That means it knows when a child menu is open. If _subListMap of one of the items is open, we should hide more menu like this:
562
561
  // https://jsfiddle.net/a4ocktfp/19/
@@ -588,7 +587,7 @@ const InteractiveListMixinImplementation = superclass =>
588
587
  }
589
588
  });
590
589
 
591
- this.__syncCurrentPageWithLocationHref(window.location);
590
+ this._syncCurrentPageWithLocationHref(window.location);
592
591
  }
593
592
 
594
593
  /**
@@ -817,12 +816,12 @@ const InteractiveListMixinImplementation = superclass =>
817
816
  /**
818
817
  * @param {Location} location
819
818
  */
820
- __syncCurrentPageWithLocationHref(location) {
819
+ _syncCurrentPageWithLocationHref(location) {
821
820
  this.listItems.forEach(item => {
822
821
  if (/** @type {HTMLAnchorElement} */ (item).href) {
823
- const pathname = location.pathname.endsWith('/')
824
- ? location.pathname.substring(0, location.pathname.length - 1)
825
- : location.pathname;
822
+ const pathname = location.href.endsWith('/')
823
+ ? location.href.substring(0, location.href.length - 1)
824
+ : location.href;
826
825
  if (pathname === /** @type {HTMLAnchorElement} */ (item).href) {
827
826
  setChecked(item);
828
827
  } else {
@@ -834,7 +833,7 @@ const InteractiveListMixinImplementation = superclass =>
834
833
 
835
834
  /** @protected */
836
835
  _onPopState = () => {
837
- this.__syncCurrentPageWithLocationHref(document.location);
836
+ this._syncCurrentPageWithLocationHref(document.location);
838
837
  };
839
838
  };
840
839
  // @ts-ignore
@@ -187,7 +187,7 @@ export class LionMenu extends MultiLevelListMixin(LitElement) {
187
187
  }
188
188
 
189
189
  if (!multiple) {
190
- // Uncheck all
190
+ // Uncheck all within group
191
191
  listItemsWithinGroup.forEach(listItem => {
192
192
  setChecked(listItem, true);
193
193
  });
@@ -22,7 +22,7 @@ export class LionTree extends MultiLevelListMixin(LitElement) {
22
22
  super.updated(changedProperties);
23
23
 
24
24
  if (changedProperties.has('level')) {
25
- if (this.level > 0) {
25
+ if (this.level > 1) {
26
26
  this._listNode.setAttribute('role', 'group');
27
27
  }
28
28
  this.__setAriaLevelForListItems();
@@ -3,10 +3,12 @@ import { html } from 'lit';
3
3
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
4
4
  // import { DisclosureMixin } from '@lion/ui/collapsible.js';
5
5
  import { InteractiveListMixin } from './InteractiveListMixin.js';
6
-
6
+ import { isChecked, setChecked } from './utils/listItemInteractions.js';
7
7
  /**
8
8
  * @typedef {import('./InteractiveListMixin.js').LionItem} LionItem
9
9
  * @typedef {import('../types/InteractiveListMixinTypes.js').InteractiveListHost} InteractiveList
10
+ * @typedef {typeof import('../../overlays/types/OverlayMixinTypes.js').OverlayHost} OverlayHost
11
+ * @typedef {import('./LionMenuOverlay.js').LionMenuOverlay} LionMenuOverlay
10
12
  */
11
13
 
12
14
  /**
@@ -37,8 +39,13 @@ const MultiLevelListMixinImplementation = superclass =>
37
39
  * @configure DisclosureMixin
38
40
  */
39
41
  get _invokerNode() {
40
- // @ts-ignore - accessing static method and super property
41
- return this.constructor._getFocusableInvokerEl(this.invokerNode) || super._invokerNode;
42
+ const ctor = /** @type {OverlayHost} */ (this.constructor);
43
+ if (ctor._getFocusableInvokerEl && this.invokerNode) {
44
+ // @ts-ignore - accessing static method and super property
45
+ return ctor._getFocusableInvokerEl(this.invokerNode);
46
+ }
47
+ // @ts-ignore
48
+ return super._invokerNode;
42
49
  }
43
50
 
44
51
  /**
@@ -84,6 +91,7 @@ const MultiLevelListMixinImplementation = superclass =>
84
91
  this.noPreselect = true;
85
92
  /**
86
93
  * @configure InteractiveListMixin
94
+ * @type {'activedescendant'|'roving-tabindex'|'tabbable-disclosure'}
87
95
  */
88
96
  this._activeMode = 'roving-tabindex';
89
97
  /**
@@ -184,12 +192,12 @@ const MultiLevelListMixinImplementation = superclass =>
184
192
  * @param {*} ev
185
193
  */
186
194
  _onListKeyDown(ev) {
187
- const targetFromsubList = Array.from(this._subListMap).find(
195
+ const targetFromSubList = Array.from(this._subListMap).find(
188
196
  // @ts-ignore - contains method on InteractiveListHost
189
197
  ([, s]) => s === ev.target || s.contains(ev.target),
190
198
  );
191
199
 
192
- if (targetFromsubList) {
200
+ if (targetFromSubList) {
193
201
  return;
194
202
  }
195
203
 
@@ -228,22 +236,51 @@ const MultiLevelListMixinImplementation = superclass =>
228
236
  if (this.orientation === 'horizontal' && parentListOfActiveItem) {
229
237
  // @ts-ignore - close method
230
238
  this.close();
231
- // @ts-ignore - _onOverlayShow method
232
- parentListOfActiveItem._onOverlayShow();
239
+ if (
240
+ /** @type {InteractiveList & LionMenuOverlay} */ (parentListOfActiveItem)
241
+ ._onOverlayShow
242
+ ) {
243
+ // @ts-ignore - _onOverlayShow method
244
+ /** @type {OverlayHost} */ (parentListOfActiveItem)._onOverlayShow();
245
+ }
233
246
  }
234
247
  break;
235
248
  case 'ArrowLeft':
236
249
  if (this.orientation === 'vertical' && parentListOfActiveItem) {
237
250
  // @ts-ignore - close method
238
251
  this.close();
239
- // @ts-ignore - _onOverlayShow method
240
- parentListOfActiveItem._onOverlayShow();
252
+ if (
253
+ /** @type {InteractiveList & LionMenuOverlay} */ (parentListOfActiveItem)
254
+ ._onOverlayShow
255
+ ) {
256
+ // @ts-ignore - _onOverlayShow method
257
+ /** @type {OverlayHost} */ (parentListOfActiveItem)._onOverlayShow();
258
+ }
241
259
  }
242
260
  break;
243
261
  /* no default */
244
262
  }
245
263
  }
246
264
 
265
+ /**
266
+ * @param {Location} location
267
+ */
268
+ _syncCurrentPageWithLocationHref(location) {
269
+ super._syncCurrentPageWithLocationHref(location);
270
+
271
+ this._subListMap.forEach(subList => {
272
+ subList.listItems.forEach(
273
+ /** @param {LionItem|HTMLElement} item */ item => {
274
+ // @ts-ignore
275
+ if (isChecked(item) && subList._invokerNode) {
276
+ // @ts-ignore
277
+ setChecked(subList._invokerNode);
278
+ }
279
+ },
280
+ );
281
+ });
282
+ }
283
+
247
284
  // /**
248
285
  // * @enhance DisclosureMixin
249
286
  // */
@@ -0,0 +1,3 @@
1
+ import { runInteractiveListMixinSuite } from '../test-suites/InteractiveListMixin.suite.js';
2
+
3
+ runInteractiveListMixinSuite();
@@ -0,0 +1,4 @@
1
+ import { runMoreButtonMenuMixinSuite } from '../test-suites/MoreButtonMenuMixin.suite.js';
2
+ import '@lion/ui/define/lion-menu.js';
3
+
4
+ runMoreButtonMenuMixinSuite({ tagString: 'lion-menu' });
@@ -0,0 +1,3 @@
1
+ import { runMultiLevelListMixinSuite } from '../test-suites/MultiLevelListMixin.suite.js';
2
+
3
+ runMultiLevelListMixinSuite();
@@ -0,0 +1,3 @@
1
+ import { runLionMenuHybridSuite } from '../test-suites/LionMenuHybrid.suite.js';
2
+
3
+ runLionMenuHybridSuite();
@@ -1,6 +1,11 @@
1
1
  import { runInteractiveListMixinSuite } from '../test-suites/InteractiveListMixin.suite.js';
2
+ import { runMultiLevelListMixinSuite } from '../test-suites/MultiLevelListMixin.suite.js';
3
+ import { runMoreButtonMenuMixinSuite } from '../test-suites/MoreButtonMenuMixin.suite.js';
4
+ import { runLionMenuSuite } from '../test-suites/LionMenu.suite.js';
2
5
  import '@lion/ui/define/lion-menu.js';
3
- import { runLionMenuHybridSuite } from '../test-suites/LionMenuHybrid.suite.js';
6
+ import '@lion/ui/define/lion-menu-overlay.js';
4
7
 
5
8
  runInteractiveListMixinSuite({ tagString: 'lion-menu' });
6
- runLionMenuHybridSuite();
9
+ runMultiLevelListMixinSuite({ tagString: 'lion-menu', tagChildString: 'lion-menu-overlay' });
10
+ runMoreButtonMenuMixinSuite({ tagString: 'lion-menu' });
11
+ runLionMenuSuite({ tagString: 'lion-menu' });
@@ -0,0 +1,8 @@
1
+ // import { runInteractiveListMixinSuite } from '../test-suites/InteractiveListMixin.suite.js';
2
+ // import { runMultiLevelListMixinSuite } from '../test-suites/MultiLevelListMixin.suite.js';
3
+ import { runMoreButtonMenuMixinSuite } from '../test-suites/MoreButtonMenuMixin.suite.js';
4
+ import '@lion/ui/define/lion-toolbar.js';
5
+
6
+ // runInteractiveListMixinSuite({ tagString: 'lion-toolbar' }); // 1 test fails
7
+ // runMultiLevelListMixinSuite({ tagString: 'lion-toolbar', tagChildString: 'lion-toolbar' }); // hangs
8
+ runMoreButtonMenuMixinSuite({ tagString: 'lion-toolbar' });
@@ -0,0 +1,7 @@
1
+ import { runInteractiveListMixinSuite } from '../test-suites/InteractiveListMixin.suite.js';
2
+ // import { runMultiLevelListMixinSuite } from '../test-suites/MultiLevelListMixin.suite.js';
3
+ import '@lion/ui/define/lion-tree.js';
4
+
5
+ runInteractiveListMixinSuite({ tagString: 'lion-tree' });
6
+ // TODO: fix failing tests. LionTree is missing a close function, should this be coming from the DisclosureMixin?
7
+ // runMultiLevelListMixinSuite({ tagString: 'lion-tree', tagChildString: 'lion-tree' });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @param {HTMLElement} el
3
+ * @param {string} key
4
+ * @param {string} code
5
+ */
6
+ export function mimicKeyPress(el, key, code = '') {
7
+ el.dispatchEvent(new KeyboardEvent('keydown', { key, code }));
8
+ el.dispatchEvent(new KeyboardEvent('keyup', { key, code }));
9
+ }