@api-client/ui 0.5.39 → 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/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- 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 -217
- 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,171 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { live } from 'lit/directives/live.js'
|
|
3
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
4
|
-
import reactive from '../../../src/decorators/reactive.js'
|
|
5
|
-
import type { IUser } from '@api-client/core/models/store/User.js'
|
|
6
|
-
import { User } from '@api-client/core/mocking/lib/User.js'
|
|
7
|
-
|
|
8
|
-
import '../../../src/elements/autocomplete/autocomplete-input.js'
|
|
9
|
-
import '../../../src/md/text-field/ui-outlined-text-field.js'
|
|
10
|
-
import '../../../src/md/listbox/ui-listbox.js'
|
|
11
|
-
import '../../../src/md/list/ui-list-item.js'
|
|
12
|
-
|
|
13
|
-
class ComponentDemoPage extends DemoPage {
|
|
14
|
-
override accessor componentName = 'Autocomplete input'
|
|
15
|
-
|
|
16
|
-
@reactive() accessor fixedValue = ''
|
|
17
|
-
@reactive() accessor dynamicValue = ''
|
|
18
|
-
@reactive() accessor dynamicCustomValue = ''
|
|
19
|
-
@reactive() accessor users: IUser[] = []
|
|
20
|
-
@reactive() accessor customUsers: IUser[] = []
|
|
21
|
-
|
|
22
|
-
userMock = new User()
|
|
23
|
-
|
|
24
|
-
handleFixedAutocomplete(event: CustomEvent<{ item: HTMLElement }>): void {
|
|
25
|
-
const item = event.detail.item
|
|
26
|
-
this.fixedValue = item.getAttribute('data-value') || item.textContent || ''
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
handleFixedInput(event: InputEvent): void {
|
|
30
|
-
const target = event.target as HTMLInputElement
|
|
31
|
-
this.fixedValue = target.value
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
handleDynamicAutocomplete(event: CustomEvent<{ item: HTMLElement }>): void {
|
|
35
|
-
const item = event.detail.item
|
|
36
|
-
this.dynamicValue = item.dataset.name || ''
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
handleDynamicInput(event: InputEvent): void {
|
|
40
|
-
const target = event.target as HTMLInputElement
|
|
41
|
-
this.dynamicValue = target.value
|
|
42
|
-
this.generateMockUsers(target.value, 'users')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
generateMockUsers(startsWith: string, prop: 'users' | 'customUsers'): void {
|
|
46
|
-
const timeout = this.userMock.types.number({ min: 100, max: 1000 })
|
|
47
|
-
const results = this.userMock.types.number({ min: 0, max: 30 })
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
this[prop] = Array.from({ length: results }, () => {
|
|
50
|
-
const item = this.userMock.user()
|
|
51
|
-
item.name = item.name.startsWith(startsWith) ? item.name : `${startsWith}${item.name}`
|
|
52
|
-
return item
|
|
53
|
-
})
|
|
54
|
-
console.log('Generated users:', this[prop])
|
|
55
|
-
}, timeout)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
handleDynamicCustomInput(event: InputEvent): void {
|
|
59
|
-
const target = event.target as HTMLInputElement
|
|
60
|
-
this.dynamicCustomValue = target.value
|
|
61
|
-
this.generateMockUsers(target.value, 'customUsers')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
handleDynamicCustomAutocomplete(event: CustomEvent<{ item: HTMLElement }>): void {
|
|
65
|
-
const item = event.detail.item
|
|
66
|
-
this.dynamicCustomValue = item.dataset.name || ''
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
override contentTemplate(): TemplateResult {
|
|
70
|
-
return html`
|
|
71
|
-
<a href="../">Back</a>
|
|
72
|
-
|
|
73
|
-
<section class="demo-section">
|
|
74
|
-
<h2 class="title-large">Fixed suggestions</h2>
|
|
75
|
-
|
|
76
|
-
<div class="demo-row">
|
|
77
|
-
<autocomplete-input @autocomplete="${this.handleFixedAutocomplete}">
|
|
78
|
-
<ui-outlined-text-field
|
|
79
|
-
slot="input"
|
|
80
|
-
label="Select a fruit"
|
|
81
|
-
name="fixed"
|
|
82
|
-
.value="${live(this.fixedValue)}"
|
|
83
|
-
@input="${this.handleFixedInput}"
|
|
84
|
-
></ui-outlined-text-field>
|
|
85
|
-
<ui-listbox slot="suggestions">
|
|
86
|
-
<ui-list-item data-value="apple" role="option">Apple</ui-list-item>
|
|
87
|
-
<ui-list-item data-value="banana" role="option">Banana</ui-list-item>
|
|
88
|
-
<ui-list-item data-value="cherry" role="option">Cherry</ui-list-item>
|
|
89
|
-
<ui-list-item data-value="date" role="option">Date</ui-list-item>
|
|
90
|
-
<ui-list-item data-value="elderberry" role="option">Elderberry</ui-list-item>
|
|
91
|
-
<ui-list-item data-value="fig" role="option">Fig</ui-list-item>
|
|
92
|
-
<ui-list-item data-value="grape" role="option">Grape</ui-list-item>
|
|
93
|
-
<ui-list-item data-value="honeydew" role="option">Honeydew</ui-list-item>
|
|
94
|
-
<ui-list-item data-value="kiwi" role="option">Kiwi</ui-list-item>
|
|
95
|
-
<ui-list-item data-value="lemon" role="option">Lemon</ui-list-item>
|
|
96
|
-
<ui-list-item data-value="mango" role="option">Mango</ui-list-item>
|
|
97
|
-
<ui-list-item data-value="nectarine" role="option">Nectarine</ui-list-item>
|
|
98
|
-
<ui-list-item data-value="orange" role="option">Orange</ui-list-item>
|
|
99
|
-
<ui-list-item data-value="papaya" role="option">Papaya</ui-list-item>
|
|
100
|
-
</ui-listbox>
|
|
101
|
-
</autocomplete-input>
|
|
102
|
-
</div>
|
|
103
|
-
</section>
|
|
104
|
-
|
|
105
|
-
<section class="demo-section">
|
|
106
|
-
<h2 class="title-large">Dynamic suggestions</h2>
|
|
107
|
-
|
|
108
|
-
<div class="demo-row">
|
|
109
|
-
<autocomplete-input @autocomplete="${this.handleDynamicAutocomplete}">
|
|
110
|
-
<ui-outlined-text-field
|
|
111
|
-
slot="input"
|
|
112
|
-
label="Choose a user"
|
|
113
|
-
name="dynamic"
|
|
114
|
-
.value="${live(this.dynamicValue)}"
|
|
115
|
-
@input="${this.handleDynamicInput}"
|
|
116
|
-
></ui-outlined-text-field>
|
|
117
|
-
<ui-listbox slot="suggestions"
|
|
118
|
-
>${this.users.map(
|
|
119
|
-
(user) =>
|
|
120
|
-
html`<ui-list-item
|
|
121
|
-
data-name="${user.name}"
|
|
122
|
-
data-email="${user.email[0].email}"
|
|
123
|
-
data-index="name email"
|
|
124
|
-
role="option"
|
|
125
|
-
>${user.name}<span slot="supporting-text">${user.email[0].email}</span></ui-list-item
|
|
126
|
-
>`
|
|
127
|
-
)}</ui-listbox
|
|
128
|
-
>
|
|
129
|
-
</autocomplete-input>
|
|
130
|
-
</div>
|
|
131
|
-
</section>
|
|
132
|
-
|
|
133
|
-
<section class="demo-section">
|
|
134
|
-
<h2 class="title-large">Custom Input</h2>
|
|
135
|
-
|
|
136
|
-
<div class="demo-row">
|
|
137
|
-
<autocomplete-input @autocomplete="${this.handleDynamicCustomAutocomplete}">
|
|
138
|
-
<div class="share-input" slot="anchor">
|
|
139
|
-
<div class="input-container">
|
|
140
|
-
<input
|
|
141
|
-
type="text"
|
|
142
|
-
slot="input"
|
|
143
|
-
autocomplete="off"
|
|
144
|
-
placeholder="Enter name or email"
|
|
145
|
-
name="dynamic-custom"
|
|
146
|
-
class="native-input"
|
|
147
|
-
.value="${live(this.dynamicCustomValue)}"
|
|
148
|
-
@input="${this.handleDynamicCustomInput}"
|
|
149
|
-
/>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
<ui-listbox slot="suggestions"
|
|
153
|
-
>${this.customUsers.map(
|
|
154
|
-
(user) =>
|
|
155
|
-
html`<ui-list-item
|
|
156
|
-
data-name="${user.name}"
|
|
157
|
-
data-email="${user.email[0].email}"
|
|
158
|
-
data-index="name email"
|
|
159
|
-
role="option"
|
|
160
|
-
>${user.name}<span slot="supporting-text">${user.email[0].email}</span></ui-list-item
|
|
161
|
-
>`
|
|
162
|
-
)}</ui-listbox
|
|
163
|
-
>
|
|
164
|
-
</autocomplete-input>
|
|
165
|
-
</div>
|
|
166
|
-
</section>
|
|
167
|
-
`
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const instance = new ComponentDemoPage()
|
|
171
|
-
instance.render()
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit'
|
|
2
|
-
import type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'
|
|
3
|
-
import reactive from '../../../src/decorators/reactive.js'
|
|
4
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
5
|
-
import type {
|
|
6
|
-
Suggestion,
|
|
7
|
-
FunctionInsertEvent,
|
|
8
|
-
SuggestionInsertEvent,
|
|
9
|
-
} from '../../../src/elements/code-editor/code-editor.js'
|
|
10
|
-
import '../../../src/elements/code-editor/code-editor.js'
|
|
11
|
-
import { stringLibrarySchema } from '@pawel-up/jexl/schemas/string.schema.js'
|
|
12
|
-
import { arrayLibrarySchema } from '@pawel-up/jexl/schemas/array.schema.js'
|
|
13
|
-
import { dateLibrarySchema } from '@pawel-up/jexl/schemas/date.schema.js'
|
|
14
|
-
import { mathLibrarySchema } from '@pawel-up/jexl/schemas/math.schema.js'
|
|
15
|
-
|
|
16
|
-
class CodeEditorDemo extends DemoPage {
|
|
17
|
-
override accessor componentName = 'Code Editor'
|
|
18
|
-
|
|
19
|
-
@reactive()
|
|
20
|
-
private accessor output = ''
|
|
21
|
-
|
|
22
|
-
@reactive()
|
|
23
|
-
private accessor editorValue = [
|
|
24
|
-
'// Start typing function names or {{ mentions }}',
|
|
25
|
-
'',
|
|
26
|
-
'"Hello {{John}}! Can you help with the " + upper() + " function?"',
|
|
27
|
-
].join('\n')
|
|
28
|
-
|
|
29
|
-
private suggestions: Suggestion[] = [
|
|
30
|
-
{
|
|
31
|
-
id: 'user-john',
|
|
32
|
-
label: 'John',
|
|
33
|
-
description: 'Software Engineer',
|
|
34
|
-
suffix: 'Engineering',
|
|
35
|
-
data: { role: 'developer', department: 'engineering' },
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'user-jane',
|
|
39
|
-
label: 'Jane',
|
|
40
|
-
description: 'Product Manager',
|
|
41
|
-
suffix: 'Product',
|
|
42
|
-
data: { role: 'manager', department: 'product' },
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'admin-system',
|
|
46
|
-
label: 'System',
|
|
47
|
-
description: 'System Administrator',
|
|
48
|
-
suffix: 'Admin',
|
|
49
|
-
data: { role: 'admin', department: 'infrastructure' },
|
|
50
|
-
},
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
functions: FunctionSchema[] = []
|
|
54
|
-
|
|
55
|
-
constructor() {
|
|
56
|
-
super()
|
|
57
|
-
|
|
58
|
-
// Initialize function schemas
|
|
59
|
-
this.functions = this.createFunctionSchema()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Creates a schema for the code-editor functions.
|
|
64
|
-
* This method is responsible for defining the functions that can be used in the formula,
|
|
65
|
-
* given the current data type.
|
|
66
|
-
*/
|
|
67
|
-
createFunctionSchema(): FunctionSchema[] {
|
|
68
|
-
const result: FunctionSchema[] = []
|
|
69
|
-
|
|
70
|
-
for (const func of Object.values(stringLibrarySchema.functions)) {
|
|
71
|
-
result.push(func)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
for (const func of Object.values(arrayLibrarySchema.functions)) {
|
|
75
|
-
result.push(func)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
for (const func of Object.values(dateLibrarySchema.functions)) {
|
|
79
|
-
result.push(func)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for (const func of Object.values(mathLibrarySchema.functions)) {
|
|
83
|
-
result.push(func)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return result
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private handleFunctionInsert(event: CustomEvent<FunctionInsertEvent>): void {
|
|
90
|
-
const { functionSchema, position } = event.detail
|
|
91
|
-
this.output = `Function inserted: ${functionSchema.name} at position ${position}`
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private handleSuggestionInsert(event: CustomEvent<SuggestionInsertEvent>): void {
|
|
95
|
-
const { suggestion, position } = event.detail
|
|
96
|
-
this.output = `Suggestion inserted: ${suggestion.label} at position ${position}`
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private handleInput(event: Event): void {
|
|
100
|
-
const target = event.target as HTMLElement & { value: string }
|
|
101
|
-
this.editorValue = target.value
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private handleFunctionDocumentation(event: CustomEvent<{ functionSchema: FunctionSchema }>): void {
|
|
105
|
-
const { functionSchema } = event.detail
|
|
106
|
-
this.output = `Function documentation requested for: ${functionSchema.name}`
|
|
107
|
-
console.log('Function documentation:', functionSchema)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private handleChange(event: Event): void {
|
|
111
|
-
const target = event.target as HTMLElement & { value: string }
|
|
112
|
-
this.output = `Editor content changed: ${target.value}`
|
|
113
|
-
console.log('Editor change:', target.value)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
contentTemplate() {
|
|
117
|
-
return html`
|
|
118
|
-
<a href="../">Back</a>
|
|
119
|
-
|
|
120
|
-
<section class="demo-section">
|
|
121
|
-
<h2 class="display-large">Basic Code Editor</h2>
|
|
122
|
-
<p>A CodeMirror 6 based editor with function autocomplete and suggestion pills.</p>
|
|
123
|
-
|
|
124
|
-
<code-editor
|
|
125
|
-
label="Code Editor"
|
|
126
|
-
supportingtext="Type function names or {{fnName}} to see autocomplete"
|
|
127
|
-
.value=${this.editorValue}
|
|
128
|
-
.functionSchemas=${this.functions}
|
|
129
|
-
.suggestions=${this.suggestions}
|
|
130
|
-
@functioninsert=${this.handleFunctionInsert}
|
|
131
|
-
@suggestioninsert=${this.handleSuggestionInsert}
|
|
132
|
-
@input=${this.handleInput}
|
|
133
|
-
@change=${this.handleChange}
|
|
134
|
-
showdocumentation
|
|
135
|
-
@docsrequest="${this.handleFunctionDocumentation}"
|
|
136
|
-
></code-editor>
|
|
137
|
-
|
|
138
|
-
${this.output ? html`<p><strong>Output:</strong> ${this.output}</p>` : ''}
|
|
139
|
-
</section>
|
|
140
|
-
|
|
141
|
-
<section class="demo-section">
|
|
142
|
-
<h2 class="display-large">Disabled State</h2>
|
|
143
|
-
<p>A disabled editor for read-only content.</p>
|
|
144
|
-
|
|
145
|
-
<code-editor
|
|
146
|
-
label="Disabled Editor"
|
|
147
|
-
supportingtext="This editor is disabled"
|
|
148
|
-
.value=${'// This editor is disabled\nconst readOnly = true'}
|
|
149
|
-
.functionSchemas=${this.functions}
|
|
150
|
-
.suggestions=${this.suggestions}
|
|
151
|
-
disabled
|
|
152
|
-
></code-editor>
|
|
153
|
-
</section>
|
|
154
|
-
|
|
155
|
-
<section class="demo-section">
|
|
156
|
-
<h2 class="display-large">Error State</h2>
|
|
157
|
-
<p>An editor in error state.</p>
|
|
158
|
-
|
|
159
|
-
<code-editor
|
|
160
|
-
label="Error Editor"
|
|
161
|
-
supportingtext="This editor has an error"
|
|
162
|
-
.value=${'// This editor has an error\nconst invalid = true'}
|
|
163
|
-
.functionSchemas=${this.functions}
|
|
164
|
-
.suggestions=${this.suggestions}
|
|
165
|
-
invalid
|
|
166
|
-
></code-editor>
|
|
167
|
-
</section>
|
|
168
|
-
`
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const instance = new CodeEditorDemo()
|
|
173
|
-
instance.render()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Code Editor Demo</title>
|
|
7
|
-
<link
|
|
8
|
-
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"
|
|
9
|
-
rel="stylesheet"
|
|
10
|
-
/>
|
|
11
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
12
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
13
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
14
|
-
</head>
|
|
15
|
-
<body data-gr-ext-disabled="next">
|
|
16
|
-
<div id="app"></div>
|
|
17
|
-
<script type="module" src="/.tmp/demo/elements/code-editor/CodeEditorDemo.js"></script>
|
|
18
|
-
</body>
|
|
19
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { svg } from 'lit'
|
|
2
|
-
import { iconWrapper } from '../../../src/md/icons/Icons.js'
|
|
3
|
-
|
|
4
|
-
// fonts by Material Design: https://fonts.google.com/icons?selected=Material+Icons
|
|
5
|
-
|
|
6
|
-
export const copy = iconWrapper(
|
|
7
|
-
svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>`
|
|
8
|
-
)
|
|
9
|
-
export const paste = iconWrapper(
|
|
10
|
-
svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"/>`
|
|
11
|
-
)
|
|
12
|
-
export const flag = iconWrapper(
|
|
13
|
-
svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M12.36 6l.4 2H18v6h-3.36l-.4-2H7V6h5.36M14 4H5v17h2v-7h5.6l.4 2h7V6h-5.6L14 4z"/>`
|
|
14
|
-
)
|
|
15
|
-
export const formatSize = iconWrapper(
|
|
16
|
-
svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z"/>`
|
|
17
|
-
)
|
|
18
|
-
export const title = iconWrapper(svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 4v3h5.5v12h3V7H19V4H5z"/>`)
|
|
19
|
-
export const fontDownload = iconWrapper(
|
|
20
|
-
svg`<path d="M0 0h24v24H0V0z" fill="none"/><path d="M9.93 13.5h4.14L12 7.98zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z"/>`
|
|
21
|
-
)
|
|
@@ -1,25 +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>Basic context menu</title>
|
|
8
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
-
<link
|
|
11
|
-
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"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
/>
|
|
14
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
16
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
17
|
-
<link href="./demo.css" rel="stylesheet" type="text/css" />
|
|
18
|
-
</head>
|
|
19
|
-
|
|
20
|
-
<body class="demo">
|
|
21
|
-
<div id="app"></div>
|
|
22
|
-
<script type="module" src="/.tmp/demo/elements/context-menu/basic.js"></script>
|
|
23
|
-
</body>
|
|
24
|
-
|
|
25
|
-
</html>
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
3
|
-
import { ContextualMenu } from '../../../src/elements/contextual-menu/internals/ContextualMenu.js'
|
|
4
|
-
import {
|
|
5
|
-
BeforeRenderOptions,
|
|
6
|
-
ContextMenuCommand,
|
|
7
|
-
CommandExecuteOptions,
|
|
8
|
-
} from '../../../src/elements/contextual-menu/internals/types.js'
|
|
9
|
-
|
|
10
|
-
class ComponentPage extends DemoPage {
|
|
11
|
-
override accessor componentName = 'Basic context menu'
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super()
|
|
15
|
-
this.componentName = 'Basic contextual menu'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override firstRender(): void {
|
|
19
|
-
super.firstRender()
|
|
20
|
-
this.initContextMenu()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
initContextMenu(): void {
|
|
24
|
-
const container = document.body.querySelector('#workspace') as HTMLElement
|
|
25
|
-
const instance = new ContextualMenu(container)
|
|
26
|
-
const commands: ContextMenuCommand[] = [
|
|
27
|
-
{
|
|
28
|
-
target: 'all',
|
|
29
|
-
label: 'test',
|
|
30
|
-
title: 'All items title',
|
|
31
|
-
id: 'test-command',
|
|
32
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
33
|
-
console.log(args)
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
target: 'all',
|
|
38
|
-
label: 'visible',
|
|
39
|
-
title: 'test visible title',
|
|
40
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
41
|
-
console.log(args)
|
|
42
|
-
},
|
|
43
|
-
visible: () => false,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
target: 'all',
|
|
47
|
-
label: 'Not enabled',
|
|
48
|
-
title: 'test enabled title',
|
|
49
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
50
|
-
console.log(args)
|
|
51
|
-
},
|
|
52
|
-
enabled: () => false,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
target: ['section.target', 'aside.target.second'],
|
|
56
|
-
type: 'separator',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
target: 'section.target',
|
|
60
|
-
label: 'Target only',
|
|
61
|
-
title: 'Target only title',
|
|
62
|
-
id: 'target-command',
|
|
63
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
64
|
-
console.log(args)
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
target: ['section.target', 'aside.target.second'],
|
|
69
|
-
label: 'Target and second only',
|
|
70
|
-
title: 'Target and second title',
|
|
71
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
72
|
-
console.log(args)
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
target: 'custom',
|
|
77
|
-
label: 'Custom action',
|
|
78
|
-
title: 'Custom action title',
|
|
79
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
80
|
-
console.log(args)
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
target: 'all',
|
|
85
|
-
label: 'Uninitialized',
|
|
86
|
-
beforeRender: (ctx: BeforeRenderOptions): void => {
|
|
87
|
-
const { menu, target } = ctx
|
|
88
|
-
const label = `Clicked on a ${target.localName}`
|
|
89
|
-
menu.label = label
|
|
90
|
-
},
|
|
91
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
92
|
-
console.log(args)
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
]
|
|
96
|
-
instance.registerCommands(commands)
|
|
97
|
-
instance.connect()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
contentTemplate(): TemplateResult {
|
|
101
|
-
return html`
|
|
102
|
-
<a href="./">Back</a>
|
|
103
|
-
<section class="demo-section">
|
|
104
|
-
<h2 class="title-large">Basic contextual menu</h2>
|
|
105
|
-
<section class="documentation-section">
|
|
106
|
-
<h3>Interactive demo</h3>
|
|
107
|
-
<div id="workspace">
|
|
108
|
-
<section class="target">Section</section>
|
|
109
|
-
<aside class="target second">Aside</aside>
|
|
110
|
-
</div>
|
|
111
|
-
<p>This menu has a hidden item.</p>
|
|
112
|
-
</section>
|
|
113
|
-
</section>
|
|
114
|
-
`
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const instance = new ComponentPage()
|
|
119
|
-
instance.render()
|
|
@@ -1,25 +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>Enabled state context menu</title>
|
|
8
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
-
<link
|
|
11
|
-
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"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
/>
|
|
14
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
16
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
17
|
-
<link rel="stylesheet" href="./demo.css"/>
|
|
18
|
-
</head>
|
|
19
|
-
|
|
20
|
-
<body class="demo">
|
|
21
|
-
<div id="app"></div>
|
|
22
|
-
<script type="module" src="/.tmp/demo/elements/context-menu/custom-data.js"></script>
|
|
23
|
-
</body>
|
|
24
|
-
|
|
25
|
-
</html>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { html, TemplateResult } from 'lit'
|
|
2
|
-
import { DemoPage } from '../../../src/demo/DemoPage.js'
|
|
3
|
-
import { ContextualMenu } from '../../../src/elements/contextual-menu/internals/ContextualMenu.js'
|
|
4
|
-
import { ContextMenuCommand, CommandExecuteOptions } from '../../../src/elements/contextual-menu/internals/types.js'
|
|
5
|
-
|
|
6
|
-
class ComponentPage extends DemoPage {
|
|
7
|
-
override accessor componentName = 'Custom data'
|
|
8
|
-
|
|
9
|
-
override firstRender(): void {
|
|
10
|
-
super.firstRender()
|
|
11
|
-
this.initContextMenu()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
initContextMenu(): void {
|
|
15
|
-
const container = document.body.querySelector('#workspace') as HTMLElement
|
|
16
|
-
const instance = new ContextualMenu(container)
|
|
17
|
-
const commands: ContextMenuCommand[] = [
|
|
18
|
-
{
|
|
19
|
-
target: 'custom',
|
|
20
|
-
label: 'Custom action',
|
|
21
|
-
title: 'Custom action title',
|
|
22
|
-
execute: (args: CommandExecuteOptions): void => {
|
|
23
|
-
console.log(args)
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
instance.registerCommands(commands)
|
|
28
|
-
instance.connect()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
customTriggerHandler(e: Event): void {
|
|
32
|
-
e.preventDefault()
|
|
33
|
-
const container = document.body.querySelector('#workspace') as HTMLElement
|
|
34
|
-
container.dispatchEvent(
|
|
35
|
-
new CustomEvent('custommenu', {
|
|
36
|
-
detail: {
|
|
37
|
-
name: 'custom',
|
|
38
|
-
x: container.offsetLeft + 100,
|
|
39
|
-
y: container.offsetTop + 100,
|
|
40
|
-
customData: { test: true },
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
contentTemplate(): TemplateResult {
|
|
47
|
-
return html`
|
|
48
|
-
<a href="./">Back</a>
|
|
49
|
-
<section class="demo-section">
|
|
50
|
-
<h2 class="title-large">Contextual menu with custom data</h2>
|
|
51
|
-
<div id="workspace">
|
|
52
|
-
<div class="target" data-id="test-value"></div>
|
|
53
|
-
</div>
|
|
54
|
-
<button id="customTrigger" @click="${this.customTriggerHandler}">Trigger custom</button>
|
|
55
|
-
<p>The menu is only triggered via the custom event.</p>
|
|
56
|
-
</section>
|
|
57
|
-
`
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const instance = new ComponentPage()
|
|
62
|
-
instance.render()
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.centered[role="main"] {
|
|
2
|
-
max-width: 1400px;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
body.demo {
|
|
6
|
-
font-family: 'Roboto', sans-serif;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
#workspace {
|
|
10
|
-
width: 100%;
|
|
11
|
-
height: 300px;
|
|
12
|
-
background-color: dimgray;
|
|
13
|
-
position: relative;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.target {
|
|
17
|
-
width: 60px;
|
|
18
|
-
height: 60px;
|
|
19
|
-
background-color: white;
|
|
20
|
-
position: absolute;
|
|
21
|
-
top: 30px;
|
|
22
|
-
left: 50px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.target.second {
|
|
26
|
-
top: 60px;
|
|
27
|
-
left: calc(50% - 60px);
|
|
28
|
-
}
|
|
@@ -1,25 +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>Enabled state context menu</title>
|
|
8
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
-
<link
|
|
11
|
-
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"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
/>
|
|
14
|
-
<link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
|
|
15
|
-
<link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
|
|
16
|
-
<link href="../../page.css" rel="stylesheet" type="text/css" />
|
|
17
|
-
<link rel="stylesheet" href="./demo.css"/>
|
|
18
|
-
</head>
|
|
19
|
-
|
|
20
|
-
<body class="demo">
|
|
21
|
-
<div id="app"></div>
|
|
22
|
-
<script type="module" src="/.tmp/demo/elements/context-menu/enabled-state.js"></script>
|
|
23
|
-
</body>
|
|
24
|
-
|
|
25
|
-
</html>
|