@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
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import * as lodash from '@microsoft/sp-lodash-subset';
|
|
2
|
+
import { _SPKillSwitch, Validate } from '@microsoft/sp-core-library';
|
|
3
|
+
import { DynamicDataReference } from '@microsoft/sp-dynamic-data';
|
|
4
|
+
import DynamicDataProvider from './DynamicDataProvider';
|
|
5
|
+
import { _LogEntry, _EngagementLogger, _LogType } from '@microsoft/sp-diagnostics';
|
|
6
|
+
class DynamicProperty {
|
|
7
|
+
/**
|
|
8
|
+
* Sets the value of the DynamicProperty to be a reference to a DynamicDynamicSource
|
|
9
|
+
* and property. The reference is of the form `<source>:<property>:<path>`.
|
|
10
|
+
* @param reference - Id of the DynamicDataSource and property.
|
|
11
|
+
*/ setReference(reference) {
|
|
12
|
+
Validate.isNonemptyString(reference, 'id');
|
|
13
|
+
this._value = undefined;
|
|
14
|
+
this._hasValue = false;
|
|
15
|
+
// Potentially changing the source. Remove all callbacks, change the source, and add callbacks again.
|
|
16
|
+
const callbacks = new Set();
|
|
17
|
+
this._callbacks.forEach((callback)=>callbacks.add(callback));
|
|
18
|
+
this._callbacks.forEach((callback)=>this.unregister(callback));
|
|
19
|
+
this._reference = new DynamicDataReference(reference);
|
|
20
|
+
this._sourceId = this._getSourceId();
|
|
21
|
+
callbacks.forEach((callback)=>this.register(callback));
|
|
22
|
+
// The source has changed, so act if a new source was added
|
|
23
|
+
this._onSourcesChangedCallback();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets a static value in the DynamicProperty.
|
|
27
|
+
* @param value - Value for the DynamicProperty.
|
|
28
|
+
*/ setValue(value) {
|
|
29
|
+
// Removing the source. Remove all callback, set the value, and add the callback again so they are not lost.
|
|
30
|
+
// Callbacks will be stored in the pending callbacks list.
|
|
31
|
+
const callbacks = this._callbacks;
|
|
32
|
+
callbacks.forEach((callback)=>this.unregister(callback));
|
|
33
|
+
this._value = value;
|
|
34
|
+
this._reference = undefined;
|
|
35
|
+
this._sourceId = undefined;
|
|
36
|
+
this._hasValue = true;
|
|
37
|
+
callbacks.forEach((callback)=>this.register(callback));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc @microsoft/sp-core-library#IDisposable.isDisposed}
|
|
41
|
+
*/ get isDisposed() {
|
|
42
|
+
return this._isDisposed;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc @microsoft/sp-core-library#IDisposable.dispose}
|
|
46
|
+
*/ dispose() {
|
|
47
|
+
if (!this._isDisposed) {
|
|
48
|
+
this._provider.unregisterAvailableSourcesChanged(this._onSourcesChanged);
|
|
49
|
+
if (this._defaultCallback) {
|
|
50
|
+
this.unregister(this._defaultCallback);
|
|
51
|
+
delete this._defaultCallback;
|
|
52
|
+
}
|
|
53
|
+
this._callbacks.forEach((callback)=>this.unregister(callback));
|
|
54
|
+
delete this._callbacks;
|
|
55
|
+
delete this._onSourcesChanged;
|
|
56
|
+
delete this._pendingCallbacks;
|
|
57
|
+
delete this._provider;
|
|
58
|
+
delete this._reference;
|
|
59
|
+
delete this._sourceId;
|
|
60
|
+
this._isDisposed = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns a serializable version of the object.
|
|
65
|
+
* To be used when `JSON.stringify()` is called on the object (i.e. during Web Part serialization)
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* This doesn't follow the naming rule for internal methods because the JavaScript engine needs this exact name.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/ toJSON() {
|
|
72
|
+
if (this._hasValue) {
|
|
73
|
+
return {
|
|
74
|
+
__type: DynamicProperty._TYPE_NAME,
|
|
75
|
+
value: this._value
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
return {
|
|
79
|
+
__type: DynamicProperty._TYPE_NAME,
|
|
80
|
+
reference: this._reference
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* DynamicDataReference string that the DynamicProperty object points to.
|
|
86
|
+
* The reference is of the form `<source>:<property>:<path>`.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* If the DynamicProperty is set up with static data, this returns undefined.
|
|
90
|
+
*/ get reference() {
|
|
91
|
+
return this._hasValue ? undefined : this._reference.reference;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the value of the DynamicProperty object, if it has a non-dynamic value.
|
|
95
|
+
* Used for serialization purposes. The proper API to access the value of the object is `tryGetValue()`
|
|
96
|
+
*
|
|
97
|
+
* @internal
|
|
98
|
+
*/ get value() {
|
|
99
|
+
return this._value;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the value of the object.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* If the value is an array, then the first element of the array is returned;
|
|
106
|
+
* otherwise, the value itself is returned.
|
|
107
|
+
*
|
|
108
|
+
* NOTE: This api will never return an array. To retrieve an array value,
|
|
109
|
+
* use the {@link DynamicProperty.tryGetValues} API.
|
|
110
|
+
*
|
|
111
|
+
* @returns the value associated with the dynamic property or
|
|
112
|
+
* undefined if the source or the data doesn't exist.
|
|
113
|
+
*/ tryGetValue() {
|
|
114
|
+
if (this.isDisposed && !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
115
|
+
return undefined;
|
|
116
|
+
} else {
|
|
117
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
118
|
+
}
|
|
119
|
+
let value = this._getData();
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
value = value[0];
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns the value of the object.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* If the value is NOT an array, then an array is returned with the value being the single entry;
|
|
130
|
+
* otherwise, the value itself is returned. If the property is undefined or cannot be found,
|
|
131
|
+
* an empty array will be returned.
|
|
132
|
+
*
|
|
133
|
+
* NOTE: This api will always return an array and it assumes that the array is homogeneous.
|
|
134
|
+
* To retrieve a non-array value, use the {@link DynamicProperty.tryGetValue} API.
|
|
135
|
+
*
|
|
136
|
+
* @returns the value associated with the dynamic property or
|
|
137
|
+
* an empty array if the source or the data doesn't exist.
|
|
138
|
+
*/ tryGetValues() {
|
|
139
|
+
let value = this._getData();
|
|
140
|
+
// OK, time for some massaging of the return.
|
|
141
|
+
if (value) {
|
|
142
|
+
// If there is a value returned, but it isn't an array, create an array and
|
|
143
|
+
// make this the return value the sole contents of the array
|
|
144
|
+
if (!Array.isArray(value)) {
|
|
145
|
+
value = [
|
|
146
|
+
value
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
// In this case, we are saying that there is no value. For this scenario
|
|
151
|
+
// we simply return an empty array.
|
|
152
|
+
value = [];
|
|
153
|
+
}
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Returns the DynamicDataSource that the DynamicProperty object refers to.
|
|
158
|
+
* Returns undefined if the source doesn't exist.
|
|
159
|
+
*/ tryGetSource() {
|
|
160
|
+
if (this.isDisposed && !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
161
|
+
return undefined;
|
|
162
|
+
} else {
|
|
163
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
164
|
+
}
|
|
165
|
+
return this._hasValue ? undefined : this._provider.tryGetSource(this._sourceId);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Registers a callback function for updates on the associated DynamicDataSource.
|
|
169
|
+
* @param callback - Callback function to register.
|
|
170
|
+
*/ register(callback) {
|
|
171
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
172
|
+
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
173
|
+
this._provider.registerPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
|
|
174
|
+
this._callbacks.add(callback);
|
|
175
|
+
} else {
|
|
176
|
+
this._pendingCallbacks.add(callback);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Unregisters a callback function for updates on the associated DynamicDataSource.
|
|
181
|
+
* The callback function must be the same it was registered with.
|
|
182
|
+
* @param callback - Callback function to unregister.
|
|
183
|
+
*/ unregister(callback) {
|
|
184
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
185
|
+
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
186
|
+
this._provider.unregisterPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
|
|
187
|
+
}
|
|
188
|
+
this._pendingCallbacks.delete(callback);
|
|
189
|
+
this._callbacks.delete(callback);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns true if the object has a default callback.
|
|
193
|
+
*/ hasDefaultCallback() {
|
|
194
|
+
return !!this._defaultCallback;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Removes the registration for the default callback.
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* This can be useful for advanced users who only want their custom callbacks.
|
|
201
|
+
*/ removeDefaultCallback() {
|
|
202
|
+
if (this._defaultCallback) {
|
|
203
|
+
this.unregister(this._defaultCallback);
|
|
204
|
+
this._defaultCallback = undefined;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns the id of the DynamicDataSource if the DynamicProperty has a reference set.
|
|
209
|
+
*
|
|
210
|
+
* @internal
|
|
211
|
+
*/ _getSourceId() {
|
|
212
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
213
|
+
return this._hasValue ? '' : this._reference.sourceId;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns the property name of the DynamicDataSource that the DynamicProperty points to.
|
|
217
|
+
*
|
|
218
|
+
* NOTE: This is accessed from the property pane code while building the DynamicDataWidget.
|
|
219
|
+
* @internal
|
|
220
|
+
*/ _getProperty() {
|
|
221
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
222
|
+
return this._hasValue ? '' : this._reference.property;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Returns the path from the property that the object points to, if applicable.
|
|
226
|
+
* If not applicable, returns an empty string.
|
|
227
|
+
*
|
|
228
|
+
* @internal
|
|
229
|
+
*/ _getPropertyPath() {
|
|
230
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
231
|
+
return this._hasValue ? '' : this._reference.propertyPath || '';
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Returns a deep cloned version of the current instance.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* Since the dynamic property is maintaining an instance of the DynamicDataProvider,
|
|
238
|
+
* which which when serialized will result in 'Maximum call stack size exceeded' based
|
|
239
|
+
* on what kind of sources they hold references to.
|
|
240
|
+
*
|
|
241
|
+
* For example, if the dynamicDataProvider is holding PageContext source, which internally
|
|
242
|
+
* has serviceScope in its state. Deep cloning this source would result in the above mentioned
|
|
243
|
+
* error.
|
|
244
|
+
*
|
|
245
|
+
* Hence we would want to just clone the dynamicDataProvider not deep clone it.
|
|
246
|
+
*
|
|
247
|
+
* @returns - Custom deep Cloned version of the current instance.
|
|
248
|
+
*
|
|
249
|
+
* @internal
|
|
250
|
+
*/ _cloneDeep(instance) {
|
|
251
|
+
return lodash.cloneDeepWith(instance, (prop)=>{
|
|
252
|
+
if (prop instanceof DynamicDataProvider) {
|
|
253
|
+
return prop;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns the property name of the DynamicDataSource that the DynamicProperty points to.
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* Removes the array notation from the property name, if any, before it is being registered.
|
|
262
|
+
* This is to avoid any mismatch between the strings passed by the source when it notifies
|
|
263
|
+
* a property change, as the source doesn't pass any array notation with the property name.
|
|
264
|
+
* Array notation is only for internal representation, for a property whose value is an array type.
|
|
265
|
+
*/ _getPropertyToRegister() {
|
|
266
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
267
|
+
// Split the property string on the array notation to get
|
|
268
|
+
// the property name. If the array notation is not present,
|
|
269
|
+
// then the original string is returned in the array.
|
|
270
|
+
return this._getProperty().split(DynamicProperty._arrayRegex)[0];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Callback when the DynamicDataSources list changes.
|
|
274
|
+
* It registers the pending callbacks into the DynamicDataProvidere.
|
|
275
|
+
*/ _onSourcesChangedCallback() {
|
|
276
|
+
if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
|
|
277
|
+
const callbacksToAdd = this._pendingCallbacks;
|
|
278
|
+
this._pendingCallbacks = new Set();
|
|
279
|
+
callbacksToAdd.forEach((callback)=>{
|
|
280
|
+
this.register(callback);
|
|
281
|
+
callback();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
_getData() {
|
|
286
|
+
if (this.isDisposed && !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/ )) {
|
|
287
|
+
return undefined;
|
|
288
|
+
} else {
|
|
289
|
+
Validate.isNotDisposed(this, 'DynamicData');
|
|
290
|
+
}
|
|
291
|
+
let value;
|
|
292
|
+
try {
|
|
293
|
+
value = this._hasValue ? this._value : this._provider._getData(this._reference);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
_EngagementLogger.logEventWithLogEntry(error);
|
|
296
|
+
throw error;
|
|
297
|
+
}
|
|
298
|
+
_EngagementLogger.logEventWithLogEntry(new _LogEntry('DynamicData', 'getData', _LogType.Event, {
|
|
299
|
+
value: JSON.stringify(this.value)
|
|
300
|
+
}));
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Create a new DynamicProperty object.
|
|
305
|
+
* @param provider - DynamicDataProvider.
|
|
306
|
+
* @param callback - Optional. Default callback to be registered for updates in the DynamicDataSource.
|
|
307
|
+
*/ constructor(provider, callback){
|
|
308
|
+
this._hasValue = false;
|
|
309
|
+
this._isDisposed = false;
|
|
310
|
+
Validate.isNotNullOrUndefined(provider, 'provider');
|
|
311
|
+
this['__type'] = DynamicProperty._TYPE_NAME;
|
|
312
|
+
this._provider = provider;
|
|
313
|
+
this._callbacks = new Set();
|
|
314
|
+
this._pendingCallbacks = new Set();
|
|
315
|
+
if (callback) {
|
|
316
|
+
// The default callback will be added once a source is configured
|
|
317
|
+
this._pendingCallbacks.add(callback);
|
|
318
|
+
this._defaultCallback = callback;
|
|
319
|
+
} else {
|
|
320
|
+
this._defaultCallback = undefined;
|
|
321
|
+
}
|
|
322
|
+
this._onSourcesChanged = this._onSourcesChangedCallback.bind(this);
|
|
323
|
+
this._cloneDeep = this._cloneDeep.bind(this);
|
|
324
|
+
this._provider.registerAvailableSourcesChanged(this._onSourcesChanged);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Constant with the type name of the DynamicProperty.
|
|
329
|
+
* @internal
|
|
330
|
+
*/ DynamicProperty._TYPE_NAME = 'DynamicProperty';
|
|
331
|
+
DynamicProperty._arrayRegex = new RegExp(/\[\*\]$/);
|
|
332
|
+
/**
|
|
333
|
+
* Serializable object that simplifies usage of a DynamicProperty.
|
|
334
|
+
*
|
|
335
|
+
* @remarks
|
|
336
|
+
* This is built for usage in web part properties, and modified through the property pane.
|
|
337
|
+
* Can be initialized with a default callback.
|
|
338
|
+
* Web parts initialize with the render method so if the 3rd party developer does nothing, a change in the
|
|
339
|
+
* DynamicProperty will re-render the web part automatically.
|
|
340
|
+
*
|
|
341
|
+
* @public
|
|
342
|
+
*/ export { DynamicProperty as default };
|
|
343
|
+
|
|
344
|
+
//# sourceMappingURL=./DynamicProperty.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
const domainRegex = new RegExp('^https://[^/]*/');
|
|
2
2
|
/**
|
|
3
3
|
* Creates an absolute url with the isolatedDomain parameter.
|
|
4
4
|
* @param isolatedDomain - a domain without the protocol. Ex: "PrepSPO-appFEEAB5CE1CB0421FB1AAE5D09E0A8AAA.spgrid.com"
|
|
5
5
|
* @param absoluteUrl - url with protocol that may or may not contain a path. Ex: "https://prepspo.spgrid.com"
|
|
6
6
|
*
|
|
7
7
|
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export function ensureIsolatedDomainUrl(isolatedDomain, absoluteUrl) {
|
|
8
|
+
*/ export function ensureIsolatedDomainUrl(isolatedDomain, absoluteUrl) {
|
|
10
9
|
if (!isolatedDomain) {
|
|
11
10
|
return absoluteUrl;
|
|
12
11
|
}
|
|
13
12
|
// replace the domain in "https://domain/path" with isolatedDomain
|
|
14
|
-
|
|
13
|
+
let slashAdded = false;
|
|
15
14
|
if (absoluteUrl.charAt(absoluteUrl.length - 1) !== '/') {
|
|
16
15
|
absoluteUrl = absoluteUrl + '/';
|
|
17
16
|
slashAdded = true;
|
|
18
17
|
}
|
|
19
|
-
absoluteUrl = absoluteUrl.replace(domainRegex,
|
|
18
|
+
absoluteUrl = absoluteUrl.replace(domainRegex, `https://${isolatedDomain}/`);
|
|
20
19
|
if (slashAdded) {
|
|
21
20
|
// Remove the ending slash
|
|
22
21
|
absoluteUrl = absoluteUrl.substr(0, absoluteUrl.length - 1);
|
|
23
22
|
}
|
|
24
23
|
return absoluteUrl;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=./EnsureIsolatedDomainUrl.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
/**
|
|
3
|
+
* Server processed data type.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/ // eslint-disable-next-line @typescript-eslint/typedef
|
|
7
|
+
export const ServerProcessedDataType = {
|
|
8
|
+
/**
|
|
9
|
+
* The date type is valid html string.
|
|
10
|
+
*/ htmlString: 1,
|
|
11
|
+
/**
|
|
12
|
+
* The date type is a link to a resource.
|
|
13
|
+
* The link can be a SharePoint content link or non-SharePoint link.
|
|
14
|
+
*/ link: 2,
|
|
15
|
+
/**
|
|
16
|
+
* The date type is a link to a image.
|
|
17
|
+
* The link can be a SharePoint content link or non-SharePoint link.
|
|
18
|
+
*/ imageSource: 3,
|
|
19
|
+
/**
|
|
20
|
+
* The data type is a string that should be search indexed.
|
|
21
|
+
*/ searchablePlainText: 4
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=./ISerializedServerProcessedData.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Version } from '@microsoft/sp-core-library';
|
|
2
|
+
class LegacyThirdPartyFabricCoreLoader {
|
|
3
|
+
/**
|
|
4
|
+
* Method to dynamically load the legacy third-party fabric core styles.
|
|
5
|
+
* This method should be called only when a third-party component(web part or extension)
|
|
6
|
+
* is being loaded on to the page.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: Remove this method when the below killswitch is graduated from \@microsoft/sp-webpart-base.
|
|
9
|
+
* 'isStopLoadingLegacyFabricCSSKillSwitchActivated' - '57b771ed-2b57-41c2-aaaa-0e21c587c6dc'
|
|
10
|
+
*
|
|
11
|
+
* @param isComponentInternal - indicates whether the requesting component is internal to Microsoft or not.
|
|
12
|
+
*/ static load(isComponentInternal) {
|
|
13
|
+
if (!isComponentInternal && !LegacyThirdPartyFabricCoreLoader._isLoaded) {
|
|
14
|
+
return import(/* webpackChunkName: 'legacy-third-party-fabric-core-localfont' */ './chunks/legacy-third-party-fabric-core/FabricLocalFont').then(()=>{
|
|
15
|
+
LegacyThirdPartyFabricCoreLoader._isLoaded = true;
|
|
16
|
+
return;
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Method to dynamically force load the legacy third-party fabric core styles.
|
|
24
|
+
* All the below conditions are checked and needs to be true to force load the legacy css:
|
|
25
|
+
* 1. Should be third party component (web part or extension)
|
|
26
|
+
* 2. Should not be already loaded
|
|
27
|
+
* 3. Component should ask to load the legacy css or if the component is built version \< 1.8
|
|
28
|
+
*
|
|
29
|
+
* @param manifest - component's manifest
|
|
30
|
+
*/ static forceLoad(manifest) {
|
|
31
|
+
try {
|
|
32
|
+
if (LegacyThirdPartyFabricCoreLoader._shouldLoad(manifest)) {
|
|
33
|
+
return import(/* webpackChunkName: 'legacy-third-party-fabric-core-localfont' */ './chunks/legacy-third-party-fabric-core/FabricLocalFont').then(()=>{
|
|
34
|
+
LegacyThirdPartyFabricCoreLoader._isLoaded = true;
|
|
35
|
+
return;
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return Promise.reject(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Method to check if the web part need to load the legacy css.
|
|
46
|
+
* @param manifest - component's manifest
|
|
47
|
+
*/ static needLegacyFabricCss(manifest) {
|
|
48
|
+
if (manifest.isInternal) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
/*
|
|
52
|
+
* If loadLegacyFabricCss is not specified by the component, then load the css
|
|
53
|
+
* if the component is built before SPFx 1.8.2 or in some cases when we cannot get
|
|
54
|
+
* the version of the SPFx.
|
|
55
|
+
*/ if (manifest.loadLegacyFabricCss === undefined) {
|
|
56
|
+
const version = Version._tryParseSPFxVersion(manifest);
|
|
57
|
+
return !version || version.lessThan(Version.parse('1.8.2'));
|
|
58
|
+
}
|
|
59
|
+
// Respect 'loadLegacyFabricCss' if a real value is provided.
|
|
60
|
+
return manifest.loadLegacyFabricCss;
|
|
61
|
+
}
|
|
62
|
+
static _shouldLoad(manifest) {
|
|
63
|
+
return !LegacyThirdPartyFabricCoreLoader._isLoaded && LegacyThirdPartyFabricCoreLoader.needLegacyFabricCss(manifest);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Indicates whether the fabric-core styles are loaded on the page or not.
|
|
68
|
+
*/ LegacyThirdPartyFabricCoreLoader._isLoaded = false;
|
|
69
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
70
|
+
/**
|
|
71
|
+
* Class to load async chunks.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/ export { LegacyThirdPartyFabricCoreLoader as default };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=./LegacyThirdPartyFabricCoreLoader.js.map
|