@ni/nimble-components 35.12.2 → 35.12.3

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.
@@ -121,6 +121,50 @@
121
121
  if ($global.trustedTypes === void 0) {
122
122
  $global.trustedTypes = { createPolicy: (n, r) => r };
123
123
  }
124
+ // Shims of globals for SSR environments that load client code in the server module graph
125
+ // Shim only what is not defined in-case SSR env is loading their own polyfills (which would need to be loaded first).
126
+ for (const name of [
127
+ "Node",
128
+ "Element",
129
+ "HTMLElement",
130
+ "ShadowRoot",
131
+ "Event",
132
+ "CustomEvent",
133
+ "MutationObserver",
134
+ "ResizeObserver",
135
+ "IntersectionObserver",
136
+ "CSSStyleSheet"
137
+ ]) {
138
+ if (typeof ($global[name]) === "undefined") {
139
+ $global[name] = class {
140
+ };
141
+ }
142
+ }
143
+ // Minimal custom elements registry for the react wrapper to leverage for tag names
144
+ if (typeof ($global.customElements) === "undefined") {
145
+ const constructorsByName = new Map();
146
+ const namesByConstructor = new Map();
147
+ $global.customElements = {
148
+ define(name, constructor) {
149
+ if (!constructorsByName.has(name)) {
150
+ constructorsByName.set(name, constructor);
151
+ namesByConstructor.set(constructor, name);
152
+ }
153
+ },
154
+ get(name) {
155
+ return constructorsByName.get(name);
156
+ },
157
+ getName(constructor) {
158
+ return namesByConstructor.get(constructor) ?? null;
159
+ },
160
+ whenDefined() {
161
+ return Promise.resolve();
162
+ },
163
+ upgrade() {
164
+ // no-op
165
+ },
166
+ };
167
+ }
124
168
  const propConfig = {
125
169
  configurable: false,
126
170
  enumerable: false,
@@ -250,7 +294,9 @@
250
294
  /**
251
295
  * Indicates whether the DOM supports the adoptedStyleSheets feature.
252
296
  */
253
- supportsAdoptedStyleSheets: Array.isArray(document.adoptedStyleSheets) &&
297
+ supportsAdoptedStyleSheets: typeof document !== "undefined" &&
298
+ typeof CSSStyleSheet !== "undefined" &&
299
+ Array.isArray(document.adoptedStyleSheets) &&
254
300
  "replace" in CSSStyleSheet.prototype,
255
301
  /**
256
302
  * Sets the HTML trusted types policy used by the templating engine.
@@ -6913,7 +6959,8 @@
6913
6959
  /**
6914
6960
  * @alpha
6915
6961
  */
6916
- const supportsElementInternals = ElementInternalsKey in window &&
6962
+ const supportsElementInternals = typeof window !== "undefined" &&
6963
+ ElementInternalsKey in window &&
6917
6964
  "setFormValue" in window[ElementInternalsKey].prototype;
6918
6965
  const InternalsMap = new WeakMap();
6919
6966
  /**
@@ -9021,7 +9068,7 @@
9021
9068
  return false;
9022
9069
  }
9023
9070
 
9024
- const defaultElement = document.createElement("div");
9071
+ const defaultElement = typeof document === "undefined" ? {} : document.createElement("div");
9025
9072
  function isFastElement(element) {
9026
9073
  return element instanceof FASTElement;
9027
9074
  }
@@ -9195,7 +9242,7 @@
9195
9242
  * @param root - the root to normalize
9196
9243
  */
9197
9244
  static normalizeRoot(root) {
9198
- return root === defaultElement ? document : root;
9245
+ return (root === defaultElement && typeof document !== "undefined") ? document : root;
9199
9246
  }
9200
9247
  }
9201
9248
  // Caches PropertyTarget instances
@@ -9212,6 +9259,12 @@
9212
9259
  */
9213
9260
  const PropertyTargetManager = Object.freeze({
9214
9261
  getOrCreate(source) {
9262
+ if (typeof document === "undefined") {
9263
+ return {
9264
+ setProperty() { },
9265
+ removeProperty() { },
9266
+ };
9267
+ }
9215
9268
  if (propertyTargetCache.has(source)) {
9216
9269
  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
9217
9270
  return propertyTargetCache.get(source);
@@ -14922,7 +14975,10 @@
14922
14975
  */
14923
14976
  class DocumentElementLang {
14924
14977
  constructor() {
14925
- this.lang = document.documentElement.lang;
14978
+ this.lang = typeof document === 'undefined' ? '' : document.documentElement.lang;
14979
+ if (typeof document === 'undefined') {
14980
+ return;
14981
+ }
14926
14982
  const observer = new MutationObserver(mutations => {
14927
14983
  for (const mutation of mutations) {
14928
14984
  if (mutation.type === 'attributes'