@revenuecat/purchases-ui-js 4.14.2 → 4.16.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.
- package/dist/components/button/ButtonNode.svelte +6 -0
- package/dist/components/package/Package.svelte +82 -10
- package/dist/components/paywall/Paywall.stories.svelte +335 -1
- package/dist/components/paywall/Paywall.svelte +95 -4
- package/dist/components/paywall/Paywall.svelte.d.ts +1 -0
- package/dist/components/paywall/Sheet.svelte +31 -1
- package/dist/components/paywall/fixtures/stack-scroll-paywall.d.ts +40 -0
- package/dist/components/paywall/fixtures/stack-scroll-paywall.js +280 -0
- package/dist/components/paywall/fixtures/window-rule-packages-paywall.d.ts +14 -0
- package/dist/components/paywall/fixtures/window-rule-packages-paywall.js +89 -0
- package/dist/components/paywall/fixtures/window-size-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/window-size-paywall.js +48 -0
- package/dist/components/stack/Stack.svelte +87 -9
- package/dist/components/stack/Stack.svelte.d.ts +2 -0
- package/dist/components/stack/stack-scroll.d.ts +59 -0
- package/dist/components/stack/stack-scroll.js +162 -0
- package/dist/components/tabs/Tabs.svelte +11 -0
- package/dist/components/workflows/Screen.svelte +3 -0
- package/dist/components/workflows/Screen.svelte.d.ts +1 -0
- package/dist/components/workflows/Workflow.svelte +3 -0
- package/dist/components/workflows/Workflow.svelte.d.ts +1 -0
- package/dist/stores/condition-context.svelte.js +3 -0
- package/dist/stores/default-selection.d.ts +17 -0
- package/dist/stores/default-selection.js +21 -0
- package/dist/stores/rendered-packages.d.ts +10 -0
- package/dist/stores/rendered-packages.js +17 -0
- package/dist/stores/window-size.d.ts +10 -0
- package/dist/stores/window-size.js +10 -0
- package/dist/types/components/button.d.ts +1 -1
- package/dist/types/components/package.d.ts +1 -0
- package/dist/types/components/stack.d.ts +6 -0
- package/dist/types/overrides.d.ts +15 -1
- package/dist/types/overrides.js +3 -0
- package/dist/types/paywall-component-interaction.d.ts +1 -1
- package/dist/utils/package-selection.d.ts +26 -0
- package/dist/utils/package-selection.js +47 -0
- package/dist/utils/style-utils.d.ts +12 -0
- package/dist/utils/style-utils.js +59 -0
- package/package.json +2 -2
|
@@ -119,6 +119,26 @@ export function collectPackageIdsInDisplayOrder({ stack, sticky_footer, }) {
|
|
|
119
119
|
]),
|
|
120
120
|
];
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Each package component's place in display order (root stack, then sticky
|
|
124
|
+
* footer) and whether it sits inside tabs, by component id.
|
|
125
|
+
*/
|
|
126
|
+
export function collectPackagePlacements({ stack, sticky_footer, }) {
|
|
127
|
+
const placements = new Map();
|
|
128
|
+
const walk = (node, inTabs) => {
|
|
129
|
+
if (node.type === "package" && !placements.has(node.id)) {
|
|
130
|
+
placements.set(node.id, { index: placements.size, inTabs });
|
|
131
|
+
}
|
|
132
|
+
for (const child of getPaywallComponentChildNodes(node)) {
|
|
133
|
+
walk(child, inTabs || node.type === "tabs");
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
walk(stack, false);
|
|
137
|
+
if (sticky_footer != null) {
|
|
138
|
+
walk(sticky_footer, false);
|
|
139
|
+
}
|
|
140
|
+
return placements;
|
|
141
|
+
}
|
|
122
142
|
/**
|
|
123
143
|
* Returns the overrides (in array order) whose conditions all match (AND) the
|
|
124
144
|
* given context, without merging their properties.
|
|
@@ -206,6 +226,11 @@ const conditionMatches = (condition, context) => {
|
|
|
206
226
|
if (condition.operator === "!=")
|
|
207
227
|
return currentValue !== conditionValue;
|
|
208
228
|
}
|
|
229
|
+
if (condition.type === RuleKey.WindowWidthCondition ||
|
|
230
|
+
condition.type === RuleKey.WindowHeightCondition ||
|
|
231
|
+
condition.type === RuleKey.WindowAspectRatioCondition) {
|
|
232
|
+
return windowSizeMatches(condition, context.windowSize);
|
|
233
|
+
}
|
|
209
234
|
if (condition.type === RuleKey.StateCondition) {
|
|
210
235
|
const stateValues = context.stateValues ?? {};
|
|
211
236
|
const stateDefaults = context.stateDefaults ?? {};
|
|
@@ -233,6 +258,40 @@ const conditionMatches = (condition, context) => {
|
|
|
233
258
|
}
|
|
234
259
|
return false;
|
|
235
260
|
};
|
|
261
|
+
// `=` compares an authored value against a fractional measurement, so it
|
|
262
|
+
// allows the same tolerances as Android.
|
|
263
|
+
const DIMENSION_EQUALITY_TOLERANCE_PX = 0.5;
|
|
264
|
+
const ASPECT_RATIO_EQUALITY_TOLERANCE = 1e-3;
|
|
265
|
+
function windowSizeMatches(condition, windowSize) {
|
|
266
|
+
if (!windowSize)
|
|
267
|
+
return false;
|
|
268
|
+
const { width, height } = windowSize;
|
|
269
|
+
if (condition.type === RuleKey.WindowWidthCondition) {
|
|
270
|
+
return compareNumbers(width, condition.operator, condition.value, DIMENSION_EQUALITY_TOLERANCE_PX);
|
|
271
|
+
}
|
|
272
|
+
if (condition.type === RuleKey.WindowHeightCondition) {
|
|
273
|
+
return compareNumbers(height, condition.operator, condition.value, DIMENSION_EQUALITY_TOLERANCE_PX);
|
|
274
|
+
}
|
|
275
|
+
if (height === 0)
|
|
276
|
+
return false;
|
|
277
|
+
return compareNumbers(width / height, condition.operator, condition.value, ASPECT_RATIO_EQUALITY_TOLERANCE);
|
|
278
|
+
}
|
|
279
|
+
function compareNumbers(actual, operator, expected, tolerance) {
|
|
280
|
+
switch (operator) {
|
|
281
|
+
case ">=":
|
|
282
|
+
return actual >= expected;
|
|
283
|
+
case ">":
|
|
284
|
+
return actual > expected;
|
|
285
|
+
case "<=":
|
|
286
|
+
return actual <= expected;
|
|
287
|
+
case "<":
|
|
288
|
+
return actual < expected;
|
|
289
|
+
case "=":
|
|
290
|
+
return Math.abs(actual - expected) < tolerance;
|
|
291
|
+
default:
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
236
295
|
function stateValuesEqual(actual, expected) {
|
|
237
296
|
if (typeof actual === "string" && typeof expected === "string") {
|
|
238
297
|
return actual === expected;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@revenuecat/purchases-ui-js",
|
|
3
3
|
"description": "Web components for Paywalls. Powered by RevenueCat",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.16.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "RevenueCat, Inc."
|
|
8
8
|
},
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@types/qrcode": "^1.5.6",
|
|
100
100
|
"@types/react": "^19.2.14",
|
|
101
101
|
"@typescript-eslint/parser": "8.57.2",
|
|
102
|
-
"chromatic": "
|
|
102
|
+
"chromatic": "18.12.2",
|
|
103
103
|
"eslint": "9.38.0",
|
|
104
104
|
"eslint-plugin-storybook": "9.1.17",
|
|
105
105
|
"eslint-plugin-svelte": "3.16.0",
|