2022-02-07 22:34:53 +08:00
|
|
|
<script lang="ts">
|
2024-01-30 08:51:22 +08:00
|
|
|
export let value: string | string[] | null;
|
2023-01-18 04:47:40 +08:00
|
|
|
export let type: "gallery" | "table";
|
|
|
|
export let selected = false;
|
2024-01-11 08:35:25 +08:00
|
|
|
export let choices: [string, string | number][];
|
|
|
|
|
2024-01-30 08:51:22 +08:00
|
|
|
let value_array = value ? (Array.isArray(value) ? value : [value]) : [];
|
2024-01-11 08:35:25 +08:00
|
|
|
let names = value_array
|
|
|
|
.map(
|
|
|
|
(val) =>
|
|
|
|
(
|
|
|
|
choices.find((pair) => pair[1] === val) as
|
|
|
|
| [string, string | number]
|
|
|
|
| undefined
|
|
|
|
)?.[0]
|
|
|
|
)
|
|
|
|
.filter((name) => name !== undefined);
|
|
|
|
let names_string = names.join(", ");
|
2022-02-01 21:45:55 +08:00
|
|
|
</script>
|
2022-02-01 23:46:50 +08:00
|
|
|
|
2023-01-18 04:47:40 +08:00
|
|
|
<div
|
|
|
|
class:table={type === "table"}
|
|
|
|
class:gallery={type === "gallery"}
|
|
|
|
class:selected
|
|
|
|
>
|
2024-01-11 08:35:25 +08:00
|
|
|
{names_string}
|
2023-01-18 04:47:40 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.gallery {
|
|
|
|
padding: var(--size-1) var(--size-2);
|
|
|
|
}
|
|
|
|
</style>
|