@revenuecat/purchases-ui-js 4.8.24 → 4.9.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.
@@ -104,16 +104,39 @@
104
104
  }
105
105
  }
106
106
 
107
- function readValidity(input: HTMLInputElement): boolean {
108
- if (compiledPattern?.mode === "custom") {
107
+ // Constraints the component checks itself, in the order they are reported.
108
+ // The value of the custom validity message is the failing rule, so
109
+ // `failingRuleFromValidity` can map `customError` back to it.
110
+ function customFailingRule(
111
+ input: HTMLInputElement,
112
+ ): InputTextValidationRule | null {
113
+ // `maxlength` is deliberately not rendered: the browser would truncate
114
+ // typing at the limit with no feedback, which reads as a broken input.
115
+ // Checking here lets the value exceed the limit and show the error copy.
116
+ if (
117
+ type !== "number" &&
118
+ validation?.maxLength != null &&
119
+ input.value.length > validation.maxLength
120
+ ) {
121
+ return "maxLength";
122
+ }
123
+ if (
124
+ compiledPattern?.mode === "custom" &&
109
125
  // Mirrors the native `pattern` semantics: empty values are left to
110
126
  // `required`, everything else must match the whole value.
111
- const mismatch =
112
- input.value !== "" && !compiledPattern.regex.test(input.value);
113
- input.setCustomValidity(mismatch ? "pattern" : "");
127
+ input.value !== "" &&
128
+ !compiledPattern.regex.test(input.value)
129
+ ) {
130
+ return "pattern";
114
131
  }
132
+ return null;
133
+ }
134
+
135
+ function readValidity(input: HTMLInputElement): boolean {
136
+ const customRule = customFailingRule(input);
137
+ input.setCustomValidity(customRule ?? "");
115
138
  const { validity } = input;
116
- failedRule = failingRuleFromValidity(validity);
139
+ failedRule = failingRuleFromValidity(validity, customRule);
117
140
  return validity.valid;
118
141
  }
119
142
 
@@ -332,12 +355,13 @@
332
355
  // ignore length/pattern on `type="number"` and min/max on text-like types.
333
356
  // `step="any"` lifts the implicit `step=1` for the `decimal` keyboard, which
334
357
  // would otherwise flag decimals as `stepMismatch`; `numeric` keeps it so the
335
- // integer keypad and non-integer values agree. Patterns the browser would
336
- // reject are enforced in `readValidity` instead of being rendered.
358
+ // integer keypad and non-integer values agree. `maxLength` and patterns the
359
+ // browser would reject are enforced in `readValidity` instead of being
360
+ // rendered (see `customFailingRule`).
337
361
  const constraintAttributes = $derived.by(
338
362
  (): Pick<
339
363
  HTMLInputAttributes,
340
- "min" | "max" | "step" | "minlength" | "maxlength" | "pattern"
364
+ "min" | "max" | "step" | "minlength" | "pattern"
341
365
  > =>
342
366
  type === "number"
343
367
  ? {
@@ -347,7 +371,6 @@
347
371
  }
348
372
  : {
349
373
  minlength: validation?.minLength ?? undefined,
350
- maxlength: validation?.maxLength ?? undefined,
351
374
  pattern:
352
375
  compiledPattern?.mode === "native"
353
376
  ? (validation?.pattern ?? undefined)
@@ -9,7 +9,8 @@ import type { InputTextValidationRule } from "../../types/components/input-text"
9
9
  * `stepMismatch` (a non-integer on the `numeric` keyboard) falls back to
10
10
  * `format` as well.
11
11
  *
12
- * `customError` is only ever set by the component for a `pattern` the browser
13
- * cannot compile itself, so it is reported as `pattern`.
12
+ * `customError` is only ever set by the component itself, for the constraints
13
+ * it checks instead of the browser (`maxLength`, and a `pattern` the browser
14
+ * cannot compile); `customRule` says which one failed.
14
15
  */
15
- export declare function failingRuleFromValidity(validity: ValidityState): InputTextValidationRule | null;
16
+ export declare function failingRuleFromValidity(validity: ValidityState, customRule?: InputTextValidationRule | null): InputTextValidationRule | null;
@@ -8,10 +8,11 @@
8
8
  * `stepMismatch` (a non-integer on the `numeric` keyboard) falls back to
9
9
  * `format` as well.
10
10
  *
11
- * `customError` is only ever set by the component for a `pattern` the browser
12
- * cannot compile itself, so it is reported as `pattern`.
11
+ * `customError` is only ever set by the component itself, for the constraints
12
+ * it checks instead of the browser (`maxLength`, and a `pattern` the browser
13
+ * cannot compile); `customRule` says which one failed.
13
14
  */
14
- export function failingRuleFromValidity(validity) {
15
+ export function failingRuleFromValidity(validity, customRule = null) {
15
16
  if (validity.valid) {
16
17
  return null;
17
18
  }
@@ -30,7 +31,10 @@ export function failingRuleFromValidity(validity) {
30
31
  if (validity.tooLong) {
31
32
  return "maxLength";
32
33
  }
33
- if (validity.patternMismatch || validity.customError) {
34
+ if (validity.customError && customRule) {
35
+ return customRule;
36
+ }
37
+ if (validity.patternMismatch) {
34
38
  return "pattern";
35
39
  }
36
40
  if (validity.typeMismatch || validity.badInput || validity.stepMismatch) {
@@ -496,6 +496,10 @@
496
496
  display: flex;
497
497
  flex-direction: column;
498
498
  align-items: stretch;
499
+ box-sizing: border-box;
500
+ width: 100%;
501
+ max-width: 100%;
502
+ min-width: 0;
499
503
  height: 100%;
500
504
 
501
505
  transition-property: filter, transform;
@@ -22,6 +22,11 @@ export declare const VARIABLES: Readonly<{
22
22
  readonly "product.offer_price_per_week": "$0.50";
23
23
  readonly "product.offer_price_per_month": "$1.99";
24
24
  readonly "product.offer_price_per_year": "$23.88";
25
+ readonly "product.offer_price_with_zero": "$1.99";
26
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
27
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
28
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
29
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
25
30
  readonly "product.offer_period": "week";
26
31
  readonly "product.offer_period_abbreviated": "wk";
27
32
  readonly "product.offer_period_in_days": "7";
@@ -59,6 +64,11 @@ export declare const VARIABLES: Readonly<{
59
64
  readonly "product.offer_price_per_week": "$0.50";
60
65
  readonly "product.offer_price_per_month": "$1.99";
61
66
  readonly "product.offer_price_per_year": "$23.88";
67
+ readonly "product.offer_price_with_zero": "$1.99";
68
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
69
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
70
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
71
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
62
72
  readonly "product.offer_period": "week";
63
73
  readonly "product.offer_period_abbreviated": "wk";
64
74
  readonly "product.offer_period_in_days": "7";
@@ -96,6 +106,11 @@ export declare const VARIABLES: Readonly<{
96
106
  readonly "product.offer_price_per_week": "$0.50";
97
107
  readonly "product.offer_price_per_month": "$1.99";
98
108
  readonly "product.offer_price_per_year": "$23.88";
109
+ readonly "product.offer_price_with_zero": "$1.99";
110
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
111
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
112
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
113
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
99
114
  readonly "product.offer_period": "week";
100
115
  readonly "product.offer_period_abbreviated": "wk";
101
116
  readonly "product.offer_period_in_days": "7";
@@ -133,6 +148,11 @@ export declare const VARIABLES: Readonly<{
133
148
  readonly "product.offer_price_per_week": "$0.50";
134
149
  readonly "product.offer_price_per_month": "$1.99";
135
150
  readonly "product.offer_price_per_year": "$23.88";
151
+ readonly "product.offer_price_with_zero": "$1.99";
152
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
153
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
154
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
155
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
136
156
  readonly "product.offer_period": "week";
137
157
  readonly "product.offer_period_abbreviated": "wk";
138
158
  readonly "product.offer_period_in_days": "7";
@@ -170,6 +190,11 @@ export declare const VARIABLES: Readonly<{
170
190
  readonly "product.offer_price_per_week": "$0.50";
171
191
  readonly "product.offer_price_per_month": "$1.99";
172
192
  readonly "product.offer_price_per_year": "$23.88";
193
+ readonly "product.offer_price_with_zero": "$1.99";
194
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
195
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
196
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
197
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
173
198
  readonly "product.offer_period": "week";
174
199
  readonly "product.offer_period_abbreviated": "wk";
175
200
  readonly "product.offer_period_in_days": "7";
@@ -207,6 +232,11 @@ export declare const VARIABLES: Readonly<{
207
232
  readonly "product.offer_price_per_week": "$0.50";
208
233
  readonly "product.offer_price_per_month": "$1.99";
209
234
  readonly "product.offer_price_per_year": "$23.88";
235
+ readonly "product.offer_price_with_zero": "$1.99";
236
+ readonly "product.offer_price_with_zero_per_day": "$0.07";
237
+ readonly "product.offer_price_with_zero_per_week": "$0.50";
238
+ readonly "product.offer_price_with_zero_per_month": "$1.99";
239
+ readonly "product.offer_price_with_zero_per_year": "$23.88";
210
240
  readonly "product.offer_period": "week";
211
241
  readonly "product.offer_period_abbreviated": "wk";
212
242
  readonly "product.offer_period_in_days": "7";
@@ -244,6 +274,11 @@ export declare const VARIABLES: Readonly<{
244
274
  readonly "product.offer_price_per_week": "";
245
275
  readonly "product.offer_price_per_month": "";
246
276
  readonly "product.offer_price_per_year": "";
277
+ readonly "product.offer_price_with_zero": "";
278
+ readonly "product.offer_price_with_zero_per_day": "";
279
+ readonly "product.offer_price_with_zero_per_week": "";
280
+ readonly "product.offer_price_with_zero_per_month": "";
281
+ readonly "product.offer_price_with_zero_per_year": "";
247
282
  readonly "product.offer_period": "";
248
283
  readonly "product.offer_period_abbreviated": "";
249
284
  readonly "product.offer_period_in_days": "";
@@ -23,6 +23,11 @@ export const VARIABLES = Object.freeze({
23
23
  "product.offer_price_per_week": "$0.50",
24
24
  "product.offer_price_per_month": "$1.99",
25
25
  "product.offer_price_per_year": "$23.88",
26
+ "product.offer_price_with_zero": "$1.99",
27
+ "product.offer_price_with_zero_per_day": "$0.07",
28
+ "product.offer_price_with_zero_per_week": "$0.50",
29
+ "product.offer_price_with_zero_per_month": "$1.99",
30
+ "product.offer_price_with_zero_per_year": "$23.88",
26
31
  "product.offer_period": "week",
27
32
  "product.offer_period_abbreviated": "wk",
28
33
  "product.offer_period_in_days": "7",
@@ -60,6 +65,11 @@ export const VARIABLES = Object.freeze({
60
65
  "product.offer_price_per_week": "$0.50",
61
66
  "product.offer_price_per_month": "$1.99",
62
67
  "product.offer_price_per_year": "$23.88",
68
+ "product.offer_price_with_zero": "$1.99",
69
+ "product.offer_price_with_zero_per_day": "$0.07",
70
+ "product.offer_price_with_zero_per_week": "$0.50",
71
+ "product.offer_price_with_zero_per_month": "$1.99",
72
+ "product.offer_price_with_zero_per_year": "$23.88",
63
73
  "product.offer_period": "week",
64
74
  "product.offer_period_abbreviated": "wk",
65
75
  "product.offer_period_in_days": "7",
@@ -97,6 +107,11 @@ export const VARIABLES = Object.freeze({
97
107
  "product.offer_price_per_week": "$0.50",
98
108
  "product.offer_price_per_month": "$1.99",
99
109
  "product.offer_price_per_year": "$23.88",
110
+ "product.offer_price_with_zero": "$1.99",
111
+ "product.offer_price_with_zero_per_day": "$0.07",
112
+ "product.offer_price_with_zero_per_week": "$0.50",
113
+ "product.offer_price_with_zero_per_month": "$1.99",
114
+ "product.offer_price_with_zero_per_year": "$23.88",
100
115
  "product.offer_period": "week",
101
116
  "product.offer_period_abbreviated": "wk",
102
117
  "product.offer_period_in_days": "7",
@@ -134,6 +149,11 @@ export const VARIABLES = Object.freeze({
134
149
  "product.offer_price_per_week": "$0.50",
135
150
  "product.offer_price_per_month": "$1.99",
136
151
  "product.offer_price_per_year": "$23.88",
152
+ "product.offer_price_with_zero": "$1.99",
153
+ "product.offer_price_with_zero_per_day": "$0.07",
154
+ "product.offer_price_with_zero_per_week": "$0.50",
155
+ "product.offer_price_with_zero_per_month": "$1.99",
156
+ "product.offer_price_with_zero_per_year": "$23.88",
137
157
  "product.offer_period": "week",
138
158
  "product.offer_period_abbreviated": "wk",
139
159
  "product.offer_period_in_days": "7",
@@ -171,6 +191,11 @@ export const VARIABLES = Object.freeze({
171
191
  "product.offer_price_per_week": "$0.50",
172
192
  "product.offer_price_per_month": "$1.99",
173
193
  "product.offer_price_per_year": "$23.88",
194
+ "product.offer_price_with_zero": "$1.99",
195
+ "product.offer_price_with_zero_per_day": "$0.07",
196
+ "product.offer_price_with_zero_per_week": "$0.50",
197
+ "product.offer_price_with_zero_per_month": "$1.99",
198
+ "product.offer_price_with_zero_per_year": "$23.88",
174
199
  "product.offer_period": "week",
175
200
  "product.offer_period_abbreviated": "wk",
176
201
  "product.offer_period_in_days": "7",
@@ -208,6 +233,11 @@ export const VARIABLES = Object.freeze({
208
233
  "product.offer_price_per_week": "$0.50",
209
234
  "product.offer_price_per_month": "$1.99",
210
235
  "product.offer_price_per_year": "$23.88",
236
+ "product.offer_price_with_zero": "$1.99",
237
+ "product.offer_price_with_zero_per_day": "$0.07",
238
+ "product.offer_price_with_zero_per_week": "$0.50",
239
+ "product.offer_price_with_zero_per_month": "$1.99",
240
+ "product.offer_price_with_zero_per_year": "$23.88",
211
241
  "product.offer_period": "week",
212
242
  "product.offer_period_abbreviated": "wk",
213
243
  "product.offer_period_in_days": "7",
@@ -245,6 +275,11 @@ export const VARIABLES = Object.freeze({
245
275
  "product.offer_price_per_week": "",
246
276
  "product.offer_price_per_month": "",
247
277
  "product.offer_price_per_year": "",
278
+ "product.offer_price_with_zero": "",
279
+ "product.offer_price_with_zero_per_day": "",
280
+ "product.offer_price_with_zero_per_week": "",
281
+ "product.offer_price_with_zero_per_month": "",
282
+ "product.offer_price_with_zero_per_year": "",
248
283
  "product.offer_period": "",
249
284
  "product.offer_period_abbreviated": "",
250
285
  "product.offer_period_in_days": "",
@@ -101,7 +101,11 @@
101
101
  }: Props = $props();
102
102
  </script>
103
103
 
104
- <div id={containerId} class="paywall-container">
104
+ <div
105
+ id={containerId}
106
+ class="paywall-container"
107
+ style="width: 100%; min-width: 0;"
108
+ >
105
109
  {#if paywallComponents}
106
110
  <Paywall
107
111
  paywallData={paywallComponents}
@@ -84,7 +84,7 @@ type CustomVariableName = string & {};
84
84
  */
85
85
  export type InputVariableName = `input.${string}`;
86
86
  export declare function mergeCustomVariables(customVariables: CustomVariables, uiConfig: UIConfig | undefined): VariableDictionary;
87
- type BuiltinVariableName = "product.price" | "product.price_per_period" | "product.price_per_period_abbreviated" | "product.price_per_day" | "product.price_per_week" | "product.price_per_month" | "product.price_per_year" | "product.period" | "product.period_abbreviated" | "product.periodly" | "product.period_in_days" | "product.period_in_weeks" | "product.period_in_months" | "product.period_in_years" | "product.period_with_unit" | "product.currency_code" | "product.currency_symbol" | "product.offer_price" | "product.offer_price_per_day" | "product.offer_price_per_week" | "product.offer_price_per_month" | "product.offer_price_per_year" | "product.offer_period" | "product.offer_period_abbreviated" | "product.offer_period_in_days" | "product.offer_period_in_weeks" | "product.offer_period_in_months" | "product.offer_period_in_years" | "product.offer_period_with_unit" | "product.offer_end_date" | "product.secondary_offer_price" | "product.secondary_offer_period" | "product.secondary_offer_period_abbreviated" | "product.relative_discount" | "product.store_product_name" | "success.redemption_url" | "success.redemption_url_redirect" | "success.package_identifier" | "success.product_identifier" | "success.product_title" | "success.product_description" | "success.price" | "success.currency_code" | "success.customer_email" | "success.is_subscription" | "success.is_trial";
87
+ type BuiltinVariableName = "product.price" | "product.price_per_period" | "product.price_per_period_abbreviated" | "product.price_per_day" | "product.price_per_week" | "product.price_per_month" | "product.price_per_year" | "product.period" | "product.period_abbreviated" | "product.periodly" | "product.period_in_days" | "product.period_in_weeks" | "product.period_in_months" | "product.period_in_years" | "product.period_with_unit" | "product.currency_code" | "product.currency_symbol" | "product.offer_price" | "product.offer_price_per_day" | "product.offer_price_per_week" | "product.offer_price_per_month" | "product.offer_price_per_year" | "product.offer_price_with_zero" | "product.offer_price_with_zero_per_day" | "product.offer_price_with_zero_per_week" | "product.offer_price_with_zero_per_month" | "product.offer_price_with_zero_per_year" | "product.offer_period" | "product.offer_period_abbreviated" | "product.offer_period_in_days" | "product.offer_period_in_weeks" | "product.offer_period_in_months" | "product.offer_period_in_years" | "product.offer_period_with_unit" | "product.offer_end_date" | "product.secondary_offer_price" | "product.secondary_offer_period" | "product.secondary_offer_period_abbreviated" | "product.relative_discount" | "product.store_product_name" | "success.redemption_url" | "success.redemption_url_redirect" | "success.package_identifier" | "success.product_identifier" | "success.product_title" | "success.product_description" | "success.price" | "success.currency_code" | "success.customer_email" | "success.is_subscription" | "success.is_trial";
88
88
  export type VariableDictionary = Partial<Record<BuiltinVariableName | InputVariableName | CustomVariableName, string>>;
89
89
  export type VariablesDictionary = Record<PackageIdentifier, VariableDictionary>;
90
90
  export interface PackageInfo {
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.8.24",
5
+ "version": "4.9.0",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },