@aquera/nile-elements 1.9.4 → 1.9.5
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/README.md +7 -0
- package/dist/index-5fef1a0d.esm.js +1 -0
- package/dist/index-8f38fae3.cjs.js +2 -0
- package/dist/index-8f38fae3.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1287 -736
- package/dist/nile-combobox/index.cjs.js +1 -1
- package/dist/nile-combobox/index.esm.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.esm.js +1 -1
- package/dist/nile-command-menu/index.cjs.js +2 -0
- package/dist/nile-command-menu/index.cjs.js.map +1 -0
- package/dist/nile-command-menu/index.esm.js +1 -0
- package/dist/nile-command-menu/nile-command-menu.cjs.js +2 -0
- package/dist/nile-command-menu/nile-command-menu.cjs.js.map +1 -0
- package/dist/nile-command-menu/nile-command-menu.css.cjs.js +2 -0
- package/dist/nile-command-menu/nile-command-menu.css.cjs.js.map +1 -0
- package/dist/nile-command-menu/nile-command-menu.css.esm.js +182 -0
- package/dist/nile-command-menu/nile-command-menu.esm.js +97 -0
- package/dist/nile-command-menu-group/index.cjs.js +2 -0
- package/dist/nile-command-menu-group/index.cjs.js.map +1 -0
- package/dist/nile-command-menu-group/index.esm.js +1 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.cjs.js +2 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.cjs.js.map +1 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.css.cjs.js +2 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.css.cjs.js.map +1 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.css.esm.js +33 -0
- package/dist/nile-command-menu-group/nile-command-menu-group.esm.js +11 -0
- package/dist/nile-command-menu-item/index.cjs.js +2 -0
- package/dist/nile-command-menu-item/index.cjs.js.map +1 -0
- package/dist/nile-command-menu-item/index.esm.js +1 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.cjs.js +2 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.cjs.js.map +1 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.css.cjs.js +2 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.css.cjs.js.map +1 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.css.esm.js +115 -0
- package/dist/nile-command-menu-item/nile-command-menu-item.esm.js +21 -0
- package/dist/nile-detail/index.cjs.js +1 -1
- package/dist/nile-detail/index.esm.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js +1 -1
- package/dist/nile-detail/nile-detail.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.esm.js +1 -1
- package/dist/nile-dot-stepper/index.cjs.js +2 -0
- package/dist/nile-dot-stepper/index.cjs.js.map +1 -0
- package/dist/nile-dot-stepper/index.esm.js +1 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.cjs.js +2 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.cjs.js.map +1 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.css.cjs.js +2 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.css.cjs.js.map +1 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.css.esm.js +77 -0
- package/dist/nile-dot-stepper/nile-dot-stepper.esm.js +24 -0
- package/dist/nile-section-message/nile-section-message.css.cjs.js +1 -1
- package/dist/nile-section-message/nile-section-message.css.cjs.js.map +1 -1
- package/dist/nile-section-message/nile-section-message.css.esm.js +7 -8
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-command-menu/index.d.ts +1 -0
- package/dist/src/nile-command-menu/index.js +2 -0
- package/dist/src/nile-command-menu/index.js.map +1 -0
- package/dist/src/nile-command-menu/nile-command-menu.css.d.ts +12 -0
- package/dist/src/nile-command-menu/nile-command-menu.css.js +194 -0
- package/dist/src/nile-command-menu/nile-command-menu.css.js.map +1 -0
- package/dist/src/nile-command-menu/nile-command-menu.d.ts +137 -0
- package/dist/src/nile-command-menu/nile-command-menu.js +557 -0
- package/dist/src/nile-command-menu/nile-command-menu.js.map +1 -0
- package/dist/src/nile-command-menu/nile-command-menu.test.d.ts +3 -0
- package/dist/src/nile-command-menu/nile-command-menu.test.js +268 -0
- package/dist/src/nile-command-menu/nile-command-menu.test.js.map +1 -0
- package/dist/src/nile-command-menu-group/index.d.ts +1 -0
- package/dist/src/nile-command-menu-group/index.js +2 -0
- package/dist/src/nile-command-menu-group/index.js.map +1 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.css.d.ts +12 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.css.js +45 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.css.js.map +1 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.d.ts +38 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.js +68 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.js.map +1 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.test.d.ts +2 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.test.js +22 -0
- package/dist/src/nile-command-menu-group/nile-command-menu-group.test.js.map +1 -0
- package/dist/src/nile-command-menu-item/index.d.ts +1 -0
- package/dist/src/nile-command-menu-item/index.js +2 -0
- package/dist/src/nile-command-menu-item/index.js.map +1 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.css.d.ts +12 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.css.js +127 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.css.js.map +1 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.d.ts +73 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.js +174 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.js.map +1 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.test.d.ts +1 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.test.js +35 -0
- package/dist/src/nile-command-menu-item/nile-command-menu-item.test.js.map +1 -0
- package/dist/src/nile-dialog/nile-dialog.js +1 -1
- package/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/dist/src/nile-dot-stepper/index.d.ts +1 -0
- package/dist/src/nile-dot-stepper/index.js +2 -0
- package/dist/src/nile-dot-stepper/index.js.map +1 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.css.d.ts +12 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.css.js +89 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.css.js.map +1 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.d.ts +48 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.js +153 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.js.map +1 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.test.d.ts +1 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.test.js +319 -0
- package/dist/src/nile-dot-stepper/nile-dot-stepper.test.js.map +1 -0
- package/dist/src/nile-section-message/nile-section-message.css.js +7 -8
- package/dist/src/nile-section-message/nile-section-message.css.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/index.ts +4 -0
- package/src/nile-command-menu/index.ts +1 -0
- package/src/nile-command-menu/nile-command-menu.css.ts +196 -0
- package/src/nile-command-menu/nile-command-menu.test.ts +289 -0
- package/src/nile-command-menu/nile-command-menu.ts +601 -0
- package/src/nile-command-menu-group/index.ts +1 -0
- package/src/nile-command-menu-group/nile-command-menu-group.css.ts +47 -0
- package/src/nile-command-menu-group/nile-command-menu-group.test.ts +23 -0
- package/src/nile-command-menu-group/nile-command-menu-group.ts +72 -0
- package/src/nile-command-menu-item/index.ts +1 -0
- package/src/nile-command-menu-item/nile-command-menu-item.css.ts +129 -0
- package/src/nile-command-menu-item/nile-command-menu-item.test.ts +36 -0
- package/src/nile-command-menu-item/nile-command-menu-item.ts +172 -0
- package/src/nile-dialog/nile-dialog.ts +1 -1
- package/src/nile-dot-stepper/index.ts +1 -0
- package/src/nile-dot-stepper/nile-dot-stepper.css.ts +90 -0
- package/src/nile-dot-stepper/nile-dot-stepper.test.ts +493 -0
- package/src/nile-dot-stepper/nile-dot-stepper.ts +159 -0
- package/src/nile-section-message/nile-section-message.css.ts +7 -8
- package/stories/dot-stepper.stories.ts +67 -0
- package/vscode-html-custom-data.json +179 -0
- package/dist/index-c0b5232c.cjs.js +0 -2
- package/dist/index-c0b5232c.cjs.js.map +0 -1
- package/dist/index-e43a18eb.esm.js +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { __decorate } from "tslib";
|
|
8
|
+
import { html } from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
import { styles } from './nile-command-menu-group.css';
|
|
12
|
+
import { HasSlotController } from '../internal/slot';
|
|
13
|
+
import NileElement from '../internal/nile-element';
|
|
14
|
+
/**
|
|
15
|
+
* Groups related commands under an optional heading inside a `nile-command-menu`.
|
|
16
|
+
*
|
|
17
|
+
* @tag nile-command-menu-group
|
|
18
|
+
*
|
|
19
|
+
* @summary A labelled section of command items within a command menu.
|
|
20
|
+
* @status stable
|
|
21
|
+
* @since 2.0
|
|
22
|
+
*
|
|
23
|
+
* @slot - The group's command items (`nile-command-menu-item`).
|
|
24
|
+
* @slot heading - The group heading. Takes precedence over the `heading` attribute when provided.
|
|
25
|
+
*
|
|
26
|
+
* @csspart base - The component's base wrapper.
|
|
27
|
+
* @csspart heading - The group heading.
|
|
28
|
+
* @csspart items - The wrapper around the slotted items.
|
|
29
|
+
*/
|
|
30
|
+
let NileCommandMenuGroup = class NileCommandMenuGroup extends NileElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.hasSlotController = new HasSlotController(this, 'heading');
|
|
34
|
+
/** The text heading shown above the group's items. Use the `heading` slot for richer content. */
|
|
35
|
+
this.heading = '';
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
this.setAttribute('role', 'group');
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const hasHeading = this.heading.length > 0 || this.hasSlotController.test('heading');
|
|
43
|
+
return html `
|
|
44
|
+
<div part="base" class="group">
|
|
45
|
+
<div
|
|
46
|
+
part="heading"
|
|
47
|
+
class=${classMap({
|
|
48
|
+
group__heading: true,
|
|
49
|
+
'group__heading--empty': !hasHeading,
|
|
50
|
+
})}
|
|
51
|
+
>
|
|
52
|
+
<slot name="heading">${this.heading}</slot>
|
|
53
|
+
</div>
|
|
54
|
+
<slot part="items" class="group__items"></slot>
|
|
55
|
+
</div>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
NileCommandMenuGroup.styles = styles;
|
|
60
|
+
__decorate([
|
|
61
|
+
property()
|
|
62
|
+
], NileCommandMenuGroup.prototype, "heading", void 0);
|
|
63
|
+
NileCommandMenuGroup = __decorate([
|
|
64
|
+
customElement('nile-command-menu-group')
|
|
65
|
+
], NileCommandMenuGroup);
|
|
66
|
+
export { NileCommandMenuGroup };
|
|
67
|
+
export default NileCommandMenuGroup;
|
|
68
|
+
//# sourceMappingURL=nile-command-menu-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-command-menu-group.js","sourceRoot":"","sources":["../../../src/nile-command-menu-group/nile-command-menu-group.ts"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3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './nile-command-menu-group.css';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\n\n/**\n * Groups related commands under an optional heading inside a `nile-command-menu`.\n *\n * @tag nile-command-menu-group\n *\n * @summary A labelled section of command items within a command menu.\n * @status stable\n * @since 2.0\n *\n * @slot - The group's command items (`nile-command-menu-item`).\n * @slot heading - The group heading. Takes precedence over the `heading` attribute when provided.\n *\n * @csspart base - The component's base wrapper.\n * @csspart heading - The group heading.\n * @csspart items - The wrapper around the slotted items.\n */\n@customElement('nile-command-menu-group')\nexport class NileCommandMenuGroup extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private readonly hasSlotController = new HasSlotController(this, 'heading');\n\n /** The text heading shown above the group's items. Use the `heading` slot for richer content. */\n @property() heading = '';\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'group');\n }\n\n render() {\n const hasHeading = this.heading.length > 0 || this.hasSlotController.test('heading');\n\n return html`\n <div part=\"base\" class=\"group\">\n <div\n part=\"heading\"\n class=${classMap({\n group__heading: true,\n 'group__heading--empty': !hasHeading,\n })}\n >\n <slot name=\"heading\">${this.heading}</slot>\n </div>\n <slot part=\"items\" class=\"group__items\"></slot>\n </div>\n `;\n }\n}\n\nexport default NileCommandMenuGroup;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-command-menu-group': NileCommandMenuGroup;\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import './nile-command-menu-group';
|
|
3
|
+
import '../nile-command-menu-item/nile-command-menu-item';
|
|
4
|
+
describe('NileCommandMenuGroup', () => {
|
|
5
|
+
it('1. renders', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el).to.exist; });
|
|
6
|
+
it('2. shadow root', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot).to.not.be.null; });
|
|
7
|
+
it('3. tag name', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.tagName.toLowerCase()).to.equal('nile-command-menu-group'); });
|
|
8
|
+
it('4. heading defaults empty', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.heading).to.equal(''); });
|
|
9
|
+
it('5. set heading', async () => { const el = await fixture(html `<nile-command-menu-group heading="Actions"></nile-command-menu-group>`); expect(el.heading).to.equal('Actions'); });
|
|
10
|
+
it('6. role group', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.getAttribute('role')).to.equal('group'); });
|
|
11
|
+
it('7. base part', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot.querySelector('[part="base"]')).to.exist; });
|
|
12
|
+
it('8. heading part', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot.querySelector('[part="heading"]')).to.exist; });
|
|
13
|
+
it('9. items slot', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot.querySelector('slot[part="items"]')).to.exist; });
|
|
14
|
+
it('10. heading slot', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot.querySelector('slot[name="heading"]')).to.exist; });
|
|
15
|
+
it('11. heading text rendered', async () => { const el = await fixture(html `<nile-command-menu-group heading="Pages"></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot.querySelector('[part="heading"]').textContent).to.contain('Pages'); });
|
|
16
|
+
it('12. heading hidden when empty', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot.querySelector('.group__heading--empty')).to.exist; });
|
|
17
|
+
it('13. heading visible when set', async () => { const el = await fixture(html `<nile-command-menu-group heading="X"></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot.querySelector('.group__heading--empty')).to.be.null; });
|
|
18
|
+
it('14. holds items', async () => { const el = await fixture(html `<nile-command-menu-group heading="A"><nile-command-menu-item>One</nile-command-menu-item></nile-command-menu-group>`); expect(el.querySelectorAll('nile-command-menu-item').length).to.equal(1); });
|
|
19
|
+
it('15. dynamic heading', async () => { const el = await fixture(html `<nile-command-menu-group></nile-command-menu-group>`); el.heading = 'New'; await el.updateComplete; expect(el.shadowRoot.querySelector('[part="heading"]').textContent).to.contain('New'); });
|
|
20
|
+
it('16. is defined', async () => { expect(customElements.get('nile-command-menu-group')).to.exist; });
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=nile-command-menu-group.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-command-menu-group.test.js","sourceRoot":"","sources":["../../../src/nile-command-menu-group/nile-command-menu-group.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,2BAA2B,CAAC;AACnC,OAAO,kDAAkD,CAAC;AAG1D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAuB,IAAI,CAAA,qDAAqD,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClK,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAuB,IAAI,CAAA,qDAAqD,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CA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,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\nimport './nile-command-menu-group';\nimport '../nile-command-menu-item/nile-command-menu-item';\nimport type { NileCommandMenuGroup } from './nile-command-menu-group';\n\ndescribe('NileCommandMenuGroup', () => {\n it('1. renders', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el).to.exist; });\n it('2. shadow root', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot).to.not.be.null; });\n it('3. tag name', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.tagName.toLowerCase()).to.equal('nile-command-menu-group'); });\n it('4. heading defaults empty', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.heading).to.equal(''); });\n it('5. set heading', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group heading=\"Actions\"></nile-command-menu-group>`); expect(el.heading).to.equal('Actions'); });\n it('6. role group', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.getAttribute('role')).to.equal('group'); });\n it('7. base part', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot!.querySelector('[part=\"base\"]')).to.exist; });\n it('8. heading part', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot!.querySelector('[part=\"heading\"]')).to.exist; });\n it('9. items slot', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot!.querySelector('slot[part=\"items\"]')).to.exist; });\n it('10. heading slot', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); expect(el.shadowRoot!.querySelector('slot[name=\"heading\"]')).to.exist; });\n it('11. heading text rendered', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group heading=\"Pages\"></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot!.querySelector('[part=\"heading\"]')!.textContent).to.contain('Pages'); });\n it('12. heading hidden when empty', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot!.querySelector('.group__heading--empty')).to.exist; });\n it('13. heading visible when set', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group heading=\"X\"></nile-command-menu-group>`); await el.updateComplete; expect(el.shadowRoot!.querySelector('.group__heading--empty')).to.be.null; });\n it('14. holds items', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group heading=\"A\"><nile-command-menu-item>One</nile-command-menu-item></nile-command-menu-group>`); expect(el.querySelectorAll('nile-command-menu-item').length).to.equal(1); });\n it('15. dynamic heading', async () => { const el = await fixture<NileCommandMenuGroup>(html`<nile-command-menu-group></nile-command-menu-group>`); el.heading = 'New'; await el.updateComplete; expect(el.shadowRoot!.querySelector('[part=\"heading\"]')!.textContent).to.contain('New'); });\n it('16. is defined', async () => { expect(customElements.get('nile-command-menu-group')).to.exist; });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NileCommandMenuItem } from './nile-command-menu-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-command-menu-item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { NileCommandMenuItem } from './nile-command-menu-item';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* CommandMenuItem CSS
|
|
9
|
+
*/
|
|
10
|
+
export declare const styles: import("lit").CSSResult;
|
|
11
|
+
declare const _default: import("lit").CSSResult[];
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
/**
|
|
9
|
+
* CommandMenuItem CSS
|
|
10
|
+
*/
|
|
11
|
+
export const styles = css `
|
|
12
|
+
:host {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
display: block;
|
|
15
|
+
-webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));
|
|
16
|
+
-moz-osx-font-smoothing: var(--nile-moz-osx-font-smoothing, var(--ng-moz-osx-font-smoothing));
|
|
17
|
+
text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host *,
|
|
21
|
+
:host *::before,
|
|
22
|
+
:host *::after {
|
|
23
|
+
box-sizing: inherit;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([hidden]) {
|
|
27
|
+
display: none !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.item {
|
|
31
|
+
position: relative;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: var(--nile-spacing-md, var(--ng-spacing-md));
|
|
35
|
+
width: 100%;
|
|
36
|
+
margin-block: var(--nile-spacing-xxs, var(--ng-spacing-xxs));
|
|
37
|
+
padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
38
|
+
border-radius: var(--nile-radius-md, var(--ng-radius-md));
|
|
39
|
+
font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body));
|
|
40
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
41
|
+
font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
|
|
42
|
+
line-height: 1.4;
|
|
43
|
+
letter-spacing: normal;
|
|
44
|
+
color: var(--nile-color-dark-1, var(--ng-colors-text-secondary-700));
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
user-select: none;
|
|
47
|
+
transition: background-color 200ms ease, color 200ms ease;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* size variants — small (default) vs medium */
|
|
51
|
+
:host([size='medium']) .item {
|
|
52
|
+
padding-block: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Active / selected (keyboard or hover) */
|
|
56
|
+
:host([active]:not([disabled])) .item,
|
|
57
|
+
.item:hover {
|
|
58
|
+
background-color: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary-hover));
|
|
59
|
+
color: var(--nile-colors-dark-900, var(--ng-colors-text-secondary-hover));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:host([disabled]) .item {
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
opacity: 0.4;
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.item__icon {
|
|
69
|
+
flex: 0 0 auto;
|
|
70
|
+
/* Reserve a fixed icon gutter so items with and without a leading icon
|
|
71
|
+
keep their labels aligned. */
|
|
72
|
+
width: 20px;
|
|
73
|
+
height: 20px;
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-fg-quaternary-400));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.item__icon::slotted(*) {
|
|
81
|
+
width: 20px;
|
|
82
|
+
height: 20px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.item__label {
|
|
86
|
+
flex: 1 1 auto;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.item__suffix {
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.item__shortcut {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.item__shortcut kbd {
|
|
110
|
+
display: inline-flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
min-width: 20px;
|
|
114
|
+
height: 20px;
|
|
115
|
+
padding: 0 5px;
|
|
116
|
+
border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));
|
|
117
|
+
border: solid 1px var(--nile-colors-border-surface, var(--ng-colors-border-secondary-alt));
|
|
118
|
+
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
119
|
+
font-family: inherit;
|
|
120
|
+
font-size: 11px;
|
|
121
|
+
font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
|
|
122
|
+
line-height: 1;
|
|
123
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-fg-quaternary-400));
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
export default [styles];
|
|
127
|
+
//# sourceMappingURL=nile-command-menu-item.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-command-menu-item.css.js","sourceRoot":"","sources":["../../../src/nile-command-menu-item/nile-command-menu-item.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkHxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit';\n\n/**\n * CommandMenuItem CSS\n */\nexport const styles = css`\n :host {\n box-sizing: border-box;\n display: block;\n -webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));\n -moz-osx-font-smoothing: var(--nile-moz-osx-font-smoothing, var(--ng-moz-osx-font-smoothing));\n text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n .item {\n position: relative;\n display: flex;\n align-items: center;\n gap: var(--nile-spacing-md, var(--ng-spacing-md));\n width: 100%;\n margin-block: var(--nile-spacing-xxs, var(--ng-spacing-xxs));\n padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));\n border-radius: var(--nile-radius-md, var(--ng-radius-md));\n font-family: var(--nile-font-family-sans-serif, var(--ng-font-family-body));\n font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));\n font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));\n line-height: 1.4;\n letter-spacing: normal;\n color: var(--nile-color-dark-1, var(--ng-colors-text-secondary-700));\n cursor: pointer;\n user-select: none;\n transition: background-color 200ms ease, color 200ms ease;\n }\n\n /* size variants — small (default) vs medium */\n :host([size='medium']) .item {\n padding-block: var(--nile-spacing-lg, var(--ng-spacing-lg));\n }\n\n /* Active / selected (keyboard or hover) */\n :host([active]:not([disabled])) .item,\n .item:hover {\n background-color: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary-hover));\n color: var(--nile-colors-dark-900, var(--ng-colors-text-secondary-hover));\n }\n\n :host([disabled]) .item {\n cursor: not-allowed;\n opacity: 0.4;\n pointer-events: none;\n }\n\n .item__icon {\n flex: 0 0 auto;\n /* Reserve a fixed icon gutter so items with and without a leading icon\n keep their labels aligned. */\n width: 20px;\n height: 20px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n color: var(--nile-colors-dark-500, var(--ng-colors-fg-quaternary-400));\n }\n\n .item__icon::slotted(*) {\n width: 20px;\n height: 20px;\n }\n\n .item__label {\n flex: 1 1 auto;\n min-width: 0;\n display: inline-flex;\n align-items: center;\n gap: var(--nile-spacing-xs, var(--ng-spacing-xs));\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .item__suffix {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n gap: var(--nile-spacing-sm, var(--ng-spacing-sm));\n }\n\n .item__shortcut {\n display: inline-flex;\n align-items: center;\n gap: var(--nile-spacing-xs, var(--ng-spacing-xs));\n }\n\n .item__shortcut kbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n height: 20px;\n padding: 0 5px;\n border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));\n border: solid 1px var(--nile-colors-border-surface, var(--ng-colors-border-secondary-alt));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n font-family: inherit;\n font-size: 11px;\n font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));\n line-height: 1;\n color: var(--nile-colors-dark-500, var(--ng-colors-fg-quaternary-400));\n }\n`;\n\nexport default [styles];\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import NileElement from '../internal/nile-element';
|
|
8
|
+
import type { CSSResultGroup } from 'lit';
|
|
9
|
+
/**
|
|
10
|
+
* An individual selectable command inside a `nile-command-menu`.
|
|
11
|
+
*
|
|
12
|
+
* @tag nile-command-menu-item
|
|
13
|
+
*
|
|
14
|
+
* @summary Represents a single command/action entry within a command menu.
|
|
15
|
+
* @status stable
|
|
16
|
+
* @since 2.0
|
|
17
|
+
*
|
|
18
|
+
* @slot - The item's label.
|
|
19
|
+
* @slot icon - Used to prepend an icon (or similar element) before the label.
|
|
20
|
+
* @slot suffix - Used to append content (e.g. a hint) after the label, before the shortcut.
|
|
21
|
+
*
|
|
22
|
+
* @csspart base - The component's base wrapper.
|
|
23
|
+
* @csspart icon - The leading icon container.
|
|
24
|
+
* @csspart label - The item label.
|
|
25
|
+
* @csspart suffix - The trailing suffix container.
|
|
26
|
+
* @csspart shortcut - The keyboard-shortcut container.
|
|
27
|
+
*/
|
|
28
|
+
export declare class NileCommandMenuItem extends NileElement {
|
|
29
|
+
static styles: CSSResultGroup;
|
|
30
|
+
private cachedTextLabel;
|
|
31
|
+
defaultSlot: HTMLSlotElement;
|
|
32
|
+
/** Controls vertical padding of the item. */
|
|
33
|
+
size: 'small' | 'medium';
|
|
34
|
+
/** A unique value used to identify the item when it is selected. */
|
|
35
|
+
value: string;
|
|
36
|
+
/** Draws the item in a disabled state, preventing selection. */
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
/** Draws the item in an active/highlighted state. Managed by the parent menu for keyboard navigation. */
|
|
39
|
+
active: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Extra keywords used by the parent menu when filtering, in addition to the visible label.
|
|
42
|
+
* Useful for matching synonyms or abbreviations.
|
|
43
|
+
*/
|
|
44
|
+
keywords: string;
|
|
45
|
+
/**
|
|
46
|
+
* The search scope this item belongs to. When the menu has active scopes (the "Searching for" row),
|
|
47
|
+
* an item is shown only if it has no scope or its scope is among the active ones.
|
|
48
|
+
*/
|
|
49
|
+
scope: string;
|
|
50
|
+
/**
|
|
51
|
+
* A keyboard shortcut hint shown on the trailing edge of the item. Separate keys with a
|
|
52
|
+
* space to render each one in its own key box (e.g. `"⌘ K"`).
|
|
53
|
+
*/
|
|
54
|
+
shortcut: string;
|
|
55
|
+
connectedCallback(): void;
|
|
56
|
+
disconnectedCallback(): void;
|
|
57
|
+
private handleHostClick;
|
|
58
|
+
private handleDefaultSlotChange;
|
|
59
|
+
handleDisabledChange(): void;
|
|
60
|
+
handleActiveChange(): void;
|
|
61
|
+
/** Returns the plain-text label based on the default slot's content. */
|
|
62
|
+
getTextLabel(): string;
|
|
63
|
+
/** Returns the string the parent menu uses to match this item against a search query. */
|
|
64
|
+
getFilterText(): string;
|
|
65
|
+
private renderShortcut;
|
|
66
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
67
|
+
}
|
|
68
|
+
export default NileCommandMenuItem;
|
|
69
|
+
declare global {
|
|
70
|
+
interface HTMLElementTagNameMap {
|
|
71
|
+
'nile-command-menu-item': NileCommandMenuItem;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { __decorate } from "tslib";
|
|
8
|
+
import { html, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
import { styles } from './nile-command-menu-item.css';
|
|
12
|
+
import { getTextContent } from '../internal/slot';
|
|
13
|
+
import { watch } from '../internal/watch';
|
|
14
|
+
import NileElement from '../internal/nile-element';
|
|
15
|
+
/**
|
|
16
|
+
* An individual selectable command inside a `nile-command-menu`.
|
|
17
|
+
*
|
|
18
|
+
* @tag nile-command-menu-item
|
|
19
|
+
*
|
|
20
|
+
* @summary Represents a single command/action entry within a command menu.
|
|
21
|
+
* @status stable
|
|
22
|
+
* @since 2.0
|
|
23
|
+
*
|
|
24
|
+
* @slot - The item's label.
|
|
25
|
+
* @slot icon - Used to prepend an icon (or similar element) before the label.
|
|
26
|
+
* @slot suffix - Used to append content (e.g. a hint) after the label, before the shortcut.
|
|
27
|
+
*
|
|
28
|
+
* @csspart base - The component's base wrapper.
|
|
29
|
+
* @csspart icon - The leading icon container.
|
|
30
|
+
* @csspart label - The item label.
|
|
31
|
+
* @csspart suffix - The trailing suffix container.
|
|
32
|
+
* @csspart shortcut - The keyboard-shortcut container.
|
|
33
|
+
*/
|
|
34
|
+
let NileCommandMenuItem = class NileCommandMenuItem extends NileElement {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/** Controls vertical padding of the item. */
|
|
38
|
+
this.size = 'small';
|
|
39
|
+
/** A unique value used to identify the item when it is selected. */
|
|
40
|
+
this.value = '';
|
|
41
|
+
/** Draws the item in a disabled state, preventing selection. */
|
|
42
|
+
this.disabled = false;
|
|
43
|
+
/** Draws the item in an active/highlighted state. Managed by the parent menu for keyboard navigation. */
|
|
44
|
+
this.active = false;
|
|
45
|
+
/**
|
|
46
|
+
* Extra keywords used by the parent menu when filtering, in addition to the visible label.
|
|
47
|
+
* Useful for matching synonyms or abbreviations.
|
|
48
|
+
*/
|
|
49
|
+
this.keywords = '';
|
|
50
|
+
/**
|
|
51
|
+
* The search scope this item belongs to. When the menu has active scopes (the "Searching for" row),
|
|
52
|
+
* an item is shown only if it has no scope or its scope is among the active ones.
|
|
53
|
+
*/
|
|
54
|
+
this.scope = '';
|
|
55
|
+
/**
|
|
56
|
+
* A keyboard shortcut hint shown on the trailing edge of the item. Separate keys with a
|
|
57
|
+
* space to render each one in its own key box (e.g. `"⌘ K"`).
|
|
58
|
+
*/
|
|
59
|
+
this.shortcut = '';
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
super.connectedCallback();
|
|
63
|
+
this.setAttribute('role', 'option');
|
|
64
|
+
this.handleHostClick = this.handleHostClick.bind(this);
|
|
65
|
+
this.addEventListener('click', this.handleHostClick);
|
|
66
|
+
}
|
|
67
|
+
disconnectedCallback() {
|
|
68
|
+
super.disconnectedCallback();
|
|
69
|
+
this.removeEventListener('click', this.handleHostClick);
|
|
70
|
+
}
|
|
71
|
+
handleHostClick(event) {
|
|
72
|
+
// Swallow clicks while disabled so the menu never selects a disabled item.
|
|
73
|
+
if (this.disabled) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
event.stopImmediatePropagation();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
handleDefaultSlotChange() {
|
|
79
|
+
const textLabel = this.getTextLabel();
|
|
80
|
+
if (typeof this.cachedTextLabel === 'undefined') {
|
|
81
|
+
this.cachedTextLabel = textLabel;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (textLabel !== this.cachedTextLabel) {
|
|
85
|
+
this.cachedTextLabel = textLabel;
|
|
86
|
+
this.emit('slotchange');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
handleDisabledChange() {
|
|
90
|
+
this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
|
|
91
|
+
}
|
|
92
|
+
handleActiveChange() {
|
|
93
|
+
this.setAttribute('aria-selected', this.active ? 'true' : 'false');
|
|
94
|
+
}
|
|
95
|
+
/** Returns the plain-text label based on the default slot's content. */
|
|
96
|
+
getTextLabel() {
|
|
97
|
+
return getTextContent(this.defaultSlot);
|
|
98
|
+
}
|
|
99
|
+
/** Returns the string the parent menu uses to match this item against a search query. */
|
|
100
|
+
getFilterText() {
|
|
101
|
+
return `${this.getTextLabel()} ${this.keywords} ${this.value}`.toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
renderShortcut() {
|
|
104
|
+
if (!this.shortcut) {
|
|
105
|
+
return nothing;
|
|
106
|
+
}
|
|
107
|
+
const keys = this.shortcut.trim().split(/\s+/);
|
|
108
|
+
return html `
|
|
109
|
+
<span part="shortcut" class="item__shortcut">
|
|
110
|
+
${keys.map(key => html `<kbd>${key}</kbd>`)}
|
|
111
|
+
</span>
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
return html `
|
|
116
|
+
<div
|
|
117
|
+
part="base"
|
|
118
|
+
class=${classMap({
|
|
119
|
+
item: true,
|
|
120
|
+
'item--active': this.active,
|
|
121
|
+
'item--disabled': this.disabled,
|
|
122
|
+
})}
|
|
123
|
+
>
|
|
124
|
+
<slot name="icon" part="icon" class="item__icon"></slot>
|
|
125
|
+
|
|
126
|
+
<span part="label" class="item__label">
|
|
127
|
+
<slot @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
128
|
+
</span>
|
|
129
|
+
|
|
130
|
+
<span part="suffix" class="item__suffix">
|
|
131
|
+
<slot name="suffix"></slot>
|
|
132
|
+
${this.renderShortcut()}
|
|
133
|
+
</span>
|
|
134
|
+
</div>
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
NileCommandMenuItem.styles = styles;
|
|
139
|
+
__decorate([
|
|
140
|
+
query('slot:not([name])')
|
|
141
|
+
], NileCommandMenuItem.prototype, "defaultSlot", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
property({ reflect: true })
|
|
144
|
+
], NileCommandMenuItem.prototype, "size", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
property()
|
|
147
|
+
], NileCommandMenuItem.prototype, "value", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
property({ type: Boolean, reflect: true })
|
|
150
|
+
], NileCommandMenuItem.prototype, "disabled", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
property({ type: Boolean, reflect: true })
|
|
153
|
+
], NileCommandMenuItem.prototype, "active", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
property()
|
|
156
|
+
], NileCommandMenuItem.prototype, "keywords", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
property()
|
|
159
|
+
], NileCommandMenuItem.prototype, "scope", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
property()
|
|
162
|
+
], NileCommandMenuItem.prototype, "shortcut", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
watch('disabled')
|
|
165
|
+
], NileCommandMenuItem.prototype, "handleDisabledChange", null);
|
|
166
|
+
__decorate([
|
|
167
|
+
watch('active')
|
|
168
|
+
], NileCommandMenuItem.prototype, "handleActiveChange", null);
|
|
169
|
+
NileCommandMenuItem = __decorate([
|
|
170
|
+
customElement('nile-command-menu-item')
|
|
171
|
+
], NileCommandMenuItem);
|
|
172
|
+
export { NileCommandMenuItem };
|
|
173
|
+
export default NileCommandMenuItem;
|
|
174
|
+
//# sourceMappingURL=nile-command-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-command-menu-item.js","sourceRoot":"","sources":["../../../src/nile-command-menu-item/nile-command-menu-item.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,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I,CAAC,QAAQ;SAChC,CAAC;;;;;8BAKoB,IAAI,CAAC,uBAAuB;;;;;YAK9C,IAAI,CAAC,cAAc,EAAE;;;KAG5B,CAAC;IACJ,CAAC;;AA7HM,0BAAM,GAAmB,MAAM,AAAzB,CAA0B;AAIZ;IAA1B,KAAK,CAAC,kBAAkB,CAAC;wDAA8B;AAG3B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAoC;AAGpD;IAAX,QAAQ,EAAE;kDAAY;AAGqB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDAAkB;AAGjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAgB;AAM/C;IAAX,QAAQ,EAAE;qDAAe;AAMd;IAAX,QAAQ,EAAE;kDAAY;AAMX;IAAX,QAAQ,EAAE;qDAAe;AAqC1B;IADC,KAAK,CAAC,UAAU,CAAC;+DAGjB;AAGD;IADC,KAAK,CAAC,QAAQ,CAAC;6DAGf;AA/EU,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA+H/B;;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './nile-command-menu-item.css';\nimport { getTextContent } from '../internal/slot';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\n\n/**\n * An individual selectable command inside a `nile-command-menu`.\n *\n * @tag nile-command-menu-item\n *\n * @summary Represents a single command/action entry within a command menu.\n * @status stable\n * @since 2.0\n *\n * @slot - The item's label.\n * @slot icon - Used to prepend an icon (or similar element) before the label.\n * @slot suffix - Used to append content (e.g. a hint) after the label, before the shortcut.\n *\n * @csspart base - The component's base wrapper.\n * @csspart icon - The leading icon container.\n * @csspart label - The item label.\n * @csspart suffix - The trailing suffix container.\n * @csspart shortcut - The keyboard-shortcut container.\n */\n@customElement('nile-command-menu-item')\nexport class NileCommandMenuItem extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private cachedTextLabel: string;\n\n @query('slot:not([name])') defaultSlot: HTMLSlotElement;\n\n /** Controls vertical padding of the item. */\n @property({ reflect: true }) size: 'small' | 'medium' = 'small';\n\n /** A unique value used to identify the item when it is selected. */\n @property() value = '';\n\n /** Draws the item in a disabled state, preventing selection. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Draws the item in an active/highlighted state. Managed by the parent menu for keyboard navigation. */\n @property({ type: Boolean, reflect: true }) active = false;\n\n /**\n * Extra keywords used by the parent menu when filtering, in addition to the visible label.\n * Useful for matching synonyms or abbreviations.\n */\n @property() keywords = '';\n\n /**\n * The search scope this item belongs to. When the menu has active scopes (the \"Searching for\" row),\n * an item is shown only if it has no scope or its scope is among the active ones.\n */\n @property() scope = '';\n\n /**\n * A keyboard shortcut hint shown on the trailing edge of the item. Separate keys with a\n * space to render each one in its own key box (e.g. `\"⌘ K\"`).\n */\n @property() shortcut = '';\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'option');\n this.handleHostClick = this.handleHostClick.bind(this);\n this.addEventListener('click', this.handleHostClick);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('click', this.handleHostClick);\n }\n\n private handleHostClick(event: MouseEvent) {\n // Swallow clicks while disabled so the menu never selects a disabled item.\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleDefaultSlotChange() {\n const textLabel = this.getTextLabel();\n\n if (typeof this.cachedTextLabel === 'undefined') {\n this.cachedTextLabel = textLabel;\n return;\n }\n\n if (textLabel !== this.cachedTextLabel) {\n this.cachedTextLabel = textLabel;\n this.emit('slotchange');\n }\n }\n\n @watch('disabled')\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('active')\n handleActiveChange() {\n this.setAttribute('aria-selected', this.active ? 'true' : 'false');\n }\n\n /** Returns the plain-text label based on the default slot's content. */\n getTextLabel() {\n return getTextContent(this.defaultSlot);\n }\n\n /** Returns the string the parent menu uses to match this item against a search query. */\n getFilterText() {\n return `${this.getTextLabel()} ${this.keywords} ${this.value}`.toLowerCase();\n }\n\n private renderShortcut() {\n if (!this.shortcut) {\n return nothing;\n }\n\n const keys = this.shortcut.trim().split(/\\s+/);\n return html`\n <span part=\"shortcut\" class=\"item__shortcut\">\n ${keys.map(key => html`<kbd>${key}</kbd>`)}\n </span>\n `;\n }\n\n render() {\n return html`\n <div\n part=\"base\"\n class=${classMap({\n item: true,\n 'item--active': this.active,\n 'item--disabled': this.disabled,\n })}\n >\n <slot name=\"icon\" part=\"icon\" class=\"item__icon\"></slot>\n\n <span part=\"label\" class=\"item__label\">\n <slot @slotchange=${this.handleDefaultSlotChange}></slot>\n </span>\n\n <span part=\"suffix\" class=\"item__suffix\">\n <slot name=\"suffix\"></slot>\n ${this.renderShortcut()}\n </span>\n </div>\n `;\n }\n}\n\nexport default NileCommandMenuItem;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-command-menu-item': NileCommandMenuItem;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './nile-command-menu-item';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import './nile-command-menu-item';
|
|
3
|
+
describe('NileCommandMenuItem', () => {
|
|
4
|
+
it('1. renders', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el).to.exist; });
|
|
5
|
+
it('2. shadow root', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot).to.not.be.null; });
|
|
6
|
+
it('3. tag name', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.tagName.toLowerCase()).to.equal('nile-command-menu-item'); });
|
|
7
|
+
it('4. size defaults small', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.size).to.equal('small'); });
|
|
8
|
+
it('5. value defaults empty', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.value).to.equal(''); });
|
|
9
|
+
it('6. disabled defaults false', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.disabled).to.be.false; });
|
|
10
|
+
it('7. active defaults false', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.active).to.be.false; });
|
|
11
|
+
it('8. keywords defaults empty', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.keywords).to.equal(''); });
|
|
12
|
+
it('9. shortcut defaults empty', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shortcut).to.equal(''); });
|
|
13
|
+
it('10. set size medium', async () => { const el = await fixture(html `<nile-command-menu-item size="medium"></nile-command-menu-item>`); expect(el.size).to.equal('medium'); });
|
|
14
|
+
it('11. set value', async () => { const el = await fixture(html `<nile-command-menu-item value="open"></nile-command-menu-item>`); expect(el.value).to.equal('open'); });
|
|
15
|
+
it('12. set disabled', async () => { const el = await fixture(html `<nile-command-menu-item disabled></nile-command-menu-item>`); expect(el.disabled).to.be.true; });
|
|
16
|
+
it('13. role option', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.getAttribute('role')).to.equal('option'); });
|
|
17
|
+
it('14. base part', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('[part="base"]')).to.exist; });
|
|
18
|
+
it('15. label part', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('[part="label"]')).to.exist; });
|
|
19
|
+
it('16. icon slot', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('slot[name="icon"]')).to.exist; });
|
|
20
|
+
it('17. suffix slot', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('slot[name="suffix"]')).to.exist; });
|
|
21
|
+
it('18. default slot', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('slot:not([name])')).to.exist; });
|
|
22
|
+
it('19. aria-disabled reflects', async () => { const el = await fixture(html `<nile-command-menu-item disabled></nile-command-menu-item>`); await el.updateComplete; expect(el.getAttribute('aria-disabled')).to.equal('true'); });
|
|
23
|
+
it('20. aria-selected reflects', async () => { const el = await fixture(html `<nile-command-menu-item active></nile-command-menu-item>`); await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); });
|
|
24
|
+
it('21. shortcut renders kbd', async () => { const el = await fixture(html `<nile-command-menu-item shortcut="⌘ K"></nile-command-menu-item>`); await el.updateComplete; expect(el.shadowRoot.querySelectorAll('kbd').length).to.equal(2); });
|
|
25
|
+
it('22. no shortcut no kbd', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot.querySelector('kbd')).to.be.null; });
|
|
26
|
+
it('23. getTextLabel', async () => { const el = await fixture(html `<nile-command-menu-item>Open file</nile-command-menu-item>`); expect(el.getTextLabel().trim()).to.equal('Open file'); });
|
|
27
|
+
it('24. getFilterText includes label', async () => { const el = await fixture(html `<nile-command-menu-item>Open file</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('open file'); });
|
|
28
|
+
it('25. getFilterText includes keywords', async () => { const el = await fixture(html `<nile-command-menu-item keywords="document">File</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('document'); });
|
|
29
|
+
it('26. getFilterText includes value', async () => { const el = await fixture(html `<nile-command-menu-item value="cmd-open">File</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('cmd-open'); });
|
|
30
|
+
it('27. disabled click swallowed', async () => { const el = await fixture(html `<nile-command-menu-item disabled>X</nile-command-menu-item>`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.false; });
|
|
31
|
+
it('28. enabled click bubbles', async () => { const el = await fixture(html `<nile-command-menu-item>X</nile-command-menu-item>`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.true; });
|
|
32
|
+
it('29. dynamic active', async () => { const el = await fixture(html `<nile-command-menu-item></nile-command-menu-item>`); el.active = true; await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); });
|
|
33
|
+
it('30. is defined', async () => { expect(customElements.get('nile-command-menu-item')).to.exist; });
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=nile-command-menu-item.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-command-menu-item.test.js","sourceRoot":"","sources":["../../../src/nile-command-menu-item/nile-command-menu-item.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,0BAA0B,CAAC;AAGlC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAsB,IAAI,CAAA,mDAAmD,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/J,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAsB,IAAI,CAAA,mDAAmD,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,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AC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvG,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\nimport './nile-command-menu-item';\nimport type { NileCommandMenuItem } from './nile-command-menu-item';\n\ndescribe('NileCommandMenuItem', () => {\n it('1. renders', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el).to.exist; });\n it('2. shadow root', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot).to.not.be.null; });\n it('3. tag name', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.tagName.toLowerCase()).to.equal('nile-command-menu-item'); });\n it('4. size defaults small', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.size).to.equal('small'); });\n it('5. value defaults empty', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.value).to.equal(''); });\n it('6. disabled defaults false', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.disabled).to.be.false; });\n it('7. active defaults false', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.active).to.be.false; });\n it('8. keywords defaults empty', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.keywords).to.equal(''); });\n it('9. shortcut defaults empty', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shortcut).to.equal(''); });\n it('10. set size medium', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item size=\"medium\"></nile-command-menu-item>`); expect(el.size).to.equal('medium'); });\n it('11. set value', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item value=\"open\"></nile-command-menu-item>`); expect(el.value).to.equal('open'); });\n it('12. set disabled', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item disabled></nile-command-menu-item>`); expect(el.disabled).to.be.true; });\n it('13. role option', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.getAttribute('role')).to.equal('option'); });\n it('14. base part', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('[part=\"base\"]')).to.exist; });\n it('15. label part', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('[part=\"label\"]')).to.exist; });\n it('16. icon slot', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('slot[name=\"icon\"]')).to.exist; });\n it('17. suffix slot', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('slot[name=\"suffix\"]')).to.exist; });\n it('18. default slot', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('slot:not([name])')).to.exist; });\n it('19. aria-disabled reflects', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item disabled></nile-command-menu-item>`); await el.updateComplete; expect(el.getAttribute('aria-disabled')).to.equal('true'); });\n it('20. aria-selected reflects', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item active></nile-command-menu-item>`); await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); });\n it('21. shortcut renders kbd', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item shortcut=\"⌘ K\"></nile-command-menu-item>`); await el.updateComplete; expect(el.shadowRoot!.querySelectorAll('kbd').length).to.equal(2); });\n it('22. no shortcut no kbd', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); expect(el.shadowRoot!.querySelector('kbd')).to.be.null; });\n it('23. getTextLabel', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item>Open file</nile-command-menu-item>`); expect(el.getTextLabel().trim()).to.equal('Open file'); });\n it('24. getFilterText includes label', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item>Open file</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('open file'); });\n it('25. getFilterText includes keywords', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item keywords=\"document\">File</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('document'); });\n it('26. getFilterText includes value', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item value=\"cmd-open\">File</nile-command-menu-item>`); expect(el.getFilterText()).to.contain('cmd-open'); });\n it('27. disabled click swallowed', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item disabled>X</nile-command-menu-item>`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.false; });\n it('28. enabled click bubbles', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item>X</nile-command-menu-item>`); let fired = false; el.addEventListener('click', () => (fired = true)); el.click(); expect(fired).to.be.true; });\n it('29. dynamic active', async () => { const el = await fixture<NileCommandMenuItem>(html`<nile-command-menu-item></nile-command-menu-item>`); el.active = true; await el.updateComplete; expect(el.getAttribute('aria-selected')).to.equal('true'); });\n it('30. is defined', async () => { expect(customElements.get('nile-command-menu-item')).to.exist; });\n});\n"]}
|