@aranova/tracking-react 1.13.0 → 1.14.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 (34) hide show
  1. package/README.md +26 -0
  2. package/dist/{bookings-C1HMPjQl.d.ts → bookings-Bw2ImtPd.d.ts} +1 -1
  3. package/dist/{bookings-CHpplXU7.d.mts → bookings-CDGNZUaH.d.mts} +1 -1
  4. package/dist/client.d.mts +5 -4
  5. package/dist/client.d.ts +5 -4
  6. package/dist/client.js +365 -40
  7. package/dist/client.js.map +1 -1
  8. package/dist/client.mjs +363 -39
  9. package/dist/client.mjs.map +1 -1
  10. package/dist/{form-submit-CX-CxJjQ.d.mts → form-submit-C_vJXCxh.d.mts} +11 -1
  11. package/dist/{form-submit-CX-CxJjQ.d.ts → form-submit-C_vJXCxh.d.ts} +11 -1
  12. package/dist/index.d.mts +9 -180
  13. package/dist/index.d.ts +9 -180
  14. package/dist/index.js +28 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +25 -3
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/{phone-utils-D12FW8tT.d.ts → phone-utils-Cfdx474X.d.mts} +178 -3
  19. package/dist/{phone-utils-BNiSqeF7.d.mts → phone-utils-D2TGPCQW.d.ts} +178 -3
  20. package/dist/phone.d.mts +2 -2
  21. package/dist/phone.d.ts +2 -2
  22. package/dist/phone.js +2 -2
  23. package/dist/phone.js.map +1 -1
  24. package/dist/phone.mjs +2 -2
  25. package/dist/phone.mjs.map +1 -1
  26. package/dist/{sales-YUH3bQl9.d.mts → sales-D4aU73mR.d.mts} +1 -1
  27. package/dist/{sales-CNvzyF5T.d.ts → sales-DkdrGIUS.d.ts} +1 -1
  28. package/dist/sales.d.mts +3 -3
  29. package/dist/sales.d.ts +3 -3
  30. package/dist/sales.js.map +1 -1
  31. package/dist/sales.mjs.map +1 -1
  32. package/dist/{ingest-typed-Ckt4R731.d.mts → submit-DuvP5AGN.d.ts} +161 -4
  33. package/dist/{ingest-typed-sCDoPInT.d.ts → submit-rqgXl-Wg.d.mts} +161 -4
  34. package/package.json +1 -1
@@ -1,6 +1,178 @@
1
- import { J as JsonValue } from './form-submit-CX-CxJjQ.js';
1
+ import { J as JsonValue } from './form-submit-C_vJXCxh.mjs';
2
+ import * as z from 'zod/mini';
2
3
  import { CountryCode } from 'libphonenumber-js';
3
4
 
5
+ /** Bump-on-change registry version; travels on every contract-typed form_submit. */
6
+ declare const LEAD_FORM_REGISTRY_VERSION = 2;
7
+ declare const LEAD_FORM_KINDS: readonly ["booking", "quote", "contact", "consult", "callback"];
8
+ /** What a form is for; `form_id` stays the instance handle. */
9
+ type LeadFormKind = (typeof LEAD_FORM_KINDS)[number];
10
+ declare const LEAD_FORM_ROLES: readonly ["given_name", "family_name", "phone", "email", "service", "preferred_date", "preferred_time", "note", "visit", "intent", "vehicle", "drop_off", "address", "patient_type", "matter", "language", "products", "goal", "business_type", "lead_volume", "attribution"];
11
+ /** A role from the registry, or `add_on:<key>` for a yes/no extra with its own label. */
12
+ type LeadFormRole = (typeof LEAD_FORM_ROLES)[number] | `add_on:${string}`;
13
+ declare const LEAD_FORM_PRIMITIVES: readonly ["string", "text", "enum", "multi_enum", "bool", "date", "time_window", "phone", "email", "address", "number"];
14
+ type LeadFormPrimitive = (typeof LEAD_FORM_PRIMITIVES)[number];
15
+ /** The wire schema of each primitive's value. */
16
+ declare const leadFormPrimitiveSchemas: {
17
+ readonly string: z.ZodMiniString<string>;
18
+ readonly text: z.ZodMiniString<string>;
19
+ readonly enum: z.ZodMiniString<string>;
20
+ readonly multi_enum: z.ZodMiniArray<z.ZodMiniString<string>>;
21
+ readonly bool: z.ZodMiniBoolean<boolean>;
22
+ readonly date: z.ZodMiniString<string>;
23
+ readonly time_window: z.ZodMiniObject<{
24
+ start: z.ZodMiniString<string>;
25
+ end: z.ZodMiniNullable<z.ZodMiniString<string>>;
26
+ label: z.ZodMiniOptional<z.ZodMiniString<string>>;
27
+ }, z.core.$strict>;
28
+ readonly phone: z.ZodMiniString<string>;
29
+ readonly email: z.ZodMiniString<string>;
30
+ readonly address: z.ZodMiniObject<{
31
+ line1: z.ZodMiniString<string>;
32
+ line2: z.ZodMiniOptional<z.ZodMiniString<string>>;
33
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
34
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
35
+ postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
36
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
+ }, z.core.$strict>;
38
+ readonly number: z.ZodMiniNumber<number>;
39
+ };
40
+ interface LeadFormRoleOption {
41
+ key: string;
42
+ label: string;
43
+ isNonAnswer?: true;
44
+ }
45
+ interface LeadFormRoleSpec {
46
+ primitive: LeadFormPrimitive;
47
+ smsLabel: string;
48
+ contactIdentity?: true;
49
+ uninteresting?: true;
50
+ options?: readonly LeadFormRoleOption[];
51
+ }
52
+ /** Every role's primitive and text label; `add_on` is the template for `add_on:<key>`. */
53
+ declare const LEAD_FORM_ROLE_SPECS: {
54
+ readonly given_name: {
55
+ readonly primitive: "string";
56
+ readonly smsLabel: "";
57
+ readonly contactIdentity: true;
58
+ };
59
+ readonly family_name: {
60
+ readonly primitive: "string";
61
+ readonly smsLabel: "";
62
+ readonly contactIdentity: true;
63
+ };
64
+ readonly phone: {
65
+ readonly primitive: "phone";
66
+ readonly smsLabel: "";
67
+ readonly contactIdentity: true;
68
+ };
69
+ readonly email: {
70
+ readonly primitive: "email";
71
+ readonly smsLabel: "";
72
+ readonly contactIdentity: true;
73
+ };
74
+ readonly service: {
75
+ readonly primitive: "multi_enum";
76
+ readonly smsLabel: "Service";
77
+ };
78
+ readonly preferred_date: {
79
+ readonly primitive: "date";
80
+ readonly smsLabel: "Date";
81
+ };
82
+ readonly preferred_time: {
83
+ readonly primitive: "time_window";
84
+ readonly smsLabel: "Time";
85
+ };
86
+ readonly note: {
87
+ readonly primitive: "text";
88
+ readonly smsLabel: "Note";
89
+ };
90
+ readonly visit: {
91
+ readonly primitive: "enum";
92
+ readonly smsLabel: "Visit";
93
+ readonly options: readonly [{
94
+ readonly key: "in-shop";
95
+ readonly label: "In shop";
96
+ }, {
97
+ readonly key: "in-home";
98
+ readonly label: "In home";
99
+ }, {
100
+ readonly key: "remote";
101
+ readonly label: "Remote";
102
+ }, {
103
+ readonly key: "on-site";
104
+ readonly label: "On site";
105
+ }];
106
+ };
107
+ readonly intent: {
108
+ readonly primitive: "enum";
109
+ readonly smsLabel: "Wants";
110
+ readonly options: readonly [{
111
+ readonly key: "book";
112
+ readonly label: "Book";
113
+ }, {
114
+ readonly key: "quote";
115
+ readonly label: "Quote";
116
+ }];
117
+ };
118
+ readonly vehicle: {
119
+ readonly primitive: "string";
120
+ readonly smsLabel: "Vehicle";
121
+ };
122
+ readonly drop_off: {
123
+ readonly primitive: "enum";
124
+ readonly smsLabel: "Drop-off";
125
+ readonly options: readonly [{
126
+ readonly key: "wait-for-it";
127
+ readonly label: "Waiting";
128
+ }, {
129
+ readonly key: "drop-off";
130
+ readonly label: "Dropping off";
131
+ }];
132
+ };
133
+ readonly address: {
134
+ readonly primitive: "address";
135
+ readonly smsLabel: "Address";
136
+ };
137
+ readonly patient_type: {
138
+ readonly primitive: "enum";
139
+ readonly smsLabel: "Patient";
140
+ };
141
+ readonly matter: {
142
+ readonly primitive: "enum";
143
+ readonly smsLabel: "Matter";
144
+ };
145
+ readonly language: {
146
+ readonly primitive: "enum";
147
+ readonly smsLabel: "Language";
148
+ };
149
+ readonly products: {
150
+ readonly primitive: "multi_enum";
151
+ readonly smsLabel: "Products";
152
+ };
153
+ readonly goal: {
154
+ readonly primitive: "enum";
155
+ readonly smsLabel: "Goal";
156
+ };
157
+ readonly business_type: {
158
+ readonly primitive: "enum";
159
+ readonly smsLabel: "Business";
160
+ };
161
+ readonly lead_volume: {
162
+ readonly primitive: "enum";
163
+ readonly smsLabel: "Lead volume";
164
+ };
165
+ readonly add_on: {
166
+ readonly primitive: "bool";
167
+ readonly smsLabel: "";
168
+ };
169
+ readonly attribution: {
170
+ readonly primitive: "enum";
171
+ readonly smsLabel: "";
172
+ readonly uninteresting: true;
173
+ };
174
+ };
175
+
4
176
  /**
5
177
  * How a phone number is shown in the UI. The transmitted value is always E.164
6
178
  * and is deliberately NOT part of this — only the display format is configurable.
@@ -44,14 +216,17 @@ interface TrackedField {
44
216
  name: string;
45
217
  type: string;
46
218
  value: JsonValue;
219
+ /** `null` when the field has no visible label; the wire requires the key. */
47
220
  label?: string | null;
221
+ /** The ADR-0024 registry role this field answers, e.g. `phone`. */
222
+ role?: LeadFormRole;
48
223
  }
49
224
  /**
50
225
  * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its
51
226
  * own display value for UI/email; this puts `+E.164` on the wire (or `null` when
52
227
  * the input isn't a valid number).
53
228
  */
54
- declare function phoneField(name: string, raw: string, country?: CountryCode): TrackedField;
229
+ declare function phoneField(name: string, raw: string, country?: CountryCode, label?: string | null): TrackedField;
55
230
 
56
231
  /**
57
232
  * Visitor consent state as reported by `getConsentState()`.
@@ -394,4 +569,4 @@ declare function optOut(options?: SetConsentOptions): void;
394
569
  */
395
570
  declare function resetConsent(): void;
396
571
 
397
- export { type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, type GtagEnvironmentMap as G, type MetaPixelEnvironmentMap as M, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, type PhoneConfig as j, type PhoneDisplayFormat as k, type TrackedField as l, type TrackingInitConfig as m, formatPhone as n, formatPhoneAsTyped as o, getConsentChoice as p, getConsentState as q, onConsentChange as r, optIn as s, optOut as t, parsePhone as u, phoneField as v, resetConsent as w, setConsentState as x, toE164 as y };
572
+ export { leadFormPrimitiveSchemas as A, onConsentChange as B, type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, optIn as E, optOut as F, type GtagEnvironmentMap as G, parsePhone as H, phoneField as I, resetConsent as J, setConsentState as K, LEAD_FORM_KINDS as L, type MetaPixelEnvironmentMap as M, toE164 as N, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, LEAD_FORM_PRIMITIVES as j, LEAD_FORM_REGISTRY_VERSION as k, LEAD_FORM_ROLES as l, LEAD_FORM_ROLE_SPECS as m, type LeadFormKind as n, type LeadFormPrimitive as o, type LeadFormRole as p, type LeadFormRoleOption as q, type LeadFormRoleSpec as r, type PhoneConfig as s, type PhoneDisplayFormat as t, type TrackedField as u, type TrackingInitConfig as v, formatPhone as w, formatPhoneAsTyped as x, getConsentChoice as y, getConsentState as z };
@@ -1,6 +1,178 @@
1
- import { J as JsonValue } from './form-submit-CX-CxJjQ.mjs';
1
+ import { J as JsonValue } from './form-submit-C_vJXCxh.js';
2
+ import * as z from 'zod/mini';
2
3
  import { CountryCode } from 'libphonenumber-js';
3
4
 
