@dosgato/dialog 0.0.28 → 0.0.29

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.
package/Tab.svelte CHANGED
@@ -1,19 +1,24 @@
1
- <script>import { getContext } from 'svelte';
1
+ <script>import { derivedStore } from '@txstate-mws/svelte-store';
2
+ import { getContext } from 'svelte';
2
3
  import Icon from './Icon.svelte';
3
4
  import { TabStore, TAB_CONTEXT } from './TabStore';
4
- export let title;
5
+ export let name;
5
6
  const { store, onClick, onKeyDown, tabelements } = getContext(TAB_CONTEXT);
6
7
  const accordion = store.accordion();
7
- const current = store.currentTitle();
8
- $: active = $current === title;
9
- const idx = $store.tabs.findIndex(t => t.title === title);
8
+ const current = store.currentName();
9
+ const def = derivedStore(store, v => v.tabs.find(t => t.name === name));
10
+ const title = derivedStore(def, 'title');
11
+ const tabid = derivedStore(store, v => v.tabids[name]);
12
+ const panelid = derivedStore(store, v => v.panelids[name]);
13
+ $: active = $current === name;
14
+ const idx = $store.tabs.findIndex(t => t.name === name);
10
15
  const last = idx === $store.tabs.length - 1;
11
16
  </script>
12
17
 
13
18
  {#if $accordion}
14
- <div bind:this={tabelements[idx]} id={$store.tabids[title]} class="tabs-tab" class:last aria-selected={active} aria-controls={$store.panelids[title]} role="tab" tabindex={0} on:click={onClick(idx)} on:keydown={onKeyDown(idx)}><Icon icon={$store.tabs[idx].icon} inline />{title}<i class="tabs-accordion-arrow" aria-hidden="true"></i></div>
19
+ <div bind:this={tabelements[idx]} id={$tabid} class="tabs-tab" class:last aria-selected={active} aria-controls={$panelid} role="tab" tabindex={0} on:click={onClick(idx)} on:keydown={onKeyDown(idx)}><Icon icon={$store.tabs[idx].icon} inline />{$title}<i class="tabs-accordion-arrow" aria-hidden="true"></i></div>
15
20
  {/if}
16
- <div id={$store.panelids[title]} hidden={!active} role="tabpanel" tabindex="-1" aria-labelledby={$store.tabids[title]} class="tabs-panel" class:accordion={$accordion}>
21
+ <div id={$panelid} hidden={!active} role="tabpanel" tabindex="-1" aria-labelledby={$tabid} class="tabs-panel" class:accordion={$accordion}>
17
22
  <slot />
18
23
  </div>
19
24
 
package/Tab.svelte.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- title: string;
4
+ name: string;
5
5
  };
6
6
  events: {
7
7
  [evt: string]: CustomEvent<any>;
package/TabStore.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { ElementSize } from '@txstate-mws/svelte-components';
3
3
  import type { IconifyIcon } from '@iconify/svelte';
4
4
  export declare const TAB_CONTEXT: {};
5
5
  export interface TabDef {
6
- name?: string;
7
- title: string;
6
+ name: string;
7
+ title?: string;
8
8
  icon?: IconifyIcon;
9
9
  required?: boolean;
10
10
  }
package/TabStore.js CHANGED
@@ -26,6 +26,7 @@ export class TabStore extends Store {
26
26
  v.tabids ??= {};
27
27
  v.panelids ??= {};
28
28
  for (const tab of v.tabs) {
29
+ tab.title ??= tab.name;
29
30
  v.tabids[tab.title] ??= randomid();
30
31
  v.panelids[tab.title] ??= randomid();
31
32
  }
@@ -35,16 +36,16 @@ export class TabStore extends Store {
35
36
  return derivedStore(this, v => v.current);
36
37
  }
37
38
  currentName() {
38
- return derivedStore(this, v => v.tabs[v.current].name ?? v.tabs[v.current].title);
39
+ return derivedStore(this, v => v.tabs[v.current].name);
39
40
  }
40
41
  currentTitle() {
41
42
  return derivedStore(this, v => v.tabs[v.current].title);
42
43
  }
43
44
  currentTabId() {
44
- return derivedStore(this, v => v.tabids[v.tabs[v.current].title]);
45
+ return derivedStore(this, v => v.tabids[v.tabs[v.current].name]);
45
46
  }
46
47
  currentPanelId() {
47
- return derivedStore(this, v => v.panelids[v.tabs[v.current].title]);
48
+ return derivedStore(this, v => v.panelids[v.tabs[v.current].name]);
48
49
  }
49
50
  accordion() {
50
51
  return derivedStore(this, v => v.clientWidth < 500);
@@ -65,6 +66,6 @@ export class TabStore extends Store {
65
66
  this.update(v => ({ ...v, current: Math.min(v.tabs.length, Math.max(0, idx)) }));
66
67
  }
67
68
  activateName(name) {
68
- this.update(v => ({ ...v, current: findIndex(v.tabs, t => t.name === name) ?? findIndex(v.tabs, t => t.title === name) ?? v.current }));
69
+ this.update(v => ({ ...v, current: findIndex(v.tabs, t => t.name === name) ?? v.current }));
69
70
  }
70
71
  }
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.28",
4
+ "version": "0.0.29",
5
5
  "dependencies": {
6
6
  "@txstate-mws/svelte-components": "^1.3.5",
7
7
  "@txstate-mws/svelte-forms": "^1.2.1",