@htmlbricks/hb-contact-item 0.71.35 → 0.71.37

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 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,109 @@ 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). |
31
59
 
32
60
  ### Usage notes
33
61
 
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`.
62
+ - Prefer **one** of `phone`, `address`, `email`, `site`, or `social` per element to avoid surprising precedence.
63
+ - Escape JSON correctly in HTML attributes when needed (for example use single quotes around the attribute value and double quotes inside the JSON string).
64
+ - Social **`name`** must be a valid Bootstrap Icons glyph name fragment (for example `facebook`, `linkedin`, `twitter-x`).
65
+ - 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.
66
+ - There is **no** built-in i18n catalog for this package; labels come entirely from your JSON props.
67
+
68
+ ### Minimal HTML examples
38
69
 
39
- ### Minimal HTML example
70
+ **Email row (click opens mail client via `mailto:`):**
40
71
 
41
72
  ```html
42
73
  <hb-contact-item
43
- email='{"address":"hello@example.com","mailLink":true}'
74
+ email='{"address":"mailto:hello@example.com","mailLink":true}'
44
75
  config='{"text":true,"dispatcher":true}'
45
76
  ></hb-contact-item>
46
77
  ```
78
+
79
+ **Email row (no automatic navigation—handle `contactClick`):**
80
+
81
+ ```html
82
+ <hb-contact-item
83
+ email='{"address":"hello@example.com"}'
84
+ config='{"dispatcher":true}'
85
+ ></hb-contact-item>
86
+ ```
87
+
88
+ **Phone row (integrator handles `contactClick`):**
89
+
90
+ ```html
91
+ <hb-contact-item
92
+ phone='{"number":"+39 02 1234567","callOnClick":true}'
93
+ ></hb-contact-item>
94
+ ```
95
+
96
+ **Address with external map link:**
97
+
98
+ ```html
99
+ <hb-contact-item
100
+ address='{"address":"Via Example 42, Milan, Italy","shortAddress":"Milan HQ","mapUri":"https://www.openstreetmap.org/search?query=Milan"}'
101
+ ></hb-contact-item>
102
+ ```
103
+
104
+ **Website with new-tab behavior:**
105
+
106
+ ```html
107
+ <hb-contact-item
108
+ site='{"label":"Company site","uri":"https://example.com","open":true}'
109
+ config='{"text":true,"icon":{"fill":false}}'
110
+ ></hb-contact-item>
111
+ ```
112
+
113
+ ### Listening from JavaScript
114
+
115
+ ```javascript
116
+ const el = document.querySelector("hb-contact-item");
117
+ el.addEventListener("contactClick", (e) => {
118
+ const { action, options } = e.detail;
119
+ // action: "phone" | "address" | "email" | "site" | "social"
120
+ // options: payload object for that action
121
+ });
122
+ ```
package/manifest.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "Events": {
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
- "contactclick": {
10
+ "contactClick": {
11
11
  "additionalProperties": false,
12
12
  "properties": {
13
13
  "action": {
@@ -23,7 +23,7 @@
23
23
  }
24
24
  },
25
25
  "required": [
26
- "contactclick"
26
+ "contactClick"
27
27
  ],
28
28
  "type": "object"
29
29
  }
@@ -206,13 +206,22 @@
206
206
  "type": "object"
207
207
  }
208
208
  },
209
- "contactclick": {
209
+ "contactClick": {
210
210
  "action": "contactClickEvent"
211
211
  }
212
212
  },
213
213
  "styleSetup": {
214
214
  "vars": [],
215
- "parts": []
215
+ "parts": [
216
+ {
217
+ "name": "iconcell",
218
+ "description": "Leading icon column when `config.icon` is enabled (Bootstrap Icon wrapper)."
219
+ },
220
+ {
221
+ "name": "prop",
222
+ "description": "Visible text span for the active contact value when `config.text` is enabled."
223
+ }
224
+ ]
216
225
  },
217
226
  "contributors": [],
218
227
  "htmlSlots": [],
@@ -288,5 +297,5 @@
288
297
  "size": {},
289
298
  "iifePath": "main.iife.js",
290
299
  "repoName": "@htmlbricks/hb-contact-item",
291
- "version": "0.71.35"
300
+ "version": "0.71.37"
292
301
  }
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.37",
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": [
@@ -43,5 +43,5 @@ export type Component = {
43
43
  };
44
44
 
45
45
  export type Events = {
46
- contactclick: { action: string; options: any };
46
+ contactClick: { action: string; options: unknown };
47
47
  };
@@ -5,7 +5,7 @@
5
5
  "Events": {
6
6
  "additionalProperties": false,
7
7
  "properties": {
8
- "contactclick": {
8
+ "contactClick": {
9
9
  "additionalProperties": false,
10
10
  "properties": {
11
11
  "action": {
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "required": [
24
- "contactclick"
24
+ "contactClick"
25
25
  ],
26
26
  "type": "object"
27
27
  }