@htmlbricks/hb-order-list 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.
- package/README.md +97 -18
- package/manifest.json +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,38 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
# hb-order-list
|
|
2
2
|
|
|
3
|
-
**Category:** commerce
|
|
4
|
-
**Tags:** commerce, order
|
|
3
|
+
**Category:** commerce · **Tags:** commerce, order
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Overview
|
|
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 scrollable list of line items (thumbnail and name), and a footer that shows the computed grand total. The view is driven entirely by a single **`payment`** payload (serialized JSON when used from HTML).
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
The layout is built with Bulma **`container`** and **`columns`**. Typography and surfaces follow Bulma’s **`--bulma-*`** theme variables on `:host`. See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/) and `extra/docs.ts` for the registered tokens.
|
|
10
|
+
|
|
11
|
+
## What it renders
|
|
12
|
+
|
|
13
|
+
1. **Header** — “Order N.” plus `payment.orderNumber`, and a static “tracking” label in a narrow column (placeholder copy in the current markup).
|
|
14
|
+
2. **Line items** — For each entry in `payment.items`, one row with the product **`image`** (see CSS part `item_image`), the **`name`**, and a static “quantity” label (the numeric `quantity` field is used for totals but not shown as text in the template).
|
|
15
|
+
3. **Footer** — Static “cancel” and placeholder middle text (`bbb` in the template), plus the **computed total** formatted as `{total}{currencySymbol}` (no thousands separator; symbol appended after the number).
|
|
16
|
+
|
|
17
|
+
Grand total is computed in the component as:
|
|
18
|
+
|
|
19
|
+
- **Subtotal** — sum of `unitaryPrice * (quantity ?? 1)` for all items.
|
|
20
|
+
- **Tax** — sum of `unitaryPrice * (quantity ?? 1) * taxPercentage / 100`, rounded to two decimal places.
|
|
21
|
+
- **Total** — subtotal + tax + `(shipmentFee ?? 0)`.
|
|
22
|
+
|
|
23
|
+
If `payment` is supplied as a **string** (typical from HTML attributes), the component parses it as JSON. Missing `countryCode` defaults to `"IT"`. Missing `currencySymbol` is inferred from `countryCode` (`IT` / `EU` → `€`, `US` → `$`).
|
|
24
|
+
|
|
25
|
+
## `payment` JSON shape (`OrderPayment`)
|
|
26
|
+
|
|
27
|
+
The attribute / property matches **`OrderPayment`** in `types/webcomponent.type.d.ts`: checkout cart fields plus order metadata.
|
|
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
|
|
11
52
|
|
|
12
53
|
`hb-order-list`
|
|
13
54
|
|
|
14
|
-
|
|
55
|
+
## Attributes (snake_case; string values in HTML)
|
|
56
|
+
|
|
57
|
+
Web component attributes are strings. Pass structured data as **JSON text** on the `payment` attribute (numbers and booleans inside that JSON follow normal JSON rules).
|
|
58
|
+
|
|
59
|
+
| Attribute | Required | Description |
|
|
60
|
+
|-----------|----------|-------------|
|
|
61
|
+
| `id` | No | Optional host identifier. |
|
|
62
|
+
| `style` | No | Optional inline host styles (present on the public `Component` type). |
|
|
63
|
+
| `payment` | Yes for real data | JSON string describing `OrderPayment` (see table above). The Svelte props type marks `payment` as required; the implementation still provides an empty placeholder when nothing is passed—set `payment` whenever you want line items and totals. From HTML, use a serialized JSON string; in Svelte/JS you may pass an object. |
|
|
15
64
|
|
|
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.
|
|
65
|
+
## Events
|
|
18
66
|
|
|
19
|
-
|
|
67
|
+
None. `Events` in `types/webcomponent.type.d.ts` is an empty object.
|
|
20
68
|
|
|
21
|
-
|
|
69
|
+
## Styling
|
|
22
70
|
|
|
23
|
-
|
|
71
|
+
Registered theme hooks (see `extra/docs.ts` / `styleSetup`):
|
|
24
72
|
|
|
25
|
-
|
|
73
|
+
| CSS variable | Role |
|
|
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. |
|
|
26
78
|
|
|
27
|
-
|
|
79
|
+
## CSS parts
|
|
28
80
|
|
|
29
|
-
|
|
30
|
-
|
|
81
|
+
| Part | Target |
|
|
82
|
+
|------|--------|
|
|
83
|
+
| `item_image` | The `<img>` thumbnail for each line item (`part="item_image"`). |
|
|
31
84
|
|
|
32
|
-
|
|
85
|
+
## HTML slots
|
|
86
|
+
|
|
87
|
+
None.
|
|
88
|
+
|
|
89
|
+
## Usage notes
|
|
90
|
+
|
|
91
|
+
- Serialize **`payment`** as one JSON string on the attribute; escape quotes for inline HTML or build the string in JavaScript.
|
|
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.
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
### Minimal order
|
|
33
98
|
|
|
34
99
|
```html
|
|
35
100
|
<hb-order-list
|
|
36
|
-
payment='{"orderNumber":"1001","countryCode":"EU","items":[{"id":"1","name":"
|
|
101
|
+
payment='{"orderNumber":"1001","countryCode":"EU","items":[{"id":"1","name":"Sample item","unitaryPrice":10,"taxPercentage":22,"image":"https://example.com/product.jpg"}]}'
|
|
37
102
|
></hb-order-list>
|
|
38
103
|
```
|
|
104
|
+
|
|
105
|
+
### Order with shipment fee and explicit currency
|
|
106
|
+
|
|
107
|
+
```html
|
|
108
|
+
<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"},{"id":"b","name":"Item B","unitaryPrice":2,"taxPercentage":7,"image":"https://example.com/b.jpg"}]}'
|
|
110
|
+
></hb-order-list>
|
|
111
|
+
```
|
|
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`).
|
package/manifest.json
CHANGED
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"name": "--bulma-text",
|
|
122
122
|
"valueType": "color",
|
|
123
123
|
"defaultValue": "#363636",
|
|
124
|
-
"description": "Primary
|
|
124
|
+
"description": "Primary foreground for order number, line item names, totals, and other body copy."
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
"name": "--bulma-scheme-main",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
"name": "--bulma-column-gap",
|
|
134
|
-
"valueType": "
|
|
134
|
+
"valueType": "string",
|
|
135
135
|
"defaultValue": "0.75rem",
|
|
136
136
|
"description": "Gap between grid columns."
|
|
137
137
|
}
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"parts": [
|
|
140
140
|
{
|
|
141
141
|
"name": "item_image",
|
|
142
|
-
"description": ""
|
|
142
|
+
"description": "Product thumbnail on each line item row."
|
|
143
143
|
}
|
|
144
144
|
]
|
|
145
145
|
},
|
|
@@ -261,5 +261,5 @@
|
|
|
261
261
|
"size": {},
|
|
262
262
|
"iifePath": "main.iife.js",
|
|
263
263
|
"repoName": "@htmlbricks/hb-order-list",
|
|
264
|
-
"version": "0.71.
|
|
264
|
+
"version": "0.71.36"
|
|
265
265
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-order-list",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "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.",
|
|
6
6
|
"licenses": [
|