@marianmeres/stuic 2.1.26 → 2.1.28

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.
@@ -8,7 +8,7 @@
8
8
  border-button-border dark:border-button-border-dark
9
9
  rounded-md
10
10
  inline-flex items-center justify-center gap-x-2
11
- px-3 py-2
11
+ px-3 py-2.5
12
12
  select-none
13
13
 
14
14
  hover:brightness-105
@@ -24,7 +24,7 @@
24
24
 
25
25
  export const BUTTON_STUIC_PRESET_CLASSES: any = {
26
26
  size: {
27
- sm: `text-xs rounded-sm px-2 py-0.5`,
27
+ sm: `text-sm rounded-sm px-2 py-1`,
28
28
  lg: `text-base rounded-md`,
29
29
  },
30
30
  variant: {
@@ -1,4 +1,4 @@
1
- export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2\n\t\tselect-none\n\n\t\thover:brightness-105\n\t\tactive:brightness-95\n\t\tdisabled:hover:brightness-100 disabled:opacity-50\n\n\t\tfocus:brightness-105\n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
1
+ export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2.5\n\t\tselect-none\n\n\t\thover:brightness-105\n\t\tactive:brightness-95\n\t\tdisabled:hover:brightness-100 disabled:opacity-50\n\n\t\tfocus:brightness-105\n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
2
2
  export declare const BUTTON_STUIC_PRESET_CLASSES: any;
3
3
  import type { Snippet } from "svelte";
4
4
  import type { HTMLButtonAttributes } from "svelte/elements";
@@ -1,10 +1,14 @@
1
1
  import { createClog } from "@marianmeres/clog";
2
+ import { isBrowser } from "./is-browser.js";
2
3
  const clog = createClog("BodyScroll").debug;
4
+ const document = globalThis.document ?? {};
3
5
  /**
4
6
  * Helper for "locking" and "unlocking" body scroll (window.scrollY) position
5
7
  */
6
8
  export class BodyScroll {
7
9
  static lock() {
10
+ if (!isBrowser())
11
+ return;
8
12
  const data = document.body.dataset;
9
13
  // Only save the scroll position if it hasn't been saved already
10
14
  if (data.originalScrollY === undefined) {
@@ -27,6 +31,8 @@ export class BodyScroll {
27
31
  }
28
32
  }
29
33
  static unlock() {
34
+ if (!isBrowser())
35
+ return;
30
36
  const data = document.body.dataset;
31
37
  // Only proceed if scroll is currently locked
32
38
  if (data.scrollLockCount !== undefined) {
@@ -13,6 +13,7 @@ export * from "./is-nullish.js";
13
13
  export * from "./maybe-json-parse.js";
14
14
  export * from "./maybe-json-stringify.js";
15
15
  export * from "./nl2br.js";
16
+ export * from "./observe-exists.svelte.js";
16
17
  export * from "./omit-pick.js";
17
18
  export * from "./oscillate.js";
18
19
  export * from "./paint.js";
@@ -13,6 +13,7 @@ export * from "./is-nullish.js";
13
13
  export * from "./maybe-json-parse.js";
14
14
  export * from "./maybe-json-stringify.js";
15
15
  export * from "./nl2br.js";
16
+ export * from "./observe-exists.svelte.js";
16
17
  export * from "./omit-pick.js";
17
18
  export * from "./oscillate.js";
18
19
  export * from "./paint.js";
@@ -0,0 +1,8 @@
1
+ /** Will observe DOM changes and triggers callback when element presence changes */
2
+ export declare function observeExists(selector: string, options?: Partial<{
3
+ rootElement: HTMLElement;
4
+ }>): {
5
+ readonly current: boolean;
6
+ disconnect(): void;
7
+ forceCheck(): void;
8
+ };
@@ -0,0 +1,40 @@
1
+ /** Will observe DOM changes and triggers callback when element presence changes */
2
+ export function observeExists(selector, options = {}) {
3
+ if (!selector)
4
+ throw new TypeError("Expecting non empty selector");
5
+ const { rootElement = document.body } = options;
6
+ const ns = `[observeExists] [${selector}]`;
7
+ const clog = (...args) => console.debug(ns, ...args);
8
+ const check = () => rootElement.querySelector(selector) !== null;
9
+ let current = $state(check());
10
+ //
11
+ const observer = new MutationObserver((mutations) => {
12
+ let shouldCheck = false;
13
+ for (const mutation of mutations) {
14
+ if (mutation.type === "childList") {
15
+ // was something added or removed?
16
+ if (mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0) {
17
+ shouldCheck = true;
18
+ break;
19
+ }
20
+ }
21
+ }
22
+ if (shouldCheck)
23
+ current = check();
24
+ });
25
+ // start observing now
26
+ clog(`connecting...`);
27
+ observer.observe(rootElement, { childList: true, subtree: true });
28
+ return {
29
+ get current() {
30
+ return current;
31
+ },
32
+ disconnect() {
33
+ clog(`disconnecting...`);
34
+ observer.disconnect();
35
+ },
36
+ forceCheck() {
37
+ check();
38
+ },
39
+ };
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.1.26",
3
+ "version": "2.1.28",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
@@ -41,22 +41,22 @@
41
41
  "@marianmeres/icons-fns": "^4.4.0",
42
42
  "@marianmeres/random-human-readable": "^1.6.1",
43
43
  "@sveltejs/adapter-auto": "^4.0.0",
44
- "@sveltejs/kit": "^2.43.5",
44
+ "@sveltejs/kit": "^2.48.4",
45
45
  "@sveltejs/package": "^2.5.4",
46
46
  "@sveltejs/vite-plugin-svelte": "^5.1.1",
47
- "@tailwindcss/cli": "^4.1.13",
47
+ "@tailwindcss/cli": "^4.1.16",
48
48
  "@tailwindcss/forms": "^0.5.10",
49
49
  "@tailwindcss/typography": "^0.5.19",
50
- "@tailwindcss/vite": "^4.1.13",
50
+ "@tailwindcss/vite": "^4.1.16",
51
51
  "dotenv": "^16.6.1",
52
52
  "prettier": "^3.6.2",
53
53
  "prettier-plugin-svelte": "^3.4.0",
54
- "publint": "^0.3.13",
55
- "svelte": "^5.39.6",
56
- "svelte-check": "^4.3.2",
57
- "tailwindcss": "^4.1.13",
58
- "typescript": "^5.9.2",
59
- "vite": "^6.3.6",
54
+ "publint": "^0.3.15",
55
+ "svelte": "^5.43.2",
56
+ "svelte-check": "^4.3.3",
57
+ "tailwindcss": "^4.1.16",
58
+ "typescript": "^5.9.3",
59
+ "vite": "^6.4.1",
60
60
  "vitest": "^3.2.4"
61
61
  },
62
62
  "dependencies": {