zumly 0.92.2 → 0.92.3

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
@@ -8,10 +8,10 @@
8
8
  <h1 align="center">ZUMLY</h1>
9
9
  <p align="center"><em>Z over XY</em></p>
10
10
 
11
- <p align="center"><strong>Focus-driven navigation.</strong></p>
12
- <p align="center"><strong>Zoom into what matters.</strong></p>
11
+ <p align="center"><strong>Focus-driven navigation. Zoom into what matters.</strong></p>
13
12
 
14
13
  <p align="center">
14
+ <a href="https://zumerlab.github.io/zumly/"><strong>Live Demo</strong></a> &nbsp;·&nbsp;
15
15
  <a href="https://www.npmjs.com/package/zumly"><img src="https://img.shields.io/npm/v/zumly.svg" alt="npm version"></a>
16
16
  </p>
17
17
 
package/dist/zumly.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * zumly
3
- * v.0.92.2
3
+ * v.0.92.3
4
4
  * Author Juan Martin Muda - Zumerlab
5
5
  * License MIT
6
6
  */
package/dist/zumly.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * zumly
3
- * v.0.92.2
3
+ * v.0.92.3
4
4
  * Author Juan Martin Muda - Zumerlab
5
5
  * License MIT
6
6
  */
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "zumly",
3
- "version": "0.92.2",
3
+ "version": "0.92.3",
4
4
  "description": "Javascript library for building zooming user interfaces",
5
5
  "type": "module",
6
6
  "author": "Juan Martin Muda - Zumerlab",
7
7
  "license": "MIT",
8
- "homepage": "https://zumerlab.github.io/zumly-docs",
8
+ "homepage": "https://zumerlab.github.io/zumly/",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/zumerlab/zumly.git"
@@ -57,6 +57,7 @@
57
57
  },
