@klarna/react-native-klarna-network-messaging 0.0.1 → 2.7.0

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 (72) hide show
  1. package/README.md +80 -28
  2. package/android/build.gradle +97 -0
  3. package/android/src/main/AndroidManifest.xml +1 -0
  4. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingPlacementErrorEvent.kt +25 -0
  5. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingPlacementResizedEvent.kt +20 -0
  6. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingPlacementViewManager.kt +251 -0
  7. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingViewManagerHelpers.kt +52 -0
  8. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaNetworkMessagingPackage.kt +19 -0
  9. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/RNKlarnaMessagingPlacementViewSpec.kt +22 -0
  10. package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingPlacementEventsTest.kt +39 -0
  11. package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingPlacementViewManagerTest.kt +76 -0
  12. package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/messaging/KlarnaMessagingViewManagerHelpersTest.kt +200 -0
  13. package/ios/Sources/KlarnaMessagingPlacementViewFactory.swift +101 -0
  14. package/ios/Sources/KlarnaMessagingPlacementViewHelper.swift +171 -0
  15. package/ios/Sources/KlarnaMessagingPlacementViewManager.h +5 -0
  16. package/ios/Sources/KlarnaMessagingPlacementViewManager.mm +37 -0
  17. package/ios/Sources/view/KlarnaMessagingPlacementViewWrapper.h +7 -0
  18. package/ios/Sources/view/KlarnaMessagingPlacementViewWrapper.mm +183 -0
  19. package/ios/Tests/KlarnaMessagingHeightObserverTests.swift +204 -0
  20. package/ios/Tests/KlarnaMessagingPlacementViewFactoryTests.swift +167 -0
  21. package/ios/Tests/KlarnaMessagingPlacementViewHelperTests.swift +118 -0
  22. package/lib/commonjs/KlarnaMessagingPlacementView.js +102 -0
  23. package/lib/commonjs/KlarnaMessagingPlacementView.js.map +1 -0
  24. package/lib/commonjs/Specs/KlarnaMessagingPlacementViewNativeComponent.js +10 -0
  25. package/lib/commonjs/Specs/KlarnaMessagingPlacementViewNativeComponent.js.map +1 -0
  26. package/lib/commonjs/index.js +27 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/internal.js +45 -0
  29. package/lib/commonjs/internal.js.map +1 -0
  30. package/lib/commonjs/types/KlarnaMessagingError.js +2 -0
  31. package/lib/commonjs/types/KlarnaMessagingError.js.map +1 -0
  32. package/lib/commonjs/types/KlarnaMessagingPlacementConfiguration.js +6 -0
  33. package/lib/commonjs/types/KlarnaMessagingPlacementConfiguration.js.map +1 -0
  34. package/lib/commonjs/types/KlarnaMessagingPlacementType.js +15 -0
  35. package/lib/commonjs/types/KlarnaMessagingPlacementType.js.map +1 -0
  36. package/lib/module/KlarnaMessagingPlacementView.js +94 -0
  37. package/lib/module/KlarnaMessagingPlacementView.js.map +1 -0
  38. package/lib/module/Specs/KlarnaMessagingPlacementViewNativeComponent.js +3 -0
  39. package/lib/module/Specs/KlarnaMessagingPlacementViewNativeComponent.js.map +1 -0
  40. package/lib/module/index.js +4 -0
  41. package/lib/module/index.js.map +1 -0
  42. package/lib/module/internal.js +38 -0
  43. package/lib/module/internal.js.map +1 -0
  44. package/lib/module/types/KlarnaMessagingError.js +2 -0
  45. package/lib/module/types/KlarnaMessagingError.js.map +1 -0
  46. package/lib/module/types/KlarnaMessagingPlacementConfiguration.js +2 -0
  47. package/lib/module/types/KlarnaMessagingPlacementConfiguration.js.map +1 -0
  48. package/lib/module/types/KlarnaMessagingPlacementType.js +9 -0
  49. package/lib/module/types/KlarnaMessagingPlacementType.js.map +1 -0
  50. package/lib/typescript/KlarnaMessagingPlacementView.d.ts +39 -0
  51. package/lib/typescript/KlarnaMessagingPlacementView.d.ts.map +1 -0
  52. package/lib/typescript/Specs/KlarnaMessagingPlacementViewNativeComponent.d.ts +23 -0
  53. package/lib/typescript/Specs/KlarnaMessagingPlacementViewNativeComponent.d.ts.map +1 -0
  54. package/lib/typescript/index.d.ts +6 -0
  55. package/lib/typescript/index.d.ts.map +1 -0
  56. package/lib/typescript/internal.d.ts +25 -0
  57. package/lib/typescript/internal.d.ts.map +1 -0
  58. package/lib/typescript/types/KlarnaMessagingError.d.ts +8 -0
  59. package/lib/typescript/types/KlarnaMessagingError.d.ts.map +1 -0
  60. package/lib/typescript/types/KlarnaMessagingPlacementConfiguration.d.ts +25 -0
  61. package/lib/typescript/types/KlarnaMessagingPlacementConfiguration.d.ts.map +1 -0
  62. package/lib/typescript/types/KlarnaMessagingPlacementType.d.ts +8 -0
  63. package/lib/typescript/types/KlarnaMessagingPlacementType.d.ts.map +1 -0
  64. package/package.json +122 -6
  65. package/react-native-klarna-network-messaging.podspec +28 -0
  66. package/src/KlarnaMessagingPlacementView.tsx +139 -0
  67. package/src/Specs/KlarnaMessagingPlacementViewNativeComponent.ts +32 -0
  68. package/src/index.tsx +12 -0
  69. package/src/internal.ts +48 -0
  70. package/src/types/KlarnaMessagingError.ts +7 -0
  71. package/src/types/KlarnaMessagingPlacementConfiguration.ts +29 -0
  72. package/src/types/KlarnaMessagingPlacementType.ts +7 -0
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.KlarnaMessagingPlacementView = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _KlarnaMessagingPlacementViewNativeComponent = _interopRequireDefault(require("./Specs/KlarnaMessagingPlacementViewNativeComponent"));
10
+ var _internal = require("./internal");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ /** Props accepted by {@link KlarnaMessagingPlacementView}. */
14
+
15
+ /**
16
+ * Renders a Klarna messaging placement (e.g. credit-promotion banner or badge).
17
+ *
18
+ * The view automatically adjusts its height to match the content reported by the
19
+ * native SDK. Shows a minimum-height fallback while waiting for the first resize
20
+ * event, then collapses to zero when the native side reports height 0 (no content).
21
+ */
22
+ class KlarnaMessagingPlacementView extends _react.Component {
23
+ hasError = false;
24
+ constructor(props) {
25
+ super(props);
26
+ this.state = {
27
+ nativeViewHeight: 0,
28
+ hasReceivedResize: false
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Resets the error latch when any configuration prop changes so the view
34
+ * can accept new height reports from the native side after a recovery.
35
+ */
36
+ componentDidUpdate(prevProps) {
37
+ const prev = prevProps.configuration;
38
+ const next = this.props.configuration;
39
+ if (prevProps.instance !== this.props.instance || prev.type !== next.type || prev.theme !== next.theme || prev.amount !== next.amount || prev.currency !== next.currency) {
40
+ this.hasError = false;
41
+ if (this.state.hasReceivedResize) {
42
+ this.setState({
43
+ hasReceivedResize: false
44
+ });
45
+ }
46
+ }
47
+ }
48
+ render() {
49
+ const {
50
+ configuration
51
+ } = this.props;
52
+ return /*#__PURE__*/_react.default.createElement(_KlarnaMessagingPlacementViewNativeComponent.default, {
53
+ style: [styles.container, this.props.style, this.state.nativeViewHeight > 0 ? {
54
+ height: this.state.nativeViewHeight
55
+ } : this.state.hasReceivedResize ? styles.collapsed : styles.minHeightFallback],
56
+ instanceId: this.props.instance.instanceId,
57
+ placementType: configuration.type,
58
+ theme: configuration.theme ?? '',
59
+ amount: String(configuration.amount),
60
+ currency: configuration.currency,
61
+ onError: event => {
62
+ var _this$props$onError, _this$props;
63
+ const error = (0, _internal.errorFromNativeEvent)(event.nativeEvent);
64
+ this.hasError = true;
65
+ this.setState({
66
+ nativeViewHeight: 0,
67
+ hasReceivedResize: true
68
+ });
69
+ (_this$props$onError = (_this$props = this.props).onError) === null || _this$props$onError === void 0 || _this$props$onError.call(_this$props, error);
70
+ },
71
+ onResized: event => {
72
+ const next = (0, _internal.nextHeightOnResize)({
73
+ rawHeight: event.nativeEvent.height,
74
+ prevHeight: this.state.nativeViewHeight,
75
+ hasError: this.hasError,
76
+ isFirstResize: !this.state.hasReceivedResize
77
+ });
78
+ if (next !== null) {
79
+ this.setState({
80
+ nativeViewHeight: next,
81
+ hasReceivedResize: true
82
+ });
83
+ }
84
+ }
85
+ });
86
+ }
87
+ }
88
+ exports.KlarnaMessagingPlacementView = KlarnaMessagingPlacementView;
89
+ const styles = _reactNative.StyleSheet.create({
90
+ container: {
91
+ width: '100%',
92
+ overflow: 'hidden'
93
+ },
94
+ minHeightFallback: {
95
+ minHeight: 60
96
+ },
97
+ collapsed: {
98
+ height: 0,
99
+ minHeight: 0
100
+ }
101
+ });
102
+ //# sourceMappingURL=KlarnaMessagingPlacementView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_KlarnaMessagingPlacementViewNativeComponent","_interopRequireDefault","_internal","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","KlarnaMessagingPlacementView","Component","hasError","constructor","props","state","nativeViewHeight","hasReceivedResize","componentDidUpdate","prevProps","prev","configuration","next","instance","type","theme","amount","currency","setState","render","createElement","style","styles","container","height","collapsed","minHeightFallback","instanceId","placementType","String","onError","event","_this$props$onError","_this$props","error","errorFromNativeEvent","nativeEvent","onResized","nextHeightOnResize","rawHeight","prevHeight","isFirstResize","exports","StyleSheet","create","width","overflow","minHeight"],"sourceRoot":"../../src","sources":["KlarnaMessagingPlacementView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,4CAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAsE,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAA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AACA,QAAQ;UACvBuC,aAAa,EAAE,CAAC,IAAI,CAACpC,KAAK,CAACE;QAC7B,CAAC,CAAC;QACF,IAAIK,IAAI,KAAK,IAAI,EAAE;UACjB,IAAI,CAACM,QAAQ,CAAC;YAAEZ,gBAAgB,EAAEM,IAAI;YAAEL,iBAAiB,EAAE;UAAK,CAAC,CAAC;QACpE;MACF;IAAE,CACH,CAAC;EAEN;AACF;AAACmC,OAAA,CAAA1C,4BAAA,GAAAA,4BAAA;AAED,MAAMsB,MAAM,GAAGqB,uBAAU,CAACC,MAAM,CAAC;EAC/BrB,SAAS,EAAE;IACTsB,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE;EACZ,CAAC;EACDpB,iBAAiB,EAAE;IACjBqB,SAAS,EAAE;EACb,CAAC;EACDtB,SAAS,EAAE;IACTD,MAAM,EAAE,CAAC;IACTuB,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = (0, _codegenNativeComponent.default)('RNKlarnaMessagingPlacementView');
10
+ //# sourceMappingURL=KlarnaMessagingPlacementViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../../src","sources":["Specs/KlarnaMessagingPlacementViewNativeComponent.ts"],"mappings":";;;;;;AAGA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GA0B9E,IAAAG,+BAAsB,EACnC,gCACF,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "KlarnaMessagingPlacementType", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _KlarnaMessagingPlacementType.KlarnaMessagingPlacementType;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "KlarnaMessagingPlacementView", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _KlarnaMessagingPlacementView.KlarnaMessagingPlacementView;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "KlarnaTheme", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _reactNativeKlarnaNetworkCore.KlarnaTheme;
22
+ }
23
+ });
24
+ var _KlarnaMessagingPlacementView = require("./KlarnaMessagingPlacementView");
25
+ var _KlarnaMessagingPlacementType = require("./types/KlarnaMessagingPlacementType");
26
+ var _reactNativeKlarnaNetworkCore = require("@klarna/react-native-klarna-network-core");
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_KlarnaMessagingPlacementView","require","_KlarnaMessagingPlacementType","_reactNativeKlarnaNetworkCore"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,6BAAA,GAAAC,OAAA;AAIA,IAAAC,6BAAA,GAAAD,OAAA;AAMA,IAAAE,6BAAA,GAAAF,OAAA","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorFromNativeEvent = errorFromNativeEvent;
7
+ exports.nextHeightOnResize = nextHeightOnResize;
8
+ /**
9
+ * Derives the next view height from a native `onResized` event. Returns
10
+ * `null` (skip update) when the view is in an error state, the raw value
11
+ * is empty/non-finite/negative, or the height hasn't actually changed.
12
+ *
13
+ * On the first resize, height 0 is accepted so the view can collapse when
14
+ * native reports no content. Subsequent 0→0 duplicates are still skipped.
15
+ */
16
+ function nextHeightOnResize({
17
+ rawHeight,
18
+ prevHeight,
19
+ hasError,
20
+ isFirstResize
21
+ }) {
22
+ if (hasError) {
23
+ return null;
24
+ }
25
+ if (rawHeight.trim() === '') {
26
+ return null;
27
+ }
28
+ const parsed = Number(rawHeight);
29
+ if (!Number.isFinite(parsed) || parsed < 0) {
30
+ return null;
31
+ }
32
+ if (parsed === prevHeight && !isFirstResize) {
33
+ return null;
34
+ }
35
+ return parsed;
36
+ }
37
+
38
+ /** Extracts a `KlarnaMessagingError` from the nested native event payload. */
39
+ function errorFromNativeEvent(event) {
40
+ return {
41
+ message: event.error.message,
42
+ name: event.error.name
43
+ };
44
+ }
45
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nextHeightOnResize","rawHeight","prevHeight","hasError","isFirstResize","trim","parsed","Number","isFinite","errorFromNativeEvent","event","message","error","name"],"sourceRoot":"../../src","sources":["internal.ts"],"mappings":";;;;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAAC;EACjCC,SAAS;EACTC,UAAU;EACVC,QAAQ;EACRC;AACe,CAAC,EAAiB;EACjC,IAAID,QAAQ,EAAE;IACZ,OAAO,IAAI;EACb;EACA,IAAIF,SAAS,CAACI,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAGC,MAAM,CAACN,SAAS,CAAC;EAChC,IAAI,CAACM,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,IAAIA,MAAM,GAAG,CAAC,EAAE;IAC1C,OAAO,IAAI;EACb;EACA,IAAIA,MAAM,KAAKJ,UAAU,IAAI,CAACE,aAAa,EAAE;IAC3C,OAAO,IAAI;EACb;EACA,OAAOE,MAAM;AACf;;AAEA;AACO,SAASG,oBAAoBA,CAACC,KAEpC,EAAwB;EACvB,OAAO;IACLC,OAAO,EAAED,KAAK,CAACE,KAAK,CAACD,OAAO;IAC5BE,IAAI,EAAEH,KAAK,CAACE,KAAK,CAACC;EACpB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=KlarnaMessagingError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingError.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=KlarnaMessagingPlacementConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingPlacementConfiguration.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.KlarnaMessagingPlacementType = void 0;
7
+ /** The visual layout style of a Klarna messaging placement. */
8
+ let KlarnaMessagingPlacementType = exports.KlarnaMessagingPlacementType = /*#__PURE__*/function (KlarnaMessagingPlacementType) {
9
+ /** A placement that automatically adjusts its size to fit the content. */
10
+ KlarnaMessagingPlacementType["CreditPromotionAutoSize"] = "CreditPromotionAutoSize";
11
+ /** A compact badge-style placement. */
12
+ KlarnaMessagingPlacementType["CreditPromotionBadge"] = "CreditPromotionBadge";
13
+ return KlarnaMessagingPlacementType;
14
+ }({});
15
+ //# sourceMappingURL=KlarnaMessagingPlacementType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KlarnaMessagingPlacementType","exports"],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingPlacementType.ts"],"mappings":";;;;;;AAAA;AAAA,IACYA,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,0BAA5BA,4BAA4B;EACtC;EADUA,4BAA4B;EAGtC;EAHUA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA","ignoreList":[]}
@@ -0,0 +1,94 @@
1
+ import React, { Component } from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import RNKlarnaMessagingPlacementView from './Specs/KlarnaMessagingPlacementViewNativeComponent';
4
+ import { errorFromNativeEvent, nextHeightOnResize } from './internal';
5
+
6
+ /** Props accepted by {@link KlarnaMessagingPlacementView}. */
7
+
8
+ /**
9
+ * Renders a Klarna messaging placement (e.g. credit-promotion banner or badge).
10
+ *
11
+ * The view automatically adjusts its height to match the content reported by the
12
+ * native SDK. Shows a minimum-height fallback while waiting for the first resize
13
+ * event, then collapses to zero when the native side reports height 0 (no content).
14
+ */
15
+ export class KlarnaMessagingPlacementView extends Component {
16
+ hasError = false;
17
+ constructor(props) {
18
+ super(props);
19
+ this.state = {
20
+ nativeViewHeight: 0,
21
+ hasReceivedResize: false
22
+ };
23
+ }
24
+
25
+ /**
26
+ * Resets the error latch when any configuration prop changes so the view
27
+ * can accept new height reports from the native side after a recovery.
28
+ */
29
+ componentDidUpdate(prevProps) {
30
+ const prev = prevProps.configuration;
31
+ const next = this.props.configuration;
32
+ if (prevProps.instance !== this.props.instance || prev.type !== next.type || prev.theme !== next.theme || prev.amount !== next.amount || prev.currency !== next.currency) {
33
+ this.hasError = false;
34
+ if (this.state.hasReceivedResize) {
35
+ this.setState({
36
+ hasReceivedResize: false
37
+ });
38
+ }
39
+ }
40
+ }
41
+ render() {
42
+ const {
43
+ configuration
44
+ } = this.props;
45
+ return /*#__PURE__*/React.createElement(RNKlarnaMessagingPlacementView, {
46
+ style: [styles.container, this.props.style, this.state.nativeViewHeight > 0 ? {
47
+ height: this.state.nativeViewHeight
48
+ } : this.state.hasReceivedResize ? styles.collapsed : styles.minHeightFallback],
49
+ instanceId: this.props.instance.instanceId,
50
+ placementType: configuration.type,
51
+ theme: configuration.theme ?? '',
52
+ amount: String(configuration.amount),
53
+ currency: configuration.currency,
54
+ onError: event => {
55
+ var _this$props$onError, _this$props;
56
+ const error = errorFromNativeEvent(event.nativeEvent);
57
+ this.hasError = true;
58
+ this.setState({
59
+ nativeViewHeight: 0,
60
+ hasReceivedResize: true
61
+ });
62
+ (_this$props$onError = (_this$props = this.props).onError) === null || _this$props$onError === void 0 || _this$props$onError.call(_this$props, error);
63
+ },
64
+ onResized: event => {
65
+ const next = nextHeightOnResize({
66
+ rawHeight: event.nativeEvent.height,
67
+ prevHeight: this.state.nativeViewHeight,
68
+ hasError: this.hasError,
69
+ isFirstResize: !this.state.hasReceivedResize
70
+ });
71
+ if (next !== null) {
72
+ this.setState({
73
+ nativeViewHeight: next,
74
+ hasReceivedResize: true
75
+ });
76
+ }
77
+ }
78
+ });
79
+ }
80
+ }
81
+ const styles = StyleSheet.create({
82
+ container: {
83
+ width: '100%',
84
+ overflow: 'hidden'
85
+ },
86
+ minHeightFallback: {
87
+ minHeight: 60
88
+ },
89
+ collapsed: {
90
+ height: 0,
91
+ minHeight: 0
92
+ }
93
+ });
94
+ //# sourceMappingURL=KlarnaMessagingPlacementView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Component","StyleSheet","RNKlarnaMessagingPlacementView","errorFromNativeEvent","nextHeightOnResize","KlarnaMessagingPlacementView","hasError","constructor","props","state","nativeViewHeight","hasReceivedResize","componentDidUpdate","prevProps","prev","configuration","next","instance","type","theme","amount","currency","setState","render","createElement","style","styles","container","height","collapsed","minHeightFallback","instanceId","placementType","String","onError","event","_this$props$onError","_this$props","error","nativeEvent","call","onResized","rawHeight","prevHeight","isFirstResize","create","width","overflow","minHeight"],"sourceRoot":"../../src","sources":["KlarnaMessagingPlacementView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAEEC,UAAU,QAEL,cAAc;AAIrB,OAAOC,8BAA8B,MAAM,qDAAqD;AAChG,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,YAAY;;A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F;AAEA,MAAMe,MAAM,GAAGzB,UAAU,CAAC4C,MAAM,CAAC;EAC/BlB,SAAS,EAAE;IACTmB,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE;EACZ,CAAC;EACDjB,iBAAiB,EAAE;IACjBkB,SAAS,EAAE;EACb,CAAC;EACDnB,SAAS,EAAE;IACTD,MAAM,EAAE,CAAC;IACToB,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ export default codegenNativeComponent('RNKlarnaMessagingPlacementView');
3
+ //# sourceMappingURL=KlarnaMessagingPlacementViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../../src","sources":["Specs/KlarnaMessagingPlacementViewNativeComponent.ts"],"mappings":"AAGA,OAAOA,sBAAsB,MAAM,yDAAyD;AA0B5F,eAAeA,sBAAsB,CACnC,gCACF,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export { KlarnaMessagingPlacementView } from './KlarnaMessagingPlacementView';
2
+ export { KlarnaMessagingPlacementType } from './types/KlarnaMessagingPlacementType';
3
+ export { KlarnaTheme } from '@klarna/react-native-klarna-network-core';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KlarnaMessagingPlacementView","KlarnaMessagingPlacementType","KlarnaTheme"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,4BAA4B,QAEvB,gCAAgC;AACvC,SAASC,4BAA4B,QAAQ,sCAAsC;AAMnF,SAASC,WAAW,QAAQ,0CAA0C","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Derives the next view height from a native `onResized` event. Returns
3
+ * `null` (skip update) when the view is in an error state, the raw value
4
+ * is empty/non-finite/negative, or the height hasn't actually changed.
5
+ *
6
+ * On the first resize, height 0 is accepted so the view can collapse when
7
+ * native reports no content. Subsequent 0→0 duplicates are still skipped.
8
+ */
9
+ export function nextHeightOnResize({
10
+ rawHeight,
11
+ prevHeight,
12
+ hasError,
13
+ isFirstResize
14
+ }) {
15
+ if (hasError) {
16
+ return null;
17
+ }
18
+ if (rawHeight.trim() === '') {
19
+ return null;
20
+ }
21
+ const parsed = Number(rawHeight);
22
+ if (!Number.isFinite(parsed) || parsed < 0) {
23
+ return null;
24
+ }
25
+ if (parsed === prevHeight && !isFirstResize) {
26
+ return null;
27
+ }
28
+ return parsed;
29
+ }
30
+
31
+ /** Extracts a `KlarnaMessagingError` from the nested native event payload. */
32
+ export function errorFromNativeEvent(event) {
33
+ return {
34
+ message: event.error.message,
35
+ name: event.error.name
36
+ };
37
+ }
38
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nextHeightOnResize","rawHeight","prevHeight","hasError","isFirstResize","trim","parsed","Number","isFinite","errorFromNativeEvent","event","message","error","name"],"sourceRoot":"../../src","sources":["internal.ts"],"mappings":"AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,kBAAkBA,CAAC;EACjCC,SAAS;EACTC,UAAU;EACVC,QAAQ;EACRC;AACe,CAAC,EAAiB;EACjC,IAAID,QAAQ,EAAE;IACZ,OAAO,IAAI;EACb;EACA,IAAIF,SAAS,CAACI,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAGC,MAAM,CAACN,SAAS,CAAC;EAChC,IAAI,CAACM,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,IAAIA,MAAM,GAAG,CAAC,EAAE;IAC1C,OAAO,IAAI;EACb;EACA,IAAIA,MAAM,KAAKJ,UAAU,IAAI,CAACE,aAAa,EAAE;IAC3C,OAAO,IAAI;EACb;EACA,OAAOE,MAAM;AACf;;AAEA;AACA,OAAO,SAASG,oBAAoBA,CAACC,KAEpC,EAAwB;EACvB,OAAO;IACLC,OAAO,EAAED,KAAK,CAACE,KAAK,CAACD,OAAO;IAC5BE,IAAI,EAAEH,KAAK,CAACE,KAAK,CAACC;EACpB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=KlarnaMessagingError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingError.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=KlarnaMessagingPlacementConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingPlacementConfiguration.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ /** The visual layout style of a Klarna messaging placement. */
2
+ export let KlarnaMessagingPlacementType = /*#__PURE__*/function (KlarnaMessagingPlacementType) {
3
+ /** A placement that automatically adjusts its size to fit the content. */
4
+ KlarnaMessagingPlacementType["CreditPromotionAutoSize"] = "CreditPromotionAutoSize";
5
+ /** A compact badge-style placement. */
6
+ KlarnaMessagingPlacementType["CreditPromotionBadge"] = "CreditPromotionBadge";
7
+ return KlarnaMessagingPlacementType;
8
+ }({});
9
+ //# sourceMappingURL=KlarnaMessagingPlacementType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KlarnaMessagingPlacementType"],"sourceRoot":"../../../src","sources":["types/KlarnaMessagingPlacementType.ts"],"mappings":"AAAA;AACA,WAAYA,4BAA4B,0BAA5BA,4BAA4B;EACtC;EADUA,4BAA4B;EAGtC;EAHUA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ import React, { Component } from 'react';
2
+ import { type ViewStyle } from 'react-native';
3
+ import type { KlarnaMessagingError } from './types/KlarnaMessagingError';
4
+ import type { KlarnaMessagingPlacementConfiguration } from './types/KlarnaMessagingPlacementConfiguration';
5
+ import { Klarna } from '@klarna/react-native-klarna-network-core';
6
+ /** Props accepted by {@link KlarnaMessagingPlacementView}. */
7
+ export interface KlarnaMessagingPlacementViewProps {
8
+ /** Optional custom styles applied to the placement container. */
9
+ style?: ViewStyle;
10
+ /** The Klarna SDK instance obtained from {@link Klarna.initialize}. */
11
+ readonly instance: Klarna;
12
+ /** Placement type, amount, currency and theme for the messaging view. */
13
+ readonly configuration: KlarnaMessagingPlacementConfiguration;
14
+ /** Called when the native placement encounters an error. */
15
+ readonly onError?: (error: KlarnaMessagingError) => void;
16
+ }
17
+ interface KlarnaMessagingPlacementViewState {
18
+ nativeViewHeight: number;
19
+ hasReceivedResize: boolean;
20
+ }
21
+ /**
22
+ * Renders a Klarna messaging placement (e.g. credit-promotion banner or badge).
23
+ *
24
+ * The view automatically adjusts its height to match the content reported by the
25
+ * native SDK. Shows a minimum-height fallback while waiting for the first resize
26
+ * event, then collapses to zero when the native side reports height 0 (no content).
27
+ */
28
+ export declare class KlarnaMessagingPlacementView extends Component<KlarnaMessagingPlacementViewProps, KlarnaMessagingPlacementViewState> {
29
+ private hasError;
30
+ constructor(props: KlarnaMessagingPlacementViewProps);
31
+ /**
32
+ * Resets the error latch when any configuration prop changes so the view
33
+ * can accept new height reports from the native side after a recovery.
34
+ */
35
+ componentDidUpdate(prevProps: KlarnaMessagingPlacementViewProps): void;
36
+ render(): React.JSX.Element;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=KlarnaMessagingPlacementView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KlarnaMessagingPlacementView.d.ts","sourceRoot":"","sources":["../../src/KlarnaMessagingPlacementView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AAC3G,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAIlE,8DAA8D;AAC9D,MAAM,WAAW,iCAAiC;IAChD,iEAAiE;IACjE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,qCAAqC,CAAC;IAC9D,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC1D;AAED,UAAU,iCAAiC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,SAAS,CACzD,iCAAiC,EACjC,iCAAiC,CAClC;IACC,OAAO,CAAC,QAAQ,CAAS;gBAEb,KAAK,EAAE,iCAAiC;IAQpD;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,iCAAiC;IAiB/D,MAAM;CAqDP"}
@@ -0,0 +1,23 @@
1
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
2
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
3
+ import type { HostComponent } from 'react-native';
4
+ export interface RNKlarnaMessagingPlacementViewProps extends ViewProps {
5
+ readonly instanceId: string;
6
+ readonly placementType: string;
7
+ readonly theme: string;
8
+ readonly amount: string;
9
+ readonly currency: string;
10
+ readonly onError: DirectEventHandler<Readonly<{
11
+ readonly error: Readonly<{
12
+ readonly message: string;
13
+ readonly name: string;
14
+ }>;
15
+ }>>;
16
+ readonly onResized: DirectEventHandler<Readonly<{
17
+ readonly height: string;
18
+ }>>;
19
+ }
20
+ type KlarnaMessagingPlacementViewNativeComponentType = HostComponent<RNKlarnaMessagingPlacementViewProps>;
21
+ declare const _default: KlarnaMessagingPlacementViewNativeComponentType;
22
+ export default _default;
23
+ //# sourceMappingURL=KlarnaMessagingPlacementViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KlarnaMessagingPlacementViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/Specs/KlarnaMessagingPlacementViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sDAAsD,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,mCAAoC,SAAQ,SAAS;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAClC,QAAQ,CAAC;QACP,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;YACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;YACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;SACvB,CAAC,CAAC;KACJ,CAAC,CACH,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CACpC,QAAQ,CAAC;QACP,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC,CACH,CAAC;CACH;AAED,KAAK,+CAA+C,GAClD,aAAa,CAAC,mCAAmC,CAAC,CAAC;wBAIhD,+CAA+C;AAFpD,wBAEqD"}
@@ -0,0 +1,6 @@
1
+ export { KlarnaMessagingPlacementView, type KlarnaMessagingPlacementViewProps, } from './KlarnaMessagingPlacementView';
2
+ export { KlarnaMessagingPlacementType } from './types/KlarnaMessagingPlacementType';
3
+ export type { KlarnaMessagingPlacementConfiguration, KlarnaMessagingCreditPromotionAutoSizeConfiguration, KlarnaMessagingCreditPromotionBadgeConfiguration, } from './types/KlarnaMessagingPlacementConfiguration';
4
+ export { KlarnaTheme } from '@klarna/react-native-klarna-network-core';
5
+ export type { KlarnaMessagingError } from './types/KlarnaMessagingError';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,KAAK,iCAAiC,GACvC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,YAAY,EACV,qCAAqC,EACrC,mDAAmD,EACnD,gDAAgD,GACjD,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { KlarnaMessagingError } from './types/KlarnaMessagingError';
2
+ interface NextHeightInput {
3
+ readonly rawHeight: string;
4
+ readonly prevHeight: number;
5
+ readonly hasError: boolean;
6
+ readonly isFirstResize?: boolean;
7
+ }
8
+ /**
9
+ * Derives the next view height from a native `onResized` event. Returns
10
+ * `null` (skip update) when the view is in an error state, the raw value
11
+ * is empty/non-finite/negative, or the height hasn't actually changed.
12
+ *
13
+ * On the first resize, height 0 is accepted so the view can collapse when
14
+ * native reports no content. Subsequent 0→0 duplicates are still skipped.
15
+ */
16
+ export declare function nextHeightOnResize({ rawHeight, prevHeight, hasError, isFirstResize, }: NextHeightInput): number | null;
17
+ /** Extracts a `KlarnaMessagingError` from the nested native event payload. */
18
+ export declare function errorFromNativeEvent(event: {
19
+ readonly error: {
20
+ readonly message: string;
21
+ readonly name: string;
22
+ };
23
+ }): KlarnaMessagingError;
24
+ export {};
25
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,UAAU,eAAe;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,UAAU,EACV,QAAQ,EACR,aAAa,GACd,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAejC;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACrE,GAAG,oBAAoB,CAKvB"}
@@ -0,0 +1,8 @@
1
+ /** Describes an error reported by a Klarna messaging placement. */
2
+ export interface KlarnaMessagingError {
3
+ /** A machine-readable error identifier. */
4
+ readonly name: string;
5
+ /** A human-readable description of the error. */
6
+ readonly message: string;
7
+ }
8
+ //# sourceMappingURL=KlarnaMessagingError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KlarnaMessagingError.d.ts","sourceRoot":"","sources":["../../../src/types/KlarnaMessagingError.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,25 @@
1
+ import type { KlarnaTheme } from '@klarna/react-native-klarna-network-core';
2
+ import type { KlarnaMessagingPlacementType } from './KlarnaMessagingPlacementType';
3
+ /** Base configuration shared by all messaging placement types. */
4
+ interface KlarnaMessagingPlacementConfigurationBase {
5
+ /** The visual theme for the placement. Defaults to the system theme when omitted. */
6
+ readonly theme?: KlarnaTheme;
7
+ /** The purchase amount in minor units (e.g. cents). */
8
+ readonly amount: number;
9
+ /** The ISO 4217 currency code (e.g. "USD", "SEK"). */
10
+ readonly currency: string;
11
+ }
12
+ /** Configuration for a credit-promotion placement that automatically sizes itself to fit its content. */
13
+ export interface KlarnaMessagingCreditPromotionAutoSizeConfiguration extends KlarnaMessagingPlacementConfigurationBase {
14
+ /** Discriminator identifying this as a credit-promotion auto-size placement. */
15
+ readonly type: KlarnaMessagingPlacementType.CreditPromotionAutoSize;
16
+ }
17
+ /** Configuration for a credit-promotion placement rendered as a compact badge. */
18
+ export interface KlarnaMessagingCreditPromotionBadgeConfiguration extends KlarnaMessagingPlacementConfigurationBase {
19
+ /** Discriminator identifying this as a credit-promotion badge placement. */
20
+ readonly type: KlarnaMessagingPlacementType.CreditPromotionBadge;
21
+ }
22
+ /** Union of all supported messaging placement configurations. */
23
+ export type KlarnaMessagingPlacementConfiguration = KlarnaMessagingCreditPromotionAutoSizeConfiguration | KlarnaMessagingCreditPromotionBadgeConfiguration;
24
+ export {};
25
+ //# sourceMappingURL=KlarnaMessagingPlacementConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KlarnaMessagingPlacementConfiguration.d.ts","sourceRoot":"","sources":["../../../src/types/KlarnaMessagingPlacementConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAEnF,kEAAkE;AAClE,UAAU,yCAAyC;IACjD,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,yGAAyG;AACzG,MAAM,WAAW,mDAAoD,SAAQ,yCAAyC;IACpH,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAAC,uBAAuB,CAAC;CACrE;AAED,kFAAkF;AAClF,MAAM,WAAW,gDAAiD,SAAQ,yCAAyC;IACjH,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAAC,oBAAoB,CAAC;CAClE;AAED,iEAAiE;AACjE,MAAM,MAAM,qCAAqC,GAC7C,mDAAmD,GACnD,gDAAgD,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** The visual layout style of a Klarna messaging placement. */
2
+ export declare enum KlarnaMessagingPlacementType {
3
+ /** A placement that automatically adjusts its size to fit the content. */
4
+ CreditPromotionAutoSize = "CreditPromotionAutoSize",
5
+ /** A compact badge-style placement. */
6
+ CreditPromotionBadge = "CreditPromotionBadge"
7
+ }
8
+ //# sourceMappingURL=KlarnaMessagingPlacementType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KlarnaMessagingPlacementType.d.ts","sourceRoot":"","sources":["../../../src/types/KlarnaMessagingPlacementType.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,oBAAY,4BAA4B;IACtC,0EAA0E;IAC1E,uBAAuB,4BAA4B;IACnD,uCAAuC;IACvC,oBAAoB,yBAAyB;CAC9C"}