@schematichq/schematic-components 1.0.5 → 1.0.6

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.
@@ -9647,9 +9647,13 @@ var I18n = class _I18n extends EventEmitter {
9647
9647
  prepend: this.options.pluralSeparator,
9648
9648
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
9649
9649
  });
9650
+ const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
9651
+ if (usingLegacyFormatFunction) {
9652
+ this.logger.warn(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
9653
+ }
9650
9654
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9651
9655
  s2.formatter = createClassOnDemand(formatter);
9652
- s2.formatter.init(s2, this.options);
9656
+ if (s2.formatter.init) s2.formatter.init(s2, this.options);
9653
9657
  this.options.interpolation.format = s2.formatter.format.bind(s2.formatter);
9654
9658
  }
9655
9659
  s2.interpolator = new Interpolator(this.options);
@@ -13737,7 +13741,7 @@ var EmbedProvider = ({
13737
13741
  });
13738
13742
  const customHeaders = (0, import_react12.useMemo)(
13739
13743
  () => ({
13740
- "X-Schematic-Components-Version": "1.0.5",
13744
+ "X-Schematic-Components-Version": "1.0.6",
13741
13745
  "X-Schematic-Session-ID": sessionIdRef.current
13742
13746
  }),
13743
13747
  []
@@ -17208,14 +17212,6 @@ var CheckoutDialog = ({ top = 0 }) => {
17208
17212
  )
17209
17213
  );
17210
17214
  const [willTrial, setWillTrial] = (0, import_react29.useState)(false);
17211
- const selectedPlanCompatibility = (0, import_react29.useMemo)(() => {
17212
- if (!data?.addOnCompatibilities || !selectedPlan?.id) {
17213
- return null;
17214
- }
17215
- return data.addOnCompatibilities.find(
17216
- (compat) => compat.sourcePlanId === selectedPlan.id
17217
- );
17218
- }, [data?.addOnCompatibilities, selectedPlan?.id]);
17219
17215
  const [addOns, setAddOns] = (0, import_react29.useState)(() => {
17220
17216
  if (isCheckoutData(data)) {
17221
17217
  return availableAddOns.map((addOn) => ({
@@ -17230,13 +17226,15 @@ var CheckoutDialog = ({ top = 0 }) => {
17230
17226
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
17231
17227
  (0, import_react29.useEffect)(() => {
17232
17228
  setAddOns((prevAddOns) => {
17233
- return prevAddOns.filter((availAddOn) => {
17234
- if (!selectedPlanCompatibility || !selectedPlanCompatibility.compatiblePlanIds?.length) {
17229
+ return availableAddOns.filter((availAddOn) => {
17230
+ const ourCompats = data?.addOnCompatibilities.find(
17231
+ (compat) => compat.sourcePlanId === availAddOn.id
17232
+ );
17233
+ if (!ourCompats || !ourCompats.compatiblePlanIds?.length) {
17235
17234
  return true;
17236
17235
  }
17237
- return selectedPlanCompatibility?.compatiblePlanIds.includes(
17238
- availAddOn.id
17239
- );
17236
+ if (!selectedPlan) return true;
17237
+ return ourCompats?.compatiblePlanIds.includes(selectedPlan?.id);
17240
17238
  }).map((addOn) => {
17241
17239
  const prevAddOn = prevAddOns.find((prev2) => prev2.id === addOn.id);
17242
17240
  return {
@@ -17245,7 +17243,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17245
17243
  };
17246
17244
  });
17247
17245
  });
17248
- }, [selectedPlanCompatibility, selectedPlan?.id]);
17246
+ }, [availableAddOns, data?.addOnCompatibilities, selectedPlan]);
17249
17247
  const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react29.useState)(
17250
17248
  () => (selectedPlan?.entitlements || []).reduce(
17251
17249
  createActiveUsageBasedEntitlementsReducer(
@@ -9583,9 +9583,13 @@ var I18n = class _I18n extends EventEmitter {
9583
9583
  prepend: this.options.pluralSeparator,
9584
9584
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
9585
9585
  });
9586
+ const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
9587
+ if (usingLegacyFormatFunction) {
9588
+ this.logger.warn(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
9589
+ }
9586
9590
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9587
9591
  s2.formatter = createClassOnDemand(formatter);
9588
- s2.formatter.init(s2, this.options);
9592
+ if (s2.formatter.init) s2.formatter.init(s2, this.options);
9589
9593
  this.options.interpolation.format = s2.formatter.format.bind(s2.formatter);
9590
9594
  }
9591
9595
  s2.interpolator = new Interpolator(this.options);
@@ -13680,7 +13684,7 @@ var EmbedProvider = ({
13680
13684
  });
13681
13685
  const customHeaders = useMemo3(
13682
13686
  () => ({
13683
- "X-Schematic-Components-Version": "1.0.5",
13687
+ "X-Schematic-Components-Version": "1.0.6",
13684
13688
  "X-Schematic-Session-ID": sessionIdRef.current
13685
13689
  }),
13686
13690
  []
@@ -17161,14 +17165,6 @@ var CheckoutDialog = ({ top = 0 }) => {
17161
17165
  )
17162
17166
  );
17163
17167
  const [willTrial, setWillTrial] = useState9(false);
17164
- const selectedPlanCompatibility = useMemo8(() => {
17165
- if (!data?.addOnCompatibilities || !selectedPlan?.id) {
17166
- return null;
17167
- }
17168
- return data.addOnCompatibilities.find(
17169
- (compat) => compat.sourcePlanId === selectedPlan.id
17170
- );
17171
- }, [data?.addOnCompatibilities, selectedPlan?.id]);
17172
17168
  const [addOns, setAddOns] = useState9(() => {
17173
17169
  if (isCheckoutData(data)) {
17174
17170
  return availableAddOns.map((addOn) => ({
@@ -17183,13 +17179,15 @@ var CheckoutDialog = ({ top = 0 }) => {
17183
17179
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
17184
17180
  useEffect5(() => {
17185
17181
  setAddOns((prevAddOns) => {
17186
- return prevAddOns.filter((availAddOn) => {
17187
- if (!selectedPlanCompatibility || !selectedPlanCompatibility.compatiblePlanIds?.length) {
17182
+ return availableAddOns.filter((availAddOn) => {
17183
+ const ourCompats = data?.addOnCompatibilities.find(
17184
+ (compat) => compat.sourcePlanId === availAddOn.id
17185
+ );
17186
+ if (!ourCompats || !ourCompats.compatiblePlanIds?.length) {
17188
17187
  return true;
17189
17188
  }
17190
- return selectedPlanCompatibility?.compatiblePlanIds.includes(
17191
- availAddOn.id
17192
- );
17189
+ if (!selectedPlan) return true;
17190
+ return ourCompats?.compatiblePlanIds.includes(selectedPlan?.id);
17193
17191
  }).map((addOn) => {
17194
17192
  const prevAddOn = prevAddOns.find((prev2) => prev2.id === addOn.id);
17195
17193
  return {
@@ -17198,7 +17196,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17198
17196
  };
17199
17197
  });
17200
17198
  });
17201
- }, [selectedPlanCompatibility, selectedPlan?.id]);
17199
+ }, [availableAddOns, data?.addOnCompatibilities, selectedPlan]);
17202
17200
  const [usageBasedEntitlements, setUsageBasedEntitlements] = useState9(
17203
17201
  () => (selectedPlan?.entitlements || []).reduce(
17204
17202
  createActiveUsageBasedEntitlementsReducer(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",