@atelic-action/ui 8.3.0 → 8.5.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/README.md +74 -9
- package/dist/lib/contactLinks.d.ts +31 -0
- package/dist/lib/contactLinks.js +55 -0
- package/dist/monitoring/server.js +82 -15
- package/dist/scripts/check-contacts.d.ts +17 -0
- package/dist/scripts/check-contacts.js +162 -0
- package/package.json +10 -13
- package/src/chrome/Footer.tsx +27 -17
- package/src/chrome/SiteHeader.tsx +7 -6
- package/src/chrome/SiteMenu.tsx +13 -10
- package/src/chrome/StickyCTABar.tsx +34 -16
- package/src/components/GateLogin.tsx +2 -1
- package/src/components/MultiSelect.tsx +225 -0
- package/src/components/index.ts +1 -0
- package/src/lib/contactForm.ts +184 -0
- package/src/lib/contactLinks.ts +57 -0
- package/src/lib/googlePlaces.ts +392 -0
- package/src/lib/latestOnly.ts +47 -0
- package/src/monitoring/server.ts +92 -16
- package/src/primitives/AddressSearch.tsx +341 -0
- package/src/primitives/EmailLink.tsx +55 -0
- package/src/primitives/ExpandableText.tsx +137 -0
- package/src/primitives/GoogleMapsAttribution.tsx +14 -0
- package/src/primitives/PhoneLink.tsx +61 -0
- package/src/primitives/index.ts +18 -0
- package/src/routing/miss.ts +14 -13
- package/src/scripts/check-base-path.ts +15 -0
- package/src/scripts/check-contacts.ts +177 -0
- package/src/sections/ContactForm.tsx +683 -87
- package/src/sections/ContactInfoCard.tsx +21 -4
- package/src/sections/InfoRows.tsx +103 -0
- package/src/sections/LocationSection.tsx +2 -1
- package/src/sections/Locations.tsx +3 -2
- package/src/sections/PageHero.tsx +22 -5
- package/src/sections/index.ts +23 -1
- package/src/sections/siteConfig.ts +12 -1
- package/src/styles/chrome.css +30 -17
- package/src/styles/components.css +123 -0
- package/src/styles/defaults.css +33 -1
- package/src/styles/fields.css +33 -0
- package/src/styles/primitives.css +165 -0
- package/src/styles/sections.css +310 -22
- package/src/types.ts +7 -2
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ Every export, grouped by the entry it is imported from. The Storybook column lin
|
|
|
30
30
|
| `StatRow` | `@atelic-action/ui/components` | A row of large figures with periods, deltas, and trends; a share's denominator set small after the figure (`outOf`) and a change set small beside it with a triangle (`change`), 3.14.0 | [Components/StatRow](https://ui.atelic.me/?path=/docs/components-statrow--docs) |
|
|
31
31
|
| `Callout` | `@atelic-action/ui/components` | One finding: an icon in its tone, the title, the explainer (not `CalloutPanel`, the business's headline claims) | [Components/Callout](https://ui.atelic.me/?path=/docs/components-callout--docs) |
|
|
32
32
|
| `Disclosure` | `@atelic-action/ui/components` | A section that folds: controlled, an app's card; uncontrolled, a native details fold that prints open | [Components/Disclosure](https://ui.atelic.me/?path=/docs/components-disclosure--docs) |
|
|
33
|
+
| `MultiSelect`, `MultiSelectOption`, `MultiSelectProps` | `@atelic-action/ui/components` | A button naming what is chosen over a Radix popover of Radix checkboxes, any number ticked, each chosen value submitted under `name`; styled in `components.css`, so an app draws it too (8.5.0) | [Components/MultiSelect](https://ui.atelic.me/?path=/docs/components-multiselect--docs) |
|
|
33
34
|
| `Tabs`, `TabsItem` | `@atelic-action/ui/components` | Panels behind a row of tabs, every panel kept in the page: a hash opens the tab or the panel holding what it names, and it prints every panel under its label | [Components/Tabs](https://ui.atelic.me/?path=/docs/components-tabs--docs) |
|
|
34
35
|
| `StackedBar` | `@atelic-action/ui/components` | One bar split into the parts of a whole, with a key | [Components/StackedBar](https://ui.atelic.me/?path=/docs/components-stackedbar--docs) |
|
|
35
36
|
| `ColumnChart` | `@atelic-action/ui/components` | A bar a period, the periods in labeled groups | [Components/ColumnChart](https://ui.atelic.me/?path=/docs/components-columnchart--docs) |
|
|
@@ -39,6 +40,12 @@ Every export, grouped by the entry it is imported from. The Storybook column lin
|
|
|
39
40
|
| `Watermark` | `@atelic-action/ui/components` | The signed in reader's confidential stamp, pill or tiled | [Components/Watermark](https://ui.atelic.me/?path=/docs/components-watermark--docs) |
|
|
40
41
|
| `readCookie`, `Tone` | `@atelic-action/ui/components` | The cookie reader the watermark uses, and the tone type | none |
|
|
41
42
|
| `Button`, `PrimaryButton`, `SecondaryButton`, `Chip`, `Eyebrow`, `Lead`, `SectionHeading` | `@atelic-action/ui/primitives` | The small pieces a page is set in; the two named buttons are the only call to action shapes a page uses | [Primitives/Button](https://ui.atelic.me/?path=/docs/primitives-button--docs) |
|
|
43
|
+
| `AddressSearch`, `AddressProvider`, `AddressSuggestion`, `AddressParts`, `AddressSearchProps` | `@atelic-action/ui/primitives` | A field that offers addresses as they are typed from the provider a site passes, and hands back the street, city, state, and ZIP on a pick; renders nothing without a provider (8.5.0) | [Primitives/AddressSearch](https://ui.atelic.me/?path=/docs/primitives-addresssearch--docs) |
|
|
44
|
+
| `googlePlacesProvider`, `GooglePlacesOptions`, `GoogleMapsAttribution`, `addressFromComponents`, `AddressComponent` | `@atelic-action/ui/primitives` | Google's address suggestions as an `AddressSearch` provider from a key alone (the Maps JavaScript API's Places library, loaded on the field's first focus, one session token per search and pick), the "Google Maps" credit its terms ask for, and the mapping from Google's address components to street, city, state, and ZIP (8.5.0) | [Primitives/AddressSearch](https://ui.atelic.me/?path=/docs/primitives-addresssearch--docs) |
|
|
45
|
+
| `PhoneLink`, `EmailLink`, `phoneHref`, `emailHref`, `PhoneLinkProps`, `EmailLinkProps` | `@atelic-action/ui/primitives` | The one way the package draws a phone number and an email address as links (Component Rules 17): `PhoneLink` takes the site's phone (`e164`, `display`) or a typed number, `EmailLink` an address, breakable after the @ and before each dot; neither opens a new tab; a configured number or address links exactly as given, as before, and only one with nothing to dial or write shows as words (8.5.0) | [Primitives/PhoneLink](https://ui.atelic.me/?path=/docs/primitives-phonelink--docs) |
|
|
46
|
+
| `toE164`, `isE164`, `isEmail`, `EMAIL_PATTERN` | `@atelic-action/ui/primitives` | The light checks the links and the contact form share: a typed number read into E.164 (ten digits take +1), and the address pattern (8.5.0) | none |
|
|
47
|
+
| `contactProblems` | `@atelic-action/ui/scripts/contacts` | The build time check on phone numbers and addresses, against Google's numbering plan (`libphonenumber-js`), for a site's own test of numbers it passes as props (8.5.0) | none |
|
|
48
|
+
| `ExpandableText`, `ExpandableTextProps` | `@atelic-action/ui/primitives` | Long text clamped to a few lines behind Show more, every word kept in the page, a checkbox's whole label when `labelFor` is set (8.5.0) | [Primitives/ExpandableText](https://ui.atelic.me/?path=/docs/primitives-expandabletext--docs) |
|
|
42
49
|
| `GradeChip`, `gradeLabel`, `WriteupGrade` | `@atelic-action/ui/artifact` | A section's grade, A to D, as a chip in its color, the letter alone, and the grade type | [Artifact/GradeChip](https://ui.atelic.me/?path=/docs/artifact-gradechip--docs) |
|
|
43
50
|
| `SignOff`, `WriteupPerson` | `@atelic-action/ui/artifact` | The close a document ends on, and the person it names | [Artifact/SignOff](https://ui.atelic.me/?path=/docs/artifact-signoff--docs) |
|
|
44
51
|
| `Shot`, `WriteupShot` | `@atelic-action/ui/artifact` | The owner's own screen, opening the full picture, over its caption; a portrait crop is marked `data-portrait` and held to 200px (1.8in in print) | [Artifact/Shot](https://ui.atelic.me/?path=/docs/artifact-shot--docs) |
|
|
@@ -69,8 +76,10 @@ Every export, grouped by the entry it is imported from. The Storybook column lin
|
|
|
69
76
|
| `CalloutPanel` | `@atelic-action/ui/sections` | Short callouts on the primary field, a heavy title over a subtitle each, four across and two by two below, titles and subtitles each on a shared line (8.0.0) | [Sections/CalloutPanel](https://ui.atelic.me/?path=/docs/sections-calloutpanel--docs) |
|
|
70
77
|
| `CTASection` | `@atelic-action/ui/sections` | The standard closer: the site's own primary action and an optional ghost second | [Sections/CTASection](https://ui.atelic.me/?path=/docs/sections-ctasection--docs) |
|
|
71
78
|
| `ComparisonTable` | `@atelic-action/ui/sections` | A graded before and after that scrolls sideways on a phone rather than reflowing; a row's label can link to what explains it (`stageHref`, 3.14.0) | [Sections/ComparisonTable](https://ui.atelic.me/?path=/docs/sections-comparisontable--docs) |
|
|
72
|
-
| `ContactForm` | `@atelic-action/ui/sections` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event | [Sections/ContactForm](https://ui.atelic.me/?path=/docs/sections-contactform--docs) |
|
|
73
|
-
| `
|
|
79
|
+
| `ContactForm` | `@atelic-action/ui/sections` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event; opt in props add a split name, a phone, the address with its search, a services picker, a consent line, a count of fields to fix, and a thanks that replaces the form (8.5.0) | [Sections/ContactForm](https://ui.atelic.me/?path=/docs/sections-contactform--docs) |
|
|
80
|
+
| `ContactFormAddress`, `ContactFormConsent`, `ContactFormLabels`, `ContactFormPlaceholders`, `ContactFormThanks`, `ContactFormValues`, `ContactFormField`, `isPhoneNumber`, `isZIP` | `@atelic-action/ui/sections` | The shapes the form's opt in props take, what a visitor wrote, and the form's default phone and ZIP checks (8.5.0) | none |
|
|
81
|
+
| `ContactInfoCard` | `@atelic-action/ui/sections` | A dark card of direct contact rows: call, email, visit, portal; `layout="stacked"` sets each label over its number (8.5.0) | [Sections/ContactInfoCard](https://ui.atelic.me/?path=/docs/sections-contactinfocard--docs) |
|
|
82
|
+
| `InfoRows`, `InfoRow`, `InfoRowAction`, `InfoRowIcon`, `InfoRowsProps` | `@atelic-action/ui/sections` | Rows of a title over a few lines with one icon action on the right, the way a map pack lists a place with its directions (8.5.0) | [Sections/InfoRows](https://ui.atelic.me/?path=/docs/sections-inforows--docs) |
|
|
74
83
|
| `CredentialList` | `@atelic-action/ui/sections` | Credential cards with a mono code before each | [Sections/CredentialList](https://ui.atelic.me/?path=/docs/sections-credentiallist--docs) |
|
|
75
84
|
| `ExpandList` | `@atelic-action/ui/sections` | A light accordion of numbered rows whose bodies stay in the HTML while closed | [Sections/ExpandList](https://ui.atelic.me/?path=/docs/sections-expandlist--docs) |
|
|
76
85
|
| `FAQBrowser` | `@atelic-action/ui/sections` | The help page: live search, a sticky `JumpRail` of categories with scroll spy, expand all, deep links; `contactHref` sets where the no match line points | [Sections/FAQBrowser](https://ui.atelic.me/?path=/docs/sections-faqbrowser--docs) |
|
|
@@ -288,6 +297,14 @@ import { Button, SectionHeading } from "@atelic-action/ui/primitives";
|
|
|
288
297
|
|
|
289
298
|
`Button` is an anchor when it has an `href` and a real button otherwise. It puts the base path from `BasePathProvider` on a root path `href` (0.19.0), so a site served under a prefix needs no wrapper; with no provider above it the `href` renders as given. Its arrow is hidden from the name a screen reader hears.
|
|
290
299
|
|
|
300
|
+
`AddressSearch` and `ExpandableText` (8.5.0) are the two form primitives. `AddressSearch` is the ARIA combobox: it asks the `provider` a site passes (`suggest` from the typed text to suggestions, `resolve` from a pick to `{ street, city, state, zip }`, each handed an `AbortSignal`) after a pause in the typing, drops an answer that comes back after a newer question, and hands the parts to `onPick`; it knows no service, so a site wraps Google's address autocomplete, or any other, in those two functions and passes the credit its terms ask for as `attribution`. Without a provider it renders nothing. A provider may also have `prepare()`, which the search calls on each focus of the field.
|
|
301
|
+
|
|
302
|
+
`googlePlacesProvider({ apiKey, regionCodes, near, types, language, region })` is the one provider the package ships. It runs on the Maps JavaScript API's Places library (the Autocomplete Data API, the New one), not the Places web service: Google documents a website restricted key for the JavaScript API and does not document one for calling `places.googleapis.com` from a browser, where its security guidance files the web service under servers. The script loads on the field's first focus (`prepare`), never at page load, and once per key; it uses the API when the page already has it, waits for a Maps script already on the page rather than adding a second, and takes the older `google.maps.places` namespace where `importLibrary` is missing. A failed load takes its tag back out; searches then hand back the same failure for 30 seconds rather than adding a tag per keystroke, and the field's next focus tries again at once. One `AutocompleteSessionToken` covers every search up to a pick; the pick's `fetchFields` ends the session, and the next search makes a new token, so a search and its pick bill as one session. The pick asks for `addressComponents` alone, an Essentials field. Suggestions default to addresses, buildings, and units (`street_address`, `premise`, `subpremise`; up to five types); `regionCodes` limits the countries, and `near` (`lat`, `lng`, `radius` in meters) prefers a point without limiting to it. The form's ZIP check is US only, on purpose: every consumer is a US business, and a pluggable check waits for the first one that is not. A failed load or search offers nothing, so the plain fields still take the address; an aborted search rejects. The key is a browser key: restrict it to the site's domains and to the Maps JavaScript API and Places API (New).
|
|
303
|
+
|
|
304
|
+
**Google's attribution.** Google's Places policies ask for attribution wherever its content shows without a Google map: the Google Maps logo where there is room, or else the text "Google Maps", unmodified, never translated (`translate="no"`), never wrapped, 12 to 16 pixels in a regular weight, at 4.5 to 1 contrast, inside the same container as the content, near its top or bottom. "Google" alone is accepted for now as the older form; "Powered by Google" does not appear in the current policy. `GoogleMapsAttribution` draws the text form, and `AddressSearch` sets it under the suggestions; a site that wants the logo passes its own node as `attribution`.
|
|
305
|
+
|
|
306
|
+
`ExpandableText` clamps prose to `lines` with a Show more under it (`aria-expanded`, its words by prop); the cut is a line clamp, so every word stays in the page and a checkbox it labels (`labelFor`) is named by the whole text, and anything a reader acts on goes in `more`, hidden and `inert` while closed. With `inline` the control sits at the end of the last line instead: closed, over the line's end on a fade of `--expandable-ground` after an ellipsis drawn with empty alternative text; open, after the last word. It stays a sibling of the text, so a checkbox the text labels is never named with the control's words. The multi select beside them is a component, `MultiSelect` in `@atelic-action/ui/components`, since an app draws it too.
|
|
307
|
+
|
|
291
308
|
`Bubble` (3.11.0) is the round tile set beside a heading or a numbered step, holding either a lucide icon the caller sizes (`icon`) or a short mono index (`num`, such as "01"); given both, the icon sits inside and the number rides a small badge on the lower right rim, the way an unread count sits on an app icon. It comes in three sizes (`sm`, `md`, `lg`: 36, 48, and 60 pixels across, `md` by default) and lifts its fill for a dark band with `onDark`, the way `Chip` does. It is decoration and wears `aria-hidden`, so the heading beside it carries the meaning, the step's number included.
|
|
292
309
|
|
|
293
310
|
## The Access Gate
|
|
@@ -612,7 +629,7 @@ export function SiteShell(props: Omit<SiteShellProps, "currentPath" | "basePath"
|
|
|
612
629
|
Every site's footer has one shape, and `Footer` draws it (7.0.0):
|
|
613
630
|
|
|
614
631
|
- **The brand column:** the header's lockup (the mark with the wordmark beside it, or the mark alone when `logo.wordmark` is false), then the Google rating beside five stars, the whole line one link to the business's Google profile when it has one, then the one address, the headquarters, linked to the same profile, then the phone and the email, each a link.
|
|
615
|
-
- **The hours,** when the site gives them: a column of their own headed Hours (`hoursHeading`), each row's days beside or over its range, as the column's width allows (8.1.0). On a phone, where the footer is two across, the cells under the brand column pair up with none left alone (8.3.0): beside an even count of link columns the hours take the row's whole width with their rows two across and the link columns pair up under them, and beside an odd count the hours stay a column of their own, rows stacked, paired with the first link column, as in 8.1.0. `Footer` counts the link columns it draws (a column with no links is left out first). `footer.hoursPlacement: "brand"` (`Footer`'s `hoursPlacement`, 8.3.0) sets them inside the brand column instead, under the address, the phone, and the email, as a compact list (days, then ranges) under a small Hours label, so the four link columns keep the row's room. In that placement each link column is at least
|
|
632
|
+
- **The hours,** when the site gives them: a column of their own headed Hours (`hoursHeading`), each row's days beside or over its range, as the column's width allows (8.1.0). On a phone, where the footer is two across, the cells under the brand column pair up with none left alone (8.3.0): beside an even count of link columns the hours take the row's whole width with their rows two across and the link columns pair up under them, and beside an odd count the hours stay a column of their own, rows stacked, paired with the first link column, as in 8.1.0. `Footer` counts the link columns it draws (a column with no links is left out first). `footer.hoursPlacement: "brand"` (`Footer`'s `hoursPlacement`, 8.3.0) sets them inside the brand column instead, under the address, the phone, and the email, as a compact list (days, then ranges) under a small Hours label, so the four link columns keep the row's room. In that placement each link column is at least ten times its link text's size wide (so `--footer-link-size` scales it) and never narrower than its longest label, and the brand column is as wide as its content needs, its longest line set whole (the lockup, the rating, an address line, the email, a row of the hours), so a short brand block is as narrow as it reads and `--footer-brand-width` shares out the rest (8.4.0); while the row holds every floor, the brand column and the link columns share it, and when it cannot, the brand column takes a row of its own with the link columns under it, all across while their floors fit and two by two below that (8.3.0). The floors are measured for the link columns `Footer` draws, so two or three columns keep the brand column beside them as long as theirs fit. The link columns share one box beside the brand column, so the brand column sits beside all of them or above all of them, never beside some; inside it one measure, the floors against the box's own width, drives the four across or two by two step, so no breakpoint disagrees with it, and a font a few percent wider than a site was drawn in still holds a three word label on one line.
|
|
616
633
|
- **Four link columns:** Company, Resources, Social, and Legal, in that order. From 760px the columns share one row at their shares but never narrower than their longest word, wrapping a column to a second row before a label breaks inside itself (8.1.0). A Social link carries its icon in front of its words. A column with no links is left out, and the grid sizes itself to the columns shown.
|
|
617
634
|
- **The closing bar:** `ClosingBar` under it all, `Copyright` with the business's name on the left and `Credit` on the right while the two share a line; when they do not (a phone, a long attribution), the credit wraps under the copyright and both start at the same edge, and a copyright longer than the line wraps inside itself (8.3.0).
|
|
618
635
|
|
|
@@ -662,7 +679,7 @@ The menu has two sheets, chosen by `menu.surface` in the config (`SiteHeader`'s
|
|
|
662
679
|
|
|
663
680
|
The burger takes `menu.burger` (`SiteHeader`'s `burger`): `labelAfter` sets the three lines before the words `menuLabel` puts beside it, and `outlined` draws it in an outlined pill; both are off by default (8.2.0). While the menu is open only the lines fold to an X. The phone's round call button beside the burger is named by its number's `label` and the number, or "Call" and the number when it has no label (8.2.0).
|
|
664
681
|
|
|
665
|
-
The menu's words come from the config: the call to action reads `cta.menuLabel` when set, else `cta.label` ("Order ahead for Saturday" in the menu where the bar says "Order ahead"), and each header number reads its `menuLabel`, else its `label`, else "Call" (8.2.0). A number's `label` keeps its place in the desktop bar's phone pill.
|
|
682
|
+
The menu's words come from the config: the call to action reads `cta.menuLabel` when set, else `cta.label` ("Order ahead for Saturday" in the menu where the bar says "Order ahead"), and each header number reads its `menuLabel`, else its `label`, else "Call" (8.2.0). A number's `label` keeps its place in the desktop bar's phone pill. With no header numbers the menu lists the contact block's one phone, which reads `phone.menuLabel`, else "Call", on either sheet (8.4.0); only the menu reads it, and `ContactInfoCard`'s row takes its own `phoneLabel`.
|
|
666
683
|
|
|
667
684
|
```ts
|
|
668
685
|
// src/site.config.ts
|
|
@@ -731,6 +748,42 @@ The space a section leaves above and below itself is one token, `--section-space
|
|
|
731
748
|
|
|
732
749
|
`.section` pads with it, and the steps derived from it keep their old proportion to it: `.section-md` 0.7, `.section-sm` 0.6, `tight-top` and `tight-bottom` a third, the `PricingBand` 0.84, `PageHero` and the not found opener 0.72 on top and 0.5 below, and the `FeatureDetail` rows 0.6, whose first and last rows now sit flush with the section around them. `--block-gap` is the space between a section's heading and the grid under it (`FeatureGrid`, `ProfileCards`, `LinkColumns`, `CalloutPanel`, and `Gallery` at 0.77 of it), and `--card-min` the least a `FeatureGrid` card stands. A site that wants its own value sets the property on `.atelic-ui` in its own sheet, outside the layer. `ArtifactShell` pins `comfortable`, so a document reads as it did; the app shell reads none of these.
|
|
733
750
|
|
|
751
|
+
### Moving to 8.5.0
|
|
752
|
+
|
|
753
|
+
No API breaks, and nothing moves on a site that changes nothing: every addition is an optional prop, an export, or a token whose default is the look it had. `@radix-ui/react-popover` and `@radix-ui/react-checkbox` move from optional peers to dependencies, as `@radix-ui/react-tabs` is, so a marketing site installs nothing for `MultiSelect`; an app that already had them keeps one copy where the ranges meet.
|
|
754
|
+
|
|
755
|
+
**The contact form's opt in fields.** `ContactForm` takes `splitName`, `phone` (`"optional"` or `"required"`), `address` (`required`, a `provider` and its `attribution` for the search, `states` for a state select, `defaultState`), `services` (a `MultiSelect` in place of the topic select), `consent` (its wording, its `links`, its `lines`), `labels`, `placeholders`, `errorText`, `errorSummary` (a count of the fields to fix over the form), `thanks` (a heading, a lead, the read back, the next steps, and Send another message, replacing the form once sent), and `validatePhone`. `topics` is optional now; with none and no `services`, no select is drawn. The body keeps `name`, `email`, `topic`, `message`, and `company` whatever is drawn, so a relay that reads only those works unchanged: with the split name `name` is the two joined, with services `topic` is the chosen ones joined by commas. Each opt in field adds its own keys (`firstName`, `lastName`, `phone`, `address`, `services`, `consent`), which a relay has to read to pass them on.
|
|
756
|
+
|
|
757
|
+
**Phone and email links.** Every phone number and email address the package draws is a `PhoneLink` or an `EmailLink`, with the same markup and the same `href` as before, loose values included, so nothing moves on a site: the browser is never stricter than it was. Only a number with no digit, or an empty address, shows as words, with a warning in development. Strictness lives in the build: `atelic-check-base-path` checks the site config's contacts (`contactProblems`) against Google's numbering plan (`libphonenumber-js`, a new dependency that runs in the command only and never ships in a page), and a failure stops the build and names the field. It judges only what it is sure is a contact: a phone is an object holding `e164` and `display`, or a `Locations` entry's `phoneE164` and `phoneDisplay`, anywhere in the config, and its number must be valid in E.164 for its country with a display that reads as it; an address is a string at a known address path (`email`, `gate.contactEmail`, `analytics.identify.email`), never a string judged by its key's name, so a label reading "Email" is left alone; a `tel:` href must reduce to a valid number once RFC 3966's visual separators and parameters are set aside, and a `mailto:` href must write to an address. A site that passes numbers as props outside its config (a contact card's `phones`) checks them in its own test with `contactProblems` from `@atelic-action/ui/scripts/contacts`. The contact form's phone check is now the links' (`toE164`): a number typed with a + and its country code is accepted too.
|
|
758
|
+
|
|
759
|
+
**Google's address suggestions.** `googlePlacesProvider` is new in the primitives, and `ContactForm`'s `address` takes `googlePlacesKey` (and `googlePlacesOptions`): with a key, the address search offers Google's addresses under the "Google Maps" credit, a site's own `provider` and `attribution` still winning; with neither, the four fields stand alone. Nothing of Google's loads until the field is focused. It has not yet been run against Google's live API.
|
|
760
|
+
|
|
761
|
+
**The field label's tokens.** `.field label` reads `--field-label-font`, `--field-label-size`, `--field-label-weight`, `--field-label-case`, `--field-label-tracking`, and `--field-label-color`, as do the pickers' labels, and every field's border reads `--field-border`; a theme restyles every label in one place. A quiet note beside a label (`(optional)`) is `.field-hint`, in the body face. The errors read `--field-error`, `--field-error-border`, and `--field-error-bg`, each unset reading what it always did, so a theme sets its errors in the tone palette's bad (`--tone-bad`, `--tone-bad-bg`) without a rule of its own.
|
|
762
|
+
|
|
763
|
+
**Also new:** `InfoRows` in the sections, `ContactInfoCard`'s `layout="stacked"`, `PageHero`'s `surface="primary"` and `eyebrowRule`, a thanks with `lead: false` drawing no lead, `ExpandableText`'s `inline` (and the consent's `inline`), the error type, footnote, and hours tokens in the table below, and `.field.invalid` reaches a `select`. The pickers name their label's words and its hint apart (`aria-labelledby`), so their names keep the space between them where a page's HTML has lost it.
|
|
764
|
+
|
|
765
|
+
**One change on a site that changes nothing:** the contact form's footnote moved from an inline style to `.form-footnote` in the sheet, at the same size and spacing, so a site can restyle it; a site's own unlayered rule on bare `p` elements now reaches it, where the inline style used to win.
|
|
766
|
+
|
|
767
|
+
### Moving to 8.4.0
|
|
768
|
+
|
|
769
|
+
No API breaks. One optional config key is new, `phone.menuLabel`, which makes this a minor; everything else is a fix.
|
|
770
|
+
|
|
771
|
+
**The phone menu's words for a line that answers texts.** A site with no header numbers that wants "Call / Text" in its phone menu sets `phone.menuLabel` on the contact phone in its config; a site with header numbers sets `phones[].menuLabel` on each (`header.phones`), which still wins for those numbers; and `ContactInfoCard`'s row takes its own `phoneLabel`. Unset, each says "Call", as in 8.3.0.
|
|
772
|
+
|
|
773
|
+
**Changes on a site that changes nothing:**
|
|
774
|
+
|
|
775
|
+
1. **The footer with the hours in the brand column** (`footer.hoursPlacement: "brand"`). The brand column's floor is its content, the width its longest line takes whole (the lockup, the rating, an address line, the email, a row of the hours), where it was a fixed 17em, so a short brand block narrows and `--footer-brand-width` shares out the room; on a row that holds every column the brand column comes in by the difference and the link columns widen by their share (the stories' bakery: the brand column 295 to 281px on a 1200 wrap, each link column 4px wider). Each link column's floor is ten of its link text's size, so a site that sets `--footer-link-size` moves the floors with it; at the default nothing there moves. Where the brand column already took its own row, nothing moves.
|
|
776
|
+
2. **On a phone page whose sticky bar slides in after a scroll**, the closing bar is padded by the bar's height from the first measure rather than once the bar shows, so one jump straight to the end lands with the closing bar's last line above the bar; the page's end is that much longer from the start. A desktop reserves nothing, as before.
|
|
777
|
+
3. **`ContactInfoCard`'s email** breaks after the @ and before each dot on a narrow card, as the footer's does, where a long address broke inside a word. An address that fits reads as before.
|
|
778
|
+
|
|
779
|
+
The rest, in detail:
|
|
780
|
+
|
|
781
|
+
- **`StickyCTABar`'s `onSpaceChange`** hears the bar's height from the first measure wherever it can show, slid in or not, and 0 on a desktop; it no longer hears 0 and the height again as the bar slides out and in. Past the swap cap (three swaps in a row with nothing measured) the outgoing listener is still told 0 when it holds a height, and the arrival waits for the next measure; a listener that stores an object, made anew each render, now ends cut off at 0, where it ended holding the height by accident. Store a plain number, or memoize the listener.
|
|
782
|
+
- **Server reports follow an error's `cause`**, up to five deep, into Sentry's chained exceptions: innermost first, each cause under the `chained` mechanism linked to its parent, the thrown value `exception_id` 0 under the `generic` mechanism, handled. A cause's `code` (ENOTFOUND, ECONNRESET) leads its message when the message does not say it, a cause's words take the refusal's address and number scrub, every message is cut to 300 characters (the thrown value's too, which was not cut before), and a cycle ends the chain. An error with no cause is sent as before.
|
|
783
|
+
- **`refusalError`'s scrub** also takes a country code written with no plus sign (`1-555-555-0142`) and a trailing extension (`x12`, `ext. 12`), where an extension left the whole number in place, and no longer takes a dotted IPv4 address for a number. Dates, bare ids, a count beside a year, and status codes still stay.
|
|
784
|
+
- **`--hero-kicker-display`'s default** (`inline-block`) is declared in `defaults.css`, where it was written inline; nothing moves.
|
|
785
|
+
- `HoursRow` and `isMiss` have their doc comments back on them, and the routing tests check the 404 head and the pending view against an answer table written by hand.
|
|
786
|
+
|
|
734
787
|
### Moving to 8.3.0
|
|
735
788
|
|
|
736
789
|
No API breaks: every prop, config key, token, class, and export a site uses still works, and every addition is optional (a minor release for that reason). Three things change on screen all the same.
|
|
@@ -837,7 +890,7 @@ Nothing breaks: every addition is an optional prop, config key, token, or entry.
|
|
|
837
890
|
| `FullBleedVideo` | A silent looping clip edge to edge, the poster first and the clip only while on screen |
|
|
838
891
|
| `CalloutPanel` | Short callouts on the primary field, titles and subtitles each on a shared line |
|
|
839
892
|
| `LinkColumns` | Columns of links under a heading, a link's figure right aligned in tabular numerals |
|
|
840
|
-
| `PageHero` | The interior page opener on the alternate band; children sit under the lead |
|
|
893
|
+
| `PageHero` | The interior page opener on the alternate band; children sit under the lead; `surface="primary"` sets it on the primary fill, every word in `--on-primary`, and `eyebrowRule={false}` sets the kicker without its rule, as `Hero`'s (8.5.0) |
|
|
841
894
|
| `LogoMarquee` | A dark band of chips scrolling without end: credentials, clients, or press |
|
|
842
895
|
| `SplitSection` | The two column band: copy beside copy, or media beside copy. `ratio` is `even`, `narrow-first`, or `media`, a fixed 420px shot column and the gap a card row uses, so a photo beside copy lines up with a case study entry above it; `even` and `narrow-first` stack below 920px, `media` below 761px |
|
|
843
896
|
| `PricingBand` | A brand colored band with the price in a card beside it, informational by design |
|
|
@@ -858,8 +911,9 @@ Nothing breaks: every addition is an optional prop, config key, token, or entry.
|
|
|
858
911
|
| `Locations` | More than one address: the flagship's map beside a card for each location |
|
|
859
912
|
| `MapEmbed` | The map: a screenshot linking to directions, or a click to load facade over the live embed |
|
|
860
913
|
| `HoursTable` | Day rows with dashed rules and mono times |
|
|
861
|
-
| `ContactForm` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event |
|
|
862
|
-
| `ContactInfoCard` | A dark card of direct contact rows: call, email, visit, portal; the single phone row reads `phoneLabel`, default "Call" (8.3.0) |
|
|
914
|
+
| `ContactForm` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event; the service business's opt in fields (8.5.0), below |
|
|
915
|
+
| `ContactInfoCard` | A dark card of direct contact rows: call, email, visit, portal; the single phone row reads `phoneLabel`, default "Call" (8.3.0); `layout="stacked"` puts each label over its number, the numbers large (8.5.0) |
|
|
916
|
+
| `InfoRows` | Rows of a title over lines (an address) and an optional `detail` (an office's hours), with one action on the right as an icon over its words; the action is described by its row's title, and a directions link opens a new tab with `newTab` (8.5.0) |
|
|
863
917
|
| `FAQBrowser` | The help page: live search, a sticky `JumpRail` of categories with scroll spy, expand all, deep links; `contactHref` sets where the no match line points |
|
|
864
918
|
| `JumpRail` | Sticky in page pill tabs with scroll spy, used by `FAQBrowser` and on its own |
|
|
865
919
|
| `BlogIndex` | The post listing as a readable stack |
|
|
@@ -1075,7 +1129,7 @@ The sheets read a set of tokens beyond the theme's palette, type, radii, and lay
|
|
|
1075
1129
|
| `--grade-a` to `--grade-d`, each with `-line` and `-bg` | A `var(--tone-good)` (`#197538`) on its ground `var(--tone-good-bg)`, B `#8a5f00` on `#c99a1a`, ground `#fdf5dc`, C `var(--tone-warn)` (`#a84500`) on `#e8650a`, ground `#fff0e3`, D `var(--tone-bad)` (`#b3261e`) on its ground `var(--tone-bad-bg)` | The grade chip's words, rule, and ground, green to red whatever the brand is. A grade whose value is a tone's reads the tone, so a theme restating the tone moves both |
|
|
1076
1130
|
| `--weight-light`, `--weight-regular`, `--weight-medium`, `--weight-semibold`, `--weight-strong`, `--weight-bold`, `--weight-heavy` | 300, 400, 500, 600, 650, 700, 800 | Every font weight in every layered sheet. A font kit with only 400 and 700 maps each name to one of those (medium to 400, semibold, strong, and heavy to 700), so the browser synthesizes no weight |
|
|
1077
1131
|
| `--brand-mark-height` | `30px` (20px inside `ArtifactShell`) | The header mark's height, and a sent document's recipient mark; the width follows the image's own ratio |
|
|
1078
|
-
| `--sticky-cta-space` | `0px`, read in place | The room the phone's sticky bar
|
|
1132
|
+
| `--sticky-cta-space` | `0px`, read in place | The room the phone's sticky bar reserves wherever it can show, from the first measure and before it slides in, which the closing bar pads its foot by; `SiteShell` sets it on its root from `StickyCTABar`'s measurement, and a theme never does |
|
|
1079
1133
|
| `--header-max`, `--header-gutter` | `--max-width`, `--gutter`, read in place (on the bar, and on the light menu's top row, which sits where the bar's content does) | The bar's and the mega panel's width and side gutter, for a design that runs the bar wider than the content (8.1.0) |
|
|
1080
1134
|
| `--nav-open-bg`, `--nav-open-ink` | `--hover-tint` read in place, `currentColor` (the bar's words) | The open group's pill (8.1.0) |
|
|
1081
1135
|
| `--nav-phone-pad`, `--nav-phone-size` | `6px 16px 6px 12px`, `0.95rem` | The header phone pill's padding and its number's size (8.1.0) |
|
|
@@ -1086,7 +1140,7 @@ The sheets read a set of tokens beyond the theme's palette, type, radii, and lay
|
|
|
1086
1140
|
| `--hero-stack-gap` | none; unset, each gap keeps its own (18, 22, and 32px on the full hero, 12, 22, and 26px on the split hero), read in place | One gap between the hero's kicker and headline, headline and lead, and lead and actions, both layouts (8.2.0) |
|
|
1087
1141
|
| `--hero-gap-kicker`, `--hero-gap-lead`, `--hero-gap-actions` | `--hero-stack-gap` when set, else the gap's own (kicker to headline 18px, 12px on the split hero; headline to lead 22px; lead to actions 32px, 26px on the split hero), read in place | Each of the hero's three gaps on its own, both layouts (8.3.0) |
|
|
1088
1142
|
| `--hero-lead-leading` | `1.55` | The hero's lead paragraph's line height, both layouts (8.3.0) |
|
|
1089
|
-
| `--hero-kicker-display`, `--hero-kicker-leading` | `inline-block`, inherited, read in place | The hero's kicker as the inline block it has been, in a line box of the copy's leading that stands it taller than its type; `block` with a leading of its own lays it out as a block whose height is that leading, so a design's kicker takes its drawn height (8.3.0) |
|
|
1143
|
+
| `--hero-kicker-display`, `--hero-kicker-leading` | `inline-block`, declared in `defaults.css`; inherited, read in place | The hero's kicker as the inline block it has been, in a line box of the copy's leading that stands it taller than its type; `block` with a leading of its own lays it out as a block whose height is that leading, so a design's kicker takes its drawn height (8.3.0) |
|
|
1090
1144
|
| `--hero-actions-gap` | `14px` | The gap between the hero's actions, side by side or stacked (8.3.0) |
|
|
1091
1145
|
| `--hero-split-pad-block` | `--section-space`, read in place | The split hero's copy column's top and bottom padding; over a transparent bar from 900px the bar's height is added above it, as before (8.3.0) |
|
|
1092
1146
|
| `--hero-lead-size` | `clamp(1.05rem, 2.2vw, 1.35rem)` | The hero's lead paragraph (`subtitle`), both layouts; a split hero whose lead wraps too long sets it smaller (8.2.0) |
|
|
@@ -1106,6 +1160,17 @@ The sheets read a set of tokens beyond the theme's palette, type, radii, and lay
|
|
|
1106
1160
|
| `--menu-rule` | `--hairline`, read in place | The light phone menu's row dividers (8.2.0) |
|
|
1107
1161
|
| `--menu-badge-bg`, `--menu-badge-ink`, `--menu-cta-bg`, `--menu-cta-ink` | `--primary-fill`, `--on-primary` (as 8.0.0 drew them), read in place | The phone menu's badge and call to action. A theme whose sheet's ground equals its primary sets them to `--on-primary` and `--primary-ink`, or they vanish into the sheet (8.1.0) |
|
|
1108
1162
|
| `--link-columns-min` | `170px` | The least a `LinkColumns` column narrows to (8.1.0) |
|
|
1163
|
+
| `--field-label-font`, `--field-label-size`, `--field-label-weight`, `--field-label-case`, `--field-label-tracking`, `--field-label-color` | `--font-mono` read in place, `0.74rem`, the inherited weight read in place, `uppercase`, `0.1em`, `--neutral-600` read in place | Every form field's label: `.field label`, and the labels of `AddressSearch` and `MultiSelect`; a design with labels in the body face sets `--field-label-font: var(--font-sans)`, `--field-label-case: none`, `--field-label-tracking: 0`, and its own size and weight (8.5.0) |
|
|
1164
|
+
| `--field-border` | `--neutral-200`, read in place | Every form field's border, the pickers' and their lists' included (8.5.0) |
|
|
1165
|
+
| `--field-error-size`, `--field-error-weight`, `--field-error-border-width` | `0.82rem`, the inherited weight read in place, `1.5px` | A refused field's message size and weight, and its border's width (8.5.0) |
|
|
1166
|
+
| `--form-footnote-size` | `0.82rem` | The contact form's footnote size (8.5.0) |
|
|
1167
|
+
| `--field-padding-block`, `--field-padding-inline` | `14px`, `16px` | Every form field's padding, the services button and the address search with them, so a form stays even (the search keeps its 44px for the pin) (8.5.0) |
|
|
1168
|
+
| `--page-hero-kicker-font`, `--page-hero-kicker-size`, `--page-hero-kicker-weight`, `--page-hero-kicker-tracking` | `--font-mono`, and the eyebrow's own size, weight, and tracking, read in place | `PageHero`'s kicker, as `--hero-kicker-*` set the hero's (8.5.0) |
|
|
1169
|
+
| `--page-hero-title-size`, `--page-hero-pad-block` | `clamp(2.4rem, 7vw, 4.2rem)`; none, each side keeping its own padding, read in place | `PageHero`'s headline size, and its band's top and bottom padding alike (8.5.0) |
|
|
1170
|
+
| `--form-footnote-align`, `--form-footnote-link-weight`, `--form-footnote-link-color` | each the inherited value, read in place | The contact form's line under its button (`footnote`, now `.form-footnote` in the sheet rather than an inline style): its alignment, and its links' weight and color (8.5.0) |
|
|
1171
|
+
| `--hours-rule`, `--hours-time-font`, `--hours-time-size` | `1px dashed --neutral-200` and `--font-mono`, read in place; `0.85rem` | `HoursTable`'s line under each row (a whole border value: `1px solid var(--hairline)` for a solid hairline), and its times' face and size (8.5.0) |
|
|
1172
|
+
| `--expandable-ground` | `--surface`, read in place | The ground an inline `ExpandableText` control fades over at the end of its clamped line; a form in a card sets `var(--card)` (8.5.0) |
|
|
1173
|
+
| `--field-error`, `--field-error-border`, `--field-error-bg` | `--primary-ink` (then `--primary`), `--primary-deep`, `--primary-tint`, read in place | A refused field's message, a refused field's border, and the count of fields to fix over the form: its words, border, and ground. A design that sets errors in the tone palette sets `--field-error: var(--tone-bad)`, `--field-error-border: var(--tone-bad)`, and `--field-error-bg: var(--tone-bad-bg)` (8.5.0) |
|
|
1109
1174
|
| `--section-space`, `--block-gap`, `--card-min` | `clamp(56px, 9vw, 120px)`, `44px`, `240px` | The section rhythm where no `base.css` sets it (an app importing `components.css` alone); with `base.css` the settings under [Density](#density) win |
|
|
1110
1175
|
|
|
1111
1176
|
The review carousel's dots and a ghost button's outline already read neutral tokens a theme sets, so they take none of their own: the dots `--neutral-200` (hover `--neutral-500`, current `--ink`), the outline `--neutral-300` (hover `--ink`). Three more read a fallback in place: `--star-fill` colors every filled star (`StarRating`'s, which falls back to the text color, and the footer's rating, which falls back to `--review-gold`), `--font-condensed` sets a `CalloutPanel` title's face, and `--neutral-700` colors prose bodies (`ProseBlocks`, the blog's index and post), falling back to `--ink`. The tone palette (`--tone-good` and its kin) is declared with the defaults and described under [Page Components](#page-components).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a phone number or an email address is well formed enough to link.
|
|
3
|
+
* One check each, shared by the contact form (what it accepts) and the link
|
|
4
|
+
* primitives (what they link), so the two never disagree. Light by design:
|
|
5
|
+
* the build guard checks a site's configured numbers against Google's full
|
|
6
|
+
* numbering plan (`checkSiteContacts`, in the scripts); a page carries none
|
|
7
|
+
* of that.
|
|
8
|
+
*/
|
|
9
|
+
/** An email address: something, an @, something, a dot, something; no spaces. */
|
|
10
|
+
export declare const EMAIL_PATTERN: RegExp;
|
|
11
|
+
/** Whether an address is one to send to, ignoring the space around it. */
|
|
12
|
+
export declare function isEmail(value: string): boolean;
|
|
13
|
+
/** A number in E.164: a + and 8 to 15 digits, never opening on 0. */
|
|
14
|
+
export declare function isE164(value: string): boolean;
|
|
15
|
+
/** An extension after the number ("x12", "ext. 12", "extension 12"), which no dialer takes in E.164. */
|
|
16
|
+
export declare const EXTENSION: RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* A typed number in E.164, or null when it is not one to dial. A number
|
|
19
|
+
* typed with a + keeps its country code; ten digits, typed any common way,
|
|
20
|
+
* take the North American +1 (an area code never opens on 0 or 1); eleven
|
|
21
|
+
* that open on 1 take the +. An extension is dropped, so the link dials the
|
|
22
|
+
* main line while the words still show it. Anything else, letters included,
|
|
23
|
+
* is null.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toE164(value: string): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* What a dialer can still take from a typed number `toE164` cannot read:
|
|
28
|
+
* its digits, its extension dropped and a typed leading + kept. Null when
|
|
29
|
+
* there is no digit to dial.
|
|
30
|
+
*/
|
|
31
|
+
export declare function dialable(value: string): string | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a phone number or an email address is well formed enough to link.
|
|
3
|
+
* One check each, shared by the contact form (what it accepts) and the link
|
|
4
|
+
* primitives (what they link), so the two never disagree. Light by design:
|
|
5
|
+
* the build guard checks a site's configured numbers against Google's full
|
|
6
|
+
* numbering plan (`checkSiteContacts`, in the scripts); a page carries none
|
|
7
|
+
* of that.
|
|
8
|
+
*/
|
|
9
|
+
/** An email address: something, an @, something, a dot, something; no spaces. */
|
|
10
|
+
export const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
11
|
+
/** Whether an address is one to send to, ignoring the space around it. */
|
|
12
|
+
export function isEmail(value) {
|
|
13
|
+
return EMAIL_PATTERN.test(value.trim());
|
|
14
|
+
}
|
|
15
|
+
/** A number in E.164: a + and 8 to 15 digits, never opening on 0. */
|
|
16
|
+
export function isE164(value) {
|
|
17
|
+
return /^\+[1-9]\d{7,14}$/.test(value);
|
|
18
|
+
}
|
|
19
|
+
/** An extension after the number ("x12", "ext. 12", "extension 12"), which no dialer takes in E.164. */
|
|
20
|
+
export const EXTENSION = /\s*(?:,|;|#|x|ext\.?|extension)\s*\d+\s*$/i;
|
|
21
|
+
/**
|
|
22
|
+
* A typed number in E.164, or null when it is not one to dial. A number
|
|
23
|
+
* typed with a + keeps its country code; ten digits, typed any common way,
|
|
24
|
+
* take the North American +1 (an area code never opens on 0 or 1); eleven
|
|
25
|
+
* that open on 1 take the +. An extension is dropped, so the link dials the
|
|
26
|
+
* main line while the words still show it. Anything else, letters included,
|
|
27
|
+
* is null.
|
|
28
|
+
*/
|
|
29
|
+
export function toE164(value) {
|
|
30
|
+
const number = value.trim().replace(EXTENSION, "");
|
|
31
|
+
if (!number || /[^\d\s().+-]/.test(number) || number.lastIndexOf("+") > 0)
|
|
32
|
+
return null;
|
|
33
|
+
const digits = number.replace(/\D/g, "");
|
|
34
|
+
if (number.startsWith("+")) {
|
|
35
|
+
const e164 = `+${digits}`;
|
|
36
|
+
return isE164(e164) ? e164 : null;
|
|
37
|
+
}
|
|
38
|
+
if (/^[2-9]\d{9}$/.test(digits))
|
|
39
|
+
return `+1${digits}`;
|
|
40
|
+
if (/^1[2-9]\d{9}$/.test(digits))
|
|
41
|
+
return `+${digits}`;
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What a dialer can still take from a typed number `toE164` cannot read:
|
|
46
|
+
* its digits, its extension dropped and a typed leading + kept. Null when
|
|
47
|
+
* there is no digit to dial.
|
|
48
|
+
*/
|
|
49
|
+
export function dialable(value) {
|
|
50
|
+
const number = value.trim().replace(EXTENSION, "");
|
|
51
|
+
const digits = number.replace(/\D/g, "");
|
|
52
|
+
if (!digits)
|
|
53
|
+
return null;
|
|
54
|
+
return number.startsWith("+") ? `+${digits}` : digits;
|
|
55
|
+
}
|
|
@@ -82,13 +82,33 @@ function eventID() {
|
|
|
82
82
|
id += Math.floor(Math.random() * 16).toString(16);
|
|
83
83
|
return id;
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
/** How many causes deep a report follows a thrown value's `cause`. */
|
|
86
|
+
const CAUSE_DEPTH = 5;
|
|
87
|
+
/** The longest an exception's message is kept in a report. */
|
|
88
|
+
const EXCEPTION_VALUE_MAX = 300;
|
|
89
|
+
/**
|
|
90
|
+
* One thrown value as Sentry's exception: its type, message, and frames. A
|
|
91
|
+
* cause's words are upstream free text (a resolver's, a socket's), so they
|
|
92
|
+
* take the refusal's scrub, and its `code` (ENOTFOUND, ECONNRESET, a TLS
|
|
93
|
+
* error's) leads its message when the message does not already say it, so a
|
|
94
|
+
* DNS fault reads apart from a refused connection.
|
|
95
|
+
*/
|
|
96
|
+
function exceptionOne(error, isCause) {
|
|
97
|
+
const words = (text) => (isCause ? scrub(text) : text).slice(0, EXCEPTION_VALUE_MAX);
|
|
98
|
+
const shaped = error instanceof Error ||
|
|
99
|
+
(isCause &&
|
|
100
|
+
error !== null &&
|
|
101
|
+
typeof error === "object" &&
|
|
102
|
+
("message" in error || "code" in error));
|
|
103
|
+
if (shaped) {
|
|
104
|
+
const { name, message, stack, code } = error;
|
|
105
|
+
const text = typeof message === "string" ? message : "";
|
|
106
|
+
const coded = isCause && (typeof code === "string" || typeof code === "number") ? String(code) : "";
|
|
107
|
+
const value = coded && !text.includes(coded) ? (text ? `${coded}: ${text}` : coded) : text;
|
|
108
|
+
const frames = parseStack(typeof stack === "string" ? stack : undefined);
|
|
89
109
|
return {
|
|
90
|
-
type:
|
|
91
|
-
value:
|
|
110
|
+
type: typeof name === "string" && name ? name : "Error",
|
|
111
|
+
value: words(value),
|
|
92
112
|
...(frames.length ? { stacktrace: { frames } } : {}),
|
|
93
113
|
};
|
|
94
114
|
}
|
|
@@ -99,7 +119,48 @@ function exceptionOf(error) {
|
|
|
99
119
|
catch {
|
|
100
120
|
value = String(error);
|
|
101
121
|
}
|
|
102
|
-
return { type: "Error", value: value ?? String(error) };
|
|
122
|
+
return { type: "Error", value: words(value ?? String(error)) };
|
|
123
|
+
}
|
|
124
|
+
/** A value's `cause`, read so that a throwing getter reads as none. */
|
|
125
|
+
function causeOf(error) {
|
|
126
|
+
if (error === null || typeof error !== "object")
|
|
127
|
+
return undefined;
|
|
128
|
+
try {
|
|
129
|
+
return error.cause;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The thrown value and the causes under it, up to five deep, as Sentry's
|
|
137
|
+
* exception values: innermost first and the thrown value last, as Sentry
|
|
138
|
+
* orders a chain, each cause linked to the one it caused (`mechanism`
|
|
139
|
+
* `chained`, `source` `cause`, its own `exception_id` and its parent's
|
|
140
|
+
* `parent_id`), the thrown value `exception_id` 0 under the generic
|
|
141
|
+
* mechanism, handled, since the reporter is called by code that caught it.
|
|
142
|
+
* A cause met twice (a cycle) ends the chain. A value with no cause is the
|
|
143
|
+
* one exception it always was, with no mechanism.
|
|
144
|
+
*/
|
|
145
|
+
function exceptionsOf(error) {
|
|
146
|
+
const chain = [error];
|
|
147
|
+
const seen = new Set([error]);
|
|
148
|
+
for (let cause = causeOf(error); chain.length <= CAUSE_DEPTH; cause = causeOf(cause)) {
|
|
149
|
+
if (cause === undefined || cause === null || seen.has(cause))
|
|
150
|
+
break;
|
|
151
|
+
seen.add(cause);
|
|
152
|
+
chain.push(cause);
|
|
153
|
+
}
|
|
154
|
+
if (chain.length === 1)
|
|
155
|
+
return [exceptionOne(error, false)];
|
|
156
|
+
return chain
|
|
157
|
+
.map((value, id) => ({
|
|
158
|
+
...exceptionOne(value, id > 0),
|
|
159
|
+
mechanism: id === 0
|
|
160
|
+
? { type: "generic", handled: true, exception_id: 0 }
|
|
161
|
+
: { type: "chained", source: "cause", exception_id: id, parent_id: id - 1 },
|
|
162
|
+
}))
|
|
163
|
+
.reverse();
|
|
103
164
|
}
|
|
104
165
|
/**
|
|
105
166
|
* The request as a report may carry it: the method, the URL with no query
|
|
@@ -143,7 +204,7 @@ export function buildEnvelope(error, dsn, options = {}, now = new Date()) {
|
|
|
143
204
|
...(environment ? { environment } : {}),
|
|
144
205
|
tags: { runtime: runtime(), ...options.tags },
|
|
145
206
|
...(request ? { request } : {}),
|
|
146
|
-
exception: { values:
|
|
207
|
+
exception: { values: exceptionsOf(error) },
|
|
147
208
|
};
|
|
148
209
|
const header = { event_id: id, sent_at: now.toISOString(), dsn, sdk: SDK };
|
|
149
210
|
return [JSON.stringify(header), JSON.stringify({ type: "event" }), JSON.stringify(event)].join("\n");
|
|
@@ -244,15 +305,21 @@ export function reportServerErrorLater(error, options = {}) {
|
|
|
244
305
|
const ADDRESS = /[^\s@<>()[\]"',;:]+@[\p{L}\p{N}_-]+(?:\.[\p{L}\p{N}_-]+)+/gu;
|
|
245
306
|
/** A separator inside a phone number: a space, a dot, a slash, or any hyphen or dash. */
|
|
246
307
|
const SEP = "[\\s./\\u2010-\\u2015\\u2212-]";
|
|
308
|
+
/** One part of a dotted IPv4 address, 0 to 255. */
|
|
309
|
+
const OCTET = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)";
|
|
247
310
|
/**
|
|
248
|
-
* A run shaped like a phone number: an optional country code
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
311
|
+
* A run shaped like a phone number: an optional country code (a plus sign
|
|
312
|
+
* and one to three digits, or one to three digits and a separator, as in
|
|
313
|
+
* 1-555-555-0142), then an area code in parentheses and the number after
|
|
314
|
+
* it, or at least three groups of digits joined by separators, the last of
|
|
315
|
+
* three or four digits, or a plus sign and seven to fifteen digits run
|
|
316
|
+
* together (E.164); any of them may close on an extension (x12, ext. 12). A
|
|
317
|
+
* date (2026-11-23), a bare id (12345678), a count beside a year (120
|
|
318
|
+
* 2026), a status (429), and a dotted IPv4 address (192.168.10.200) are none
|
|
319
|
+
* of these, and stay. A run starts at a word's edge and never just after a
|
|
320
|
+
* digit's dot, so no tail of a longer dotted run is taken for one.
|
|
254
321
|
*/
|
|
255
|
-
const PHONE = new RegExp(`(?<![\\w+-])
|
|
322
|
+
const PHONE = new RegExp(`(?<![\\w+-])(?<!\\d\\.)(?:\\+\\d{7,15}|(?!(?:${OCTET}\\.){3}${OCTET}(?![\\w.-]))(?:\\+\\d{1,3}${SEP}?|\\d{1,3}${SEP})?(?:\\(\\d{2,4}\\)${SEP}?\\d{2,4}(?:${SEP}\\d{3,4})?|\\d{2,4}(?:${SEP}\\d{2,4}){1,2}${SEP}\\d{3,4}))(?:\\s*(?:x|ext\\.?|extension)\\s*\\d{1,6})?(?![\\w-])`, "giu");
|
|
256
323
|
/** A refusal's field with every address and phone number in it replaced. */
|
|
257
324
|
function scrub(text) {
|
|
258
325
|
return text.replace(ADDRESS, "[address]").replace(PHONE, "[number]");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every problem with the numbers and addresses in `value`, each naming its
|
|
3
|
+
* field (`site.header.phones[1].display`), empty when all is sound. Judges
|
|
4
|
+
* only what it is sure is a contact:
|
|
5
|
+
*
|
|
6
|
+
* - a phone is any object holding a string `e164` and `display` (the
|
|
7
|
+
* package's `Phone`, `HeaderPhone`, `ContactPhone`) or `phoneE164` and
|
|
8
|
+
* `phoneDisplay` (a `Locations` entry), wherever it sits: the number must
|
|
9
|
+
* be valid in E.164 for its country and the display must read as it;
|
|
10
|
+
* - an address is a string at one of the config's known address paths
|
|
11
|
+
* (`email`, `gate.contactEmail`, `analytics.identify.email`);
|
|
12
|
+
* - a `tel:` href must reduce, separators aside, to a valid number, and a
|
|
13
|
+
* `mailto:` href must write to an address.
|
|
14
|
+
*
|
|
15
|
+
* A value seen twice (a config that refers to itself) is walked once.
|
|
16
|
+
*/
|
|
17
|
+
export declare function contactProblems(value: unknown, path?: string): string[];
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The build time check on a site's phone numbers and email addresses: every
|
|
3
|
+
* number the package draws as a link has an `e164` that is a real number
|
|
4
|
+
* for its country, and a `display` that reads as the same number; every
|
|
5
|
+
* address matches the form's pattern. A number that fails ships as a dead or
|
|
6
|
+
* wrong call link on every page, so the build stops and names the field.
|
|
7
|
+
*
|
|
8
|
+
* Google's numbering plan (`libphonenumber-js`, its complete `max` metadata)
|
|
9
|
+
* runs here and in tests only, never in a page: nothing a page bundles
|
|
10
|
+
* imports this file (tst/phone-library-stays-out.test.ts holds that). The
|
|
11
|
+
* browser keeps its light check (`toE164`, `src/lib/contactLinks.ts`).
|
|
12
|
+
*
|
|
13
|
+
* It is sure of what it judges: phones by their shape (an `e164` beside a
|
|
14
|
+
* `display`), addresses only at the config's known paths, and `tel:` and
|
|
15
|
+
* `mailto:` hrefs anywhere, so a site's words are never mistaken for a
|
|
16
|
+
* contact and a valid site never fails.
|
|
17
|
+
*
|
|
18
|
+
* `atelic-check-base-path`, a marketing site's last build step and the one
|
|
19
|
+
* that already reads its config, runs `contactProblems` over the `site`
|
|
20
|
+
* export. A site passing numbers as props outside its config (a contact
|
|
21
|
+
* card's `phones`) calls the same function from its own test:
|
|
22
|
+
*
|
|
23
|
+
* import { contactProblems } from "@atelic-action/ui/scripts/contacts";
|
|
24
|
+
* expect(contactProblems({ phones })).toEqual([]);
|
|
25
|
+
*/
|
|
26
|
+
import parsePhoneNumber, { isSupportedCountry, } from "libphonenumber-js/max";
|
|
27
|
+
import { isEmail } from "../lib/contactLinks.js";
|
|
28
|
+
/** A number read against a country, or undefined when it is not one; never throws. */
|
|
29
|
+
function parse(text, country) {
|
|
30
|
+
try {
|
|
31
|
+
return parsePhoneNumber(text, country);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The country a number written without its + is read against: the
|
|
39
|
+
* config's own (`address.country`, a two letter code), else the US, where
|
|
40
|
+
* every site so far does business.
|
|
41
|
+
*/
|
|
42
|
+
function countryOf(value) {
|
|
43
|
+
const country = isRecord(value) && isRecord(value.address) ? value.address.country : undefined;
|
|
44
|
+
const code = typeof country === "string" ? country.trim().toUpperCase() : "";
|
|
45
|
+
return isSupportedCountry(code) ? code : "US";
|
|
46
|
+
}
|
|
47
|
+
/** The problem with one number, or null when it is sound. */
|
|
48
|
+
function phoneProblem(e164, display, country) {
|
|
49
|
+
const number = e164.startsWith("+") ? parse(e164, country) : undefined;
|
|
50
|
+
if (!number?.isValid() || number.number !== e164) {
|
|
51
|
+
return `e164 "${e164}" is not a valid number in E.164 (a + and the country code, digits only)`;
|
|
52
|
+
}
|
|
53
|
+
const shown = parse(display, number.country ?? country);
|
|
54
|
+
if (shown?.number !== e164) {
|
|
55
|
+
return `display "${display}" does not read as ${e164}`;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60
|
+
/**
|
|
61
|
+
* The config's known email addresses, by path from the walk's root (a
|
|
62
|
+
* `SiteConfig` or an `ArtifactConfig`). A string is judged as an address
|
|
63
|
+
* only here or as a `mailto:` href, never by its key's name alone, so words
|
|
64
|
+
* such as a label reading "Email" are left alone.
|
|
65
|
+
*/
|
|
66
|
+
const EMAIL_PATHS = new Set([
|
|
67
|
+
"email",
|
|
68
|
+
"gate.contactEmail",
|
|
69
|
+
"contactEmail",
|
|
70
|
+
"analytics.identify.email",
|
|
71
|
+
]);
|
|
72
|
+
/**
|
|
73
|
+
* A `tel:` href's number, decoded, with RFC 3966's visual separators (- .
|
|
74
|
+
* ( ) and spaces) and any parameters (";ext=12") taken out.
|
|
75
|
+
*/
|
|
76
|
+
const telNumber = (href) => decoded(href.slice("tel:".length))
|
|
77
|
+
.split(";")[0]
|
|
78
|
+
?.replace(/[-.()\s]/g, "") ?? "";
|
|
79
|
+
/** A percent encoded address, decoded; one too malformed to decode, as given. */
|
|
80
|
+
function decoded(address) {
|
|
81
|
+
try {
|
|
82
|
+
return decodeURIComponent(address);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return address;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Every problem with the numbers and addresses in `value`, each naming its
|
|
90
|
+
* field (`site.header.phones[1].display`), empty when all is sound. Judges
|
|
91
|
+
* only what it is sure is a contact:
|
|
92
|
+
*
|
|
93
|
+
* - a phone is any object holding a string `e164` and `display` (the
|
|
94
|
+
* package's `Phone`, `HeaderPhone`, `ContactPhone`) or `phoneE164` and
|
|
95
|
+
* `phoneDisplay` (a `Locations` entry), wherever it sits: the number must
|
|
96
|
+
* be valid in E.164 for its country and the display must read as it;
|
|
97
|
+
* - an address is a string at one of the config's known address paths
|
|
98
|
+
* (`email`, `gate.contactEmail`, `analytics.identify.email`);
|
|
99
|
+
* - a `tel:` href must reduce, separators aside, to a valid number, and a
|
|
100
|
+
* `mailto:` href must write to an address.
|
|
101
|
+
*
|
|
102
|
+
* A value seen twice (a config that refers to itself) is walked once.
|
|
103
|
+
*/
|
|
104
|
+
export function contactProblems(value, path = "site") {
|
|
105
|
+
return walk(value, path, "", new WeakSet(), countryOf(value));
|
|
106
|
+
}
|
|
107
|
+
function walk(value, path, at, seen, country) {
|
|
108
|
+
if (typeof value === "object" && value !== null) {
|
|
109
|
+
if (seen.has(value))
|
|
110
|
+
return [];
|
|
111
|
+
seen.add(value);
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(value)) {
|
|
114
|
+
return value.flatMap((item, index) => walk(item, `${path}[${index}]`, at, seen, country));
|
|
115
|
+
}
|
|
116
|
+
// A React element (words a config may hold as JSX) is copy, never a contact.
|
|
117
|
+
if (!isRecord(value) || "$$typeof" in value)
|
|
118
|
+
return [];
|
|
119
|
+
const problems = [];
|
|
120
|
+
for (const [e164Key, displayKey] of [
|
|
121
|
+
["e164", "display"],
|
|
122
|
+
["phoneE164", "phoneDisplay"],
|
|
123
|
+
]) {
|
|
124
|
+
const e164 = value[e164Key];
|
|
125
|
+
const display = value[displayKey];
|
|
126
|
+
if (typeof e164 === "string" && typeof display === "string") {
|
|
127
|
+
const problem = phoneProblem(e164, display, country);
|
|
128
|
+
if (problem)
|
|
129
|
+
problems.push(`${path}: ${problem}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const [key, item] of Object.entries(value)) {
|
|
133
|
+
const field = `${path}.${key}`;
|
|
134
|
+
const where = at ? `${at}.${key}` : key;
|
|
135
|
+
if (typeof item !== "string") {
|
|
136
|
+
// An array keeps its parent's place: header.phones[0] is under header.phones.
|
|
137
|
+
problems.push(...walk(item, field, where, seen, country));
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// An empty address is none (a site without a public one), not a bad one.
|
|
141
|
+
if (EMAIL_PATHS.has(where) && item.trim() && !isEmail(item)) {
|
|
142
|
+
problems.push(`${field}: "${item}" is not an email address`);
|
|
143
|
+
}
|
|
144
|
+
if (item.startsWith("tel:")) {
|
|
145
|
+
// A national number (no +) is read against the config's country, as a
|
|
146
|
+
// dialer reads it; only one that is not a plausible number fails.
|
|
147
|
+
const number = parse(telNumber(item), country);
|
|
148
|
+
if (!number?.isPossible())
|
|
149
|
+
problems.push(`${field}: "${item}" does not dial a number`);
|
|
150
|
+
}
|
|
151
|
+
if (item.startsWith("mailto:")) {
|
|
152
|
+
// RFC 6068: one address or several, comma separated, before the query,
|
|
153
|
+
// or in its to= when nothing comes before it.
|
|
154
|
+
const [head = "", query = ""] = item.slice("mailto:".length).split("?");
|
|
155
|
+
const to = decoded(head) || (new URLSearchParams(query).get("to") ?? "");
|
|
156
|
+
if (!to.split(",").every((address) => isEmail(address))) {
|
|
157
|
+
problems.push(`${field}: "${item}" does not write to an address`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return problems;
|
|
162
|
+
}
|