5
+ /** Bump-on-change registry version; travels on every contract-typed form_submit. */
6
+ declare const LEAD_FORM_REGISTRY_VERSION = 2;
7
+ declare const LEAD_FORM_KINDS: readonly ["booking", "quote", "contact", "consult", "callback"];
8
+ /** What a form is for; `form_id` stays the instance handle. */
9
+ type LeadFormKind = (typeof LEAD_FORM_KINDS)[number];
10
+ declare const LEAD_FORM_ROLES: readonly ["given_name", "family_name", "phone", "email", "service", "preferred_date", "preferred_time", "note", "visit", "intent", "vehicle", "drop_off", "address", "patient_type", "matter", "language", "products", "goal", "business_type", "lead_volume", "attribution"];
11
+ /** A role from the registry, or `add_on:<key>` for a yes/no extra with its own label. */
12
+ type LeadFormRole = (typeof LEAD_FORM_ROLES)[number] | `add_on:${string}`;
13
+ declare const LEAD_FORM_PRIMITIVES: readonly ["string", "text", "enum", "multi_enum", "bool", "date", "time_window", "phone", "email", "address", "number"];
14
+ type LeadFormPrimitive = (typeof LEAD_FORM_PRIMITIVES)[number];
15
+ /** The wire schema of each primitive's value. */
16
+ declare const leadFormPrimitiveSchemas: {
17
+ readonly string: z.ZodMiniString<string>;
18
+ readonly text: z.ZodMiniString<string>;
19
+ readonly enum: z.ZodMiniString<string>;
20
+ readonly multi_enum: z.ZodMiniArray<z.ZodMiniString<string>>;
21
+ readonly bool: z.ZodMiniBoolean<boolean>;
22
+ readonly date: z.ZodMiniString<string>;
23
+ readonly time_window: z.ZodMiniObject<{
24
+ start: z.ZodMiniString<string>;
25
+ end: z.ZodMiniNullable<z.ZodMiniString<string>>;
26
+ label: z.ZodMiniOptional<z.ZodMiniString<string>>;
27
+ }, z.core.$strict>;
28
+ readonly phone: z.ZodMiniString<string>;
29
+ readonly email: z.ZodMiniString<string>;
30
+ readonly address: z.ZodMiniObject<{
31
+ line1: z.ZodMiniString<string>;
32
+ line2: z.ZodMiniOptional<z.ZodMiniString<string>>;
33
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
34
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
35
+ postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
36
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
+ }, z.core.$strict>;
38
+ readonly number: z.ZodMiniNumber<number>;
39
+ };
40
+ interface LeadFormRoleOption {
41
+ key: string;
42
+ label: string;
43
+ isNonAnswer?: true;
44
+ }
45
+ interface LeadFormRoleSpec {
46
+ primitive: LeadFormPrimitive;
47
+ smsLabel: string;
48
+ contactIdentity?: true;
49
+ uninteresting?: true;
50
+ options?: readonly LeadFormRoleOption[];
51
+ }
52
+ /** Every role's primitive and text label; `add_on` is the template for `add_on:<key>`. */
53
+ declare const LEAD_FORM_ROLE_SPECS: {
54
+ readonly given_name: {
55
+ readonly primitive: "string";
56
+ readonly smsLabel: "";
57
+ readonly contactIdentity: true;
58
+ };
59
+ readonly family_name: {
60
+ readonly primitive: "string";
61
+ readonly smsLabel: "";
62
+ readonly contactIdentity: true;
63
+ };
64
+ readonly phone: {
65
+ readonly primitive: "phone";
66
+ readonly smsLabel: "";
67
+ readonly contactIdentity: true;
68
+ };
69
+ readonly email: {
70
+ readonly primitive: "email";
71
+ readonly smsLabel: "";
72
+ readonly contactIdentity: true;
73
+ };
74
+ readonly service: {
75
+ readonly primitive: "multi_enum";
76
+ readonly smsLabel: "Service";
77
+ };
78
+ readonly preferred_date: {
79
+ readonly primitive: "date";
80
+ readonly smsLabel: "Date";
81
+ };
82
+ readonly preferred_time: {
83
+ readonly primitive: "time_window";
84
+ readonly smsLabel: "Time";
85
+ };
86
+ readonly note: {
87
+ readonly primitive: "text";
88
+ readonly smsLabel: "Note";
89
+ };
90
+ readonly visit: {
91
+ readonly primitive: "enum";
92
+ readonly smsLabel: "Visit";
93
+ readonly options: readonly [{
94
+ readonly key: "in-shop";
95
+ readonly label: "In shop";
96
+ }, {
97
+ readonly key: "in-home";
98
+ readonly label: "In home";
99
+ }, {
100
+ readonly key: "remote";
101
+ readonly label: "Remote";
102
+ }, {
103
+ readonly key: "on-site";
104
+ readonly label: "On site";
105
+ }];
106
+ };
107
+ readonly intent: {
108
+ readonly primitive: "enum";
109
+ readonly smsLabel: "Wants";
110
+ readonly options: readonly [{
111
+ readonly key: "book";
112
+ readonly label: "Book";
113
+ }, {
114
+ readonly key: "quote";
115
+ readonly label: "Quote";
116
+ }];
117
+ };
118
+ readonly vehicle: {
119
+ readonly primitive: "string";
120
+ readonly smsLabel: "Vehicle";
121
+ };
122
+ readonly drop_off: {
123
+ readonly primitive: "enum";
124
+ readonly smsLabel: "Drop-off";
125
+ readonly options: readonly [{
126
+ readonly key: "wait-for-it";
127
+ readonly label: "Waiting";
128
+ }, {
129
+ readonly key: "drop-off";
130
+ readonly label: "Dropping off";
131
+ }];
132
+ };
133
+ readonly address: {
134
+ readonly primitive: "address";
135
+ readonly smsLabel: "Address";
136
+ };
137
+ readonly patient_type: {
138
+ readonly primitive: "enum";
139
+ readonly smsLabel: "Patient";
140
+ };
141
+ readonly matter: {
142
+ readonly primitive: "enum";
143
+ readonly smsLabel: "Matter";
144
+ };
145
+ readonly language: {
146
+ readonly primitive: "enum";
147
+ readonly smsLabel: "Language";
148
+ };
149
+ readonly products: {
150
+ readonly primitive: "multi_enum";
151
+ readonly smsLabel: "Products";
152
+ };
153
+ readonly goal: {
154
+ readonly primitive: "enum";
155
+ readonly smsLabel: "Goal";
156
+ };
157
+ readonly business_type: {
158
+ readonly primitive: "enum";
159
+ readonly smsLabel: "Business";
160
+ };
161
+ readonly lead_volume: {
162
+ readonly primitive: "enum";
163
+ readonly smsLabel: "Lead volume";
164
+ };
165
+ readonly add_on: {
166
+ readonly primitive: "bool";
167
+ readonly smsLabel: "";
168
+ };
169
+ readonly attribution: {
170
+ readonly primitive: "enum";
171
+ readonly smsLabel: "";
172
+ readonly uninteresting: true;
173
+ };
174
+ };
175
+
4
176
  /**
5
177
  * How a phone number is shown in the UI. The transmitted value is always E.164
6
178
  * and is deliberately NOT part of this — only the display format is configurable.
@@ -44,14 +216,17 @@ interface TrackedField {
44
216
  name: string;
45
217
  type: string;
46
218
  value: JsonValue;
219
+ /** `null` when the field has no visible label; the wire requires the key. */
47
220
  label?: string | null;
221
+ /** The ADR-0024 registry role this field answers, e.g. `phone`. */
222
+ role?: LeadFormRole;
48
223
  }
49
224
  /**
50
225
  * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its
51
226
  * own display value for UI/email; this puts `+E.164` on the wire (or `null` when
52
227
  * the input isn't a valid number).
53
228
  */
54
- declare function phoneField(name: string, raw: string, country?: CountryCode): TrackedField;
229
+ declare function phoneField(name: string, raw: string, country?: CountryCode, label?: string | null): TrackedField;
55
230
 
56
231
  /**
57
232
  * Visitor consent state as reported by `getConsentState()`.
@@ -394,4 +569,4 @@ declare function optOut(options?: SetConsentOptions): void;
394
569
  */
395
570
  declare function resetConsent(): void;
396
571
 
