framework7 8.0.0-beta.7 → 8.0.0-beta.9

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 (72) hide show
  1. package/components/actions/actions-md.less +1 -0
  2. package/components/actions/actions-rtl.css +1 -1
  3. package/components/actions/actions.css +1 -1
  4. package/components/actions/actions.less +4 -1
  5. package/components/button/button-ios.less +3 -0
  6. package/components/button/button-md.less +1 -4
  7. package/components/button/button-vars.less +10 -5
  8. package/components/button/button.less +0 -1
  9. package/components/data-table/data-table-md.less +0 -1
  10. package/components/data-table/data-table-rtl.css +1 -1
  11. package/components/data-table/data-table.css +1 -1
  12. package/components/dialog/dialog-rtl.css +1 -1
  13. package/components/dialog/dialog-vars.less +2 -2
  14. package/components/dialog/dialog.css +1 -1
  15. package/components/fab/fab-ios.less +1 -0
  16. package/components/fab/fab-md.less +9 -0
  17. package/components/fab/fab-rtl.css +1 -1
  18. package/components/fab/fab-vars.less +5 -1
  19. package/components/fab/fab.css +1 -1
  20. package/components/fab/fab.less +0 -3
  21. package/components/list/list-md.less +5 -0
  22. package/components/list/list-vars.less +7 -7
  23. package/components/list/list.less +4 -1
  24. package/components/navbar/navbar-md.less +0 -1
  25. package/components/notification/notification-rtl.css +1 -1
  26. package/components/notification/notification.css +1 -1
  27. package/components/notification/notification.less +0 -2
  28. package/components/photo-browser/photo-browser-rtl.css +1 -1
  29. package/components/photo-browser/photo-browser.css +1 -1
  30. package/components/photo-browser/photo-browser.less +2 -2
  31. package/components/searchbar/searchbar-md.less +0 -3
  32. package/components/searchbar/searchbar-rtl.css +1 -1
  33. package/components/searchbar/searchbar.css +1 -1
  34. package/components/searchbar/searchbar.less +5 -1
  35. package/components/stepper/stepper-md.less +2 -2
  36. package/components/stepper/stepper-rtl.css +1 -1
  37. package/components/stepper/stepper-vars.less +2 -1
  38. package/components/stepper/stepper.css +1 -1
  39. package/components/subnavbar/subnavbar-md.less +0 -1
  40. package/components/text-editor/text-editor-md.less +0 -1
  41. package/components/text-editor/text-editor-rtl.css +1 -1
  42. package/components/text-editor/text-editor.css +1 -1
  43. package/components/toast/toast-rtl.css +1 -1
  44. package/components/toast/toast.css +1 -1
  45. package/components/toast/toast.less +0 -1
  46. package/components/toolbar/toolbar-md.less +0 -1
  47. package/components/touch-ripple/touch-ripple-class.js +2 -2
  48. package/components/touch-ripple/touch-ripple-vars.less +1 -1
  49. package/components/touch-ripple/touch-ripple.less +41 -4
  50. package/framework7-bundle-rtl.css +90 -262
  51. package/framework7-bundle-rtl.min.css +3 -3
  52. package/framework7-bundle.css +90 -262
  53. package/framework7-bundle.esm.js +2 -2
  54. package/framework7-bundle.js +181 -7
  55. package/framework7-bundle.js.map +1 -1
  56. package/framework7-bundle.less +2 -2
  57. package/framework7-bundle.min.css +3 -3
  58. package/framework7-bundle.min.js +3 -3
  59. package/framework7-bundle.min.js.map +1 -1
  60. package/framework7-lite-bundle.esm.js +2 -2
  61. package/framework7-lite.esm.js +2 -2
  62. package/framework7-rtl.css +63 -115
  63. package/framework7-rtl.min.css +3 -3
  64. package/framework7.css +63 -115
  65. package/framework7.esm.js +2 -2
  66. package/framework7.less +2 -2
  67. package/framework7.min.css +3 -3
  68. package/modules/component/component-class.js +174 -1
  69. package/modules/component/component.d.ts +16 -0
  70. package/modules/component/parse-component.js +1 -0
  71. package/modules/touch/touch.js +2 -2
  72. package/package.json +2 -2