58
58
  "files": [
59
59
  "dist",
60
+ "types",
60
61
  "src/drivers/driver-helpers.js",
61
62
  "src/drivers/index.js",
62
63
  "docs/DRIVER_API.md",
@@ -0,0 +1,304 @@
1
+ // Type definitions for Zumly
2
+ // https://github.com/zumerlab/zumly
3
+
4
+ // ─── View sources ───────────────────────────────────────────────────
5
+
6
+ /** Context object passed to function and object view sources. */
7
+ export interface ViewContext {
8
+ /** A fresh <div> for mounting framework components. */
9
+ target: HTMLDivElement
10
+ /** The trigger element that initiated the zoom (if from a click). */
11
+ trigger?: HTMLElement
12
+ /** The componentContext from Zumly constructor options. */
13
+ context: Map<string, unknown> | Record<string, unknown>
14
+ /** Data attributes from the trigger element (e.g. data-id="42" → props.id). */
15
+ props: Record<string, string>
16
+ }
17
+
18
+ /** A function that receives context and returns a view. */
19
+ export type ViewFunction = (ctx: ViewContext) => string | HTMLElement | void | Promise<string | HTMLElement | void>
20
+
21
+ /** An object with a render method and optional mounted hook. */
22
+ export interface ViewObject {
23
+ render(ctx: ViewContext): string | HTMLElement | Promise<string | HTMLElement>
24
+ mounted?(): void | Promise<void>
25
+ }
26
+
27
+ /** All supported view source types. */
28
+ export type ViewSource = string | ViewFunction | ViewObject | HTMLElement
29
+
30
+ // ─── Options ────────────────────────────────────────────────────────
31
+
32
+ /** Built-in transition driver names. */
33
+ export type DriverName = 'css' | 'waapi' | 'none' | 'anime' | 'gsap' | 'motion'
34
+
35
+ /** Transition spec passed to custom driver functions. */
36
+ export interface TransitionSpec {
37
+ type: 'zoomIn' | 'zoomOut' | 'lateral'
38
+ currentView: HTMLElement
39
+ previousView: HTMLElement
40
+ lastView: HTMLElement | null
41
+ currentStage: ZoomSnapshot
42
+ duration: string
43
+ ease: string
44
+ canvas: HTMLElement
45
+ /** Lateral-specific fields (present when type === 'lateral') */
46
+ backView?: HTMLElement | null
47
+ backViewState?: { transformStart: string; transformEnd: string } | null
48
+ lastViewState?: { transformStart: string; transformEnd: string } | null
49
+ incomingTransformStart?: string
50
+ incomingTransformEnd?: string
51
+ outgoingTransform?: string
52
+ outgoingTransformEnd?: string
53
+ slideDeltaX?: number
54
+ slideDeltaY?: number
55
+ /** When true, driver should not remove the outgoing view from DOM (lateral keepAlive). */
56
+ keepAlive?: boolean
57
+ }
58
+
59
+ /** Custom driver function signature. */
60
+ export type DriverFunction = (spec: TransitionSpec, onComplete: () => void) => void
61
+
62
+ /** View state (transform + origin) stored in snapshots. */
63
+ export interface ViewState {
64
+ origin: string
65
+ transform: string
66
+ duration: string
67
+ ease: string
68
+ }
69
+
70
+ /** A single view entry in a zoom snapshot. */
71
+ export interface ViewEntry {
72
+ viewName: string
73
+ backwardState: ViewState
74
+ forwardState: ViewState
75
+ detachedNode?: HTMLElement
76
+ }
77
+
78
+ /** Zoom snapshot stored in the storedViews stack. */
79
+ export interface ZoomSnapshot {
80
+ level: number
81
+ views: [ViewEntry, ViewEntry, ViewEntry | null, ViewEntry | null]
82
+ scale?: number
83
+ stagger?: number
84
+ hideTriggerMode?: string
85
+ }
86
+
87
+ /** Transition configuration options. */
88
+ export interface TransitionOptions {
89
+ /** Transition driver. Default: 'css'. */
90
+ driver?: DriverName | DriverFunction
91
+ /** Which dimension to use for cover scale. Default: 'width'. */
92
+ cover?: 'width' | 'height'
93
+ /** CSS duration string. Default: '1s'. */
94
+ duration?: string
95
+ /** CSS easing function. Default: 'ease-in-out'. */
96
+ ease?: string
97
+ /** Array of 1-2 CSS filter strings for background view effects. */
98
+ effects?: [string] | [string, string]
99
+ /** Progressive delay (ms) between view layers during zoom. Default: 0. */
100
+ stagger?: number
101
+ /** Parallax intensity (0-1). Default: 0. */
102
+ parallax?: number
103
+ }
104
+
105
+ /** Lateral navigation UI configuration. */
106
+ export interface LateralNavOptions {
107
+ /** Display mode. 'auto' = only when view doesn't cover full canvas. 'always' = whenever siblings exist. Default: 'auto'. */
108
+ mode?: 'auto' | 'always'
109
+ /** Show prev/next arrow buttons. Default: true. */
110
+ arrows?: boolean
111
+ /** Show dot indicators. Default: true. */
112
+ dots?: boolean
113
+ /** Keep lateral views alive in the DOM. true = hidden, 'visible' = visible. Default: false. */
114
+ keepAlive?: boolean | 'visible'
115
+ /** Position of the lateral nav bar. Default: 'bottom-center'. */
116
+ position?: 'bottom-center' | 'top-center'
117
+ }
118
+
119
+ /** Depth navigation UI configuration. */
120
+ export interface DepthNavOptions {
121
+ /** Position of the back button. Default: 'bottom-left'. */
122
+ position?: 'bottom-left' | 'top-left'
123
+ }
124
+
125
+ /** Input types that can be individually enabled/disabled. */
126
+ export interface InputsOptions {
127
+ /** Enable wheel zoom-out. Default: true. */
128
+ wheel?: boolean
129
+ /** Enable keyboard navigation (arrow keys). Default: true. */
130
+ keyboard?: boolean
131
+ /** Enable click/mouseup navigation. Default: true. */
132
+ click?: boolean
133
+ /** Enable touch navigation. Default: true. */
134
+ touch?: boolean
135
+ }
136
+
137
+ /** Options for goTo(). */
138
+ export interface GoToOptions {
139
+ /** Navigation mode. Default: 'depth'. */
140
+ mode?: 'depth' | 'lateral'
141
+ /** Override transition duration. */
142
+ duration?: string
143
+ /** Override transition easing. */
144
+ ease?: string
145
+ /** Props to pass to the target view. */
146
+ props?: Record<string, unknown>
147
+ }
148
+
149
+ /** Options for zoomTo(). */
150
+ export interface ZoomToOptions {
151
+ /** Override transition duration. */
152
+ duration?: string
153
+ /** Override transition easing. */
154
+ ease?: string
155
+ /** Props to pass to the target view. */
156
+ props?: Record<string, unknown>
157
+ }
158
+
159
+ /** Depth nav position presets. */
160
+ export type DepthNavPosition = 'bottom-left' | 'top-left'
161
+
162
+ /** Lateral nav position presets. */
163
+ export type LateralNavPosition = 'bottom-center' | 'top-center'
164
+
165
+ /** Zumly constructor options. */
166
+ export interface ZumlyOptions {
167
+ /** CSS selector for the canvas element (must have class zumly-canvas). */
168
+ mount: string
169
+ /** Name of the first view to show. */
170
+ initialView: string
171
+ /** Map of view names to view sources. */
172
+ views: Record<string, ViewSource>
173
+ /** View names to resolve and cache on init(). */
174
+ preload?: string[]
175
+ /** Transition configuration. */
176
+ transitions?: TransitionOptions
177
+ /** Enable debug messages. Default: false. */
178
+ debug?: boolean
179
+ /** Context object passed to function/object view sources. */
180
+ componentContext?: Map<string, unknown> | Record<string, unknown>
181
+ /** Lateral navigation UI. true = default, false = disabled. */
182
+ lateralNav?: boolean | LateralNavOptions
183
+ /** Depth navigation UI. true = default (back button, bottom-left), false = disabled. */
184
+ depthNav?: boolean | DepthNavOptions
185
+ /** Input types to enable/disable. All enabled by default. */
186
+ inputs?: InputsOptions
187
+ /** Enable deferred rendering (view content inserted after zoom animation). */
188
+ deferred?: boolean
189
+ /** Hide trigger mode during zoom: 'fade', 'remove', or falsy. */
190
+ hideTrigger?: string | false
191
+ }
192
+
193
+ // ─── Events ─────────────────────────────────────────────────────────
194
+
195
+ export interface ZumlyEventMap {
196
+ viewMounted: { viewName: string; node: HTMLElement }
197
+ beforeZoomIn: { viewName: string }
198
+ afterZoomIn: { viewName: string; zoomLevel: number }
199
+ beforeZoomOut: { zoomLevel: number }
200
+ afterZoomOut: { zoomLevel: number }
201
+ beforeLateral: { viewName: string; from: string; isBack: boolean }
202
+ afterLateral: { viewName: string; from: string; isBack: boolean }
203
+ destroy: Record<string, never>
204
+ }
205
+
206
+ export type ZumlyEventName = keyof ZumlyEventMap
207
+
208
+ // ─── Plugin system ──────────────────────────────────────────────────
209
+
210
+ /** A Zumly plugin: object with install(), or a plain function. */
211
+ export interface ZumlyPlugin<T = unknown> {
212
+ install(instance: Zumly, options?: T): void
213
+ }
214
+
215
+ export type ZumlyPluginFunction<T = unknown> = (instance: Zumly, options?: T) => void
216
+
217
+ // ─── Router plugin ──────────────────────────────────────────────────
218
+
219
+ export interface RouterOptions {
220
+ /** Character used to join view path segments in the hash. Default: '/'. */
221
+ separator?: string
222
+ /** Prefix before the path in the hash. Default: '/'. */
223
+ prefix?: string
224
+ }
225
+
226
+ export const ZumlyRouter: ZumlyPlugin<RouterOptions>
227
+
228
+ // ─── Zumly class ────────────────────────────────────────────────────
229
+
230
+ export class Zumly {
231
+ constructor(options: ZumlyOptions)
232
+
233
+ /** Static reference to the Router plugin. */
234
+ static Router: ZumlyPlugin<RouterOptions>
235
+
236
+ /** Whether the instance was initialized with valid options. */
237
+ readonly isValid: boolean
238
+
239
+ /** Initialize the zoom interface: render initial view and bind events. */
240
+ init(): Promise<void>
241
+
242
+ /** Clean up: remove listeners, timers, navigation UI, and nullify state. Idempotent. */
243
+ destroy(): void
244
+
245
+ /**
246
+ * Subscribe to a lifecycle event.
247
+ * @returns this (chainable)
248
+ */
249
+ on<E extends ZumlyEventName>(event: E, fn: (data: ZumlyEventMap[E]) => void): this
250
+
251
+ /**
252
+ * Unsubscribe from a lifecycle event. If fn is omitted, removes all hooks for that event.
253
+ * @returns this (chainable)
254
+ */
255
+ off<E extends ZumlyEventName>(event: E, fn?: (data: ZumlyEventMap[E]) => void): this
256
+
257
+ /**
258
+ * Register a plugin. Plugins are installed during init(), or immediately if already initialized.
259
+ * @returns this (chainable)
260
+ */
261
+ use<T>(plugin: ZumlyPlugin<T> | ZumlyPluginFunction<T>, options?: T): this
262
+
263
+ /** Get the current zoom depth (number of stored snapshots). */
264
+ zoomLevel(): number
265
+
266
+ /** Alias for zoomLevel(). */
267
+ getZoomLevel(): number
268
+
269
+ /** Get the name of the currently active view, or null if not initialized. */
270
+ getCurrentViewName(): string | null
271
+
272
+ /**
273
+ * Navigate to a view by name. Unified API for depth and lateral navigation.
274
+ */
275
+ goTo(viewName: string, options?: GoToOptions): Promise<void>
276
+
277
+ /**
278
+ * Programmatic zoom to a named view (depth navigation).
279
+ * Uses a centered synthetic trigger for the transition.
280
+ */
281
+ zoomTo(viewName: string, options?: ZoomToOptions): Promise<void>
282
+
283
+ /** Zoom into the view indicated by a trigger element with data-to="viewName". */
284
+ zoomIn(el: HTMLElement): Promise<void>
285
+
286
+ /** Zoom out one level. No-op at root. */
287
+ zoomOut(): void
288
+
289
+ /**
290
+ * Navigate back. Pops lateral history first, then zooms out.
291
+ * Returns a Promise when navigating laterally.
292
+ */
293
+ back(): Promise<void> | void
294
+ }
295
+
296
+ export default Zumly
297
+
298
+ // ─── Driver helper types ────────────────────────────────────────────
299
+ // These types describe the exports from 'zumly/driver-helpers'.
300
+ // Use: import type { MatrixComponents } from 'zumly'
301
+
302
+ export interface MatrixComponents {
303
+ a: number; b: number; c: number; d: number; e: number; f: number
304
+ }