@microsoft/sp-component-base 1.22.0-beta.2 → 1.22.0-beta.4

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 (101) hide show
  1. package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +1 -1
  2. package/lib/BaseComponent.d.ts +115 -0
  3. package/lib/BaseComponent.d.ts.map +1 -0
  4. package/lib/BaseComponent.js +162 -0
  5. package/lib/BaseComponentContext.d.ts +142 -0
  6. package/lib/BaseComponentContext.d.ts.map +1 -0
  7. package/lib/BaseComponentContext.js +221 -0
  8. package/lib/DynamicDataProvider.d.ts +166 -0
  9. package/lib/DynamicDataProvider.d.ts.map +1 -0
  10. package/lib/DynamicDataProvider.js +420 -0
  11. package/lib/DynamicDataSourceManager.d.ts +160 -0
  12. package/lib/DynamicDataSourceManager.d.ts.map +1 -0
  13. package/lib/DynamicDataSourceManager.js +382 -0
  14. package/lib/DynamicProperty.d.ts +204 -0
  15. package/lib/DynamicProperty.d.ts.map +1 -0
  16. package/lib/DynamicProperty.js +390 -0
  17. package/lib/EnsureIsolatedDomainUrl.d.ts +9 -0
  18. package/lib/EnsureIsolatedDomainUrl.d.ts.map +1 -0
  19. package/lib/EnsureIsolatedDomainUrl.js +26 -0
  20. package/lib/IComponentPosition.d.ts +28 -0
  21. package/lib/IComponentPosition.d.ts.map +1 -0
  22. package/lib/IComponentPosition.js +2 -0
  23. package/lib/IComponentPropertyMetadata.d.ts +100 -0
  24. package/lib/IComponentPropertyMetadata.d.ts.map +1 -0
  25. package/lib/IComponentPropertyMetadata.js +2 -0
  26. package/lib/ISerializedServerProcessedData.d.ts +166 -0
  27. package/lib/ISerializedServerProcessedData.d.ts.map +1 -0
  28. package/lib/ISerializedServerProcessedData.js +28 -0
  29. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts +40 -0
  30. package/lib/LegacyThirdPartyFabricCoreLoader.d.ts.map +1 -0
  31. package/lib/LegacyThirdPartyFabricCoreLoader.js +90 -0
  32. package/lib/PropertyMetadataProcessor.d.ts +54 -0
  33. package/lib/PropertyMetadataProcessor.d.ts.map +1 -0
  34. package/lib/PropertyMetadataProcessor.js +297 -0
  35. package/lib/ShimmerFactory.d.ts +17 -0
  36. package/lib/ShimmerFactory.d.ts.map +1 -0
  37. package/lib/ShimmerFactory.js +62 -0
  38. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts +17 -0
  39. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.d.ts.map +1 -0
  40. package/lib/chunks/legacy-third-party-fabric-core/FabricLocalFont.js +17 -0
  41. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +9247 -0
  42. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +11165 -0
  43. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-shim.global.scss.css +2063 -0
  44. package/lib/chunks/legacy-third-party-fabric-core/fabric-core-shimKillSwitchActivated.scss.css +2164 -0
  45. package/lib/chunks/legacy-third-party-fabric-core/iconDefinitions.css +6 -0
  46. package/lib/common/Flights.d.ts +3 -0
  47. package/lib/common/Flights.d.ts.map +1 -0
  48. package/lib/common/Flights.js +10 -0
  49. package/lib/common/KillSwitches.d.ts +2 -0
  50. package/lib/common/KillSwitches.d.ts.map +1 -0
  51. package/lib/common/KillSwitches.js +5 -0
  52. package/lib/dataCollector/IWebPartLoadData.d.ts +140 -0
  53. package/lib/dataCollector/IWebPartLoadData.d.ts.map +1 -0
  54. package/lib/dataCollector/IWebPartLoadData.js +40 -0
  55. package/lib/dataCollector/WebPartLoadDataCollector.d.ts +14 -0
  56. package/lib/dataCollector/WebPartLoadDataCollector.d.ts.map +1 -0
  57. package/lib/dataCollector/WebPartLoadDataCollector.js +137 -0
  58. package/lib/index.d.ts +34 -0
  59. package/lib/index.d.ts.map +1 -0
  60. package/lib/index.js +27 -0
  61. package/lib/loc/Strings.resx.d.ts +44 -0
  62. package/lib/loc/Strings.resx.json +1 -0
  63. package/lib/sp-component-base.manifest.json +9 -0
  64. package/lib/styles/shimmer.module.scss.css +11 -0
  65. package/lib/teams/DeferredTeamsAppsClient.d.ts +17 -0
  66. package/lib/teams/DeferredTeamsAppsClient.d.ts.map +1 -0
  67. package/lib/teams/DeferredTeamsAppsClient.js +39 -0
  68. package/lib/teams/ITeamsAppCatalog.d.ts +72 -0
  69. package/lib/teams/ITeamsAppCatalog.d.ts.map +1 -0
  70. package/lib/teams/ITeamsAppCatalog.js +2 -0
  71. package/lib/teams/TeamsAppsClient.d.ts +113 -0
  72. package/lib/teams/TeamsAppsClient.d.ts.map +1 -0
  73. package/lib/teams/TeamsAppsClient.js +440 -0
  74. package/lib/test-api/MockComponent.d.ts +8 -0
  75. package/lib/test-api/MockComponent.d.ts.map +1 -0
  76. package/lib/test-api/MockComponent.js +31 -0
  77. package/lib/test-api/MockComponentContext.d.ts +6 -0
  78. package/lib/test-api/MockComponentContext.d.ts.map +1 -0
  79. package/lib/test-api/MockComponentContext.js +27 -0
  80. package/lib/test-api/index.d.ts +3 -0
  81. package/lib/test-api/index.d.ts.map +1 -0
  82. package/lib/test-api/index.js +3 -0
  83. package/lib/themeProvider/ThemeProvider.d.ts +71 -0
  84. package/lib/themeProvider/ThemeProvider.d.ts.map +1 -0
  85. package/lib/themeProvider/ThemeProvider.js +99 -0
  86. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts +26 -0
  87. package/lib/themeProvider/themeInterfaces/IFontStyles.d.ts.map +1 -0
  88. package/lib/themeProvider/themeInterfaces/IFontStyles.js +2 -0
  89. package/lib/themeProvider/themeInterfaces/IPalette.d.ts +7 -0
  90. package/lib/themeProvider/themeInterfaces/IPalette.d.ts.map +1 -0
  91. package/lib/themeProvider/themeInterfaces/IPalette.js +2 -0
  92. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts +56 -0
  93. package/lib/themeProvider/themeInterfaces/ISemanticColors.d.ts.map +1 -0
  94. package/lib/themeProvider/themeInterfaces/ISemanticColors.js +2 -0
  95. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts +7 -0
  96. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.d.ts.map +1 -0
  97. package/lib/themeProvider/themeInterfaces/ISemanticTextColors.js +2 -0
  98. package/lib/themeProvider/themeInterfaces/ITheme.d.ts +16 -0
  99. package/lib/themeProvider/themeInterfaces/ITheme.d.ts.map +1 -0
  100. package/lib/themeProvider/themeInterfaces/ITheme.js +2 -0
  101. package/package.json +15 -15
