@mulsense/xnew 0.6.2 → 0.6.4

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/dist/xnew.d.ts CHANGED
@@ -20,59 +20,49 @@ declare class MapMap<Key1, Key2, Value> extends Map<Key1, Map<Key2, Value>> {
20
20
  delete(key1: Key1, key2: Key2): boolean;
21
21
  }
22
22
 
23
- interface TimerOptions {
24
- transition?: Function;
25
- timeout?: Function;
26
- duration: number;
27
- iterations: number;
28
- easing?: string;
29
- }
30
-
31
23
  declare class Eventor {
32
24
  private map;
33
25
  add(element: HTMLElement | SVGElement, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
34
26
  remove(type: string, listener: Function): void;
35
- private basic;
36
- private resize;
37
- private change;
38
- private input;
39
- private click;
40
- private click_outside;
41
- private pointer;
42
- private mouse;
43
- private touch;
44
- private pointer_outside;
45
- private wheel;
46
- private drag;
47
- private gesture;
48
- private key;
49
- private key_arrow;
50
- private key_wasd;
27
+ private element_basic;
28
+ private element_resize;
29
+ private element_change;
30
+ private element_input;
31
+ private element_click;
32
+ private element_click_outside;
33
+ private element_pointer;
34
+ private element_mouse;
35
+ private element_touch;
36
+ private element_pointer_outside;
37
+ private element_wheel;
38
+ private element_drag;
39
+ private window_basic;
40
+ private window_key;
41
+ private window_key_arrow;
42
+ private window_key_wasd;
43
+ private document_basic;
51
44
  }
52
45
 
53
46
  type UnitElement = HTMLElement | SVGElement;
54
47
  declare class UnitPromise {
55
48
  promise: Promise<any>;
56
- component: Function | null;
57
- constructor(promise: Promise<any>, component: Function | null);
49
+ Component: Function | null;
50
+ constructor(promise: Promise<any>, Component: Function | null);
58
51
  then(callback: Function): UnitPromise;
59
52
  catch(callback: Function): UnitPromise;
60
53
  finally(callback: Function): UnitPromise;
54
+ private wrap;
61
55
  }
62
56
  declare class UnitTimer {
63
57
  private unit;
64
58
  private stack;
65
- constructor(options: TimerOptions);
66
59
  clear(): void;
67
- timeout(timeout: Function, duration?: number): this;
68
- iteration(timeout: Function, duration?: number, iterations?: number): this;
69
- transition(transition: Function, duration?: number, easing?: string): this;
70
- static execute(timer: UnitTimer, options: TimerOptions): void;
71
- static next(timer: UnitTimer): void;
72
- static Component(unit: Unit, { options, snapshot }: {
73
- options: TimerOptions;
74
- snapshot: Snapshot;
75
- }): void;
60
+ timeout(callback: Function, duration?: number): UnitTimer;
61
+ interval(callback: Function, duration?: number, iterations?: number): UnitTimer;
62
+ transition(transition: Function, duration?: number, easing?: string): UnitTimer;
63
+ private static execute;
64
+ private static next;
65
+ private static Component;
76
66
  }
77
67
  interface Context {
78
68
  stack: Context | null;
@@ -102,7 +92,10 @@ interface Internal {
102
92
  ancestors: Unit[];
103
93
  children: Unit[];
104
94
  promises: UnitPromise[];
105
- elements: UnitElement[];
95
+ nestElements: {
96
+ element: UnitElement;
97
+ owned: boolean;
98
+ }[];
106
99
  components: Function[];
107
100
  listeners: MapMap<string, Function, {
108
101
  element: UnitElement;
@@ -127,9 +120,9 @@ declare class Unit {
127
120
  reboot(): void;
128
121
  static initialize(unit: Unit, anchor: UnitElement | null): void;
129
122
  static finalize(unit: Unit): void;
130
- static nest(unit: Unit, tag: string, textContent?: string | number): UnitElement;
123
+ static nest(unit: Unit, target: UnitElement | string, textContent?: string | number): UnitElement;
131
124
  static currentComponent: Function;
132
- static extend(unit: Unit, component: Function, props?: Object): {
125
+ static extend(unit: Unit, Component: Function, props?: Object): {
133
126
  [key: string]: any;
134
127
  };
135
128
  static start(unit: Unit): void;
@@ -143,7 +136,7 @@ declare class Unit {
143
136
  static snapshot(unit: Unit): Snapshot;
144
137
  static context(unit: Unit, key: any, value?: any): any;
145
138
  static component2units: MapSet<Function, Unit>;
146
- static find(component: Function): Unit[];
139
+ static find(Component: Function): Unit[];
147
140
  static type2units: MapSet<string, Unit>;
148
141
  on(type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
149
142
  off(type?: string, listener?: Function): void;
@@ -154,20 +147,20 @@ declare class Unit {
154
147
 
155
148
  interface CreateUnit {
156
149
  /**
157
- * Creates a new Unit component
150
+ * creates a new Unit component
158
151
  * @param Component - component function
159
152
  * @param props - properties for component function
160
- * @returns A new Unit instance
153
+ * @returns a new Unit instance
161
154
  * @example
162
155
  * const unit = xnew(MyComponent, { data: 0 })
163
156
  */
164
157
  (Component?: Function | string, props?: Object): Unit;
165
158
  /**
166
- * Creates a new Unit component
159
+ * creates a new Unit component
167
160
  * @param target - HTMLElement | SVGElement, or HTML tag for new element
168
161
  * @param Component - component function
169
162
  * @param props - properties for component function
170
- * @returns A new Unit instance
163
+ * @returns a new Unit instance
171
164
  * @example
172
165
  * const unit = xnew(element, MyComponent, { data: 0 })
173
166
  * const unit = xnew('<div>', MyComponent, { data: 0 })
@@ -175,15 +168,20 @@ interface CreateUnit {
175
168
  (target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
176
169
  }
177
170
 
178
- declare function OpenAndClose(unit: Unit, { open }: {
171
+ interface TransitionOptions {
172
+ duration?: number;
173
+ easing?: string;
174
+ }
175
+ declare function OpenAndClose(unit: Unit, { open, transition }: {
179
176
  open?: boolean;
177
+ transition?: TransitionOptions;
180
178
  }): {
181
- toggle(duration?: number, easing?: string): void;
182
- open(duration?: number, easing?: string): void;
183
- close(duration?: number, easing?: string): void;
179
+ toggle(): void;
180
+ open(): void;
181
+ close(): void;
184
182
  };
185
183
  declare function Accordion(unit: Unit): void;
186
- declare function Modal(unit: Unit): void;
184
+ declare function Popup(unit: Unit): void;
187
185
 
188
186
  type ScreenFit = 'contain' | 'cover';
189
187
  declare function Screen(unit: Unit, { aspect, fit }?: {
@@ -275,12 +273,12 @@ declare namespace xnew {
275
273
  type UnitTimer = InstanceType<typeof UnitTimer>;
276
274
  }
277
275
  declare const xnew: CreateUnit & {
278
- nest(tag: string): HTMLElement | SVGElement;
279
- extend(component: Function, props?: Object): {
276
+ nest(target: UnitElement | string): HTMLElement | SVGElement;
277
+ extend(Component: Function, props?: Object): {
280
278
  [key: string]: any;
281
279
  };
282
280
  context(component: Function): any;
283
- promise(promise: Promise<any>): UnitPromise;
281
+ promise(promise: Promise<any> | Unit): UnitPromise;
284
282
  then(callback: Function): UnitPromise;
285
283
  catch(callback: Function): UnitPromise;
286
284
  finally(callback: Function): UnitPromise;
@@ -288,7 +286,7 @@ declare const xnew: CreateUnit & {
288
286
  find(component: Function): Unit[];
289
287
  emit(type: string, ...args: any[]): void;
290
288
  timeout(timeout: Function, duration?: number): UnitTimer;
291
- interval(timeout: Function, duration: number, iterations?: number): UnitTimer;
289
+ interval(interval: Function, duration: number, iterations?: number): UnitTimer;
292
290
  transition(transition: Function, duration?: number, easing?: string): UnitTimer;
293
291
  protect(): void;
294
292
  } & {
@@ -299,7 +297,7 @@ declare const xnew: CreateUnit & {
299
297
  DPad: typeof DPad;
300
298
  Panel: typeof Panel;
301
299
  Accordion: typeof Accordion;
302
- Modal: typeof Modal;
300
+ Popup: typeof Popup;
303
301
  };
304
302
  audio: {
305
303
  load(path: string): UnitPromise;