highsoft-ui 1.0.178 → 1.0.179

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/CLAUDE.md CHANGED
@@ -1117,6 +1117,73 @@ heading, provide an appropriate accessible section label and distinct CTA label
1117
1117
  through `action.buttonProps` as needed. Preserve reduced-motion handling and
1118
1118
  keyboard operation of the media control.
1119
1119
 
1120
+ ### ProductNotice
1121
+ Slim, closable product notice on a brand surface: a product icon, a semibold run-in title and its description, up to two buttons and a close button. Under 760px of its own width it switches to a compact layout. Reports views, clicks and closes to the page's tracker (see [Tracking](#tracking)). Figma "orbit Banner shop" in the Kartoffel shop file (wide 4055:77089, mobile 4061:42944).
1122
+ ```tsx
1123
+ import { Mail01 } from '@untitled-ui/icons-react'
1124
+
1125
+ <ProductNotice
1126
+ product="orbit"
1127
+ title="Highcharts Orbit is here."
1128
+ description="It’s sold through our sales team, so you won’t find it in the configurator below."
1129
+ compactDescription="It’s sold through our sales team."
1130
+ actions={[
1131
+ { label: 'Explore Orbit', href: '/products/orbit' },
1132
+ { label: 'Contact sales', href: '/contact-sales', iconRight: <Mail01 /> }
1133
+ ]}
1134
+ tracking={{ id: 'orbit-shop-notice', name: 'Highcharts Orbit (shop)' }}
1135
+ />
1136
+
1137
+ // One button, no close
1138
+ <ProductNotice product="stock" title="…" description="…" actions={[{ label: 'Read more', href: '…' }]} closable={false} />
1139
+
1140
+ // Any other logo in place of the product icon: it then needs a tracking id (or tracking={false})
1141
+ <ProductNotice icon={<FrameworkIcon icon="python" size={24} />} title="…" tracking={{ id: 'python-notice' }} />
1142
+ ```
1143
+ - **`product`:** a `ProductIconName` (default `orbit`), drawn as a monochrome 24px `ProductIcon`; also the default `promotion_id` and `item_id`. **`icon`** replaces it with any element (a `FrameworkIcon`, an `<img>`); it sits in an `aria-hidden` slot, so it is decorative — the title names the product. `product` and `icon` are exclusive, and with `icon` the types require `tracking={{ id }}` or `tracking={false}`, so a Python notice can't report as Orbit.
1144
+ - **`title`** / **`description`:** one 16px paragraph (`Typography` 200, 130%), the title in a semibold `<strong>`, the description regular. **`compactDescription`** is the shorter text for the compact layout (defaults to `description`).
1145
+ - **`actions`:** zero, one or two `{ label, href?, onClick?, iconLeft?, iconRight?, buttonProps?, tracking? }`, rendered as transparent `Button`s; variant and size are fixed by the design. A third item is ignored. `label` is a string because it is also the tracked `link_text`. `buttonProps` can't override the variant, size, `href` or the tracked click; an `onClick` in it still runs after the notice's own handler.
1146
+ - **`closable`** (default `true`) shows a plain icon-only `Button` with `X`; clicking it hides the notice and calls **`onClose`**. Nothing is remembered: to keep it closed across page loads, store that in `onClose` and stop rendering it. **`closeLabel`** (default `'Close'`) is its accessible name.
1147
+ - **Wide layout:** `Box` (1px border, 8px radius, `--shadow-size-100`, 12px padding, 20px from the left edge to the content): icon and text, then size-100 buttons and close on the same row.
1148
+ - **Compact layout** (under 760px, Figma mobile): no icon and no shadow, 12px padding all round, the text with a size-200 close top right, and size-200 buttons on their own row below. It is a **container query** on the notice's own width, so a narrow column gets it too, not only a phone. Both button sets are rendered and the hidden one is `display: none`; so each action renders twice — don't put an `id` in `buttonProps`.
1149
+ - **Colours** are the component's own light/dark pair from primitives, as in PromoBanner: light brand-200 surface, brand-300 stroke, brand-1000 text; dark brand-1000 surface, brand-900 stroke, brand-50 text (`--product-notice-bg` / `-border` / `-text`, remapped under `[data-theme='dark']`). The semantic brand tokens would give brand-800 and brand-600 in dark.
1150
+
1151
+ **Tracking.** Events go to the page's tracker: a `TrackingProvider` at the app root, or the notice's own **`tracker`** prop (see [Tracking](#tracking)). With neither, nothing is sent. The default event names are GA4's promotion events (`dismiss_promotion` is a custom one):
1152
+
1153
+ | Interaction | Default event | Extra params |
1154
+ |---|---|---|
1155
+ | half the notice on screen (once per mount) | `view_promotion` | `items` |
1156
+ | a button click | `select_promotion` | `items`, `link_text`, `link_url` |
1157
+ | close | `dismiss_promotion` | — |
1158
+
1159
+ Every event carries `promotion_id` (`tracking.id`, default the `product`) and `promotion_name` (`tracking.name`, default the id). View and click also carry GA4's **`items`**: GA4 requires them on `view_promotion`, and the Promotions report leaves out a `select_promotion` without them. The default is the product, `[{ item_id: 'orbit' }]` (with a custom `icon`, the tracking id); pass `tracking.items` for your own (each needs an `item_id` or an `item_name`), or `false` for none. Change any of it through **`tracking`**:
1160
+ ```tsx
1161
+ <ProductNotice
1162
+ tracking={{
1163
+ id: 'orbit-shop-notice',
1164
+ events: { view: false, close: 'shop_notice_close' }, // rename or skip an event
1165
+ items: [{ item_id: 'orbit', item_name: 'Highcharts Orbit' }], // GA4 items for view and click
1166
+ params: { creative_slot: 'shop_configurator' } // sent with every event
1167
+ }}
1168
+ tracker={({ event, params }) => Google.analytics({ event, ...params })} // this notice only, instead of the provider's
1169
+ actions={[
1170
+ { label: 'Explore Orbit', href: '…', tracking: false }, // this button isn't tracked
1171
+ { label: 'Contact sales', href: '…', tracking: { event: 'generate_lead', params: { lead_source: 'orbit_shop_notice' } } }
1172
+ ]}
1173
+ />
1174
+
1175
+ <ProductNotice tracking={false} … /> // send nothing
1176
+ ```
1177
+ Params merge in this order, later winning: `promotion_id`/`promotion_name`/`items` → `link_text`/`link_url` → `tracking.params` → the button's `tracking.params`. Undefined values are dropped. The tracker receives `{ event, params }`. An inline `tracking` object doesn't restart the view observer; the latest config is read when an event fires.
1178
+
1179
+ **Accessibility:**
1180
+ - The buttons are real `Button`s (links when `href` is set) with the shared focus ring; the close button is named by `closeLabel`. Tab order follows the layout: the buttons then close in the wide row; close then the buttons in the compact one, top to bottom.
1181
+ - The layout not shown is `display: none`, so assistive technology and the tab order only ever meet one set of buttons and one description.
1182
+ - The icon is decorative (`aria-hidden`); the title carries the product name.
1183
+ - Text is brand-1000 on brand-200 in light and brand-50 on brand-1000 in dark, both well above 4.5:1.
1184
+ - Closing removes the notice, so focus falls back to the page; if the notice sits before important content, move focus there in `onClose`.
1185
+ - Nothing animates.
1186
+
1120
1187
  ### TableOfContents
1121
1188
  "On this page" navigation for an article: a rule down the left, a semibold title and one link per heading. Uncontrolled by default with a built-in scroll spy; pass `activeId` to drive the highlight yourself.
1122
1189
 
@@ -1153,6 +1220,33 @@ const items: TableOfContentsItem[] = [
1153
1220
  - Hover and current states pair the bar with a text-colour change, so neither rests on colour alone. The bar's width grows on the bounce token and is instant under `prefers-reduced-motion: reduce`, which leaves nothing animating; colours switch instantly in every mode. The spy only swaps which row is current.
1154
1221
  - Rows are 18px tall on a 25px pitch: under the 24px minimum of WCAG 2.5.8, but the pitch keeps every target at least 24px from the next, which is the criterion's spacing exception. Nested rows indent without shrinking.
1155
1222
 
1223
+ ## Tracking
1224
+
1225
+ Components that report interactions (currently `ProductNotice`) don't know which analytics a site runs. They hand each event, `{ event, params }` in GA4 shape, to a **tracker**, and the site chooses the tracker. Set it once at the app root:
1226
+
1227
+ ```tsx
1228
+ import { TrackingProvider, dataLayerTracker, gtagTracker } from 'highsoft-ui'
1229
+
1230
+ // Google Tag Manager (highcharts.com): pushes { event, ...params } onto window.dataLayer
1231
+ <TrackingProvider tracker={dataLayerTracker()}>…</TrackingProvider>
1232
+
1233
+ // GTM with a renamed data layer
1234
+ <TrackingProvider tracker={dataLayerTracker({ name: 'siteLayer' })}>…</TrackingProvider>
1235
+
1236
+ // gtag.js straight to GA4, routed to this site's measurement ID
1237
+ <TrackingProvider tracker={gtagTracker({ sendTo: 'G-XXXXXXX' })}>…</TrackingProvider>
1238
+
1239
+ // The site's own wrapper, which keeps its consent check (the shop's Cookiebot-gated Google.analytics)
1240
+ <TrackingProvider tracker={({ event, params }) => Google.analytics({ event, ...params })}>…</TrackingProvider>
1241
+ ```
1242
+ - **`Tracker`** is `(event: TrackingEvent) => void`; any function works, so a site can also log, sample, or send to two places at once.
1243
+ - A component's own **`tracker`** prop beats the provider. No provider and no prop: no events are sent.
1244
+ - `dataLayerTracker` pushes everything at the top level, `items` included: `{ event, promotion_id, items, … }`. Google's GTM ecommerce examples nest them under an `ecommerce` key, which is what a GA4 event tag's "Send Ecommerce data" option reads; with this tracker, map `items` as an event parameter in the tag instead.
1245
+ - **Consent belongs to the site.** `dataLayerTracker`/`gtagTracker` push unconditionally; GTM consent mode or the site's wrapper decides what is sent. Never point a consent-gated site at the raw adapters.
1246
+ - Trackers run inside a `try/catch`: a broken analytics script logs an error but never blocks the click or the navigation. The adapters do nothing during SSR, and `gtagTracker` does nothing until the gtag snippet has run.
1247
+ - `useTracker(prop?)` returns the resolved, never-throwing tracker, for new components that track.
1248
+ - Functions can't cross the Next.js Server → Client Component boundary: create the tracker in a client component (e.g. a `'use client'` providers file at the root).
1249
+
1156
1250
  ## Hooks
1157
1251
 
1158
1252
  ### useSuccessFlash
@@ -0,0 +1,144 @@
1
+ "use client";
2
+ import { useTracker as e } from "./tracking.js";
3
+ import { t } from "./Box-BZgeSeCV.js";
4
+ import { t as n } from "./clsx-BWCAbrjV.js";
5
+ import { r } from "./esm-CqcQTziN.js";
6
+ import { t as i } from "./Button-DtCIaVhq.js";
7
+ import { n as a } from "./Typography-DI1AkqiO.js";
8
+ import { t as o } from "./ProductIcon-Cr6E2K9a.js";
9
+ import { trackProductNotice as s } from "./components/ProductNotice/tracking.js";
10
+ import { useEffect as c, useRef as l, useState as u } from "react";
11
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
12
+ var m = {
13
+ actions: "hJxRhW_actions",
14
+ compactActions: "hJxRhW_compactActions",
15
+ compactClose: "hJxRhW_compactClose",
16
+ compactText: "hJxRhW_compactText",
17
+ content: "hJxRhW_content",
18
+ icon: "hJxRhW_icon",
19
+ message: "hJxRhW_message",
20
+ notice: "hJxRhW_notice",
21
+ "product-notice": "hJxRhW_product-notice",
22
+ surface: "hJxRhW_surface",
23
+ title: "hJxRhW_title",
24
+ wideActions: "hJxRhW_wideActions",
25
+ wideText: "hJxRhW_wideText"
26
+ };
27
+ //#endregion
28
+ //#region lib/components/ProductNotice/index.tsx
29
+ function h({ product: h, icon: g, title: _, description: v, compactDescription: y, actions: b, closable: x = !0, onClose: S, closeLabel: C = "Close", tracking: w, tracker: T, className: E, ...D }) {
30
+ let O = l(null), [k, A] = u(!1), j = e(T), M = g ? void 0 : h ?? "orbit", N = l({
31
+ tracking: w,
32
+ promoted: M,
33
+ send: j
34
+ });
35
+ if (c(() => {
36
+ N.current = {
37
+ tracking: w,
38
+ promoted: M,
39
+ send: j
40
+ };
41
+ }), c(() => {
42
+ let e = O.current;
43
+ if (!e) return;
44
+ let t = !1, n = () => {
45
+ t || (t = !0, s(N.current.send, N.current.tracking, "view", N.current.promoted));
46
+ };
47
+ if (typeof IntersectionObserver > "u") {
48
+ n();
49
+ return;
50
+ }
51
+ let r = new IntersectionObserver((e) => {
52
+ e.some((e) => e.isIntersecting) && (r.disconnect(), n());
53
+ }, { threshold: .5 });
54
+ return r.observe(e), () => r.disconnect();
55
+ }, []), k) return null;
56
+ let P = () => {
57
+ s(j, w, "close", M), A(!0), S?.();
58
+ }, F = (b ?? []).slice(0, 2).filter((e) => !!e), I = (e) => F.map((t, n) => {
59
+ let { onClick: r, ...a } = t.buttonProps ?? {};
60
+ return /* @__PURE__ */ f(i, {
61
+ ...a,
62
+ variant: "transparent",
63
+ size: e,
64
+ href: t.href,
65
+ iconLeft: t.iconLeft,
66
+ iconRight: t.iconRight,
67
+ onClick: (e) => {
68
+ t.tracking !== !1 && s(j, w, "click", M, {
69
+ ...t.tracking,
70
+ defaults: {
71
+ link_text: t.label,
72
+ link_url: t.href
73
+ }
74
+ }), t.onClick?.(e), r?.(e);
75
+ },
76
+ children: t.label
77
+ }, `${t.label}-${n}`);
78
+ }), L = (e) => /* @__PURE__ */ f(i, {
79
+ variant: "plain",
80
+ size: e,
81
+ "aria-label": C,
82
+ onClick: P,
83
+ children: /* @__PURE__ */ f(r, {})
84
+ });
85
+ return /* @__PURE__ */ f("div", {
86
+ ref: O,
87
+ className: n("hsui-product-notice", m.notice, E),
88
+ ...D,
89
+ children: /* @__PURE__ */ p(t, {
90
+ border: !0,
91
+ radius: 8,
92
+ padding: 300,
93
+ shadow: 100,
94
+ className: m.surface,
95
+ children: [
96
+ /* @__PURE__ */ p("div", {
97
+ className: m.content,
98
+ children: [/* @__PURE__ */ f("span", {
99
+ className: m.icon,
100
+ "aria-hidden": "true",
101
+ children: g ?? /* @__PURE__ */ f(o, {
102
+ icon: M ?? "orbit",
103
+ theme: "monochrome",
104
+ size: 24
105
+ })
106
+ }), /* @__PURE__ */ p(a, {
107
+ as: "p",
108
+ size: 200,
109
+ className: m.message,
110
+ style: { "--hsui-typography-color": "var(--product-notice-text)" },
111
+ children: [
112
+ _ != null && /* @__PURE__ */ f("strong", {
113
+ className: m.title,
114
+ children: _
115
+ }),
116
+ _ != null && (v != null || y != null) && " ",
117
+ y == null ? v : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("span", {
118
+ className: m.wideText,
119
+ children: v
120
+ }), /* @__PURE__ */ f("span", {
121
+ className: m.compactText,
122
+ children: y
123
+ })] })
124
+ ]
125
+ })]
126
+ }),
127
+ (F.length > 0 || x) && /* @__PURE__ */ p("div", {
128
+ className: n(m.actions, m.wideActions),
129
+ children: [I(100), x && L(100)]
130
+ }),
131
+ x && /* @__PURE__ */ f("div", {
132
+ className: m.compactClose,
133
+ children: L(200)
134
+ }),
135
+ F.length > 0 && /* @__PURE__ */ f("div", {
136
+ className: n(m.actions, m.compactActions),
137
+ children: I(200)
138
+ })
139
+ ]
140
+ })
141
+ });
142
+ }
143
+ //#endregion
144
+ export { h as t };
@@ -0,0 +1,4 @@
1
+ import "../../tracking.js";
2
+ import { PRODUCT_NOTICE_EVENTS as e } from "./tracking.js";
3
+ import { t } from "../../ProductNotice-CtgDdo5_.js";
4
+ export { e as PRODUCT_NOTICE_EVENTS, t as ProductNotice };
@@ -0,0 +1,25 @@
1
+ //#region lib/components/ProductNotice/tracking.ts
2
+ var e = {
3
+ view: "view_promotion",
4
+ click: "select_promotion",
5
+ close: "dismiss_promotion"
6
+ };
7
+ function t(t, n, r, i, a) {
8
+ if (n === !1) return;
9
+ let o = a?.event ?? n?.events?.[r] ?? e[r];
10
+ if (o === !1) return;
11
+ let s = n?.id ?? i, c = i ?? s, l = r === "close" || n?.items === !1 ? void 0 : n?.items ?? (c ? [{ item_id: c }] : void 0), u = {
12
+ promotion_id: s,
13
+ promotion_name: n?.name ?? s,
14
+ items: l,
15
+ ...a?.defaults,
16
+ ...n?.params,
17
+ ...a?.params
18
+ };
19
+ t({
20
+ event: o,
21
+ params: Object.fromEntries(Object.entries(u).filter(([, e]) => e !== void 0))
22
+ });
23
+ }
24
+ //#endregion
25
+ export { e as PRODUCT_NOTICE_EVENTS, t as trackProductNotice };