@lion/ui 0.21.1-menu-system.0 → 0.22.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.
- package/components/button/src/LionButton.js +0 -4
- package/components/form/test/lion-form.test.js +4 -3
- package/components/form-core/src/form-group/FormGroupMixin.js +37 -0
- package/components/form-core/test-suites/form-group/FormGroupMixin.suite.js +25 -0
- package/components/input-amount-dropdown/src/LionInputAmountDropdown.js +2 -2
- package/components/input-amount-dropdown/test/lion-input-amount-dropdown-integrations.test.js +12 -3
- package/components/input-amount-dropdown/test-suites/LionInputAmountDropdown.suite.js +10 -3
- package/components/overlays/src/OverlayController.js +111 -296
- package/components/overlays/src/OverlayMixin.js +17 -76
- package/components/overlays/src/utils/adopt-styles.js +1 -1
- package/components/overlays/src/utils/is-equal-config.js +6 -15
- package/components/overlays/test/OverlayController.test.js +24 -144
- package/components/overlays/test-suites/OverlayMixin.suite.js +8 -8
- package/components/overlays/types/ArrowMixinTypes.ts +3 -1
- package/components/overlays/types/OverlayConfig.ts +5 -20
- package/components/overlays/types/OverlayMixinTypes.ts +0 -2
- package/custom-elements.json +6260 -13587
- package/dist-types/components/button/src/LionButton.d.ts +0 -1
- package/dist-types/components/button/src/LionButton.d.ts.map +1 -1
- package/dist-types/components/combobox/src/LionCombobox.d.ts +1 -1
- package/dist-types/components/dialog/src/LionDialog.d.ts +2 -6
- package/dist-types/components/dialog/src/LionDialog.d.ts.map +1 -1
- package/dist-types/components/form-core/src/form-group/FormGroupMixin.d.ts +1 -0
- package/dist-types/components/form-core/src/form-group/FormGroupMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/test-suites/form-group/FormGroupMixin.suite.d.ts.map +1 -1
- package/dist-types/components/input-amount-dropdown/test-suites/LionInputAmountDropdown.suite.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +1 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts +5 -22
- package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/overlays/src/utils/is-equal-config.d.ts.map +1 -1
- package/dist-types/components/overlays/types/ArrowMixinTypes.d.ts.map +1 -1
- package/dist-types/components/overlays/types/OverlayConfig.d.ts +2 -12
- package/dist-types/components/overlays/types/OverlayConfig.d.ts.map +1 -1
- package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts +0 -1
- package/dist-types/components/overlays/types/OverlayMixinTypes.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +2 -6
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/components/tooltip/src/LionTooltip.d.ts +1 -1
- package/dist-types/exports/overlays.d.ts +0 -6
- package/dist-types/exports/overlays.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/api-table.md +39 -53
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/api-table.md +6 -32
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/form/use-cases.md +2 -2
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/api-table.md +45 -63
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-file/overview.md +1 -1
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/listbox/use-cases.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select/use-cases.md +1 -1
- package/docs/components/select-rich/api-table.md +33 -50
- package/docs/components/select-rich/use-cases.md +2 -2
- package/docs/components/tabs/examples.md +1 -1
- package/docs/components/tooltip/api-table.md +7 -33
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +2 -2
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/api-table.md +43 -46
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/create-a-form.md +4 -4
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/how-to/index.md +1 -1
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/overlays.js +0 -6
- package/overlays.js +0 -6
- package/package.json +6 -2
- package/vscode.css-custom-data.json +5 -0
- package/vscode.html-custom-data.json +789 -0
- package/web-types.json +2016 -0
- package/components/menu/CHANGELOG.md +0 -37
- package/components/menu/README.md +0 -334
- package/components/menu/index.js +0 -2
- package/components/menu/lion-menu.js +0 -3
- package/components/menu/package.json +0 -46
- package/components/menu/requirements.temp.md +0 -12
- package/components/menu/src/InteractiveListMixin.js +0 -840
- package/components/menu/src/LionMenu.js +0 -421
- package/components/menu/src/MoreButtonMenuMixin.js +0 -278
- package/components/menu/src/MultiLevelListMixin.js +0 -305
- package/components/menu/src/utils/isInView.js +0 -26
- package/components/menu/src/utils/listItemInteractions.js +0 -124
- package/components/menu/test/InteractiveListMixin.test.js +0 -3
- package/components/menu/test/MoreButtonMenuMixin.test.js +0 -4
- package/components/menu/test/MultiLevelListMixin.test.js +0 -3
- package/components/menu/test/lion-menu-interactions.test.js +0 -3
- package/components/menu/test/lion-menu.test.js +0 -14
- package/components/menu/test-helpers/mimicKeyPress.js +0 -9
- package/components/menu/test-suites/InteractiveListMixin.suite.js +0 -454
- package/components/menu/test-suites/LionMenu.suite.js +0 -114
- package/components/menu/test-suites/LionMenuInteractions.suite.js +0 -583
- package/components/menu/test-suites/MoreButtonMenuMixin.suite.js +0 -372
- package/components/menu/test-suites/MultiLevelListMixin.suite.js +0 -303
- package/components/menu/types/InteractiveListMixinTypes.d.ts +0 -84
- package/components/overlays/NEXT.md +0 -49
- package/dist-types/components/menu/index.d.ts +0 -3
- package/dist-types/components/menu/index.d.ts.map +0 -1
- package/dist-types/components/menu/lion-menu.d.ts +0 -2
- package/dist-types/components/menu/lion-menu.d.ts.map +0 -1
- package/dist-types/components/menu/src/MoreButtonMenuMixin.d.ts +0 -39
- package/dist-types/components/menu/src/MoreButtonMenuMixin.d.ts.map +0 -1
- package/dist-types/components/menu/src/utils/isInView.d.ts +0 -9
- package/dist-types/components/menu/src/utils/isInView.d.ts.map +0 -1
- package/dist-types/components/menu/src/utils/listItemInteractions.d.ts +0 -48
- package/dist-types/components/menu/src/utils/listItemInteractions.d.ts.map +0 -1
- package/dist-types/components/menu/test/InteractiveListMixin.test.d.ts +0 -2
- package/dist-types/components/menu/test/InteractiveListMixin.test.d.ts.map +0 -1
- package/dist-types/components/menu/test/MoreButtonMenuMixin.test.d.ts +0 -2
- package/dist-types/components/menu/test/MoreButtonMenuMixin.test.d.ts.map +0 -1
- package/dist-types/components/menu/test/MultiLevelListMixin.test.d.ts +0 -2
- package/dist-types/components/menu/test/MultiLevelListMixin.test.d.ts.map +0 -1
- package/dist-types/components/menu/test/lion-menu-interactions.test.d.ts +0 -2
- package/dist-types/components/menu/test/lion-menu-interactions.test.d.ts.map +0 -1
- package/dist-types/components/menu/test/lion-menu.test.d.ts +0 -2
- package/dist-types/components/menu/test/lion-menu.test.d.ts.map +0 -1
- package/dist-types/components/menu/test-helpers/mimicKeyPress.d.ts +0 -7
- package/dist-types/components/menu/test-helpers/mimicKeyPress.d.ts.map +0 -1
- package/dist-types/components/menu/test-suites/InteractiveListMixin.suite.d.ts +0 -11
- package/dist-types/components/menu/test-suites/InteractiveListMixin.suite.d.ts.map +0 -1
- package/dist-types/components/menu/test-suites/LionMenu.suite.d.ts +0 -9
- package/dist-types/components/menu/test-suites/LionMenu.suite.d.ts.map +0 -1
- package/dist-types/components/menu/test-suites/LionMenuInteractions.suite.d.ts +0 -5
- package/dist-types/components/menu/test-suites/LionMenuInteractions.suite.d.ts.map +0 -1
- package/dist-types/components/menu/test-suites/MoreButtonMenuMixin.suite.d.ts +0 -11
- package/dist-types/components/menu/test-suites/MoreButtonMenuMixin.suite.d.ts.map +0 -1
- package/dist-types/components/menu/test-suites/MultiLevelListMixin.suite.d.ts +0 -11
- package/dist-types/components/menu/test-suites/MultiLevelListMixin.suite.d.ts.map +0 -1
- package/dist-types/exports/define/lion-item.d.ts +0 -2
- package/dist-types/exports/define/lion-item.d.ts.map +0 -1
- package/dist-types/exports/define/lion-menu.d.ts +0 -2
- package/dist-types/exports/define/lion-menu.d.ts.map +0 -1
- package/dist-types/exports/menu-test-suites.d.ts +0 -4
- package/dist-types/exports/menu-test-suites.d.ts.map +0 -1
- package/dist-types/exports/menu.d.ts +0 -3
- package/dist-types/exports/menu.d.ts.map +0 -1
- package/docs/components/menu/api-table.md +0 -121
- package/docs/components/menu/applyMenuDemoStyles.js +0 -173
- package/docs/components/menu/extensions.md +0 -262
- package/docs/components/menu/index.md +0 -13
- package/docs/components/menu/overview.md +0 -422
- package/docs/components/menu/src/DemoNavigationBar.js +0 -441
- package/docs/components/menu/src/DemoSpinButton.js +0 -215
- package/docs/components/menu/src/DemoToolbar.js +0 -101
- package/docs/components/menu/src/DemoTree.js +0 -55
- package/docs/components/menu/src/navigation-bar-types.js +0 -41
- package/docs/components/menu/use-cases.md +0 -74
- package/exports/define/lion-item.js +0 -3
- package/exports/define/lion-menu.js +0 -3
- package/exports/menu-test-suites.js +0 -4
- package/exports/menu.js +0 -3
- package/menu-test-suites.js +0 -4
- package/menu.js +0 -3
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { html } from 'lit';
|
|
3
|
-
import { dedupeMixin } from '@open-wc/dedupe-mixin';
|
|
4
|
-
// import { DisclosureMixin } from '@lion/ui/collapsible.js';
|
|
5
|
-
import { InteractiveListMixin } from './InteractiveListMixin.js';
|
|
6
|
-
import { isChecked, setChecked } from './utils/listItemInteractions.js';
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {import('./InteractiveListMixin.js').LionItem} LionItem
|
|
9
|
-
* @typedef {import('../types/InteractiveListMixinTypes.js').InteractiveListHost} InteractiveList
|
|
10
|
-
* @typedef {typeof import('../../overlays/types/OverlayMixinTypes.js').OverlayHost} OverlayHost
|
|
11
|
-
* @typedef {import('./LionMenu.js').LionMenu} LionMenu
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* All logic that is needed for interactive lists that are allowed to have multiple nested, collapsible levels
|
|
16
|
-
* Applies to [role=menu] and [role=tree]
|
|
17
|
-
*/
|
|
18
|
-
// @ts-ignore - mixin implementation
|
|
19
|
-
const MultiLevelListMixinImplementation = superclass =>
|
|
20
|
-
// @ts-ignore - mixin class extension
|
|
21
|
-
class extends InteractiveListMixin(superclass) {
|
|
22
|
-
render() {
|
|
23
|
-
return html`
|
|
24
|
-
<slot name="invoker"></slot>
|
|
25
|
-
<slot name="list"></slot>
|
|
26
|
-
<slot id="list-items-outlet"></slot>
|
|
27
|
-
`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static get properties() {
|
|
31
|
-
return {
|
|
32
|
-
invokerNode: Object,
|
|
33
|
-
behaveAsAccordion: { type: Boolean, attribute: 'behave-as-accordion' },
|
|
34
|
-
level: { type: Number, reflect: true },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @configure DisclosureMixin
|
|
40
|
-
*/
|
|
41
|
-
get _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;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @configure DisclosureMixin
|
|
53
|
-
* This will be compatible with DisclosureMixin and OverlayMixin. It contains the invoked
|
|
54
|
-
* InteractiveList widget (like menu|tree).
|
|
55
|
-
*/
|
|
56
|
-
get _contentNode() {
|
|
57
|
-
return this._listNode;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
constructor() {
|
|
61
|
-
super();
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* When an invokerNode is supplied (usually by a parent level menu), it will take precedence
|
|
65
|
-
* over [slot=invoker] and previousElementSibling with [data-invoker] attribute
|
|
66
|
-
* @type {HTMLElement}
|
|
67
|
-
*/
|
|
68
|
-
// @ts-ignore - can be undefined initially
|
|
69
|
-
this.invokerNode = undefined;
|
|
70
|
-
/**
|
|
71
|
-
* @configure DisclosureMixin
|
|
72
|
-
*/
|
|
73
|
-
this.handleFocus = true;
|
|
74
|
-
/**
|
|
75
|
-
* The parent list if level > 1
|
|
76
|
-
* @type {InteractiveList}
|
|
77
|
-
*/
|
|
78
|
-
// @ts-ignore - can be undefined initially
|
|
79
|
-
this.parentList = undefined;
|
|
80
|
-
/**
|
|
81
|
-
* When true, will have a maximum of one submenu open at a time
|
|
82
|
-
*/
|
|
83
|
-
this.behaveAsAccordion = false;
|
|
84
|
-
/**
|
|
85
|
-
* The level of nested menus. Will be reflected as attribute for styling purposes
|
|
86
|
-
*/
|
|
87
|
-
this.level = 1;
|
|
88
|
-
/**
|
|
89
|
-
* @configure InteractiveListMixin
|
|
90
|
-
*/
|
|
91
|
-
this.noPreselect = true;
|
|
92
|
-
/**
|
|
93
|
-
* @configure InteractiveListMixin
|
|
94
|
-
* @type {'activedescendant'|'roving-tabindex'|'tabbable-disclosure'}
|
|
95
|
-
*/
|
|
96
|
-
this._activeMode = 'roving-tabindex';
|
|
97
|
-
/**
|
|
98
|
-
* @type {Map<HTMLElement|LionItem,InteractiveList>}
|
|
99
|
-
*/
|
|
100
|
-
this._subListMap = new Map();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// /**
|
|
104
|
-
// * @param {import('lit-element').PropertyValues } changedProperties
|
|
105
|
-
// */
|
|
106
|
-
// updated(changedProperties) {
|
|
107
|
-
// super.updated(changedProperties);
|
|
108
|
-
|
|
109
|
-
// if (changedProperties.has('invokerNode')) {
|
|
110
|
-
// // TODO: update openableCtrl invokerNode once we make this a ctrl as well
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Gets the child InteractiveList, based on item
|
|
116
|
-
* @param {LionItem|HTMLElement} item can be sibling of or parent of InteractiveList
|
|
117
|
-
*/
|
|
118
|
-
static _getSubInteractiveList(item) {
|
|
119
|
-
/**
|
|
120
|
-
* Note that, according to W3C spec, the sub level element with [role=menu|menubar|tree]
|
|
121
|
-
* needs to be a sibling of the invoker element with
|
|
122
|
-
* [role=menuitem|menuitemchecbox|menuitemradio|treeitem] (and not the parent)
|
|
123
|
-
*
|
|
124
|
-
* In the example below <lion-menu> is considered as item
|
|
125
|
-
* @example
|
|
126
|
-
* <lion-menuitem>
|
|
127
|
-
* <button slot="invoker"></button>
|
|
128
|
-
* <lion-menu> ... </lion-menu>
|
|
129
|
-
* </lion-menuitem>
|
|
130
|
-
*/
|
|
131
|
-
// @ts-ignore - isInteractiveList property check
|
|
132
|
-
const siblingOfInvoker = item.nextElementSibling?.isInteractiveList;
|
|
133
|
-
if (siblingOfInvoker) {
|
|
134
|
-
return item.nextElementSibling;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* In the example below div[role=listitem] | [data-item] is considered as item
|
|
138
|
-
* @example
|
|
139
|
-
* <div role="listitem" data-item>
|
|
140
|
-
* <button slot="invoker"></button>
|
|
141
|
-
* <lion-menu> ... </lion-menu>
|
|
142
|
-
* </div>
|
|
143
|
-
*/
|
|
144
|
-
const childOfInvoker =
|
|
145
|
-
item.getAttribute?.('role') === 'listitem' || item.hasAttribute?.('data-item');
|
|
146
|
-
if (childOfInvoker) {
|
|
147
|
-
// @ts-ignore - isInteractiveList check
|
|
148
|
-
return Array.from(item.children).find(child => child.isInteractiveList);
|
|
149
|
-
}
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @param {*} newItems
|
|
155
|
-
*/
|
|
156
|
-
_initListItems(newItems) {
|
|
157
|
-
super._initListItems(newItems);
|
|
158
|
-
|
|
159
|
-
const ctor = this.constructor;
|
|
160
|
-
// @ts-ignore - forEach parameter types
|
|
161
|
-
newItems.forEach(item => {
|
|
162
|
-
// @ts-ignore - static method access
|
|
163
|
-
const subList = ctor._getSubInteractiveList(item);
|
|
164
|
-
if (subList) {
|
|
165
|
-
this._subListMap.set(item, subList);
|
|
166
|
-
subList.level = this.level + 1;
|
|
167
|
-
subList.parentList = this;
|
|
168
|
-
subList.invokerNode = item;
|
|
169
|
-
// @ts-ignore - invokerInteraction property
|
|
170
|
-
subList.invokerInteraction = this.invokerInteraction;
|
|
171
|
-
subList._activeMode = this._activeMode;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* @enhance DisclosureMixin
|
|
178
|
-
* @param {Event} [ev]
|
|
179
|
-
*/
|
|
180
|
-
toggle(ev) {
|
|
181
|
-
// @ts-ignore - target property
|
|
182
|
-
if (ev && this._listNode.contains(ev.target)) {
|
|
183
|
-
// prevent nested menus (inside invokers) from triggering invoker
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
// @ts-ignore - super.toggle method
|
|
187
|
-
super.toggle();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* @enhance InteractiveListMixin
|
|
192
|
-
* @param {*} ev
|
|
193
|
-
*/
|
|
194
|
-
_onListKeyDown(ev) {
|
|
195
|
-
const targetFromSubList = Array.from(this._subListMap).find(
|
|
196
|
-
// @ts-ignore - contains method on InteractiveListHost
|
|
197
|
-
([, s]) => s === ev.target || s.contains(ev.target),
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
if (targetFromSubList) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
super._onListKeyDown(ev);
|
|
205
|
-
|
|
206
|
-
const subListOfActiveItem = this._subListMap.get(this.activeItem);
|
|
207
|
-
const parentListOfActiveItem = this.parentList;
|
|
208
|
-
const { key } = ev;
|
|
209
|
-
|
|
210
|
-
if (key === 'Escape' && parentListOfActiveItem) {
|
|
211
|
-
// We need to stop here, or else we affect parent menu (handled by OverlayController)
|
|
212
|
-
ev.stopPropagation();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
switch (key) {
|
|
216
|
-
case 'Enter':
|
|
217
|
-
case ' ':
|
|
218
|
-
// make it work like a button
|
|
219
|
-
this.activeItem?.click();
|
|
220
|
-
break;
|
|
221
|
-
case 'ArrowDown':
|
|
222
|
-
if (
|
|
223
|
-
this.orientation === 'horizontal' &&
|
|
224
|
-
subListOfActiveItem &&
|
|
225
|
-
this._activeMode !== 'tabbable-disclosure'
|
|
226
|
-
) {
|
|
227
|
-
this.activeItem.click();
|
|
228
|
-
}
|
|
229
|
-
break;
|
|
230
|
-
case 'ArrowRight':
|
|
231
|
-
if (this.orientation === 'vertical' && subListOfActiveItem) {
|
|
232
|
-
this.activeItem.click();
|
|
233
|
-
}
|
|
234
|
-
break;
|
|
235
|
-
case 'ArrowUp':
|
|
236
|
-
if (this.orientation === 'horizontal' && parentListOfActiveItem) {
|
|
237
|
-
// @ts-ignore - close method
|
|
238
|
-
this.close();
|
|
239
|
-
if (/** @type {InteractiveList & LionMenu} */ (parentListOfActiveItem)._onOverlayShow) {
|
|
240
|
-
// @ts-ignore - _onOverlayShow method
|
|
241
|
-
/** @type {OverlayHost} */ (parentListOfActiveItem)._onOverlayShow();
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
break;
|
|
245
|
-
case 'ArrowLeft':
|
|
246
|
-
if (this.orientation === 'vertical' && parentListOfActiveItem) {
|
|
247
|
-
// @ts-ignore - close method
|
|
248
|
-
this.close();
|
|
249
|
-
if (/** @type {InteractiveList & LionMenu} */ (parentListOfActiveItem)._onOverlayShow) {
|
|
250
|
-
// @ts-ignore - _onOverlayShow method
|
|
251
|
-
/** @type {OverlayHost} */ (parentListOfActiveItem)._onOverlayShow();
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
break;
|
|
255
|
-
/* no default */
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* @param {Location} location
|
|
261
|
-
*/
|
|
262
|
-
_syncCurrentPageWithLocationHref(location) {
|
|
263
|
-
super._syncCurrentPageWithLocationHref(location);
|
|
264
|
-
|
|
265
|
-
this._subListMap.forEach(subList => {
|
|
266
|
-
subList.listItems.forEach(
|
|
267
|
-
/** @param {LionItem|HTMLElement} item */ item => {
|
|
268
|
-
// @ts-ignore
|
|
269
|
-
if (isChecked(item) && subList._invokerNode) {
|
|
270
|
-
// @ts-ignore
|
|
271
|
-
setChecked(subList._invokerNode);
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
);
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// /**
|
|
279
|
-
// * @enhance DisclosureMixin
|
|
280
|
-
// */
|
|
281
|
-
// _setupDisclosure() {
|
|
282
|
-
// if (!this._invokerNode) return;
|
|
283
|
-
|
|
284
|
-
// super._setupDisclosure();
|
|
285
|
-
// }
|
|
286
|
-
|
|
287
|
-
// /**
|
|
288
|
-
// * @enhance DisclosureMixin
|
|
289
|
-
// */
|
|
290
|
-
// _teardownDisclosure() {
|
|
291
|
-
// if (!this._invokerNode) return;
|
|
292
|
-
|
|
293
|
-
// super._teardownDisclosure();
|
|
294
|
-
// }
|
|
295
|
-
|
|
296
|
-
// /**
|
|
297
|
-
// * @enhance DisclosureMixin
|
|
298
|
-
// */
|
|
299
|
-
// async _onOpenedChanged() {
|
|
300
|
-
// if (!this._invokerNode) return;
|
|
301
|
-
|
|
302
|
-
// await super._onOpenedChanged();
|
|
303
|
-
// }
|
|
304
|
-
};
|
|
305
|
-
export const MultiLevelListMixin = dedupeMixin(MultiLevelListMixinImplementation);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether element is visible within container
|
|
3
|
-
*
|
|
4
|
-
* @param {HTMLElement} container
|
|
5
|
-
* @param {HTMLElement} element
|
|
6
|
-
* @param {Boolean} [partial]
|
|
7
|
-
*/
|
|
8
|
-
export function isInView(container, element, partial = false) {
|
|
9
|
-
const cTop = container.scrollTop;
|
|
10
|
-
const cBottom = cTop + container.clientHeight;
|
|
11
|
-
const eTop = element.offsetTop;
|
|
12
|
-
const eBottom = eTop + element.clientHeight;
|
|
13
|
-
const isTotal = eTop >= cTop && eBottom <= cBottom;
|
|
14
|
-
let isPartial;
|
|
15
|
-
|
|
16
|
-
if (partial === true) {
|
|
17
|
-
isPartial = (eTop < cTop && eBottom > cTop) || (eBottom > cBottom && eTop < cBottom);
|
|
18
|
-
} else if (typeof partial === 'number') {
|
|
19
|
-
if (eTop < cTop && eBottom > cTop) {
|
|
20
|
-
isPartial = ((eBottom - cTop) * 100) / element.clientHeight > partial;
|
|
21
|
-
} else if (eBottom > cBottom && eTop < cBottom) {
|
|
22
|
-
isPartial = ((cBottom - eTop) * 100) / element.clientHeight > partial;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return isTotal || isPartial;
|
|
26
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set of universal interactive list item state methods that are both compatible with
|
|
3
|
-
* 'smart' (LionOption) and 'regular' items
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('@lion/ui/checkbox-group.js').LionCheckboxIndeterminate} LionCheckboxIndeterminate
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {HTMLElement} item
|
|
12
|
-
*/
|
|
13
|
-
export function isDisabled(item) {
|
|
14
|
-
return item.hasAttribute('disabled') || item.getAttribute('aria-disabled') === 'true';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {HTMLElement} item
|
|
19
|
-
*/
|
|
20
|
-
export function setDisabled(item, unset = false) {
|
|
21
|
-
if (unset) {
|
|
22
|
-
item.removeAttribute('disabled');
|
|
23
|
-
item.setAttribute('aria-disabled', 'false');
|
|
24
|
-
} else {
|
|
25
|
-
item.setAttribute('disabled', '');
|
|
26
|
-
item.setAttribute('aria-disabled', 'true');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param {HTMLElement} item
|
|
32
|
-
*/
|
|
33
|
-
export function toggleDisabled(item) {
|
|
34
|
-
setDisabled(item, isDisabled(item));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param {HTMLElement} item
|
|
39
|
-
*/
|
|
40
|
-
export function isChecked(item) {
|
|
41
|
-
return item.hasAttribute('checked');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {HTMLElement} item
|
|
46
|
-
* @param {Object} [options]
|
|
47
|
-
* @param {boolean} [options.unset=false]
|
|
48
|
-
* @param {'page'|'mixed'} [options.text] - optional text to set for aria-checked/aria-selected/aria-current (e.g. "mixed")
|
|
49
|
-
*/
|
|
50
|
-
export function setChecked(item, unset = false) {
|
|
51
|
-
const role = item.getAttribute('role');
|
|
52
|
-
let ariaAttr = 'current';
|
|
53
|
-
if (role?.endsWith('checkbox') || role?.endsWith('radio')) {
|
|
54
|
-
ariaAttr = 'checked';
|
|
55
|
-
} else if (role === 'option' || role === 'treeitem') {
|
|
56
|
-
ariaAttr = 'selected';
|
|
57
|
-
}
|
|
58
|
-
let text;
|
|
59
|
-
if (/** @type {HTMLAnchorElement} */ (item).href) {
|
|
60
|
-
text = 'page';
|
|
61
|
-
}
|
|
62
|
-
if (/** @type {LionCheckboxIndeterminate} */ (item).mixedState) {
|
|
63
|
-
text = 'mixed';
|
|
64
|
-
}
|
|
65
|
-
if (!unset) {
|
|
66
|
-
item.setAttribute('checked', '');
|
|
67
|
-
item.setAttribute(`aria-${ariaAttr}`, text || 'true');
|
|
68
|
-
} else {
|
|
69
|
-
item.removeAttribute('checked');
|
|
70
|
-
item.setAttribute(`aria-${ariaAttr}`, 'false');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param {HTMLElement} item
|
|
76
|
-
*/
|
|
77
|
-
export function toggleChecked(item) {
|
|
78
|
-
const shouldUnset = isChecked(item);
|
|
79
|
-
setChecked(item, shouldUnset);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {HTMLElement} item
|
|
84
|
-
*/
|
|
85
|
-
export function isActive(item) {
|
|
86
|
-
return item.hasAttribute('active');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @param {HTMLElement} item
|
|
91
|
-
*/
|
|
92
|
-
export function setActive(item, unset = false) {
|
|
93
|
-
if (unset) {
|
|
94
|
-
item.removeAttribute('active');
|
|
95
|
-
} else {
|
|
96
|
-
item.setAttribute('active', '');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {HTMLElement} item
|
|
102
|
-
*/
|
|
103
|
-
function getDirectTextContent(item) {
|
|
104
|
-
return Array.from(item.childNodes)
|
|
105
|
-
.filter(n => n.nodeName === '#text')
|
|
106
|
-
.map(n => n.textContent)
|
|
107
|
-
.join('')
|
|
108
|
-
.trim();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @param {HTMLElement} item
|
|
113
|
-
*/
|
|
114
|
-
export function getValue(item) {
|
|
115
|
-
return (
|
|
116
|
-
// @ts-ignore - choiceValue is a custom property
|
|
117
|
-
item.choiceValue ||
|
|
118
|
-
// @ts-ignore - value might not exist on all HTMLElements
|
|
119
|
-
item.value ||
|
|
120
|
-
item.getAttribute('value') ||
|
|
121
|
-
item.getAttribute('data-value') ||
|
|
122
|
-
getDirectTextContent(item)
|
|
123
|
-
);
|
|
124
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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';
|
|
5
|
-
import '@lion/ui/define/lion-menu.js';
|
|
6
|
-
|
|
7
|
-
// The Mixin suites run against plain mixin hosts (their defaults) on purpose:
|
|
8
|
-
// LionMenu composes InteractiveListMixin + MultiLevelListMixin with the
|
|
9
|
-
// overlay/disclosure behavior, and the composite is covered by the LionMenu
|
|
10
|
-
// suites.
|
|
11
|
-
runInteractiveListMixinSuite();
|
|
12
|
-
runMultiLevelListMixinSuite();
|
|
13
|
-
runMoreButtonMenuMixinSuite({ tagString: 'lion-menu' });
|
|
14
|
-
runLionMenuSuite({ tagString: 'lion-menu' });
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|