397
- export { type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, type GtagEnvironmentMap as G, type MetaPixelEnvironmentMap as M, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, type PhoneConfig as j, type PhoneDisplayFormat as k, type TrackedField as l, type TrackingInitConfig as m, formatPhone as n, formatPhoneAsTyped as o, getConsentChoice as p, getConsentState as q, onConsentChange as r, optIn as s, optOut as t, parsePhone as u, phoneField as v, resetConsent as w, setConsentState as x, toE164 as y };
572
+ export { leadFormPrimitiveSchemas as A, onConsentChange as B, type ConsentChoice as C, DEFAULT_DECLINE_TTL_DAYS as D, optIn as E, optOut as F, type GtagEnvironmentMap as G, parsePhone as H, phoneField as I, resetConsent as J, setConsentState as K, LEAD_FORM_KINDS as L, type MetaPixelEnvironmentMap as M, toE164 as N, type ParsedPhone as P, type SetConsentOptions as S, type TrackingParams as T, type TrackingInstallSurface as a, type TrackingEnvironment as b, type TrackingClientContext as c, type TrackingEventCreatePayload as d, type TrackingSessionUpsertPayload as e, type ConsentChoiceState as f, type ConsentSource as g, type ConsentState as h, DEFAULT_PHONE_COUNTRY as i, LEAD_FORM_PRIMITIVES as j, LEAD_FORM_REGISTRY_VERSION as k, LEAD_FORM_ROLES as l, LEAD_FORM_ROLE_SPECS as m, type LeadFormKind as n, type LeadFormPrimitive as o, type LeadFormRole as p, type LeadFormRoleOption as q, type LeadFormRoleSpec as r, type PhoneConfig as s, type PhoneDisplayFormat as t, type TrackedField as u, type TrackingInitConfig as v, formatPhone as w, formatPhoneAsTyped as x, getConsentChoice as y, getConsentState as z };
package/dist/phone.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, j as PhoneConfig, k as PhoneDisplayFormat, l as TrackedField, n as formatPhone, o as formatPhoneAsTyped, u as parsePhone, v as phoneField, y as toE164 } from './phone-utils-BNiSqeF7.mjs';
1
+ export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, s as PhoneConfig, t as PhoneDisplayFormat, u as TrackedField, w as formatPhone, x as formatPhoneAsTyped, H as parsePhone, I as phoneField, N as toE164 } from './phone-utils-Cfdx474X.mjs';
2
2
  export { CountryCode } from 'libphonenumber-js';
3
- import './form-submit-CX-CxJjQ.mjs';
3
+ import './form-submit-C_vJXCxh.mjs';
4
4
  import 'zod/mini';
package/dist/phone.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, j as PhoneConfig, k as PhoneDisplayFormat, l as TrackedField, n as formatPhone, o as formatPhoneAsTyped, u as parsePhone, v as phoneField, y as toE164 } from './phone-utils-D12FW8tT.js';
1
+ export { i as DEFAULT_PHONE_COUNTRY, P as ParsedPhone, s as PhoneConfig, t as PhoneDisplayFormat, u as TrackedField, w as formatPhone, x as formatPhoneAsTyped, H as parsePhone, I as phoneField, N as toE164 } from './phone-utils-D2TGPCQW.js';
2
2
  export { CountryCode } from 'libphonenumber-js';
3
- import './form-submit-CX-CxJjQ.js';
3
+ import './form-submit-C_vJXCxh.js';
4
4
  import 'zod/mini';
package/dist/phone.js CHANGED
@@ -70,8 +70,8 @@ function formatPhoneAsTyped(raw, country) {
70
70
  }
71
71
 
72
72
  // ../tracking-core/src/phone-field.ts
