@hyvor/design 2.0.8 → 2.0.11
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/dist/cloud/HyvorBar/BarUpdatesList.svelte +6 -6
- package/dist/cloud/HyvorBar/bar.d.ts +1 -6
- package/dist/cloud/HyvorBar/bar.js +5 -54
- package/dist/components/Table/Table.svelte +11 -2
- package/dist/components/Table/Table.svelte.d.ts +1 -0
- package/dist/components/Table/TableRow.svelte +31 -4
- package/dist/components/Table/TableRow.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
|
-
import { barUnreadUpdates,
|
|
3
|
+
import { barUnreadUpdates, barLastReadUpdatesAt, type BarUpdate } from './bar.js';
|
|
4
4
|
import IconBoxArrowUpRight from '@hyvor/icons/IconBoxArrowUpRight';
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
let loading = $state(true);
|
|
18
18
|
let error = $state(false);
|
|
19
19
|
|
|
20
|
-
let lastReadTime: null | number = $
|
|
20
|
+
let lastReadTime: null | number = $derived($barLastReadUpdatesAt);
|
|
21
21
|
|
|
22
22
|
const cloudContext = $derived(getCloudContext());
|
|
23
23
|
|
|
24
24
|
function fetchUpdates() {
|
|
25
25
|
error = false;
|
|
26
|
-
lastReadTime = UnreadUpdatesTimeLocalStorage.get();
|
|
27
26
|
loading = true;
|
|
28
27
|
|
|
29
|
-
fetch(cloudContext.instance + '/api/public/updates?types=company,' + cloudContext.component
|
|
28
|
+
fetch(cloudContext.instance + '/api/public/updates?types=company,' + cloudContext.component, {
|
|
29
|
+
credentials: 'include'
|
|
30
|
+
})
|
|
30
31
|
.then((response) => response.json())
|
|
31
32
|
.then((data) => {
|
|
32
33
|
updates = data;
|
|
33
34
|
|
|
34
35
|
barUnreadUpdates.set(0);
|
|
35
|
-
|
|
36
|
-
UnreadUpdatesTimeLocalStorage.setNow();
|
|
36
|
+
barLastReadUpdatesAt.set(Math.floor(Date.now() / 1000));
|
|
37
37
|
})
|
|
38
38
|
.catch(() => {
|
|
39
39
|
error = true;
|
|
@@ -15,13 +15,8 @@ export interface BarUpdate {
|
|
|
15
15
|
export type BarUpdateType = 'company' | 'core' | 'talk' | 'blogs' | 'post' | 'relay' | 'fortguard';
|
|
16
16
|
export declare const barUnreadUpdates: import("svelte/store").Writable<number>;
|
|
17
17
|
export declare const barHasFailedInvoices: import("svelte/store").Writable<boolean>;
|
|
18
|
+
export declare const barLastReadUpdatesAt: import("svelte/store").Writable<number | null>;
|
|
18
19
|
export declare function initBar(): Promise<void>;
|
|
19
|
-
export declare class UnreadUpdatesTimeLocalStorage {
|
|
20
|
-
static KEY: string;
|
|
21
|
-
static get(): number | null;
|
|
22
|
-
static set(value: string): void;
|
|
23
|
-
static setNow(): void;
|
|
24
|
-
}
|
|
25
20
|
export declare const bar: {
|
|
26
21
|
/**
|
|
27
22
|
* Refetches data like user info, unread updates, billing data, etc.
|
|
@@ -2,6 +2,7 @@ import { writable } from 'svelte/store';
|
|
|
2
2
|
import { getCloudContext } from '../CloudContext/cloudContextState.svelte.js';
|
|
3
3
|
export const barUnreadUpdates = writable(0);
|
|
4
4
|
export const barHasFailedInvoices = writable(false);
|
|
5
|
+
export const barLastReadUpdatesAt = writable(null);
|
|
5
6
|
export async function initBar() {
|
|
6
7
|
const { user, organization, instance, component, deployment } = getCloudContext();
|
|
7
8
|
if (deployment !== 'cloud') {
|
|
@@ -9,10 +10,6 @@ export async function initBar() {
|
|
|
9
10
|
}
|
|
10
11
|
const query = new URLSearchParams();
|
|
11
12
|
query.set('component', component);
|
|
12
|
-
const lastUnreadTime = UnreadUpdatesTimeLocalStorage.get();
|
|
13
|
-
if (lastUnreadTime) {
|
|
14
|
-
query.set('last_read_updates_at', lastUnreadTime.toString());
|
|
15
|
-
}
|
|
16
13
|
const response = await fetch(instance + '/api/v2/cloud/bar/init?' + query.toString(), {
|
|
17
14
|
credentials: 'include'
|
|
18
15
|
});
|
|
@@ -27,57 +24,11 @@ export async function initBar() {
|
|
|
27
24
|
}
|
|
28
25
|
barHasFailedInvoices.set(data.has_failed_invoices);
|
|
29
26
|
barUnreadUpdates.set(data.unread_updates);
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export class UnreadUpdatesTimeLocalStorage {
|
|
35
|
-
static KEY = 'unread_updates';
|
|
36
|
-
static get() {
|
|
37
|
-
const val = BarLocalStorage.get(UnreadUpdatesTimeLocalStorage.KEY);
|
|
38
|
-
if (val) {
|
|
39
|
-
return Number(val);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
static set(value) {
|
|
44
|
-
BarLocalStorage.set(UnreadUpdatesTimeLocalStorage.KEY, value);
|
|
45
|
-
}
|
|
46
|
-
static setNow() {
|
|
47
|
-
UnreadUpdatesTimeLocalStorage.set(Math.floor(Date.now() / 1000).toString());
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
class BarLocalStorage {
|
|
51
|
-
static KEY = 'hyvor_bar';
|
|
52
|
-
static getJson() {
|
|
53
|
-
try {
|
|
54
|
-
const data = localStorage.getItem(BarLocalStorage.KEY);
|
|
55
|
-
if (data) {
|
|
56
|
-
return JSON.parse(data);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
console.error(e);
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
static get(key) {
|
|
66
|
-
const data = BarLocalStorage.getJson();
|
|
67
|
-
if (data) {
|
|
68
|
-
return data[key];
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
27
|
+
if (data.last_read_updates_at !== null) {
|
|
28
|
+
barLastReadUpdatesAt.set(data.last_read_updates_at);
|
|
71
29
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const data = BarLocalStorage.getJson() || {};
|
|
75
|
-
data[key] = value;
|
|
76
|
-
localStorage.setItem(BarLocalStorage.KEY, JSON.stringify(data));
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
console.error(e);
|
|
80
|
-
}
|
|
30
|
+
else {
|
|
31
|
+
barLastReadUpdatesAt.set(Math.floor(Date.now() / 1000));
|
|
81
32
|
}
|
|
82
33
|
}
|
|
83
34
|
// exported to be used from outside
|
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
interface Props {
|
|
3
3
|
columns: string;
|
|
4
4
|
hover?: boolean;
|
|
5
|
+
style?: 'default' | 'bordered';
|
|
5
6
|
children?: import('svelte').Snippet;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
let { columns, hover = false, children }: Props = $props();
|
|
9
|
+
let { columns, hover = false, style = 'default', children }: Props = $props();
|
|
9
10
|
|
|
10
11
|
const hoverCss = hover ? '--local-hover-color: var(--hover);' : '';
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
|
-
<div class="table" style="--local-columns: {columns};{hoverCss}" role="table">
|
|
14
|
+
<div class="table {style}" style="--local-columns: {columns};{hoverCss}" role="table">
|
|
14
15
|
{@render children?.()}
|
|
15
16
|
</div>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
.table.bordered {
|
|
20
|
+
border-radius: 20px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
border: 1px solid var(--border);
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
head?: boolean;
|
|
6
|
+
section?: boolean;
|
|
6
7
|
children: Snippet;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
const { head = false, children, ...rest }: Props = $props();
|
|
10
|
+
const { head = false, section = false, children, ...rest }: Props = $props();
|
|
10
11
|
|
|
11
|
-
setContext('table-row', { head });
|
|
12
|
+
setContext('table-row', { head, section });
|
|
12
13
|
</script>
|
|
13
14
|
|
|
14
|
-
<div class:head {...rest} role="row">
|
|
15
|
+
<div class:head class:section {...rest} role="row">
|
|
15
16
|
{@render children()}
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -28,11 +29,37 @@
|
|
|
28
29
|
background: var(--accent-lightest);
|
|
29
30
|
margin-bottom: 5px;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
:global(.table.bordered) div {
|
|
34
|
+
border-radius: 0;
|
|
35
|
+
padding: 13px 20px;
|
|
36
|
+
border-top: 1px solid var(--border);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:global(.table.bordered) div.head {
|
|
40
|
+
background: var(--box-background);
|
|
41
|
+
font-weight: 600;
|
|
42
|
+
font-size: 13px;
|
|
43
|
+
padding: 12px 20px;
|
|
44
|
+
margin-bottom: 0;
|
|
45
|
+
border-top: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
div:hover:not(.head, .section) {
|
|
32
49
|
background-color: var(--local-hover-color);
|
|
33
50
|
}
|
|
34
51
|
div > :global(*) {
|
|
35
52
|
padding-right: 5px;
|
|
36
53
|
word-wrap: break-word;
|
|
37
54
|
}
|
|
55
|
+
|
|
56
|
+
div.section {
|
|
57
|
+
background: var(--box-background);
|
|
58
|
+
font-size: 11px;
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
letter-spacing: 0.06em;
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
color: var(--text-light);
|
|
63
|
+
padding: 8px 20px;
|
|
64
|
+
}
|
|
38
65
|
</style>
|