@hyvor/design 1.1.24-beta.1 → 1.1.24-beta.2

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,13 +1,17 @@
1
1
  <script lang="ts">
2
2
  import Dropdown from '../../Dropdown/Dropdown.svelte';
3
3
  import Tooltip from '../../Tooltip/Tooltip.svelte';
4
- import { barUser, switchOrganization, type BarOrganization } from '../bar.js';
4
+ import {
5
+ barOrganizationDropdownOpen,
6
+ barUser,
7
+ switchOrganization,
8
+ type BarOrganization
9
+ } from '../bar.js';
5
10
  import IconChevronExpand from '@hyvor/icons/IconChevronExpand';
6
11
  import OrgsList from './OrgsList.svelte';
7
12
  import toast from '../../Toast/toast.js';
8
13
 
9
- let showDropdown = $state(false);
10
- let showTooltip = $state(true);
14
+ let disableTooltip = $state(true);
11
15
  let switching = $state(false);
12
16
 
13
17
  let props: {
@@ -15,7 +19,7 @@
15
19
  } = $props();
16
20
 
17
21
  async function handleSwitch(org: BarOrganization) {
18
- showDropdown = false;
22
+ barOrganizationDropdownOpen.set(false);
19
23
  switching = true;
20
24
 
21
25
  try {
@@ -26,24 +30,24 @@
26
30
  return;
27
31
  }
28
32
 
33
+ switching = false;
29
34
  props.onSwitch(org);
30
35
  }
31
36
 
32
- $effect(() => {
33
- if (showDropdown) {
34
- showTooltip = false;
35
- } else {
36
- setTimeout(() => {
37
- showTooltip = true;
38
- }, 3000);
39
- }
37
+ barOrganizationDropdownOpen.subscribe((value) => {
38
+ disableTooltip = true;
40
39
  });
41
40
  </script>
42
41
 
43
42
  {#if $barUser}
44
- <Tooltip position="bottom" text="Switch Organization" disabled={!showTooltip}>
43
+ <Tooltip position="bottom" text="Switch Organization" disabled={disableTooltip}>
45
44
  <span class="wrap">
46
- <Dropdown bind:show={showDropdown} align="center" width={275} contentPadding={0}>
45
+ <Dropdown
46
+ bind:show={$barOrganizationDropdownOpen}
47
+ align="center"
48
+ width={275}
49
+ contentPadding={0}
50
+ >
47
51
  {#snippet trigger()}
48
52
  <button>
49
53
  {#if switching}
@@ -2,13 +2,12 @@
2
2
  import IconMessage from '../../IconMessage/IconMessage.svelte';
3
3
  import Loader from '../../Loader/Loader.svelte';
4
4
  import { onMount } from 'svelte';
5
- import { getMyOrganizations, type BarOrganization } from '../bar.js';
5
+ import { barOrganizations, getMyOrganizations, type BarOrganization } from '../bar.js';
6
6
  import ActionList from '../../ActionList/ActionList.svelte';
7
7
  import ActionListItem from '../../ActionList/ActionListItem.svelte';
8
8
 
9
9
  let loading = $state(true);
10
10
  let error = $state('');
11
- let orgs = $state<BarOrganization[]>([]);
12
11
 
13
12
  let {
14
13
  onSwitch
@@ -17,9 +16,13 @@
17
16
  } = $props();
18
17
 
19
18
  onMount(() => {
19
+ if ($barOrganizations.length > 0) {
20
+ loading = false;
21
+ return;
22
+ }
20
23
  getMyOrganizations()
21
24
  .then((data) => {
22
- orgs = data;
25
+ barOrganizations.set(data);
23
26
  })
24
27
  .catch((err) => {
25
28
  error = 'Failed to load organizations.';
@@ -39,7 +42,7 @@
39
42
  {:else}
40
43
  <div class="list-wrap">
41
44
  <ActionList>
42
- {#each orgs as org}
45
+ {#each $barOrganizations as org}
43
46
  <ActionListItem on:select={() => onSwitch(org)}>
44
47
  {org.name}
45
48
  {#snippet end()}
@@ -39,6 +39,8 @@ export declare const barUser: import("svelte/store").Writable<BarUser | null>;
39
39
  export declare const barUnreadUpdates: import("svelte/store").Writable<number>;
40
40
  export declare const barLicense: import("svelte/store").Writable<BarResolvedLicense | null>;
41
41
  export declare const barHasFailedInvoices: import("svelte/store").Writable<boolean>;
42
+ export declare const barOrganizationDropdownOpen: import("svelte/store").Writable<boolean>;
43
+ export declare const barOrganizations: import("svelte/store").Writable<BarOrganization[]>;
42
44
  export declare function setInstanceAndProduct(instance_: string, product_: string): void;
43
45
  /**
44
46
  * @throws Error if initialization fails
@@ -59,4 +61,8 @@ export declare const bar: {
59
61
  * This is useful to create after, for example, a user creates a new blog
60
62
  */
61
63
  reload: () => void;
64
+ /**
65
+ * Open the org selector dropdown from the outside world
66
+ */
67
+ openOrganizationDropdown: () => void;
62
68
  };
@@ -6,6 +6,8 @@ export const barUser = writable(null);
6
6
  export const barUnreadUpdates = writable(0);
7
7
  export const barLicense = writable(null);
8
8
  export const barHasFailedInvoices = writable(false);
9
+ export const barOrganizationDropdownOpen = writable(false);
10
+ export const barOrganizations = writable([]);
9
11
  export function setInstanceAndProduct(instance_, product_) {
10
12
  instance = instance_;
11
13
  product = product_;
@@ -126,5 +128,9 @@ export const bar = {
126
128
  */
127
129
  reload: () => {
128
130
  initBar();
129
- }
131
+ },
132
+ /**
133
+ * Open the org selector dropdown from the outside world
134
+ */
135
+ openOrganizationDropdown: () => barOrganizationDropdownOpen.set(true)
130
136
  };
package/package.json CHANGED
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "version": "1.1.24-beta.1"
65
+ "version": "1.1.24-beta.2"
66
66
  }