@htmlbricks/hb-contact-item 0.71.35 → 0.71.36

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 (3) hide show
  1. package/README.md +97 -19
  2. package/manifest.json +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,9 @@
4
4
 
5
5
  ### What it does
6
6
 
7
- Single contact line (mutually exclusive props): phone, postal address, email, website, or social network. Renders a Bootstrap Icon and optional visible text; JSON `config` toggles icons (filled/outline), label text, and whether clicks dispatch `contactclick` with `{ action, options }` vs opening a window (maps URL, `mailto`, external site, or social page).
7
+ Renders a single contact row: one of **phone**, **postal address**, **email**, **website**, or **social** profile. Each variant shows a Bootstrap Icon (when enabled) and optional label text. Behavior is controlled by a JSON **`config`** object: show or hide the icon column, show or hide text, and choose whether a click should **`window.open`** a URL or dispatch a **`contactClick`** custom event with the active mode and payload.
8
+
9
+ Evaluation order is fixed: if multiple inputs are present, **phone** wins, then **social**, **address**, **email**, and **site**. In practice you should pass only one contact type per instance.
8
10
 
9
11
  ### Custom element
10
12
 
@@ -12,35 +14,111 @@ Single contact line (mutually exclusive props): phone, postal address, email, we
12
14
 
13
15
  ### Attributes / props (snake_case)
14
16
 
15
- | Property | Type | Notes |
17
+ Web component attributes are **strings**. Objects must be passed as **JSON** (single-line attribute values are typical). Property names on the element use **snake_case**; keys **inside** the JSON payloads follow the TypeScript shapes below (camelCase where noted).
18
+
19
+ | Attribute | Type | Description |
16
20
  | --- | --- | --- |
17
- | `id` | string (optional) | Element identifier. |
18
- | `style` | string (optional) | Inline style string. |
19
- | `phone` | object (optional) | JSON `IPhone`: number, callOnClick?. |
20
- | `address` | object (optional) | JSON `IAddress`: mapUri?, latLang?, address, shortAddress?. |
21
- | `email` | object (optional) | JSON `IEmail`: mailLink?, address. |
22
- | `site` | object (optional) | JSON `ISite`: label?, uri?, open?. |
23
- | `social` | object (optional) | JSON `ISocial`: label?, pageUri?, name. |
24
- | `config` | object (optional) | JSON `IConfig`: icon?.fill, text?, dispatcher?. |
21
+ | `id` | string (optional) | Host-controlled identifier; forwarded like any HTML id when set by the runtime. |
22
+ | `style` | string (optional) | Inline style string on the host element. |
23
+ | `phone` | JSON (optional) | **`IPhone`**: `number` (required), `callOnClick` (optional boolean). The value is included in `contactClick` detail; the component does not open `tel:` URLs by itself—handle dialing or navigation in your listener if needed. |
24
+ | `address` | JSON (optional) | **`IAddress`**: `address` (required), `shortAddress` (optional), `mapUri` (optional), `latLang` (optional number array `[lat, lng]`). If `mapUri` or `latLang` is set, a click opens a map URL (`latLang` becomes a Google Maps query URL; if both `latLang` and `mapUri` exist, **`mapUri` wins**). |
25
+ | `email` | JSON (optional) | **`IEmail`**: `address` (required), `mailLink` (optional boolean). If `mailLink` is true, a click calls `window.open` with **`address` as the URL string**—use a full URL (for example `mailto:support@example.com`) so the browser can open the mail client. |
26
+ | `site` | JSON (optional) | **`ISite`**: `uri` (optional), `label` (optional), `open` (optional boolean). Display text is `label` if set, otherwise `uri`. If `open` is true and `uri` is set, a click opens `uri` in a new window. |
27
+ | `social` | JSON (optional) | **`ISocial`**: `name` (required), `label` (optional), `pageUri` (optional). The icon class is `bi bi-{name}` (Bootstrap Icons suffix only, without the `bi-` prefix). If `pageUri` is set, a click opens that URL. |
28
+ | `config` | JSON (optional) | **`IConfig`**: `icon` (optional object with optional `fill` boolean), `text` (optional boolean), `dispatcher` (optional boolean). Defaults applied in logic: `icon.fill` defaults to false if `icon` exists; `text` defaults to true unless explicitly `false`; `dispatcher` defaults to true unless explicitly `false`. The **`fill`** flag is accepted for forward compatibility but **does not** currently switch icon classes in markup. |
29
+
30
+ ### Click behavior (summary)
31
+
32
+ 1. If the row is configured to open a window (**social** `pageUri`, **address** map link, **email** with `mailLink`, or **site** with `open` + `uri`), the first click runs **`window.open`** with the resolved URL. **`contactClick` is not fired** in that branch.
33
+ 2. Otherwise, if **`config.dispatcher`** is not disabled, a click dispatches **`contactClick`** with detail **`{ action, options }`**:
34
+ - **`action`**: `"phone"` | `"social"` | `"address"` | `"email"` | `"site"` (whichever branch is active).
35
+ - **`options`**: the parsed object for that branch (same shape as the corresponding prop).
36
+
37
+ The root span gets a clickable affordance (Bulma `is-clickable`) when a window URL will be used on click.
38
+
39
+ ### CSS custom properties
40
+
41
+ None are declared for this component in `styleSetup`. The shadow tree loads Bulma helpers for layout and Bootstrap Icons for glyphs. Surrounding page typography and colors affect only the host, not inner defaults beyond Bulma utilities.
42
+
43
+ ### CSS parts (`::part`)
44
+
45
+ | Part | Description |
46
+ | --- | --- |
47
+ | `iconcell` | Wrapper around the leading icon column (when `config.icon` is truthy). |
48
+ | `prop` | Text span for the visible value (when `config.text` is enabled). |
49
+
50
+ ### HTML slots
25
51
 
