@schematichq/schematic-components 2.0.1 → 2.0.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.
@@ -89,82 +89,6 @@ var require_void_elements = __commonJS({
89
89
  }
90
90
  });
91
91
 
92
- // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
93
- var require_use_sync_external_store_shim_development = __commonJS({
94
- "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
95
- "use strict";
96
- (function() {
97
- function is(x2, y2) {
98
- return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
99
- }
100
- function useSyncExternalStore$2(subscribe, getSnapshot) {
101
- didWarnOld18Alpha || void 0 === React3.startTransition || (didWarnOld18Alpha = true, console.error(
102
- "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
103
- ));
104
- var value = getSnapshot();
105
- if (!didWarnUncachedGetSnapshot) {
106
- var cachedValue = getSnapshot();
107
- objectIs(value, cachedValue) || (console.error(
108
- "The result of getSnapshot should be cached to avoid an infinite loop"
109
- ), didWarnUncachedGetSnapshot = true);
110
- }
111
- cachedValue = useState21({
112
- inst: { value, getSnapshot }
113
- });
114
- var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
115
- useLayoutEffect6(
116
- function() {
117
- inst.value = value;
118
- inst.getSnapshot = getSnapshot;
119
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
120
- },
121
- [subscribe, value, getSnapshot]
122
- );
123
- useEffect11(
124
- function() {
125
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
126
- return subscribe(function() {
127
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
128
- });
129
- },
130
- [subscribe]
131
- );
132
- useDebugValue(value);
133
- return value;
134
- }
135
- function checkIfSnapshotChanged(inst) {
136
- var latestGetSnapshot = inst.getSnapshot;
137
- inst = inst.value;
138
- try {
139
- var nextValue = latestGetSnapshot();
140
- return !objectIs(inst, nextValue);
141
- } catch (error) {
142
- return true;
143
- }
144
- }
145
- function useSyncExternalStore$1(subscribe, getSnapshot) {
146
- return getSnapshot();
147
- }
148
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
149
- var React3 = require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState21 = React3.useState, useEffect11 = React3.useEffect, useLayoutEffect6 = React3.useLayoutEffect, useDebugValue = React3.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
150
- exports.useSyncExternalStore = void 0 !== React3.useSyncExternalStore ? React3.useSyncExternalStore : shim;
151
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
152
- })();
153
- }
154
- });
155
-
156
- // node_modules/use-sync-external-store/shim/index.js
157
- var require_shim = __commonJS({
158
- "node_modules/use-sync-external-store/shim/index.js"(exports, module2) {
159
- "use strict";
160
- if (false) {
161
- module2.exports = null;
162
- } else {
163
- module2.exports = require_use_sync_external_store_shim_development();
164
- }
165
- }
166
- });
167
-
168
92
  // node_modules/lodash/isObject.js
169
93
  var require_isObject = __commonJS({
170
94
  "node_modules/lodash/isObject.js"(exports, module2) {
@@ -7218,18 +7142,15 @@ IcuTrans.displayName = "IcuTrans";
7218
7142
 
7219
7143
  // node_modules/react-i18next/dist/es/useTranslation.js
7220
7144
  var import_react10 = require("react");
7221
- var import_shim = __toESM(require_shim(), 1);
7222
- var notReadyT = (k2, optsOrDefaultValue) => {
7223
- if (isString2(optsOrDefaultValue)) return optsOrDefaultValue;
7224
- if (isObject(optsOrDefaultValue) && isString2(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
7225
- return Array.isArray(k2) ? k2[k2.length - 1] : k2;
7226
- };
7227
- var notReadySnapshot = {
7228
- t: notReadyT,
7229
- ready: false
7230
- };
7231
- var dummySubscribe = () => () => {
7145
+ var usePrevious = (value, ignore) => {
7146
+ const ref = (0, import_react10.useRef)();
7147
+ (0, import_react10.useEffect)(() => {
7148
+ ref.current = ignore ? ref.current : value;
7149
+ }, [value, ignore]);
7150
+ return ref.current;
7232
7151
  };
7152
+ var alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
7153
+ var useMemoizedT = (i18n, language, namespace, keyPrefix) => (0, import_react10.useCallback)(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
7233
7154
  var useTranslation = (ns, props = {}) => {
7234
7155
  const {
7235
7156
  i18n: i18nFromProps
@@ -7242,96 +7163,88 @@ var useTranslation = (ns, props = {}) => {
7242
7163
  if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
7243
7164
  if (!i18n) {
7244
7165
  warnOnce(i18n, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
7245
- }
7246
- const i18nOptions = (0, import_react10.useMemo)(() => ({
7166
+ const notReadyT = (k2, optsOrDefaultValue) => {
7167
+ if (isString2(optsOrDefaultValue)) return optsOrDefaultValue;
7168
+ if (isObject(optsOrDefaultValue) && isString2(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
7169
+ return Array.isArray(k2) ? k2[k2.length - 1] : k2;
7170
+ };
7171
+ const retNotReady = [notReadyT, {}, false];
7172
+ retNotReady.t = notReadyT;
7173
+ retNotReady.i18n = {};
7174
+ retNotReady.ready = false;
7175
+ return retNotReady;
7176
+ }
7177
+ if (i18n.options.react?.wait) warnOnce(i18n, "DEPRECATED_OPTION", "useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
7178
+ const i18nOptions = {
7247
7179
  ...getDefaults(),
7248
- ...i18n?.options?.react,
7180
+ ...i18n.options.react,
7249
7181
  ...props
7250
- }), [i18n, props]);
7182
+ };
7251
7183
  const {
7252
7184
  useSuspense,
7253
7185
  keyPrefix
7254
7186
  } = i18nOptions;
7255
- const namespaces = (0, import_react10.useMemo)(() => {
7256
- const nsOrContext = ns || defaultNSFromContext || i18n?.options?.defaultNS;
7257
- return isString2(nsOrContext) ? [nsOrContext] : nsOrContext || ["translation"];
7258
- }, [ns, defaultNSFromContext, i18n]);
7259
- i18n?.reportNamespaces?.addUsedNamespaces?.(namespaces);
7260
- const revisionRef = (0, import_react10.useRef)(0);
7261
- const subscribe = (0, import_react10.useCallback)((callback) => {
7262
- if (!i18n) return dummySubscribe;
7187
+ let namespaces = ns || defaultNSFromContext || i18n.options?.defaultNS;
7188
+ namespaces = isString2(namespaces) ? [namespaces] : namespaces || ["translation"];
7189
+ i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
7190
+ const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n) => hasLoadedNamespace2(n, i18n, i18nOptions));
7191
+ const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
7192
+ const getT = () => memoGetT;
7193
+ const getNewT = () => alwaysNewT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
7194
+ const [t2, setT] = (0, import_react10.useState)(getT);
7195
+ let joinedNS = namespaces.join();
7196
+ if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
7197
+ const previousJoinedNS = usePrevious(joinedNS);
7198
+ const isMounted = (0, import_react10.useRef)(true);
7199
+ (0, import_react10.useEffect)(() => {
7263
7200
  const {
7264
7201
  bindI18n,
7265
7202
  bindI18nStore
7266
7203
  } = i18nOptions;
7267
- const wrappedCallback = () => {
7268
- revisionRef.current += 1;
7269
- callback();
7204
+ isMounted.current = true;
7205
+ if (!ready && !useSuspense) {
7206
+ if (props.lng) {
7207
+ loadLanguages2(i18n, props.lng, namespaces, () => {
7208
+ if (isMounted.current) setT(getNewT);
7209
+ });
7210
+ } else {
7211
+ loadNamespaces2(i18n, namespaces, () => {
7212
+ if (isMounted.current) setT(getNewT);
7213
+ });
7214
+ }
7215
+ }
7216
+ if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
7217
+ setT(getNewT);
7218
+ }
7219
+ const boundReset = () => {
7220
+ if (isMounted.current) setT(getNewT);
7270
7221
  };
7271
- if (bindI18n) i18n.on(bindI18n, wrappedCallback);
7272
- if (bindI18nStore) i18n.store.on(bindI18nStore, wrappedCallback);
7222
+ if (bindI18n) i18n?.on(bindI18n, boundReset);
7223
+ if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
7273
7224
  return () => {
7274
- if (bindI18n) bindI18n.split(" ").forEach((e2) => i18n.off(e2, wrappedCallback));
7275
- if (bindI18nStore) bindI18nStore.split(" ").forEach((e2) => i18n.store.off(e2, wrappedCallback));
7276
- };
7277
- }, [i18n, i18nOptions]);
7278
- const snapshotRef = (0, import_react10.useRef)();
7279
- const getSnapshot = (0, import_react10.useCallback)(() => {
7280
- if (!i18n) {
7281
- return notReadySnapshot;
7282
- }
7283
- const calculatedReady = !!(i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n) => hasLoadedNamespace2(n, i18n, i18nOptions));
7284
- const currentLng = props.lng || i18n.language;
7285
- const currentRevision = revisionRef.current;
7286
- const lastSnapshot = snapshotRef.current;
7287
- if (lastSnapshot && lastSnapshot.ready === calculatedReady && lastSnapshot.lng === currentLng && lastSnapshot.keyPrefix === keyPrefix && lastSnapshot.revision === currentRevision) {
7288
- return lastSnapshot;
7289
- }
7290
- const calculatedT = i18n.getFixedT(currentLng, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
7291
- const newSnapshot = {
7292
- t: calculatedT,
7293
- ready: calculatedReady,
7294
- lng: currentLng,
7295
- keyPrefix,
7296
- revision: currentRevision
7225
+ isMounted.current = false;
7226
+ if (i18n && bindI18n) bindI18n?.split(" ").forEach((e2) => i18n.off(e2, boundReset));
7227
+ if (bindI18nStore && i18n) bindI18nStore.split(" ").forEach((e2) => i18n.store.off(e2, boundReset));
7297
7228
  };
7298
- snapshotRef.current = newSnapshot;
7299
- return newSnapshot;
7300
- }, [i18n, namespaces, keyPrefix, i18nOptions, props.lng]);
7301
- const [loadCount, setLoadCount] = (0, import_react10.useState)(0);
7302
- const {
7303
- t: t2,
7304
- ready
7305
- } = (0, import_shim.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
7229
+ }, [i18n, joinedNS]);
7306
7230
  (0, import_react10.useEffect)(() => {
7307
- if (i18n && !ready && !useSuspense) {
7308
- const onLoaded = () => setLoadCount((c2) => c2 + 1);
7309
- if (props.lng) {
7310
- loadLanguages2(i18n, props.lng, namespaces, onLoaded);
7311
- } else {
7312
- loadNamespaces2(i18n, namespaces, onLoaded);
7313
- }
7314
- }
7315
- }, [i18n, props.lng, namespaces, ready, useSuspense, loadCount]);
7316
- const finalI18n = i18n || {};
7317
- const ret = (0, import_react10.useMemo)(() => {
7318
- const arr = [t2, finalI18n, ready];
7319
- arr.t = t2;
7320
- arr.i18n = finalI18n;
7321
- arr.ready = ready;
7322
- return arr;
7323
- }, [t2, finalI18n, ready]);
7324
- if (i18n && useSuspense && !ready) {
7325
- throw new Promise((resolve) => {
7326
- const onLoaded = () => resolve();
7327
- if (props.lng) {
7328
- loadLanguages2(i18n, props.lng, namespaces, onLoaded);
7329
- } else {
7330
- loadNamespaces2(i18n, namespaces, onLoaded);
7331
- }
7332
- });
7333
- }
7334
- return ret;
7231
+ if (isMounted.current && ready) {
7232
+ setT(getT);
7233
+ }
7234
+ }, [i18n, keyPrefix, ready]);
7235
+ const ret = [t2, i18n, ready];
7236
+ ret.t = t2;
7237
+ ret.i18n = i18n;
7238
+ ret.ready = ready;
7239
+ if (ready) return ret;
7240
+ if (!ready && !useSuspense) return ret;
7241
+ throw new Promise((resolve) => {
7242
+ if (props.lng) {
7243
+ loadLanguages2(i18n, props.lng, namespaces, () => resolve());
7244
+ } else {
7245
+ loadNamespaces2(i18n, namespaces, () => resolve());
7246
+ }
7247
+ });
7335
7248
  };
7336
7249
 
7337
7250
  // node_modules/react-i18next/dist/es/withTranslation.js
@@ -11325,7 +11238,7 @@ var reducer = (state, action) => {
11325
11238
  // src/context/EmbedProvider.tsx
11326
11239
  var import_jsx_runtime2 = require("react/jsx-runtime");
11327
11240
  var getCustomHeaders = (sessionId) => ({
11328
- "X-Schematic-Components-Version": "2.0.1",
11241
+ "X-Schematic-Components-Version": "2.0.2",
11329
11242
  "X-Schematic-Session-ID": sessionId
11330
11243
  });
11331
11244
  var EmbedProvider = ({
@@ -25227,17 +25140,6 @@ var SchematicEmbed = ({ id, accessToken }) => {
25227
25140
  };
25228
25141
  /*! Bundled license information:
25229
25142
 
25230
- use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
25231
- (**
25232
- * @license React
25233
- * use-sync-external-store-shim.development.js
25234
- *
25235
- * Copyright (c) Meta Platforms, Inc. and affiliates.
25236
- *
25237
- * This source code is licensed under the MIT license found in the
25238
- * LICENSE file in the root directory of this source tree.
25239
- *)
25240
-
25241
25143
  pako/dist/pako.esm.mjs:
25242
25144
  (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
25243
25145
  */