@stacksjs/ui 0.70.160 → 0.70.162

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@ This package contains the Stacks UI engine.
4
4
 
5
5
  ## ☘️ Features
6
6
 
7
- - 🍀 **Vue-powered** _extendable & native access to the ecosystem_
7
+ - 🍀 **STX-powered** _extendable & native access to the ecosystem_
8
8
  - 🎨 **Style with ease** _via a blazingly fast utility-first CSS framework, powered by Headwind_
9
9
  - 🍍 **Simple data storage** _accessed via an intuitive API_
10
10
  - Written in modern ESM/TypeScript
@@ -1,4 +1,4 @@
1
- // Disclosure primitives were part of the former Vue compatibility layer.
1
+ // Disclosure primitives were part of the former compatibility layer.
2
2
  // stx does not expose them, so keep this module intentionally empty instead
3
3
  // of publishing exports that fail at runtime.
4
4
  export {};
@@ -1,2 +1,2 @@
1
- // Menu primitives were part of the former Vue compatibility layer.
1
+ // Menu primitives were part of the former compatibility layer.
2
2
  export {};
@@ -1,3 +1,22 @@
1
+ export declare function createModal<T = unknown>(initialValue?: T): ModalController<T>;
2
+ export declare function createAlert(initialValue?: AlertValue): ModalController<AlertValue>;
3
+ export declare interface ModalSnapshot<T = unknown> {
4
+ open: boolean
5
+ value?: T
6
+ }
7
+ export declare interface ModalController<T = unknown> {
8
+ readonly snapshot: ModalSnapshot<T>
9
+ open: (value?: T) => void
10
+ close: () => void
11
+ toggle: (value?: T) => void
12
+ subscribe: (listener: (snapshot: ModalSnapshot<T>) => void) => () => void
13
+ }
14
+ export declare interface AlertValue {
15
+ title: string
16
+ description?: string
17
+ tone?: AlertTone
18
+ }
19
+ export type AlertTone = 'info' | 'success' | 'warning' | 'danger';
1
20
  export {
2
21
  Dialog,
3
22
  DialogDescription,
@@ -4,3 +4,34 @@ export {
4
4
  DialogPanel,
5
5
  DialogTitle
6
6
  } from "@stacksjs/components";
7
+ export function createModal(initialValue) {
8
+ let snapshot = { open: !1, value: initialValue };
9
+ const listeners = new Set;
10
+ function publish(next) {
11
+ snapshot = next;
12
+ for (const listener of listeners)
13
+ listener(snapshot);
14
+ }
15
+ return {
16
+ get snapshot() {
17
+ return snapshot;
18
+ },
19
+ open(value = snapshot.value) {
20
+ publish({ open: !0, value });
21
+ },
22
+ close() {
23
+ publish({ ...snapshot, open: !1 });
24
+ },
25
+ toggle(value = snapshot.value) {
26
+ publish({ open: !snapshot.open, value });
27
+ },
28
+ subscribe(listener) {
29
+ listeners.add(listener);
30
+ listener(snapshot);
31
+ return () => listeners.delete(listener);
32
+ }
33
+ };
34
+ }
35
+ export function createAlert(initialValue) {
36
+ return createModal(initialValue);
37
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/ui",
3
3
  "type": "module",
4
- "version": "0.70.160",
4
+ "version": "0.70.162",
5
5
  "description": "The Stacks UI engine.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -61,9 +61,9 @@
61
61
  "@stacksjs/components": "^0.2.82"
62
62
  },
63
63
  "devDependencies": {
64
- "@stacksjs/build": "0.70.160",
65
- "@stacksjs/config": "0.70.160",
64
+ "@stacksjs/build": "0.70.162",
65
+ "@stacksjs/config": "0.70.162",
66
66
  "better-dx": "^0.2.17",
67
- "@stacksjs/router": "0.70.160"
67
+ "@stacksjs/router": "0.70.162"
68
68
  }
69
69
  }