@marianmeres/stuic 1.62.0 → 1.64.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.
@@ -1,15 +1,16 @@
1
+ const _window = typeof window !== 'undefined' ? window : null;
1
2
  export class ColorScheme {
2
3
  static KEY = 'color-scheme';
3
4
  static DARK = 'dark';
4
5
  static LIGHT = 'light';
5
- static getSystemValue = () => window?.matchMedia(`(prefers-color-scheme: ${ColorScheme.DARK})`).matches
6
+ static getSystemValue = () => _window?.matchMedia(`(prefers-color-scheme: ${ColorScheme.DARK})`).matches
6
7
  ? ColorScheme.DARK
7
8
  : ColorScheme.LIGHT;
8
9
  static getLocalValue = (fallback = null) => localStorage?.getItem(ColorScheme.KEY) || fallback;
9
10
  static getValue = () => ColorScheme.getLocalValue(ColorScheme.getSystemValue());
10
11
  static toggle = () => {
11
12
  // returns bool, indicating whether token is in the list after the call or not.
12
- const isDark = window?.document.documentElement.classList.toggle(ColorScheme.DARK);
13
+ const isDark = _window?.document.documentElement.classList.toggle(ColorScheme.DARK);
13
14
  localStorage?.setItem(ColorScheme.KEY, isDark ? ColorScheme.DARK : ColorScheme.LIGHT);
14
15
  };
15
16
  static reset = () => {
package/dist/index.d.ts CHANGED
@@ -20,12 +20,13 @@ export { default as Popover } from './components/Popover/Popover.svelte';
20
20
  export { default as Switch, SwitchConfig } from './components/Switch/Switch.svelte';
21
21
  export { default as Thc, type THC, isTHCNotEmpty } from './components/Thc/Thc.svelte';
22
22
  export { default as X } from './components/X/X.svelte';
23
+ export { autogrow } from './actions/autogrow.js';
23
24
  export { focusTrap } from './actions/focus-trap.js';
24
25
  export { onOutside } from './actions/on-outside.js';
26
+ export { preSubmitValidityCheck } from './actions/pre-submit-validity-check.js';
25
27
  export { tooltip, TooltipConfig, type TooltipOptions, } from './actions/tooltip/tooltip.js';
26
28
  export { validate, type ValidateOptions, type ValidationResult, } from './actions/validate.js';
27
29
  export { trim } from './actions/trim.js';
28
- export { autogrow } from './actions/autogrow.js';
29
30
  export { calculateAlignment } from './utils/calculate-alignment.js';
30
31
  export { DevicePointer } from './utils/device-pointer.js';
31
32
  export { getId } from './utils/get-id.js';
package/dist/index.js CHANGED
@@ -35,12 +35,13 @@ export { default as Thc, isTHCNotEmpty } from './components/Thc/Thc.svelte';
35
35
  //
36
36
  export { default as X } from './components/X/X.svelte';
37
37
  // actions
38
+ export { autogrow } from './actions/autogrow.js';
38
39
  export { focusTrap } from './actions/focus-trap.js';
39
40
  export { onOutside } from './actions/on-outside.js';
41
+ export { preSubmitValidityCheck } from './actions/pre-submit-validity-check.js';
40
42
  export { tooltip, TooltipConfig, } from './actions/tooltip/tooltip.js';
41
43
  export { validate, } from './actions/validate.js';
42
44
  export { trim } from './actions/trim.js';
43
- export { autogrow } from './actions/autogrow.js';
44
45
  // utils
45
46
  export { calculateAlignment } from './utils/calculate-alignment.js';
46
47
  export { DevicePointer } from './utils/device-pointer.js';
@@ -1,5 +1,5 @@
1
1
  export declare class DevicePointer {
2
- static readonly isNone: boolean;
3
- static readonly isCoarse: boolean;
4
- static readonly isFine: boolean;
2
+ static readonly isNone: boolean | undefined;
3
+ static readonly isCoarse: boolean | undefined;
4
+ static readonly isFine: boolean | undefined;
5
5
  }
@@ -1,9 +1,10 @@
1
+ const _window = typeof window !== 'undefined' ? window : null;
1
2
  export class DevicePointer {
2
3
  // none - The primary input mechanism does not include a pointing device.
3
- static isNone = window?.matchMedia('(any-pointer:none)').matches;
4
+ static isNone = _window?.matchMedia('(any-pointer:none)').matches;
4
5
  // coarse - The primary input mechanism includes a pointing device of limited accuracy,
5
6
  // such as a finger on a touchscreen.
6
- static isCoarse = window?.matchMedia('(any-pointer:coarse)').matches;
7
+ static isCoarse = _window?.matchMedia('(any-pointer:coarse)').matches;
7
8
  // fine - The primary input mechanism includes an accurate pointing device, such as a mouse.
8
- static isFine = window?.matchMedia('(any-pointer:fine)').matches;
9
+ static isFine = _window?.matchMedia('(any-pointer:fine)').matches;
9
10
  }
@@ -1,6 +1,7 @@
1
1
  import { derived, writable } from 'svelte/store';
2
+ const _window = typeof window !== 'undefined' ? window : null;
2
3
  const getWindowSize = () => {
3
- const { width, height, scale } = window?.visualViewport || {
4
+ const { width, height, scale } = _window?.visualViewport || {
4
5
  width: 0,
5
6
  height: 0,
6
7
  scale: 1,
@@ -15,8 +16,8 @@ export const windowSize = {
15
16
  // init now!
16
17
  windowSize.touch();
17
18
  // intentionally not debounced
18
- window?.visualViewport?.addEventListener('resize', windowSize.touch);
19
- window?.visualViewport?.addEventListener('scroll', windowSize.touch);
19
+ _window?.visualViewport?.addEventListener('resize', windowSize.touch);
20
+ _window?.visualViewport?.addEventListener('scroll', windowSize.touch);
20
21
  export const breakpoint = derived([windowSize], ([{ width: w }]) => {
21
22
  const list = [
22
23
  ['sm', 640],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.62.0",
3
+ "version": "1.64.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",