framework7 8.0.0-beta.7 → 8.0.0-beta.8

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
package/framework7.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
package/framework7.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
package/framework7.less CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Framework7 8.0.0-beta.7
2
+ * Framework7 8.0.0-beta.8
3
3
  * Full featured mobile HTML framework for building iOS & Android apps
4
4
  * https://framework7.io/
5
5
  *
@@ -6,6 +6,118 @@ import { id as generateId, merge, eventNameToColonCase, deleteProps } from '../.
6
6
  import vdom from './vdom.js';
7
7
  import patch from './patch.js';
8
8
  import $jsx from './$jsx.js';
9
+
10
+ /* eslint-disable no-shadow */
11
+ /* eslint-disable no-return-assign */
12
+ /* eslint-disable no-plusplus */
13
+ /* eslint-disable no-param-reassign */
14
+ /* eslint-disable no-sequences */
15
+ const types = [{
16
+ name: 'array',
17
+ init: i => i,
18
+ type: i => [i].find(Array.isArray),
19
+ update: (i, o) => [o].filter(Array.isArray).find(() => (i.length = 0, i.push(...o))),
20
+ insert: function (i, x, o) {
21
+ if (o === void 0) {
22
+ o = [];
23
+ }
24
+ return i.splice(Math.max(x, 0), 0, ...[o].flat());
25
+ },
26
+ replace: function (i, x, o) {
27
+ if (o === void 0) {
28
+ o = [];
29
+ }
30
+ return i.splice(Math.max(x, 0), Math.min(++x, 1), ...[o].flat());
31
+ },
32
+ append: function (i, o) {
33
+ if (o === void 0) {
34
+ o = [];
35
+ }
36
+ return i.push(...[o].flat());
37
+ },
38
+ prepend: function (i, o) {
39
+ if (o === void 0) {
40
+ o = [];
41
+ }
42
+ return i.unshift(...[o].flat());
43
+ },
44
+ swap: (i, a, b) => {
45
+ [i[a], i[b]] = [i[b], i[a]];
46
+ },
47
+ fromTo: function (i, a, b) {
48
+ if (b === void 0) {
49
+ b = a;
50
+ }
51
+ return i.splice(Math.max(b, 0), 0, ...i.splice(Math.max(a, 0), 1));
52
+ },
53
+ remove: function (i, o, a) {
54
+ if (a === void 0) {
55
+ a = i.map((_, x) => x);
56
+ }
57
+ return [o].flat().filter(i => a.includes(i)).sort((a, b) => b - a).forEach(x => i.splice(x, 1));
58
+ },
59
+ clear: i => i.length = 0
60
+ }, {
61
+ name: 'object',
62
+ init: i => i,
63
+ type: i => [i].filter(i => [i !== null, i !== undefined].every(i => i)).find(i => Object.getPrototypeOf(i) === Object.prototype),
64
+ update: (i, o) => Object.assign(i, o),
65
+ insert: () => {},
66
+ replace: () => {},
67
+ append: () => {},
68
+ prepend: () => {},
69
+ swap: () => ({}),
70
+ // N/A
71
+ fromTo: () => ({}),
72
+ // N/A
73
+ remove: (i, o) => [o].flat().forEach(k => delete i[k]),
74
+ clear: i => Object.keys(i).forEach(k => delete i[k])
75
+ }, {
76
+ name: 'atoms',
77
+ type: () => true,
78
+ init: function (i, o) {
79
+ if (o === void 0) {
80
+ o = {};
81
+ }
82
+ return Object.defineProperty(o, 'value', {
83
+ get: () => i,
84
+ set: v => {
85
+ // eslint-disable-next-line
86
+ i = v;
87
+ }
88
+ }), o;
89
+ },
90
+ update: function (i, v) {
91
+ if (v === void 0) {
92
+ v = i.value;
93
+ }
94
+ i.value = v;
95
+ },
96
+ insert: () => ({}),
97
+ // N/A
98
+ replace: () => ({}),
99
+ // N/A
100
+ append: () => ({}),
101
+ // N/A
102
+ prepend: () => ({}),
103
+ // N/A
104
+ swap: () => ({}),
105
+ // N/A
106
+ fromTo: () => ({}),
107
+ // N/A
108
+ remove: () => ({}),
109
+ // N/A
110
+ clear: i => {
111
+ i.value = undefined;
112
+ }
113
+ }];
114
+
115
+ /* eslint-enable no-shadow */
116
+ /* eslint-enable no-return-assign */
117
+ /* eslint-enable no-plusplus */
118
+ /* eslint-enable no-param-reassign */
119
+ /* eslint-enable no-sequences */
120
+
9
121
  class Component {
10
122
  constructor(app, component, props, _temp) {
11
123
  if (props === void 0) {
@@ -150,6 +262,84 @@ class Component {
150
262
  });
151
263
  return $store;
152
264
  }
265
+
266
+ /* eslint-disable no-sequences */
267
+ getUseState() {
268
+ var _this = this;
269
+ return o => [o].reduce(function (t, _i, _x, _a, i) {
270
+ if (i === void 0) {
271
+ i = t.init(_i);
272
+ }
273
+ return {
274
+ state: i,
275
+ update: v => (t.update(i, v), _this.update()),
276
+ remove: v => (t.remove(i, v), _this.update()),
277
+ clear: () => (t.clear(i), _this.update()),
278
+ insert: (x, v) => (t.insert(i, x, v), _this.update()),
279
+ replace: (x, v) => (t.replace(i, x, v), _this.update()),
280
+ append: v => (t.append(i, v), _this.update()),
281
+ prepend: v => (t.prepend(i, v), _this.update()),
282
+ swap: (a, b) => (t.swap(i, a, b), _this.update()),
283
+ fromTo: (a, b) => (t.fromTo(i, a, b), _this.update()),
284
+ method: function (f) {
285
+ if (f === void 0) {
286
+ f = () => ({});
287
+ }
288
+ return f(i), _this.update();
289
+ },
290
+ async: function (f) {
291
+ if (f === void 0) {
292
+ f = () => Promise.reject(i);
293
+ }
294
+ return f(i).then(() => _this.update());
295
+ }
296
+ };
297
+ }, types.find(i => i.type(o)));
298
+ }
299
+ _getUseState() {
300
+ var _this2 = this;
301
+ return o => [o].reduce(function (t, _i, _x, _a, i) {
302
+ if (i === void 0) {
303
+ i = t.init(_i);
304
+ }
305
+ return [i,
306
+ // state
307
+ v => (t.update(i, v), _this2.update()),
308
+ // update
309
+ v => (t.remove(i, v), _this2.update()),
310
+ // remove
311
+ () => (t.clear(i), _this2.update()),
312
+ // clear
313
+ (x, v) => (t.insert(i, x, v), _this2.update()),
314
+ // insert
315
+ (x, v) => (t.replace(i, x, v), _this2.update()),
316
+ // replace
317
+ v => (t.append(i, v), _this2.update()),
318
+ // append
319
+ v => (t.prepend(i, v), _this2.update()),
320
+ // prepend
321
+ (a, b) => (t.swap(i, a, b), _this2.update()),
322
+ // swap
323
+ (a, b) => (t.fromTo(i, a, b), _this2.update()),
324
+ // fromTo
325
+ function (f) {
326
+ if (f === void 0) {
327
+ f = () => ({});
328
+ }
329
+ return f(i), _this2.update();
330
+ },
331
+ // method
332
+ function (f) {
333
+ if (f === void 0) {
334
+ f = () => Promise.reject(i);
335
+ }
336
+ return f(i).then(() => _this2.update());
337
+ } // async
338
+ ];
339
+ }, types.find(i => i.type(o)));
340
+ }
341
+ /* eslint-enable no-sequences */
342
+
153
343
  getComponentContext(includeHooks) {
154
344
  const ctx = {
155
345
  $f7route: this.context.f7route,
@@ -165,7 +355,9 @@ class Component {
165
355
  $emit: this.emit.bind(this),
166
356
  $store: this.getComponentStore(),
167
357
  $ref: this.getComponentRef(),
168
- $el: {}
358
+ $el: {},
359
+ $useState: this.getUseState(),
360
+ $_useState: this._getUseState()
169
361
  };
170
362
  Object.defineProperty(ctx.$el, 'value', {
171
363
  get: () => {
@@ -34,6 +34,22 @@ export interface ComponentContext {
34
34
  /** Create reactive variable */
35
35
  $ref: (initialValue: any) => { value: any };
36
36
 
37
+ /** Create reactive state */
38
+ $useState: (initialValue: any) => {
39
+ state: any;
40
+ update: (value: any) => void;
41
+ remove: (pos: any) => void;
42
+ clear: () => void;
43
+ insert: (pos: any, value: any) => void;
44
+ replace: (pos: any, value: any) => void;
45
+ append: (value: any) => void;
46
+ prepend: (value: any) => void;
47
+ swap: (a: any, b: any) => void;
48
+ fromTo: (a: any, b: any) => void;
49
+ method: (f: any) => void;
50
+ async: (f: any) => void;
51
+ };
52
+
37
53
  /** Defer the callback to be executed after the next DOM update cycle. Use it immediately after you’ve changed some data to wait for the DOM update. */
38
54
  $tick: (callback?: () => void) => Promise<any>;
39
55
  /** Update/rerender component when state/data changed */
@@ -46,6 +46,7 @@ function parseComponent(componentString) {
46
46
  var $update = $$ctx.$update;
47
47
  var $store = $$ctx.$store;
48
48
  var $ref = $$ctx.$ref;
49
+ var $useState = $$ctx.$useState;
49
50
 
50
51
  return $h\`${template}\`
51
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework7",
3
- "version": "8.0.0-beta.7",
3
+ "version": "8.0.0-beta.8",
4
4
  "description": "Full featured mobile HTML framework for building iOS & Android apps",
5
5
  "type": "module",
6
6
  "exports": {