@dosgato/dialog 0.0.62 → 0.0.63

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.
@@ -5,8 +5,7 @@ export let hiddenLabel = undefined;
5
5
  export let inline = false;
6
6
  export let width = '1em';
7
7
  export let height = width;
8
- export let vAlign = 'middle';
9
8
  $: icon = iconForMime(mime);
10
9
  </script>
11
10
 
12
- <Icon {icon} {hiddenLabel} {inline} {width} {height} {vAlign} />
11
+ <Icon {icon} {hiddenLabel} {inline} {width} {height} />
@@ -6,7 +6,6 @@ declare const __propDef: {
6
6
  inline?: boolean | undefined;
7
7
  width?: string | number | undefined;
8
8
  height?: string | number | undefined;
9
- vAlign?: "top" | "bottom" | "middle" | undefined;
10
9
  };
11
10
  events: {
12
11
  [evt: string]: CustomEvent<any>;
package/dist/Icon.svelte CHANGED
@@ -5,17 +5,20 @@
5
5
  -->
6
6
  <script>import Icon from '@iconify/svelte/dist/OfflineIcon.svelte';
7
7
  import { ScreenReaderOnly } from '@txstate-mws/svelte-components';
8
+ import Tooltip from './Tooltip.svelte';
8
9
  export let icon;
9
10
  /** Label used in a `<ScreenReaderOnly>`. */
10
11
  export let hiddenLabel = undefined;
11
12
  export let inline = false;
12
13
  export let width = '1em';
13
14
  export let height = width;
14
- export let vAlign = 'middle';
15
+ export let tooltip = undefined;
15
16
  </script>
16
17
 
17
18
  {#if icon}
18
- <Icon {icon} {inline} {width} {height} {vAlign} aria-hidden={!hiddenLabel} />
19
+ <Tooltip tip={tooltip} top>
20
+ <Icon {icon} {inline} {width} {height} aria-hidden={!hiddenLabel} />
21
+ </Tooltip>
19
22
  {#if hiddenLabel}
20
23
  <ScreenReaderOnly>{hiddenLabel}</ScreenReaderOnly>
21
24
  {/if}
@@ -7,7 +7,7 @@ declare const __propDef: {
7
7
  inline?: boolean | undefined;
8
8
  width?: string | number | undefined;
9
9
  height?: string | number | undefined;
10
- vAlign?: "top" | "bottom" | "middle" | undefined;
10
+ tooltip?: string | undefined;
11
11
  };
12
12
  events: {
13
13
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,60 @@
1
+ <script>export let tip = undefined;
2
+ export let top = false;
3
+ export let right = false;
4
+ export let bottom = false;
5
+ export let left = false;
6
+ export let active = false;
7
+ export let color = "#fff";
8
+ let style = `background-color: ${color}; border: 1px solid black;`;
9
+ </script>
10
+
11
+ <style>
12
+ .tooltip {
13
+ opacity: 0;
14
+ position: absolute;
15
+ z-index: 1;
16
+ visibility: hidden;
17
+ transition: opacity 150ms, visibility 150ms;
18
+ }
19
+ .default-tip {
20
+ padding: 4px 8px;
21
+ border-radius: 6px;
22
+ color: inherit;
23
+ }
24
+ .tooltip.top {
25
+ transform: translate(-40%, -100%);
26
+ margin-top: -20px;
27
+ }
28
+ .tooltip.active {
29
+ opacity: 1;
30
+ visibility: initial;
31
+ }
32
+ .tooltip-slot:hover + .tooltip {
33
+ opacity: 1;
34
+ visibility: initial;
35
+ }
36
+ .tip {
37
+ border: 1px solid #000;
38
+ background-color: #fff;
39
+ }
40
+
41
+ </style>
42
+
43
+ {#if tip}
44
+ <div class="tooltip-wrapper">
45
+ <span class="tooltip-slot">
46
+ <slot />
47
+ </span>
48
+ <div
49
+ class="tooltip"
50
+ class:active
51
+ class:left
52
+ class:right
53
+ class:bottom
54
+ class:top>
55
+ <div class="default-tip tip">{tip}</div>
56
+ </div>
57
+ </div>
58
+ {:else}
59
+ <slot />
60
+ {/if}
@@ -0,0 +1,24 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ tip?: string | undefined;
5
+ top?: boolean | undefined;
6
+ right?: boolean | undefined;
7
+ bottom?: boolean | undefined;
8
+ left?: boolean | undefined;
9
+ active?: boolean | undefined;
10
+ color?: string | undefined;
11
+ };
12
+ events: {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {
16
+ default: {};
17
+ };
18
+ };
19
+ export type TooltipProps = typeof __propDef.props;
20
+ export type TooltipEvents = typeof __propDef.events;
21
+ export type TooltipSlots = typeof __propDef.slots;
22
+ export default class Tooltip extends SvelteComponentTyped<TooltipProps, TooltipEvents, TooltipSlots> {
23
+ }
24
+ export {};
@@ -90,7 +90,7 @@ const previewId = randomid();
90
90
  <section class="dialog-chooser-chooser">
91
91
  {#if $store.initialized}
92
92
  <Tree headers={[
93
- { label: 'Path', id: 'name', grow: 4, icon: item => item.type === 'asset' ? iconForMime(item.mime) : (item.type === 'folder' ? (item.open ? folderNotchOpen : folderIcon) : applicationOutline), get: 'name' }
93
+ { label: 'Path', id: 'name', grow: 4, icon: item => item.type === 'asset' ? { icon: iconForMime(item.mime) } : (item.type === 'folder' ? (item.open ? { icon: folderNotchOpen } : { icon: folderIcon }) : { icon: applicationOutline }), get: 'name' }
94
94
  ]} singleSelect store={treeStore} on:deselect={onDeselect} on:choose={onChoose} />
95
95
  {/if}
96
96
  </section>
@@ -1,13 +1,16 @@
1
- <script>import { get } from 'txstate-utils';
1
+ <script>import { get, titleCase } from 'txstate-utils';
2
2
  import { Icon } from '..';
3
3
  export let header;
4
4
  export let item;
5
- $: icon = typeof header.icon === 'function' ? header.icon(item) : header.icon;
5
+ $: icon = typeof header.icon === 'function' ? header.icon(item).icon : header.icon?.icon;
6
+ $: iconLabel = typeof header.icon === 'function' ? header.icon(item).label : header.icon?.label;
6
7
  $: headerComponent = header.component;
7
8
  </script>
8
9
 
9
10
  {#if header.icon}
10
- <span class="icon"><Icon {icon} inline width="1.5em" /></span>
11
+ <span class="icon">
12
+ <Icon {icon} tooltip={iconLabel} inline width="1.5em" hiddenLabel={iconLabel} />
13
+ </span>
11
14
  {/if}
12
15
  {#if header.component}
13
16
  <svelte:component this={headerComponent} {item} {header} />
@@ -39,7 +39,13 @@ export interface TreeHeader<T extends TreeItemFromDB> {
39
39
  label: string;
40
40
  fixed?: string;
41
41
  grow?: number;
42
- icon?: IconifyIcon | ((item: TypedTreeItem<T>) => IconifyIcon | undefined);
42
+ icon?: {
43
+ icon: IconifyIcon;
44
+ label?: string | undefined;
45
+ } | ((item: TypedTreeItem<T>) => {
46
+ icon: IconifyIcon;
47
+ label?: string;
48
+ });
43
49
  get?: string;
44
50
  render?: (item: TypedTreeItem<T>) => string;
45
51
  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": "0.0.62",
4
+ "version": "0.0.63",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
7
7
  "dev": "vite dev --force",