@dosgato/dialog 0.0.62 → 0.0.64

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.
@@ -33,12 +33,11 @@ export let lookupByValue = async (val) => { const options = await getOptions(val
33
33
  export let related = 0;
34
34
  export let extradescid = undefined;
35
35
  export let helptext = undefined;
36
- // Each time we run getOptions we will save the value -> label mappings
37
- // that it finds, so that we can display labels on pills.
36
+ /** Each time we run getOptions we will save the value -> label mappings that it finds, so that we can display labels on pills. */
38
37
  const valueToLabel = {};
39
38
  async function wrapGetOptions(search) {
40
39
  const opts = await getOptions(search);
41
- /** If no options are returned with the search term, we can end up with an infinite loop the first time reactToValue calls wrapGetOptions */
40
+ /* If no options are returned with the search term, we can end up with an infinite loop the first time reactToValue calls wrapGetOptions */
42
41
  // if (opts.length === 0) opts = await getOptions('')
43
42
  for (const opt of opts) {
44
43
  valueToLabel[opt.value] = opt.label || opt.value;
@@ -54,10 +53,9 @@ onMount(async () => {
54
53
  await reactToValue(defaultValue);
55
54
  hasInit = true;
56
55
  });
57
- // If we get a value from the form that we haven't seen in the popup menu
58
- // yet, we won't have a label for it.
59
- // This function runs getOptions on any selected values for which the label
60
- // is currently unknown.
56
+ /**
57
+ If we get a value from the form that we haven't seen in the popup menu yet, we won't have a label for it.
58
+ This function runs getOptions on any selected values for which the label is currently unknown. */
61
59
  async function reactToValue(value) {
62
60
  await Promise.all(value.map(async (v) => {
63
61
  if (!valueToLabel[v]) {
@@ -75,7 +73,11 @@ async function reactToValue(value) {
75
73
  <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} let:value let:valid let:invalid let:id let:onBlur let:setVal let:messagesid let:helptextid>
76
74
  {@const _ = reactToValue(value)}
77
75
  <div class:valid class:invalid>
78
- <MultiSelect {id} name={path} usePortal={portal} descid={getDescribedBy([messagesid, helptextid, extradescid])} {disabled} {maxSelections} selected={$selectedStore} {placeholder} getOptions={wrapGetOptions} on:change={e => setVal(e.detail.map(itm => itm.value))} on:blur={onBlur} />
76
+ <MultiSelect {id} name={path} usePortal={portal} descid={getDescribedBy([messagesid, helptextid, extradescid])}
77
+ {disabled} {maxSelections} selected={$selectedStore} {placeholder} getOptions={wrapGetOptions}
78
+ inputClass='multiselect-input'
79
+ on:change={e => setVal(e.detail.map(itm => itm.value))} on:blur={onBlur}
80
+ />
79
81
  </div>
80
82
  </FieldStandard>
81
83
  {/if}
@@ -84,5 +86,8 @@ async function reactToValue(value) {
84
86
  .invalid {
85
87
  --multiselect-border: 1px solid red;
86
88
  }
89
+ :global(.multiselect-input) {
90
+ width: 100%
91
+ }
87
92
 
88
93
  </style>
@@ -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 => ({ icon: item.type === 'asset' ? iconForMime(item.mime) : (item.type === 'folder' ? (item.open ? folderNotchOpen : folderIcon) : applicationOutline) }), get: 'name' }
94
94
  ]} singleSelect store={treeStore} on:deselect={onDeselect} on:choose={onChoose} />
95
95
  {/if}
96
96
  </section>
@@ -2,12 +2,14 @@
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) : header.icon);
6
6
  $: headerComponent = header.component;
7
7
  </script>
8
8
 
9
- {#if header.icon}
10
- <span class="icon"><Icon {icon} inline width="1.5em" /></span>
9
+ {#if icon}
10
+ <span class="icon">
11
+ <Icon icon={icon.icon} tooltip={icon.label} inline width="1.5em" hiddenLabel={icon.label} />
12
+ </span>
11
13
  {/if}
12
14
  {#if header.component}
13
15
  <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;
45
+ } | ((item: TypedTreeItem<T>) => {
46
+ icon: IconifyIcon;
47
+ label?: string;
48
+ } | undefined);
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.64",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
7
7
  "dev": "vite dev --force",