@fullcalendar/core 5.10.1 → 6.0.0-beta.1
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/main.cjs.js +64 -74
- package/main.global.js +2813 -3225
- package/main.global.min.js +3 -3
- package/main.js +65 -75
- package/main.js.map +1 -1
- package/package.json +3 -3
- package/vdom.cjs.js +25 -31
- package/vdom.d.ts +1 -1
- package/vdom.js +25 -31
package/main.js
CHANGED
|
@@ -1,71 +1,63 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar
|
|
2
|
+
FullCalendar v6.0.0-beta.1
|
|
3
3
|
Docs & License: https://fullcalendar.io/
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2022 Adam Shaw
|
|
5
5
|
*/
|
|
6
6
|
import './vdom.js';
|
|
7
|
-
import {
|
|
8
|
-
import { render, createElement, CalendarRoot, CustomContentRenderContext, CalendarContent, unmountComponentAtNode, flushToDom, DelayedRunner, CalendarDataManager, isArraysEqual, applyStyleProp, CalendarApi } from '@fullcalendar/common';
|
|
7
|
+
import { CalendarApi, flushSync, render, createElement, CalendarRoot, CustomContentRenderContext, CalendarContent, unmountComponentAtNode, DelayedRunner, CalendarDataManager, isArraysEqual, applyStyleProp } from '@fullcalendar/common';
|
|
9
8
|
export * from '@fullcalendar/common';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_this.customContentRenderId = 0; // will affect custom generated classNames?
|
|
20
|
-
_this.handleAction = function (action) {
|
|
10
|
+
class Calendar extends CalendarApi {
|
|
11
|
+
constructor(el, optionOverrides = {}) {
|
|
12
|
+
super();
|
|
13
|
+
this.isRendering = false;
|
|
14
|
+
this.isRendered = false;
|
|
15
|
+
this.currentClassNames = [];
|
|
16
|
+
this.customContentRenderId = 0; // will affect custom generated classNames?
|
|
17
|
+
this.handleAction = (action) => {
|
|
21
18
|
// actions we know we want to render immediately
|
|
22
19
|
switch (action.type) {
|
|
23
20
|
case 'SET_EVENT_DRAG':
|
|
24
21
|
case 'SET_EVENT_RESIZE':
|
|
25
|
-
|
|
22
|
+
this.renderRunner.tryDrain();
|
|
26
23
|
}
|
|
27
24
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
this.handleData = (data) => {
|
|
26
|
+
this.currentData = data;
|
|
27
|
+
this.renderRunner.request(data.calendarOptions.rerenderDelay);
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
createElement(
|
|
41
|
-
|
|
29
|
+
this.handleRenderRequest = () => {
|
|
30
|
+
if (this.isRendering) {
|
|
31
|
+
this.isRendered = true;
|
|
32
|
+
let { currentData } = this;
|
|
33
|
+
flushSync(() => {
|
|
34
|
+
render(createElement(CalendarRoot, { options: currentData.calendarOptions, theme: currentData.theme, emitter: currentData.emitter }, (classNames, height, isHeightAuto, forPrint) => {
|
|
35
|
+
this.setClassNames(classNames);
|
|
36
|
+
this.setHeight(height);
|
|
37
|
+
return (createElement(CustomContentRenderContext.Provider, { value: this.customContentRenderId },
|
|
38
|
+
createElement(CalendarContent, Object.assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData))));
|
|
39
|
+
}), this.el);
|
|
40
|
+
});
|
|
42
41
|
}
|
|
43
|
-
else if (
|
|
44
|
-
|
|
45
|
-
unmountComponentAtNode(
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
else if (this.isRendered) {
|
|
43
|
+
this.isRendered = false;
|
|
44
|
+
unmountComponentAtNode(this.el);
|
|
45
|
+
this.setClassNames([]);
|
|
46
|
+
this.setHeight('');
|
|
48
47
|
}
|
|
49
|
-
flushToDom();
|
|
50
48
|
};
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
this.el = el;
|
|
50
|
+
this.renderRunner = new DelayedRunner(this.handleRenderRequest);
|
|
53
51
|
new CalendarDataManager({
|
|
54
|
-
optionOverrides
|
|
55
|
-
calendarApi:
|
|
56
|
-
onAction:
|
|
57
|
-
onData:
|
|
52
|
+
optionOverrides,
|
|
53
|
+
calendarApi: this,
|
|
54
|
+
onAction: this.handleAction,
|
|
55
|
+
onData: this.handleData,
|
|
58
56
|
});
|
|
59
|
-
return _this;
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
enumerable: false,
|
|
65
|
-
configurable: true
|
|
66
|
-
});
|
|
67
|
-
Calendar.prototype.render = function () {
|
|
68
|
-
var wasRendering = this.isRendering;
|
|
58
|
+
get view() { return this.currentData.viewApi; } // for public API
|
|
59
|
+
render() {
|
|
60
|
+
let wasRendering = this.isRendering;
|
|
69
61
|
if (!wasRendering) {
|
|
70
62
|
this.isRendering = true;
|
|
71
63
|
}
|
|
@@ -76,50 +68,48 @@ var Calendar = /** @class */ (function (_super) {
|
|
|
76
68
|
if (wasRendering) {
|
|
77
69
|
this.updateSize();
|
|
78
70
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
71
|
+
}
|
|
72
|
+
destroy() {
|
|
81
73
|
if (this.isRendering) {
|
|
82
74
|
this.isRendering = false;
|
|
83
75
|
this.renderRunner.request();
|
|
84
76
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
}
|
|
78
|
+
updateSize() {
|
|
79
|
+
flushSync(() => {
|
|
80
|
+
super.updateSize();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
batchRendering(func) {
|
|
91
84
|
this.renderRunner.pause('batchRendering');
|
|
92
85
|
func();
|
|
93
86
|
this.renderRunner.resume('batchRendering');
|
|
94
|
-
}
|
|
95
|
-
|
|
87
|
+
}
|
|
88
|
+
pauseRendering() {
|
|
96
89
|
this.renderRunner.pause('pauseRendering');
|
|
97
|
-
}
|
|
98
|
-
|
|
90
|
+
}
|
|
91
|
+
resumeRendering() {
|
|
99
92
|
this.renderRunner.resume('pauseRendering', true);
|
|
100
|
-
}
|
|
101
|
-
|
|
93
|
+
}
|
|
94
|
+
resetOptions(optionOverrides, append) {
|
|
102
95
|
this.currentDataManager.resetOptions(optionOverrides, append);
|
|
103
|
-
}
|
|
104
|
-
|
|
96
|
+
}
|
|
97
|
+
setClassNames(classNames) {
|
|
105
98
|
if (!isArraysEqual(classNames, this.currentClassNames)) {
|
|
106
|
-
|
|
107
|
-
for (
|
|
108
|
-
var className = _a[_i];
|
|
99
|
+
let { classList } = this.el;
|
|
100
|
+
for (let className of this.currentClassNames) {
|
|
109
101
|
classList.remove(className);
|
|
110
102
|
}
|
|
111
|
-
for (
|
|
112
|
-
var className = classNames_1[_b];
|
|
103
|
+
for (let className of classNames) {
|
|
113
104
|
classList.add(className);
|
|
114
105
|
}
|
|
115
106
|
this.currentClassNames = classNames;
|
|
116
107
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
108
|
+
}
|
|
109
|
+
setHeight(height) {
|
|
119
110
|
applyStyleProp(this.el, 'height', height);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
}(CalendarApi));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
123
113
|
|
|
124
114
|
export { Calendar };
|
|
125
115
|
//# sourceMappingURL=main.js.map
|
package/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["src/Calendar.tsx"],"sourcesContent":["import {\n CalendarOptions, Action, CalendarContent, render, createElement, DelayedRunner, CssDimValue, applyStyleProp,\n CalendarApi, CalendarRoot, isArraysEqual, CalendarDataManager, CalendarData,\n CustomContentRenderContext,
|
|
1
|
+
{"version":3,"file":"main.js","sources":["src/Calendar.tsx"],"sourcesContent":["import {\n CalendarOptions, Action, CalendarContent, render, createElement, DelayedRunner, CssDimValue, applyStyleProp,\n CalendarApi, CalendarRoot, isArraysEqual, CalendarDataManager, CalendarData,\n CustomContentRenderContext, flushSync, unmountComponentAtNode,\n} from '@fullcalendar/common'\n\nexport class Calendar extends CalendarApi {\n currentData: CalendarData\n renderRunner: DelayedRunner\n el: HTMLElement\n isRendering = false\n isRendered = false\n currentClassNames: string[] = []\n customContentRenderId = 0 // will affect custom generated classNames?\n\n get view() { return this.currentData.viewApi } // for public API\n\n constructor(el: HTMLElement, optionOverrides: CalendarOptions = {}) {\n super()\n\n this.el = el\n this.renderRunner = new DelayedRunner(this.handleRenderRequest)\n\n new CalendarDataManager({ // eslint-disable-line no-new\n optionOverrides,\n calendarApi: this,\n onAction: this.handleAction,\n onData: this.handleData,\n })\n }\n\n handleAction = (action: Action) => {\n // actions we know we want to render immediately\n switch (action.type) {\n case 'SET_EVENT_DRAG':\n case 'SET_EVENT_RESIZE':\n this.renderRunner.tryDrain()\n }\n }\n\n handleData = (data: CalendarData) => {\n this.currentData = data\n this.renderRunner.request(data.calendarOptions.rerenderDelay)\n }\n\n handleRenderRequest = () => {\n if (this.isRendering) {\n this.isRendered = true\n let { currentData } = this\n\n flushSync(() => {\n render(\n <CalendarRoot options={currentData.calendarOptions} theme={currentData.theme} emitter={currentData.emitter}>\n {(classNames, height, isHeightAuto, forPrint) => {\n this.setClassNames(classNames)\n this.setHeight(height)\n\n return (\n <CustomContentRenderContext.Provider value={this.customContentRenderId}>\n <CalendarContent\n isHeightAuto={isHeightAuto}\n forPrint={forPrint}\n {...currentData}\n />\n </CustomContentRenderContext.Provider>\n )\n }}\n </CalendarRoot>,\n this.el,\n )\n })\n } else if (this.isRendered) {\n this.isRendered = false\n unmountComponentAtNode(this.el)\n this.setClassNames([])\n this.setHeight('')\n }\n }\n\n render() {\n let wasRendering = this.isRendering\n\n if (!wasRendering) {\n this.isRendering = true\n } else {\n this.customContentRenderId += 1\n }\n\n this.renderRunner.request()\n\n if (wasRendering) {\n this.updateSize()\n }\n }\n\n destroy() {\n if (this.isRendering) {\n this.isRendering = false\n this.renderRunner.request()\n }\n }\n\n updateSize() {\n flushSync(() => {\n super.updateSize()\n })\n }\n\n batchRendering(func) {\n this.renderRunner.pause('batchRendering')\n func()\n this.renderRunner.resume('batchRendering')\n }\n\n pauseRendering() { // available to plugins\n this.renderRunner.pause('pauseRendering')\n }\n\n resumeRendering() { // available to plugins\n this.renderRunner.resume('pauseRendering', true)\n }\n\n resetOptions(optionOverrides, append?) {\n this.currentDataManager.resetOptions(optionOverrides, append)\n }\n\n setClassNames(classNames: string[]) {\n if (!isArraysEqual(classNames, this.currentClassNames)) {\n let { classList } = this.el\n\n for (let className of this.currentClassNames) {\n classList.remove(className)\n }\n\n for (let className of classNames) {\n classList.add(className)\n }\n\n this.currentClassNames = classNames\n }\n }\n\n setHeight(height: CssDimValue) {\n applyStyleProp(this.el, 'height', height)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;MAMa,QAAS,SAAQ,WAAW;IAWvC,YAAY,EAAe,EAAE,kBAAmC,EAAE;QAChE,KAAK,EAAE,CAAA;QART,gBAAW,GAAG,KAAK,CAAA;QACnB,eAAU,GAAG,KAAK,CAAA;QAClB,sBAAiB,GAAa,EAAE,CAAA;QAChC,0BAAqB,GAAG,CAAC,CAAA;QAkBzB,iBAAY,GAAG,CAAC,MAAc;;YAE5B,QAAQ,MAAM,CAAC,IAAI;gBACjB,KAAK,gBAAgB,CAAC;gBACtB,KAAK,kBAAkB;oBACrB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAA;aAC/B;SACF,CAAA;QAED,eAAU,GAAG,CAAC,IAAkB;YAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAA;SAC9D,CAAA;QAED,wBAAmB,GAAG;YACpB,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;gBACtB,IAAI,EAAE,WAAW,E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C,CAAA;aAC5B;YAED,KAAK,IAAI,SAAS,IAAI,UAAU,EAAE;gBAChC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;aACzB;YAED,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAA;SACpC;KACF;IAED,SAAS,CAAC,MAAmB;QAC3B,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;KAC1C;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullcalendar/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-beta.1",
|
|
4
4
|
"title": "FullCalendar Core Package",
|
|
5
5
|
"description": "Provides core functionality, including the Calendar class",
|
|
6
6
|
"docs": "https://fullcalendar.io/docs/initialize-es6",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@fullcalendar/common": "
|
|
8
|
+
"@fullcalendar/common": "6.0.0-beta.1",
|
|
9
9
|
"preact": "^10.0.5",
|
|
10
10
|
"tslib": "^2.1.0"
|
|
11
11
|
},
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"url": "http://arshaw.com/"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@fullcalendar/core-preact": "
|
|
32
|
+
"@fullcalendar/core-preact": "6.0.0-beta.1"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/vdom.cjs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib = require('tslib');
|
|
4
3
|
var preact = require('preact');
|
|
5
4
|
var preactCompat = require('preact/compat');
|
|
6
5
|
|
|
@@ -27,7 +26,7 @@ function _interopNamespace(e) {
|
|
|
27
26
|
var preact__namespace = /*#__PURE__*/_interopNamespace(preact);
|
|
28
27
|
var preactCompat__namespace = /*#__PURE__*/_interopNamespace(preactCompat);
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
let globalObj = typeof globalThis !== 'undefined' ? globalThis : window; // // TODO: streamline when killing IE11 support
|
|
31
30
|
if (globalObj.FullCalendarVDom) {
|
|
32
31
|
console.warn('FullCalendar VDOM already loaded');
|
|
33
32
|
}
|
|
@@ -38,18 +37,19 @@ else {
|
|
|
38
37
|
render: preact__namespace.render,
|
|
39
38
|
createRef: preact__namespace.createRef,
|
|
40
39
|
Fragment: preact__namespace.Fragment,
|
|
41
|
-
createContext
|
|
40
|
+
createContext,
|
|
42
41
|
createPortal: preactCompat__namespace.createPortal,
|
|
43
|
-
|
|
44
|
-
unmountComponentAtNode
|
|
42
|
+
flushSync,
|
|
43
|
+
unmountComponentAtNode,
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
// HACKS...
|
|
48
47
|
// TODO: lock version
|
|
49
48
|
// TODO: link gh issues
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
function flushSync(runBeforeFlush) {
|
|
50
|
+
runBeforeFlush();
|
|
51
|
+
let oldDebounceRendering = preact__namespace.options.debounceRendering; // orig
|
|
52
|
+
let callbackQ = [];
|
|
53
53
|
function execCallbackSync(callback) {
|
|
54
54
|
callbackQ.push(callback);
|
|
55
55
|
}
|
|
@@ -60,37 +60,31 @@ function flushToDom() {
|
|
|
60
60
|
}
|
|
61
61
|
preact__namespace.options.debounceRendering = oldDebounceRendering;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
FakeComponent.prototype.render = function () { return preact__namespace.createElement('div', {}); };
|
|
69
|
-
FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
|
|
70
|
-
return FakeComponent;
|
|
71
|
-
}(preact__namespace.Component));
|
|
63
|
+
class FakeComponent extends preact__namespace.Component {
|
|
64
|
+
render() { return preact__namespace.createElement('div', {}); }
|
|
65
|
+
componentDidMount() { this.setState({}); }
|
|
66
|
+
}
|
|
72
67
|
function createContext(defaultValue) {
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
let ContextType = preact__namespace.createContext(defaultValue);
|
|
69
|
+
let origProvider = ContextType.Provider;
|
|
75
70
|
ContextType.Provider = function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
|
71
|
+
let isNew = !this.getChildContext;
|
|
72
|
+
let children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
|
79
73
|
if (isNew) {
|
|
80
|
-
|
|
81
|
-
this.shouldComponentUpdate =
|
|
82
|
-
if (
|
|
83
|
-
|
|
74
|
+
let subs = [];
|
|
75
|
+
this.shouldComponentUpdate = (_props) => {
|
|
76
|
+
if (this.props.value !== _props.value) {
|
|
77
|
+
subs.forEach((c) => {
|
|
84
78
|
c.context = _props.value;
|
|
85
79
|
c.forceUpdate();
|
|
86
80
|
});
|
|
87
81
|
}
|
|
88
82
|
};
|
|
89
|
-
this.sub =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
c.componentWillUnmount =
|
|
93
|
-
|
|
83
|
+
this.sub = (c) => {
|
|
84
|
+
subs.push(c);
|
|
85
|
+
let old = c.componentWillUnmount;
|
|
86
|
+
c.componentWillUnmount = () => {
|
|
87
|
+
subs.splice(subs.indexOf(c), 1);
|
|
94
88
|
old && old.call(c);
|
|
95
89
|
};
|
|
96
90
|
};
|
package/vdom.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare global {
|
|
|
17
17
|
export import createContext = preact.createContext;
|
|
18
18
|
export import createPortal = preactCompat.createPortal;
|
|
19
19
|
type VUIEvent = UIEvent;
|
|
20
|
-
function
|
|
20
|
+
function flushSync(callback: () => void): void;
|
|
21
21
|
function unmountComponentAtNode(node: HTMLElement): void;
|
|
22
22
|
}
|
|
23
23
|
}
|
package/vdom.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { __extends } from 'tslib';
|
|
2
1
|
import * as preact from 'preact';
|
|
3
2
|
import * as preactCompat from 'preact/compat';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
let globalObj = typeof globalThis !== 'undefined' ? globalThis : window; // // TODO: streamline when killing IE11 support
|
|
6
5
|
if (globalObj.FullCalendarVDom) {
|
|
7
6
|
console.warn('FullCalendar VDOM already loaded');
|
|
8
7
|
}
|
|
@@ -13,18 +12,19 @@ else {
|
|
|
13
12
|
render: preact.render,
|
|
14
13
|
createRef: preact.createRef,
|
|
15
14
|
Fragment: preact.Fragment,
|
|
16
|
-
createContext
|
|
15
|
+
createContext,
|
|
17
16
|
createPortal: preactCompat.createPortal,
|
|
18
|
-
|
|
19
|
-
unmountComponentAtNode
|
|
17
|
+
flushSync,
|
|
18
|
+
unmountComponentAtNode,
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
// HACKS...
|
|
23
22
|
// TODO: lock version
|
|
24
23
|
// TODO: link gh issues
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
function flushSync(runBeforeFlush) {
|
|
25
|
+
runBeforeFlush();
|
|
26
|
+
let oldDebounceRendering = preact.options.debounceRendering; // orig
|
|
27
|
+
let callbackQ = [];
|
|
28
28
|
function execCallbackSync(callback) {
|
|
29
29
|
callbackQ.push(callback);
|
|
30
30
|
}
|
|
@@ -35,37 +35,31 @@ function flushToDom() {
|
|
|
35
35
|
}
|
|
36
36
|
preact.options.debounceRendering = oldDebounceRendering;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
FakeComponent.prototype.render = function () { return preact.createElement('div', {}); };
|
|
44
|
-
FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
|
|
45
|
-
return FakeComponent;
|
|
46
|
-
}(preact.Component));
|
|
38
|
+
class FakeComponent extends preact.Component {
|
|
39
|
+
render() { return preact.createElement('div', {}); }
|
|
40
|
+
componentDidMount() { this.setState({}); }
|
|
41
|
+
}
|
|
47
42
|
function createContext(defaultValue) {
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
let ContextType = preact.createContext(defaultValue);
|
|
44
|
+
let origProvider = ContextType.Provider;
|
|
50
45
|
ContextType.Provider = function () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
|
46
|
+
let isNew = !this.getChildContext;
|
|
47
|
+
let children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
|
54
48
|
if (isNew) {
|
|
55
|
-
|
|
56
|
-
this.shouldComponentUpdate =
|
|
57
|
-
if (
|
|
58
|
-
|
|
49
|
+
let subs = [];
|
|
50
|
+
this.shouldComponentUpdate = (_props) => {
|
|
51
|
+
if (this.props.value !== _props.value) {
|
|
52
|
+
subs.forEach((c) => {
|
|
59
53
|
c.context = _props.value;
|
|
60
54
|
c.forceUpdate();
|
|
61
55
|
});
|
|
62
56
|
}
|
|
63
57
|
};
|
|
64
|
-
this.sub =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
c.componentWillUnmount =
|
|
68
|
-
|
|
58
|
+
this.sub = (c) => {
|
|
59
|
+
subs.push(c);
|
|
60
|
+
let old = c.componentWillUnmount;
|
|
61
|
+
c.componentWillUnmount = () => {
|
|
62
|
+
subs.splice(subs.indexOf(c), 1);
|
|
69
63
|
old && old.call(c);
|
|
70
64
|
};
|
|
71
65
|
};
|