Skip to content

Commit 2d234ba

Browse files
committed
3.4.0 release
1 parent ee10869 commit 2d234ba

File tree

259 files changed

+31633
-4482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+31633
-4482
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
# Change Log
44

5+
# [v3.4.0](https://github.com/framework7io/framework7/compare/v3.3.2...v3.4.0) - September 28, 2018
6+
* Core
7+
* Lazy modules support 🎉
8+
* Added support to load F7 modules during runtime with new app methods:
9+
* New `app.loadModule(module)` method to load F7 module
10+
* New `app.loadModules([module])` method to load array of F7 modules
11+
* New `lazyModulesPath` app parameter to specify lazy modules location
12+
* New lazy component files in `lazy-components/` package folder
13+
* New `js/framework7-lazy.js` script containing core version of Framework7
14+
* New `css/framework7-lazy.css` styles containing core version of Framework7
15+
* Router
16+
* New Route's `modules` parameter to load F7 modules before entering the route
17+
* Statusbar
18+
* Added new `statusbar` app parameters:
19+
* `androidOverlaysWebView` (by default `false`)
20+
* `androidTextColor` (by default `black`)
21+
* `androidBackgroundColor` (by default `null`)
22+
* Added new `app.statusbar` app methods:
23+
* `app.statusbar.overlaysWebView(overlays)`
24+
* `app.statusbar.setTextColor(color)`
25+
* Phenome
26+
* Lots of TypeScript definitions fixes and tweaks
27+
* Minor fixes
28+
29+
530
# [v3.3.2](https://github.com/framework7io/framework7/compare/v3.3.1...v3.3.2) - September 20, 2018
631
* Core
732
* Support for new iPhone XR / XS / XS Max

