@casinogate/ui 1.8.2 → 1.8.3
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/dialog/_ui/nested-dialog/nested-dialog.svelte +9 -8
- package/dist/components/dialog/dialog-host-item.svelte +31 -3
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/model/dialog-manager.svelte.js +11 -13
- package/dist/components/dialog/styles.js +1 -1
- package/dist/components/dialog/types.d.ts +8 -1
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { Button } from '../../../button/index.js';
|
|
3
|
+
import { useDialogItemContext } from '../../dialog-host-item.svelte';
|
|
2
4
|
import { dialogs } from '../../model/dialog-manager.svelte.js';
|
|
5
|
+
|
|
6
|
+
const itemCtx = useDialogItemContext();
|
|
3
7
|
</script>
|
|
4
8
|
|
|
5
9
|
<div class="cgui:bg-surface-white cgui:max-w-140 cgui:p-4">
|
|
@@ -15,12 +19,9 @@
|
|
|
15
19
|
amet culpa culpa in id.
|
|
16
20
|
</p>
|
|
17
21
|
|
|
18
|
-
<
|
|
19
|
-
onclick={() =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
}}>Close</button
|
|
25
|
-
>
|
|
22
|
+
<div class="cgui:flex cgui:gap-2">
|
|
23
|
+
<Button variant="outline" onclick={() => dialogs.closeAll()}>Close all</Button>
|
|
24
|
+
|
|
25
|
+
<Button onclick={itemCtx.close}>Close Nested Dialog</Button>
|
|
26
|
+
</div>
|
|
26
27
|
</div>
|
|
@@ -16,11 +16,37 @@
|
|
|
16
16
|
|
|
17
17
|
let { component, props: dialogProps, options, open, id, close, update }: DialogItemState = $props();
|
|
18
18
|
|
|
19
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
interactOutsideBehavior = 'close',
|
|
21
|
+
escapeKeydownBehavior = 'close',
|
|
22
|
+
onOpenChange,
|
|
23
|
+
withOverlay = true,
|
|
24
|
+
contentClass,
|
|
25
|
+
positionerClass,
|
|
26
|
+
overlayClass,
|
|
27
|
+
contentProps: contentPropsOptions,
|
|
28
|
+
positionerProps: positionerPropsOptions,
|
|
29
|
+
overlayProps: overlayPropsOptions,
|
|
30
|
+
...restOptions
|
|
31
|
+
} = options;
|
|
32
|
+
|
|
20
33
|
const Component = $derived(component);
|
|
34
|
+
|
|
21
35
|
const contentProps = $derived({
|
|
22
36
|
interactOutsideBehavior,
|
|
23
37
|
escapeKeydownBehavior,
|
|
38
|
+
class: contentClass,
|
|
39
|
+
...contentPropsOptions,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const positionerProps = $derived({
|
|
43
|
+
class: positionerClass,
|
|
44
|
+
...positionerPropsOptions,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const overlayProps = $derived({
|
|
48
|
+
class: overlayClass,
|
|
49
|
+
...overlayPropsOptions,
|
|
24
50
|
});
|
|
25
51
|
|
|
26
52
|
DialogItemContext.set({
|
|
@@ -51,8 +77,10 @@
|
|
|
51
77
|
}
|
|
52
78
|
>
|
|
53
79
|
<Portal>
|
|
54
|
-
|
|
55
|
-
|
|
80
|
+
{#if withOverlay}
|
|
81
|
+
<Overlay {...overlayProps} />
|
|
82
|
+
{/if}
|
|
83
|
+
<Positioner {...positionerProps}>
|
|
56
84
|
<Content {...contentProps}>
|
|
57
85
|
<Component {...dialogProps} />
|
|
58
86
|
</Content>
|
|
@@ -2,4 +2,4 @@ export * as DialogPrimitive from './exports-primitive.js';
|
|
|
2
2
|
export * as Dialog from './exports.js';
|
|
3
3
|
export { useDialogItemContext } from './dialog-host-item.svelte';
|
|
4
4
|
export { dialogs } from './model/index.js';
|
|
5
|
-
export type { DialogCloseProps, DialogContentProps, DialogOptions, DialogOverlayProps, DialogPortalProps, DialogPositionerProps, DialogRootProps, ExtractRegisterdDialogs, RegisteredDialogCollection, RegisteredDialogKeys, RegisteredDialogsOverride,
|
|
5
|
+
export type { DialogCloseProps, DialogContentProps, DialogOptions, DialogOverlayProps, DialogPortalProps, DialogPositionerProps, DialogRootProps, ExtractRegisterdDialogs, RegisteredDialogCollection, RegisteredDialogKeys, RegisteredDialogsOverride, WithDialogProps, } from './types.js';
|
|
@@ -29,6 +29,17 @@ export class DialogManagerState {
|
|
|
29
29
|
'dialog:closeAll': () => this.#handleCloseAll(),
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
#updateDialog(id, fn) {
|
|
33
|
+
const dialogIndex = this.#dialogs.findIndex((d) => d.id === id);
|
|
34
|
+
if (dialogIndex === -1)
|
|
35
|
+
return;
|
|
36
|
+
const currentDialog = this.#dialogs[dialogIndex];
|
|
37
|
+
if (!currentDialog)
|
|
38
|
+
return;
|
|
39
|
+
const { props: newProps, options: newOptions } = fn(currentDialog.props, currentDialog.options);
|
|
40
|
+
currentDialog.props = { id, ...newProps };
|
|
41
|
+
currentDialog.options = newOptions;
|
|
42
|
+
}
|
|
32
43
|
#handleOpenRegistered(payload) {
|
|
33
44
|
const { key, props, options = {}, id } = payload;
|
|
34
45
|
const registeredValue = this.opts.register.current?.[key];
|
|
@@ -55,17 +66,6 @@ export class DialogManagerState {
|
|
|
55
66
|
const newDialogs = [...this.#dialogs.map((d) => ({ ...d, open: false })), state];
|
|
56
67
|
this.dialogs = newDialogs;
|
|
57
68
|
}
|
|
58
|
-
#updateDialog(id, fn) {
|
|
59
|
-
const dialogIndex = this.#dialogs.findIndex((d) => d.id === id);
|
|
60
|
-
if (dialogIndex === -1)
|
|
61
|
-
return;
|
|
62
|
-
const currentDialog = this.#dialogs[dialogIndex];
|
|
63
|
-
if (!currentDialog)
|
|
64
|
-
return;
|
|
65
|
-
const { props: newProps, options: newOptions } = fn(currentDialog.props, currentDialog.options);
|
|
66
|
-
currentDialog.props = { id, ...newProps };
|
|
67
|
-
currentDialog.options = newOptions;
|
|
68
|
-
}
|
|
69
69
|
#handleOpen(payload) {
|
|
70
70
|
const { component, props, options = {}, id } = payload;
|
|
71
71
|
const componentProps = {
|
|
@@ -89,7 +89,6 @@ export class DialogManagerState {
|
|
|
89
89
|
const { id } = payload;
|
|
90
90
|
for (let i = this.#dialogs.length - 1; i >= 0; i--) {
|
|
91
91
|
const dialog = this.#dialogs[i];
|
|
92
|
-
console.log('dialog IDX', i);
|
|
93
92
|
if (!dialog)
|
|
94
93
|
continue;
|
|
95
94
|
if (dialog.id === id) {
|
|
@@ -102,7 +101,6 @@ export class DialogManagerState {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
setTimeout(() => {
|
|
105
|
-
console.log('afterTick');
|
|
106
104
|
this.dialogs = this.dialogs.filter((d) => d.id !== id);
|
|
107
105
|
}, 150);
|
|
108
106
|
}
|
|
@@ -23,7 +23,7 @@ export const dialogOverlayStyles = tv({
|
|
|
23
23
|
});
|
|
24
24
|
export const dialogContentStyles = tv({
|
|
25
25
|
base: [
|
|
26
|
-
'cgui:z-(--z-index-dialog) cgui:outline-none cgui:overflow-hidden',
|
|
26
|
+
'cgui:relative cgui:z-(--z-index-dialog) cgui:outline-none cgui:overflow-hidden',
|
|
27
27
|
'cgui:data-[state=open]:animate-in cgui:data-[state=open]:fade-in-0 cgui:data-[state=open]:slide-in-from-bottom-20',
|
|
28
28
|
'cgui:data-[state=closed]:animate-out cgui:data-[state=closed]:fade-out-0 cgui:data-[state=closed]:slide-out-to-bottom-20',
|
|
29
29
|
],
|
|
@@ -34,8 +34,15 @@ export type DialogRegistrationOptions = {
|
|
|
34
34
|
interactOutsideBehavior?: DialogContentProps['interactOutsideBehavior'];
|
|
35
35
|
};
|
|
36
36
|
export type DialogOptions = Omit<DialogRootProps, 'open' | 'onOpenChangeComplete' | 'children'> & {
|
|
37
|
+
withOverlay?: boolean;
|
|
37
38
|
escapeKeydownBehavior?: Extract<DialogContentProps['escapeKeydownBehavior'], 'close' | 'ignore'>;
|
|
38
39
|
interactOutsideBehavior?: Extract<DialogContentProps['interactOutsideBehavior'], 'close' | 'ignore'>;
|
|
40
|
+
contentClass?: string;
|
|
41
|
+
positionerClass?: string;
|
|
42
|
+
overlayClass?: string;
|
|
43
|
+
contentProps?: Partial<Omit<DialogContentProps, 'id' | 'class' | 'children' | 'ref' | 'child'>>;
|
|
44
|
+
positionerProps?: Partial<Omit<DialogPositionerProps, 'id' | 'class' | 'children' | 'ref' | 'child'>>;
|
|
45
|
+
overlayProps?: Partial<Omit<DialogOverlayProps, 'id' | 'class' | 'children' | 'ref' | 'child'>>;
|
|
39
46
|
};
|
|
40
47
|
export type DialogItemState = {
|
|
41
48
|
id: string;
|
|
@@ -67,7 +74,7 @@ export type OpenDialogCommandPayload<TComponent extends DialogComponent = Dialog
|
|
|
67
74
|
export type CloseDialogCommandPayload = {
|
|
68
75
|
id: string;
|
|
69
76
|
};
|
|
70
|
-
export type
|
|
77
|
+
export type WithDialogProps<T extends Record<string, unknown>> = {
|
|
71
78
|
id: string;
|
|
72
79
|
} & T;
|
|
73
80
|
export type ExtractRegisterdDialogs<TData extends Record<string, DialogRegistrationValue>> = {
|