2022-04-02 04:06:48 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// 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">
|
|
|
|
import type { Asset, IntlString } from '@anticrm/platform'
|
|
|
|
import { translate } from '@anticrm/platform'
|
2022-04-08 06:27:02 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
2022-04-14 11:03:49 +00:00
|
|
|
import { Icon, Label } from '..'
|
2022-04-02 04:06:48 +00:00
|
|
|
|
|
|
|
export let placeholder: IntlString | undefined = undefined
|
|
|
|
export let placeholderParam: any | undefined = undefined
|
|
|
|
export let searchable: boolean = false
|
2022-04-29 05:27:17 +00:00
|
|
|
export let value: Array<{ id: number | string; icon: Asset; label?: IntlString; text?: string }>
|
2022-04-02 04:06:48 +00:00
|
|
|
|
|
|
|
let search: string = ''
|
|
|
|
|
|
|
|
let phTraslate: string = ''
|
2022-04-29 05:27:17 +00:00
|
|
|
$: if (placeholder) {
|
|
|
|
translate(placeholder, placeholderParam ?? {}).then((res) => {
|
|
|
|
phTraslate = res
|
|
|
|
})
|
|
|
|
}
|
2022-04-02 04:06:48 +00:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="selectPopup">
|
|
|
|
{#if searchable}
|
|
|
|
<div class="header">
|
2022-04-29 05:27:17 +00:00
|
|
|
<input type="text" bind:value={search} placeholder={phTraslate} on:input={(ev) => {}} on:change />
|
2022-04-02 04:06:48 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
<div class="scroll">
|
|
|
|
<div class="box">
|
2022-04-29 05:27:17 +00:00
|
|
|
{#each value.filter((el) => (el.label ?? el.text ?? '').toLowerCase().includes(search.toLowerCase())) as item}
|
|
|
|
<button
|
|
|
|
class="menu-item"
|
|
|
|
on:click={() => {
|
|
|
|
dispatch('close', item.id)
|
|
|
|
}}
|
|
|
|
>
|
2022-04-14 11:03:49 +00:00
|
|
|
<div class="icon"><Icon icon={item.icon} size={'small'} /></div>
|
2022-04-23 16:59:57 +00:00
|
|
|
<span class="label">
|
|
|
|
{#if item.label}
|
|
|
|
<Label label={item.label} />
|
|
|
|
{:else if item.text}
|
|
|
|
<span>{item.text}</span>
|
|
|
|
{/if}
|
|
|
|
</span>
|
2022-04-02 04:06:48 +00:00
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|