@marianmeres/stuic 1.75.0 → 1.77.0
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/AlertConfirmPrompt/AlertConfirmPrompt.svelte +8 -0
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte.d.ts +8 -1
- package/dist/components/Drawer/Drawer.svelte.d.ts +1 -1
- package/dist/components/Notifications/Notifications.svelte +60 -56
- package/dist/components/Notifications/Notifications.svelte.d.ts +19 -2
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,10 @@ import {
|
|
|
6
6
|
Button,
|
|
7
7
|
Field,
|
|
8
8
|
FieldSelect,
|
|
9
|
+
Notifications,
|
|
9
10
|
Thc,
|
|
10
11
|
createAlertConfirmPromptStore,
|
|
12
|
+
createNotificationsStore,
|
|
11
13
|
focusTrap
|
|
12
14
|
} from "../../index.js";
|
|
13
15
|
import { acpDefaultIcons } from "./acp-icons.js";
|
|
@@ -72,6 +74,8 @@ const _isFn = (v) => typeof v === "function";
|
|
|
72
74
|
|
|
73
75
|
<script>const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
|
|
74
76
|
const clog = createClog("AlertConfirmPrompt");
|
|
77
|
+
export let notifications = void 0;
|
|
78
|
+
export let notificationsPositionConfig = {};
|
|
75
79
|
export let acp;
|
|
76
80
|
export let forceAsHtml = void 0;
|
|
77
81
|
export let defaultIcons = acpDefaultIcons;
|
|
@@ -334,6 +338,10 @@ $:
|
|
|
334
338
|
{/if}
|
|
335
339
|
</form>
|
|
336
340
|
{/if}
|
|
341
|
+
|
|
342
|
+
{#if notifications}
|
|
343
|
+
<Notifications {notifications} {...notificationsPositionConfig || {}} />
|
|
344
|
+
{/if}
|
|
337
345
|
</dialog>
|
|
338
346
|
|
|
339
347
|
<style>@keyframes -global-rotating-cw {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { createAlertConfirmPromptStore } from '../../index.js';
|
|
2
|
+
import { createAlertConfirmPromptStore, createNotificationsStore, type NOTIFICATIONS_POSX, type NOTIFICATIONS_POSY } from '../../index.js';
|
|
3
3
|
import type { AlertConfirmPromptKnownClasses, AlertConfirmPromptVariant } from './alert-confirm-prompt.js';
|
|
4
4
|
export interface AlertConfirmPromptIcons extends Record<AlertConfirmPromptVariant, () => string> {
|
|
5
5
|
spinner: () => string;
|
|
@@ -71,6 +71,13 @@ export declare class AlertConfirmPromptConfig {
|
|
|
71
71
|
}
|
|
72
72
|
declare const __propDef: {
|
|
73
73
|
props: {
|
|
74
|
+
notifications?: ReturnType<typeof createNotificationsStore> | undefined;
|
|
75
|
+
notificationsPositionConfig?: Partial<{
|
|
76
|
+
posX: NOTIFICATIONS_POSX;
|
|
77
|
+
posXMobile: NOTIFICATIONS_POSX;
|
|
78
|
+
posY: NOTIFICATIONS_POSY;
|
|
79
|
+
posYMobile: NOTIFICATIONS_POSY;
|
|
80
|
+
}> | undefined;
|
|
74
81
|
acp: ReturnType<typeof createAlertConfirmPromptStore>;
|
|
75
82
|
forceAsHtml?: boolean | undefined;
|
|
76
83
|
defaultIcons?: Partial<AlertConfirmPromptIcons> | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const createDrawerStore: (open?: boolean) => import("@marianmeres
|
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
drawer: import("@marianmeres/switch-store").SwitchStore<any>;
|
|
7
|
-
position?: "left" | "
|
|
7
|
+
position?: "left" | "right" | "top" | "bottom" | undefined;
|
|
8
8
|
class?: string | undefined;
|
|
9
9
|
backdropClass?: string | undefined;
|
|
10
10
|
labelledby?: string | undefined;
|
|
@@ -4,7 +4,6 @@ import { twMerge } from "tailwind-merge";
|
|
|
4
4
|
import Thc from "../Thc/Thc.svelte";
|
|
5
5
|
import X from "../X/X.svelte";
|
|
6
6
|
import { notificationsDefaultIcons } from "./notifications-icons.js";
|
|
7
|
-
import { disableScrollHandling } from "$app/navigation";
|
|
8
7
|
const X_POSITIONS = ["left", "center", "right"];
|
|
9
8
|
const Y_POSITIONS = ["top", "center", "bottom"];
|
|
10
9
|
const DEFAULT = {
|
|
@@ -89,6 +88,14 @@ export let posXMobile = DEFAULT.posXMobile;
|
|
|
89
88
|
export let posY = DEFAULT.posY;
|
|
90
89
|
export let posYMobile = DEFAULT.posYMobile;
|
|
91
90
|
let x, y, xMobile, yMobile;
|
|
91
|
+
export function getPositionConfig() {
|
|
92
|
+
return {
|
|
93
|
+
posX: x,
|
|
94
|
+
posY: y,
|
|
95
|
+
posXMobile: xMobile,
|
|
96
|
+
posYMobile: yMobile
|
|
97
|
+
};
|
|
98
|
+
}
|
|
92
99
|
$:
|
|
93
100
|
x = X_POSITIONS.includes(posX) ? posX : DEFAULT.posX;
|
|
94
101
|
$:
|
|
@@ -131,66 +138,63 @@ const _isFn = (v) => typeof v === "function";
|
|
|
131
138
|
</script>
|
|
132
139
|
|
|
133
140
|
{#if $notifications.length}
|
|
134
|
-
<
|
|
135
|
-
<div class={
|
|
136
|
-
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<!-- svelte-ignore
|
|
141
|
+
<div class={_wrapClass} aria-live="assertive">
|
|
142
|
+
<div class={_wrapInnerClass}>
|
|
143
|
+
{#each $notifications as n}
|
|
144
|
+
{@const iconFn = _iconFn(n)}
|
|
145
|
+
<!-- use your own component -->
|
|
146
|
+
{#if n?.component}
|
|
147
|
+
<svelte:component
|
|
148
|
+
this={n.component.component || n.component}
|
|
149
|
+
{...n.component.props || {}}
|
|
150
|
+
notification={n}
|
|
151
|
+
{notifications}
|
|
152
|
+
/>
|
|
153
|
+
{:else}
|
|
154
|
+
<!-- svelte-ignore
|
|
149
155
|
a11y-click-events-have-key-events
|
|
150
156
|
a11y-no-noninteractive-element-interactions
|
|
151
157
|
a11y-mouse-events-have-key-events -->
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
>
|
|
164
|
-
{
|
|
165
|
-
|
|
166
|
-
{n.count}
|
|
167
|
-
</div>
|
|
168
|
-
{/if}
|
|
169
|
-
|
|
170
|
-
{#if _isFn(iconFn)}
|
|
171
|
-
<div class={_iconClass(n)}>{@html iconFn()}</div>
|
|
172
|
-
{/if}
|
|
173
|
-
|
|
174
|
-
<div class={_contentClass(n)}>
|
|
175
|
-
<Thc
|
|
176
|
-
thc={n.content}
|
|
177
|
-
forceAsHtml={n.forceAsHtml ?? forceAsHtml}
|
|
178
|
-
notification={n}
|
|
179
|
-
{notifications}
|
|
180
|
-
/>
|
|
158
|
+
<div
|
|
159
|
+
transition:fade|global={{ duration: 200 }}
|
|
160
|
+
class={_boxClass(n)}
|
|
161
|
+
class:cursor-pointer={typeof n.onClick === 'function'}
|
|
162
|
+
data-notification-type={n.type}
|
|
163
|
+
data-notification-multiple={n.count > 1 ? true : undefined}
|
|
164
|
+
role="alert"
|
|
165
|
+
on:mouseover={() => notifications.event(n.id, notifications.EVENT.MOUSEOVER)}
|
|
166
|
+
on:mouseout={() => notifications.event(n.id, notifications.EVENT.MOUSEOUT)}
|
|
167
|
+
on:click={() => notifications.event(n.id, notifications.EVENT.CLICK)}
|
|
168
|
+
>
|
|
169
|
+
{#if n.count > 1}
|
|
170
|
+
<div class={_countClass(n)}>
|
|
171
|
+
{n.count}
|
|
181
172
|
</div>
|
|
173
|
+
{/if}
|
|
174
|
+
|
|
175
|
+
{#if _isFn(iconFn)}
|
|
176
|
+
<div class={_iconClass(n)}>{@html iconFn()}</div>
|
|
177
|
+
{/if}
|
|
182
178
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
179
|
+
<div class={_contentClass(n)}>
|
|
180
|
+
<Thc
|
|
181
|
+
thc={n.content}
|
|
182
|
+
forceAsHtml={n.forceAsHtml ?? forceAsHtml}
|
|
183
|
+
notification={n}
|
|
184
|
+
{notifications}
|
|
185
|
+
/>
|
|
190
186
|
</div>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
|
|
188
|
+
<button
|
|
189
|
+
class={_buttonClass(n)}
|
|
190
|
+
aria-label={ariaCloseLabel}
|
|
191
|
+
on:click|preventDefault|stopPropagation={() => notifications.remove(n.id)}
|
|
192
|
+
>
|
|
193
|
+
<X class={_xClass(n)} />
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
196
|
+
{/if}
|
|
197
|
+
{/each}
|
|
194
198
|
</div>
|
|
195
|
-
</
|
|
199
|
+
</div>
|
|
196
200
|
{/if}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { NotificationKnownClasses, NotificationType, createNotificationsStore } from './notifications.js';
|
|
3
|
+
declare const X_POSITIONS: readonly ["left", "center", "right"];
|
|
4
|
+
declare const Y_POSITIONS: readonly ["top", "center", "bottom"];
|
|
5
|
+
type ArrayElement<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ArrayElement> ? ArrayElement : never;
|
|
6
|
+
export type NOTIFICATIONS_POSX = ArrayElement<typeof X_POSITIONS>;
|
|
7
|
+
export type NOTIFICATIONS_POSY = ArrayElement<typeof Y_POSITIONS>;
|
|
3
8
|
export declare class NotificationsConfig {
|
|
4
9
|
static preset: {
|
|
5
10
|
wrap: string;
|
|
@@ -23,10 +28,16 @@ declare const __propDef: {
|
|
|
23
28
|
classes?: Partial<NotificationKnownClasses> | undefined;
|
|
24
29
|
classesByType?: Partial<Record<string, Partial<NotificationKnownClasses>>> | undefined;
|
|
25
30
|
ariaCloseLabel?: string | undefined;
|
|
26
|
-
posX?: "
|
|
27
|
-
posXMobile?: "
|
|
31
|
+
posX?: "left" | "center" | "right" | undefined;
|
|
32
|
+
posXMobile?: "left" | "center" | "right" | undefined;
|
|
28
33
|
posY?: "center" | "top" | "bottom" | undefined;
|
|
29
34
|
posYMobile?: "center" | "top" | "bottom" | undefined;
|
|
35
|
+
getPositionConfig?: (() => {
|
|
36
|
+
posX: "left" | "center" | "right";
|
|
37
|
+
posY: "center" | "top" | "bottom";
|
|
38
|
+
posXMobile: "left" | "center" | "right";
|
|
39
|
+
posYMobile: "center" | "top" | "bottom";
|
|
40
|
+
}) | undefined;
|
|
30
41
|
};
|
|
31
42
|
events: {
|
|
32
43
|
[evt: string]: CustomEvent<any>;
|
|
@@ -37,5 +48,11 @@ export type NotificationsProps = typeof __propDef.props;
|
|
|
37
48
|
export type NotificationsEvents = typeof __propDef.events;
|
|
38
49
|
export type NotificationsSlots = typeof __propDef.slots;
|
|
39
50
|
export default class Notifications extends SvelteComponent<NotificationsProps, NotificationsEvents, NotificationsSlots> {
|
|
51
|
+
get getPositionConfig(): () => {
|
|
52
|
+
posX: "left" | "center" | "right";
|
|
53
|
+
posY: "center" | "top" | "bottom";
|
|
54
|
+
posXMobile: "left" | "center" | "right";
|
|
55
|
+
posYMobile: "center" | "top" | "bottom";
|
|
56
|
+
};
|
|
40
57
|
}
|
|
41
58
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { default as FieldSelect, FieldSelectConfig, type FieldSelectConfigClasse
|
|
|
16
16
|
export { default as Fieldset, FieldsetConfig, type FieldsetConfigClasses, } from './components/Input/Fieldset.svelte';
|
|
17
17
|
export { default as ModalDialog, type ModalDialogAPI, } from './components/ModalDialog/ModalDialog.svelte';
|
|
18
18
|
export { createNotificationsStore, NOTIFICATION_EVENT, type NotiticationsCreateStoreOptions, type NotificationCreateParam, type Notification, type NotificationInput, type NotificationType, type NotificationOnEventHandler, type NotificationsSortOrder, type NotificationKnownClasses, } from './components/Notifications/notifications.js';
|
|
19
|
-
export { default as Notifications, NotificationsConfig, } from './components/Notifications/Notifications.svelte';
|
|
19
|
+
export { default as Notifications, NotificationsConfig, type NOTIFICATIONS_POSX, type NOTIFICATIONS_POSY, } from './components/Notifications/Notifications.svelte';
|
|
20
20
|
export { default as Popover } from './components/Popover/Popover.svelte';
|
|
21
21
|
export { default as Switch, SwitchConfig, type SwitchPreHook, } from './components/Switch/Switch.svelte';
|
|
22
22
|
export { default as Thc, type THC, isTHCNotEmpty } from './components/Thc/Thc.svelte';
|