@microsoft/sp-component-base 1.23.1 → 1.24.0-beta.2
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/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +136 -141
- package/dist/{chunk.legacy-third-party-fabric-core-localfont_none_9e84ea19c68fdc8b9094.js → chunk.legacy-third-party-fabric-core-localfont_none_b7f7978a3e90166c361b.js} +1 -1
- package/dist/chunk.teams-apps-client_none_27d3c7c1d01080e4f131.js +2 -0
- package/dist/index-internal-beta.d.ts +30 -8
- package/dist/index-internal-public.d.ts +30 -8
- package/dist/index-internal.d.ts +30 -8
- package/dist/sp-component-base_default_8d535b51fa18aa47002b.js +22 -0
- package/dist/sp-component-base_en-us_8ce25dfb69a7786caece.js +22 -0
- package/dist/sp-component-base_qps-ploc_4fec831895d90df8aa7a.js +22 -0
- package/dist/sp-component-base_qps-ploca_b80610c8dff04dcec755.js +22 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-commonjs/BaseComponent.js +110 -145
- package/lib-commonjs/BaseComponentContext.js +126 -183
- package/lib-commonjs/DynamicDataProvider.js +251 -268
- package/lib-commonjs/DynamicDataSourceManager.js +218 -241
- package/lib-commonjs/DynamicProperty.js +232 -280
- package/lib-commonjs/EnsureIsolatedDomainUrl.js +14 -14
- package/lib-commonjs/IComponentPosition.js +8 -3
- package/lib-commonjs/IComponentPropertyMetadata.js +10 -3
- package/lib-commonjs/ISerializedServerProcessedData.js +24 -21
- package/lib-commonjs/LegacyThirdPartyFabricCoreLoader.js +53 -87
- package/lib-commonjs/PropertyMetadataProcessor.js +117 -150
- package/lib-commonjs/RenderableComponentContext.js +37 -0
- package/lib-commonjs/ShimmerFactory.js +66 -51
- package/lib-commonjs/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +6 -4
- package/lib-commonjs/common/Flights.js +22 -10
- package/lib-commonjs/common/KillSwitches.js +13 -6
- package/lib-commonjs/dataCollector/IWebPartLoadData.js +35 -30
- package/lib-commonjs/dataCollector/WebPartLoadDataCollector.js +82 -91
- package/lib-commonjs/index.js +78 -38
- package/lib-commonjs/teams/DeferredTeamsAppsClient.js +30 -52
- package/lib-commonjs/teams/ITeamsAppCatalog.js +10 -3
- package/lib-commonjs/teams/TeamsAppsClient.js +189 -231
- package/lib-commonjs/test-api/MockComponent.js +38 -23
- package/lib-commonjs/test-api/MockComponentContext.js +21 -14
- package/lib-commonjs/test-api/index.js +21 -7
- package/lib-commonjs/themeProvider/ThemeProvider.js +68 -82
- package/lib-commonjs/themeProvider/themeInterfaces/IFontStyles.js +5 -2
- package/lib-commonjs/themeProvider/themeInterfaces/IPalette.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticColors.js +59 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ISemanticTextColors.js +10 -3
- package/lib-commonjs/themeProvider/themeInterfaces/ITheme.js +5 -2
- package/{lib → lib-dts}/BaseComponent.d.ts +8 -8
- package/{lib → lib-dts}/BaseComponentContext.d.ts +5 -5
- package/lib-dts/RenderableComponentContext.d.ts +35 -0
- package/{lib → lib-dts}/index.d.ts +1 -0
- package/lib-esm/BaseComponent.js +123 -0
- package/lib-esm/BaseComponentContext.js +157 -0
- package/lib-esm/DynamicDataProvider.js +401 -0
- package/lib-esm/DynamicDataSourceManager.js +358 -0
- package/lib-esm/DynamicProperty.js +344 -0
- package/{lib → lib-esm}/EnsureIsolatedDomainUrl.js +6 -6
- package/lib-esm/IComponentPosition.js +5 -0
- package/lib-esm/IComponentPropertyMetadata.js +7 -0
- package/lib-esm/ISerializedServerProcessedData.js +24 -0
- package/lib-esm/LegacyThirdPartyFabricCoreLoader.js +76 -0
- package/{lib → lib-esm}/PropertyMetadataProcessor.js +92 -127
- package/lib-esm/RenderableComponentContext.js +26 -0
- package/lib-esm/ShimmerFactory.js +74 -0
- package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +3 -3
- package/{lib → lib-esm}/common/Flights.js +4 -3
- package/{lib → lib-esm}/common/KillSwitches.js +3 -2
- package/lib-esm/dataCollector/IWebPartLoadData.js +33 -0
- package/lib-esm/dataCollector/WebPartLoadDataCollector.js +125 -0
- package/{lib → lib-esm}/index.js +4 -3
- package/lib-esm/teams/DeferredTeamsAppsClient.js +32 -0
- package/lib-esm/teams/ITeamsAppCatalog.js +9 -0
- package/lib-esm/teams/TeamsAppsClient.js +395 -0
- package/lib-esm/test-api/MockComponent.js +38 -0
- package/{lib → lib-esm}/test-api/MockComponentContext.js +10 -11
- package/{lib → lib-esm}/test-api/index.js +2 -1
- package/lib-esm/themeProvider/ThemeProvider.js +79 -0
- package/lib-esm/themeProvider/themeInterfaces/IFontStyles.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/IPalette.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticColors.js +56 -0
- package/lib-esm/themeProvider/themeInterfaces/ISemanticTextColors.js +7 -0
- package/lib-esm/themeProvider/themeInterfaces/ITheme.js +7 -0
- package/package.json +41 -14
- package/dist/chunk.teams-apps-client_none_f9872389cb6ea9ad28e2.js +0 -2
- package/dist/sp-component-base_default_5ba07be39b0dc8968f7b.js +0 -2
- package/dist/sp-component-base_en-us_eb9bebb3acce0ae83f1c.js +0 -2
- package/dist/sp-component-base_qps-ploc_45f37623d87c3d848f2a.js +0 -2
- package/dist/sp-component-base_qps-ploca_b3f3b7bf97c4185b0fd6.js +0 -2
- package/lib/BaseComponent.d.ts.map +0 -1
- package/lib/BaseComponent.js +0 -161
- package/lib/BaseComponentContext.d.ts.map +0 -1
- package/lib/BaseComponentContext.js +0 -222
- package/lib/DynamicDataProvider.d.ts.map +0 -1
- package/lib/DynamicDataProvider.js +0 -420
- package/lib/DynamicDataSourceManager.d.ts.map +0 -1
- package/lib/DynamicDataSourceManager.js +0 -382
- package/lib/DynamicProperty.d.ts.map +0 -1
- package/lib/DynamicProperty.js +0 -390
- package/lib/EnsureIsolatedDomainUrl.d.ts.map +0 -1
- package/lib/IComponentPosition.d.ts.map +0 -1
- package/lib/IComponentPosition.js +0 -2
- package/lib/IComponentPropertyMetadata.d.ts.map +0 -1
- package/lib/IComponentPropertyMetadata.js +0 -2
- package/lib/ISerializedServerProcessedData.d.ts.map +0 -1
- package/lib/ISerializedServerProcessedData.js +0 -28
- package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +0 -1
- package/lib/LegacyThirdPartyFabricCoreLoader.js +0 -90
- package/lib/PropertyMetadataProcessor.d.ts.map +0 -1
- package/lib/ShimmerFactory.d.ts.map +0 -1
- package/lib/ShimmerFactory.js +0 -62
- package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +0 -1
- package/lib/common/Flights.d.ts.map +0 -1
- package/lib/common/KillSwitches.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.d.ts.map +0 -1
- package/lib/dataCollector/IWebPartLoadData.js +0 -40
- package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +0 -1
- package/lib/dataCollector/WebPartLoadDataCollector.js +0 -137
- package/lib/index.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/DeferredTeamsAppsClient.js +0 -39
- package/lib/teams/ITeamsAppCatalog.d.ts.map +0 -1
- package/lib/teams/ITeamsAppCatalog.js +0 -2
- package/lib/teams/TeamsAppsClient.d.ts.map +0 -1
- package/lib/teams/TeamsAppsClient.js +0 -440
- package/lib/test-api/MockComponent.d.ts.map +0 -1
- package/lib/test-api/MockComponent.js +0 -31
- package/lib/test-api/MockComponentContext.d.ts.map +0 -1
- package/lib/test-api/index.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.d.ts.map +0 -1
- package/lib/themeProvider/ThemeProvider.js +0 -99
- package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IFontStyles.js +0 -2
- package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/IPalette.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +0 -2
- package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +0 -1
- package/lib/themeProvider/themeInterfaces/ITheme.js +0 -2
- /package/{lib → lib-dts}/DynamicDataProvider.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicDataSourceManager.d.ts +0 -0
- /package/{lib → lib-dts}/DynamicProperty.d.ts +0 -0
- /package/{lib → lib-dts}/EnsureIsolatedDomainUrl.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPosition.d.ts +0 -0
- /package/{lib → lib-dts}/IComponentPropertyMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/ISerializedServerProcessedData.d.ts +0 -0
- /package/{lib → lib-dts}/LegacyThirdPartyFabricCoreLoader.d.ts +0 -0
- /package/{lib → lib-dts}/PropertyMetadataProcessor.d.ts +0 -0
- /package/{lib → lib-dts}/ShimmerFactory.d.ts +0 -0
- /package/{lib → lib-dts}/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +0 -0
- /package/{lib → lib-dts}/common/Flights.d.ts +0 -0
- /package/{lib → lib-dts}/common/KillSwitches.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/IWebPartLoadData.d.ts +0 -0
- /package/{lib → lib-dts}/dataCollector/WebPartLoadDataCollector.d.ts +0 -0
- /package/{lib → lib-dts}/loc/Strings.resx.d.ts +0 -0
- /package/{lib → lib-dts}/teams/DeferredTeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/teams/ITeamsAppCatalog.d.ts +0 -0
- /package/{lib → lib-dts}/teams/TeamsAppsClient.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponent.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/MockComponentContext.d.ts +0 -0
- /package/{lib → lib-dts}/test-api/index.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/ThemeProvider.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IFontStyles.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/IPalette.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +0 -0
- /package/{lib → lib-dts}/themeProvider/themeInterfaces/ITheme.d.ts +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +0 -0
- /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/iconDefinitions.css +0 -0
- /package/{lib → lib-esm}/loc/Strings.resx.json +0 -0
- /package/{lib → lib-esm}/sp-component-base.manifest.json +0 -0
- /package/{lib → lib-esm}/styles/shimmer.module.scss.css +0 -0
|
@@ -1,106 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Serializable object that simplifies usage of a DynamicProperty.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* This is built for usage in web part properties, and modified through the property pane.
|
|
14
|
-
* Can be initialized with a default callback.
|
|
15
|
-
* Web parts initialize with the render method so if the 3rd party developer does nothing, a change in the
|
|
16
|
-
* DynamicProperty will re-render the web part automatically.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
var DynamicProperty = /** @class */ (function () {
|
|
21
|
-
/**
|
|
22
|
-
* Create a new DynamicProperty object.
|
|
23
|
-
* @param provider - DynamicDataProvider.
|
|
24
|
-
* @param callback - Optional. Default callback to be registered for updates in the DynamicDataSource.
|
|
25
|
-
*/
|
|
26
|
-
function DynamicProperty(provider, callback) {
|
|
27
|
-
this._hasValue = false;
|
|
28
|
-
this._isDisposed = false;
|
|
29
|
-
sp_core_library_1.Validate.isNotNullOrUndefined(provider, 'provider');
|
|
30
|
-
this['__type'] = DynamicProperty._TYPE_NAME;
|
|
31
|
-
this._provider = provider;
|
|
32
|
-
this._callbacks = new Set();
|
|
33
|
-
this._pendingCallbacks = new Set();
|
|
34
|
-
if (callback) {
|
|
35
|
-
// The default callback will be added once a source is configured
|
|
36
|
-
this._pendingCallbacks.add(callback);
|
|
37
|
-
this._defaultCallback = callback;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this._defaultCallback = undefined;
|
|
41
|
-
}
|
|
42
|
-
this._onSourcesChanged = this._onSourcesChangedCallback.bind(this);
|
|
43
|
-
this._cloneDeep = this._cloneDeep.bind(this);
|
|
44
|
-
this._provider.registerAvailableSourcesChanged(this._onSourcesChanged);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return DynamicProperty;
|
|
45
9
|
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _splodashsubset = /*#__PURE__*/ _interop_require_wildcard._(require("@microsoft/sp-lodash-subset"));
|
|
14
|
+
const _spcorelibrary = require("@microsoft/sp-core-library");
|
|
15
|
+
const _spdynamicdata = require("@microsoft/sp-dynamic-data");
|
|
16
|
+
const _DynamicDataProvider = /*#__PURE__*/ _interop_require_default._(require("./DynamicDataProvider"));
|
|
17
|
+
const _spdiagnostics = require("@microsoft/sp-diagnostics");
|
|
18
|
+
class DynamicProperty {
|
|
46
19
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var _this = this;
|
|
53
|
-
sp_core_library_1.Validate.isNonemptyString(reference, 'id');
|
|
20
|
+
* Sets the value of the DynamicProperty to be a reference to a DynamicDynamicSource
|
|
21
|
+
* and property. The reference is of the form `<source>:<property>:<path>`.
|
|
22
|
+
* @param reference - Id of the DynamicDataSource and property.
|
|
23
|
+
*/ setReference(reference) {
|
|
24
|
+
_spcorelibrary.Validate.isNonemptyString(reference, 'id');
|
|
54
25
|
this._value = undefined;
|
|
55
26
|
this._hasValue = false;
|
|
56
27
|
// Potentially changing the source. Remove all callbacks, change the source, and add callbacks again.
|
|
57
|
-
|
|
58
|
-
this._callbacks.forEach(
|
|
59
|
-
this._callbacks.forEach(
|
|
60
|
-
this._reference = new
|
|
28
|
+
const callbacks = new Set();
|
|
29
|
+
this._callbacks.forEach((callback)=>callbacks.add(callback));
|
|
30
|
+
this._callbacks.forEach((callback)=>this.unregister(callback));
|
|
31
|
+
this._reference = new _spdynamicdata.DynamicDataReference(reference);
|
|
61
32
|
this._sourceId = this._getSourceId();
|
|
62
|
-
callbacks.forEach(
|
|
33
|
+
callbacks.forEach((callback)=>this.register(callback));
|
|
63
34
|
// The source has changed, so act if a new source was added
|
|
64
35
|
this._onSourcesChangedCallback();
|
|
65
|
-
}
|
|
36
|
+
}
|
|
66
37
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
DynamicProperty.prototype.setValue = function (value) {
|
|
71
|
-
var _this = this;
|
|
38
|
+
* Sets a static value in the DynamicProperty.
|
|
39
|
+
* @param value - Value for the DynamicProperty.
|
|
40
|
+
*/ setValue(value) {
|
|
72
41
|
// Removing the source. Remove all callback, set the value, and add the callback again so they are not lost.
|
|
73
42
|
// Callbacks will be stored in the pending callbacks list.
|
|
74
|
-
|
|
75
|
-
callbacks.forEach(
|
|
43
|
+
const callbacks = this._callbacks;
|
|
44
|
+
callbacks.forEach((callback)=>this.unregister(callback));
|
|
76
45
|
this._value = value;
|
|
77
46
|
this._reference = undefined;
|
|
78
47
|
this._sourceId = undefined;
|
|
79
48
|
this._hasValue = true;
|
|
80
|
-
callbacks.forEach(
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return this._isDisposed;
|
|
88
|
-
},
|
|
89
|
-
enumerable: false,
|
|
90
|
-
configurable: true
|
|
91
|
-
});
|
|
49
|
+
callbacks.forEach((callback)=>this.register(callback));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc @microsoft/sp-core-library#IDisposable.isDisposed}
|
|
53
|
+
*/ get isDisposed() {
|
|
54
|
+
return this._isDisposed;
|
|
55
|
+
}
|
|
92
56
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
DynamicProperty.prototype.dispose = function () {
|
|
96
|
-
var _this = this;
|
|
57
|
+
* {@inheritDoc @microsoft/sp-core-library#IDisposable.dispose}
|
|
58
|
+
*/ dispose() {
|
|
97
59
|
if (!this._isDisposed) {
|
|
98
60
|
this._provider.unregisterAvailableSourcesChanged(this._onSourcesChanged);
|
|
99
61
|
if (this._defaultCallback) {
|
|
100
62
|
this.unregister(this._defaultCallback);
|
|
101
63
|
delete this._defaultCallback;
|
|
102
64
|
}
|
|
103
|
-
this._callbacks.forEach(
|
|
65
|
+
this._callbacks.forEach((callback)=>this.unregister(callback));
|
|
104
66
|
delete this._callbacks;
|
|
105
67
|
delete this._onSourcesChanged;
|
|
106
68
|
delete this._pendingCallbacks;
|
|
@@ -109,285 +71,275 @@ var DynamicProperty = /** @class */ (function () {
|
|
|
109
71
|
delete this._sourceId;
|
|
110
72
|
this._isDisposed = true;
|
|
111
73
|
}
|
|
112
|
-
}
|
|
74
|
+
}
|
|
113
75
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
DynamicProperty.prototype.toJSON = function () {
|
|
76
|
+
* Returns a serializable version of the object.
|
|
77
|
+
* To be used when `JSON.stringify()` is called on the object (i.e. during Web Part serialization)
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* This doesn't follow the naming rule for internal methods because the JavaScript engine needs this exact name.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/ toJSON() {
|
|
123
84
|
if (this._hasValue) {
|
|
124
85
|
return {
|
|
125
86
|
__type: DynamicProperty._TYPE_NAME,
|
|
126
87
|
value: this._value
|
|
127
88
|
};
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
89
|
+
} else {
|
|
130
90
|
return {
|
|
131
91
|
__type: DynamicProperty._TYPE_NAME,
|
|
132
92
|
reference: this._reference
|
|
133
93
|
};
|
|
134
94
|
}
|
|
135
|
-
}
|
|
136
|
-
Object.defineProperty(DynamicProperty.prototype, "reference", {
|
|
137
|
-
/**
|
|
138
|
-
* DynamicDataReference string that the DynamicProperty object points to.
|
|
139
|
-
* The reference is of the form `<source>:<property>:<path>`.
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* If the DynamicProperty is set up with static data, this returns undefined.
|
|
143
|
-
*/
|
|
144
|
-
get: function () {
|
|
145
|
-
return this._hasValue ? undefined : this._reference.reference;
|
|
146
|
-
},
|
|
147
|
-
enumerable: false,
|
|
148
|
-
configurable: true
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(DynamicProperty.prototype, "value", {
|
|
151
|
-
/**
|
|
152
|
-
* Returns the value of the DynamicProperty object, if it has a non-dynamic value.
|
|
153
|
-
* Used for serialization purposes. The proper API to access the value of the object is `tryGetValue()`
|
|
154
|
-
*
|
|
155
|
-
* @internal
|
|
156
|
-
*/
|
|
157
|
-
get: function () {
|
|
158
|
-
return this._value;
|
|
159
|
-
},
|
|
160
|
-
enumerable: false,
|
|
161
|
-
configurable: true
|
|
162
|
-
});
|
|
95
|
+
}
|
|
163
96
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
97
|
+
* DynamicDataReference string that the DynamicProperty object points to.
|
|
98
|
+
* The reference is of the form `<source>:<property>:<path>`.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* If the DynamicProperty is set up with static data, this returns undefined.
|
|
102
|
+
*/ get reference() {
|
|
103
|
+
return this._hasValue ? undefined : this._reference.reference;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Returns the value of the DynamicProperty object, if it has a non-dynamic value.
|
|
107
|
+
* Used for serialization purposes. The proper API to access the value of the object is `tryGetValue()`
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/ get value() {
|
|
111
|
+
return this._value;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns the value of the object.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* If the value is an array, then the first element of the array is returned;
|
|
118
|
+
* otherwise, the value itself is returned.
|
|
119
|
+
*
|
|
120
|
+
* NOTE: This api will never return an array. To retrieve an array value,
|
|
121
|
+
* use the {@link DynamicProperty.tryGetValues} API.
|
|
122
|
+
*
|
|
123
|
+
* @returns the value associated with the dynamic property or
|
|
124
|
+
* undefined if the source or the data doesn't exist.
|
|
125
|
+
*/ tryGetValue() {
|
|
126
|
+
if (this.isDisposed && !_spcorelibrary._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
179
127
|
return undefined;
|
|
128
|
+
} else {
|
|
129
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
180
130
|
}
|
|
181
|
-
|
|
182
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
183
|
-
}
|
|
184
|
-
var value = this._getData();
|
|
131
|
+
let value = this._getData();
|
|
185
132
|
if (Array.isArray(value)) {
|
|
186
133
|
value = value[0];
|
|
187
134
|
}
|
|
188
135
|
return value;
|
|
189
|
-
}
|
|
136
|
+
}
|
|
190
137
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
var value = this._getData();
|
|
138
|
+
* Returns the value of the object.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* If the value is NOT an array, then an array is returned with the value being the single entry;
|
|
142
|
+
* otherwise, the value itself is returned. If the property is undefined or cannot be found,
|
|
143
|
+
* an empty array will be returned.
|
|
144
|
+
*
|
|
145
|
+
* NOTE: This api will always return an array and it assumes that the array is homogeneous.
|
|
146
|
+
* To retrieve a non-array value, use the {@link DynamicProperty.tryGetValue} API.
|
|
147
|
+
*
|
|
148
|
+
* @returns the value associated with the dynamic property or
|
|
149
|
+
* an empty array if the source or the data doesn't exist.
|
|
150
|
+
*/ tryGetValues() {
|
|
151
|
+
let value = this._getData();
|
|
206
152
|
// OK, time for some massaging of the return.
|
|
207
153
|
if (value) {
|
|
208
154
|
// If there is a value returned, but it isn't an array, create an array and
|
|
209
155
|
// make this the return value the sole contents of the array
|
|
210
156
|
if (!Array.isArray(value)) {
|
|
211
|
-
value = [
|
|
157
|
+
value = [
|
|
158
|
+
value
|
|
159
|
+
];
|
|
212
160
|
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
161
|
+
} else {
|
|
215
162
|
// In this case, we are saying that there is no value. For this scenario
|
|
216
163
|
// we simply return an empty array.
|
|
217
164
|
value = [];
|
|
218
165
|
}
|
|
219
166
|
return value;
|
|
220
|
-
}
|
|
167
|
+
}
|
|
221
168
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (this.isDisposed &&
|
|
227
|
-
!sp_core_library_1._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
|
|
169
|
+
* Returns the DynamicDataSource that the DynamicProperty object refers to.
|
|
170
|
+
* Returns undefined if the source doesn't exist.
|
|
171
|
+
*/ tryGetSource() {
|
|
172
|
+
if (this.isDisposed && !_spcorelibrary._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
228
173
|
return undefined;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
174
|
+
} else {
|
|
175
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
232
176
|
}
|
|
233
177
|
return this._hasValue ? undefined : this._provider.tryGetSource(this._sourceId);
|
|
234
|
-
}
|
|
178
|
+
}
|
|
235
179
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
180
|
+
* Registers a callback function for updates on the associated DynamicDataSource.
|
|
181
|
+
* @param callback - Callback function to register.
|
|
182
|
+
*/ register(callback) {
|
|
183
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
241
184
|
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
242
185
|
this._provider.registerPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
|
|
243
186
|
this._callbacks.add(callback);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
187
|
+
} else {
|
|
246
188
|
this._pendingCallbacks.add(callback);
|
|
247
189
|
}
|
|
248
|
-
}
|
|
190
|
+
}
|
|
249
191
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
192
|
+
* Unregisters a callback function for updates on the associated DynamicDataSource.
|
|
193
|
+
* The callback function must be the same it was registered with.
|
|
194
|
+
* @param callback - Callback function to unregister.
|
|
195
|
+
*/ unregister(callback) {
|
|
196
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
256
197
|
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
257
198
|
this._provider.unregisterPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
|
|
258
199
|
}
|
|
259
200
|
this._pendingCallbacks.delete(callback);
|
|
260
201
|
this._callbacks.delete(callback);
|
|
261
|
-
}
|
|
202
|
+
}
|
|
262
203
|
/**
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
DynamicProperty.prototype.hasDefaultCallback = function () {
|
|
204
|
+
* Returns true if the object has a default callback.
|
|
205
|
+
*/ hasDefaultCallback() {
|
|
266
206
|
return !!this._defaultCallback;
|
|
267
|
-
}
|
|
207
|
+
}
|
|
268
208
|
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
DynamicProperty.prototype.removeDefaultCallback = function () {
|
|
209
|
+
* Removes the registration for the default callback.
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* This can be useful for advanced users who only want their custom callbacks.
|
|
213
|
+
*/ removeDefaultCallback() {
|
|
275
214
|
if (this._defaultCallback) {
|
|
276
215
|
this.unregister(this._defaultCallback);
|
|
277
216
|
this._defaultCallback = undefined;
|
|
278
217
|
}
|
|
279
|
-
}
|
|
218
|
+
}
|
|
280
219
|
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
220
|
+
* Returns the id of the DynamicDataSource if the DynamicProperty has a reference set.
|
|
221
|
+
*
|
|
222
|
+
* @internal
|
|
223
|
+
*/ _getSourceId() {
|
|
224
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
287
225
|
return this._hasValue ? '' : this._reference.sourceId;
|
|
288
|
-
}
|
|
226
|
+
}
|
|
289
227
|
/**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
228
|
+
* Returns the property name of the DynamicDataSource that the DynamicProperty points to.
|
|
229
|
+
*
|
|
230
|
+
* NOTE: This is accessed from the property pane code while building the DynamicDataWidget.
|
|
231
|
+
* @internal
|
|
232
|
+
*/ _getProperty() {
|
|
233
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
297
234
|
return this._hasValue ? '' : this._reference.property;
|
|
298
|
-
}
|
|
235
|
+
}
|
|
299
236
|
/**
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
237
|
+
* Returns the path from the property that the object points to, if applicable.
|
|
238
|
+
* If not applicable, returns an empty string.
|
|
239
|
+
*
|
|
240
|
+
* @internal
|
|
241
|
+
*/ _getPropertyPath() {
|
|
242
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
307
243
|
return this._hasValue ? '' : this._reference.propertyPath || '';
|
|
308
|
-
}
|
|
244
|
+
}
|
|
309
245
|
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (prop instanceof DynamicDataProvider_1.default) {
|
|
246
|
+
* Returns a deep cloned version of the current instance.
|
|
247
|
+
*
|
|
248
|
+
* @remarks
|
|
249
|
+
* Since the dynamic property is maintaining an instance of the DynamicDataProvider,
|
|
250
|
+
* which which when serialized will result in 'Maximum call stack size exceeded' based
|
|
251
|
+
* on what kind of sources they hold references to.
|
|
252
|
+
*
|
|
253
|
+
* For example, if the dynamicDataProvider is holding PageContext source, which internally
|
|
254
|
+
* has serviceScope in its state. Deep cloning this source would result in the above mentioned
|
|
255
|
+
* error.
|
|
256
|
+
*
|
|
257
|
+
* Hence we would want to just clone the dynamicDataProvider not deep clone it.
|
|
258
|
+
*
|
|
259
|
+
* @returns - Custom deep Cloned version of the current instance.
|
|
260
|
+
*
|
|
261
|
+
* @internal
|
|
262
|
+
*/ _cloneDeep(instance) {
|
|
263
|
+
return _splodashsubset.cloneDeepWith(instance, (prop)=>{
|
|
264
|
+
if (prop instanceof _DynamicDataProvider.default) {
|
|
330
265
|
return prop;
|
|
331
266
|
}
|
|
332
267
|
});
|
|
333
|
-
}
|
|
268
|
+
}
|
|
334
269
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
270
|
+
* Returns the property name of the DynamicDataSource that the DynamicProperty points to.
|
|
271
|
+
*
|
|
272
|
+
* @remarks
|
|
273
|
+
* Removes the array notation from the property name, if any, before it is being registered.
|
|
274
|
+
* This is to avoid any mismatch between the strings passed by the source when it notifies
|
|
275
|
+
* a property change, as the source doesn't pass any array notation with the property name.
|
|
276
|
+
* Array notation is only for internal representation, for a property whose value is an array type.
|
|
277
|
+
*/ _getPropertyToRegister() {
|
|
278
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
345
279
|
// Split the property string on the array notation to get
|
|
346
280
|
// the property name. If the array notation is not present,
|
|
347
281
|
// then the original string is returned in the array.
|
|
348
282
|
return this._getProperty().split(DynamicProperty._arrayRegex)[0];
|
|
349
|
-
}
|
|
283
|
+
}
|
|
350
284
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
DynamicProperty.prototype._onSourcesChangedCallback = function () {
|
|
355
|
-
var _this = this;
|
|
285
|
+
* Callback when the DynamicDataSources list changes.
|
|
286
|
+
* It registers the pending callbacks into the DynamicDataProvidere.
|
|
287
|
+
*/ _onSourcesChangedCallback() {
|
|
356
288
|
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
357
|
-
|
|
289
|
+
const callbacksToAdd = this._pendingCallbacks;
|
|
358
290
|
this._pendingCallbacks = new Set();
|
|
359
|
-
callbacksToAdd.forEach(
|
|
360
|
-
|
|
291
|
+
callbacksToAdd.forEach((callback)=>{
|
|
292
|
+
this.register(callback);
|
|
361
293
|
callback();
|
|
362
294
|
});
|
|
363
295
|
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (this.isDisposed &&
|
|
367
|
-
!sp_core_library_1._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
|
|
296
|
+
}
|
|
297
|
+
_getData() {
|
|
298
|
+
if (this.isDisposed && !_spcorelibrary._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
368
299
|
return undefined;
|
|
300
|
+
} else {
|
|
301
|
+
_spcorelibrary.Validate.isNotDisposed(this, 'DynamicData');
|
|
369
302
|
}
|
|
370
|
-
|
|
371
|
-
sp_core_library_1.Validate.isNotDisposed(this, 'DynamicData');
|
|
372
|
-
}
|
|
373
|
-
var value;
|
|
303
|
+
let value;
|
|
374
304
|
try {
|
|
375
305
|
value = this._hasValue ? this._value : this._provider._getData(this._reference);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
sp_diagnostics_1._EngagementLogger.logEventWithLogEntry(error);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
_spdiagnostics._EngagementLogger.logEventWithLogEntry(error);
|
|
379
308
|
throw error;
|
|
380
309
|
}
|
|
381
|
-
|
|
310
|
+
_spdiagnostics._EngagementLogger.logEventWithLogEntry(new _spdiagnostics._LogEntry('DynamicData', 'getData', _spdiagnostics._LogType.Event, {
|
|
311
|
+
value: JSON.stringify(this.value)
|
|
312
|
+
}));
|
|
382
313
|
return value;
|
|
383
|
-
}
|
|
314
|
+
}
|
|
384
315
|
/**
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
316
|
+
* Create a new DynamicProperty object.
|
|
317
|
+
* @param provider - DynamicDataProvider.
|
|
318
|
+
* @param callback - Optional. Default callback to be registered for updates in the DynamicDataSource.
|
|
319
|
+
*/ constructor(provider, callback){
|
|
320
|
+
this._hasValue = false;
|
|
321
|
+
this._isDisposed = false;
|
|
322
|
+
_spcorelibrary.Validate.isNotNullOrUndefined(provider, 'provider');
|
|
323
|
+
this['__type'] = DynamicProperty._TYPE_NAME;
|
|
324
|
+
this._provider = provider;
|
|
325
|
+
this._callbacks = new Set();
|
|
326
|
+
this._pendingCallbacks = new Set();
|
|
327
|
+
if (callback) {
|
|
328
|
+
// The default callback will be added once a source is configured
|
|
329
|
+
this._pendingCallbacks.add(callback);
|
|
330
|
+
this._defaultCallback = callback;
|
|
331
|
+
} else {
|
|
332
|
+
this._defaultCallback = undefined;
|
|
333
|
+
}
|
|
334
|
+
this._onSourcesChanged = this._onSourcesChangedCallback.bind(this);
|
|
335
|
+
this._cloneDeep = this._cloneDeep.bind(this);
|
|
336
|
+
this._provider.registerAvailableSourcesChanged(this._onSourcesChanged);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Constant with the type name of the DynamicProperty.
|
|
341
|
+
* @internal
|
|
342
|
+
*/ DynamicProperty._TYPE_NAME = 'DynamicProperty';
|
|
343
|
+
DynamicProperty._arrayRegex = new RegExp(/\[\*\]$/);
|
|
344
|
+
|
|
345
|
+
//# sourceMappingURL=./DynamicProperty.js.map
|