@@ -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,66 @@ 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 => {
270
+ const obj = [o].reduce(function (t, _i, _x, _a, i) {
271
+ if (i === void 0) {
272
+ i = t.init(_i);
273
+ }
274
+ return {
275
+ state: i,
276
+ update: v => (t.update(i, v), _this.update()),
277
+ remove: v => (t.remove(i, v), _this.update()),
278
+ clear: () => (t.clear(i), _this.update()),
279
+ insert: (x, v) => (t.insert(i, x, v), _this.update()),
280
+ replace: (x, v) => (t.replace(i, x, v), _this.update()),
281
+ append: v => (t.append(i, v), _this.update()),
282
+ prepend: v => (t.prepend(i, v), _this.update()),
283
+ swap: (a, b) => (t.swap(i, a, b), _this.update()),
284
+ fromTo: (a, b) => (t.fromTo(i, a, b), _this.update()),
285
+ method: function (f) {
286
+ if (f === void 0) {
287
+ f = () => ({});
288
+ }
289
+ return f(i), _this.update();
290
+ },
291
+ async: function (f) {
292
+ if (f === void 0) {
293
+ f = () => Promise.reject(i);
294
+ }
295
+ return f(i).then(() => _this.update());
296
+ }
297
+ };
298
+ }, types.find(i => i.type(o)));
299
+ obj.length = 12;
300
+ obj[Symbol.iterator] = function Iterate() {
301
+ const values = Object.values(this);
302
+ values.splice(values.indexOf(12), 1);
303
+ let index = 0;
304
+ return {
305
+ next() {
306
+ if (index < values.length) {
307
+ const val = values[index];
308
+ index += 1;
309
+ return {
310
+ value: val,
311
+ done: false
312
+ };
313
+ }
314
+ return {
315
+ done: true
316
+ };
317
+ }
318
+ };
319
+ };
320
+ return obj;
321
+ };
322
+ }
323
+ /* eslint-enable no-sequences */
324
+
153
325
  getComponentContext(includeHooks) {
154
326
  const ctx = {
155
327
  $f7route: this.context.f7route,
@@ -165,7 +337,8 @@ class Component {
165
337
  $emit: this.emit.bind(this),
166
338
  $store: this.getComponentStore(),
167
339
  $ref: this.getComponentRef(),
168
- $el: {}
340
+ $el: {},
341
+ $useState: this.getUseState()
169
342
  };
170
343
  Object.defineProperty(ctx.$el, 'value', {
171
344
  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
  }
@@ -454,11 +454,11 @@ export default {
454
454
  tapHoldPreventClicks: true,
455
455
  // Active State
456
456
  activeState: true,
457
- activeStateElements: 'a, button, label, span, .actions-button, .stepper-button, .stepper-button-plus, .stepper-button-minus, .card-expandable, .menu-item, .link, .item-link, .accordion-item-toggle',
457
+ activeStateElements: 'a, button, label, span, .actions-button, .stepper-button, .stepper-button-plus, .stepper-button-minus, .card-expandable, .link, .item-link, .accordion-item-toggle',
458
458
  activeStateOnMouseMove: false,
459
459
  mdTouchRipple: true,
460
460
  iosTouchRipple: false,
461
- touchRippleElements: '.ripple, .link, .item-link, .list label.item-content, .list-button, .links-list a, .button, button, .input-clear-button, .dialog-button, .tab-link, .item-radio, .item-checkbox, .actions-button, .searchbar-disable-button, .fab a, .checkbox, .radio, .data-table .sortable-cell:not(.input-cell), .notification-close-button, .stepper-button, .stepper-button-minus, .stepper-button-plus, .menu-item-content, .list.accordion-list .accordion-item-toggle',
461
+ touchRippleElements: '.ripple, .link, .item-link, .list label.item-content, .list-button, .links-list a, .button, button, .input-clear-button, .dialog-button, .tab-link, .item-radio, .item-checkbox, .actions-button, .searchbar-disable-button, .fab a, .checkbox, .radio, .data-table .sortable-cell:not(.input-cell), .notification-close-button, .stepper-button, .stepper-button-minus, .stepper-button-plus, .list.accordion-list .accordion-item-toggle',
462
462
  touchRippleInsetElements: '.ripple-inset, .icon-only, .searchbar-disable-button, .input-clear-button, .notification-close-button, .md .navbar .link.back'
463
463
  }
464
464
  },
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.9",
4
4
  "description": "Full featured mobile HTML framework for building iOS & Android apps",
5
5
  "type": "module",
6
6
  "exports": {
@@ -436,5 +436,5 @@
436
436
  "ssr-window": "^4.0.2",
437
437
  "swiper": "^9.1.1"
438
438
  },
439
- "releaseDate": "March 27, 2023"
439
+ "releaseDate": "March 31, 2023"
440
440
  }