73
- function phoneField(name, raw, country) {
74
- return { name, type: "phone", value: toE164(raw, country) };
73
+ function phoneField(name, raw, country, label = null) {
74
+ return { name, type: "phone", label, value: toE164(raw, country) };
75
75
  }
76
76
  // Annotate the CommonJS export names for ESM import in node:
77
77
  0 && (module.exports = {
package/dist/phone.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/phone-utils.ts","../../tracking-core/src/phone.ts","../../tracking-core/src/phone-field.ts"],"sourcesContent":["// `@aranova/tracking-react/phone` — the isomorphic phone utils only (NO React,\n// NO 'use client'), so server/Node code can normalize/format too. The React\n// hook + component live on the package root.\nexport {\n DEFAULT_PHONE_COUNTRY,\n formatPhone,\n formatPhoneAsTyped,\n parsePhone,\n phoneField,\n toE164,\n} from \"../../tracking-core/src/index\";\nexport type {\n CountryCode,\n ParsedPhone,\n PhoneConfig,\n PhoneDisplayFormat,\n TrackedField,\n} from \"../../tracking-core/src/index\";\n","// Framework-agnostic phone-number utilities — isomorphic (browser + Node/RSC),\n// zero React. Bundled `libphonenumber-js` (standard metadata) so clients add no\n// dependency. The transmitted value is ALWAYS E.164; display is the only knob.\n\nimport { AsYouType, parsePhoneNumberFromString, type CountryCode } from \"libphonenumber-js\";\n\nexport type { CountryCode };\n\n/**\n * How a phone number is shown in the UI. The transmitted value is always E.164\n * and is deliberately NOT part of this — only the display format is configurable.\n * A function form covers the long tail (`(parsed) => string`).\n */\nexport type PhoneDisplayFormat =\n | \"national\"\n | \"international\"\n | \"e164\"\n | ((parsed: ParsedPhone) => string);\n\nexport interface ParsedPhone {\n /** E.164 (`\"+14165550199\"`) or `null` when the input isn't a valid number. This is what gets transmitted. */\n e164: string | null;\n /** National display form (`\"(416) 555-0199\"`); empty string when unparseable. */\n national: string;\n /** International display form (`\"+1 416 555 0199\"`); empty string when unparseable. */\n international: string;\n /** ISO-3166 country resolved by libphonenumber, or `null`. */\n country: CountryCode | null;\n isValid: boolean;\n}\n\n/** Region assumed for numbers typed without a country code. */\nexport const DEFAULT_PHONE_COUNTRY: CountryCode = \"CA\";\n\n/** Parse a raw/display string into every representation at once (one parse → display + wire never drift). */\nexport function parsePhone(raw: string, country?: CountryCode): ParsedPhone {\n const region = country ?? DEFAULT_PHONE_COUNTRY;\n const parsed = parsePhoneNumberFromString(raw ?? \"\", region);\n if (!parsed) {\n return { e164: null, national: \"\", international: \"\", country: region, isValid: false };\n }\n const isValid = parsed.isValid();\n return {\n // E.164 is only surfaced for a *valid* number — a possible-but-invalid input\n // (e.g. too few digits) still parses but must not be transmitted.\n e164: isValid ? parsed.number : null,\n national: parsed.formatNational(),\n international: parsed.formatInternational(),\n country: parsed.country ?? region,\n isValid,\n };\n}\n\n/** Normalize any raw/display value to E.164, or `null` if it isn't a valid number. */\nexport function toE164(raw: string, country?: CountryCode): string | null {\n return parsePhone(raw, country).e164;\n}\n\n/** Format a value for display. Defaults to `'national'`. Never affects the wire value. */\nexport function formatPhone(\n value: string,\n format: PhoneDisplayFormat = \"national\",\n country?: CountryCode,\n): string {\n const parsed = parsePhone(value, country);\n if (typeof format === \"function\") return format(parsed);\n switch (format) {\n case \"international\":\n return parsed.international || value;\n case \"e164\":\n return parsed.e164 ?? value;\n case \"national\":\n default:\n return parsed.national || value;\n }\n}\n\n/** Live, incremental formatting for an `<input>` as the user types (`AsYouType`). */\nexport function formatPhoneAsTyped(raw: string, country?: CountryCode): string {\n return new AsYouType(country ?? DEFAULT_PHONE_COUNTRY).input(raw ?? \"\");\n}\n","// Layer 0 (init config) + Layer 3 (tracking integration) for phone fields.\n// Kept in core so both the React and Next packages share identical types, and\n// the `phoneField` helper stays isomorphic.\n\nimport type { JsonValue } from \"./events/form-submit\";\nimport { toE164, type CountryCode, type PhoneDisplayFormat } from \"./phone\";\n\n/**\n * Init-time phone config (`createTracking({ phone })`). The transmitted value is\n * ALWAYS E.164 and is deliberately not configurable here — only display is.\n */\nexport interface PhoneConfig {\n /** Region assumed for numbers typed without a country code. Default `'CA'`. */\n defaultCountry?: CountryCode;\n /** How the input DISPLAYS to the user. Default `'national'`. Does not affect the wire. */\n display?: PhoneDisplayFormat;\n}\n\n/** A single tracked form field destined for `form_submit.fields[]`. */\nexport interface TrackedField {\n name: string;\n type: string;\n value: JsonValue;\n label?: string | null;\n}\n\n/**\n * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its\n * own display value for UI/email; this puts `+E.164` on the wire (or `null` when\n * the input isn't a valid number).\n */\nexport function phoneField(name: string, raw: string, country?: CountryCode): TrackedField {\n return { name, type: \"phone\", value: toE164(raw, country) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,+BAAwE;AA4BjE,IAAM,wBAAqC;AAG3C,SAAS,WAAW,KAAa,SAAoC;AAC1E,QAAM,SAAS,WAAW;AAC1B,QAAM,aAAS,qDAA2B,OAAO,IAAI,MAAM;AAC3D,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,MAAM,MAAM,UAAU,IAAI,eAAe,IAAI,SAAS,QAAQ,SAAS,MAAM;AAAA,EACxF;AACA,QAAM,UAAU,OAAO,QAAQ;AAC/B,SAAO;AAAA;AAAA;AAAA,IAGL,MAAM,UAAU,OAAO,SAAS;AAAA,IAChC,UAAU,OAAO,eAAe;AAAA,IAChC,eAAe,OAAO,oBAAoB;AAAA,IAC1C,SAAS,OAAO,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;AAGO,SAAS,OAAO,KAAa,SAAsC;AACxE,SAAO,WAAW,KAAK,OAAO,EAAE;AAClC;AAGO,SAAS,YACd,OACA,SAA6B,YAC7B,SACQ;AACR,QAAM,SAAS,WAAW,OAAO,OAAO;AACxC,MAAI,OAAO,WAAW,WAAY,QAAO,OAAO,MAAM;AACtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,OAAO,iBAAiB;AAAA,IACjC,KAAK;AACH,aAAO,OAAO,QAAQ;AAAA,IACxB,KAAK;AAAA,IACL;AACE,aAAO,OAAO,YAAY;AAAA,EAC9B;AACF;AAGO,SAAS,mBAAmB,KAAa,SAA+B;AAC7E,SAAO,IAAI,mCAAU,WAAW,qBAAqB,EAAE,MAAM,OAAO,EAAE;AACxE;;;ACjDO,SAAS,WAAW,MAAc,KAAa,SAAqC;AACzF,SAAO,EAAE,MAAM,MAAM,SAAS,OAAO,OAAO,KAAK,OAAO,EAAE;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../src/phone-utils.ts","../../tracking-core/src/phone.ts","../../tracking-core/src/phone-field.ts"],"sourcesContent":["// `@aranova/tracking-react/phone` — the isomorphic phone utils only (NO React,\n// NO 'use client'), so server/Node code can normalize/format too. The React\n// hook + component live on the package root.\nexport {\n DEFAULT_PHONE_COUNTRY,\n formatPhone,\n formatPhoneAsTyped,\n parsePhone,\n phoneField,\n toE164,\n} from \"../../tracking-core/src/index\";\nexport type {\n CountryCode,\n ParsedPhone,\n PhoneConfig,\n PhoneDisplayFormat,\n TrackedField,\n} from \"../../tracking-core/src/index\";\n","// Framework-agnostic phone-number utilities — isomorphic (browser + Node/RSC),\n// zero React. Bundled `libphonenumber-js` (standard metadata) so clients add no\n// dependency. The transmitted value is ALWAYS E.164; display is the only knob.\n\nimport { AsYouType, parsePhoneNumberFromString, type CountryCode } from \"libphonenumber-js\";\n\nexport type { CountryCode };\n\n/**\n * How a phone number is shown in the UI. The transmitted value is always E.164\n * and is deliberately NOT part of this — only the display format is configurable.\n * A function form covers the long tail (`(parsed) => string`).\n */\nexport type PhoneDisplayFormat =\n | \"national\"\n | \"international\"\n | \"e164\"\n | ((parsed: ParsedPhone) => string);\n\nexport interface ParsedPhone {\n /** E.164 (`\"+14165550199\"`) or `null` when the input isn't a valid number. This is what gets transmitted. */\n e164: string | null;\n /** National display form (`\"(416) 555-0199\"`); empty string when unparseable. */\n national: string;\n /** International display form (`\"+1 416 555 0199\"`); empty string when unparseable. */\n international: string;\n /** ISO-3166 country resolved by libphonenumber, or `null`. */\n country: CountryCode | null;\n isValid: boolean;\n}\n\n/** Region assumed for numbers typed without a country code. */\nexport const DEFAULT_PHONE_COUNTRY: CountryCode = \"CA\";\n\n/** Parse a raw/display string into every representation at once (one parse → display + wire never drift). */\nexport function parsePhone(raw: string, country?: CountryCode): ParsedPhone {\n const region = country ?? DEFAULT_PHONE_COUNTRY;\n const parsed = parsePhoneNumberFromString(raw ?? \"\", region);\n if (!parsed) {\n return { e164: null, national: \"\", international: \"\", country: region, isValid: false };\n }\n const isValid = parsed.isValid();\n return {\n // E.164 is only surfaced for a *valid* number — a possible-but-invalid input\n // (e.g. too few digits) still parses but must not be transmitted.\n e164: isValid ? parsed.number : null,\n national: parsed.formatNational(),\n international: parsed.formatInternational(),\n country: parsed.country ?? region,\n isValid,\n };\n}\n\n/** Normalize any raw/display value to E.164, or `null` if it isn't a valid number. */\nexport function toE164(raw: string, country?: CountryCode): string | null {\n return parsePhone(raw, country).e164;\n}\n\n/** Format a value for display. Defaults to `'national'`. Never affects the wire value. */\nexport function formatPhone(\n value: string,\n format: PhoneDisplayFormat = \"national\",\n country?: CountryCode,\n): string {\n const parsed = parsePhone(value, country);\n if (typeof format === \"function\") return format(parsed);\n switch (format) {\n case \"international\":\n return parsed.international || value;\n case \"e164\":\n return parsed.e164 ?? value;\n case \"national\":\n default:\n return parsed.national || value;\n }\n}\n\n/** Live, incremental formatting for an `<input>` as the user types (`AsYouType`). */\nexport function formatPhoneAsTyped(raw: string, country?: CountryCode): string {\n return new AsYouType(country ?? DEFAULT_PHONE_COUNTRY).input(raw ?? \"\");\n}\n","// Layer 0 (init config) + Layer 3 (tracking integration) for phone fields.\n// Kept in core so both the React and Next packages share identical types, and\n// the `phoneField` helper stays isomorphic.\n\nimport type { JsonValue } from \"./events/form-submit\";\nimport type { LeadFormRole } from \"./lead-forms/lead-forms.gen\";\nimport { toE164, type CountryCode, type PhoneDisplayFormat } from \"./phone\";\n\n/**\n * Init-time phone config (`createTracking({ phone })`). The transmitted value is\n * ALWAYS E.164 and is deliberately not configurable here — only display is.\n */\nexport interface PhoneConfig {\n /** Region assumed for numbers typed without a country code. Default `'CA'`. */\n defaultCountry?: CountryCode;\n /** How the input DISPLAYS to the user. Default `'national'`. Does not affect the wire. */\n display?: PhoneDisplayFormat;\n}\n\n/** A single tracked form field destined for `form_submit.fields[]`. */\nexport interface TrackedField {\n name: string;\n type: string;\n value: JsonValue;\n /** `null` when the field has no visible label; the wire requires the key. */\n label?: string | null;\n /** The ADR-0024 registry role this field answers, e.g. `phone`. */\n role?: LeadFormRole;\n}\n\n/**\n * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its\n * own display value for UI/email; this puts `+E.164` on the wire (or `null` when\n * the input isn't a valid number).\n */\nexport function phoneField(\n name: string,\n raw: string,\n country?: CountryCode,\n label: string | null = null,\n): TrackedField {\n return { name, type: \"phone\", label, value: toE164(raw, country) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,+BAAwE;AA4BjE,IAAM,wBAAqC;AAG3C,SAAS,WAAW,KAAa,SAAoC;AAC1E,QAAM,SAAS,WAAW;AAC1B,QAAM,aAAS,qDAA2B,OAAO,IAAI,MAAM;AAC3D,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,MAAM,MAAM,UAAU,IAAI,eAAe,IAAI,SAAS,QAAQ,SAAS,MAAM;AAAA,EACxF;AACA,QAAM,UAAU,OAAO,QAAQ;AAC/B,SAAO;AAAA;AAAA;AAAA,IAGL,MAAM,UAAU,OAAO,SAAS;AAAA,IAChC,UAAU,OAAO,eAAe;AAAA,IAChC,eAAe,OAAO,oBAAoB;AAAA,IAC1C,SAAS,OAAO,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;AAGO,SAAS,OAAO,KAAa,SAAsC;AACxE,SAAO,WAAW,KAAK,OAAO,EAAE;AAClC;AAGO,SAAS,YACd,OACA,SAA6B,YAC7B,SACQ;AACR,QAAM,SAAS,WAAW,OAAO,OAAO;AACxC,MAAI,OAAO,WAAW,WAAY,QAAO,OAAO,MAAM;AACtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,OAAO,iBAAiB;AAAA,IACjC,KAAK;AACH,aAAO,OAAO,QAAQ;AAAA,IACxB,KAAK;AAAA,IACL;AACE,aAAO,OAAO,YAAY;AAAA,EAC9B;AACF;AAGO,SAAS,mBAAmB,KAAa,SAA+B;AAC7E,SAAO,IAAI,mCAAU,WAAW,qBAAqB,EAAE,MAAM,OAAO,EAAE;AACxE;;;AC7CO,SAAS,WACd,MACA,KACA,SACA,QAAuB,MACT;AACd,SAAO,EAAE,MAAM,MAAM,SAAS,OAAO,OAAO,OAAO,KAAK,OAAO,EAAE;AACnE;","names":[]}
package/dist/phone.mjs CHANGED
@@ -39,8 +39,8 @@ function formatPhoneAsTyped(raw, country) {
39
39
  }
40
40
 
41
41
  // ../tracking-core/src/phone-field.ts
42
- function phoneField(name, raw, country) {
43
- return { name, type: "phone", value: toE164(raw, country) };
42
+ function phoneField(name, raw, country, label = null) {
43
+ return { name, type: "phone", label, value: toE164(raw, country) };
44
44
  }
45
45
  export {
46
46
  DEFAULT_PHONE_COUNTRY,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../tracking-core/src/phone.ts","../../tracking-core/src/phone-field.ts"],"sourcesContent":["// Framework-agnostic phone-number utilities — isomorphic (browser + Node/RSC),\n// zero React. Bundled `libphonenumber-js` (standard metadata) so clients add no\n// dependency. The transmitted value is ALWAYS E.164; display is the only knob.\n\nimport { AsYouType, parsePhoneNumberFromString, type CountryCode } from \"libphonenumber-js\";\n\nexport type { CountryCode };\n\n/**\n * How a phone number is shown in the UI. The transmitted value is always E.164\n * and is deliberately NOT part of this — only the display format is configurable.\n * A function form covers the long tail (`(parsed) => string`).\n */\nexport type PhoneDisplayFormat =\n | \"national\"\n | \"international\"\n | \"e164\"\n | ((parsed: ParsedPhone) => string);\n\nexport interface ParsedPhone {\n /** E.164 (`\"+14165550199\"`) or `null` when the input isn't a valid number. This is what gets transmitted. */\n e164: string | null;\n /** National display form (`\"(416) 555-0199\"`); empty string when unparseable. */\n national: string;\n /** International display form (`\"+1 416 555 0199\"`); empty string when unparseable. */\n international: string;\n /** ISO-3166 country resolved by libphonenumber, or `null`. */\n country: CountryCode | null;\n isValid: boolean;\n}\n\n/** Region assumed for numbers typed without a country code. */\nexport const DEFAULT_PHONE_COUNTRY: CountryCode = \"CA\";\n\n/** Parse a raw/display string into every representation at once (one parse → display + wire never drift). */\nexport function parsePhone(raw: string, country?: CountryCode): ParsedPhone {\n const region = country ?? DEFAULT_PHONE_COUNTRY;\n const parsed = parsePhoneNumberFromString(raw ?? \"\", region);\n if (!parsed) {\n return { e164: null, national: \"\", international: \"\", country: region, isValid: false };\n }\n const isValid = parsed.isValid();\n return {\n // E.164 is only surfaced for a *valid* number — a possible-but-invalid input\n // (e.g. too few digits) still parses but must not be transmitted.\n e164: isValid ? parsed.number : null,\n national: parsed.formatNational(),\n international: parsed.formatInternational(),\n country: parsed.country ?? region,\n isValid,\n };\n}\n\n/** Normalize any raw/display value to E.164, or `null` if it isn't a valid number. */\nexport function toE164(raw: string, country?: CountryCode): string | null {\n return parsePhone(raw, country).e164;\n}\n\n/** Format a value for display. Defaults to `'national'`. Never affects the wire value. */\nexport function formatPhone(\n value: string,\n format: PhoneDisplayFormat = \"national\",\n country?: CountryCode,\n): string {\n const parsed = parsePhone(value, country);\n if (typeof format === \"function\") return format(parsed);\n switch (format) {\n case \"international\":\n return parsed.international || value;\n case \"e164\":\n return parsed.e164 ?? value;\n case \"national\":\n default:\n return parsed.national || value;\n }\n}\n\n/** Live, incremental formatting for an `<input>` as the user types (`AsYouType`). */\nexport function formatPhoneAsTyped(raw: string, country?: CountryCode): string {\n return new AsYouType(country ?? DEFAULT_PHONE_COUNTRY).input(raw ?? \"\");\n}\n","// Layer 0 (init config) + Layer 3 (tracking integration) for phone fields.\n// Kept in core so both the React and Next packages share identical types, and\n// the `phoneField` helper stays isomorphic.\n\nimport type { JsonValue } from \"./events/form-submit\";\nimport { toE164, type CountryCode, type PhoneDisplayFormat } from \"./phone\";\n\n/**\n * Init-time phone config (`createTracking({ phone })`). The transmitted value is\n * ALWAYS E.164 and is deliberately not configurable here — only display is.\n */\nexport interface PhoneConfig {\n /** Region assumed for numbers typed without a country code. Default `'CA'`. */\n defaultCountry?: CountryCode;\n /** How the input DISPLAYS to the user. Default `'national'`. Does not affect the wire. */\n display?: PhoneDisplayFormat;\n}\n\n/** A single tracked form field destined for `form_submit.fields[]`. */\nexport interface TrackedField {\n name: string;\n type: string;\n value: JsonValue;\n label?: string | null;\n}\n\n/**\n * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its\n * own display value for UI/email; this puts `+E.164` on the wire (or `null` when\n * the input isn't a valid number).\n */\nexport function phoneField(name: string, raw: string, country?: CountryCode): TrackedField {\n return { name, type: \"phone\", value: toE164(raw, country) };\n}\n"],"mappings":";AAIA,SAAS,WAAW,kCAAoD;AA4BjE,IAAM,wBAAqC;AAG3C,SAAS,WAAW,KAAa,SAAoC;AAC1E,QAAM,SAAS,WAAW;AAC1B,QAAM,SAAS,2BAA2B,OAAO,IAAI,MAAM;AAC3D,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,MAAM,MAAM,UAAU,IAAI,eAAe,IAAI,SAAS,QAAQ,SAAS,MAAM;AAAA,EACxF;AACA,QAAM,UAAU,OAAO,QAAQ;AAC/B,SAAO;AAAA;AAAA;AAAA,IAGL,MAAM,UAAU,OAAO,SAAS;AAAA,IAChC,UAAU,OAAO,eAAe;AAAA,IAChC,eAAe,OAAO,oBAAoB;AAAA,IAC1C,SAAS,OAAO,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;AAGO,SAAS,OAAO,KAAa,SAAsC;AACxE,SAAO,WAAW,KAAK,OAAO,EAAE;AAClC;AAGO,SAAS,YACd,OACA,SAA6B,YAC7B,SACQ;AACR,QAAM,SAAS,WAAW,OAAO,OAAO;AACxC,MAAI,OAAO,WAAW,WAAY,QAAO,OAAO,MAAM;AACtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,OAAO,iBAAiB;AAAA,IACjC,KAAK;AACH,aAAO,OAAO,QAAQ;AAAA,IACxB,KAAK;AAAA,IACL;AACE,aAAO,OAAO,YAAY;AAAA,EAC9B;AACF;AAGO,SAAS,mBAAmB,KAAa,SAA+B;AAC7E,SAAO,IAAI,UAAU,WAAW,qBAAqB,EAAE,MAAM,OAAO,EAAE;AACxE;;;ACjDO,SAAS,WAAW,MAAc,KAAa,SAAqC;AACzF,SAAO,EAAE,MAAM,MAAM,SAAS,OAAO,OAAO,KAAK,OAAO,EAAE;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../../tracking-core/src/phone.ts","../../tracking-core/src/phone-field.ts"],"sourcesContent":["// Framework-agnostic phone-number utilities — isomorphic (browser + Node/RSC),\n// zero React. Bundled `libphonenumber-js` (standard metadata) so clients add no\n// dependency. The transmitted value is ALWAYS E.164; display is the only knob.\n\nimport { AsYouType, parsePhoneNumberFromString, type CountryCode } from \"libphonenumber-js\";\n\nexport type { CountryCode };\n\n/**\n * How a phone number is shown in the UI. The transmitted value is always E.164\n * and is deliberately NOT part of this — only the display format is configurable.\n * A function form covers the long tail (`(parsed) => string`).\n */\nexport type PhoneDisplayFormat =\n | \"national\"\n | \"international\"\n | \"e164\"\n | ((parsed: ParsedPhone) => string);\n\nexport interface ParsedPhone {\n /** E.164 (`\"+14165550199\"`) or `null` when the input isn't a valid number. This is what gets transmitted. */\n e164: string | null;\n /** National display form (`\"(416) 555-0199\"`); empty string when unparseable. */\n national: string;\n /** International display form (`\"+1 416 555 0199\"`); empty string when unparseable. */\n international: string;\n /** ISO-3166 country resolved by libphonenumber, or `null`. */\n country: CountryCode | null;\n isValid: boolean;\n}\n\n/** Region assumed for numbers typed without a country code. */\nexport const DEFAULT_PHONE_COUNTRY: CountryCode = \"CA\";\n\n/** Parse a raw/display string into every representation at once (one parse → display + wire never drift). */\nexport function parsePhone(raw: string, country?: CountryCode): ParsedPhone {\n const region = country ?? DEFAULT_PHONE_COUNTRY;\n const parsed = parsePhoneNumberFromString(raw ?? \"\", region);\n if (!parsed) {\n return { e164: null, national: \"\", international: \"\", country: region, isValid: false };\n }\n const isValid = parsed.isValid();\n return {\n // E.164 is only surfaced for a *valid* number — a possible-but-invalid input\n // (e.g. too few digits) still parses but must not be transmitted.\n e164: isValid ? parsed.number : null,\n national: parsed.formatNational(),\n international: parsed.formatInternational(),\n country: parsed.country ?? region,\n isValid,\n };\n}\n\n/** Normalize any raw/display value to E.164, or `null` if it isn't a valid number. */\nexport function toE164(raw: string, country?: CountryCode): string | null {\n return parsePhone(raw, country).e164;\n}\n\n/** Format a value for display. Defaults to `'national'`. Never affects the wire value. */\nexport function formatPhone(\n value: string,\n format: PhoneDisplayFormat = \"national\",\n country?: CountryCode,\n): string {\n const parsed = parsePhone(value, country);\n if (typeof format === \"function\") return format(parsed);\n switch (format) {\n case \"international\":\n return parsed.international || value;\n case \"e164\":\n return parsed.e164 ?? value;\n case \"national\":\n default:\n return parsed.national || value;\n }\n}\n\n/** Live, incremental formatting for an `<input>` as the user types (`AsYouType`). */\nexport function formatPhoneAsTyped(raw: string, country?: CountryCode): string {\n return new AsYouType(country ?? DEFAULT_PHONE_COUNTRY).input(raw ?? \"\");\n}\n","// Layer 0 (init config) + Layer 3 (tracking integration) for phone fields.\n// Kept in core so both the React and Next packages share identical types, and\n// the `phoneField` helper stays isomorphic.\n\nimport type { JsonValue } from \"./events/form-submit\";\nimport type { LeadFormRole } from \"./lead-forms/lead-forms.gen\";\nimport { toE164, type CountryCode, type PhoneDisplayFormat } from \"./phone\";\n\n/**\n * Init-time phone config (`createTracking({ phone })`). The transmitted value is\n * ALWAYS E.164 and is deliberately not configurable here — only display is.\n */\nexport interface PhoneConfig {\n /** Region assumed for numbers typed without a country code. Default `'CA'`. */\n defaultCountry?: CountryCode;\n /** How the input DISPLAYS to the user. Default `'national'`. Does not affect the wire. */\n display?: PhoneDisplayFormat;\n}\n\n/** A single tracked form field destined for `form_submit.fields[]`. */\nexport interface TrackedField {\n name: string;\n type: string;\n value: JsonValue;\n /** `null` when the field has no visible label; the wire requires the key. */\n label?: string | null;\n /** The ADR-0024 registry role this field answers, e.g. `phone`. */\n role?: LeadFormRole;\n}\n\n/**\n * Build a tracked field whose wire value is ALWAYS E.164. The client keeps its\n * own display value for UI/email; this puts `+E.164` on the wire (or `null` when\n * the input isn't a valid number).\n */\nexport function phoneField(\n name: string,\n raw: string,\n country?: CountryCode,\n label: string | null = null,\n): TrackedField {\n return { name, type: \"phone\", label, value: toE164(raw, country) };\n}\n"],"mappings":";AAIA,SAAS,WAAW,kCAAoD;AA4BjE,IAAM,wBAAqC;AAG3C,SAAS,WAAW,KAAa,SAAoC;AAC1E,QAAM,SAAS,WAAW;AAC1B,QAAM,SAAS,2BAA2B,OAAO,IAAI,MAAM;AAC3D,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,MAAM,MAAM,UAAU,IAAI,eAAe,IAAI,SAAS,QAAQ,SAAS,MAAM;AAAA,EACxF;AACA,QAAM,UAAU,OAAO,QAAQ;AAC/B,SAAO;AAAA;AAAA;AAAA,IAGL,MAAM,UAAU,OAAO,SAAS;AAAA,IAChC,UAAU,OAAO,eAAe;AAAA,IAChC,eAAe,OAAO,oBAAoB;AAAA,IAC1C,SAAS,OAAO,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;AAGO,SAAS,OAAO,KAAa,SAAsC;AACxE,SAAO,WAAW,KAAK,OAAO,EAAE;AAClC;AAGO,SAAS,YACd,OACA,SAA6B,YAC7B,SACQ;AACR,QAAM,SAAS,WAAW,OAAO,OAAO;AACxC,MAAI,OAAO,WAAW,WAAY,QAAO,OAAO,MAAM;AACtD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,OAAO,iBAAiB;AAAA,IACjC,KAAK;AACH,aAAO,OAAO,QAAQ;AAAA,IACxB,KAAK;AAAA,IACL;AACE,aAAO,OAAO,YAAY;AAAA,EAC9B;AACF;AAGO,SAAS,mBAAmB,KAAa,SAA+B;AAC7E,SAAO,IAAI,UAAU,WAAW,qBAAqB,EAAE,MAAM,OAAO,EAAE;AACxE;;;AC7CO,SAAS,WACd,MACA,KACA,SACA,QAAuB,MACT;AACd,SAAO,EAAE,MAAM,MAAM,SAAS,OAAO,OAAO,OAAO,KAAK,OAAO,EAAE;AACnE;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-CHpplXU7.mjs';
2
+ import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-CDGNZUaH.mjs';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/mini';
2
- import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-C1HMPjQl.js';
2
+ import { S as SalesBookingsClient, l as ConversionConfigStore, s as TrackingConfigRuntime } from './bookings-Bw2ImtPd.js';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  /** Raw identifiers a caller may hand us (normalized before use). */
package/dist/sales.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-YUH3bQl9.mjs';
2
- export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-CHpplXU7.mjs';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-D4aU73mR.mjs';
2
+ export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-CDGNZUaH.mjs';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
- import './form-submit-CX-CxJjQ.mjs';
5
+ import './form-submit-C_vJXCxh.mjs';
package/dist/sales.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-CNvzyF5T.js';
2
- export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-C1HMPjQl.js';
1
+ export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, C as CompareTo, d as CurrencyRevenue, e as CustomerCurrencyDelta, f as CustomerCurrencyTotal, g as CustomerGetOptions, h as CustomerGetResult, i as CustomerKpis, j as CustomerKpisDeltas, k as CustomerKpisPrevious, l as CustomerListPage, m as CustomerListQuery, n as CustomerProfile, o as CustomerSegment, p as CustomerSegmentCount, q as CustomerSortField, r as CustomerSummary, s as CustomerSummaryQuery, D as DistinctCustomersByCurrency, E as EffectiveSaleProperty, G as Granularity, N as NAMED_RANGES, t as NamedRange, P as PublicServiceItem, S as SALE_SOURCES, u as SUPPORTED_CURRENCIES, v as Sale, w as SaleBuiltinRequirableField, x as SaleCursorPage, y as SaleFilters, z as SaleInput, F as SaleItem, H as SaleItemInput, I as SaleKeysetSortField, J as SaleListPage, K as SaleListQuery, L as SaleListQueryV2, M as SalePropertyOption, O as SalePropertyType, Q as SaleService, R as SaleServiceInput, T as SaleSortField, U as SaleSortOrder, V as SaleSource, W as SaleSourceFacts, X as SaleSummary, Y as SaleSummaryPrevious, Z as SaleSummaryQuery, _ as SaleSummaryQueryV2, $ as SaleSummaryV2, a0 as SaleUpdateInput, a1 as SalesBusinessClient, a2 as SalesCategoryBreakdown, a3 as SalesClient, a4 as SalesClientConfig, a5 as SalesCustomersClient, a6 as SalesServiceBreakdown, a7 as SalesTransportConfig, a8 as SalesTrendPoint, a9 as SummaryCurrencyDelta, aa as SummaryDeltas, ab as SummaryWindow, ac as SupportedCurrency, ad as TRACKING_RANGES, ae as TrackingOverviewRange, ag as createSalesClient, ah as currencySchema, ai as fetchServices, aj as formatDateInTz, ak as formatMoney, al as fromMinor, am as saleCreateSchema, an as saleItemSchema, ao as saleServiceSchema, ap as saleUpdateSchema, aq as salesRequest, as as toMinor } from './sales-DkdrGIUS.js';
2
+ export { B as BookingDetailsFailure, a as BookingDetailsInput, b as BookingDetailsOptions, c as BookingDetailsOutcome, d as BookingDetailsStatus, e as BookingDropOff, f as BookingFormSubmit, g as BookingInput, h as BookingMode, i as BookingOutcome, j as BookingSimulation, k as BookingSubmitOptions, F as FormSubmitField, S as SalesBookingsClient, n as newBookingAttemptKey } from './bookings-Bw2ImtPd.js';
3
3
  import 'zod/mini';
4
4
  import 'libphonenumber-js';
5
- import './form-submit-CX-CxJjQ.js';
5
+ import './form-submit-C_vJXCxh.js';