26
- No CSS vars, parts, or slots in metadata.
52
+ None.
27
53
 
28
- ### Events (`CustomEvent` names)
54
+ ### Events (`CustomEvent`)
29
55
 
30
- - **`contactclick`** `{ action: string; options: any }` Exact event name is lowercase in types.
56
+ | Event | `detail` | When it fires |
57
+ | --- | --- | --- |
58
+ | **`contactClick`** | `{ action: string; options: ... }` — `options` matches the active **`phone` / `address` / `email` / `site` / `social`** object | On click when **no** `window.open` URL is resolved for that row and **`config.dispatcher`** is true (default). |
59
+
60
+ Authoring typings may list a lowercase `contactclick` key for tooling compatibility; the **DOM event type emitted at runtime is `contactClick`**.
31
61
 
32
62
  ### Usage notes
33
63
 
34
- - Icons come from bootstrap-icons naming conventions.
35
- - Only one of phone/address/email/site/social should be primary per row (per description).
36
- - Shadow DOM wraps the row; no theme variables declared in docs.
37
- - No i18n in `docs.ts`.
64
+ - Prefer **one** of `phone`, `address`, `email`, `site`, or `social` per element to avoid surprising precedence.
65
+ - Escape JSON correctly in HTML attributes when needed (for example use single quotes around the attribute value and double quotes inside the JSON string).
66
+ - Social **`name`** must be a valid Bootstrap Icons glyph name fragment (for example `facebook`, `linkedin`, `twitter-x`).
67
+ - Bootstrap Icons CSS is injected from the component (`svelte:head` / shadow stylesheet); no extra icon font link is required on the host page for the shadow tree.
68
+ - There is **no** built-in i18n catalog for this package; labels come entirely from your JSON props.
69
+
70
+ ### Minimal HTML examples
38
71
 
39
- ### Minimal HTML example
72
+ **Email row (click opens mail client via `mailto:`):**
40
73
 
41
74
  ```html
42
75
  <hb-contact-item
43
- email='{"address":"hello@example.com","mailLink":true}'
76
+ email='{"address":"mailto:hello@example.com","mailLink":true}'
44
77
  config='{"text":true,"dispatcher":true}'
45
78
  ></hb-contact-item>
46
79
  ```
80
+
81
+ **Email row (no automatic navigation—handle `contactClick`):**
82
+
83
+ ```html
84
+ <hb-contact-item
85
+ email='{"address":"hello@example.com"}'
86
+ config='{"dispatcher":true}'
87
+ ></hb-contact-item>
88
+ ```
89
+
90
+ **Phone row (integrator handles `contactClick`):**
91
+
92
+ ```html
93
+ <hb-contact-item
94
+ phone='{"number":"+39 02 1234567","callOnClick":true}'
95
+ ></hb-contact-item>
96
+ ```
97
+
98
+ **Address with external map link:**
99
+
100
+ ```html
101
+ <hb-contact-item
102
+ address='{"address":"Via Example 42, Milan, Italy","shortAddress":"Milan HQ","mapUri":"https://www.openstreetmap.org/search?query=Milan"}'
103
+ ></hb-contact-item>
104
+ ```
105
+
106
+ **Website with new-tab behavior:**
107
+
108
+ ```html
109
+ <hb-contact-item
110
+ site='{"label":"Company site","uri":"https://example.com","open":true}'
111
+ config='{"text":true,"icon":{"fill":false}}'
112
+ ></hb-contact-item>
113
+ ```
114
+
115
+ ### Listening from JavaScript
116
+
117
+ ```javascript
118
+ const el = document.querySelector("hb-contact-item");
119
+ el.addEventListener("contactClick", (e) => {
120
+ const { action, options } = e.detail;
121
+ // action: "phone" | "address" | "email" | "site" | "social"
122
+ // options: payload object for that action
123
+ });
124
+ ```
package/manifest.json CHANGED
@@ -288,5 +288,5 @@
288
288
  "size": {},
289
289
  "iifePath": "main.iife.js",
290
290
  "repoName": "@htmlbricks/hb-contact-item",
291
- "version": "0.71.35"
291
+ "version": "0.71.36"
292
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-contact-item",
3
- "version": "0.71.35",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Single contact line (mutually exclusive props): phone, postal address, email, website, or social network. Renders a Bootstrap Icon and optional visible text; JSON `config` toggles icons (filled/outline), label text, and whether clicks dispatch `contactClick` with `{ action, options }` vs opening a window (maps URL, `mailto`, external site, or social page).",
6
6
  "licenses": [