@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.
Files changed (171) hide show
  1. package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +136 -141
  2. package/dist/{chunk.legacy-third-party-fabric-core-localfont_none_9e84ea19c68fdc8b9094.js → chunk.legacy-third-party-fabric-core-localfont_none_b7f7978a3e90166c361b.js} +1 -1
  3. package/dist/chunk.teams-apps-client_none_27d3c7c1d01080e4f131.js +2 -0
  4. package/dist/index-internal-beta.d.ts +30 -8
  5. package/dist/index-internal-public.d.ts +30 -8
  6. package/dist/index-internal.d.ts +30 -8
  7. package/dist/sp-component-base_default_8d535b51fa18aa47002b.js +22 -0
  8. package/dist/sp-component-base_en-us_8ce25dfb69a7786caece.js +22 -0
  9. package/dist/sp-component-base_qps-ploc_4fec831895d90df8aa7a.js +22 -0
  10. package/dist/sp-component-base_qps-ploca_b80610c8dff04dcec755.js +22 -0
  11. package/dist/tsdoc-metadata.json +1 -1
  12. package/lib-commonjs/BaseComponent.js +110 -145
  13. package/lib-commonjs/BaseComponentContext.js +126 -183
  14. package/lib-commonjs/DynamicDataProvider.js +251 -268
  15. package/lib-commonjs/DynamicDataSourceManager.js +218 -241
  16. package/lib-commonjs/DynamicProperty.js +232 -280
  17. package/lib-commonjs/EnsureIsolatedDomainUrl.js +14 -14
  18. package/lib-commonjs/IComponentPosition.js +8 -3
  19. package/lib-commonjs/IComponentPropertyMetadata.js +10 -3
  20. package/lib-commonjs/ISerializedServerProcessedData.js +24 -21
  21. package/lib-commonjs/LegacyThirdPartyFabricCoreLoader.js +53 -87
  22. package/lib-commonjs/PropertyMetadataProcessor.js +117 -150
  23. package/lib-commonjs/RenderableComponentContext.js +37 -0
  24. package/lib-commonjs/ShimmerFactory.js +66 -51
  25. package/lib-commonjs/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +6 -4
  26. package/lib-commonjs/common/Flights.js +22 -10
  27. package/lib-commonjs/common/KillSwitches.js +13 -6
  28. package/lib-commonjs/dataCollector/IWebPartLoadData.js +35 -30
  29. package/lib-commonjs/dataCollector/WebPartLoadDataCollector.js +82 -91
  30. package/lib-commonjs/index.js +78 -38
  31. package/lib-commonjs/teams/DeferredTeamsAppsClient.js +30 -52
  32. package/lib-commonjs/teams/ITeamsAppCatalog.js +10 -3
  33. package/lib-commonjs/teams/TeamsAppsClient.js +189 -231
  34. package/lib-commonjs/test-api/MockComponent.js +38 -23
  35. package/lib-commonjs/test-api/MockComponentContext.js +21 -14
  36. package/lib-commonjs/test-api/index.js +21 -7
  37. package/lib-commonjs/themeProvider/ThemeProvider.js +68 -82
  38. package/lib-commonjs/themeProvider/themeInterfaces/IFontStyles.js +5 -2
  39. package/lib-commonjs/themeProvider/themeInterfaces/IPalette.js +10 -3
  40. package/lib-commonjs/themeProvider/themeInterfaces/ISemanticColors.js +59 -3
  41. package/lib-commonjs/themeProvider/themeInterfaces/ISemanticTextColors.js +10 -3
  42. package/lib-commonjs/themeProvider/themeInterfaces/ITheme.js +5 -2
  43. package/{lib → lib-dts}/BaseComponent.d.ts +8 -8
  44. package/{lib → lib-dts}/BaseComponentContext.d.ts +5 -5
  45. package/lib-dts/RenderableComponentContext.d.ts +35 -0
  46. package/{lib → lib-dts}/index.d.ts +1 -0
  47. package/lib-esm/BaseComponent.js +123 -0
  48. package/lib-esm/BaseComponentContext.js +157 -0
  49. package/lib-esm/DynamicDataProvider.js +401 -0
  50. package/lib-esm/DynamicDataSourceManager.js +358 -0
  51. package/lib-esm/DynamicProperty.js +344 -0
  52. package/{lib → lib-esm}/EnsureIsolatedDomainUrl.js +6 -6
  53. package/lib-esm/IComponentPosition.js +5 -0
  54. package/lib-esm/IComponentPropertyMetadata.js +7 -0
  55. package/lib-esm/ISerializedServerProcessedData.js +24 -0
  56. package/lib-esm/LegacyThirdPartyFabricCoreLoader.js +76 -0
  57. package/{lib → lib-esm}/PropertyMetadataProcessor.js +92 -127
  58. package/lib-esm/RenderableComponentContext.js +26 -0
  59. package/lib-esm/ShimmerFactory.js +74 -0
  60. package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +3 -3
  61. package/{lib → lib-esm}/common/Flights.js +4 -3
  62. package/{lib → lib-esm}/common/KillSwitches.js +3 -2
  63. package/lib-esm/dataCollector/IWebPartLoadData.js +33 -0
  64. package/lib-esm/dataCollector/WebPartLoadDataCollector.js +125 -0
  65. package/{lib → lib-esm}/index.js +4 -3
  66. package/lib-esm/teams/DeferredTeamsAppsClient.js +32 -0
  67. package/lib-esm/teams/ITeamsAppCatalog.js +9 -0
  68. package/lib-esm/teams/TeamsAppsClient.js +395 -0
  69. package/lib-esm/test-api/MockComponent.js +38 -0
  70. package/{lib → lib-esm}/test-api/MockComponentContext.js +10 -11
  71. package/{lib → lib-esm}/test-api/index.js +2 -1
  72. package/lib-esm/themeProvider/ThemeProvider.js +79 -0
  73. package/lib-esm/themeProvider/themeInterfaces/IFontStyles.js +7 -0
  74. package/lib-esm/themeProvider/themeInterfaces/IPalette.js +7 -0
  75. package/lib-esm/themeProvider/themeInterfaces/ISemanticColors.js +56 -0
  76. package/lib-esm/themeProvider/themeInterfaces/ISemanticTextColors.js +7 -0
  77. package/lib-esm/themeProvider/themeInterfaces/ITheme.js +7 -0
  78. package/package.json +41 -14
  79. package/dist/chunk.teams-apps-client_none_f9872389cb6ea9ad28e2.js +0 -2
  80. package/dist/sp-component-base_default_5ba07be39b0dc8968f7b.js +0 -2
  81. package/dist/sp-component-base_en-us_eb9bebb3acce0ae83f1c.js +0 -2
  82. package/dist/sp-component-base_qps-ploc_45f37623d87c3d848f2a.js +0 -2
  83. package/dist/sp-component-base_qps-ploca_b3f3b7bf97c4185b0fd6.js +0 -2
  84. package/lib/BaseComponent.d.ts.map +0 -1
  85. package/lib/BaseComponent.js +0 -161
  86. package/lib/BaseComponentContext.d.ts.map +0 -1
  87. package/lib/BaseComponentContext.js +0 -222
  88. package/lib/DynamicDataProvider.d.ts.map +0 -1
  89. package/lib/DynamicDataProvider.js +0 -420
  90. package/lib/DynamicDataSourceManager.d.ts.map +0 -1
  91. package/lib/DynamicDataSourceManager.js +0 -382
  92. package/lib/DynamicProperty.d.ts.map +0 -1
  93. package/lib/DynamicProperty.js +0 -390
  94. package/lib/EnsureIsolatedDomainUrl.d.ts.map +0 -1
  95. package/lib/IComponentPosition.d.ts.map +0 -1
  96. package/lib/IComponentPosition.js +0 -2
  97. package/lib/IComponentPropertyMetadata.d.ts.map +0 -1
  98. package/lib/IComponentPropertyMetadata.js +0 -2
  99. package/lib/ISerializedServerProcessedData.d.ts.map +0 -1
  100. package/lib/ISerializedServerProcessedData.js +0 -28
  101. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +0 -1
  102. package/lib/LegacyThirdPartyFabricCoreLoader.js +0 -90
  103. package/lib/PropertyMetadataProcessor.d.ts.map +0 -1
  104. package/lib/ShimmerFactory.d.ts.map +0 -1
  105. package/lib/ShimmerFactory.js +0 -62
  106. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +0 -1
  107. package/lib/common/Flights.d.ts.map +0 -1
  108. package/lib/common/KillSwitches.d.ts.map +0 -1
  109. package/lib/dataCollector/IWebPartLoadData.d.ts.map +0 -1
  110. package/lib/dataCollector/IWebPartLoadData.js +0 -40
  111. package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +0 -1
  112. package/lib/dataCollector/WebPartLoadDataCollector.js +0 -137
  113. package/lib/index.d.ts.map +0 -1
  114. package/lib/teams/DeferredTeamsAppsClient.d.ts.map +0 -1
  115. package/lib/teams/DeferredTeamsAppsClient.js +0 -39
  116. package/lib/teams/ITeamsAppCatalog.d.ts.map +0 -1
  117. package/lib/teams/ITeamsAppCatalog.js +0 -2
  118. package/lib/teams/TeamsAppsClient.d.ts.map +0 -1
  119. package/lib/teams/TeamsAppsClient.js +0 -440
  120. package/lib/test-api/MockComponent.d.ts.map +0 -1
  121. package/lib/test-api/MockComponent.js +0 -31
  122. package/lib/test-api/MockComponentContext.d.ts.map +0 -1
  123. package/lib/test-api/index.d.ts.map +0 -1
  124. package/lib/themeProvider/ThemeProvider.d.ts.map +0 -1
  125. package/lib/themeProvider/ThemeProvider.js +0 -99
  126. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +0 -1
  127. package/lib/themeProvider/themeInterfaces/IFontStyles.js +0 -2
  128. package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +0 -1
  129. package/lib/themeProvider/themeInterfaces/IPalette.js +0 -2
  130. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +0 -1
  131. package/lib/themeProvider/themeInterfaces/ISemanticColors.js +0 -2
  132. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +0 -1
  133. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +0 -2
  134. package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +0 -1
  135. package/lib/themeProvider/themeInterfaces/ITheme.js +0 -2
  136. /package/{lib → lib-dts}/DynamicDataProvider.d.ts +0 -0
  137. /package/{lib → lib-dts}/DynamicDataSourceManager.d.ts +0 -0
  138. /package/{lib → lib-dts}/DynamicProperty.d.ts +0 -0
  139. /package/{lib → lib-dts}/EnsureIsolatedDomainUrl.d.ts +0 -0
  140. /package/{lib → lib-dts}/IComponentPosition.d.ts +0 -0
  141. /package/{lib → lib-dts}/IComponentPropertyMetadata.d.ts +0 -0
  142. /package/{lib → lib-dts}/ISerializedServerProcessedData.d.ts +0 -0
  143. /package/{lib → lib-dts}/LegacyThirdPartyFabricCoreLoader.d.ts +0 -0
  144. /package/{lib → lib-dts}/PropertyMetadataProcessor.d.ts +0 -0
  145. /package/{lib → lib-dts}/ShimmerFactory.d.ts +0 -0
  146. /package/{lib → lib-dts}/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +0 -0
  147. /package/{lib → lib-dts}/common/Flights.d.ts +0 -0
  148. /package/{lib → lib-dts}/common/KillSwitches.d.ts +0 -0
  149. /package/{lib → lib-dts}/dataCollector/IWebPartLoadData.d.ts +0 -0
  150. /package/{lib → lib-dts}/dataCollector/WebPartLoadDataCollector.d.ts +0 -0
  151. /package/{lib → lib-dts}/loc/Strings.resx.d.ts +0 -0
  152. /package/{lib → lib-dts}/teams/DeferredTeamsAppsClient.d.ts +0 -0
  153. /package/{lib → lib-dts}/teams/ITeamsAppCatalog.d.ts +0 -0
  154. /package/{lib → lib-dts}/teams/TeamsAppsClient.d.ts +0 -0
  155. /package/{lib → lib-dts}/test-api/MockComponent.d.ts +0 -0
  156. /package/{lib → lib-dts}/test-api/MockComponentContext.d.ts +0 -0
  157. /package/{lib → lib-dts}/test-api/index.d.ts +0 -0
  158. /package/{lib → lib-dts}/themeProvider/ThemeProvider.d.ts +0 -0
  159. /package/{lib → lib-dts}/themeProvider/themeInterfaces/IFontStyles.d.ts +0 -0
  160. /package/{lib → lib-dts}/themeProvider/themeInterfaces/IPalette.d.ts +0 -0
  161. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticColors.d.ts +0 -0
  162. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +0 -0
  163. /package/{lib → lib-dts}/themeProvider/themeInterfaces/ITheme.d.ts +0 -0
  164. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +0 -0
  165. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +0 -0
  166. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +0 -0
  167. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +0 -0
  168. /package/{lib → lib-esm}/chunks/legacy-third-party-fabric-core/iconDefinitions.css +0 -0
  169. /package/{lib → lib-esm}/loc/Strings.resx.json +0 -0
  170. /package/{lib → lib-esm}/sp-component-base.manifest.json +0 -0
  171. /package/{lib → lib-esm}/styles/shimmer.module.scss.css +0 -0