@@ -0,0 +1,204 @@
1
+ import { type IDisposable } from '@microsoft/sp-core-library';
2
+ import { type IDynamicDataSource } from '@microsoft/sp-dynamic-data';
3
+ import DynamicDataProvider from './DynamicDataProvider';
4
+ /**
5
+ * Serializable object that simplifies usage of a DynamicProperty.
6
+ *
7
+ * @remarks
8
+ * This is built for usage in web part properties, and modified through the property pane.
9
+ * Can be initialized with a default callback.
10
+ * Web parts initialize with the render method so if the 3rd party developer does nothing, a change in the
11
+ * DynamicProperty will re-render the web part automatically.
12
+ *
13
+ * @public
14
+ */
15
+ export default class DynamicProperty<TValue> implements IDisposable {
16
+ /**
17
+ * Constant with the type name of the DynamicProperty.
18
+ * @internal
19
+ */
20
+ static readonly _TYPE_NAME: string;
21
+ private static readonly _arrayRegex;
22
+ private _reference;
23
+ private _value;
24
+ private _hasValue;
25
+ private _sourceId;
26
+ private _provider?;
27
+ private _isDisposed;
28
+ /**
29
+ * Set to store all callback assigned in order to unregister them when the object gets disposed.
30
+ */
31
+ private _callbacks?;
32
+ /**
33
+ * Default callback. Can be undefined if another callback has been set up.
34
+ */
35
+ private _defaultCallback;
36
+ /**
37
+ * Collection of callbacks that should be registered if/when the DynamicProperty source gets registered.
38
+ * This gets emptied when the source exists.
39
+ */
40
+ private _pendingCallbacks?;
41
+ private _onSourcesChanged?;
42
+ /**
43
+ * Create a new DynamicProperty object.
44
+ * @param provider - DynamicDataProvider.
45
+ * @param callback - Optional. Default callback to be registered for updates in the DynamicDataSource.
46
+ */
47
+ constructor(provider: DynamicDataProvider, callback?: () => void);
48
+ /**
49
+ * Sets the value of the DynamicProperty to be a reference to a DynamicDynamicSource
50
+ * and property. The reference is of the form `<source>:<property>:<path>`.
51
+ * @param reference - Id of the DynamicDataSource and property.
52
+ */
53
+ setReference(reference: string): void;
54
+ /**
55
+ * Sets a static value in the DynamicProperty.
56
+ * @param value - Value for the DynamicProperty.
57
+ */
58
+ setValue(value: TValue): void;
59
+ /**
60
+ * {@inheritDoc @microsoft/sp-core-library#IDisposable.isDisposed}
61
+ */
62
+ get isDisposed(): boolean;
63
+ /**
64
+ * {@inheritDoc @microsoft/sp-core-library#IDisposable.dispose}
65
+ */
66
+ dispose(): void;
67
+ /**
68
+ * Returns a serializable version of the object.
69
+ * To be used when `JSON.stringify()` is called on the object (i.e. during Web Part serialization)
70
+ *
71
+ * @remarks
72
+ * This doesn't follow the naming rule for internal methods because the JavaScript engine needs this exact name.
73
+ *
74
+ * @internal
75
+ */
76
+ toJSON(): object;
77
+ /**
78
+ * DynamicDataReference string that the DynamicProperty object points to.
79
+ * The reference is of the form `<source>:<property>:<path>`.
80
+ *
81
+ * @remarks
82
+ * If the DynamicProperty is set up with static data, this returns undefined.
83
+ */
84
+ get reference(): string | undefined;
85
+ /**
86
+ * Returns the value of the DynamicProperty object, if it has a non-dynamic value.
87
+ * Used for serialization purposes. The proper API to access the value of the object is `tryGetValue()`
88
+ *
89
+ * @internal
90
+ */
91
+ get value(): TValue | undefined;
92
+ /**
93
+ * Returns the value of the object.
94
+ *
95
+ * @remarks
96
+ * If the value is an array, then the first element of the array is returned;
97
+ * otherwise, the value itself is returned.
98
+ *
99
+ * NOTE: This api will never return an array. To retrieve an array value,
100
+ * use the {@link DynamicProperty.tryGetValues} API.
101
+ *
102
+ * @returns the value associated with the dynamic property or
103
+ * undefined if the source or the data doesn't exist.
104
+ */
105
+ tryGetValue(): TValue | undefined;
106
+ /**
107
+ * Returns the value of the object.
108
+ *
109
+ * @remarks
110
+ * If the value is NOT an array, then an array is returned with the value being the single entry;
111
+ * otherwise, the value itself is returned. If the property is undefined or cannot be found,
112
+ * an empty array will be returned.
113
+ *
114
+ * NOTE: This api will always return an array and it assumes that the array is homogeneous.
115
+ * To retrieve a non-array value, use the {@link DynamicProperty.tryGetValue} API.
116
+ *
117
+ * @returns the value associated with the dynamic property or
118
+ * an empty array if the source or the data doesn't exist.
119
+ */
120
+ tryGetValues(): TValue[];
121
+ /**
122
+ * Returns the DynamicDataSource that the DynamicProperty object refers to.
123
+ * Returns undefined if the source doesn't exist.
124
+ */
125
+ tryGetSource(): IDynamicDataSource | undefined;
126
+ /**
127
+ * Registers a callback function for updates on the associated DynamicDataSource.
128
+ * @param callback - Callback function to register.
129
+ */
130
+ register(callback: () => void): void;
131
+ /**
132
+ * Unregisters a callback function for updates on the associated DynamicDataSource.
133
+ * The callback function must be the same it was registered with.
134
+ * @param callback - Callback function to unregister.
135
+ */
136
+ unregister(callback: () => void): void;
137
+ /**
138
+ * Returns true if the object has a default callback.
139
+ */
140
+ hasDefaultCallback(): boolean;
141
+ /**
142
+ * Removes the registration for the default callback.
143
+ *
144
+ * @remarks
145
+ * This can be useful for advanced users who only want their custom callbacks.
146
+ */
147
+ removeDefaultCallback(): void;
148
+ /**
149
+ * Returns the id of the DynamicDataSource if the DynamicProperty has a reference set.
150
+ *
151
+ * @internal
152
+ */
153
+ _getSourceId(): string;
154
+ /**
155
+ * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
156
+ *
157
+ * NOTE: This is accessed from the property pane code while building the DynamicDataWidget.
158
+ * @internal
159
+ */
160
+ _getProperty(): string;
161
+ /**
162
+ * Returns the path from the property that the object points to, if applicable.
163
+ * If not applicable, returns an empty string.
164
+ *
165
+ * @internal
166
+ */
167
+ _getPropertyPath(): string;
168
+ /**
169
+ * Returns a deep cloned version of the current instance.
170
+ *
171
+ * @remarks
172
+ * Since the dynamic property is maintaining an instance of the DynamicDataProvider,
173
+ * which which when serialized will result in 'Maximum call stack size exceeded' based
174
+ * on what kind of sources they hold references to.
175
+ *
176
+ * For example, if the dynamicDataProvider is holding PageContext source, which internally
177
+ * has serviceScope in its state. Deep cloning this source would result in the above mentioned
178
+ * error.
179
+ *
180
+ * Hence we would want to just clone the dynamicDataProvider not deep clone it.
181
+ *
182
+ * @returns - Custom deep Cloned version of the current instance.
183
+ *
184
+ * @internal
185
+ */
186
+ _cloneDeep(instance: DynamicProperty<unknown>): unknown;
187
+ /**
188
+ * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
189
+ *
190
+ * @remarks
191
+ * Removes the array notation from the property name, if any, before it is being registered.
192
+ * This is to avoid any mismatch between the strings passed by the source when it notifies
193
+ * a property change, as the source doesn't pass any array notation with the property name.
194
+ * Array notation is only for internal representation, for a property whose value is an array type.
195
+ */
196
+ private _getPropertyToRegister;
197
+ /**
198
+ * Callback when the DynamicDataSources list changes.
199
+ * It registers the pending callbacks into the DynamicDataProvidere.
200
+ */
201
+ private _onSourcesChangedCallback;
202
+ private _getData;
203
+ }
204
+ //# sourceMappingURL=DynamicProperty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicProperty.d.ts","sourceRoot":"","sources":["../src/DynamicProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,KAAK,kBAAkB,EAAwB,MAAM,4BAA4B,CAAC;AAE3F,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe,CAAC,MAAM,CAAE,YAAW,WAAW;IACjE;;;OAGG;IACH,gBAAuB,UAAU,EAAE,MAAM,CAAqB;IAC9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAEpE,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,SAAS,CAAC,CAAsB;IACxC,OAAO,CAAC,WAAW,CAAkB;IAErC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,CAAkB;IACrC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAA2B;IACnD;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAC,CAAkB;IAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAa;IAEvC;;;;OAIG;gBACgB,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI;IAuBvE;;;;OAIG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAmB5C;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAcpC;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;OAEG;IACI,OAAO,IAAI,IAAI;IAsBtB;;;;;;;;OAQG;IACI,MAAM,IAAI,MAAM;IAcvB;;;;;;OAMG;IACH,IAAW,SAAS,IAAI,MAAM,GAAG,SAAS,CAEzC;IAED;;;;;OAKG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED;;;;;;;;;;;;OAYG;IACI,WAAW,IAAI,MAAM,GAAG,SAAS;IAoBxC;;;;;;;;;;;;;OAaG;IACI,YAAY,IAAI,MAAM,EAAE;IAkB/B;;;OAGG;IACI,YAAY,IAAI,kBAAkB,GAAG,SAAS;IAcrD;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAW3C;;;;OAIG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAW7C;;OAEG;IACI,kBAAkB,IAAI,OAAO;IAIpC;;;;;OAKG;IACI,qBAAqB,IAAI,IAAI;IAOpC;;;;OAIG;IACI,YAAY,IAAI,MAAM;IAK7B;;;;;OAKG;IACI,YAAY,IAAI,MAAM;IAK7B;;;;;OAKG;IACI,gBAAgB,IAAI,MAAM;IAKjC;;;;;;;;;;;;;;;;;OAiBG;IAEI,UAAU,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO;IAQ9D;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,QAAQ;CAwBjB"}
@@ -0,0 +1,390 @@
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
+ /**
7
+ * Serializable object that simplifies usage of a DynamicProperty.
8
+ *
9
+ * @remarks
10
+ * This is built for usage in web part properties, and modified through the property pane.
11
+ * Can be initialized with a default callback.
12
+ * Web parts initialize with the render method so if the 3rd party developer does nothing, a change in the
13
+ * DynamicProperty will re-render the web part automatically.
14
+ *
15
+ * @public
16
+ */
17
+ var DynamicProperty = /** @class */ (function () {
18
+ /**
19
+ * Create a new DynamicProperty object.
20
+ * @param provider - DynamicDataProvider.
21
+ * @param callback - Optional. Default callback to be registered for updates in the DynamicDataSource.
22
+ */
23
+ function DynamicProperty(provider, callback) {
24
+ this._hasValue = false;
25
+ this._isDisposed = false;
26
+ Validate.isNotNullOrUndefined(provider, 'provider');
27
+ this['__type'] = DynamicProperty._TYPE_NAME;
28
+ this._provider = provider;
29
+ this._callbacks = new Set();
30
+ this._pendingCallbacks = new Set();
31
+ if (callback) {
32
+ // The default callback will be added once a source is configured
33
+ this._pendingCallbacks.add(callback);
34
+ this._defaultCallback = callback;
35
+ }
36
+ else {
37
+ this._defaultCallback = undefined;
38
+ }
39
+ this._onSourcesChanged = this._onSourcesChangedCallback.bind(this);
40
+ this._cloneDeep = this._cloneDeep.bind(this);
41
+ this._provider.registerAvailableSourcesChanged(this._onSourcesChanged);
42
+ }
43
+ /**
44
+ * Sets the value of the DynamicProperty to be a reference to a DynamicDynamicSource
45
+ * and property. The reference is of the form `<source>:<property>:<path>`.
46
+ * @param reference - Id of the DynamicDataSource and property.
47
+ */
48
+ DynamicProperty.prototype.setReference = function (reference) {
49
+ var _this = this;
50
+ Validate.isNonemptyString(reference, 'id');
51
+ this._value = undefined;
52
+ this._hasValue = false;
53
+ // Potentially changing the source. Remove all callbacks, change the source, and add callbacks again.
54
+ var callbacks = new Set();
55
+ this._callbacks.forEach(function (callback) { return callbacks.add(callback); });
56
+ this._callbacks.forEach(function (callback) { return _this.unregister(callback); });
57
+ this._reference = new DynamicDataReference(reference);
58
+ this._sourceId = this._getSourceId();
59
+ callbacks.forEach(function (callback) { return _this.register(callback); });
60
+ // The source has changed, so act if a new source was added
61
+ this._onSourcesChangedCallback();
62
+ };
63
+ /**
64
+ * Sets a static value in the DynamicProperty.
65
+ * @param value - Value for the DynamicProperty.
66
+ */
67
+ DynamicProperty.prototype.setValue = function (value) {
68
+ var _this = this;
69
+ // Removing the source. Remove all callback, set the value, and add the callback again so they are not lost.
70
+ // Callbacks will be stored in the pending callbacks list.
71
+ var callbacks = this._callbacks;
72
+ callbacks.forEach(function (callback) { return _this.unregister(callback); });
73
+ this._value = value;
74
+ this._reference = undefined;
75
+ this._sourceId = undefined;
76
+ this._hasValue = true;
77
+ callbacks.forEach(function (callback) { return _this.register(callback); });
78
+ };
79
+ Object.defineProperty(DynamicProperty.prototype, "isDisposed", {
80
+ /**
81
+ * {@inheritDoc @microsoft/sp-core-library#IDisposable.isDisposed}
82
+ */
83
+ get: function () {
84
+ return this._isDisposed;
85
+ },
86
+ enumerable: false,
87
+ configurable: true
88
+ });
89
+ /**
90
+ * {@inheritDoc @microsoft/sp-core-library#IDisposable.dispose}
91
+ */
92
+ DynamicProperty.prototype.dispose = function () {
93
+ var _this = this;
94
+ if (!this._isDisposed) {
95
+ this._provider.unregisterAvailableSourcesChanged(this._onSourcesChanged);
96
+ if (this._defaultCallback) {
97
+ this.unregister(this._defaultCallback);
98
+ delete this._defaultCallback;
99
+ }
100
+ this._callbacks.forEach(function (callback) { return _this.unregister(callback); });
101
+ delete this._callbacks;
102
+ delete this._onSourcesChanged;
103
+ delete this._pendingCallbacks;
104
+ delete this._provider;
105
+ delete this._reference;
106
+ delete this._sourceId;
107
+ this._isDisposed = true;
108
+ }
109
+ };
110
+ /**
111
+ * Returns a serializable version of the object.
112
+ * To be used when `JSON.stringify()` is called on the object (i.e. during Web Part serialization)
113
+ *
114
+ * @remarks
115
+ * This doesn't follow the naming rule for internal methods because the JavaScript engine needs this exact name.
116
+ *
117
+ * @internal
118
+ */
119
+ DynamicProperty.prototype.toJSON = function () {
120
+ if (this._hasValue) {
121
+ return {
122
+ __type: DynamicProperty._TYPE_NAME,
123
+ value: this._value
124
+ };
125
+ }
126
+ else {
127
+ return {
128
+ __type: DynamicProperty._TYPE_NAME,
129
+ reference: this._reference
130
+ };
131
+ }
132
+ };
133
+ Object.defineProperty(DynamicProperty.prototype, "reference", {
134
+ /**
135
+ * DynamicDataReference string that the DynamicProperty object points to.
136
+ * The reference is of the form `<source>:<property>:<path>`.
137
+ *
138
+ * @remarks
139
+ * If the DynamicProperty is set up with static data, this returns undefined.
140
+ */
141
+ get: function () {
142
+ return this._hasValue ? undefined : this._reference.reference;
143
+ },
144
+ enumerable: false,
145
+ configurable: true
146
+ });
147
+ Object.defineProperty(DynamicProperty.prototype, "value", {
148
+ /**
149
+ * Returns the value of the DynamicProperty object, if it has a non-dynamic value.
150
+ * Used for serialization purposes. The proper API to access the value of the object is `tryGetValue()`
151
+ *
152
+ * @internal
153
+ */
154
+ get: function () {
155
+ return this._value;
156
+ },
157
+ enumerable: false,
158
+ configurable: true
159
+ });
160
+ /**
161
+ * Returns the value of the object.
162
+ *
163
+ * @remarks
164
+ * If the value is an array, then the first element of the array is returned;
165
+ * otherwise, the value itself is returned.
166
+ *
167
+ * NOTE: This api will never return an array. To retrieve an array value,
168
+ * use the {@link DynamicProperty.tryGetValues} API.
169
+ *
170
+ * @returns the value associated with the dynamic property or
171
+ * undefined if the source or the data doesn't exist.
172
+ */
173
+ DynamicProperty.prototype.tryGetValue = function () {
174
+ if (this.isDisposed &&
175
+ !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
176
+ return undefined;
177
+ }
178
+ else {
179
+ Validate.isNotDisposed(this, 'DynamicData');
180
+ }
181
+ var value = this._getData();
182
+ if (Array.isArray(value)) {
183
+ value = value[0];
184
+ }
185
+ return value;
186
+ };
187
+ /**
188
+ * Returns the value of the object.
189
+ *
190
+ * @remarks
191
+ * If the value is NOT an array, then an array is returned with the value being the single entry;
192
+ * otherwise, the value itself is returned. If the property is undefined or cannot be found,
193
+ * an empty array will be returned.
194
+ *
195
+ * NOTE: This api will always return an array and it assumes that the array is homogeneous.
196
+ * To retrieve a non-array value, use the {@link DynamicProperty.tryGetValue} API.
197
+ *
198
+ * @returns the value associated with the dynamic property or
199
+ * an empty array if the source or the data doesn't exist.
200
+ */
201
+ DynamicProperty.prototype.tryGetValues = function () {
202
+ var value = this._getData();
203
+ // OK, time for some massaging of the return.
204
+ if (value) {
205
+ // If there is a value returned, but it isn't an array, create an array and
206
+ // make this the return value the sole contents of the array
207
+ if (!Array.isArray(value)) {
208
+ value = [value];
209
+ }
210
+ }
211
+ else {
212
+ // In this case, we are saying that there is no value. For this scenario
213
+ // we simply return an empty array.
214
+ value = [];
215
+ }
216
+ return value;
217
+ };
218
+ /**
219
+ * Returns the DynamicDataSource that the DynamicProperty object refers to.
220
+ * Returns undefined if the source doesn't exist.
221
+ */
222
+ DynamicProperty.prototype.tryGetSource = function () {
223
+ if (this.isDisposed &&
224
+ !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
225
+ return undefined;
226
+ }
227
+ else {
228
+ Validate.isNotDisposed(this, 'DynamicData');
229
+ }
230
+ return this._hasValue ? undefined : this._provider.tryGetSource(this._sourceId);
231
+ };
232
+ /**
233
+ * Registers a callback function for updates on the associated DynamicDataSource.
234
+ * @param callback - Callback function to register.
235
+ */
236
+ DynamicProperty.prototype.register = function (callback) {
237
+ Validate.isNotDisposed(this, 'DynamicData');
238
+ if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
239
+ this._provider.registerPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
240
+ this._callbacks.add(callback);
241
+ }
242
+ else {
243
+ this._pendingCallbacks.add(callback);
244
+ }
245
+ };
246
+ /**
247
+ * Unregisters a callback function for updates on the associated DynamicDataSource.
248
+ * The callback function must be the same it was registered with.
249
+ * @param callback - Callback function to unregister.
250
+ */
251
+ DynamicProperty.prototype.unregister = function (callback) {
252
+ Validate.isNotDisposed(this, 'DynamicData');
253
+ if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
254
+ this._provider.unregisterPropertyChanged(this._sourceId, this._getPropertyToRegister(), callback);
255
+ }
256
+ this._pendingCallbacks.delete(callback);
257
+ this._callbacks.delete(callback);
258
+ };
259
+ /**
260
+ * Returns true if the object has a default callback.
261
+ */
262
+ DynamicProperty.prototype.hasDefaultCallback = function () {
263
+ return !!this._defaultCallback;
264
+ };
265
+ /**
266
+ * Removes the registration for the default callback.
267
+ *
268
+ * @remarks
269
+ * This can be useful for advanced users who only want their custom callbacks.
270
+ */
271
+ DynamicProperty.prototype.removeDefaultCallback = function () {
272
+ if (this._defaultCallback) {
273
+ this.unregister(this._defaultCallback);
274
+ this._defaultCallback = undefined;
275
+ }
276
+ };
277
+ /**
278
+ * Returns the id of the DynamicDataSource if the DynamicProperty has a reference set.
279
+ *
280
+ * @internal
281
+ */
282
+ DynamicProperty.prototype._getSourceId = function () {
283
+ Validate.isNotDisposed(this, 'DynamicData');
284
+ return this._hasValue ? '' : this._reference.sourceId;
285
+ };
286
+ /**
287
+ * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
288
+ *
289
+ * NOTE: This is accessed from the property pane code while building the DynamicDataWidget.
290
+ * @internal
291
+ */
292
+ DynamicProperty.prototype._getProperty = function () {
293
+ Validate.isNotDisposed(this, 'DynamicData');
294
+ return this._hasValue ? '' : this._reference.property;
295
+ };
296
+ /**
297
+ * Returns the path from the property that the object points to, if applicable.
298
+ * If not applicable, returns an empty string.
299
+ *
300
+ * @internal
301
+ */
302
+ DynamicProperty.prototype._getPropertyPath = function () {
303
+ Validate.isNotDisposed(this, 'DynamicData');
304
+ return this._hasValue ? '' : this._reference.propertyPath || '';
305
+ };
306
+ /**
307
+ * Returns a deep cloned version of the current instance.
308
+ *
309
+ * @remarks
310
+ * Since the dynamic property is maintaining an instance of the DynamicDataProvider,
311
+ * which which when serialized will result in 'Maximum call stack size exceeded' based
312
+ * on what kind of sources they hold references to.
313
+ *
314
+ * For example, if the dynamicDataProvider is holding PageContext source, which internally
315
+ * has serviceScope in its state. Deep cloning this source would result in the above mentioned
316
+ * error.
317
+ *
318
+ * Hence we would want to just clone the dynamicDataProvider not deep clone it.
319
+ *
320
+ * @returns - Custom deep Cloned version of the current instance.
321
+ *
322
+ * @internal
323
+ */
324
+ DynamicProperty.prototype._cloneDeep = function (instance) {
325
+ return lodash.cloneDeepWith(instance, function (prop) {
326
+ if (prop instanceof DynamicDataProvider) {
327
+ return prop;
328
+ }
329
+ });
330
+ };
331
+ /**
332
+ * Returns the property name of the DynamicDataSource that the DynamicProperty points to.
333
+ *
334
+ * @remarks
335
+ * Removes the array notation from the property name, if any, before it is being registered.
336
+ * This is to avoid any mismatch between the strings passed by the source when it notifies
337
+ * a property change, as the source doesn't pass any array notation with the property name.
338
+ * Array notation is only for internal representation, for a property whose value is an array type.
339
+ */
340
+ DynamicProperty.prototype._getPropertyToRegister = function () {
341
+ Validate.isNotDisposed(this, 'DynamicData');
342
+ // Split the property string on the array notation to get
343
+ // the property name. If the array notation is not present,
344
+ // then the original string is returned in the array.
345
+ return this._getProperty().split(DynamicProperty._arrayRegex)[0];
346
+ };
347
+ /**
348
+ * Callback when the DynamicDataSources list changes.
349
+ * It registers the pending callbacks into the DynamicDataProvidere.
350
+ */
351
+ DynamicProperty.prototype._onSourcesChangedCallback = function () {
352
+ var _this = this;
353
+ if (!this._hasValue && this._sourceId && !!this._provider.tryGetSource(this._sourceId)) {
354
+ var callbacksToAdd = this._pendingCallbacks;
355
+ this._pendingCallbacks = new Set();
356
+ callbacksToAdd.forEach(function (callback) {
357
+ _this.register(callback);
358
+ callback();
359
+ });
360
+ }
361
+ };
362
+ DynamicProperty.prototype._getData = function () {
363
+ if (this.isDisposed &&
364
+ !_SPKillSwitch.isActivated('413769dc-5e0c-4609-9c86-bdf099fe84e3' /*, '12/02/2021', 'DisposedUndefinedNotException'*/)) {
365
+ return undefined;
366
+ }
367
+ else {
368
+ Validate.isNotDisposed(this, 'DynamicData');
369
+ }
370
+ var value;
371
+ try {
372
+ value = this._hasValue ? this._value : this._provider._getData(this._reference);
373
+ }
374
+ catch (error) {
375
+ _EngagementLogger.logEventWithLogEntry(error);
376
+ throw error;
377
+ }
378
+ _EngagementLogger.logEventWithLogEntry(new _LogEntry('DynamicData', 'getData', _LogType.Event, { value: JSON.stringify(this.value) }));
379
+ return value;
380
+ };
381
+ /**
382
+ * Constant with the type name of the DynamicProperty.
383
+ * @internal
384
+ */
385
+ DynamicProperty._TYPE_NAME = 'DynamicProperty';
386
+ DynamicProperty._arrayRegex = new RegExp(/\[\*\]$/);
387
+ return DynamicProperty;
388
+ }());
389
+ export default DynamicProperty;
390
+ //# sourceMappingURL=DynamicProperty.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates an absolute url with the isolatedDomain parameter.
3
+ * @param isolatedDomain - a domain without the protocol. Ex: "PrepSPO-appFEEAB5CE1CB0421FB1AAE5D09E0A8AAA.spgrid.com"
4
+ * @param absoluteUrl - url with protocol that may or may not contain a path. Ex: "https://prepspo.spgrid.com"
5
+ *
6
+ * @internal
7
+ */
8
+ export declare function ensureIsolatedDomainUrl(isolatedDomain: string | undefined, absoluteUrl: string): string;
9
+ //# sourceMappingURL=EnsureIsolatedDomainUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnsureIsolatedDomainUrl.d.ts","sourceRoot":"","sources":["../src/EnsureIsolatedDomainUrl.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAoBvG"}
@@ -0,0 +1,26 @@
1
+ var domainRegex = new RegExp('^https://[^/]*/');
2
+ /**
3
+ * Creates an absolute url with the isolatedDomain parameter.
4
+ * @param isolatedDomain - a domain without the protocol. Ex: "PrepSPO-appFEEAB5CE1CB0421FB1AAE5D09E0A8AAA.spgrid.com"
5
+ * @param absoluteUrl - url with protocol that may or may not contain a path. Ex: "https://prepspo.spgrid.com"
6
+ *
7
+ * @internal
8
+ */
9
+ export function ensureIsolatedDomainUrl(isolatedDomain, absoluteUrl) {
10
+ if (!isolatedDomain) {
11
+ return absoluteUrl;
12
+ }
13
+ // replace the domain in "https://domain/path" with isolatedDomain
14
+ var slashAdded = false;
15
+ if (absoluteUrl.charAt(absoluteUrl.length - 1) !== '/') {
16
+ absoluteUrl = absoluteUrl + '/';
17
+ slashAdded = true;
18
+ }
19
+ absoluteUrl = absoluteUrl.replace(domainRegex, "https://".concat(isolatedDomain, "/"));
20
+ if (slashAdded) {
21
+ // Remove the ending slash
22
+ absoluteUrl = absoluteUrl.substr(0, absoluteUrl.length - 1);
23
+ }
24
+ return absoluteUrl;
25
+ }
26
+ //# sourceMappingURL=EnsureIsolatedDomainUrl.js.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export interface IComponentPosition {
5
+ /**
6
+ * Represents the parent section index if hosted in a section.
7
+ */
8
+ readonly sectionIndex: undefined | number;
9
+ /**
10
+ * Represents the control index
11
+ */
12
+ readonly controlIndex: undefined | number;
13
+ /**
14
+ * Represents the relative space of the section to consume. Specific to the Canvas hosting.
15
+ *
16
+ * 0 means this is a full bleed control.
17
+ */
18
+ readonly sectionFactor?: number;
19
+ /**
20
+ * Represents the component order in the section.
21
+ */
22
+ readonly componentOrder: undefined | number;
23
+ /**
24
+ * Represents the number of section components. For ACEs: number of cards in the dashboard.
25
+ */
26
+ readonly numberOfSectionComponents: undefined | number;
27
+ }
28
+ //# sourceMappingURL=IComponentPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IComponentPosition.d.ts","sourceRoot":"","sources":["../src/IComponentPosition.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAGhC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,GAAG,MAAM,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,yBAAyB,EAAE,SAAS,GAAG,MAAM,CAAC;CACxD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IComponentPosition.js.map