@txstate-mws/svelte-components 1.0.0 → 1.0.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.
@@ -10,6 +10,7 @@ let className = '';
10
10
  export { className as class };
11
11
  import { onMount, onDestroy, createEventDispatcher, tick } from 'svelte';
12
12
  import { tabbable } from 'tabbable';
13
+ import { sleep } from 'txstate-utils';
13
14
  import { buttonify } from '../actions';
14
15
  import ScreenReaderOnly from './ScreenReaderOnly.svelte';
15
16
  const dispatch = createEventDispatcher();
@@ -19,7 +20,7 @@ let active = true;
19
20
  let listenforescape = false;
20
21
  if (initialfocus)
21
22
  hidefocus = false;
22
- onMount(() => {
23
+ onMount(async () => {
23
24
  const prevFocusLock = FocusLockStack.slice(-1)[0];
24
25
  if (prevFocusLock)
25
26
  prevFocusLock.pause();
@@ -30,6 +31,7 @@ onMount(() => {
30
31
  if (typeof returnfocusto === 'undefined') {
31
32
  returnfocusto = document.querySelector(':focus');
32
33
  }
34
+ await sleep(1); // sapper resets focus on page load, so we'll wait a millisecond in case our modal is on screen at load
33
35
  if (initialfocus) {
34
36
  const focusEl = lockelement.querySelector(initialfocus);
35
37
  if (focusEl instanceof HTMLElement)
@@ -78,7 +80,7 @@ const focusin = (e) => {
78
80
  setInitialFocus();
79
81
  }
80
82
  };
81
- const windowclick = (e) => {
83
+ const windowclick = (_) => {
82
84
  if (listenforescape && active) {
83
85
  returnfocusto = undefined;
84
86
  dispatch('escape');
@@ -13,6 +13,7 @@
13
13
 
14
14
  import { onMount, onDestroy, createEventDispatcher, tick } from 'svelte'
15
15
  import { tabbable } from 'tabbable'
16
+ import { sleep } from 'txstate-utils'
16
17
  import { buttonify } from '../actions'
17
18
  import ScreenReaderOnly from './ScreenReaderOnly.svelte'
18
19
  const dispatch = createEventDispatcher()
@@ -21,7 +22,7 @@
21
22
  let active = true
22
23
  let listenforescape = false
23
24
  if (initialfocus) hidefocus = false
24
- onMount(() => {
25
+ onMount(async () => {
25
26
  const prevFocusLock = FocusLockStack.slice(-1)[0]
26
27
  if (prevFocusLock) prevFocusLock.pause()
27
28
  FocusLockStack.push({
@@ -31,6 +32,7 @@
31
32
  if (typeof returnfocusto === 'undefined') {
32
33
  returnfocusto = document.querySelector(':focus') as HTMLElement
33
34
  }
35
+ await sleep(1) // sapper resets focus on page load, so we'll wait a millisecond in case our modal is on screen at load
34
36
  if (initialfocus) {
35
37
  const focusEl = lockelement.querySelector(initialfocus)
36
38
  if (focusEl instanceof HTMLElement) focusEl.focus()
@@ -74,7 +76,7 @@
74
76
  else setInitialFocus()
75
77
  }
76
78
  }
77
- const windowclick = (e: MouseEvent) => {
79
+ const windowclick = (_: MouseEvent) => {
78
80
  if (listenforescape && active) {
79
81
  returnfocusto = undefined
80
82
  dispatch('escape')
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@txstate-mws/svelte-components",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Svelte components that are generically useful.",
5
5
  "main": "dist/index.js",
6
6
  "module": "esm/index.js",
7
- "svelte": "esm/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/index.js",
10
+ "import": "./esm/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
8
14
  "types": "dist/ts/index.d.ts",
9
15
  "scripts": {
10
16
  "test": "jest src",
@@ -31,17 +37,11 @@
31
37
  "@testing-library/jest-dom": "^5.11.9",
32
38
  "@testing-library/svelte": "^3.0.3",
33
39
  "@testing-library/user-event": "^13.1.9",
34
- "@tsconfig/svelte": "^2.0.1",
40
+ "@tsconfig/svelte": "^3.0.0",
35
41
  "@types/jest": "^27.0.2",
36
42
  "@types/node": "^15.3.1",
37
- "@typescript-eslint/eslint-plugin": "^4.14.1",
38
- "@typescript-eslint/parser": "^4.14.1",
39
43
  "babel-jest": "^27.3.1",
40
- "eslint": "^7.18.0",
41
44
  "eslint-config-standard-with-typescript": "^21.0.1",
42
- "eslint-plugin-import": "^2.22.0",
43
- "eslint-plugin-node": "^11.1.0",
44
- "eslint-plugin-promise": "^5.1.0",
45
45
  "eslint-plugin-svelte3": "^3.0.0",
46
46
  "fs-extra": "^10.0.0",
47
47
  "glob": "^7.1.6",