2021-08-07 14:49:14 +00:00
|
|
|
<!--
|
2022-04-28 12:03:10 +00:00
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
2021-08-07 14:49:14 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2023-03-09 09:05:42 +00:00
|
|
|
import { getName, Person } from '@hcengineering/contact'
|
2023-03-22 02:48:57 +00:00
|
|
|
import { getEmbeddedLabel, IntlString } from '@hcengineering/platform'
|
2023-04-23 17:37:24 +00:00
|
|
|
import type { LabelAndProps, IconSize } from '@hcengineering/ui'
|
2023-01-14 10:54:54 +00:00
|
|
|
import { PersonLabelTooltip } from '..'
|
2022-04-08 18:05:49 +00:00
|
|
|
import PersonContent from './PersonContent.svelte'
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2022-06-07 08:57:05 +00:00
|
|
|
export let value: Person | null | undefined
|
2022-04-28 12:03:10 +00:00
|
|
|
export let inline = false
|
2022-08-25 03:11:10 +00:00
|
|
|
export let enlargedText = false
|
2022-04-28 12:03:10 +00:00
|
|
|
export let isInteractive = true
|
2022-05-12 07:05:26 +00:00
|
|
|
export let shouldShowAvatar = true
|
2022-04-08 18:05:49 +00:00
|
|
|
export let shouldShowName = true
|
|
|
|
export let shouldShowPlaceholder = false
|
2022-04-28 12:03:10 +00:00
|
|
|
export let defaultName: IntlString | undefined = undefined
|
2023-03-17 03:52:32 +00:00
|
|
|
export let statusLabel: IntlString | undefined = undefined
|
2023-01-14 10:54:54 +00:00
|
|
|
export let tooltipLabels: PersonLabelTooltip | undefined = undefined
|
2023-04-23 17:37:24 +00:00
|
|
|
export let avatarSize: IconSize = 'x-small'
|
2022-04-28 12:03:10 +00:00
|
|
|
export let onEdit: ((event: MouseEvent) => void) | undefined = undefined
|
2023-03-14 05:08:23 +00:00
|
|
|
export let element: HTMLElement | undefined = undefined
|
2023-04-23 17:37:24 +00:00
|
|
|
export let colorInherit: boolean = false
|
|
|
|
export let accent: boolean = false
|
2023-01-14 10:54:54 +00:00
|
|
|
|
|
|
|
function getTooltip (
|
|
|
|
tooltipLabels: PersonLabelTooltip | undefined,
|
|
|
|
value: Person | null | undefined
|
|
|
|
): LabelAndProps | undefined {
|
|
|
|
if (!tooltipLabels) {
|
|
|
|
return !value
|
|
|
|
? undefined
|
|
|
|
: {
|
2023-03-22 02:48:57 +00:00
|
|
|
label: getEmbeddedLabel(getName(value))
|
2023-01-14 10:54:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const component = value ? tooltipLabels.component : undefined
|
|
|
|
const label = value
|
|
|
|
? tooltipLabels.personLabel
|
|
|
|
? tooltipLabels.personLabel
|
2023-03-22 02:48:57 +00:00
|
|
|
: getEmbeddedLabel(getName(value))
|
2023-01-14 10:54:54 +00:00
|
|
|
: undefined
|
2023-03-24 04:53:55 +00:00
|
|
|
const props = tooltipLabels.props ? tooltipLabels.props : value ? { value: getName(value) } : undefined
|
2023-01-14 10:54:54 +00:00
|
|
|
return {
|
|
|
|
component,
|
|
|
|
label,
|
|
|
|
props
|
|
|
|
}
|
|
|
|
}
|
2021-08-07 14:49:14 +00:00
|
|
|
</script>
|
|
|
|
|
2022-04-08 18:05:49 +00:00
|
|
|
{#if value || shouldShowPlaceholder}
|
2022-06-07 04:10:34 +00:00
|
|
|
<PersonContent
|
2023-01-14 10:54:54 +00:00
|
|
|
showTooltip={getTooltip(tooltipLabels, value)}
|
2022-06-07 04:10:34 +00:00
|
|
|
{value}
|
|
|
|
{inline}
|
|
|
|
{onEdit}
|
|
|
|
{avatarSize}
|
|
|
|
{defaultName}
|
|
|
|
{isInteractive}
|
|
|
|
{shouldShowAvatar}
|
|
|
|
{shouldShowName}
|
|
|
|
{shouldShowPlaceholder}
|
2022-08-25 03:11:10 +00:00
|
|
|
{enlargedText}
|
2023-03-17 03:52:32 +00:00
|
|
|
{statusLabel}
|
2023-04-23 17:37:24 +00:00
|
|
|
{colorInherit}
|
|
|
|
{accent}
|
2023-03-14 05:08:23 +00:00
|
|
|
bind:element
|
2022-06-07 04:10:34 +00:00
|
|
|
/>
|
2021-12-06 15:15:36 +00:00
|
|
|
{/if}
|