@api-client/ui 0.5.38 → 0.5.40
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/build/src/md/list/internals/ListItem.d.ts +24 -15
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +85 -59
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +11 -11
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/select/internals/Option.d.ts +4 -14
- package/build/src/md/select/internals/Option.d.ts.map +1 -1
- package/build/src/md/select/internals/Option.js +13 -28
- package/build/src/md/select/internals/Option.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +1 -1
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +15 -5
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/md/list/internals/ListItem.styles.ts +11 -11
- package/src/md/list/internals/ListItem.ts +68 -43
- package/src/md/select/internals/Option.ts +14 -26
- package/src/md/select/internals/Select.ts +15 -5
- package/.aiexclude +0 -3
- package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
- package/.cursor/rules/lit-best-practices.mdc +0 -89
- package/.editorconfig +0 -29
- package/.github/CONTRIBUTING.md +0 -24
- package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
- package/.github/instructions/lit-best-practices.instructions.md +0 -90
- package/.github/release.yml +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/auto-release.yml +0 -182
- package/.github/workflows/release.yml +0 -82
- package/.prettierrc.js +0 -14
- package/.vscode/settings.json +0 -18
- package/RELEASE.md +0 -163
- package/RELEASE_SETUP.md +0 -235
- package/build/src/demo/DemoPage.d.ts +0 -81
- package/build/src/demo/DemoPage.d.ts.map +0 -1
- package/build/src/demo/DemoPage.js +0 -175
- package/build/src/demo/DemoPage.js.map +0 -1
- package/build/src/demo/DemoStyles.d.ts +0 -3
- package/build/src/demo/DemoStyles.d.ts.map +0 -1
- package/build/src/demo/DemoStyles.js +0 -60
- package/build/src/demo/DemoStyles.js.map +0 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
- package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
- package/build/test/elements/navigation/Navigation.test.js +0 -113
- package/build/test/elements/navigation/Navigation.test.js.map +0 -1
- package/commitlint.config.cjs +0 -2
- package/demo/elements/authorization/AuthPlugin.js +0 -57
- package/demo/elements/authorization/AuthProxy.js +0 -215
- package/demo/elements/authorization/api-key.html +0 -27
- package/demo/elements/authorization/api-key.ts +0 -44
- package/demo/elements/authorization/basic.html +0 -27
- package/demo/elements/authorization/basic.ts +0 -43
- package/demo/elements/authorization/bearer.html +0 -27
- package/demo/elements/authorization/bearer.ts +0 -43
- package/demo/elements/authorization/env.js +0 -8
- package/demo/elements/authorization/index.html +0 -44
- package/demo/elements/authorization/ntlm.html +0 -27
- package/demo/elements/authorization/ntlm.ts +0 -43
- package/demo/elements/authorization/oauth-authorize.html +0 -75
- package/demo/elements/authorization/oauth-authorize.ts +0 -40
- package/demo/elements/authorization/oauth-error.html +0 -18
- package/demo/elements/authorization/oauth-error.ts +0 -10
- package/demo/elements/authorization/oauth-popup.html +0 -36
- package/demo/elements/authorization/oauth2.html +0 -27
- package/demo/elements/authorization/oauth2.ts +0 -100
- package/demo/elements/authorization/oidc.html +0 -27
- package/demo/elements/authorization/oidc.ts +0 -139
- package/demo/elements/authorization/private.crt +0 -31
- package/demo/elements/authorization/private.csr +0 -28
- package/demo/elements/authorization/private.key +0 -51
- package/demo/elements/authorization/private.pem +0 -31
- package/demo/elements/authorization/redirect.html +0 -20
- package/demo/elements/authorization/ssl-commands.sh +0 -30
- package/demo/elements/authorization/ssl.conf +0 -24
- package/demo/elements/autocomplete/index.html +0 -64
- package/demo/elements/autocomplete/index.ts +0 -171
- package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
- package/demo/elements/code-editor/index.html +0 -19
- package/demo/elements/context-menu/DemoIcons.ts +0 -21
- package/demo/elements/context-menu/basic.html +0 -25
- package/demo/elements/context-menu/basic.ts +0 -119
- package/demo/elements/context-menu/custom-data.html +0 -25
- package/demo/elements/context-menu/custom-data.ts +0 -62
- package/demo/elements/context-menu/demo.css +0 -28
- package/demo/elements/context-menu/enabled-state.html +0 -25
- package/demo/elements/context-menu/enabled-state.ts +0 -73
- package/demo/elements/context-menu/icons.html +0 -25
- package/demo/elements/context-menu/icons.ts +0 -64
- package/demo/elements/context-menu/index.html +0 -43
- package/demo/elements/context-menu/nested.html +0 -25
- package/demo/elements/context-menu/nestedt.ts +0 -152
- package/demo/elements/context-menu/no-execute.html +0 -25
- package/demo/elements/context-menu/no-execute.ts +0 -134
- package/demo/elements/context-menu/radio-menu.html +0 -25
- package/demo/elements/context-menu/radio-menu.ts +0 -83
- package/demo/elements/context-menu/separators.html +0 -25
- package/demo/elements/context-menu/separators.ts +0 -172
- package/demo/elements/currency/index.html +0 -91
- package/demo/elements/currency/index.ts +0 -352
- package/demo/elements/environment/environment-editor.html +0 -20
- package/demo/elements/environment/environment-editor.ts +0 -49
- package/demo/elements/environment/index.html +0 -33
- package/demo/elements/environment/server-editor.html +0 -20
- package/demo/elements/environment/server-editor.ts +0 -67
- package/demo/elements/environment/variables-editor.html +0 -20
- package/demo/elements/environment/variables-editor.ts +0 -94
- package/demo/elements/har/har-viewer.html +0 -20
- package/demo/elements/har/har-viewer.ts +0 -76
- package/demo/elements/har/har1.har +0 -3044
- package/demo/elements/har/har2.json +0 -439
- package/demo/elements/har/index.html +0 -26
- package/demo/elements/highlight/example.md +0 -27
- package/demo/elements/highlight/index.html +0 -31
- package/demo/elements/highlight/marked-highlight.html +0 -132
- package/demo/elements/highlight/marked-highlight.ts +0 -22
- package/demo/elements/highlight/prism-highlight.html +0 -62
- package/demo/elements/highlight/prism-highlight.ts +0 -17
- package/demo/elements/http/body-editor.html +0 -17
- package/demo/elements/http/body-editor.ts +0 -115
- package/demo/elements/http/headers.html +0 -17
- package/demo/elements/http/headers.ts +0 -59
- package/demo/elements/http/http-assertions.html +0 -20
- package/demo/elements/http/http-assertions.ts +0 -89
- package/demo/elements/http/http-flows.html +0 -23
- package/demo/elements/http/http-flows.ts +0 -89
- package/demo/elements/http/index.html +0 -45
- package/demo/elements/http/request-editor.html +0 -26
- package/demo/elements/http/request-editor.ts +0 -197
- package/demo/elements/http/request-log.html +0 -16
- package/demo/elements/http/request-log.ts +0 -136
- package/demo/elements/http/url-editing.html +0 -17
- package/demo/elements/http/url-editing.ts +0 -112
- package/demo/elements/icons/index.html +0 -81
- package/demo/elements/icons/index.ts +0 -52
- package/demo/elements/index.html +0 -72
- package/demo/elements/mention-textarea/index.html +0 -19
- package/demo/elements/mention-textarea/index.ts +0 -205
- package/demo/elements/navigation/navigation-item.html +0 -49
- package/demo/elements/navigation/navigation-item.ts +0 -131
- package/demo/elements/navigation/navigation.html +0 -20
- package/demo/elements/navigation/navigation.ts +0 -45
- package/demo/elements/project/index.html +0 -29
- package/demo/elements/project/project-run-report.html +0 -20
- package/demo/elements/project/project-run-report.ts +0 -132
- package/demo/elements/project/request-editor.html +0 -23
- package/demo/elements/project/request-editor.ts +0 -232
- package/demo/elements/user/user-avatar.html +0 -17
- package/demo/elements/user/user-avatar.ts +0 -60
- package/demo/env.js +0 -4
- package/demo/index.html +0 -34
- package/demo/layout/index.html +0 -94
- package/demo/layout/index.ts +0 -190
- package/demo/md/DemoStyles.ts +0 -61
- package/demo/md/UiDemoPage.ts +0 -6
- package/demo/md/buttons/button.html +0 -121
- package/demo/md/buttons/button.ts +0 -246
- package/demo/md/buttons/group.html +0 -36
- package/demo/md/buttons/group.ts +0 -171
- package/demo/md/checkbox/index.html +0 -39
- package/demo/md/checkbox/index.ts +0 -220
- package/demo/md/chip/chip.html +0 -70
- package/demo/md/chip/chip.ts +0 -219
- package/demo/md/chip/pawel6c9a.jpg +0 -0
- package/demo/md/collapse/CustomDetail.ts +0 -89
- package/demo/md/collapse/collapse.html +0 -21
- package/demo/md/collapse/collapse.ts +0 -78
- package/demo/md/date-picker/date-picker.ts +0 -336
- package/demo/md/date-picker/index.html +0 -171
- package/demo/md/dialog/confirm-dialog.html +0 -49
- package/demo/md/dialog/confirm-dialog.ts +0 -121
- package/demo/md/dialog/dialog.html +0 -25
- package/demo/md/dialog/dialog.ts +0 -468
- package/demo/md/dropdown-list/index.html +0 -31
- package/demo/md/dropdown-list/index.ts +0 -158
- package/demo/md/icon-button/index.html +0 -122
- package/demo/md/icon-button/index.ts +0 -132
- package/demo/md/index.html +0 -73
- package/demo/md/inputs/input.html +0 -73
- package/demo/md/inputs/input.ts +0 -278
- package/demo/md/inputs/radio.html +0 -39
- package/demo/md/inputs/radio.ts +0 -156
- package/demo/md/inputs/switch.html +0 -45
- package/demo/md/inputs/switch.ts +0 -144
- package/demo/md/list/list.html +0 -65
- package/demo/md/list/list.ts +0 -204
- package/demo/md/listbox/listbox.html +0 -31
- package/demo/md/listbox/listbox.ts +0 -27
- package/demo/md/menu/index.html +0 -19
- package/demo/md/menu/index.ts +0 -514
- package/demo/md/notification/snack.html +0 -21
- package/demo/md/notification/snack.ts +0 -70
- package/demo/md/progress/progress.html +0 -46
- package/demo/md/progress/progress.ts +0 -161
- package/demo/md/segmented-button/index.html +0 -21
- package/demo/md/segmented-button/index.ts +0 -55
- package/demo/md/select/index.html +0 -16
- package/demo/md/select/index.ts +0 -207
- package/demo/md/tabs/tabs.html +0 -40
- package/demo/md/tabs/tabs.ts +0 -214
- package/demo/oauth-popup.html +0 -36
- package/demo/page.css +0 -8
- package/demo/resources/calendar-month.png +0 -0
- package/demo/resources/favorite.png +0 -0
- package/demo/resources/fingerprint.png +0 -0
- package/demo/resources/home-work.png +0 -0
- package/demo/resources/mood.png +0 -0
- package/demo/resources/print.png +0 -0
- package/demo/resources/stars.png +0 -0
- package/demo/resources/theaters.png +0 -0
- package/demo/tsconfig.json +0 -4
- package/eslint.config.js +0 -97
- package/scripts/copy-assets.js +0 -21
- package/scripts/release.js +0 -66
- package/src/demo/DemoPage.ts +0 -169
- package/src/demo/DemoStyles.ts +0 -60
- package/test/README.md +0 -375
- package/test/contextual-menu/ContextMenu.test.ts +0 -760
- package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
- package/test/core/activity.spec.ts +0 -413
- package/test/core/activity_manager.spec.ts +0 -544
- package/test/core/application.spec.ts +0 -218
- package/test/core/fragment.spec.ts +0 -565
- package/test/core/fragment_manager.spec.ts +0 -404
- package/test/core/live_data.spec.ts +0 -558
- package/test/core/renderer.spec.ts +0 -113
- package/test/dom-assertions.test.ts +0 -182
- package/test/elements/MonacoSetup.ts +0 -65
- package/test/elements/authorization/basic-method.test.ts +0 -177
- package/test/elements/authorization/bearer-method.test.ts +0 -143
- package/test/elements/authorization/ntlm-method.test.ts +0 -219
- package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
- package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
- package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
- package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
- package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
- package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
- package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
- package/test/elements/authorization/openid-method.test.ts +0 -591
- package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
- package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
- package/test/elements/code-editor/code-editor.test.ts +0 -574
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
- package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
- package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
- package/test/elements/currency/CurrencyPicker.test.ts +0 -486
- package/test/elements/data-table/DataTable.browser.test.ts +0 -649
- package/test/elements/har/HarUtils.test.ts +0 -45
- package/test/elements/har/HarViewerElement.test.ts +0 -687
- package/test/elements/har/test-data/har1.har +0 -3044
- package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
- package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
- package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
- package/test/elements/highlight/remoteSanitization.md +0 -1
- package/test/elements/highlight/test.md +0 -3
- package/test/elements/highlight/test1.md +0 -3
- package/test/elements/highlight/test2.md +0 -1
- package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
- package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
- package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
- package/test/elements/http/CertificateAdd.test.ts +0 -457
- package/test/elements/http/HttpAssertions.test.ts +0 -994
- package/test/elements/http/HttpFlows.test.ts +0 -502
- package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
- package/test/elements/layout/SplitItem.test.ts +0 -440
- package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
- package/test/elements/layout/SplitPanel.test.ts +0 -1109
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
- package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
- package/test/elements/navigation/Navigation.test.ts +0 -120
- package/test/env.ts +0 -15
- package/test/events/EventTypes.test.ts +0 -363
- package/test/events/EventsTestHelpers.ts +0 -16
- package/test/helpers/TestUtils.ts +0 -243
- package/test/helpers/UiMock.ts +0 -185
- package/test/lib/Dom.test.ts +0 -231
- package/test/md/button/UiButton.test.ts +0 -347
- package/test/md/button/UiIconButton.test.ts +0 -155
- package/test/md/chip/UiChip.test.ts +0 -219
- package/test/md/collapse/UiCollapse.test.ts +0 -250
- package/test/md/collapse/flex-layout.test.ts +0 -105
- package/test/md/date-time/DateTime.test.ts +0 -348
- package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
- package/test/md/dialog/UiDialog.test.ts +0 -759
- package/test/md/menu/Menu.test.ts +0 -855
- package/test/md/menu/MenuIntegration.test.ts +0 -426
- package/test/md/menu/MenuItem.test.ts +0 -652
- package/test/md/menu/SubMenu.test.ts +0 -410
- package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
- package/test/md/progress/UiProgressElement.test.ts +0 -117
- package/test/md/progress/UiRangeElement.test.ts +0 -156
- package/test/md/select/Select.test.ts +0 -925
- package/test/plugins/takeScreenshotPlugin.js +0 -35
- package/test/setup.test.ts +0 -217
- package/test/setup.ts +0 -117
- package/test/tsconfig.json +0 -7
- package/web-dev-server.config.js +0 -21
- package/web-test-runner.config.js +0 -90
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { html, fixture, assert, oneEvent, aTimeout } from '@open-wc/testing';
|
|
2
|
-
import '../../../src/elements/navigation/ui-navigation.js';
|
|
3
|
-
import '../../../src/elements/navigation/ui-navigation-item.js';
|
|
4
|
-
describe('Navigation', () => {
|
|
5
|
-
it('renders with slot content', async () => {
|
|
6
|
-
const el = await fixture(html `
|
|
7
|
-
<ui-navigation aria-label="Main navigation">
|
|
8
|
-
<ui-navigation-item selected aria-current="page">Home</ui-navigation-item>
|
|
9
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
10
|
-
<ui-navigation-item>Files</ui-navigation-item>
|
|
11
|
-
</ui-navigation>
|
|
12
|
-
`);
|
|
13
|
-
const nav = el.shadowRoot.querySelector('nav');
|
|
14
|
-
assert.ok(nav, 'nav element is rendered');
|
|
15
|
-
assert.equal(nav?.getAttribute('aria-label'), 'Main navigation');
|
|
16
|
-
const items = el._items;
|
|
17
|
-
assert.equal(items.length, 3);
|
|
18
|
-
assert.isTrue(items[0].selected);
|
|
19
|
-
assert.equal(items[0].getAttribute('aria-current'), 'page');
|
|
20
|
-
});
|
|
21
|
-
it('sets correct tabindex for items', async () => {
|
|
22
|
-
const el = await fixture(html `
|
|
23
|
-
<ui-navigation>
|
|
24
|
-
<ui-navigation-item selected>Home</ui-navigation-item>
|
|
25
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
26
|
-
</ui-navigation>
|
|
27
|
-
`);
|
|
28
|
-
const items = el._items;
|
|
29
|
-
assert.equal(items[0].getAttribute('tabindex'), '0');
|
|
30
|
-
assert.equal(items[1].getAttribute('tabindex'), '-1');
|
|
31
|
-
});
|
|
32
|
-
it('selects item on click and fires select event', async () => {
|
|
33
|
-
const el = await fixture(html `
|
|
34
|
-
<ui-navigation>
|
|
35
|
-
<ui-navigation-item>Home</ui-navigation-item>
|
|
36
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
37
|
-
</ui-navigation>
|
|
38
|
-
`);
|
|
39
|
-
const items = el._items;
|
|
40
|
-
setTimeout(() => items[1].click());
|
|
41
|
-
const ev = await oneEvent(el, 'select');
|
|
42
|
-
assert.equal(ev.detail.item, items[1]);
|
|
43
|
-
assert.isTrue(items[1].selected);
|
|
44
|
-
assert.equal(items[1].getAttribute('tabindex'), '0');
|
|
45
|
-
assert.isFalse(items[0].selected);
|
|
46
|
-
assert.equal(items[0].getAttribute('tabindex'), '-1');
|
|
47
|
-
});
|
|
48
|
-
it('handles keyboard navigation (vertical)', async () => {
|
|
49
|
-
const el = await fixture(html `
|
|
50
|
-
<ui-navigation>
|
|
51
|
-
<ui-navigation-item>Home</ui-navigation-item>
|
|
52
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
53
|
-
<ui-navigation-item>Files</ui-navigation-item>
|
|
54
|
-
</ui-navigation>
|
|
55
|
-
`);
|
|
56
|
-
const items = el._items;
|
|
57
|
-
items[0].focus();
|
|
58
|
-
// ArrowDown moves to next
|
|
59
|
-
items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
60
|
-
await aTimeout(0);
|
|
61
|
-
assert.dom.equal(document.activeElement, items[1]);
|
|
62
|
-
// ArrowUp wraps to last
|
|
63
|
-
items[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }));
|
|
64
|
-
await aTimeout(0);
|
|
65
|
-
assert.dom.equal(document.activeElement, items[0]);
|
|
66
|
-
});
|
|
67
|
-
it('handles keyboard navigation (horizontal)', async () => {
|
|
68
|
-
const el = await fixture(html `
|
|
69
|
-
<ui-navigation orientation="horizontal">
|
|
70
|
-
<ui-navigation-item>Home</ui-navigation-item>
|
|
71
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
72
|
-
</ui-navigation>
|
|
73
|
-
`);
|
|
74
|
-
const items = el._items;
|
|
75
|
-
items[0].focus();
|
|
76
|
-
items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }));
|
|
77
|
-
await aTimeout(0);
|
|
78
|
-
assert.dom.equal(document.activeElement, items[1]);
|
|
79
|
-
items[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true }));
|
|
80
|
-
await aTimeout(0);
|
|
81
|
-
assert.dom.equal(document.activeElement, items[0]);
|
|
82
|
-
});
|
|
83
|
-
it('skips disabled items in navigation', async () => {
|
|
84
|
-
const el = await fixture(html `
|
|
85
|
-
<ui-navigation>
|
|
86
|
-
<ui-navigation-item>Home</ui-navigation-item>
|
|
87
|
-
<ui-navigation-item disabled>Search</ui-navigation-item>
|
|
88
|
-
<ui-navigation-item>Files</ui-navigation-item>
|
|
89
|
-
</ui-navigation>
|
|
90
|
-
`);
|
|
91
|
-
const items = el._items;
|
|
92
|
-
items[0].focus();
|
|
93
|
-
items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
94
|
-
await aTimeout(0);
|
|
95
|
-
// Should skip disabled and go to Files
|
|
96
|
-
assert.dom.equal(document.activeElement, items[2]);
|
|
97
|
-
});
|
|
98
|
-
it('sets aria-current on selected item if current is set', async () => {
|
|
99
|
-
const el = await fixture(html `
|
|
100
|
-
<ui-navigation current="page">
|
|
101
|
-
<ui-navigation-item>Home</ui-navigation-item>
|
|
102
|
-
<ui-navigation-item>Search</ui-navigation-item>
|
|
103
|
-
</ui-navigation>
|
|
104
|
-
`);
|
|
105
|
-
const items = el._items;
|
|
106
|
-
// Simulate user selection by clicking the item (public API)
|
|
107
|
-
items[1].click();
|
|
108
|
-
await aTimeout(0);
|
|
109
|
-
assert.equal(items[1].getAttribute('aria-current'), 'page');
|
|
110
|
-
assert.isFalse(items[0].hasAttribute('aria-current'));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=Navigation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.test.js","sourceRoot":"","sources":["../../../../test/elements/navigation/Navigation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5E,OAAO,mDAAmD,CAAA;AAC1D,OAAO,wDAAwD,CAAA;AAE/D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAa,IAAI,CAAA;;;;;;KAMxC,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAA;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC,CAAA;QAChE,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAA;QACvB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QAC7B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAChC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7D,CAAC,CAA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F,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAA;QACvB,4DAA4D;QAC5D,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;QAChB,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAA;QACjB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAA;QAC3D,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { html, fixture, assert, oneEvent, aTimeout } from '@open-wc/testing'\nimport type Navigation from '../../../src/elements/navigation/internals/Navigation.js'\nimport '../../../src/elements/navigation/ui-navigation.js'\nimport '../../../src/elements/navigation/ui-navigation-item.js'\n\ndescribe('Navigation', () => {\n it('renders with slot content', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation aria-label=\"Main navigation\">\n <ui-navigation-item selected aria-current=\"page\">Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n <ui-navigation-item>Files</ui-navigation-item>\n </ui-navigation>\n `)\n const nav = el.shadowRoot!.querySelector('nav')\n assert.ok(nav, 'nav element is rendered')\n assert.equal(nav?.getAttribute('aria-label'), 'Main navigation')\n const items = el._items\n assert.equal(items.length, 3)\n assert.isTrue(items[0].selected)\n assert.equal(items[0].getAttribute('aria-current'), 'page')\n })\n\n it('sets correct tabindex for items', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation>\n <ui-navigation-item selected>Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n assert.equal(items[0].getAttribute('tabindex'), '0')\n assert.equal(items[1].getAttribute('tabindex'), '-1')\n })\n\n it('selects item on click and fires select event', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation>\n <ui-navigation-item>Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n setTimeout(() => items[1].click())\n const ev = await oneEvent(el, 'select')\n assert.equal(ev.detail.item, items[1])\n assert.isTrue(items[1].selected)\n assert.equal(items[1].getAttribute('tabindex'), '0')\n assert.isFalse(items[0].selected)\n assert.equal(items[0].getAttribute('tabindex'), '-1')\n })\n\n it('handles keyboard navigation (vertical)', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation>\n <ui-navigation-item>Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n <ui-navigation-item>Files</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n items[0].focus()\n // ArrowDown moves to next\n items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }))\n await aTimeout(0)\n assert.dom.equal(document.activeElement, items[1])\n // ArrowUp wraps to last\n items[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }))\n await aTimeout(0)\n assert.dom.equal(document.activeElement, items[0])\n })\n\n it('handles keyboard navigation (horizontal)', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation orientation=\"horizontal\">\n <ui-navigation-item>Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n items[0].focus()\n items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))\n await aTimeout(0)\n assert.dom.equal(document.activeElement, items[1])\n items[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true }))\n await aTimeout(0)\n assert.dom.equal(document.activeElement, items[0])\n })\n\n it('skips disabled items in navigation', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation>\n <ui-navigation-item>Home</ui-navigation-item>\n <ui-navigation-item disabled>Search</ui-navigation-item>\n <ui-navigation-item>Files</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n items[0].focus()\n items[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }))\n await aTimeout(0)\n // Should skip disabled and go to Files\n assert.dom.equal(document.activeElement, items[2])\n })\n\n it('sets aria-current on selected item if current is set', async () => {\n const el = await fixture<Navigation>(html`\n <ui-navigation current=\"page\">\n <ui-navigation-item>Home</ui-navigation-item>\n <ui-navigation-item>Search</ui-navigation-item>\n </ui-navigation>\n `)\n const items = el._items\n // Simulate user selection by clicking the item (public API)\n items[1].click()\n await aTimeout(0)\n assert.equal(items[1].getAttribute('aria-current'), 'page')\n assert.isFalse(items[0].hasAttribute('aria-current'))\n })\n})\n"]}
|
package/commitlint.config.cjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { OAuth2Server } from 'oauth2-mock-server'
|
|
2
|
-
import proxy from 'koa-proxies'
|
|
3
|
-
// Using the core library here slows down loading time signoficantly
|
|
4
|
-
import getPort, { portNumbers } from 'get-port'
|
|
5
|
-
import { AuthProxy } from './AuthProxy.js'
|
|
6
|
-
|
|
7
|
-
/** @typedef {import('@web/dev-server-core').Plugin} Plugin */
|
|
8
|
-
/** @typedef {import('@web/dev-server-core').ServerStartParams} ServerStartParams */
|
|
9
|
-
|
|
10
|
-
const oauth2server = new OAuth2Server()
|
|
11
|
-
const authProxy = new AuthProxy()
|
|
12
|
-
let oauth2env
|
|
13
|
-
|
|
14
|
-
export default /** @type Plugin */ ({
|
|
15
|
-
name: 'auth',
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {ServerStartParams} args
|
|
19
|
-
*/
|
|
20
|
-
async serverStart(args) {
|
|
21
|
-
const port = await getPort({ port: portNumbers(8000, 8100) })
|
|
22
|
-
const proxyPort = await getPort({ port: portNumbers(8000, 8100) })
|
|
23
|
-
args.app.use(
|
|
24
|
-
proxy('/auth', {
|
|
25
|
-
target: `http://localhost:${port}`,
|
|
26
|
-
// logs: true,
|
|
27
|
-
rewrite: (path) => path.replace('/auth', ''),
|
|
28
|
-
})
|
|
29
|
-
)
|
|
30
|
-
const jwtKey = await oauth2server.issuer.keys.generate('RS256')
|
|
31
|
-
await oauth2server.start(port, 'localhost')
|
|
32
|
-
await authProxy.start(proxyPort)
|
|
33
|
-
|
|
34
|
-
oauth2env = {
|
|
35
|
-
port,
|
|
36
|
-
root: '/auth',
|
|
37
|
-
jwtKey,
|
|
38
|
-
issuer: oauth2server.issuer.url,
|
|
39
|
-
tokenProxy: `http://localhost:${proxyPort}/proxy?u=`,
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
async serverStop() {
|
|
44
|
-
await oauth2server.stop()
|
|
45
|
-
await authProxy.stop()
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
serve(context) {
|
|
49
|
-
if (context.path === '/demo/elements/authorization/env.js') {
|
|
50
|
-
const data = {
|
|
51
|
-
oauth2: oauth2env,
|
|
52
|
-
}
|
|
53
|
-
return `export default ${JSON.stringify(data)}`
|
|
54
|
-
}
|
|
55
|
-
return undefined
|
|
56
|
-
},
|
|
57
|
-
})
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
import http from 'http'
|
|
3
|
-
import https from 'https'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A server that proxies oauth 2 token requests from the client to the
|
|
7
|
-
* final token request endpoint.
|
|
8
|
-
*
|
|
9
|
-
* Append the token endpoint to the `/proxy?u=...` endpoint.
|
|
10
|
-
* The token URL must be URL encoded.
|
|
11
|
-
*
|
|
12
|
-
* Example:
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
* http://localhost:8082/proxy?u=https....
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class AuthProxy {
|
|
19
|
-
constructor() {
|
|
20
|
-
/** @type http.RequestListener */
|
|
21
|
-
this._requestListener = this._requestListener.bind(this)
|
|
22
|
-
/** @type http.IncomingMessage[] */
|
|
23
|
-
this.connections = []
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {number} port Starts the proxy
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
async start(port) {
|
|
31
|
-
const server = http.createServer(this._requestListener)
|
|
32
|
-
return new Promise((resolve) => {
|
|
33
|
-
server.listen(port, () => {
|
|
34
|
-
this.server = server
|
|
35
|
-
resolve()
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @returns {Promise<void>}
|
|
42
|
-
*/
|
|
43
|
-
async stop() {
|
|
44
|
-
if (!this.server) {
|
|
45
|
-
return undefined
|
|
46
|
-
}
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
if (this.connections.length) {
|
|
49
|
-
console.log(`Stopping ${this.connections.length} connections.`)
|
|
50
|
-
}
|
|
51
|
-
this.connections.forEach((client) => {
|
|
52
|
-
if (!client.destroyed) {
|
|
53
|
-
client.destroy()
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
this.connections = []
|
|
57
|
-
console.log('Stopping OAuth 2 proxy...')
|
|
58
|
-
this.server.close(() => {
|
|
59
|
-
resolve()
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {http.IncomingMessage} req
|
|
66
|
-
* @param {http.ServerResponse} res
|
|
67
|
-
*/
|
|
68
|
-
async _requestListener(req, res) {
|
|
69
|
-
const { url = '', method } = req
|
|
70
|
-
if (method !== 'POST') {
|
|
71
|
-
this._sendError(req, res, 'not found (method)', 404)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!url.startsWith('/proxy?u=')) {
|
|
76
|
-
this._sendError(req, res, 'not found (url)', 404)
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const proxied = decodeURIComponent(url.replace('/proxy?u=', ''))
|
|
81
|
-
if (!proxied) {
|
|
82
|
-
this._sendError(req, res, 'no token url')
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!proxied.startsWith('https://') && !proxied.startsWith('http://')) {
|
|
87
|
-
this._sendError(req, res, `token url must use http(s): scheme. "${proxied}" given.`)
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.connections.push(req)
|
|
92
|
-
req.on('end', () => {
|
|
93
|
-
const index = this.connections.indexOf(req)
|
|
94
|
-
if (index >= 0) {
|
|
95
|
-
this.connections.splice(index, 1)
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
try {
|
|
99
|
-
const result = await this._proxy(req, proxied)
|
|
100
|
-
const { buffer, headers, code = 200 } = result
|
|
101
|
-
const corsHeaders = this._getCors(headers)
|
|
102
|
-
const finalHeaders = { ...headers, ...corsHeaders }
|
|
103
|
-
res.writeHead(code, finalHeaders)
|
|
104
|
-
res.end(buffer)
|
|
105
|
-
} catch (e) {
|
|
106
|
-
console.error(e)
|
|
107
|
-
this._sendError(req, res, e.message)
|
|
108
|
-
}
|
|
109
|
-
const index = this.connections.indexOf(req)
|
|
110
|
-
if (index >= 0) {
|
|
111
|
-
this.connections.splice(index, 1)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @param {http.IncomingMessage} req
|
|
117
|
-
* @param {http.ServerResponse} res
|
|
118
|
-
* @param {string} message
|
|
119
|
-
* @param {number} code
|
|
120
|
-
*/
|
|
121
|
-
_sendError(req, res, message, code = 400) {
|
|
122
|
-
const { headers } = req
|
|
123
|
-
const body = JSON.stringify({
|
|
124
|
-
error: 'invalid_request',
|
|
125
|
-
error_description: message,
|
|
126
|
-
})
|
|
127
|
-
const rspHeaders = this._getCors(headers)
|
|
128
|
-
rspHeaders['content-type'] = 'application/json'
|
|
129
|
-
res.writeHead(code, rspHeaders)
|
|
130
|
-
res.end(body)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {http.IncomingHttpHeaders} requestHeaders
|
|
135
|
-
* @returns {http.OutgoingHttpHeaders}
|
|
136
|
-
*/
|
|
137
|
-
_getCors(requestHeaders = {}) {
|
|
138
|
-
const { origin } = requestHeaders
|
|
139
|
-
const result = /** @type http.OutgoingHttpHeaders */ ({
|
|
140
|
-
'access-control-allow-origin': origin || '*',
|
|
141
|
-
'access-control-allow-methods': 'POST',
|
|
142
|
-
'access-control-request-headers': 'Content-Type',
|
|
143
|
-
})
|
|
144
|
-
return result
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @param {http.IncomingMessage} req
|
|
149
|
-
* @param {string} url
|
|
150
|
-
* @returns {Promise<{ buffer: Buffer, header: http.IncomingHttpHeaders }>}
|
|
151
|
-
*/
|
|
152
|
-
async _proxy(req, url) {
|
|
153
|
-
const body = await this._readBody(req)
|
|
154
|
-
return new Promise((resolve, reject) => {
|
|
155
|
-
const lib = url.startsWith('https://') ? https : http
|
|
156
|
-
const client = lib.request(
|
|
157
|
-
url,
|
|
158
|
-
{
|
|
159
|
-
headers: this._proxyHeaders(req),
|
|
160
|
-
method: req.method,
|
|
161
|
-
},
|
|
162
|
-
async (res) => {
|
|
163
|
-
const buffers = []
|
|
164
|
-
for await (const chunk of res) {
|
|
165
|
-
buffers.push(chunk)
|
|
166
|
-
}
|
|
167
|
-
resolve({
|
|
168
|
-
buffer: Buffer.concat(buffers),
|
|
169
|
-
headers: res.headers,
|
|
170
|
-
code: res.code,
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
client.on('error', (e) => {
|
|
175
|
-
console.error(`Error making connection to ${url}`)
|
|
176
|
-
reject(e)
|
|
177
|
-
})
|
|
178
|
-
client.write(body)
|
|
179
|
-
client.end()
|
|
180
|
-
})
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @param {http.IncomingMessage} req
|
|
185
|
-
* @returns {http.IncomingHttpHeaders}
|
|
186
|
-
*/
|
|
187
|
-
_proxyHeaders(req) {
|
|
188
|
-
const headers = { ...(req.headers || {}) }
|
|
189
|
-
delete headers.host
|
|
190
|
-
delete headers.connection
|
|
191
|
-
delete headers.accept
|
|
192
|
-
delete headers.origin
|
|
193
|
-
delete headers.referer
|
|
194
|
-
delete headers['sec-ch-ua']
|
|
195
|
-
delete headers['sec-ch-ua-mobile']
|
|
196
|
-
delete headers['sec-ch-ua-platform']
|
|
197
|
-
delete headers['user-agent']
|
|
198
|
-
delete headers['sec-fetch-site']
|
|
199
|
-
delete headers['sec-fetch-mode']
|
|
200
|
-
delete headers['sec-fetch-dest']
|
|
201
|
-
return headers
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @param {http.IncomingMessage} req
|
|
206
|
-
* @returns {Promise<Buffer>}
|
|
207
|
-
*/
|
|
208
|
-
async _readBody(req) {
|
|
209
|
-
const buffers = []
|
|
210
|
-
for await (const chunk of req) {
|
|
211
|
-
buffers.push(chunk)
|
|
212
|
-
}
|
|
213
|
-
return Buffer.concat(buffers)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
|
|
7
|
-
<title>API Key</title>
|
|
8
|
-
<link
|
|
9
|
-
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
|
10
|
-
rel="stylesheet"
|
|
11
|
-
/>
|
|
12
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
13
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
14
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<style>
|
|
16
|
-
.demo-row {
|
|
17
|
-
margin: 20px 0;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
|
|
22
|
-
<body class="demo">
|
|
23
|
-
<div id="app"></div>
|
|
24
|
-
<script type="module" src="/.tmp/demo/elements/authorization/api-key.js"></script>
|
|
25
|
-
</body>
|
|
26
|
-
|
|
27
|
-
</html>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { type IRequestAuthorization, RequestAuthorization } from '@api-client/core/models/RequestAuthorization.js'
|
|
3
|
-
import { reactive } from '../../../src/decorators/index.js'
|
|
4
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
5
|
-
import { Authorization } from '../../../src/elements/authorization/ui/Authorization.js'
|
|
6
|
-
import '../../../src/define/authorization/apikey-authorization.js'
|
|
7
|
-
|
|
8
|
-
class ComponentDemoPage extends DemoPage {
|
|
9
|
-
override accessor componentName = 'API Key authorization'
|
|
10
|
-
|
|
11
|
-
@reactive() accessor authorization: IRequestAuthorization
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super()
|
|
15
|
-
const auth = RequestAuthorization.fromTypedConfig('api key', {}, false)
|
|
16
|
-
this.authorization = auth.toJSON()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
handleChange(e: Event): void {
|
|
20
|
-
const input = e.target as Authorization
|
|
21
|
-
console.log('Value changed', input.authorization)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
handleDelete(): void {
|
|
25
|
-
console.log('Requested to delete.')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
contentTemplate(): TemplateResult {
|
|
29
|
-
return html`
|
|
30
|
-
<a href="./">Back</a>
|
|
31
|
-
<section class="demo-section">
|
|
32
|
-
<h2 class="title-large">HTTP basic authorization</h2>
|
|
33
|
-
<apikey-authorization
|
|
34
|
-
.authorization="${this.authorization}"
|
|
35
|
-
@change="${this.handleChange}"
|
|
36
|
-
@delete="${this.handleDelete}"
|
|
37
|
-
></apikey-authorization>
|
|
38
|
-
</section>
|
|
39
|
-
`
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const instance = new ComponentDemoPage()
|
|
44
|
-
instance.render()
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
|
|
7
|
-
<title>HTTP basic</title>
|
|
8
|
-
<link
|
|
9
|
-
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
|
10
|
-
rel="stylesheet"
|
|
11
|
-
/>
|
|
12
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
13
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
14
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<style>
|
|
16
|
-
.demo-row {
|
|
17
|
-
margin: 20px 0;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
|
|
22
|
-
<body class="demo">
|
|
23
|
-
<div id="app"></div>
|
|
24
|
-
<script type="module" src="/.tmp/demo/elements/authorization/basic.js"></script>
|
|
25
|
-
</body>
|
|
26
|
-
|
|
27
|
-
</html>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { type IRequestAuthorization, RequestAuthorization } from '@api-client/core/models/RequestAuthorization.js'
|
|
3
|
-
import { reactive } from '../../../src/decorators/index.js'
|
|
4
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
5
|
-
import { Authorization } from '../../../src/elements/authorization/ui/Authorization.js'
|
|
6
|
-
import '../../../src/define/authorization/basic-authorization.js'
|
|
7
|
-
|
|
8
|
-
class ComponentDemoPage extends DemoPage {
|
|
9
|
-
override accessor componentName = 'HTTP basic authorization'
|
|
10
|
-
|
|
11
|
-
@reactive() accessor authorization: IRequestAuthorization
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super()
|
|
15
|
-
const auth = RequestAuthorization.fromTypedConfig('basic', {}, false)
|
|
16
|
-
this.authorization = auth.toJSON()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
handleChange(e: Event): void {
|
|
20
|
-
const input = e.target as Authorization
|
|
21
|
-
console.log('Value changed', input.authorization)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
handleDelete(): void {
|
|
25
|
-
console.log('Requested to delete.')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
contentTemplate(): TemplateResult {
|
|
29
|
-
return html`
|
|
30
|
-
<a href="./">Back</a>
|
|
31
|
-
<section class="demo-section">
|
|
32
|
-
<basic-authorization
|
|
33
|
-
.authorization="${this.authorization}"
|
|
34
|
-
@change="${this.handleChange}"
|
|
35
|
-
@delete="${this.handleDelete}"
|
|
36
|
-
></basic-authorization>
|
|
37
|
-
</section>
|
|
38
|
-
`
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const instance = new ComponentDemoPage()
|
|
43
|
-
instance.render()
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
|
|
7
|
-
<title>HTTP bearer</title>
|
|
8
|
-
<link
|
|
9
|
-
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
|
10
|
-
rel="stylesheet"
|
|
11
|
-
/>
|
|
12
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
13
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
14
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<style>
|
|
16
|
-
.demo-row {
|
|
17
|
-
margin: 20px 0;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
|
|
22
|
-
<body class="demo">
|
|
23
|
-
<div id="app"></div>
|
|
24
|
-
<script type="module" src="/.tmp/demo/elements/authorization/bearer.js"></script>
|
|
25
|
-
</body>
|
|
26
|
-
|
|
27
|
-
</html>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { type IRequestAuthorization, RequestAuthorization } from '@api-client/core/models/RequestAuthorization.js'
|
|
3
|
-
import { reactive } from '../../../src/decorators/index.js'
|
|
4
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
5
|
-
import BearerAuthorization from '../../../src/elements/authorization/ui/BearerAuthorization.js'
|
|
6
|
-
import '../../../src/define/authorization/bearer-authorization.js'
|
|
7
|
-
|
|
8
|
-
class ComponentDemoPage extends DemoPage {
|
|
9
|
-
override accessor componentName = 'HTTP Bearer authorization'
|
|
10
|
-
|
|
11
|
-
@reactive() accessor authorization: IRequestAuthorization
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super()
|
|
15
|
-
const auth = RequestAuthorization.fromTypedConfig('bearer', {}, false)
|
|
16
|
-
this.authorization = auth.toJSON()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
handleChange(e: Event): void {
|
|
20
|
-
const input = e.target as BearerAuthorization
|
|
21
|
-
console.log('Value changed', input.authorization)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
handleDelete(): void {
|
|
25
|
-
console.log('Requested to delete.')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
contentTemplate(): TemplateResult {
|
|
29
|
-
return html`
|
|
30
|
-
<a href="./">Back</a>
|
|
31
|
-
<section class="demo-section">
|
|
32
|
-
<bearer-authorization
|
|
33
|
-
.authorization="${this.authorization}"
|
|
34
|
-
@change="${this.handleChange}"
|
|
35
|
-
@delete="${this.handleDelete}"
|
|
36
|
-
></bearer-authorization>
|
|
37
|
-
</section>
|
|
38
|
-
`
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const instance = new ComponentDemoPage()
|
|
43
|
-
instance.render()
|