@surdeddd/wmkit 0.1.0 → 0.2.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.
Files changed (54) hide show
  1. package/README.md +14 -2
  2. package/README.ru.md +8 -2
  3. package/dist/{controller-D5zIriLg.d.ts → binder-BY-saDUB.d.cts} +9 -3
  4. package/dist/{controller-B0bogK9N.d.cts → binder-D9UEE1SM.d.ts} +9 -3
  5. package/dist/{chunk-7HHDQEBI.js → chunk-2TVOEDRG.js} +368 -247
  6. package/dist/chunk-2TVOEDRG.js.map +1 -0
  7. package/dist/{chunk-KWLI7JIY.cjs → chunk-KQCVZ2W7.cjs} +368 -247
  8. package/dist/chunk-KQCVZ2W7.cjs.map +1 -0
  9. package/dist/index.cjs +15 -15
  10. package/dist/index.d.cts +7 -4
  11. package/dist/index.d.ts +7 -4
  12. package/dist/index.js +1 -1
  13. package/dist/persist.cjs +1 -1
  14. package/dist/persist.cjs.map +1 -1
  15. package/dist/persist.d.cts +1 -1
  16. package/dist/persist.d.ts +1 -1
  17. package/dist/persist.js +1 -1
  18. package/dist/persist.js.map +1 -1
  19. package/dist/popout.cjs +1 -1
  20. package/dist/popout.cjs.map +1 -1
  21. package/dist/popout.d.cts +1 -1
  22. package/dist/popout.d.ts +1 -1
  23. package/dist/popout.js +1 -1
  24. package/dist/popout.js.map +1 -1
  25. package/dist/react.cjs +3 -3
  26. package/dist/react.cjs.map +1 -1
  27. package/dist/react.d.cts +2 -2
  28. package/dist/react.d.ts +2 -2
  29. package/dist/react.js +1 -1
  30. package/dist/react.js.map +1 -1
  31. package/dist/solid.cjs +3 -3
  32. package/dist/solid.cjs.map +1 -1
  33. package/dist/solid.d.cts +2 -2
  34. package/dist/solid.d.ts +2 -2
  35. package/dist/solid.js +1 -1
  36. package/dist/solid.js.map +1 -1
  37. package/dist/svelte.cjs +4 -4
  38. package/dist/svelte.cjs.map +1 -1
  39. package/dist/svelte.d.cts +2 -2
  40. package/dist/svelte.d.ts +2 -2
  41. package/dist/svelte.js +2 -2
  42. package/dist/svelte.js.map +1 -1
  43. package/dist/themes/glass.css +0 -1
  44. package/dist/{types-CtFzL_oA.d.cts → types-Bkrq2djr.d.cts} +9 -2
  45. package/dist/{types-CtFzL_oA.d.ts → types-Bkrq2djr.d.ts} +9 -2
  46. package/dist/vue.cjs +3 -3
  47. package/dist/vue.cjs.map +1 -1
  48. package/dist/vue.d.cts +2 -2
  49. package/dist/vue.d.ts +2 -2
  50. package/dist/vue.js +1 -1
  51. package/dist/vue.js.map +1 -1
  52. package/package.json +5 -5
  53. package/dist/chunk-7HHDQEBI.js.map +0 -1
  54. package/dist/chunk-KWLI7JIY.cjs.map +0 -1
package/README.md CHANGED
@@ -2,12 +2,16 @@
2
2
 
3
3
  **Headless window manager for the web.** Draggable, resizable, snappable windows with a taskbar model, keyboard accessibility and state persistence — for vanilla JS and every major framework.
4
4
 
