@htmlbricks/hb-order-list 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 +65 -19
- package/main.iife.js.map +1 -1
- package/manifest.json +13 -8
- package/package.json +1 -1
- package/types/webcomponent.type.d.json +9 -4
- package/types/webcomponent.type.d.ts +2 -1
package/README.md
CHANGED
|
@@ -1,38 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
# `hb-order-list` — integrator guide
|
|
2
2
|
|
|
3
|
-
**Category:** commerce
|
|
4
|
-
**Tags:** commerce, order
|
|
3
|
+
**Category:** commerce · **Tags:** commerce, order · **Package:** `@htmlbricks/hb-order-list`
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Summary
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
`hb-order-list` is a read-only order summary for commerce flows. It renders a header with the order number, a list of line items (thumbnail and name), and a footer with the computed grand total. The view is driven by a **`payment`** payload (JSON string from HTML).
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
Layout uses Bulma **`container`** and **`columns`**. Theme via **`--bulma-*`** on `:host`; see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/) and `extra/docs.ts`.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
## Behavior
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
1. **Header** — “Order N.” plus `payment.orderNumber`, and a static “tracking” label (placeholder in the current markup).
|
|
14
|
+
2. **Line items** — For each `payment.items` row: product **`image`** (CSS part `item_image`), **`name`**, and a static “quantity” label (numeric `quantity` affects totals only).
|
|
15
|
+
3. **Footer** — Static “cancel” and placeholder middle text (`bbb` in the template), plus **total** as `{total}{currencySymbol}`.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
- `payment` (required): JSON string — `OrderPayment` with `orderNumber`, `countryCode`, `items` (shop line items plus `image` per row), plus cart/tax fields from shared checkout types.
|
|
17
|
+
**Totals:** Subtotal = sum of `unitaryPrice * (quantity ?? 1)`; tax = sum of line VAT rounded at the sum level; total = subtotal + tax + `(shipmentFee ?? 0)`.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
If **`payment`** is a string, it is JSON-parsed. Missing **`countryCode`** defaults to **`"IT"`**. Missing **`currencySymbol`** is inferred from **`countryCode`** (`IT` / `EU` → `€`, `US` → `$`).
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## Custom element tag
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
```html
|
|
24
|
+
<hb-order-list …></hb-order-list>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Attributes (HTML / reflected props)
|
|
28
|
+
|
|
29
|
+
Web component attributes are **strings** (snake_case). Structured data is a **JSON** string on **`payment`**.
|
|
30
|
+
|
|
31
|
+
| Attribute | Role |
|
|
32
|
+
|-----------|------|
|
|
33
|
+
| `id` | Optional host id. |
|
|
34
|
+
| `style` | Optional inline style on the host. |
|
|
35
|
+
| `payment` | JSON string (or object when used from JS) describing **`OrderPayment`** (see `types/webcomponent.type.d.ts`). The implementation falls back to an empty in-memory default when omitted. |
|
|
36
|
+
|
|
37
|
+
## Events
|
|
38
|
+
|
|
39
|
+
No custom events (`Events` is `{}` in `types/webcomponent.type.d.ts`).
|
|
40
|
+
|
|
41
|
+
## CSS custom properties, parts, and slots
|
|
42
|
+
|
|
43
|
+
**Documented variables** (`extra/docs.ts` / `styleSetup`):
|
|
44
|
+
|
|
45
|
+
| Variable | Default | Notes |
|
|
46
|
+
|----------|---------|--------|
|
|
47
|
+
| `--bulma-text` | `#363636` | Foreground for copy and totals. |
|
|
48
|
+
| `--bulma-scheme-main` | `#ffffff` | Surface background. |
|
|
49
|
+
| `--bulma-column-gap` | `0.75rem` | Column gutter. |
|
|
24
50
|
|
|
25
|
-
|
|
51
|
+
| `::part` | Role |
|
|
52
|
+
|---------|------|
|
|
53
|
+
| `item_image` | Line item `<img>` thumbnail. |
|
|
26
54
|
|
|
27
|
-
|
|
55
|
+
**Slots:** none.
|
|
28
56
|
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
## TypeScript typings (authoring)
|
|
58
|
+
|
|
59
|
+
From `types/webcomponent.type.d.ts` (see that file for **`OrderPayment`** and line item shapes):
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
export type Component = {
|
|
63
|
+
id?: string;
|
|
64
|
+
style?: string;
|
|
65
|
+
payment?: OrderPayment | string;
|
|
66
|
+
};
|
|
67
|
+
export type Events = {};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Minimal HTML
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<hb-order-list
|
|
74
|
+
payment='{"orderNumber":"1001","countryCode":"EU","items":[{"id":"1","name":"Sample item","unitaryPrice":10,"taxPercentage":22,"image":"https://example.com/product.jpg"}]}'
|
|
75
|
+
></hb-order-list>
|
|
76
|
+
```
|
|
31
77
|
|
|
32
|
-
|
|
78
|
+
With shipment fee:
|
|
33
79
|
|
|
34
80
|
```html
|
|
35
81
|
<hb-order-list
|
|
36
|
-
payment='{"orderNumber":"
|
|
82
|
+
payment='{"orderNumber":"ORD-1002","countryCode":"EU","currencySymbol":"€","shipmentFee":4.99,"items":[{"id":"a","name":"Item A","unitaryPrice":5,"taxPercentage":7,"quantity":2,"image":"https://example.com/a.jpg"}]}'
|
|
37
83
|
></hb-order-list>
|
|
38
84
|
```
|