@htmlbricks/hb-order-list 0.71.36 → 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 +47 -80
- package/main.iife.js.map +1 -1
- package/manifest.json +10 -5
- 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,100 +1,73 @@
|
|
|
1
|
-
# hb-order-list
|
|
1
|
+
# `hb-order-list` — integrator guide
|
|
2
2
|
|
|
3
|
-
**Category:** commerce · **Tags:** commerce, order
|
|
3
|
+
**Category:** commerce · **Tags:** commerce, order · **Package:** `@htmlbricks/hb-order-list`
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Summary
|
|
6
6
|
|
|
7
|
-
`hb-order-list` is a read-only order summary for commerce flows. It renders a header with the order number, a
|
|
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).
|
|
8
8
|
|
|
9
|
-
|
|
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`.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Behavior
|
|
12
12
|
|
|
13
|
-
1. **Header** — “Order N.” plus `payment.orderNumber`, and a static “tracking” label
|
|
14
|
-
2. **Line items** — For each
|
|
15
|
-
3. **Footer** — Static “cancel” and placeholder middle text (`bbb` in the template), plus
|
|
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}`.
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
-
|
|
20
|
-
- **Tax** — sum of `unitaryPrice * (quantity ?? 1) * taxPercentage / 100`, rounded to two decimal places.
|
|
21
|
-
- **Total** — subtotal + tax + `(shipmentFee ?? 0)`.
|
|
19
|
+
If **`payment`** is a string, it is JSON-parsed. Missing **`countryCode`** defaults to **`"IT"`**. Missing **`currencySymbol`** is inferred from **`countryCode`** (`IT` / `EU` → `€`, `US` → `$`).
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
## Custom element tag
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| Field | Type | Required | Notes |
|
|
30
|
-
|-------|------|----------|--------|
|
|
31
|
-
| `orderNumber` | string | Yes | Shown in the header after “Order N.” |
|
|
32
|
-
| `countryCode` | `"IT"` \| `"US"` \| `"EU"` | Yes | Drives default currency when `currencySymbol` is omitted. |
|
|
33
|
-
| `currencySymbol` | `"€"` \| `"$"` | No | Shown after the numeric total. Defaults from `countryCode` when missing. |
|
|
34
|
-
| `shipmentFee` | number | No | Added once to the grand total. |
|
|
35
|
-
| `items` | array | Yes | Each line item must satisfy the row UI (including **`image`**). |
|
|
36
|
-
|
|
37
|
-
Each **`items[]`** entry extends the shared shop line type with a required **`image`** URL (or path) for the thumbnail.
|
|
38
|
-
|
|
39
|
-
| Field | Type | Required | Notes |
|
|
40
|
-
|-------|------|----------|--------|
|
|
41
|
-
| `id` | string | Yes | Stable key for the `{#each}` block. |
|
|
42
|
-
| `name` | string | Yes | Product title next to the image. |
|
|
43
|
-
| `unitaryPrice` | number | Yes | Unit price before tax. |
|
|
44
|
-
| `taxPercentage` | number | Yes | Percent applied per line (`8` means 8%). |
|
|
45
|
-
| `quantity` | number | No | Defaults to `1` for subtotal and tax. |
|
|
46
|
-
| `unit` | string | No | Part of shared `IShopItem`; not displayed in this template. |
|
|
47
|
-
| `image` | string | Yes | `src` for the row thumbnail; exposed via `::part(item_image)`. |
|
|
48
|
-
|
|
49
|
-
Types re-use **`IShopItem`** / **`IShoppingPayment`** from `checkout-shopping-cart` (`builder/src/wc/checkout-shopping-cart/types/webcomponent.type.d.ts`) with **`image`** required on each item.
|
|
50
|
-
|
|
51
|
-
## Custom element
|
|
52
|
-
|
|
53
|
-
`hb-order-list`
|
|
23
|
+
```html
|
|
24
|
+
<hb-order-list …></hb-order-list>
|
|
25
|
+
```
|
|
54
26
|
|
|
55
|
-
## Attributes (
|
|
27
|
+
## Attributes (HTML / reflected props)
|
|
56
28
|
|
|
57
|
-
Web component attributes are strings.
|
|
29
|
+
Web component attributes are **strings** (snake_case). Structured data is a **JSON** string on **`payment`**.
|
|
58
30
|
|
|
59
|
-
| Attribute |
|
|
60
|
-
|
|
61
|
-
| `id` |
|
|
62
|
-
| `style` |
|
|
63
|
-
| `payment` |
|
|
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. |
|
|
64
36
|
|
|
65
37
|
## Events
|
|
66
38
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
## Styling
|
|
70
|
-
|
|
71
|
-
Registered theme hooks (see `extra/docs.ts` / `styleSetup`):
|
|
39
|
+
No custom events (`Events` is `{}` in `types/webcomponent.type.d.ts`).
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|--------------|------|
|
|
75
|
-
| `--bulma-text` | Foreground for order number, names, totals, and body copy. |
|
|
76
|
-
| `--bulma-scheme-main` | Surface / background. |
|
|
77
|
-
| `--bulma-column-gap` | Horizontal gap between Bulma columns. |
|
|
41
|
+
## CSS custom properties, parts, and slots
|
|
78
42
|
|
|
79
|
-
|
|
43
|
+
**Documented variables** (`extra/docs.ts` / `styleSetup`):
|
|
80
44
|
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
| `
|
|
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. |
|
|
84
50
|
|
|
85
|
-
|
|
51
|
+
| `::part` | Role |
|
|
52
|
+
|---------|------|
|
|
53
|
+
| `item_image` | Line item `<img>` thumbnail. |
|
|
86
54
|
|
|
87
|
-
|
|
55
|
+
**Slots:** none.
|
|
88
56
|
|
|
89
|
-
##
|
|
57
|
+
## TypeScript typings (authoring)
|
|
90
58
|
|
|
91
|
-
|
|
92
|
-
- Ensure every item includes **`image`**, **`id`**, **`name`**, **`unitaryPrice`**, and **`taxPercentage`** so totals and rows stay consistent with the typings.
|
|
93
|
-
- Country and currency should stay aligned (`countryCode` + optional `currencySymbol`) for a coherent footer.
|
|
59
|
+
From `types/webcomponent.type.d.ts` (see that file for **`OrderPayment`** and line item shapes):
|
|
94
60
|
|
|
95
|
-
|
|
61
|
+
```ts
|
|
62
|
+
export type Component = {
|
|
63
|
+
id?: string;
|
|
64
|
+
style?: string;
|
|
65
|
+
payment?: OrderPayment | string;
|
|
66
|
+
};
|
|
67
|
+
export type Events = {};
|
|
68
|
+
```
|
|
96
69
|
|
|
97
|
-
|
|
70
|
+
## Minimal HTML
|
|
98
71
|
|
|
99
72
|
```html
|
|
100
73
|
<hb-order-list
|
|
@@ -102,16 +75,10 @@ None.
|
|
|
102
75
|
></hb-order-list>
|
|
103
76
|
```
|
|
104
77
|
|
|
105
|
-
|
|
78
|
+
With shipment fee:
|
|
106
79
|
|
|
107
80
|
```html
|
|
108
81
|
<hb-order-list
|
|
109
|
-
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"}
|
|
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"}]}'
|
|
110
83
|
></hb-order-list>
|
|
111
84
|
```
|
|
112
|
-
|
|
113
|
-
## Related files
|
|
114
|
-
|
|
115
|
-
- `component.wc.svelte` — markup and total calculation.
|
|
116
|
-
- `types/webcomponent.type.d.ts` — `Component`, `OrderPayment`, and item typing.
|
|
117
|
-
- `extra/docs.ts` — Storybook args, `styleSetup`, and named examples (`default`, `withShipment`, `singleItem`, `usd`).
|