5
- [Русская версия](./README.ru.md) · [Live demo](https://surdeddd.github.io/wmkit/) · [GitHub](https://github.com/Surdeddd/wmkit)
5
+ [Русская версия](./README.ru.md) · [Live demo](https://wmkit.vercel.app) · [Mirror (Pages)](https://surdeddd.github.io/wmkit/) · [GitHub](https://github.com/Surdeddd/wmkit)
6
6
 
7
7
  [![CI](https://github.com/Surdeddd/wmkit/actions/workflows/ci.yml/badge.svg)](https://github.com/Surdeddd/wmkit/actions/workflows/ci.yml)
8
8
  [![npm](https://img.shields.io/npm/v/@surdeddd/wmkit)](https://www.npmjs.com/package/@surdeddd/wmkit)
9
9
  [![license](https://img.shields.io/badge/license-MIT-2dd4a8)](./LICENSE)
10
10
 
11
+ [![wmkit — live demo desktop](https://raw.githubusercontent.com/Surdeddd/wmkit/main/.github/assets/hero.png)](https://surdeddd.github.io/wmkit/)
12
+
13
+ <p align="center"><em>Every window above is real — <a href="https://surdeddd.github.io/wmkit/">open the demo</a> and drag one.</em></p>
14
+
11
15
  - 🪟 **Full window lifecycle** — open, close, focus, minimize, maximize, restore, drag, 8-direction resize
12
16
  - 🧠 **Headless core** — a serializable state machine plus a DOM controller; bring your own markup or use the glass theme
13
17
  - ⚛️ **Official adapters** — `@surdeddd/wmkit/react`, `@surdeddd/wmkit/vue`, `@surdeddd/wmkit/svelte`, `@surdeddd/wmkit/solid`, all thin sugar over one core
@@ -50,7 +54,7 @@ el.innerHTML = `
50
54
  <div data-wm-content>Anything you want.</div>
51
55
  `
52
56
  document.querySelector('#desktop').append(el)
53
- desktop.attachWindow(win.id, el)
57
+ desktop.attachWindow(win.id, el, { removeOnClose: true })
54
58
  ```
55
59
 
56
60
  The desktop element becomes the coordinate space. Your markup stays yours — wmkit wires behavior onto `data-wm-*` attributes:
@@ -62,6 +66,8 @@ The desktop element becomes the coordinate space. Your markup stays yours — wm
62
66
  | `data-wm-close` / `data-wm-minimize` / `data-wm-maximize` | control buttons, wired by delegation |
63
67
  | `data-wm-content` | scrollable content area (styled by themes) |
64
68
 
69
+ `removeOnClose` detaches the controller and removes the element when the window closes. Touch devices get larger resize hit areas and snap thresholds automatically (`pointer: coarse`); tune via `attachDesktop(wm, el, { hitAreas: { edge, corner } })`.
70
+
65
71
  The controller adds resize handles (`[data-wm-resize]`), a snap preview (`[data-wm-snap-preview]`) and a visually hidden live region for screen readers.
66
72
 
67
73
  ## React
@@ -184,6 +190,12 @@ function Desktop() {
184
190
  }
185
191
  ```
186
192
 
193
+ ## Snap zones in action
194
+
195
+ [![Snap zones — window tiled to the left half](https://raw.githubusercontent.com/Surdeddd/wmkit/main/.github/assets/snap.png)](https://surdeddd.github.io/wmkit/)
196
+
197
+ Throw a window against an edge or corner — a live preview shows the target zone, releasing tiles it. Halves, quarters, and drag-to-top maximize.
198
+
187
199
  ## Core API
188
200
 
189
201
  ### `createWindowManager(options?)`
package/README.ru.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  **Headless оконный менеджер для веба.** Перетаскиваемые окна с ресайзом, снэпом, таскбаром, клавиатурной доступностью и персистом состояния — для vanilla JS и всех основных фреймворков.
4
4
 
5
- [English version](./README.md) · [Живое демо](https://surdeddd.github.io/wmkit/) · [GitHub](https://github.com/Surdeddd/wmkit)
5
+ [English version](./README.md) · [Живое демо](https://wmkit.vercel.app) · [Зеркало (Pages)](https://surdeddd.github.io/wmkit/) · [GitHub](https://github.com/Surdeddd/wmkit)
6
+
7
+ [![wmkit — живой демо-десктоп](https://raw.githubusercontent.com/Surdeddd/wmkit/main/.github/assets/hero.png)](https://surdeddd.github.io/wmkit/)
8
+
9
+ <p align="center"><em>Все окна выше настоящие — <a href="https://surdeddd.github.io/wmkit/">откройте демо</a> и потаскайте.</em></p>
6
10
 
7
11
  - 🪟 **Полный жизненный цикл окна** — открытие, закрытие, фокус, сворачивание, разворачивание, восстановление, drag, ресайз в 8 направлениях
8
12
  - 🧠 **Headless-ядро** — сериализуемая стейт-машина плюс DOM-контроллер; своя разметка или готовая стеклянная тема
@@ -46,7 +50,7 @@ el.innerHTML = `
46
50
  <div data-wm-content>Что угодно.</div>
47
51
  `
48
52
  document.querySelector('#desktop').append(el)
49
- desktop.attachWindow(win.id, el)
53
+ desktop.attachWindow(win.id, el, { removeOnClose: true })
50
54
  ```
51
55
 
52
56
  Элемент рабочего стола становится системой координат. Разметка остаётся вашей — wmkit вешает поведение на `data-wm-*` атрибуты:
@@ -58,6 +62,8 @@ desktop.attachWindow(win.id, el)
58
62
  | `data-wm-close` / `data-wm-minimize` / `data-wm-maximize` | кнопки управления, работают через делегирование |
59
63
  | `data-wm-content` | скроллируемая область контента |
60
64
 
65
+ `removeOnClose` сам отвязывает контроллер и удаляет элемент при закрытии окна. На тач-устройствах хит-зоны ресайза и порог снэпа автоматически крупнее (`pointer: coarse`); настраиваются через `attachDesktop(wm, el, { hitAreas: { edge, corner } })`.
66
+
61
67
  Контроллер добавляет ресайз-хендлы (`[data-wm-resize]`), превью снэпа (`[data-wm-snap-preview]`) и скрытый live-регион для скринридеров.
62
68
 
63
69
  ## Адаптеры
@@ -1,4 +1,4 @@
1
- import { B as Bounds, c as Size, d as SnapZone, W as WindowManager, i as WindowState } from './types-CtFzL_oA.js';
1
+ import { B as Bounds, f as Size, g as SnapZone, W as WindowManager, b as WindowState } from './types-Bkrq2djr.cjs';
2
2
 
3
3
  declare function clamp(value: number, min: number, max: number): number;
4
4
  declare function clampSize(size: Size, min: Size, max: Size | null): Size;
@@ -36,16 +36,22 @@ interface DesktopKeyboardOptions {
36
36
  moveStep?: number;
37
37
  cycle?: boolean;
38
38
  }
39
+ interface HitAreaOptions {
40
+ edge?: number;
41
+ corner?: number;
42
+ }
39
43
  interface DesktopOptions {
40
44
  snap?: boolean | DesktopSnapOptions;
41
45
  keyboard?: boolean | DesktopKeyboardOptions;
42
46
  announce?: boolean | Partial<AnnouncerMessages>;
43
47
  autoViewport?: boolean;
48
+ hitAreas?: HitAreaOptions;
44
49
  minimizeTarget?: (window: WindowState) => Element | null;
45
50
  }
46
51
  interface WindowAttachOptions {
47
52
  handle?: HTMLElement | string;
48
53
  resizeHandles?: boolean;
54
+ removeOnClose?: boolean;
49
55
  }
50
56
  interface DesktopController {
51
57
  element: HTMLElement;
@@ -53,7 +59,7 @@ interface DesktopController {
53
59
  attachWindow(id: string, element: HTMLElement, options?: WindowAttachOptions): () => void;
54
60
  destroy(): void;
55
61
  }
56
- declare function attachDesktop(wm: WindowManager, element: HTMLElement, options?: DesktopOptions): DesktopController;
62
+
57
63
  interface DesktopBinder {
58
64
  wm: WindowManager;
59
65
  controller(): DesktopController | null;
@@ -62,4 +68,4 @@ interface DesktopBinder {
62
68
  }
63
69
  declare function createDesktopBinder(wm: WindowManager, options?: DesktopOptions): DesktopBinder;
64
70
 
65
- export { type Announcer as A, type DesktopBinder as D, type SnapDetectOptions as S, type WindowAttachOptions as W, type AnnouncerMessages as a, type DesktopController as b, type DesktopKeyboardOptions as c, type DesktopOptions as d, type DesktopSnapOptions as e, attachDesktop as f, boundsEqual as g, clamp as h, clampSize as i, clampToViewport as j, createAnnouncer as k, createDesktopBinder as l, defaultMessages as m, detectSnapZone as n, zoneBounds as z };
71
+ export { type Announcer as A, type DesktopBinder as D, type HitAreaOptions as H, type SnapDetectOptions as S, type WindowAttachOptions as W, type DesktopController as a, type DesktopOptions as b, type AnnouncerMessages as c, type DesktopKeyboardOptions as d, type DesktopSnapOptions as e, boundsEqual as f, clamp as g, clampSize as h, clampToViewport as i, createAnnouncer as j, createDesktopBinder as k, defaultMessages as l, detectSnapZone as m, zoneBounds as z };
@@ -1,4 +1,4 @@
1
- import { B as Bounds, c as Size, d as SnapZone, W as WindowManager, i as WindowState } from './types-CtFzL_oA.cjs';
1
+ import { B as Bounds, f as Size, g as SnapZone, W as WindowManager, b as WindowState } from './types-Bkrq2djr.js';
2
2
 
3
3
  declare function clamp(value: number, min: number, max: number): number;
4
4
  declare function clampSize(size: Size, min: Size, max: Size | null): Size;
@@ -36,16 +36,22 @@ interface DesktopKeyboardOptions {
36
36
  moveStep?: number;
37
37
  cycle?: boolean;
38
38
  }
39
+ interface HitAreaOptions {
40
+ edge?: number;
41
+ corner?: number;
42
+ }
39
43
  interface DesktopOptions {
40
44
  snap?: boolean | DesktopSnapOptions;
41
45
  keyboard?: boolean | DesktopKeyboardOptions;
42
46
  announce?: boolean | Partial<AnnouncerMessages>;
43
47
  autoViewport?: boolean;
48
+ hitAreas?: HitAreaOptions;
44
49
  minimizeTarget?: (window: WindowState) => Element | null;
45
50
  }
46
51
  interface WindowAttachOptions {
47
52
  handle?: HTMLElement | string;
48
53
  resizeHandles?: boolean;
54
+ removeOnClose?: boolean;
49
55
  }
50
56
  interface DesktopController {
51
57
  element: HTMLElement;
@@ -53,7 +59,7 @@ interface DesktopController {
53
59
  attachWindow(id: string, element: HTMLElement, options?: WindowAttachOptions): () => void;
54
60
  destroy(): void;
55
61
  }
56
- declare function attachDesktop(wm: WindowManager, element: HTMLElement, options?: DesktopOptions): DesktopController;
62
+
57
63
  interface DesktopBinder {
58
64
  wm: WindowManager;
59
65
  controller(): DesktopController | null;
@@ -62,4 +68,4 @@ interface DesktopBinder {
62
68
  }
63
69
  declare function createDesktopBinder(wm: WindowManager, options?: DesktopOptions): DesktopBinder;
64
70
 
65
- export { type Announcer as A, type DesktopBinder as D, type SnapDetectOptions as S, type WindowAttachOptions as W, type AnnouncerMessages as a, type DesktopController as b, type DesktopKeyboardOptions as c, type DesktopOptions as d, type DesktopSnapOptions as e, attachDesktop as f, boundsEqual as g, clamp as h, clampSize as i, clampToViewport as j, createAnnouncer as k, createDesktopBinder as l, defaultMessages as m, detectSnapZone as n, zoneBounds as z };
71
+ export { type Announcer as A, type DesktopBinder as D, type HitAreaOptions as H, type SnapDetectOptions as S, type WindowAttachOptions as W, type DesktopController as a, type DesktopOptions as b, type AnnouncerMessages as c, type DesktopKeyboardOptions as d, type DesktopSnapOptions as e, boundsEqual as f, clamp as g, clampSize as h, clampToViewport as i, createAnnouncer as j, createDesktopBinder as k, defaultMessages as l, detectSnapZone as m, zoneBounds as z };