@sveltia/ui 0.26.6 → 0.26.8

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.
@@ -34,6 +34,7 @@
34
34
  okDisabled = false,
35
35
  cancelLabel = '',
36
36
  cancelDisabled = false,
37
+ focusInput = true,
37
38
  children,
38
39
  header,
39
40
  headerExtra,
@@ -52,7 +53,7 @@
52
53
  const id = $props.id();
53
54
  /**
54
55
  * A reference to the modal component.
55
- * @type {any}
56
+ * @type {Modal | undefined}
56
57
  */
57
58
  let modal = $state();
58
59
  /**
@@ -64,10 +65,15 @@
64
65
  if (open && content) {
65
66
  (async () => {
66
67
  await sleep(50);
67
- /** @type {HTMLInputElement | HTMLButtonElement} */ (
68
- content?.querySelector('input, button.primary')
69
- )?.focus();
70
- /** @type {HTMLInputElement} */ (content?.querySelector('input'))?.select();
68
+
69
+ if (focusInput) {
70
+ /** @type {HTMLInputElement | HTMLButtonElement} */ (
71
+ content?.querySelector('input, button.primary')
72
+ )?.focus();
73
+ /** @type {HTMLInputElement} */ (content?.querySelector('input'))?.select();
74
+ } else {
75
+ modal?.focus();
76
+ }
71
77
  })();
72
78
  }
73
79
  });
@@ -36,6 +36,13 @@
36
36
  /* eslint-enable prefer-const */
37
37
  } = $props();
38
38
 
39
+ /**
40
+ * Focus the `<dialog>` element.
41
+ */
42
+ export const focus = () => {
43
+ dialog?.focus();
44
+ };
45
+
39
46
  /**
40
47
  * Close the modal.
41
48
  * @param {string} returnValue Return value to be used for `<dialog>`.
@@ -3,10 +3,12 @@ type Modal = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
4
  $set?(props: Partial<ModalProps & Record<string, any>>): void;
5
5
  } & {
6
+ focus: () => void;
6
7
  close: (returnValue: string) => void;
7
8
  };
8
9
  /** A generic modal top-layer helper based on the HTML `<dialog>` element. */
9
10
  declare const Modal: import("svelte").Component<ModalProps & Record<string, any>, {
11
+ focus: () => void;
10
12
  close: (returnValue: string) => void;
11
13
  }, "dialog" | "open">;
12
14
  import type { ModalProps } from '../../typedefs';
@@ -233,6 +233,11 @@ export type DialogProps = {
233
233
  * Whether to disable the Cancel button.
234
234
  */
235
235
  cancelDisabled?: boolean | undefined;
236
+ /**
237
+ * Whether to automatically focus the first input field or primary
238
+ * action button. Default: `true`. If `false`, the `<dialog>` gets focused.
239
+ */
240
+ focusInput?: boolean | undefined;
236
241
  /**
237
242
  * Whether to close the modal when the backdrop (outside of the
238
243
  * modal) is clicked.
package/dist/typedefs.js CHANGED
@@ -79,6 +79,8 @@
79
79
  * @property {boolean} [okDisabled] Whether to disable the OK button.
80
80
  * @property {string} [cancelLabel] Text label displayed on the Cancel button.
81
81
  * @property {boolean} [cancelDisabled] Whether to disable the Cancel button.
82
+ * @property {boolean} [focusInput] Whether to automatically focus the first input field or primary
83
+ * action button. Default: `true`. If `false`, the `<dialog>` gets focused.
82
84
  * @property {boolean} [lightDismiss] Whether to close the modal when the backdrop (outside of the
83
85
  * modal) is clicked.
84
86
  * @property {string} [value] Value entered on the textbox.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.26.6",
3
+ "version": "0.26.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -28,18 +28,18 @@
28
28
  "test:unit": "vitest"
29
29
  },
30
30
  "dependencies": {
31
- "@lexical/code": "^0.31.0",
32
- "@lexical/dragon": "^0.31.0",
33
- "@lexical/history": "^0.31.0",
34
- "@lexical/link": "^0.31.0",
35
- "@lexical/list": "^0.31.0",
36
- "@lexical/markdown": "^0.31.0",
37
- "@lexical/rich-text": "^0.31.0",
38
- "@lexical/selection": "^0.31.0",
39
- "@lexical/table": "^0.31.0",
40
- "@lexical/utils": "^0.31.0",
41
- "@sveltia/utils": "^0.7.3",
42
- "lexical": "^0.31.0",
31
+ "@lexical/code": "^0.31.1",
32
+ "@lexical/dragon": "^0.31.1",
33
+ "@lexical/history": "^0.31.1",
34
+ "@lexical/link": "^0.31.1",
35
+ "@lexical/list": "^0.31.1",
36
+ "@lexical/markdown": "^0.31.1",
37
+ "@lexical/rich-text": "^0.31.1",
38
+ "@lexical/selection": "^0.31.1",
39
+ "@lexical/table": "^0.31.1",
40
+ "@lexical/utils": "^0.31.1",
41
+ "@sveltia/utils": "^0.7.5",
42
+ "lexical": "^0.31.1",
43
43
  "prismjs": "^1.30.0"
44
44
  },
45
45
  "peerDependencies": {
@@ -47,32 +47,32 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@playwright/test": "^1.52.0",
50
- "@sveltejs/adapter-auto": "^6.0.0",
51
- "@sveltejs/kit": "^2.20.8",
50
+ "@sveltejs/adapter-auto": "^6.0.1",
51
+ "@sveltejs/kit": "^2.21.1",
52
52
  "@sveltejs/package": "^2.3.11",
53
53
  "@sveltejs/vite-plugin-svelte": "5.0.3",
54
- "cspell": "^8.19.3",
54
+ "cspell": "^9.0.1",
55
55
  "eslint": "^8.57.1",
56
56
  "eslint-config-airbnb-base": "^15.0.0",
57
- "eslint-config-prettier": "^10.1.2",
57
+ "eslint-config-prettier": "^10.1.5",
58
58
  "eslint-plugin-import": "^2.31.0",
59
- "eslint-plugin-jsdoc": "^50.6.11",
59
+ "eslint-plugin-jsdoc": "^50.6.17",
60
60
  "eslint-plugin-svelte": "^2.46.1",
61
61
  "postcss": "^8.5.3",
62
62
  "postcss-html": "^1.8.0",
63
63
  "prettier": "^3.5.3",
64
- "prettier-plugin-svelte": "^3.3.3",
65
- "sass": "^1.87.0",
64
+ "prettier-plugin-svelte": "^3.4.0",
65
+ "sass": "^1.89.0",
66
66
  "stylelint": "^16.19.1",
67
- "stylelint-config-recommended-scss": "^14.1.0",
68
- "stylelint-scss": "^6.11.1",
69
- "svelte": "5.28.2",
70
- "svelte-check": "^4.1.6",
67
+ "stylelint-config-recommended-scss": "^15.0.1",
68
+ "stylelint-scss": "^6.12.0",
69
+ "svelte": "5.31.1",
70
+ "svelte-check": "^4.2.1",
71
71
  "svelte-i18n": "^4.0.1",
72
72
  "svelte-preprocess": "^6.0.3",
73
73
  "tslib": "^2.8.1",
74
- "vite": "^6.3.4",
75
- "vitest": "^3.1.2"
74
+ "vite": "^6.3.5",
75
+ "vitest": "^3.1.4"
76
76
  },
77
77
  "exports": {
78
78
  ".": {