@api-client/ui 0.0.13 → 0.0.14
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/dist/define/http/http-body-editor.d.ts.map +1 -1
- package/dist/define/http/http-body-editor.js +1 -1
- package/dist/define/http/http-body-editor.js.map +1 -1
- package/dist/elements/http/BodyEditor.js +5 -5
- package/dist/elements/http/BodyEditor.js.map +1 -1
- package/dist/elements/http/BodyEditor.styles.d.ts +1 -1
- package/dist/elements/http/BodyEditor.styles.d.ts.map +1 -1
- package/dist/elements/http/BodyEditor.styles.js +5 -19
- package/dist/elements/http/BodyEditor.styles.js.map +1 -1
- package/dist/elements/store/FilesLib.d.ts +2 -2
- package/dist/elements/store/FilesLib.d.ts.map +1 -1
- package/dist/elements/store/FilesLib.js.map +1 -1
- package/dist/http-client/store/Cursor.js +2 -2
- package/dist/http-client/store/Cursor.js.map +1 -1
- package/dist/http-client/store/HttpClientIdbDatabase.d.ts.map +1 -1
- package/dist/http-client/store/HttpClientIdbDatabase.js +2 -6
- package/dist/http-client/store/HttpClientIdbDatabase.js.map +1 -1
- package/dist/http-client/store/State.d.ts +1 -3
- package/dist/http-client/store/State.d.ts.map +1 -1
- package/dist/http-client/store/State.js.map +1 -1
- package/dist/http-client/store/idb/IdbStore.d.ts +1 -10
- package/dist/http-client/store/idb/IdbStore.d.ts.map +1 -1
- package/dist/http-client/store/idb/IdbStore.js +0 -48
- package/dist/http-client/store/idb/IdbStore.js.map +1 -1
- package/dist/http-client/store/types.d.ts +2 -56
- package/dist/http-client/store/types.d.ts.map +1 -1
- package/dist/http-client/store/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/api-client/ApiClient.screen.d.ts +4 -4
- package/dist/pages/api-client/ApiClient.screen.d.ts.map +1 -1
- package/dist/pages/api-client/ApiClient.screen.js +2 -2
- package/dist/pages/api-client/ApiClient.screen.js.map +1 -1
- package/dist/pages/api-client/pages/Trash.page.d.ts.map +1 -1
- package/dist/pages/api-client/pages/Trash.page.js +3 -11
- package/dist/pages/api-client/pages/Trash.page.js.map +1 -1
- package/dist/ui/list/UiDropdownList.js +1 -1
- package/dist/ui/list/UiDropdownList.js.map +1 -1
- package/package.json +2 -2
- package/src/define/http/http-body-editor.ts +1 -1
- package/src/elements/http/BodyEditor.styles.ts +5 -19
- package/src/elements/http/BodyEditor.ts +5 -5
- package/src/elements/store/FilesLib.ts +2 -2
- package/src/http-client/store/Cursor.ts +2 -2
- package/src/http-client/store/HttpClientIdbDatabase.ts +5 -9
- package/src/http-client/store/State.ts +1 -5
- package/src/http-client/store/idb/IdbStore.ts +1 -51
- package/src/http-client/store/types.ts +2 -57
- package/src/index.ts +3 -0
- package/src/pages/api-client/ApiClient.screen.ts +7 -7
- package/src/pages/api-client/pages/Trash.page.ts +3 -10
- package/src/ui/list/UiDropdownList.ts +1 -1
- package/web-test-runner.config.mjs +2 -2
- package/dist/http-client/store/Validator.d.ts +0 -4
- package/dist/http-client/store/Validator.d.ts.map +0 -1
- package/dist/http-client/store/Validator.js +0 -32
- package/dist/http-client/store/Validator.js.map +0 -1
- package/src/http-client/store/Validator.ts +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Trash.page.js","sourceRoot":"","sources":["../../../../src/pages/api-client/pages/Trash.page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAqF,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACzL,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,+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C;IACJ,CAAC;CACF","sourcesContent":["import { ProjectKind, EventUtils, FolderKind, TrashEntry, ContextSpaceListOptions, IFile, BroadcastEvent, BroadcastCreatedEvent, DataFileKind } from \"@api-client/core/build/browser.js\";\nimport { html, TemplateResult } from \"lit\";\nimport '@github/relative-time-element';\nimport { IconType } from \"../../../ui/icons/Icons.js\";\nimport { navigate } from \"../../../lib/route.js\";\nimport { SnackNotifications } from \"../../../ui/notification/SnackNotifications.js\";\nimport { DataTable } from \"../../../ui/table/DataTable.js\";\nimport type ApiClientScreen from \"../ApiClient.screen.js\";\nimport '../../../define/ui/ui-icon.js';\n\n/**\n * A class that specializes in rendering the list of trash in HTTP Client.\n */\nexport class TrashPage {\n files: TrashEntry[] = [];\n\n /**\n * The pagination cursor for trash.\n * As long there's a cursor, there are more files to request.\n */\n cursor?: string;\n\n dt = new DataTable(() => this.files, { ariaLabel: 'Trashed files' });\n\n readingFiles?: boolean;\n\n /**\n * The list of keys of files to delete.\n */\n deleteKeys?: string[];\n\n get deleteItems(): TrashEntry[] {\n const { deleteKeys, files } = this;\n if (!deleteKeys) {\n return [];\n }\n const result: TrashEntry[] = [];\n deleteKeys.forEach((key) => {\n const item = files.find(i => i.key === key);\n if (item) {\n result.push(item);\n }\n });\n return result;\n }\n\n constructor(protected screen: ApiClientScreen) {\n this.dt.addEventListener('empty', this.renderEmptyTable.bind(this));\n this.dt.addEventListener('header', this.renderTableHeader.bind(this));\n this.dt.addEventListener('item', this.renderTableItem.bind(this));\n\n this.itemOptionsSelectHandler = this.itemOptionsSelectHandler.bind(this);\n this.cancelDeleteAllDialog = this.cancelDeleteAllDialog.bind(this);\n this.deleteAllHandler = this.deleteAllHandler.bind(this);\n this.cancelDeleteFilesDialog = this.cancelDeleteFilesDialog.bind(this);\n this.deleteFilesHandler = this.deleteFilesHandler.bind(this);\n this.openEmptyAllDialogHandler = this.openEmptyAllDialogHandler.bind(this);\n }\n\n handleFileEvent(event: BroadcastEvent): void {\n switch (event.operation) {\n case 'created': this.handleTrashAdded((event as BroadcastCreatedEvent).data as TrashEntry); break;\n case 'deleted': this.handleTrashRemoved(event.key as string); break;\n default:\n }\n }\n\n protected handleTrashAdded(item: TrashEntry): void {\n this.files.push(item);\n this.files.sort(this.filesSortFunction.bind(this));\n this.screen.render();\n }\n\n protected handleTrashRemoved(key: string): void {\n const index = this.files.findIndex(i => i.key === key);\n if (index === -1) {\n return;\n }\n this.files.splice(index, 1);\n this.screen.render();\n }\n\n async refresh(): Promise<void> {\n this.resetList();\n this.screen.render();\n await this.readFiles();\n }\n\n resetList(): void {\n this.files = [];\n this.cursor = undefined;\n }\n\n async readFiles(): Promise<void> {\n const { selectedSpace } = this.screen;\n if (!selectedSpace) {\n return;\n }\n if (this.readingFiles) {\n return;\n }\n this.readingFiles = true;\n const { cursor: currentCursor } = this;\n const opts: ContextSpaceListOptions = {\n space: selectedSpace,\n descending: true,\n };\n if (currentCursor) {\n opts.cursor = currentCursor;\n }\n try {\n const result = await this.screen.bindings.store.trash.list(opts);\n const { items, cursor } = result;\n this.files = this.files.concat(items).sort(this.filesSortFunction.bind(this));\n this.cursor = cursor;\n } finally {\n this.readingFiles = false;\n }\n this.screen.render();\n }\n\n /**\n * Sorts files on the list.\n * \n * Folders are always on top.\n */\n filesSortFunction(a: TrashEntry, b: TrashEntry): number {\n return b.info.time - a.info.time;\n }\n\n protected itemOptionsSelectHandler(e: CustomEvent): void {\n const item = e.detail.item as HTMLElement;\n const list = e.target as HTMLElement;\n const operation = item.dataset.option as string;\n const key = list.dataset.key as string;\n if (!key || !operation) {\n return;\n }\n if (operation === 'restore') {\n this.restoreItem(key);\n } else if (operation === 'delete') {\n this.deleteKeys = [key];\n this.screen.render();\n this.screen.openDialog('deleteFilesDialog');\n }\n }\n\n async restoreItem(key: string): Promise<void> {\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n const record = await bindings.store.trash.restore(key);\n const file = record.item as IFile;\n const parentId = file.parents && file.parents.length ? file.parents[file.parents.length - 1] : undefined;\n SnackNotifications.notify(`Restored file: ${file.info.name}`, {\n actionLabel: 'Go to file location',\n actionCallback: () => {\n if (parentId) {\n navigate('files', parentId);\n } else {\n navigate('files');\n }\n },\n });\n }\n\n async deleteItem(key: string): Promise<void> {\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n await bindings.store.trash.delete(key);\n }\n\n protected openEmptyAllDialogHandler(): void {\n this.screen.openDialog('deleteAllDialog');\n }\n\n protected cancelDeleteAllDialog(): void {\n this.screen.closeDialog('deleteAllDialog');\n }\n\n protected deleteAllHandler(): void {\n this.screen.closeDialog('deleteAllDialog');\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n bindings.store.trash.empty(selectedSpace);\n }\n\n protected cancelDeleteFilesDialog(): void {\n this.deleteKeys = undefined;\n this.screen.closeDialog('deleteFilesDialog');\n }\n\n protected deleteFilesHandler(): void {\n this.screen.closeDialog('deleteFilesDialog');\n this.screen.render();\n const { deleteKeys } = this;\n this.deleteKeys = undefined;\n if (!deleteKeys || !deleteKeys.length) {\n return;\n }\n deleteKeys.forEach(k => this.deleteItem(k));\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"section-header\">\n <h2 class=\"headline-small\">Trash</h2>\n <div class=\"spacer\"></div>\n ${this.renderEmptyTrash()}\n </div>\n ${this.renderTrashTable()}\n ${this.renderDeleteAllDialog()}\n ${this.renderDeleteFilesDialog()}\n `;\n }\n\n protected renderEmptyTrash(): TemplateResult {\n const { files } = this;\n const disabled = !files || !files.length;\n return html`\n <ui-button type=\"outlined\" ?disabled=\"${disabled}\" @click=\"${this.openEmptyAllDialogHandler}\">\n <ui-icon icon=\"deleteOutline\" slot=\"icon\"></ui-icon>\n Empty trash\n </ui-button>\n `;\n }\n\n protected renderTrashTable(): TemplateResult {\n return this.dt.render();\n }\n\n protected renderEmptyTable(): TemplateResult {\n return html`\n <p>The trash bin is empty.</p>\n `;\n }\n\n protected renderTableHeader(): TemplateResult[] {\n const name = this.dt.header('Name', { class: 'name-cell' });\n const deleted = this.dt.header('Deleted', { class: 'updated-cell' });\n const menu = this.dt.header(html`<span hidden>Menu</span>`, { class: 'menu-cell' });\n return [name, deleted, menu];\n }\n\n protected renderTableItem(item: TrashEntry): TemplateResult[] {\n const { kind, name, info } = item;\n let icon: IconType | undefined;\n if (kind === ProjectKind) {\n icon = 'collectionsBookmark';\n } else if (kind === FolderKind) {\n icon = 'folder';\n } else if (kind === DataFileKind) {\n icon = 'schema';\n }\n\n const nameCell = this.dt.cell(html`\n ${icon ? html`<ui-icon icon=\"${icon}\" class=\"cell-icon\"></ui-icon>` : ''}\n ${name || 'Unnamed file'}\n `, { class: 'name-cell', data: { kind } });\n\n const deleted = this.dt.cell(html`\n <relative-time datetime=\"${new Date(info.time).toISOString()}\"></relative-time>\n `, { class: 'updated-cell' });\n\n const menu = this.dt.cell(this.renderItemOptions(item), { class: 'menu-cell' });\n\n return [nameCell, deleted, menu];\n }\n\n protected renderItemOptions(item: TrashEntry): TemplateResult {\n return html`\n <ui-dropdown-list\n horizontalAlign=\"auto\"\n verticalAlign=\"auto\"\n closeOnOutsideClick\n @mousedown=\"${EventUtils.cancelEvent}\" \n @mouseup=\"${EventUtils.cancelEvent}\" \n @click=\"${EventUtils.cancelEvent}\"\n @dblclick=\"${EventUtils.cancelEvent}\"\n @select=\"${this.itemOptionsSelectHandler}\"\n data-key=\"${item.key}\"\n >\n <ui-icon-button title=\"Project options\" aria-label=\"Activate for more options\">\n <ui-icon icon=\"moreVert\"></ui-icon>\n </ui-icon-button>\n <ui-list slot=\"dropdown\" role=\"menu\">\n <ui-list-item image=\"icon\" data-option=\"restore\" role=\"menuitem\" title=\"Restores the file to its original folder.\">\n <ui-icon icon=\"restoreFromTrash\" slot=\"start\"></ui-icon>\n Restore\n </ui-list-item>\n <ui-list-item image=\"icon\" data-option=\"delete\" role=\"menuitem\" title=\"Permanently deleted the item.\">\n <ui-icon icon=\"deleteOutline\" slot=\"start\"></ui-icon>\n Delete forever\n </ui-list-item>\n </ui-list>\n </ui-dropdown-list>\n `;\n }\n\n protected renderDeleteAllDialog(): TemplateResult {\n return html`\n <dialog id=\"deleteAllDialog\" class=\"warning\">\n <h3>Empty Trash?</h3>\n <div>\n <p class=\"body-medium\">\n This will permanently delete all files in the trash.\n </p>\n </div>\n <div class=\"dialog-buttons\">\n <ui-button type=\"text\" value=\"cancel\" @click=\"${this.cancelDeleteAllDialog}\">Cancel</ui-button>\n <ui-button type=\"text\" value=\"delete\" @click=\"${this.deleteAllHandler}\">Delete</ui-button>\n </div>\n </dialog>\n `;\n }\n\n protected renderDeleteFilesDialog(): TemplateResult {\n const { deleteItems } = this;\n return html`\n <dialog id=\"deleteFilesDialog\" class=\"warning\">\n <h3>Delete Forever?</h3>\n <div>\n ${deleteItems.length > 1 ? this.renderDeleteMultiFile(deleteItems) : this.renderDeleteSingleFile(deleteItems[0])}\n </div>\n <div class=\"dialog-buttons\">\n <ui-button type=\"text\" value=\"cancel\" @click=\"${this.cancelDeleteFilesDialog}\">Cancel</ui-button>\n <ui-button type=\"text\" value=\"delete\" @click=\"${this.deleteFilesHandler}\">Delete</ui-button>\n </div>\n </dialog>\n `;\n }\n\n protected renderDeleteSingleFile(item: TrashEntry): TemplateResult {\n if (!item) {\n return html`\n <p class=\"body-medium\">Invalid state. Couldn't find files to delete.</p>\n `;\n }\n return html`\n <p class=\"body-medium\">\n <b>\"${item.name}\"</b> will be deleted forever and you won't be able to restore it.\n </p>\n `;\n }\n\n protected renderDeleteMultiFile(items: TrashEntry[]): TemplateResult {\n return html`\n <p class=\"body-medium\">\n The following files will be deleted forever and you won't be able to restore them:\n </p>\n <ui-divider></ui-divider>\n <ul>\n ${items.map(i => html`<li>${i.name}</li>`)}\n </ul>\n <ui-divider></ui-divider>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,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AAI,CAAA;;YAEH,IAAI,CAAC,IAAI;;KAEhB,CAAC;IACJ,CAAC;IAES,qBAAqB,CAAC,KAAmB;QACjD,OAAO,IAAI,CAAA;;;;;;QAMP,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAA,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC;;;KAG3C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { EventUtils, TrashEntry, ContextSpaceListOptions, IFile, BroadcastEvent, BroadcastCreatedEvent } from \"@api-client/core/build/browser.js\";\nimport { html, TemplateResult } from \"lit\";\nimport '@github/relative-time-element';\nimport { navigate } from \"../../../lib/route.js\";\nimport { SnackNotifications } from \"../../../ui/notification/SnackNotifications.js\";\nimport { DataTable } from \"../../../ui/table/DataTable.js\";\nimport { fileIcon } from \"../../../elements/store/FilesLib.js\";\nimport type ApiClientScreen from \"../ApiClient.screen.js\";\nimport '../../../define/ui/ui-icon.js';\n\n/**\n * A class that specializes in rendering the list of trash in HTTP Client.\n */\nexport class TrashPage {\n files: TrashEntry[] = [];\n\n /**\n * The pagination cursor for trash.\n * As long there's a cursor, there are more files to request.\n */\n cursor?: string;\n\n dt = new DataTable(() => this.files, { ariaLabel: 'Trashed files' });\n\n readingFiles?: boolean;\n\n /**\n * The list of keys of files to delete.\n */\n deleteKeys?: string[];\n\n get deleteItems(): TrashEntry[] {\n const { deleteKeys, files } = this;\n if (!deleteKeys) {\n return [];\n }\n const result: TrashEntry[] = [];\n deleteKeys.forEach((key) => {\n const item = files.find(i => i.key === key);\n if (item) {\n result.push(item);\n }\n });\n return result;\n }\n\n constructor(protected screen: ApiClientScreen) {\n this.dt.addEventListener('empty', this.renderEmptyTable.bind(this));\n this.dt.addEventListener('header', this.renderTableHeader.bind(this));\n this.dt.addEventListener('item', this.renderTableItem.bind(this));\n\n this.itemOptionsSelectHandler = this.itemOptionsSelectHandler.bind(this);\n this.cancelDeleteAllDialog = this.cancelDeleteAllDialog.bind(this);\n this.deleteAllHandler = this.deleteAllHandler.bind(this);\n this.cancelDeleteFilesDialog = this.cancelDeleteFilesDialog.bind(this);\n this.deleteFilesHandler = this.deleteFilesHandler.bind(this);\n this.openEmptyAllDialogHandler = this.openEmptyAllDialogHandler.bind(this);\n }\n\n handleFileEvent(event: BroadcastEvent): void {\n switch (event.operation) {\n case 'created': this.handleTrashAdded((event as BroadcastCreatedEvent).data as TrashEntry); break;\n case 'deleted': this.handleTrashRemoved(event.key as string); break;\n default:\n }\n }\n\n protected handleTrashAdded(item: TrashEntry): void {\n this.files.push(item);\n this.files.sort(this.filesSortFunction.bind(this));\n this.screen.render();\n }\n\n protected handleTrashRemoved(key: string): void {\n const index = this.files.findIndex(i => i.key === key);\n if (index === -1) {\n return;\n }\n this.files.splice(index, 1);\n this.screen.render();\n }\n\n async refresh(): Promise<void> {\n this.resetList();\n this.screen.render();\n await this.readFiles();\n }\n\n resetList(): void {\n this.files = [];\n this.cursor = undefined;\n }\n\n async readFiles(): Promise<void> {\n const { selectedSpace } = this.screen;\n if (!selectedSpace) {\n return;\n }\n if (this.readingFiles) {\n return;\n }\n this.readingFiles = true;\n const { cursor: currentCursor } = this;\n const opts: ContextSpaceListOptions = {\n space: selectedSpace,\n descending: true,\n };\n if (currentCursor) {\n opts.cursor = currentCursor;\n }\n try {\n const result = await this.screen.bindings.store.trash.list(opts);\n const { items, cursor } = result;\n this.files = this.files.concat(items).sort(this.filesSortFunction.bind(this));\n this.cursor = cursor;\n } finally {\n this.readingFiles = false;\n }\n this.screen.render();\n }\n\n /**\n * Sorts files on the list.\n * \n * Folders are always on top.\n */\n filesSortFunction(a: TrashEntry, b: TrashEntry): number {\n return b.info.time - a.info.time;\n }\n\n protected itemOptionsSelectHandler(e: CustomEvent): void {\n const item = e.detail.item as HTMLElement;\n const list = e.target as HTMLElement;\n const operation = item.dataset.option as string;\n const key = list.dataset.key as string;\n if (!key || !operation) {\n return;\n }\n if (operation === 'restore') {\n this.restoreItem(key);\n } else if (operation === 'delete') {\n this.deleteKeys = [key];\n this.screen.render();\n this.screen.openDialog('deleteFilesDialog');\n }\n }\n\n async restoreItem(key: string): Promise<void> {\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n const record = await bindings.store.trash.restore(key);\n const file = record.item as IFile;\n const parentId = file.parents && file.parents.length ? file.parents[file.parents.length - 1] : undefined;\n SnackNotifications.notify(`Restored file: ${file.info.name}`, {\n actionLabel: 'Go to file location',\n actionCallback: () => {\n if (parentId) {\n navigate('files', parentId);\n } else {\n navigate('files');\n }\n },\n });\n }\n\n async deleteItem(key: string): Promise<void> {\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n await bindings.store.trash.delete(key);\n }\n\n protected openEmptyAllDialogHandler(): void {\n this.screen.openDialog('deleteAllDialog');\n }\n\n protected cancelDeleteAllDialog(): void {\n this.screen.closeDialog('deleteAllDialog');\n }\n\n protected deleteAllHandler(): void {\n this.screen.closeDialog('deleteAllDialog');\n const { bindings, selectedSpace } = this.screen;\n if (!selectedSpace) {\n throw new Error(`Invalid state: Folder is not selected.`);\n }\n bindings.store.trash.empty(selectedSpace);\n }\n\n protected cancelDeleteFilesDialog(): void {\n this.deleteKeys = undefined;\n this.screen.closeDialog('deleteFilesDialog');\n }\n\n protected deleteFilesHandler(): void {\n this.screen.closeDialog('deleteFilesDialog');\n this.screen.render();\n const { deleteKeys } = this;\n this.deleteKeys = undefined;\n if (!deleteKeys || !deleteKeys.length) {\n return;\n }\n deleteKeys.forEach(k => this.deleteItem(k));\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"section-header\">\n <h2 class=\"headline-small\">Trash</h2>\n <div class=\"spacer\"></div>\n ${this.renderEmptyTrash()}\n </div>\n ${this.renderTrashTable()}\n ${this.renderDeleteAllDialog()}\n ${this.renderDeleteFilesDialog()}\n `;\n }\n\n protected renderEmptyTrash(): TemplateResult {\n const { files } = this;\n const disabled = !files || !files.length;\n return html`\n <ui-button type=\"outlined\" ?disabled=\"${disabled}\" @click=\"${this.openEmptyAllDialogHandler}\">\n <ui-icon icon=\"deleteOutline\" slot=\"icon\"></ui-icon>\n Empty trash\n </ui-button>\n `;\n }\n\n protected renderTrashTable(): TemplateResult {\n return this.dt.render();\n }\n\n protected renderEmptyTable(): TemplateResult {\n return html`\n <p>The trash bin is empty.</p>\n `;\n }\n\n protected renderTableHeader(): TemplateResult[] {\n const name = this.dt.header('Name', { class: 'name-cell' });\n const deleted = this.dt.header('Deleted', { class: 'updated-cell' });\n const menu = this.dt.header(html`<span hidden>Menu</span>`, { class: 'menu-cell' });\n return [name, deleted, menu];\n }\n\n protected renderTableItem(item: TrashEntry): TemplateResult[] {\n const { kind, name, info } = item;\n const icon = fileIcon(item);\n\n const nameCell = this.dt.cell(html`\n ${icon ? html`<ui-icon icon=\"${icon}\" class=\"cell-icon\"></ui-icon>` : ''}\n ${name || 'Unnamed file'}\n `, { class: 'name-cell', data: { kind } });\n\n const deleted = this.dt.cell(html`\n <relative-time datetime=\"${new Date(info.time).toISOString()}\"></relative-time>\n `, { class: 'updated-cell' });\n\n const menu = this.dt.cell(this.renderItemOptions(item), { class: 'menu-cell' });\n\n return [nameCell, deleted, menu];\n }\n\n protected renderItemOptions(item: TrashEntry): TemplateResult {\n return html`\n <ui-dropdown-list\n horizontalAlign=\"auto\"\n verticalAlign=\"auto\"\n closeOnOutsideClick\n @mousedown=\"${EventUtils.cancelEvent}\" \n @mouseup=\"${EventUtils.cancelEvent}\" \n @click=\"${EventUtils.cancelEvent}\"\n @dblclick=\"${EventUtils.cancelEvent}\"\n @select=\"${this.itemOptionsSelectHandler}\"\n data-key=\"${item.key}\"\n >\n <ui-icon-button title=\"Project options\" aria-label=\"Activate for more options\">\n <ui-icon icon=\"moreVert\"></ui-icon>\n </ui-icon-button>\n <ui-list slot=\"dropdown\" role=\"menu\">\n <ui-list-item image=\"icon\" data-option=\"restore\" role=\"menuitem\" title=\"Restores the file to its original folder.\">\n <ui-icon icon=\"restoreFromTrash\" slot=\"start\"></ui-icon>\n Restore\n </ui-list-item>\n <ui-list-item image=\"icon\" data-option=\"delete\" role=\"menuitem\" title=\"Permanently deleted the item.\">\n <ui-icon icon=\"deleteOutline\" slot=\"start\"></ui-icon>\n Delete forever\n </ui-list-item>\n </ui-list>\n </ui-dropdown-list>\n `;\n }\n\n protected renderDeleteAllDialog(): TemplateResult {\n return html`\n <dialog id=\"deleteAllDialog\" class=\"warning\">\n <h3>Empty Trash?</h3>\n <div>\n <p class=\"body-medium\">\n This will permanently delete all files in the trash.\n </p>\n </div>\n <div class=\"dialog-buttons\">\n <ui-button type=\"text\" value=\"cancel\" @click=\"${this.cancelDeleteAllDialog}\">Cancel</ui-button>\n <ui-button type=\"text\" value=\"delete\" @click=\"${this.deleteAllHandler}\">Delete</ui-button>\n </div>\n </dialog>\n `;\n }\n\n protected renderDeleteFilesDialog(): TemplateResult {\n const { deleteItems } = this;\n return html`\n <dialog id=\"deleteFilesDialog\" class=\"warning\">\n <h3>Delete Forever?</h3>\n <div>\n ${deleteItems.length > 1 ? this.renderDeleteMultiFile(deleteItems) : this.renderDeleteSingleFile(deleteItems[0])}\n </div>\n <div class=\"dialog-buttons\">\n <ui-button type=\"text\" value=\"cancel\" @click=\"${this.cancelDeleteFilesDialog}\">Cancel</ui-button>\n <ui-button type=\"text\" value=\"delete\" @click=\"${this.deleteFilesHandler}\">Delete</ui-button>\n </div>\n </dialog>\n `;\n }\n\n protected renderDeleteSingleFile(item: TrashEntry): TemplateResult {\n if (!item) {\n return html`\n <p class=\"body-medium\">Invalid state. Couldn't find files to delete.</p>\n `;\n }\n return html`\n <p class=\"body-medium\">\n <b>\"${item.name}\"</b> will be deleted forever and you won't be able to restore it.\n </p>\n `;\n }\n\n protected renderDeleteMultiFile(items: TrashEntry[]): TemplateResult {\n return html`\n <p class=\"body-medium\">\n The following files will be deleted forever and you won't be able to restore them:\n </p>\n <ui-divider></ui-divider>\n <ul>\n ${items.map(i => html`<li>${i.name}</li>`)}\n </ul>\n <ui-divider></ui-divider>\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiDropdownList.js","sourceRoot":"","sources":["../../../src/ui/list/UiDropdownList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAA0C,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC;AAMnE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU;IAmEpD;;OAEG;IACH,IAAc,OAAO;QACnB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACjC,OAAO,IAAI,CAAC;SACb;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,IAAc,QAAQ;QACpB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACnC,OAAO,IAAI,CAAC;SACb;QACD,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS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AAE,CAAC;2DAA+B;AAO9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDAA6B;AAO5B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAsB;AA0BzC;IAAR,KAAK,EAAE;0DAA0C","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult } from \"lit\";\nimport { property, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { ClassInfo, classMap } from \"lit/directives/class-map.js\";\nimport { StyleInfo, styleMap } from \"lit/directives/style-map.js\";\nimport { randomString } from \"../../lib/Random.js\";\nimport { ElementPositioning, HorizontalAlignment, VerticalAlignment } from \"../lib/ElementPositioning.js\";\nimport { ScrollHelper } from \"../lib/ScrollHelper.js\";\n\nconst itemRole = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];\n\nexport interface UiDropdownListSelection {\n item: HTMLElement;\n}\n\n/**\n * An overlay list rendered over a button.\n * \n * Examples:\n * \n * <ui-dropdown-list>\n * <ui-button>Click me</ui-button>\n * <ui-list slot=\"dropdown\" role=\"menu\">\n * <ui-list-item role=\"menuitem\">Item 1</ui-list-item>\n * <ui-list-item role=\"menuitem\">Item 2</ui-list-item>\n * </ui-list>\n * </ui-dropdown-list>\n * \n * @slot - The default slot for the dropdown trigger (button) \n * @slot dropdown - The slot for the list.\n * @fires select - Custom event with the selected item on the `detail.item` when the user selected an item. When the event is cancelled then there's no side effects (closing the dropdown)\n * @fires dropdownopen - An event informing other dropdowns that this one was opened and other should close.\n * @fires open - An event dispatched when the open state change through a user interaction\n */\nexport default class UiDropdownList extends LitElement {\n @queryAssignedElements()\n protected triggers!: HTMLElement[] | null;\n\n @queryAssignedElements({ slot: 'dropdown' })\n protected dropdowns!: HTMLElement[] | null;\n\n @state() protected triggerId = `ui-trigger-${randomString(4)}`;\n\n @state() protected menuId = `ui-menu-${randomString(4)}`;\n\n /**\n * Whether the menu is opened.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The vertical (y-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n * \n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) verticalAlign?: VerticalAlignment;\n\n /**\n * The horizontal (x-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n * \n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) horizontalAlign?: HorizontalAlignment;\n\n /**\n * Affects the `horizontal` and `vertical` positioning so that the target element does not overlap with the anchor.\n * For example, when the `vertical` align is `top`, the top edge of the target will be rendered at the bottom \n * of the anchor down to the edge of the viewport.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) noOverlap?: boolean;\n\n /**\n * When set it closes the opened list when registering a click outside the list.\n * @attribute\n */\n @property({ type: Boolean }) closeOnOutsideClick?: boolean;\n\n /**\n * When set it makes the drop-down to match the width of the trigger.\n * Be careful as this may crop the content when the trigger is not wide enough.\n * @attribute\n */\n @property({ type: Boolean }) matchTriggerWidth?: boolean;\n\n /**\n * When set it closes the drop-down when `tab` button is pressed.\n * This is not a default behavior since the drop-down content can have its own logic\n * related to tab index.\n */\n @property({ type: Boolean }) closeOnTab?: boolean;\n\n /**\n * The first element located in the default slot.\n */\n protected get trigger(): HTMLElement | null {\n const { triggers } = this;\n if (!triggers || !triggers.length) {\n return null;\n }\n const [button] = triggers;\n return button;\n }\n\n /**\n * The first element located in the \"dropdown\" slot.\n */\n protected get dropdown(): HTMLElement | null {\n const { dropdowns } = this;\n if (!dropdowns || !dropdowns.length) {\n return null;\n }\n const [content] = dropdowns;\n return content;\n }\n\n @state() protected overlayPositioning?: StyleInfo;\n\n constructor() {\n super();\n this.dropdownOpenHandler = this.dropdownOpenHandler.bind(this);\n this.scrollHandler = this.scrollHandler.bind(this);\n this.clickHandler = this.clickHandler.bind(this);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('dropdownopen', this.dropdownOpenHandler);\n window.addEventListener('click', this.clickHandler, { capture: true });\n ScrollHelper.addListeners(this, this.scrollHandler);\n\n this.setAttribute('aria-haspopup', 'menu');\n this.setAttribute('aria-expanded', 'false');\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('dropdownopen', this.dropdownOpenHandler);\n window.removeEventListener('click', this.clickHandler, { capture: true });\n ScrollHelper.removeListeners(this);\n }\n\n protected dropdownOpenHandler(e: Event): void {\n if (e.composedPath()[0] === this) {\n return;\n }\n this.close();\n }\n\n protected updateExpanded(): void {\n this.setAttribute('aria-expanded', String(this.open));\n }\n\n protected triggerChanged(): void {\n const { trigger } = this;\n if (!trigger) {\n return;\n }\n this.decorateTrigger(trigger);\n }\n\n protected dropdownChanged(): void {\n const { dropdown } = this;\n if (!dropdown) {\n return;\n }\n this.decorateDropdown(dropdown);\n }\n\n /**\n * Decorates the trigger with aria attributes.\n */\n protected decorateTrigger(button: HTMLElement): void {\n button.setAttribute('aria-controls', this.menuId);\n button.setAttribute('tabindex', '0');\n if (button.id) {\n this.triggerId = button.id;\n } else {\n // eslint-disable-next-line no-param-reassign\n button.id = this.triggerId;\n }\n }\n\n protected decorateDropdown(list: HTMLElement): void {\n if (!list.hasAttribute('role')) {\n list.setAttribute('role', 'menu');\n }\n if (!list.hasAttribute('aria-labelledby')) {\n list.setAttribute('aria-labelledby', this.triggerId);\n }\n list.setAttribute('tabindex', '-1');\n // eslint-disable-next-line no-param-reassign\n list.id = this.menuId;\n }\n\n protected triggerClickHandler(): void {\n this.open = !this.open;\n this.updateExpanded();\n this.notifyOpen();\n }\n\n protected triggerKeyDownHandler(e: KeyboardEvent): void {\n if (['Enter', 'Space', 'ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault();\n this.open = true;\n this.updateExpanded();\n this.notifyOpen();\n }\n }\n\n protected contentKeyDownHandler(e: KeyboardEvent): void {\n if (e.defaultPrevented) {\n return;\n }\n if (e.code === 'Escape') {\n this.close();\n } else if (e.code === 'Tab') {\n if (this.closeOnTab) {\n this.close();\n }\n } else if (['Enter', 'Space'].includes(e.code)) {\n this.activate(e);\n }\n }\n\n protected contentClickHandler(e: PointerEvent): void {\n this.activate(e);\n }\n\n close(): void {\n this.open = false;\n this.updateExpanded();\n this.notifyOpen();\n }\n\n protected contentCloseHandler(e: Event): void {\n e.stopPropagation();\n this.close();\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n super.willUpdate(cp);\n if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {\n this.computePositioning();\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp);\n if (cp.has('open')) {\n this.toggleOpened();\n }\n }\n\n /**\n * Since the container for the dropdown content is positioned as fixed\n * we need to position the dropdown according to the configured rules.\n */\n protected computePositioning(): void {\n const { trigger, dropdown } = this;\n if (!trigger || !dropdown) {\n return;\n }\n this.overlayPositioning = ElementPositioning.positionOverlay(dropdown, trigger, {\n horizontal: this.horizontalAlign,\n vertical: this.verticalAlign,\n noOverlap: this.noOverlap,\n constrain: true,\n constrainPaddingY: 20,\n matchAnchorWidth: this.matchTriggerWidth,\n });\n }\n\n protected scrollHandler(): void {\n if (this.open) {\n this.computePositioning();\n }\n }\n\n protected clickHandler(e: Event): void {\n if (!this.open || !this.closeOnOutsideClick) {\n return;\n }\n const inside = e.composedPath().some(i => i === this);\n if (inside) {\n return;\n }\n this.close();\n }\n\n protected toggleOpened(): void {\n const { open } = this;\n if (open) {\n this.handleOpened();\n } else {\n this.handleClosed();\n }\n }\n\n protected handleOpened(): void {\n const { trigger, dropdown } = this;\n if (trigger) {\n trigger.removeAttribute('tabindex');\n }\n if (dropdown) {\n dropdown.setAttribute('tabindex', '0');\n dropdown.focus();\n }\n }\n\n protected handleClosed(): void {\n const { trigger, dropdown } = this;\n if (trigger) {\n trigger.setAttribute('tabindex', '0');\n if (this.matches(':focus-within')) {\n trigger.focus();\n }\n }\n if (dropdown) {\n dropdown.removeAttribute('tabindex');\n }\n }\n\n protected activate(e: Event): void {\n if (e.defaultPrevented) {\n return;\n }\n const path = e.composedPath();\n let item: HTMLElement | undefined;\n while (!item) {\n const next = path.shift() as Element;\n if (next === this) {\n break;\n }\n if (next.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n if (itemRole.includes(next.getAttribute('role') || '')) {\n item = next as HTMLElement;\n }\n }\n if (!item) {\n return;\n }\n const event = new CustomEvent<UiDropdownListSelection>('select', {\n cancelable: true,\n composed: true,\n detail: {\n item,\n },\n })\n this.dispatchEvent(event);\n if (event.defaultPrevented) {\n return;\n }\n this.close();\n }\n\n protected notifyOpen(): void {\n this.dispatchEvent(new Event('open'));\n if (this.open) {\n this.dispatchEvent(new Event('dropdownopen', {\n bubbles: true,\n composed: true,\n cancelable: true,\n }));\n }\n }\n\n protected override render(): TemplateResult {\n const classes: ClassInfo = {\n container: true,\n open: this.open,\n };\n \n return html`\n <div class=\"${classMap(classes)}\">\n ${this.renderTrigger()}\n ${this.renderContent()}\n </div>\n `;\n }\n\n protected renderTrigger(): TemplateResult {\n return html`\n <div \n class=\"trigger\" \n @click=\"${this.triggerClickHandler}\" \n @keydown=\"${this.triggerKeyDownHandler}\"\n ><slot @slotchange=\"${this.triggerChanged}\"></slot></div>\n `;\n }\n\n protected renderContent(): TemplateResult {\n const contentStyles = this.overlayPositioning || {};\n return html`\n <div \n class=\"content\" \n style=\"${styleMap(contentStyles)}\"\n >\n <slot \n name=\"dropdown\" \n @slotchange=\"${this.dropdownChanged}\" \n @keydown=\"${this.contentKeyDownHandler}\" \n @click=\"${this.contentClickHandler}\"\n @close=\"${this.contentCloseHandler}\"\n ></slot>\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UiDropdownList.js","sourceRoot":"","sources":["../../../src/ui/list/UiDropdownList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,QAAQ,EAA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0BAClB,IAAI,CAAC,cAAc;KACxC,CAAC;IACJ,CAAC;IAES,aAAa;QACrB,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAC;QACpD,OAAO,IAAI,CAAA;;;eAGA,QAAQ,CAAC,aAAa,CAAC;;;;uBAIf,IAAI,CAAC,eAAe;oBACvB,IAAI,CAAC,qBAAqB;kBAC5B,IAAI,CAAC,mBAAmB;kBACxB,IAAI,CAAC,mBAAmB;;;KAGrC,CAAC;IACJ,CAAC;CACF;AA/XC;IADC,qBAAqB,EAAE;gDACkB;AAG1C;IADC,qBAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;iDACD;AAElC;IAAR,KAAK,EAAE;iDAAuD;AAEtD;IAAR,KAAK,EAAE;8CAAiD;AAMb;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAAc;AAWd;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDAAmC;AAWlC;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDAAuC;AAQrC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAqB;AAMnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2DAA+B;AAO9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yDAA6B;AAO5B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAsB;AA0BzC;IAAR,KAAK,EAAE;0DAA0C","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult } from \"lit\";\nimport { property, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { ClassInfo, classMap } from \"lit/directives/class-map.js\";\nimport { StyleInfo, styleMap } from \"lit/directives/style-map.js\";\nimport { randomString } from \"../../lib/Random.js\";\nimport { ElementPositioning, HorizontalAlignment, VerticalAlignment } from \"../lib/ElementPositioning.js\";\nimport { ScrollHelper } from \"../lib/ScrollHelper.js\";\n\nconst itemRole = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];\n\nexport interface UiDropdownListSelection {\n item: HTMLElement;\n}\n\n/**\n * An overlay list rendered over a button.\n * \n * Examples:\n * \n * <ui-dropdown-list>\n * <ui-button>Click me</ui-button>\n * <ui-list slot=\"dropdown\" role=\"menu\">\n * <ui-list-item role=\"menuitem\">Item 1</ui-list-item>\n * <ui-list-item role=\"menuitem\">Item 2</ui-list-item>\n * </ui-list>\n * </ui-dropdown-list>\n * \n * @slot - The default slot for the dropdown trigger (button) \n * @slot dropdown - The slot for the list.\n * @fires select - Custom event with the selected item on the `detail.item` when the user selected an item. When the event is cancelled then there's no side effects (closing the dropdown)\n * @fires dropdownopen - An event informing other dropdowns that this one was opened and other should close.\n * @fires open - An event dispatched when the open state change through a user interaction\n */\nexport default class UiDropdownList extends LitElement {\n @queryAssignedElements()\n protected triggers!: HTMLElement[] | null;\n\n @queryAssignedElements({ slot: 'dropdown' })\n protected dropdowns!: HTMLElement[] | null;\n\n @state() protected triggerId = `ui-trigger-${randomString(4)}`;\n\n @state() protected menuId = `ui-menu-${randomString(4)}`;\n\n /**\n * Whether the menu is opened.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The vertical (y-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n * \n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) verticalAlign?: VerticalAlignment;\n\n /**\n * The horizontal (x-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n * \n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) horizontalAlign?: HorizontalAlignment;\n\n /**\n * Affects the `horizontal` and `vertical` positioning so that the target element does not overlap with the anchor.\n * For example, when the `vertical` align is `top`, the top edge of the target will be rendered at the bottom \n * of the anchor down to the edge of the viewport.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) noOverlap?: boolean;\n\n /**\n * When set it closes the opened list when registering a click outside the list.\n * @attribute\n */\n @property({ type: Boolean }) closeOnOutsideClick?: boolean;\n\n /**\n * When set it makes the drop-down to match the width of the trigger.\n * Be careful as this may crop the content when the trigger is not wide enough.\n * @attribute\n */\n @property({ type: Boolean }) matchTriggerWidth?: boolean;\n\n /**\n * When set it closes the drop-down when `tab` button is pressed.\n * This is not a default behavior since the drop-down content can have its own logic\n * related to tab index.\n */\n @property({ type: Boolean }) closeOnTab?: boolean;\n\n /**\n * The first element located in the default slot.\n */\n protected get trigger(): HTMLElement | null {\n const { triggers } = this;\n if (!triggers || !triggers.length) {\n return null;\n }\n const [button] = triggers;\n return button;\n }\n\n /**\n * The first element located in the \"dropdown\" slot.\n */\n protected get dropdown(): HTMLElement | null {\n const { dropdowns } = this;\n if (!dropdowns || !dropdowns.length) {\n return null;\n }\n const [content] = dropdowns;\n return content;\n }\n\n @state() protected overlayPositioning?: StyleInfo;\n\n constructor() {\n super();\n this.dropdownOpenHandler = this.dropdownOpenHandler.bind(this);\n this.scrollHandler = this.scrollHandler.bind(this);\n this.clickHandler = this.clickHandler.bind(this);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('dropdownopen', this.dropdownOpenHandler);\n window.addEventListener('click', this.clickHandler, { capture: true });\n ScrollHelper.addListeners(this, this.scrollHandler);\n\n this.setAttribute('aria-haspopup', 'menu');\n this.setAttribute('aria-expanded', 'false');\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('dropdownopen', this.dropdownOpenHandler);\n window.removeEventListener('click', this.clickHandler, { capture: true });\n ScrollHelper.removeListeners(this);\n }\n\n protected dropdownOpenHandler(e: Event): void {\n if (e.composedPath()[0] === this) {\n return;\n }\n this.close();\n }\n\n protected updateExpanded(): void {\n this.setAttribute('aria-expanded', String(this.open));\n }\n\n protected triggerChanged(): void {\n const { trigger } = this;\n if (!trigger) {\n return;\n }\n this.decorateTrigger(trigger);\n }\n\n protected dropdownChanged(): void {\n const { dropdown } = this;\n if (!dropdown) {\n return;\n }\n this.decorateDropdown(dropdown);\n }\n\n /**\n * Decorates the trigger with aria attributes.\n */\n protected decorateTrigger(button: HTMLElement): void {\n button.setAttribute('aria-controls', this.menuId);\n button.setAttribute('tabindex', '0');\n if (button.id) {\n this.triggerId = button.id;\n } else {\n // eslint-disable-next-line no-param-reassign\n button.id = this.triggerId;\n }\n }\n\n protected decorateDropdown(list: HTMLElement): void {\n if (!list.hasAttribute('role')) {\n list.setAttribute('role', 'menu');\n }\n if (!list.hasAttribute('aria-labelledby')) {\n list.setAttribute('aria-labelledby', this.triggerId);\n }\n list.setAttribute('tabindex', '-1');\n // eslint-disable-next-line no-param-reassign\n list.id = this.menuId;\n }\n\n protected triggerClickHandler(): void {\n this.open = !this.open;\n this.updateExpanded();\n this.notifyOpen();\n }\n\n protected triggerKeyDownHandler(e: KeyboardEvent): void {\n if (['Enter', 'Space', 'ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault();\n this.open = true;\n this.updateExpanded();\n this.notifyOpen();\n }\n }\n\n protected contentKeyDownHandler(e: KeyboardEvent): void {\n if (e.defaultPrevented) {\n return;\n }\n if (e.code === 'Escape') {\n this.close();\n } else if (e.code === 'Tab') {\n if (this.closeOnTab) {\n this.close();\n }\n } else if (['Enter', 'Space'].includes(e.code)) {\n this.activate(e);\n }\n }\n\n protected contentClickHandler(e: PointerEvent): void {\n this.activate(e);\n }\n\n close(): void {\n this.open = false;\n this.updateExpanded();\n this.notifyOpen();\n }\n\n protected contentCloseHandler(e: Event): void {\n e.stopPropagation();\n this.close();\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n super.willUpdate(cp);\n if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {\n this.computePositioning();\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp);\n if (cp.has('open')) {\n this.toggleOpened();\n }\n }\n\n /**\n * Since the container for the dropdown content is positioned as fixed\n * we need to position the dropdown according to the configured rules.\n */\n protected computePositioning(): void {\n const { trigger, dropdown } = this;\n if (!trigger || !dropdown) {\n return;\n }\n this.overlayPositioning = ElementPositioning.positionOverlay(dropdown, trigger, {\n horizontal: this.horizontalAlign,\n vertical: this.verticalAlign,\n noOverlap: this.noOverlap,\n constrain: true,\n constrainPaddingY: 20,\n matchAnchorWidth: this.matchTriggerWidth,\n });\n }\n\n protected scrollHandler(): void {\n if (this.open) {\n this.computePositioning();\n }\n }\n\n protected clickHandler(e: Event): void {\n if (!this.open || !this.closeOnOutsideClick) {\n return;\n }\n const inside = e.composedPath().some(i => i === this);\n if (inside) {\n return;\n }\n this.close();\n }\n\n protected toggleOpened(): void {\n const { open } = this;\n if (open) {\n this.handleOpened();\n } else {\n this.handleClosed();\n }\n }\n\n protected handleOpened(): void {\n const { trigger, dropdown } = this;\n if (trigger) {\n trigger.removeAttribute('tabindex');\n }\n if (dropdown) {\n dropdown.setAttribute('tabindex', '0');\n dropdown.focus();\n }\n }\n\n protected handleClosed(): void {\n const { trigger, dropdown } = this;\n if (trigger) {\n trigger.setAttribute('tabindex', '0');\n if (this.matches(':focus-within')) {\n trigger.focus();\n }\n }\n if (dropdown) {\n dropdown.removeAttribute('tabindex');\n }\n }\n\n protected activate(e: Event): void {\n if (e.defaultPrevented) {\n return;\n }\n const path = e.composedPath();\n let item: HTMLElement | undefined;\n while (!item) {\n const next = path.shift() as Element;\n if (next === this) {\n break;\n }\n if (next.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n if (itemRole.includes(next.getAttribute('role') || '')) {\n item = next as HTMLElement;\n }\n }\n if (!item) {\n return;\n }\n const event = new CustomEvent<UiDropdownListSelection>('select', {\n cancelable: true,\n // composed: true,\n detail: {\n item,\n },\n })\n this.dispatchEvent(event);\n if (event.defaultPrevented) {\n return;\n }\n this.close();\n }\n\n protected notifyOpen(): void {\n this.dispatchEvent(new Event('open'));\n if (this.open) {\n this.dispatchEvent(new Event('dropdownopen', {\n bubbles: true,\n composed: true,\n cancelable: true,\n }));\n }\n }\n\n protected override render(): TemplateResult {\n const classes: ClassInfo = {\n container: true,\n open: this.open,\n };\n \n return html`\n <div class=\"${classMap(classes)}\">\n ${this.renderTrigger()}\n ${this.renderContent()}\n </div>\n `;\n }\n\n protected renderTrigger(): TemplateResult {\n return html`\n <div \n class=\"trigger\" \n @click=\"${this.triggerClickHandler}\" \n @keydown=\"${this.triggerKeyDownHandler}\"\n ><slot @slotchange=\"${this.triggerChanged}\"></slot></div>\n `;\n }\n\n protected renderContent(): TemplateResult {\n const contentStyles = this.overlayPositioning || {};\n return html`\n <div \n class=\"content\" \n style=\"${styleMap(contentStyles)}\"\n >\n <slot \n name=\"dropdown\" \n @slotchange=\"${this.dropdownChanged}\" \n @keydown=\"${this.contentKeyDownHandler}\" \n @click=\"${this.contentClickHandler}\"\n @close=\"${this.contentCloseHandler}\"\n ></slot>\n </div>\n `;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "UI for API Client.",
|
|
5
5
|
"license": "CC-BY-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"idb-keyval": "^6.1.0",
|
|
50
50
|
"lit": "^2.2.2",
|
|
51
51
|
"marked": "^4.0.15",
|
|
52
|
-
"monaco-editor": "^0.
|
|
52
|
+
"monaco-editor": "^0.36.0",
|
|
53
53
|
"pouchdb": "^7.3.0",
|
|
54
54
|
"prismjs": "^1.28.0"
|
|
55
55
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
+
import typography from '../../styles/m3/typography.module.js';
|
|
2
3
|
|
|
3
|
-
export default css`
|
|
4
|
+
export default [typography, css`
|
|
4
5
|
:host {
|
|
5
6
|
display: flex;
|
|
6
7
|
flex-direction: column;
|
|
@@ -32,7 +33,8 @@ http-body-text-editor {
|
|
|
32
33
|
background-color: #FFEB3B;
|
|
33
34
|
color: #000;
|
|
34
35
|
padding: 0 8px;
|
|
35
|
-
border-radius:
|
|
36
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
37
|
+
margin-bottom: 20px;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
.invalid-mime .warning-icon {
|
|
@@ -54,14 +56,6 @@ http-body-text-editor {
|
|
|
54
56
|
.form-info {
|
|
55
57
|
margin: 20px 0 0 0;
|
|
56
58
|
color: var(--md-sys-color-on-surface);
|
|
57
|
-
font-family: var(--md-sys-typescale-body-small-font-family-name);
|
|
58
|
-
font-style: var(--md-sys-typescale-body-small-font-family-style);
|
|
59
|
-
font-weight: var(--md-sys-typescale-body-small-font-weight);
|
|
60
|
-
font-size: var(--md-sys-typescale-body-small-font-size);
|
|
61
|
-
letter-spacing: var(--md-sys-typescale-body-small-tracking);
|
|
62
|
-
line-height: var(--md-sys-typescale-body-small-height);
|
|
63
|
-
text-transform: var(--md-sys-typescale-body-small-text-transform);
|
|
64
|
-
text-decoration: var(--md-sys-typescale-body-small-text-decoration);
|
|
65
59
|
}
|
|
66
60
|
|
|
67
61
|
.file-picker {
|
|
@@ -73,13 +67,5 @@ http-body-text-editor {
|
|
|
73
67
|
display: flex;
|
|
74
68
|
align-items: center;
|
|
75
69
|
margin-left: 8px;
|
|
76
|
-
font-family: var(--md-sys-typescale-label-medium-font-family-name);
|
|
77
|
-
font-style: var(--md-sys-typescale-label-medium-font-family-style);
|
|
78
|
-
font-weight: var(--md-sys-typescale-label-medium-font-weight);
|
|
79
|
-
font-size: var(--md-sys-typescale-label-medium-font-size);
|
|
80
|
-
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
81
|
-
line-height: var(--md-sys-typescale-label-medium-height);
|
|
82
|
-
text-transform: var(--md-sys-typescale-label-medium-text-transform);
|
|
83
|
-
text-decoration: var(--md-sys-typescale-label-medium-text-decoration);
|
|
84
70
|
}
|
|
85
|
-
|
|
71
|
+
`];
|
|
@@ -683,7 +683,7 @@ export default class BodyEditor extends ApiElement {
|
|
|
683
683
|
>
|
|
684
684
|
URL decode
|
|
685
685
|
</ui-button>
|
|
686
|
-
<label title="When set it automatically encodes the values before sending the request">
|
|
686
|
+
<label title="When set it automatically encodes the values before sending the request" class="label-medium">
|
|
687
687
|
<ui-checkbox .checked="${autoEncode}" @change="${this.handleUrlEncodeAutoChange}"></ui-checkbox>
|
|
688
688
|
Encode on send
|
|
689
689
|
</label>
|
|
@@ -803,7 +803,7 @@ export default class BodyEditor extends ApiElement {
|
|
|
803
803
|
|
|
804
804
|
protected renderFormInfo(): TemplateResult {
|
|
805
805
|
return html`
|
|
806
|
-
<p class="form-info">
|
|
806
|
+
<p class="form-info body-small">
|
|
807
807
|
Note that the content-type header will be added when the request is sent.
|
|
808
808
|
</p>
|
|
809
809
|
`;
|
|
@@ -829,7 +829,7 @@ export default class BodyEditor extends ApiElement {
|
|
|
829
829
|
const { value } = this;
|
|
830
830
|
const { size, name } = value as File;
|
|
831
831
|
return html`
|
|
832
|
-
<div class="file-info">
|
|
832
|
+
<div class="file-info label-medium">
|
|
833
833
|
<span class="file-name">${name || 'unknown name'}</span>
|
|
834
834
|
<span class="file-size">${size} bytes</span>
|
|
835
835
|
<ui-icon-button
|
|
@@ -850,7 +850,7 @@ export default class BodyEditor extends ApiElement {
|
|
|
850
850
|
}
|
|
851
851
|
const id = this.invalidMimeMessage;
|
|
852
852
|
return html`
|
|
853
|
-
<div class="invalid-mime">
|
|
853
|
+
<div class="invalid-mime body-medium">
|
|
854
854
|
<ui-icon icon="warning" class="warning-icon"></ui-icon>
|
|
855
855
|
${id === 1 ? this.renderFixableInvalidMime('multipart/form-data') : ''}
|
|
856
856
|
${id === 2 ? this.renderFixableInvalidMime('application/x-www-form-urlencoded') : ''}
|
|
@@ -863,7 +863,7 @@ export default class BodyEditor extends ApiElement {
|
|
|
863
863
|
*/
|
|
864
864
|
protected renderFixableInvalidMime(suggested: string): TemplateResult {
|
|
865
865
|
return html`
|
|
866
|
-
<p class="message">
|
|
866
|
+
<p class="message body-medium">
|
|
867
867
|
The <code>content-type</code> header has different value than <b>${suggested}</b>.
|
|
868
868
|
</p>
|
|
869
869
|
<ui-button class="fix" type="tonal" title="Updates the content type header for the request" @click="${this.autoFixMime}">Fix</ui-button>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CertificateFileKind, DataFileKind, FolderKind, IFile, ProjectKind } from "@api-client/core/build/browser.js";
|
|
1
|
+
import { CertificateFileKind, DataFileKind, FolderKind, IFile, ProjectKind, TrashEntry } from "@api-client/core/build/browser.js";
|
|
2
2
|
import { IconType } from "../../ui/icons/Icons.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,7 +19,7 @@ export function filesSortFunction(a: IFile, b: IFile): number {
|
|
|
19
19
|
return b.lastModified.time - a.lastModified.time;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function fileIcon(item: IFile): IconType | undefined {
|
|
22
|
+
export function fileIcon(item: IFile | TrashEntry): IconType | undefined {
|
|
23
23
|
let icon: IconType | undefined;
|
|
24
24
|
switch (item.kind) {
|
|
25
25
|
case DataFileKind: icon = 'schema'; break;
|
|
@@ -12,7 +12,7 @@ export class Cursor {
|
|
|
12
12
|
async decodeCursor(cursor: string): Promise<IListState> {
|
|
13
13
|
let result: IListState;
|
|
14
14
|
try {
|
|
15
|
-
const decoded = atob(cursor);
|
|
15
|
+
const decoded = window.atob(cursor);
|
|
16
16
|
result = JSON.parse(decoded);
|
|
17
17
|
} catch (e) {
|
|
18
18
|
throw new ApiError(`Invalid page cursor.`, 400);
|
|
@@ -27,6 +27,6 @@ export class Cursor {
|
|
|
27
27
|
*/
|
|
28
28
|
async encodeCursor(state: object): Promise<string> {
|
|
29
29
|
const str = JSON.stringify(state);
|
|
30
|
-
return btoa(str);
|
|
30
|
+
return window.btoa(str);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -3,7 +3,7 @@ import { ContextListOptions } from '@api-client/core/build/browser.js';
|
|
|
3
3
|
import { HttpClientPersistance } from "./HttpClientPersistance.js";
|
|
4
4
|
import { Cursor } from './Cursor.js';
|
|
5
5
|
import { IListState } from './State.js';
|
|
6
|
-
import { HttpClientDB,
|
|
6
|
+
import { HttpClientDB, StoreName } from './types.js';
|
|
7
7
|
import { IdbUrlHistory } from './idb/IdbUrlHistory.js';
|
|
8
8
|
import { IdbWsHistory } from './idb/IdbWsHistory.js';
|
|
9
9
|
import { IdbProjectUi } from './idb/IdbProjectUi.js';
|
|
@@ -132,9 +132,7 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
|
|
|
132
132
|
const dbResult = await openDB<HttpClientDB>('HttpClient', 1, {
|
|
133
133
|
upgrade: (db) => {
|
|
134
134
|
const stores: StoreName[] = [
|
|
135
|
-
'UrlHistory', 'WsHistory',
|
|
136
|
-
'AuthCache', 'Hosts', 'Environments',
|
|
137
|
-
'ProjectUi',
|
|
135
|
+
'UrlHistory', 'WsHistory', 'ProjectUi',
|
|
138
136
|
];
|
|
139
137
|
const names = db.objectStoreNames;
|
|
140
138
|
for (const name of stores) {
|
|
@@ -143,7 +141,7 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
|
|
|
143
141
|
if (typeof this[fnName] === 'function') {
|
|
144
142
|
this[fnName](db, exists);
|
|
145
143
|
} else if (!exists) {
|
|
146
|
-
this._defaultUpgradeHandler(name as
|
|
144
|
+
this._defaultUpgradeHandler(name as StoreName, db, exists);
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
147
|
},
|
|
@@ -157,13 +155,11 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
|
|
|
157
155
|
* @param name The store name to create
|
|
158
156
|
* @param db The handler to the database
|
|
159
157
|
*/
|
|
160
|
-
private _defaultUpgradeHandler(name:
|
|
158
|
+
private _defaultUpgradeHandler(name: StoreName, db: IDBPDatabase<HttpClientDB>, storeExists: boolean): void {
|
|
161
159
|
if (storeExists) {
|
|
162
160
|
return;
|
|
163
161
|
}
|
|
164
|
-
|
|
165
|
-
const typed = store as IDBPObjectStore<HttpClientDB, SpaceStoreNames[], SpaceStoreNames, 'versionchange'>;
|
|
166
|
-
typed.createIndex('space', 'meta.space', { unique: false });
|
|
162
|
+
db.createObjectStore(name, { keyPath: 'data.key' });
|
|
167
163
|
}
|
|
168
164
|
|
|
169
165
|
private _UrlHistoryUpgradeHandler(db: IDBPDatabase<HttpClientDB>, storeExists: boolean): void {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextSpaceListOptions
|
|
1
|
+
import { ContextSpaceListOptions } from "@api-client/core/build/browser.js";
|
|
2
2
|
|
|
3
3
|
export interface CursorState {
|
|
4
4
|
/**
|
|
@@ -14,7 +14,3 @@ export interface CursorState {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type IListState = ContextSpaceListOptions & CursorState;
|
|
17
|
-
|
|
18
|
-
export type HistoryState = HistoryListOptions & CursorState;
|
|
19
|
-
|
|
20
|
-
export type ProjectRunsState = IProjectExecutionListOptions & CursorState;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IDBPDatabase } from "idb";
|
|
2
|
-
import { HttpClientDB
|
|
3
|
-
import { IListState } from "../State.js";
|
|
2
|
+
import { HttpClientDB } from "../types.js";
|
|
4
3
|
import { HttpClientIdbDatabase } from "../HttpClientIdbDatabase.js";
|
|
5
4
|
|
|
6
5
|
export abstract class IdbStore {
|
|
@@ -24,53 +23,4 @@ export abstract class IdbStore {
|
|
|
24
23
|
async cleanup(): Promise<void> {
|
|
25
24
|
//
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Lists entities that uses `IStoredEntity` format.
|
|
30
|
-
* @param db A reference to the database
|
|
31
|
-
* @param storeName The name of the store to query.
|
|
32
|
-
* @param opts Query options.
|
|
33
|
-
* @returns The list of listed objects.
|
|
34
|
-
*/
|
|
35
|
-
protected async listStoredEntities(db: IDBPDatabase<HttpClientDB>, storeName: StoreName, opts: IListState): Promise<unknown[]> {
|
|
36
|
-
let adv = opts.skip || 0;
|
|
37
|
-
const { descending, limit = this.parent.defaultLimit, lastKey, space } = opts;
|
|
38
|
-
const tx = db.transaction(storeName, 'readonly');
|
|
39
|
-
const dir = descending === true ? 'prev' : 'next';
|
|
40
|
-
let keyFound = false;
|
|
41
|
-
const items: unknown[] = [];
|
|
42
|
-
for await (const cursor of tx.store.iterate(null, dir)) {
|
|
43
|
-
const info = cursor.value as IStoredEntity;
|
|
44
|
-
if (!info.meta || !info.data) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
const { meta, data } = info;
|
|
48
|
-
if (space && meta.space !== space) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const { key } = data as { key: string };
|
|
52
|
-
if (!key) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (lastKey && !keyFound) {
|
|
56
|
-
if (key !== lastKey) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
keyFound = true;
|
|
60
|
-
}
|
|
61
|
-
if (adv) {
|
|
62
|
-
cursor.advance(adv);
|
|
63
|
-
adv = 0;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (meta.deleted) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
items.push(data);
|
|
70
|
-
if (items.length >= limit) {
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return items;
|
|
75
|
-
}
|
|
76
26
|
}
|
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IAuthorizationData, IEnvironment, IHostRule,
|
|
3
|
-
IRequestUiMeta, IUrl,
|
|
4
|
-
} from '@api-client/core/build/browser.js';
|
|
1
|
+
import { IRequestUiMeta, IUrl } from '@api-client/core/build/browser.js';
|
|
5
2
|
import { DBSchema } from 'idb/with-async-ittr';
|
|
6
3
|
|
|
7
|
-
export interface IEntityMeta {
|
|
8
|
-
/**
|
|
9
|
-
* The space this object belongs to.
|
|
10
|
-
*/
|
|
11
|
-
space: string;
|
|
12
|
-
/**
|
|
13
|
-
* Whether the entity is deleted.
|
|
14
|
-
*/
|
|
15
|
-
deleted?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* A timestamp when the entity was deleted.
|
|
18
|
-
* Can be used to cleanup the store after some time.
|
|
19
|
-
*/
|
|
20
|
-
deleteTime?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface IStoredEntity<T = unknown> {
|
|
24
|
-
meta: IEntityMeta;
|
|
25
|
-
data: T;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface IGetOptions {
|
|
29
|
-
/**
|
|
30
|
-
* Whether to return a deleted document.
|
|
31
|
-
*/
|
|
32
|
-
deleted?: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface IStoredMedia<T = unknown> {
|
|
36
|
-
key: string;
|
|
37
|
-
value: T;
|
|
38
|
-
mime: string;
|
|
39
|
-
deleted?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
4
|
export interface IStoredRequestUi {
|
|
43
5
|
data: IRequestUiMeta;
|
|
44
6
|
meta: { key: string; project: string; }
|
|
45
7
|
}
|
|
46
8
|
|
|
47
|
-
export type
|
|
48
|
-
export type GeneralStoreNames = 'UrlHistory' | 'WsHistory' | 'ProjectUi';
|
|
49
|
-
export type StoreName = GeneralStoreNames | SpaceStoreNames;
|
|
9
|
+
export type StoreName = 'UrlHistory' | 'WsHistory' | 'ProjectUi';
|
|
50
10
|
|
|
51
11
|
export interface HttpClientDB extends DBSchema {
|
|
52
12
|
UrlHistory: {
|
|
@@ -57,21 +17,6 @@ export interface HttpClientDB extends DBSchema {
|
|
|
57
17
|
key: string;
|
|
58
18
|
value: IUrl;
|
|
59
19
|
}
|
|
60
|
-
AuthCache: {
|
|
61
|
-
key: string;
|
|
62
|
-
value: IStoredEntity<IAuthorizationData>;
|
|
63
|
-
indexes: { 'space': string };
|
|
64
|
-
}
|
|
65
|
-
Hosts: {
|
|
66
|
-
key: string;
|
|
67
|
-
value: IStoredEntity<IHostRule>;
|
|
68
|
-
indexes: { 'space': string };
|
|
69
|
-
}
|
|
70
|
-
Environments: {
|
|
71
|
-
key: string;
|
|
72
|
-
value: IStoredEntity<IEnvironment>;
|
|
73
|
-
indexes: { 'space': string };
|
|
74
|
-
}
|
|
75
20
|
ProjectUi: {
|
|
76
21
|
key: string[];
|
|
77
22
|
value: IStoredRequestUi;
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,9 @@ export * from './bindings/base/ProxyBindings.js';
|
|
|
31
31
|
export * from './bindings/base/SharedWorkerThread.js';
|
|
32
32
|
export * from './bindings/base/StoreBindings.js';
|
|
33
33
|
|
|
34
|
+
// HTTP Client IDB
|
|
35
|
+
export * from './http-client/store/HttpClientIdbDatabase.js';
|
|
36
|
+
|
|
34
37
|
// Events
|
|
35
38
|
|
|
36
39
|
export { Events } from './events/Events.js';
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { html, TemplateResult, CSSResult, nothing } from 'lit';
|
|
3
3
|
import { BroadcastCreatedEvent, BroadcastEvent, IFile, ISpace, uuidV4 } from '@api-client/core/build/browser.js';
|
|
4
4
|
import { ApplicationInit, ApplicationScreen } from '../ApplicationScreen.js';
|
|
5
|
-
import { IRoute, IRouteResult } from '../../mixins/RouteMixin.js';
|
|
6
5
|
import pageStyles from './ApiClient.styles.js';
|
|
7
6
|
import globalStyles from '../../styles/global-styles.js';
|
|
8
7
|
import typography from '../../styles/m3/typography.module.js';
|
|
@@ -11,15 +10,16 @@ import dialogStyles from '../../styles/m3/dialog.module.js';
|
|
|
11
10
|
import { navigate } from '../../lib/route.js';
|
|
12
11
|
import { reactive } from '../../lib/decorators.js';
|
|
13
12
|
import { DataTable } from '../../ui/table/DataTable.js';
|
|
14
|
-
import Input from '../../ui/input/Input.js';
|
|
15
13
|
import { FilesPage } from './pages/Files.page.js';
|
|
16
14
|
import { SharedPage } from './pages/Shared.page.js';
|
|
17
15
|
import { TrashPage } from './pages/Trash.page.js';
|
|
18
16
|
import { SettingsPage } from './pages/Settings.page.js';
|
|
19
|
-
import {
|
|
17
|
+
import type { IRoute, IRouteResult } from '../../mixins/RouteMixin.js';
|
|
18
|
+
import type Input from '../../ui/input/Input.js';
|
|
19
|
+
import type { HttpClientStoreBindings } from '../../bindings/base/HttpClientStoreBindings.js';
|
|
20
|
+
import type { NavigationBindings } from '../../bindings/base/NavigationBindings.js';
|
|
21
|
+
import type { FileBindings } from '../../bindings/base/FileBindings.js';
|
|
20
22
|
import { StoreBroadcast } from '../../http-client/store/StoreBroadcast.js';
|
|
21
|
-
import { NavigationBindings } from '../../bindings/base/NavigationBindings.js';
|
|
22
|
-
import { FileBindings } from '../../bindings/base/FileBindings.js';
|
|
23
23
|
import AppInfo from './AppInfo.js';
|
|
24
24
|
import '../../define/ui/ui-button.js';
|
|
25
25
|
import '../../define/app-navigation-item.js';
|
|
@@ -196,7 +196,7 @@ export default class ApiClientScreen extends ApplicationScreen {
|
|
|
196
196
|
protected async createLastSpaceStoreKey(): Promise<string | undefined> {
|
|
197
197
|
try {
|
|
198
198
|
const env = await this.bindings.store.global.get();
|
|
199
|
-
return `
|
|
199
|
+
return `api-client.latest.space.${env.key}`;
|
|
200
200
|
} catch (_) {
|
|
201
201
|
return undefined;
|
|
202
202
|
}
|
|
@@ -547,7 +547,7 @@ export default class ApiClientScreen extends ApplicationScreen {
|
|
|
547
547
|
const { page, isSingleUser } = this;
|
|
548
548
|
return html`
|
|
549
549
|
<nav aria-label="Main">
|
|
550
|
-
<h1 class="title-small nav-title">
|
|
550
|
+
<h1 class="title-small nav-title">API Client</h1>
|
|
551
551
|
<ol class="nav-list">
|
|
552
552
|
<li>
|
|
553
553
|
<app-navigation-item data-page="files" .selected=${page === 'files'} @click="${this.mainNavHandler}">
|