From fee0f28b074a578e70d3f1b9bb231f8577685504 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 12 May 2022 11:10:52 +0700 Subject: [PATCH] Basic focus management support (#1719) Signed-off-by: Andrey Sobolev --- models/view/src/index.ts | 4 +- .../presentation/src/components/Card.svelte | 4 +- .../src/components/SpaceSelect.svelte | 8 +- .../src/components/SpacesPopup.svelte | 63 ++++++++-- .../src/components/UserBox.svelte | 6 +- .../src/components/UsersPopup.svelte | 102 +++++++++++----- packages/ui/src/components/Button.svelte | 37 ++++-- packages/ui/src/components/ColorPopup.svelte | 82 ++++++++++--- packages/ui/src/components/EditBox.svelte | 28 ++++- .../ui/src/components/FocusHandler.svelte | 16 +++ .../ui}/src/components/ListView.svelte | 0 packages/ui/src/components/Menu.svelte | 7 +- .../ui/src/components/PanelInstance.svelte | 2 +- .../ui/src/components/TooltipInstance.svelte | 9 +- packages/ui/src/focus.ts | 115 ++++++++++++++++++ packages/ui/src/index.ts | 16 ++- packages/ui/src/tooltips.ts | 17 +-- packages/ui/src/types.ts | 2 +- .../src/components/ChannelEditor.svelte | 23 +++- .../src/components/ChannelsDropdown.svelte | 79 ++++++++---- plugins/recruit-assets/lang/en.json | 5 +- plugins/recruit-assets/lang/ru.json | 3 +- .../src/components/CreateApplication.svelte | 9 ++ .../src/components/CreateCandidate.svelte | 60 +++++++-- .../src/components/YesNo.svelte | 7 +- plugins/recruit-resources/src/plugin.ts | 3 +- .../src/components/ActionsPopup.svelte | 2 +- .../src/components/Workbench.svelte | 2 +- 28 files changed, 573 insertions(+), 138 deletions(-) create mode 100644 packages/ui/src/components/FocusHandler.svelte rename {plugins/view-resources => packages/ui}/src/components/ListView.svelte (100%) create mode 100644 packages/ui/src/focus.ts diff --git a/models/view/src/index.ts b/models/view/src/index.ts index c0620be313..4495c0e6ab 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -389,7 +389,7 @@ export function createModel (builder: Builder): void { action: view.actionImpl.SelectItem, keyBinding: ['keyX'], category: view.category.General, - input: 'focus', + input: 'any', target: core.class.Doc, context: { mode: 'browser' } }, @@ -434,7 +434,7 @@ export function createModel (builder: Builder): void { input: 'none', target: core.class.Doc, context: { - mode: ['workbench', 'browser', 'popup', 'panel', 'editor', 'input'] + mode: ['workbench', 'browser', 'panel', 'editor', 'input'] } }, view.action.ShowActions diff --git a/packages/presentation/src/components/Card.svelte b/packages/presentation/src/components/Card.svelte index 9c4dc8914b..36f6d5497a 100644 --- a/packages/presentation/src/components/Card.svelte +++ b/packages/presentation/src/components/Card.svelte @@ -45,7 +45,7 @@ {#if $$slots.space} {:else if spaceClass && spaceLabel && spacePlaceholder} - + {/if} {/if} @@ -53,6 +53,7 @@
- {/each} + handleSelection(evt, evt.detail)} + > + + {@const space = objects[item]} + + + +
diff --git a/packages/presentation/src/components/UserBox.svelte b/packages/presentation/src/components/UserBox.svelte index 251e127e19..e72843021e 100644 --- a/packages/presentation/src/components/UserBox.svelte +++ b/packages/presentation/src/components/UserBox.svelte @@ -17,7 +17,7 @@ import contact, { Contact, formatName } from '@anticrm/contact' import type { Class, Ref } from '@anticrm/core' import type { IntlString } from '@anticrm/platform' - import type { TooltipAlignment, ButtonKind, ButtonSize } from '@anticrm/ui' + import { TooltipAlignment, ButtonKind, ButtonSize, getFocusManager } from '@anticrm/ui' import { Button, Label, showPopup, Tooltip } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import presentation from '..' @@ -38,6 +38,7 @@ export let justify: 'left' | 'center' = 'center' export let width: string | undefined = undefined export let labelDirection: TooltipAlignment | undefined = undefined + export let focusIndex = -1 const dispatch = createEventDispatcher() @@ -56,11 +57,13 @@ const isPerson = client.getHierarchy().isDerived(obj._class, contact.class.Person) return isPerson ? formatName(obj.name) : obj.name } + const mgr = getFocusManager()
- {/each} + {/if} +
+ {/if} + + + diff --git a/packages/ui/src/components/Button.svelte b/packages/ui/src/components/Button.svelte index ac70343d49..7471539544 100644 --- a/packages/ui/src/components/Button.svelte +++ b/packages/ui/src/components/Button.svelte @@ -13,12 +13,13 @@ // limitations under the License. --> + - {/each} + handleSelection(evt, evt.detail)} + > + + {@const itemValue = objects[item]} + + + diff --git a/packages/ui/src/components/EditBox.svelte b/packages/ui/src/components/EditBox.svelte index 8ad4d73d01..4bf71869c1 100644 --- a/packages/ui/src/components/EditBox.svelte +++ b/packages/ui/src/components/EditBox.svelte @@ -13,13 +13,14 @@ // limitations under the License. -->
+
{#if label}
{/if}
diff --git a/packages/ui/src/components/FocusHandler.svelte b/packages/ui/src/components/FocusHandler.svelte new file mode 100644 index 0000000000..276c227176 --- /dev/null +++ b/packages/ui/src/components/FocusHandler.svelte @@ -0,0 +1,16 @@ + + + handleKey(evt)} /> + diff --git a/plugins/view-resources/src/components/ListView.svelte b/packages/ui/src/components/ListView.svelte similarity index 100% rename from plugins/view-resources/src/components/ListView.svelte rename to packages/ui/src/components/ListView.svelte diff --git a/packages/ui/src/components/Menu.svelte b/packages/ui/src/components/Menu.svelte index 09f4ec94b2..63f4ae645e 100644 --- a/packages/ui/src/components/Menu.svelte +++ b/packages/ui/src/components/Menu.svelte @@ -13,11 +13,11 @@ // limitations under the License. --> +
{#if editable}
- - - + + + {#if resume.uuid} - { showPopup(PDFViewer, { file: resume.uuid, name: resume.name }, 'right') }} - /> + > + + {resume.name} + + {:else} {#if loading} {:else} - { inputFile.click() diff --git a/plugins/recruit-resources/src/components/YesNo.svelte b/plugins/recruit-resources/src/components/YesNo.svelte index 85e7069329..e9e5beed4d 100644 --- a/plugins/recruit-resources/src/components/YesNo.svelte +++ b/plugins/recruit-resources/src/components/YesNo.svelte @@ -14,8 +14,8 @@ -->
+ @@ -448,7 +449,6 @@ - {:else} No client