@@ -1,106 +1,68 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var lodash = tslib_1.__importStar(require("@microsoft/sp-lodash-subset"));
5
- var sp_core_library_1 = require("@microsoft/sp-core-library");
6
- var sp_dynamic_data_1 = require("@microsoft/sp-dynamic-data");
7
- var DynamicDataProvider_1 = tslib_1.__importDefault(require("./DynamicDataProvider"));
8
- var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
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
- * Sets the value of the DynamicProperty to be a reference to a DynamicDynamicSource
48
- * and property. The reference is of the form `<source>:<property>:<path>`.
49
- * @param reference - Id of the DynamicDataSource and property.
50
- */
51
- DynamicProperty.prototype.setReference = function (reference) {
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
- var callbacks = new Set();
58
- this._callbacks.forEach(function (callback) { return callbacks.add(callback); });
59
- this._callbacks.forEach(function (callback) { return _this.unregister(callback); });
60
- this._reference = new sp_dynamic_data_1.DynamicDataReference(reference);
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(function (callback) { return _this.register(callback); });
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
- * Sets a static value in the DynamicProperty.
68
- * @param value - Value for the DynamicProperty.
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
- var callbacks = this._callbacks;
75
- callbacks.forEach(function (callback) { return _this.unregister(callback); });
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(function (callback) { return _this.register(callback); });
81
- };
82
- Object.defineProperty(DynamicProperty.prototype, "isDisposed", {
83
- /**
84
- * {@inheritDoc @microsoft/sp-core-library#IDisposable.isDisposed}
85
- */
86
- get: function () {
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
- * {@inheritDoc @microsoft/sp-core-library#IDisposable.dispose}
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(function (callback) { return _this.unregister(callback); });
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
- * Returns a serializable version of the object.
115
- * To be used when `JSON.stringify()` is called on the object (i.e. during Web Part serialization)
116
- *
117
- * @remarks
118
- * This doesn't follow the naming rule for internal methods because the JavaScript engine needs this exact name.
119
- *
120
- * @internal
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
- * Returns the value of the object.
165
- *
166
- * @remarks
167
- * If the value is an array, then the first element of the array is returned;
168
- * otherwise, the value itself is returned.
169
- *
170
- * NOTE: This api will never return an array. To retrieve an array value,
171
- * use the {@link DynamicProperty.tryGetValues} API.
172
- *
173
- * @returns the value associated with the dynamic property or
174
- * undefined if the source or the data doesn't exist.
175
- */
176
- DynamicProperty.prototype.tryGetValue = function () {
177
- if (this.isDisposed &&
178
- !sp_core_library_1._SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
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
- else {
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
- * Returns the value of the object.
192
- *
193
- * @remarks
194
- * If the value is NOT an array, then an array is returned with the value being the single entry;
195
- * otherwise, the value itself is returned. If the property is undefined or cannot be found,
196
- * an empty array will be returned.
197
- *
198
- * NOTE: This api will always return an array and it assumes that the array is homogeneous.
199
- * To retrieve a non-array value, use the {@link DynamicProperty.tryGetValue} API.
200
- *
201
- * @returns the value associated with the dynamic property or
202
- * an empty array if the source or the data doesn't exist.
203
- */
204
- DynamicProperty.prototype.tryGetValues = function () {
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 = [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
- * Returns the DynamicDataSource that the DynamicProperty object refers to.
223
- * Returns undefined if the source doesn't exist.
224
- */
225
- DynamicProperty.prototype.tryGetSource = function () {
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
- else {
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
- * Registers a callback function for updates on the associated DynamicDataSource.
237
- * @param callback - Callback function to register.
238
- */
239
- DynamicProperty.prototype.register = function (callback) {
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
- * Unregisters a callback function for updates on the associated DynamicDataSource.
251
- * The callback function must be the same it was registered with.
252
- * @param callback - Callback function to unregister.
253
- */
254
- DynamicProperty.prototype.unregister = function (callback) {
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
- * Returns true if the object has a default callback.
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
- * Removes the registration for the default callback.
270
- *
271
- * @remarks
272
- * This can be useful for advanced users who only want their custom callbacks.
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
- * Returns the id of the DynamicDataSource if the DynamicProperty has a reference set.
282
- *
283
- * @internal
284
- */
285
- DynamicProperty.prototype._getSourceId = function () {
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
- * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
291
- *
292
- * NOTE: This is accessed from the property pane code while building the DynamicDataWidget.
293
- * @internal
294
- */
295
- DynamicProperty.prototype._getProperty = function () {
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
- * Returns the path from the property that the object points to, if applicable.
301
- * If not applicable, returns an empty string.
302
- *
303
- * @internal
304
- */
305
- DynamicProperty.prototype._getPropertyPath = function () {
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
- * Returns a deep cloned version of the current instance.
311
- *
312
- * @remarks
313
- * Since the dynamic property is maintaining an instance of the DynamicDataProvider,
314
- * which which when serialized will result in 'Maximum call stack size exceeded' based
315
- * on what kind of sources they hold references to.
316
- *
317
- * For example, if the dynamicDataProvider is holding PageContext source, which internally
318
- * has serviceScope in its state. Deep cloning this source would result in the above mentioned
319
- * error.
320
- *
321
- * Hence we would want to just clone the dynamicDataProvider not deep clone it.
322
- *
323
- * @returns - Custom deep Cloned version of the current instance.
324
- *
325
- * @internal
326
- */
327
- DynamicProperty.prototype._cloneDeep = function (instance) {
328
- return lodash.cloneDeepWith(instance, function (prop) {
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
- * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
336
- *
337
- * @remarks
338
- * Removes the array notation from the property name, if any, before it is being registered.
339
- * This is to avoid any mismatch between the strings passed by the source when it notifies
340
- * a property change, as the source doesn't pass any array notation with the property name.
341
- * Array notation is only for internal representation, for a property whose value is an array type.
342
- */
343
- DynamicProperty.prototype._getPropertyToRegister = function () {
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
- * Callback when the DynamicDataSources list changes.
352
- * It registers the pending callbacks into the DynamicDataProvidere.
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
- var callbacksToAdd = this._pendingCallbacks;
289
+ const callbacksToAdd = this._pendingCallbacks;
358
290
  this._pendingCallbacks = new Set();
359
- callbacksToAdd.forEach(function (callback) {
360
- _this.register(callback);
291
+ callbacksToAdd.forEach((callback)=>{
292
+ this.register(callback);
361
293
  callback();
362
294
  });
363
295
  }
364
- };
365
- DynamicProperty.prototype._getData = function () {
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
- else {
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
- catch (error) {
378
- sp_diagnostics_1._EngagementLogger.logEventWithLogEntry(error);
306
+ } catch (error) {
307
+ _spdiagnostics._EngagementLogger.logEventWithLogEntry(error);
379
308
  throw error;
380
309
  }
381
- sp_diagnostics_1._EngagementLogger.logEventWithLogEntry(new sp_diagnostics_1._LogEntry('DynamicData', 'getData', sp_diagnostics_1._LogType.Event, { value: JSON.stringify(this.value) }));
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
- * Constant with the type name of the DynamicProperty.
386
- * @internal
387
- */
388
- DynamicProperty._TYPE_NAME = 'DynamicProperty';
389
- DynamicProperty._arrayRegex = new RegExp(/\[\*\]$/);
390
- return DynamicProperty;
391
- }());
392
- exports.default = DynamicProperty;
393
- //# sourceMappingURL=DynamicProperty.js.map
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