@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 CHANGED
@@ -1,38 +1,84 @@
1
- ## `hb-order-list` — order list
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
- ### What it does
5
+ ## Summary
7
6
 
8
- Order summary view driven by a payment JSON object: order number header, optional tracking area, list of line items with image and name, and a footer showing the order total including tax and optional shipment fee. Exposes the item image via the `item_image` CSS part.
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
- ### Custom element
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
- `hb-order-list`
11
+ ## Behavior
13
12
 
14
- ### Attributes (snake_case; use string values in HTML)
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
- - `id`, `style` (optional): strings.
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
- ### Events
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
- None declared.
21
+ ## Custom element tag
22
22
 
23
- ### Styling (Bulma)
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
- Layout uses Bulma `container` and `columns` / `column` with fractional widths (`is-10`, `is-2`, etc.). Theme tokens are registered on `:host` via Bulma’s light theme and `setup-theme`. Customize colors and spacing from the page by setting `--bulma-*` variables (for example `--bulma-text`, `--bulma-scheme-main`, `--bulma-column-gap`); see `extra/docs.ts` and `styles/bulma.scss`.
51
+ | `::part` | Role |
52
+ |---------|------|
53
+ | `item_image` | Line item `<img>` thumbnail. |
26
54
 
27
- ### Usage notes
55
+ **Slots:** none.
28
56
 
29
- - **CSS parts:** `item_image`.
30
- - Serialize `payment` as a single JSON attribute; see `builder/src/wc/order-list/types/webcomponent.type.d.ts` and examples in `extra/docs.ts`.
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
- ### Minimal HTML example
78
+ With shipment fee:
33
79
 
34
80
  ```html
35
81
  <hb-order-list
36
- payment='{"orderNumber":"1001","countryCode":"EU","items":[{"id":"1","name":"Item","unitaryPrice":10,"taxPercentage":22,"image":"https://example.com/a.jpg"}]}'
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
  ```