packages/core/components/accordion/accordion.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ const Accordion = {
3434
$contentEl.css('height', 'auto');
3535
Utils.nextFrame(() => {
3636
$contentEl.transition('');
37-
$el.trigger('accordion:opened');
38-
app.emit('accordionOpened', $el[0]);
3937
});
38+
$contentEl.transition('');
39+
$el.trigger('accordion:opened');
40+
app.emit('accordionOpened', $el[0]);
4041
} else {
4142
$contentEl.css('height', '');
4243
$el.trigger('accordion:closed');
@@ -64,9 +65,9 @@ const Accordion = {
6465
$contentEl.css('height', 'auto');
6566
Utils.nextFrame(() => {
6667
$contentEl.transition('');
67-
$el.trigger('accordion:opened');
68-
app.emit('accordionOpened', $el[0]);
6968
});
69+
$el.trigger('accordion:opened');
70+
app.emit('accordionOpened', $el[0]);
7071
} else {
7172
$contentEl.css('height', '');
7273
$el.trigger('accordion:closed');
@@ -77,7 +78,7 @@ const Accordion = {
7778
$contentEl.transition('');
7879
$contentEl.css('height', '');
7980
$el.trigger('accordion:close');
80-
app.emit('accordionClose');
81+
app.emit('accordionClose', $el[0]);
8182
});
8283
},
8384
toggle(el) {

packages/core/components/actions/actions.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ export namespace Actions {
147147

148148
declare const ActionsComponent: Framework7Plugin;
149149

150-
export default ActionsComponent;
150+
export default ActionsComponent;

packages/core/components/app/app-class.d.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Dom7, Dom7Instance } from 'Dom7'
2-
import Template7 from 'Template7'
1+
import { Dom7, Dom7Instance } from 'dom7'
2+
import Template7 from 'template7'
33
import { Router } from '../../modules/router/router';
4-
import Device, { Device as DeviceInterface } from '../../utils/device';
5-
import Request, { Request as RequestInterface } from '../../utils/request';
6-
import Support, { Support as SupportInterface } from '../../utils/support';
7-
import Utils, { Utils as UtilsInterface } from '../../utils/utils';
4+
import { Device } from '../../utils/device';
5+
import { Request } from '../../utils/request';
6+
import { Support } from '../../utils/support';
7+
import { Utils } from '../../utils/utils';
88

99
// Css Selector string is an option on many F7 methods
1010
// Giving this alias makes the typename show in the intellisense
@@ -56,6 +56,8 @@ export interface Framework7Params {
5656
data? : () => any
5757
/** App root methods. Object with methods. Note, that this inside of each method points to app Framework7 instance.. (default {}) */
5858
methods? : { [name : string] : () => any }
59+
/** Lazy modules path */
60+
lazyModulesPath?: string
5961
/** By default Framework7 will be initialized automatically when you call new Framework7(). If you want to prevent this behavior you can disable it with this option and then initialize it manually with init() when you need it.. (default true) */
6062
init? : boolean
6163
/** If automatic initialization is enabled with init: true parameter and app is running under cordova environment then it will be initialized on deviceready event.. (default true) */
@@ -141,16 +143,20 @@ interface Framework7 extends Framework7Class<Framework7Events> {
141143
params : Framework7Params
142144
/** Initialize app. In case you disabled auto initialization with init: false parameter */
143145
init() : void
146+
/** Load module */
147+
loadModule(module: string | Function | Framework7Plugin) : Promise
148+
/** Load modules */
149+
loadModules(modules: any[]) : Promise
144150
}
145151

146152
declare class Framework7 implements Framework7 {
147153
constructor(parameters?: Framework7Params);
148154

149155
static use(plugin : Framework7Plugin) : void;
150-
static device: DeviceInterface = Device;
151-
static request: RequestInterface = Request;
152-
static support: SupportInterface = Support;
153-
static utils: UtilsInterface = Utils;
156+
static device: Device;
157+
static request: Request;
158+
static support: Support;
159+
static utils: Utils;
154160
}
155161

156-
export default Framework7;
162+
export default Framework7;

packages/core/components/app/app-class.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { window, document } from 'ssr-window';
44
import Utils from '../../utils/utils';
55
import Device from '../../utils/device';
66
import Framework7Class from '../../utils/class';
7+
import ConstructorMethods from '../../utils/constructor-methods';
8+
import ModalMethods from '../../utils/modal-methods';
9+
import loadModule from './load-module';
710

811
class Framework7 extends Framework7Class {
912
constructor(params) {
@@ -14,6 +17,8 @@ class Framework7 extends Framework7Class {
1417
// App Instance
1518
const app = this;
1619

20+
Framework7.instance = app;
21+
1722
// Default
1823
const defaults = {
1924
version: '1.0.0',
@@ -23,6 +28,7 @@ class Framework7 extends Framework7Class {
2328
language: window.navigator.language,
2429
routes: [],
2530
name: 'Framework7',
31+
lazyModulesPath: null,
2632
initOnDeviceReady: true,
2733
init: true,
2834
};
@@ -129,6 +135,16 @@ class Framework7 extends Framework7Class {
129135
return app;
130136
}
131137

138+
// eslint-disable-next-line
139+
loadModule(...args) {
140+
return Framework7.loadModule(...args);
141+
}
142+
143+
// eslint-disable-next-line
144+
loadModules(...args) {
145+
return Framework7.loadModules(...args);
146+
}
147+
132148
getVnodeHooks(hook, id) {
133149
const app = this;
134150
if (!app.vnodeHooks || !app.vnodeHooks[hook]) return [];
@@ -161,4 +177,12 @@ class Framework7 extends Framework7Class {
161177
}
162178
}
163179

180+
Framework7.ModalMethods = ModalMethods;
181+
Framework7.ConstructorMethods = ConstructorMethods;
182+
183+
Framework7.loadModule = loadModule;
184+
Framework7.loadModules = function loadModules(modules) {
185+
return Promise.all(modules.map(module => Framework7.loadModule(module)));
186+
};
187+
164188
export default Framework7;
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import $ from 'dom7';
2+
import Utils from '../../utils/utils';
3+
4+
const fetchedModules = [];
5+
function loadModule(moduleToLoad) {
6+
const Framework7 = this;
7+
return new Promise((resolve, reject) => {
8+
const app = Framework7.instance;
9+
let modulePath;
10+
let moduleObj;
11+
let moduleFunc;
12+
if (!moduleToLoad) {
13+
reject(new Error('Framework7: Lazy module must be specified'));
14+
return;
15+
}
16+
17+
function install(module) {
18+
Framework7.use(module);
19+
20+
if (app) {
21+
app.useModuleParams(module, app.params);
22+
app.useModule(module);
23+
}
24+
}
25+
26+
if (typeof moduleToLoad === 'string') {
27+
const matchNamePattern = moduleToLoad.match(/([a-z0-9-]*)/i);
28+
if (moduleToLoad.indexOf('.') < 0 && matchNamePattern && matchNamePattern[0].length === moduleToLoad.length) {
29+
if (!app || (app && !app.params.lazyModulesPath)) {
30+
reject(new Error('Framework7: "lazyModulesPath" app parameter must be specified to fetch module by name'));
31+
return;
32+
}
33+
modulePath = `${app.params.lazyModulesPath}/${moduleToLoad}.js`;
34+
} else {
35+
modulePath = moduleToLoad;
36+
}
37+
} else if (typeof moduleToLoad === 'function') {
38+
moduleFunc = moduleToLoad;
39+
} else {
40+
// considering F7-Plugin object
41+
moduleObj = moduleToLoad;
42+
}
43+
44+
if (moduleFunc) {
45+
const module = moduleFunc(Framework7, false);
46+
if (!module) {
47+
reject(new Error('Framework7: Can\'t find Framework7 component in specified component function'));
48+
return;
49+
}
50+
// Check if it was added
51+
if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {
52+
resolve();
53+
return;
54+
}
55+
// Install It
56+
install(module);
57+
58+
resolve();
59+
}
60+
if (moduleObj) {
61+
const module = moduleObj;
62+
if (!module) {
63+
reject(new Error('Framework7: Can\'t find Framework7 component in specified component'));
64+
return;
65+
}
66+
// Check if it was added
67+
if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {
68+
resolve();
69+
return;
70+
}
71+
// Install It
72+
install(module);
73+
74+
resolve();
75+
}
76+
if (modulePath) {
77+
if (fetchedModules.indexOf(modulePath) >= 0) {
78+
resolve();
79+
return;
80+
}
81+
fetchedModules.push(modulePath);
82+
const scriptLoad = new Promise((resolveScript, rejectScript) => {
83+
Framework7.request.get(
84+
modulePath,
85+
(scriptContent) => {
86+
const id = Utils.id();
87+
const callbackLoadName = `f7_component_loader_callback_${id}`;
88+
89+
const scriptEl = document.createElement('script');
90+
scriptEl.innerHTML = `window.${callbackLoadName} = function (Framework7, Framework7AutoInstallComponent) {return ${scriptContent.trim()}}`;
91+
$('head').append(scriptEl);
92+
93+
const componentLoader = window[callbackLoadName];
94+
delete window[callbackLoadName];
95+
$(scriptEl).remove();
96+
97+
const module = componentLoader(Framework7, false);
98+
99+
if (!module) {
100+
rejectScript(new Error(`Framework7: Can't find Framework7 component in ${modulePath} file`));
101+
return;
102+
}
103+
104+
// Check if it was added
105+
if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {
106+
resolveScript();
107+
return;
108+
}
109+
110+
// Install It
111+
install(module);
112+
113+
resolveScript();
114+
},
115+
(xhr, status) => {
116+
rejectScript(xhr, status);
117+
}
118+
);
119+
});
120+
const styleLoad = new Promise((resolveStyle) => {
121+
Framework7.request.get(
122+
modulePath.replace('.js', app.rtl ? '.rtl.css' : '.css'),
123+
(styleContent) => {
124+
const styleEl = document.createElement('style');
125+
styleEl.innerHTML = styleContent;
126+
$('head').append(styleEl);
127+
128+
resolveStyle();
129+
},
130+
() => {
131+
resolveStyle();
132+
}
133+
);
134+
});
135+
136+
Promise.all([scriptLoad, styleLoad]).then(() => {
137+
resolve();
138+
}).catch((err) => {
139+
reject(err);
140+
});
141+
}
142+
});
143+
}
144+
145+
export default loadModule;

packages/core/components/badge/badge-ios.less

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
padding: 0 6px;
77
height: 20px;
88
line-height: 20px;
9-
.item-after & {
10-
min-width: 20px;
11-
}
129
}
1310
.icon, .f7-icons, .framework7-icons, .material-icons {
1411
.badge {

packages/core/components/card/card.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* === Card === */
2+
@import (reference) '../button/button.less';
3+
24
.cards-list, .card .list {
35
> ul {
46
.hairline-remove(top);

packages/core/components/contacts-list/contacts-list.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Framework7, { CSSSelector, Framework7EventsClass, Framework7Plugin } from '../app/app-class';
22

3-
export namespace ContactList {
3+
export namespace ContactsList {
44
interface AppMethods {
55

66
}
@@ -12,5 +12,5 @@ export namespace ContactList {
1212
}
1313
}
1414

15-
declare const ContactListComponent: Framework7Plugin;
16-
export default ContactListComponent;
15+
declare const ContactsListComponent: Framework7Plugin;
16+
export default ContactsListComponent;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
name: 'contactList',
2+
name: 'contactsList',
33
};

0 commit comments

Comments
 (0)