ankiutils 0.0.4 → 0.0.6
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/components/BaseSelect.svelte +4 -7
- package/dist/components/BaseSelect.svelte.d.ts +1 -1
- package/dist/components/Dropdown.svelte +2 -1
- package/dist/components/Dropdown.svelte.d.ts +1 -1
- package/dist/components/ModalSelector.svelte +6 -17
- package/dist/components/ModalSelector.svelte.d.ts +2 -5
- package/dist/components/MultiSelect.svelte +1 -1
- package/dist/components/MultiSelect.svelte.d.ts +1 -1
- package/dist/components/Select.svelte +1 -1
- package/dist/components/Select.svelte.d.ts +1 -1
- package/dist/components/SelectOptions.svelte +1 -5
- package/dist/components/SelectOptions.svelte.d.ts +1 -4
- package/dist/components/Spinner.svelte +13 -67
- package/dist/components/Spinner.svelte.d.ts +0 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/types.d.ts +4 -0
- package/dist/components/types.js +1 -0
- package/dist/components/utils.d.ts +2 -0
- package/dist/components/utils.js +6 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/promise.d.ts +5 -1
- package/dist/promise.js +1 -1
- package/dist/proto.d.ts +2 -2
- package/dist/proto.js +6 -6
- package/dist/theme.svelte.js +6 -6
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tick } from 'svelte';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { type SelectOption } from './types.js';
|
|
4
|
+
import SelectOptions from './SelectOptions.svelte';
|
|
5
|
+
import { filterSelectOptions } from './utils.js';
|
|
5
6
|
interface Props {
|
|
6
7
|
id?: string;
|
|
7
8
|
options: SelectOption[];
|
|
@@ -34,11 +35,7 @@
|
|
|
34
35
|
let inputElement: HTMLInputElement;
|
|
35
36
|
let optionElements: (HTMLButtonElement | HTMLInputElement)[] = $state([]);
|
|
36
37
|
|
|
37
|
-
let filteredOptions = $derived(
|
|
38
|
-
searchTerm
|
|
39
|
-
? options.filter((option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()))
|
|
40
|
-
: options
|
|
41
|
-
);
|
|
38
|
+
let filteredOptions = $derived(filterSelectOptions(searchTerm, options));
|
|
42
39
|
|
|
43
40
|
let displayValue = $derived(
|
|
44
41
|
isOpen
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
2
|
+
import { type SelectOption } from './types.js';
|
|
3
|
+
import { filterSelectOptions } from './utils.js';
|
|
7
4
|
interface Props {
|
|
8
5
|
selectedOption: string;
|
|
9
|
-
options:
|
|
6
|
+
options: SelectOption[];
|
|
10
7
|
placeholder?: string;
|
|
11
8
|
onSelected?: () => void;
|
|
12
9
|
}
|
|
@@ -18,15 +15,7 @@
|
|
|
18
15
|
placeholder = 'Search...'
|
|
19
16
|
}: Props = $props();
|
|
20
17
|
let search = $state('');
|
|
21
|
-
let filteredOptions = $derived
|
|
22
|
-
search
|
|
23
|
-
? options.filter(
|
|
24
|
-
(opt) =>
|
|
25
|
-
opt.value.toLowerCase().includes(search.toLowerCase()) ||
|
|
26
|
-
opt.label.toLowerCase().includes(search.toLowerCase())
|
|
27
|
-
)
|
|
28
|
-
: options
|
|
29
|
-
);
|
|
18
|
+
let filteredOptions = $derived(filterSelectOptions(search, options));
|
|
30
19
|
let selectedIndex = $derived.by(() => {
|
|
31
20
|
for (let i = 0; i < filteredOptions.length; i++) {
|
|
32
21
|
if (isOptionSelected(filteredOptions[i])) return i;
|
|
@@ -38,11 +27,11 @@
|
|
|
38
27
|
let modalElement: HTMLDialogElement;
|
|
39
28
|
let optionElements: HTMLButtonElement[] = $state([]);
|
|
40
29
|
|
|
41
|
-
function isOptionSelected(option:
|
|
30
|
+
function isOptionSelected(option: SelectOption) {
|
|
42
31
|
return option.value.toLowerCase() === selectedOption.toLowerCase();
|
|
43
32
|
}
|
|
44
33
|
|
|
45
|
-
function selectOption(language:
|
|
34
|
+
function selectOption(language: SelectOption) {
|
|
46
35
|
selectedOption = language.value;
|
|
47
36
|
modalElement.close();
|
|
48
37
|
onSelected?.();
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
value: string;
|
|
3
|
-
label: string;
|
|
4
|
-
}
|
|
1
|
+
import { type SelectOption } from './types.ts';
|
|
5
2
|
interface Props {
|
|
6
3
|
selectedOption: string;
|
|
7
|
-
options:
|
|
4
|
+
options: SelectOption[];
|
|
8
5
|
placeholder?: string;
|
|
9
6
|
onSelected?: () => void;
|
|
10
7
|
}
|
|
@@ -1,77 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
}
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
label?: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
center?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let { label = "Loading...", size = 80, center = true }: Props =
|
|
11
|
-
$props();
|
|
6
|
+
let { label = 'Loading...' }: Props = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
class:centered={center}
|
|
18
|
-
style="--size: {size}px"
|
|
19
|
-
>
|
|
20
|
-
<div class="spinner" class:nightMode={pageTheme.isDark}>
|
|
21
|
-
<div></div>
|
|
22
|
-
<div></div>
|
|
23
|
-
<div></div>
|
|
24
|
-
<div></div>
|
|
25
|
-
</div>
|
|
26
|
-
<div class="progress-label">{label}</div>
|
|
9
|
+
<div class="spinner-container">
|
|
10
|
+
<span class="loading loading-spinner w-20"></span>
|
|
11
|
+
<div>{label}</div>
|
|
27
12
|
</div>
|
|
28
13
|
|
|
29
|
-
<style>.
|
|
30
|
-
position:
|
|
14
|
+
<style>.spinner-container {
|
|
15
|
+
position: fixed;
|
|
31
16
|
top: 50%;
|
|
32
17
|
left: 50%;
|
|
33
18
|
transform: translate(-50%, -50%);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
position: relative;
|
|
39
|
-
width: var(--size);
|
|
40
|
-
height: var(--size);
|
|
41
|
-
margin: 0 auto;
|
|
42
|
-
}
|
|
43
|
-
.spinner div {
|
|
44
|
-
display: block;
|
|
45
|
-
position: absolute;
|
|
46
|
-
width: calc(var(--size) - 16px);
|
|
47
|
-
height: calc(var(--size) - 16px);
|
|
48
|
-
margin: 8px;
|
|
49
|
-
border: calc(var(--size) / 10) solid #000;
|
|
50
|
-
border-radius: 50%;
|
|
51
|
-
animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
52
|
-
border-color: #000 transparent transparent transparent;
|
|
53
|
-
}
|
|
54
|
-
.spinner.nightMode div {
|
|
55
|
-
border-top-color: #fff;
|
|
56
|
-
}
|
|
57
|
-
.spinner div:nth-child(1) {
|
|
58
|
-
animation-delay: -0.45s;
|
|
59
|
-
}
|
|
60
|
-
.spinner div:nth-child(2) {
|
|
61
|
-
animation-delay: -0.3s;
|
|
62
|
-
}
|
|
63
|
-
.spinner div:nth-child(3) {
|
|
64
|
-
animation-delay: -0.15s;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@keyframes spin {
|
|
68
|
-
0% {
|
|
69
|
-
transform: rotate(0deg);
|
|
70
|
-
}
|
|
71
|
-
100% {
|
|
72
|
-
transform: rotate(360deg);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
.progress-label {
|
|
76
|
-
text-align: center;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 0.5rem;
|
|
77
23
|
}</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Spinner from './Spinner.svelte';
|
|
2
|
-
import type { SelectOption } from './
|
|
2
|
+
import type { SelectOption } from './types.ts';
|
|
3
3
|
import Select from './Select.svelte';
|
|
4
4
|
import MultiSelect from './MultiSelect.svelte';
|
|
5
5
|
import Dropdown from './Dropdown.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './bridgecommand';
|
|
2
|
+
export * from './promise';
|
|
3
|
+
export * from './proto';
|
|
4
|
+
export * from './theme.svelte';
|
|
5
|
+
export * from './components';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './bridgecommand';
|
|
2
|
+
export * from './promise';
|
|
3
|
+
export * from './proto';
|
|
4
|
+
export * from './theme.svelte';
|
|
5
|
+
export * from './components';
|
package/dist/promise.d.ts
CHANGED
package/dist/promise.js
CHANGED
package/dist/proto.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { DescService } from
|
|
2
|
-
import { type Client } from
|
|
1
|
+
import type { DescService } from '@bufbuild/protobuf';
|
|
2
|
+
import { type Client } from '@connectrpc/connect';
|
|
3
3
|
export declare function createProtoClient<T extends DescService>(service: T): Client<T>;
|
package/dist/proto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createClient
|
|
2
|
-
import { createConnectTransport } from
|
|
1
|
+
import { createClient } from '@connectrpc/connect';
|
|
2
|
+
import { createConnectTransport } from '@connectrpc/connect-web';
|
|
3
3
|
const transport = createConnectTransport({
|
|
4
|
-
baseUrl:
|
|
4
|
+
baseUrl: '/api',
|
|
5
5
|
useBinaryFormat: true,
|
|
6
6
|
fetch: (input, init) => {
|
|
7
7
|
const headers = init?.headers ?? {};
|
|
@@ -9,10 +9,10 @@ const transport = createConnectTransport({
|
|
|
9
9
|
...init,
|
|
10
10
|
headers: {
|
|
11
11
|
...headers,
|
|
12
|
-
|
|
13
|
-
}
|
|
12
|
+
'qt-widget-id': window.qtWidgetId
|
|
13
|
+
}
|
|
14
14
|
});
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
});
|
|
17
17
|
export function createProtoClient(service) {
|
|
18
18
|
return createClient(service, transport);
|
package/dist/theme.svelte.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
export function checkNightMode() {
|
|
2
|
-
const nightMode = window.location.hash ==
|
|
3
|
-
const theme = nightMode ?
|
|
2
|
+
const nightMode = window.location.hash == '#night';
|
|
3
|
+
const theme = nightMode ? 'dark' : 'light';
|
|
4
4
|
// DaisyUI
|
|
5
5
|
document.documentElement.dataset.theme = theme;
|
|
6
6
|
if (nightMode) {
|
|
7
7
|
// Standard Anki class
|
|
8
|
-
document.documentElement.className =
|
|
8
|
+
document.documentElement.className = 'night-mode';
|
|
9
9
|
// Bootstrap
|
|
10
|
-
document.documentElement.dataset.bsTheme =
|
|
10
|
+
document.documentElement.dataset.bsTheme = 'dark';
|
|
11
11
|
}
|
|
12
12
|
return nightMode;
|
|
13
13
|
}
|
|
14
14
|
function getThemeFromRoot() {
|
|
15
15
|
return {
|
|
16
|
-
isDark: document.documentElement.classList.contains(
|
|
16
|
+
isDark: document.documentElement.classList.contains('night-mode')
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export const pageTheme = $state(getThemeFromRoot());
|
|
20
20
|
const observer = new MutationObserver((_mutationsList, _observer) => {
|
|
21
21
|
pageTheme.isDark = getThemeFromRoot().isDark;
|
|
22
22
|
});
|
|
23
|
-
observer.observe(document.documentElement, { attributeFilter: [
|
|
23
|
+
observer.observe(document.documentElement, { attributeFilter: ['class'] });
|