@fuzdev/fuz_ui 0.200.0 → 0.202.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_ui",
3
- "version": "0.200.0",
3
+ "version": "0.202.0",
4
4
  "description": "Svelte UI library",
5
5
  "tagline": "friendly user zystem",
6
6
  "glyph": "🧶",
@@ -99,7 +99,7 @@
99
99
  "eslint": "^9.39.4",
100
100
  "eslint-plugin-svelte": "^3.19.0",
101
101
  "esm-env": "^1.2.2",
102
- "jsdom": "^27.2.0",
102
+ "jsdom": "^29.1.1",
103
103
  "magic-string": "^0.30.21",
104
104
  "prettier": "^3.7.4",
105
105
  "prettier-plugin-svelte": "^3.5.1",
package/src/lib/dialog.ts CHANGED
@@ -1,35 +1,38 @@
1
- import type {ComponentProps, Component} from 'svelte';
1
+ import {create_context} from './context_helpers.js';
2
2
 
3
- import type Dialog from './Dialog.svelte';
3
+ export type DialogAlign = 'center' | 'top';
4
+ export const dialog_aligns: Array<DialogAlign> = ['center', 'top'];
4
5
 
5
6
  /**
6
- * This helper function is needed to construct `DialogParams` with type safety.
7
- * It uses TypeScript's inferred generics for functions,
8
- * which do not work for plain objects as of v5.0.4.
9
- * * `ContextmenuParams` uses a similar strategy.
7
+ * Set by `Dialog`, read by `DialogContent`. Lets the content surface close the
8
+ * dialog without the consumer threading `close` through the `children` snippet.
10
9
  */
11
- export const to_dialog_params = <T extends Component<any>>(
12
- Component: T,
13
- props: ComponentProps<T>,
14
- dialog_props?: Partial<ComponentProps<typeof Dialog>>,
15
- ): DialogParams<T> => ({
16
- Component,
17
- props,
18
- dialog_props,
19
- });
10
+ export interface DialogContext {
11
+ /**
12
+ * Closes the dialog. When passed an event it's swallowed (default-prevented
13
+ * and propagation-stopped) before closing.
14
+ */
15
+ close: (e?: Event) => void;
16
+ /**
17
+ * Registers a content-surface element so a press inside it isn't treated as an
18
+ * outside-dismiss. The surface is known by node identity, independent of any
19
+ * class. Use as an attachment on the surface: `{@attach register_surface}`.
20
+ * Returns a cleanup that unregisters on unmount.
21
+ */
22
+ register_surface: (element: Element) => () => void;
23
+ }
24
+
25
+ export const dialog_context = create_context<DialogContext>();
20
26
 
21
27
  /**
22
- * This pattern is based on:
23
- * https://github.com/ivanhofer/sveltekit-typescript-showcase/blob/main/src/01-props/09-svelte-component/Component.svelte
24
- * The main limitation is that the generic cannot be inferred automatically,
25
- * so we use `to_dialog_params` to construct instances in most cases.
26
- * Definining `DialogParams` with no concrete `T` lacks typechecking for `props`.
28
+ * The `attrs` a custom `DialogContent` `close_button` snippet receives.
29
+ * Spread onto a `<button>` to inherit the corner-anchored close button.
27
30
  */
28
- export interface DialogParams<T extends Component<any> = Component<any>> {
29
- Component: T;
30
- props: ComponentProps<T>;
31
- dialog_props?: Partial<ComponentProps<typeof Dialog>> | undefined;
31
+ export interface DialogCloseButtonAttrs {
32
+ type: 'button';
33
+ class: string;
34
+ style: string;
35
+ onclick: DialogContext['close'];
36
+ title: string;
37
+ 'aria-label': string;
32
38
  }
33
-
34
- export type DialogLayout = 'centered' | 'page';
35
- export const dialog_layouts: Array<DialogLayout> = ['centered', 'page'];