@dosgato/dialog 1.3.9 → 1.4.1

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.
@@ -1,20 +1,21 @@
1
1
  <script lang="ts" generics="T extends TreeItemFromDB = TreeItemFromDB">
2
- import type { IconifyIcon } from '@iconify/svelte'
3
- import { get } from 'txstate-utils'
2
+ import { get, toArray } from 'txstate-utils'
4
3
  import { Icon } from '..'
5
4
  import type { TreeHeader, TreeItemFromDB, TypedTreeItem } from './treestore'
6
5
 
7
6
  export let header: TreeHeader<T>
8
7
  export let item: TypedTreeItem<T>
9
- $: icon = (typeof header.icon === 'function' ? header.icon(item) : header.icon) as { icon: IconifyIcon, label: string } | undefined
8
+ $: icons = toArray((typeof header.icon === 'function' ? header.icon(item) : header.icon))
9
+ $: leadingIcons = icons.filter(i => !i.trailing)
10
+ $: trailingIcons = icons.filter(i => i.trailing)
10
11
  $: headerComponent = header.component as any
11
12
  </script>
12
13
 
13
- {#if icon}
14
+ {#each leadingIcons as icon}
14
15
  <span class="icon">
15
- <Icon icon={icon.icon} tooltip={icon.label} inline width="1.5em" hiddenLabel={icon.label} />
16
+ <Icon icon={icon.icon} tooltip={icon.tooltip} class={icon.class} inline width="1.5em" hiddenLabel={icon.label} />
16
17
  </span>
17
- {/if}
18
+ {/each}
18
19
  {#if header.component}
19
20
  <svelte:component this={headerComponent} {item} {header} />
20
21
  {:else if header.render}
@@ -22,3 +23,20 @@
22
23
  {:else if header.get}
23
24
  {#if get(item, header.get)}{get(item, header.get)}{:else}&nbsp;{/if}
24
25
  {/if}
26
+ {#if trailingIcons.length}
27
+ <span class="trailing-icons">
28
+ {#each trailingIcons as icon}
29
+ <span class="icon">
30
+ <Icon icon={icon.icon} tooltip={icon.tooltip} class={icon.class} inline width="1.5em" hiddenLabel={icon.label} />
31
+ </span>
32
+ {/each}
33
+ </span>
34
+ {/if}
35
+
36
+ <style>
37
+ .trailing-icons {
38
+ margin-left: 10px;
39
+ display: inline-flex;
40
+ align-items: center;
41
+ }
42
+ </style>
@@ -35,18 +35,19 @@ export type DropEffectFn<T extends TreeItemFromDB> = (selectedItems: TypedTreeIt
35
35
  export type MoveHandlerFn<T extends TreeItemFromDB> = (selectedItems: TypedTreeItem<T>[], dropTarget: TypedTreeItem<T>, above: boolean) => boolean | Promise<boolean>;
36
36
  export type CopyHandlerFn<T extends TreeItemFromDB> = (selectedItems: TypedTreeItem<T>[], dropTarget: TypedTreeItem<T>, above: boolean, userWantsRecursive: boolean | undefined) => boolean | Promise<boolean>;
37
37
  export type SearchableFn<T extends TreeItemFromDB> = (item: TypedTreeItem<T>) => string[];
38
+ export interface TreeIcon {
39
+ icon: IconifyIcon;
40
+ label?: string;
41
+ class?: string;
42
+ trailing?: boolean;
43
+ tooltip?: string;
44
+ }
38
45
  export interface TreeHeader<T extends TreeItemFromDB> {
39
46
  id: string;
40
47
  label: string;
41
48
  fixed?: string;
42
49
  grow?: number;
43
- icon?: {
44
- icon: IconifyIcon;
45
- label?: string;
46
- } | ((item: TypedTreeItem<T>) => {
47
- icon: IconifyIcon;
48
- label?: string;
49
- } | undefined);
50
+ icon?: TreeIcon[] | TreeIcon | ((item: TypedTreeItem<T>) => TreeIcon[] | TreeIcon | undefined);
50
51
  get?: string;
51
52
  render?: (item: TypedTreeItem<T>) => string;
52
53
  component?: SvelteComponent;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dosgato/dialog",
3
3
  "description": "A component library for building forms that edit a JSON document.",
4
- "version": "1.3.9",
4
+ "version": "1.4.1",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
7
7
  "dev": "vite dev --force",