@axium/client 0.18.4 → 0.19.1
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/requests.js +4 -0
- package/lib/AccessControlDialog.svelte +3 -2
- package/lib/FormDialog.svelte +2 -1
- package/lib/NumberBar.svelte +10 -2
- package/lib/SidebarLayout.svelte +1 -1
- package/lib/attachments.ts +41 -2
- package/package.json +1 -1
- package/styles/list.css +1 -0
package/dist/requests.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import type { AccessControllable, AccessTarget, User } from '@axium/core';
|
|
4
4
|
import { getTarget, pickPermissions } from '@axium/core';
|
|
5
5
|
import { errorText } from '@axium/core/io';
|
|
6
|
-
import { toastStatus } from './toast.js';
|
|
7
6
|
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
8
7
|
import Icon from './Icon.svelte';
|
|
9
8
|
import UserCard from './UserCard.svelte';
|
|
10
9
|
import UserDiscovery from './UserDiscovery.svelte';
|
|
10
|
+
import { closeOnBackGesture } from './attachments.js';
|
|
11
|
+
import { toastStatus } from './toast.js';
|
|
11
12
|
|
|
12
13
|
interface Props extends HTMLDialogAttributes {
|
|
13
14
|
editable: boolean;
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
}
|
|
29
30
|
</script>
|
|
30
31
|
|
|
31
|
-
<dialog bind:this={dialog} {...rest} onclick={e => e.stopPropagation()}>
|
|
32
|
+
<dialog bind:this={dialog} {...rest} onclick={e => e.stopPropagation()} {@attach closeOnBackGesture}>
|
|
32
33
|
{#if item.name}
|
|
33
34
|
<h3>{@html text('component.AccessControlDialog.named_title', { $html: true, name: item.name })}</h3>
|
|
34
35
|
{:else}
|
package/lib/FormDialog.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { text } from '@axium/client';
|
|
3
3
|
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
4
|
+
import { closeOnBackGesture } from './attachments.js';
|
|
4
5
|
|
|
5
6
|
let {
|
|
6
7
|
children,
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
<button type="submit" class={['submit', submitDanger && 'danger']}>{submitText}</button>
|
|
63
64
|
{/snippet}
|
|
64
65
|
|
|
65
|
-
<dialog bind:this={dialog} {onclose} {...rest} onclick={e => e.stopPropagation()}>
|
|
66
|
+
<dialog bind:this={dialog} {onclose} {...rest} onclick={e => e.stopPropagation()} {@attach closeOnBackGesture}>
|
|
66
67
|
{@render header?.()}
|
|
67
68
|
<form {onsubmit} class="main" method="dialog">
|
|
68
69
|
{#if error}
|
package/lib/NumberBar.svelte
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
interface Props<T extends number | bigint> {
|
|
3
|
+
min?: T;
|
|
4
|
+
max: T;
|
|
5
|
+
value: T;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { min: _min, max, value, text }: Props<any> = $props();
|
|
10
|
+
let min: typeof value = _min || typeof value == 'bigint' ? 0n : 0;
|
|
3
11
|
</script>
|
|
4
12
|
|
|
5
13
|
<div class="Bar">
|
|
6
14
|
{#if max}
|
|
7
|
-
<div class="fill" style="width: {((value - min) / (max - min)) * 100}%"></div>
|
|
15
|
+
<div class="fill" style="width: {((value - min) / (max - min)) * ((typeof value == 'bigint' ? 100n : 100) as typeof value)}%"></div>
|
|
8
16
|
{/if}
|
|
9
17
|
{#if text}<span class="text">{text}</span>{/if}
|
|
10
18
|
</div>
|
package/lib/SidebarLayout.svelte
CHANGED
package/lib/attachments.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @see https://svelte.dev/docs/svelte/@attach
|
|
4
4
|
*/
|
|
5
5
|
import { mount, unmount } from 'svelte';
|
|
6
|
-
import Icon from './Icon.svelte';
|
|
7
6
|
import type { Attachment } from 'svelte/attachments';
|
|
7
|
+
import Icon from './Icon.svelte';
|
|
8
8
|
|
|
9
9
|
export interface ContextMenuItem {
|
|
10
10
|
/** Icon name */
|
|
@@ -95,8 +95,12 @@ export function contextMenu(...menuItems: (ContextMenuItem | false | null | unde
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Dynamically resize `<textarea>`s based on content.
|
|
100
|
+
* @todo Remove this once `field-sizing` works everywhere
|
|
101
|
+
*/
|
|
98
102
|
export function dynamicRows(max: number = 40, min: number = 3): Attachment<HTMLTextAreaElement> {
|
|
99
|
-
return function
|
|
103
|
+
return function _attachDynamicRows(element: HTMLTextAreaElement) {
|
|
100
104
|
element.style.resize = 'none';
|
|
101
105
|
// @ts-expect-error field-sizing is not yet in the types
|
|
102
106
|
element.style.fieldSizing = 'content';
|
|
@@ -118,3 +122,38 @@ export function dynamicRows(max: number = 40, min: number = 3): Attachment<HTMLT
|
|
|
118
122
|
};
|
|
119
123
|
};
|
|
120
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Enabled the use of back gestures to close dialogs
|
|
128
|
+
*/
|
|
129
|
+
export function closeOnBackGesture(element: HTMLDialogElement) {
|
|
130
|
+
if (!globalThis.history) {
|
|
131
|
+
throw new Error('Can not attach back gesture handling because the History API is unavailable');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const showModal = element.showModal.bind(element);
|
|
135
|
+
|
|
136
|
+
let closedByBack = false,
|
|
137
|
+
historyKey = Math.random().toString(16).slice(2);
|
|
138
|
+
|
|
139
|
+
element.showModal = () => {
|
|
140
|
+
closedByBack = false;
|
|
141
|
+
/* popstate's state will be the "upcoming" state.
|
|
142
|
+
i.e, the state after having pushed 1 then 2 would be 1 */
|
|
143
|
+
history.replaceState(historyKey, '');
|
|
144
|
+
history.pushState(null, '');
|
|
145
|
+
showModal();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
element.addEventListener('close', () => {
|
|
149
|
+
if (closedByBack) return;
|
|
150
|
+
history.replaceState(null, '');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
window.addEventListener('popstate', e => {
|
|
154
|
+
if (e.state != historyKey) return;
|
|
155
|
+
closedByBack = true;
|
|
156
|
+
element.close();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
closeOnBackGesture satisfies Attachment<HTMLDialogElement>;
|
package/package.json
CHANGED