@justeattakeaway/pie-list 0.5.0 → 0.6.1
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 +19 -18
- package/custom-elements.json +10 -1
- package/dist/{PieElement-DQQMEr70.js → PieElement-DgjFUjAZ.js} +1 -1
- package/dist/{index-BH08tWcm.js → index-K8-W-Okw.js} +24 -19
- package/dist/index.js +14 -14
- package/dist/pie-list-item/defs.d.ts +4 -0
- package/dist/pie-list-item/defs.d.ts.map +1 -1
- package/dist/pie-list-item/index.d.ts +1 -0
- package/dist/pie-list-item/index.d.ts.map +1 -1
- package/dist/pie-list-item/index.js +2 -2
- package/dist/pie-list-item/react.js +2 -2
- package/package.json +3 -3
- package/src/list.scss +0 -2
- package/src/pie-list-item/defs.ts +6 -0
- package/src/pie-list-item/index.ts +4 -0
- package/src/pie-list-item/list-item.scss +8 -6
package/README.md
CHANGED
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
`@justeattakeaway/pie-list` is a Web Component built using the Lit library. It provides a simple, accessible list built from two elements: a `pie-list` container and one or more `pie-list-item` children.
|
|
11
11
|
|
|
12
|
-
> [!NOTE]
|
|
13
|
-
> This component is still growing. More properties, slots and sub-components will be added over time. This documentation covers what is currently supported.
|
|
14
|
-
|
|
15
12
|
## Table of Contents
|
|
16
13
|
|
|
17
14
|
- [Installation](#installation)
|
|
@@ -52,7 +49,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
|
|
|
52
49
|
|
|
53
50
|
## Documentation
|
|
54
51
|
|
|
55
|
-
`pie-list` is a compound component. The `pie-list` element is the container (it applies the `list` role
|
|
52
|
+
`pie-list` is a compound component. The `pie-list` element is the container (it applies the `list` role), and each row is a `pie-list-item` (which applies the `listitem` role). Set `hasDivider` on each item that needs a divider except for the last one.
|
|
56
53
|
|
|
57
54
|
> [!IMPORTANT]
|
|
58
55
|
> Because `pie-list` uses the `list` role, you **must always give it an accessible name** using either `aria-label` or `aria-labelledby`. Without one, screen reader users get no context for what the list contains. See [Accessibility](#accessibility).
|
|
@@ -75,6 +72,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
|
|
|
75
72
|
| `hasMedia` | `true`, `false` | **Required whenever you slot a media element (e.g. `pie-thumbnail`) into the item.** Reduces the block padding so single-line media sits correctly (this padding adjustment has no effect when `secondaryText` is set, but you should still set `hasMedia`). | `false` |
|
|
76
73
|
| `interactionType` | `"none"`, `"radio"`, `"checkbox"`, `"switch"`, `"link"`, `"button"` | Declares how the **whole row** behaves, and drives its role, accessible naming, click forwarding and interactive states from this one prop. `"none"` is a static item; `"radio"`/`"checkbox"`/`"switch"` host the matching control in the `leading`/`trailing` slot; `"link"` turns the row into a single navigation link (slot an empty `<a slot="link" href="...">`); `"button"` turns the row into a single button for an in-page action (the item renders the button for you - listen for `click`). See [Selectable lists](#selectable-lists), [Link items](#link-items) and [Button items](#button-items). | `"none"` |
|
|
77
74
|
| `disabled` | `true`, `false` | Marks the row as disabled: it takes the disabled styling and stops forwarding row clicks to its control. Set it alongside the slotted control's own `disabled` (the control still governs its own interactivity). No visible effect on a non-selectable (static) item. | `false` |
|
|
75
|
+
| `hasDivider` | `true`, `false` | Renders a bottom divider line on the item. Do not set this to `true` on the last item in a list. | `false` |
|
|
78
76
|
| `aria` | `{ button?: { haspopup?: "menu" \| "listbox" \| "tree" \| "grid" \| "dialog" \| "true" } }` | Additional ARIA properties that the item cannot derive from its text props. `button.haspopup` only applies when `interactionType="button"` and is forwarded to the internal `<button>` element. Set it when the button row triggers a popup such as a dialog or menu. | `undefined` |
|
|
79
77
|
|
|
80
78
|
### Slots
|
|
@@ -121,7 +119,7 @@ This component does not emit any custom events. To listen for interactions, trea
|
|
|
121
119
|
|
|
122
120
|
```html
|
|
123
121
|
<pie-list aria-label="Payment methods">
|
|
124
|
-
<pie-list-item primaryText="Credit card"></pie-list-item>
|
|
122
|
+
<pie-list-item hasDivider primaryText="Credit card"></pie-list-item>
|
|
125
123
|
<pie-list-item primaryText="PayPal"></pie-list-item>
|
|
126
124
|
</pie-list>
|
|
127
125
|
```
|
|
@@ -131,7 +129,7 @@ This component does not emit any custom events. To listen for interactions, trea
|
|
|
131
129
|
```html
|
|
132
130
|
<h2 id="payment-methods-heading">Payment methods</h2>
|
|
133
131
|
<pie-list aria-labelledby="payment-methods-heading">
|
|
134
|
-
<pie-list-item primaryText="Credit card"></pie-list-item>
|
|
132
|
+
<pie-list-item hasDivider primaryText="Credit card"></pie-list-item>
|
|
135
133
|
<pie-list-item primaryText="PayPal"></pie-list-item>
|
|
136
134
|
</pie-list>
|
|
137
135
|
```
|
|
@@ -178,10 +176,12 @@ A basic list with primary, secondary and meta text (note the required `aria-labe
|
|
|
178
176
|
```html
|
|
179
177
|
<pie-list aria-label="Recent orders">
|
|
180
178
|
<pie-list-item
|
|
179
|
+
hasDivider
|
|
181
180
|
primaryText="Primary text"
|
|
182
181
|
secondaryText="Secondary text"
|
|
183
182
|
metaText="Meta text"></pie-list-item>
|
|
184
183
|
<pie-list-item
|
|
184
|
+
hasDivider
|
|
185
185
|
primaryText="Primary text"
|
|
186
186
|
secondaryText="Secondary text"></pie-list-item>
|
|
187
187
|
<pie-list-item primaryText="Primary text"></pie-list-item>
|
|
@@ -245,7 +245,7 @@ Reduced height, see [rules](#usage-notes-and-rules):
|
|
|
245
245
|
|
|
246
246
|
```html
|
|
247
247
|
<pie-list>
|
|
248
|
-
<pie-list-item isCompact primaryText="Primary text">
|
|
248
|
+
<pie-list-item hasDivider isCompact primaryText="Primary text">
|
|
249
249
|
<icon-chevron-right slot="trailing"></icon-chevron-right>
|
|
250
250
|
</pie-list-item>
|
|
251
251
|
<pie-list-item isCompact primaryText="Primary text">
|
|
@@ -327,10 +327,10 @@ import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
|
327
327
|
```
|
|
328
328
|
|
|
329
329
|
```html
|
|
330
|
-
<!-- `interactionType="radio"` makes each row selectable
|
|
331
|
-
|
|
330
|
+
<!-- `interactionType="radio"` makes each row selectable. `value` on the group selects
|
|
331
|
+
the matching radio (here, Express). -->
|
|
332
332
|
<pie-radio-group name="delivery" value="express">
|
|
333
|
-
<pie-list-item interactionType="radio" primaryText="Standard delivery" secondaryText="3 to 5 working days" metaText="Free">
|
|
333
|
+
<pie-list-item hasDivider interactionType="radio" primaryText="Standard delivery" secondaryText="3 to 5 working days" metaText="Free">
|
|
334
334
|
<pie-radio slot="leading" value="standard"></pie-radio>
|
|
335
335
|
</pie-list-item>
|
|
336
336
|
<pie-list-item interactionType="radio" primaryText="Express delivery" secondaryText="Next working day" metaText="£4.99">
|
|
@@ -349,7 +349,7 @@ import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
|
349
349
|
|
|
350
350
|
```html
|
|
351
351
|
<pie-checkbox-group>
|
|
352
|
-
<pie-list-item interactionType="checkbox" primaryText="Cheese" secondaryText="Extra mature" metaText="Free">
|
|
352
|
+
<pie-list-item hasDivider interactionType="checkbox" primaryText="Cheese" secondaryText="Extra mature" metaText="Free">
|
|
353
353
|
<pie-checkbox slot="leading" name="cheese"></pie-checkbox>
|
|
354
354
|
</pie-list-item>
|
|
355
355
|
<pie-list-item interactionType="checkbox" primaryText="Pepperoni" secondaryText="Spicy">
|
|
@@ -370,10 +370,10 @@ import '@justeattakeaway/pie-webc/components/switch.js';
|
|
|
370
370
|
|
|
371
371
|
```html
|
|
372
372
|
<pie-list aria-label="Notification settings">
|
|
373
|
-
<pie-list-item interactionType="switch" primaryText="Email" secondaryText="Order updates and receipts">
|
|
373
|
+
<pie-list-item hasDivider interactionType="switch" primaryText="Email" secondaryText="Order updates and receipts">
|
|
374
374
|
<pie-switch slot="trailing"></pie-switch>
|
|
375
375
|
</pie-list-item>
|
|
376
|
-
<pie-list-item interactionType="switch" primaryText="Push notifications">
|
|
376
|
+
<pie-list-item hasDivider interactionType="switch" primaryText="Push notifications">
|
|
377
377
|
<pie-switch slot="trailing"></pie-switch>
|
|
378
378
|
</pie-list-item>
|
|
379
379
|
<pie-list-item interactionType="switch" primaryText="SMS" disabled>
|
|
@@ -397,7 +397,7 @@ import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
|
397
397
|
|
|
398
398
|
```html
|
|
399
399
|
<pie-list aria-label="Manage your restaurant">
|
|
400
|
-
<pie-list-item interactionType="link" primaryText="Orders" secondaryText="View and manage live orders" metaText="12 active">
|
|
400
|
+
<pie-list-item hasDivider interactionType="link" primaryText="Orders" secondaryText="View and manage live orders" metaText="12 active">
|
|
401
401
|
<a slot="link" href="/orders"></a>
|
|
402
402
|
</pie-list-item>
|
|
403
403
|
<pie-list-item interactionType="link" primaryText="Menu" secondaryText="Edit items, prices and photos">
|
|
@@ -430,14 +430,14 @@ import '@justeattakeaway/pie-icons-webc/dist/IconCheck.js';
|
|
|
430
430
|
|
|
431
431
|
```html
|
|
432
432
|
<pie-list aria-label="Account navigation">
|
|
433
|
-
<pie-list-item interactionType="link" primaryText="Overview">
|
|
433
|
+
<pie-list-item hasDivider interactionType="link" primaryText="Overview">
|
|
434
434
|
<a slot="link" href="/account"></a>
|
|
435
435
|
</pie-list-item>
|
|
436
|
-
<pie-list-item interactionType="link" isBold primaryText="Orders">
|
|
436
|
+
<pie-list-item hasDivider interactionType="link" isBold primaryText="Orders">
|
|
437
437
|
<a slot="link" href="/account/orders" aria-current="page"></a>
|
|
438
438
|
<icon-check slot="trailing"></icon-check>
|
|
439
439
|
</pie-list-item>
|
|
440
|
-
<pie-list-item interactionType="link" primaryText="Payment methods">
|
|
440
|
+
<pie-list-item hasDivider interactionType="link" primaryText="Payment methods">
|
|
441
441
|
<a slot="link" href="/account/payment"></a>
|
|
442
442
|
</pie-list-item>
|
|
443
443
|
<pie-list-item interactionType="link" primaryText="Addresses">
|
|
@@ -496,7 +496,7 @@ import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
|
496
496
|
|
|
497
497
|
```html
|
|
498
498
|
<pie-list aria-label="Account actions">
|
|
499
|
-
<pie-list-item interactionType="button" primaryText="Edit profile" secondaryText="Update your name and photo"></pie-list-item>
|
|
499
|
+
<pie-list-item hasDivider interactionType="button" primaryText="Edit profile" secondaryText="Update your name and photo"></pie-list-item>
|
|
500
500
|
<pie-list-item interactionType="button" primaryText="Sign out" secondaryText="End your session on this device"></pie-list-item>
|
|
501
501
|
</pie-list>
|
|
502
502
|
|
|
@@ -549,6 +549,7 @@ To keep lists consistent and correct, follow these rules:
|
|
|
549
549
|
|
|
550
550
|
- **Always give `pie-list` an accessible name** with `aria-label` or `aria-labelledby` (use `aria-labelledby` when a visible heading exists). This is required for screen reader users to understand the list. See [Accessibility](#accessibility).
|
|
551
551
|
- **Provide `primaryText`** on every `pie-list-item`; it is the item's main line of content.
|
|
552
|
+
- **Do not set `hasDivider` to `true` on the last item in a list.** Setting it on the last item adds a bottom border beneath the list, which breaks the design. Set `hasDivider` on every item except the last.
|
|
552
553
|
- **For selectable lists, use `pie-list-item` inside `pie-radio-group` or `pie-checkbox-group`, not `pie-list`.** `pie-list` is a static container with no selection or keyboard behaviour. See [Selectable lists](#selectable-lists).
|
|
553
554
|
- **`metaText` and the `trailing` slot are mutually exclusive.** If `metaText` is set, any `trailing` slot content is ignored. Choose one.
|
|
554
555
|
- **Slotted `pie-thumbnail` must use `size="40"`.** This is the only size that fits the list-item layout correctly.
|
package/custom-elements.json
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"type": {
|
|
81
81
|
"text": "DefaultProps"
|
|
82
82
|
},
|
|
83
|
-
"default": "{ isCompact: false, isBold: false, hasMedia: false, interactionType: 'none', disabled: false, }"
|
|
83
|
+
"default": "{ isCompact: false, isBold: false, hasMedia: false, interactionType: 'none', disabled: false, hasDivider: false, }"
|
|
84
84
|
}
|
|
85
85
|
],
|
|
86
86
|
"exports": [
|
|
@@ -174,6 +174,11 @@
|
|
|
174
174
|
"name": "disabled",
|
|
175
175
|
"attribute": "disabled"
|
|
176
176
|
},
|
|
177
|
+
{
|
|
178
|
+
"kind": "field",
|
|
179
|
+
"name": "hasDivider",
|
|
180
|
+
"attribute": "hasDivider"
|
|
181
|
+
},
|
|
177
182
|
{
|
|
178
183
|
"kind": "field",
|
|
179
184
|
"name": "aria",
|
|
@@ -406,6 +411,10 @@
|
|
|
406
411
|
"name": "disabled",
|
|
407
412
|
"fieldName": "disabled"
|
|
408
413
|
},
|
|
414
|
+
{
|
|
415
|
+
"name": "hasDivider",
|
|
416
|
+
"fieldName": "hasDivider"
|
|
417
|
+
},
|
|
409
418
|
{
|
|
410
419
|
"name": "aria",
|
|
411
420
|
"type": {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { unsafeCSS as x, isServer as y, html as
|
|
1
|
+
import { unsafeCSS as x, isServer as y, html as h, nothing as p } from "lit";
|
|
2
2
|
import { property as c, state as k } from "lit/decorators.js";
|
|
3
3
|
import { classMap as _ } from "lit/directives/class-map.js";
|
|
4
4
|
import { ifDefined as m } from "lit/directives/if-defined.js";
|
|
5
5
|
import { validPropertyValues as I, safeCustomElement as T, ariaContext as w, parentDisabledContext as C } from "@justeattakeaway/pie-webc-core";
|
|
6
|
-
import { P as A } from "./PieElement-
|
|
6
|
+
import { P as A } from "./PieElement-DgjFUjAZ.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2021 Google LLC
|
|
@@ -82,7 +82,7 @@ class L extends Event {
|
|
|
82
82
|
super("context-provider", { bubbles: !0, composed: !0 }), this.context = t, this.contextTarget = e;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
class
|
|
85
|
+
class D extends R {
|
|
86
86
|
constructor(t, e, o) {
|
|
87
87
|
var s, r;
|
|
88
88
|
super(e.context !== void 0 ? e.initialValue : o), this.onContextRequest = (n) => {
|
|
@@ -121,22 +121,23 @@ function B({ context: i, subscribe: t }) {
|
|
|
121
121
|
}));
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
const
|
|
124
|
+
const P = ["none", "radio", "checkbox", "switch", "link", "button"], d = {
|
|
125
125
|
isCompact: !1,
|
|
126
126
|
isBold: !1,
|
|
127
127
|
hasMedia: !1,
|
|
128
128
|
interactionType: "none",
|
|
129
|
-
disabled: !1
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
disabled: !1,
|
|
130
|
+
hasDivider: !1
|
|
131
|
+
}, S = "*,*:after,*:before{box-sizing:inherit}:host{--list-item-inline-padding: var(--dt-spacing-d);--list-item-alignment: flex-start;display:block}.c-listItem-container{--list-item-block-padding: var(--dt-spacing-d);padding-inline-start:var(--list-item-inline-padding);padding-inline-end:var(--list-item-inline-padding);padding-block-start:var(--list-item-block-padding);padding-block-end:var(--list-item-block-padding);display:flex;align-items:var(--list-item-alignment);gap:var(--dt-spacing-c);min-height:56px}.c-listItem-container.has-divider{padding-block-end:calc(var(--list-item-block-padding) - 1px);border-bottom:1px solid var(--dt-color-divider-default)}.c-listItem-container:has(.c-listItem-secondaryText){align-items:var(--list-item-alignment);min-height:76px}.c-listItem-container.is-compact{--list-item-block-padding: var(--dt-spacing-c);--list-item-alignment: center;align-items:var(--list-item-alignment);min-height:48px}.c-listItem-container.is-link,.c-listItem-container.is-button{position:relative}.c-listItem-container.is-selectable:not(.is-disabled),.c-listItem-container.is-link,.c-listItem-container.is-button:not(.is-disabled){--list-item-hover-bg: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--dt-color-hover-01));--list-item-active-bg: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--dt-color-active-01))}@supports (background-color: color-mix(in srgb,black,white)){.c-listItem-container.is-selectable:not(.is-disabled),.c-listItem-container.is-link,.c-listItem-container.is-button:not(.is-disabled){--list-item-hover-bg: color-mix(in srgb, var(--dt-color-hover-01-bg) var(--dt-color-hover-01), transparent);--list-item-active-bg: color-mix(in srgb, var(--dt-color-active-01-bg) var(--dt-color-active-01), transparent)}}.c-listItem-container.is-selectable:not(.is-disabled),.c-listItem-container.is-link,.c-listItem-container.is-button:not(.is-disabled){cursor:pointer}.c-listItem-container.is-selectable:not(.is-disabled):hover,.c-listItem-container.is-link:hover,.c-listItem-container.is-button:not(.is-disabled):hover{background-color:var(--list-item-hover-bg);--interactive-container-tint: var(--list-item-hover-bg)}.c-listItem-container.is-selectable:not(.is-disabled):active,.c-listItem-container.is-link:active,.c-listItem-container.is-button:not(.is-disabled):active{background-color:var(--list-item-active-bg);--interactive-container-tint: var(--list-item-active-bg)}.c-listItem-container.is-button:has(.c-listItem-action:active){background-color:var(--list-item-active-bg);--interactive-container-tint: var(--list-item-active-bg)}slot[name=link]::slotted(a),.c-listItem-action{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;border-radius:inherit}.c-listItem-action{padding:0;border:none;background:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;font:inherit;cursor:pointer}.c-listItem-action:disabled{cursor:default}slot[name=link]::slotted(a:focus-visible),.c-listItem-action:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-listItem-container.has-media:has(.c-listItem-primaryText:only-child){--list-item-block-padding: var(--dt-spacing-b)}.c-listItem-text{flex:1}slot[name=trailing]::slotted(*),.c-listItem-metaText{padding-inline-start:var(--dt-spacing-a)}.c-listItem-leading,slot[name=leading],.c-listItem-trailing,slot[name=trailing]{display:contents}.c-listItem-text>*{display:block}.c-listItem-trailing{margin-inline-start:auto}.c-listItem-metaText{display:block;max-width:33.3333333333%}::slotted(.c-pieIcon){--icon-size-override: 24px }.c-listItem-container.is-button.is-disabled .c-listItem-primaryText,.c-listItem-container.is-button.is-disabled .c-listItem-secondaryText,.c-listItem-container.is-button.is-disabled .c-listItem-metaText{color:var(--dt-color-content-disabled)}.c-listItem-container.is-button.is-disabled ::slotted(.c-pieIcon){color:var(--dt-color-disabled-01)}.c-listItem-primaryText{font-family:var(--dt-font-body-l-family);font-weight:var(--dt-font-body-l-weight);font-size:calc(var(--dt-font-body-l-size) * 1px);line-height:calc(var(--dt-font-body-l-line-height) * 1px);color:var(--dt-color-content-default)}.c-listItem-container.is-bold .c-listItem-primaryText{font-family:var(--dt-font-body-strong-l-family);font-weight:var(--dt-font-body-strong-l-weight);font-size:calc(var(--dt-font-body-strong-l-size) * 1px);line-height:calc(var(--dt-font-body-strong-l-line-height) * 1px)}.c-listItem-secondaryText,.c-listItem-metaText{font-family:var(--dt-font-body-s-family);font-weight:var(--dt-font-body-s-weight);font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px);color:var(--dt-color-content-subdued)}";
|
|
132
|
+
var $ = Object.defineProperty, q = Object.getOwnPropertyDescriptor, l = (i, t, e, o) => {
|
|
133
|
+
for (var s = o > 1 ? void 0 : o ? q(t, e) : t, r = i.length - 1, n; r >= 0; r--)
|
|
133
134
|
(n = i[r]) && (s = (o ? n(t, e, s) : n(s)) || s);
|
|
134
135
|
return o && s && $(t, e, s), s;
|
|
135
136
|
};
|
|
136
|
-
const
|
|
137
|
+
const z = "pie-list-item";
|
|
137
138
|
let a = class extends A {
|
|
138
139
|
constructor() {
|
|
139
|
-
super(...arguments), this.isCompact =
|
|
140
|
+
super(...arguments), this.isCompact = d.isCompact, this.isBold = d.isBold, this.hasMedia = d.hasMedia, this.interactionType = d.interactionType, this.disabled = d.disabled, this.hasDivider = d.hasDivider, this._parentDisabled = !1, this._ariaProvider = y ? void 0 : new D(this, { context: w }), this._managedRole = null, this._linkAriaCaptured = !1, this._consumerNamedLink = !1, this._consumerDescribedLink = !1, this._handleHostClick = (i) => {
|
|
140
141
|
if (!this._isSelectable || this._isDisabled) return;
|
|
141
142
|
const t = this._control;
|
|
142
143
|
!t || i.composedPath().includes(t) || (t.click(), t.focus());
|
|
@@ -242,12 +243,12 @@ let a = class extends A {
|
|
|
242
243
|
}
|
|
243
244
|
_renderSecondaryText() {
|
|
244
245
|
const { secondaryText: i } = this;
|
|
245
|
-
return i ?
|
|
246
|
+
return i ? h`<span class="c-listItem-secondaryText">${i}</span>` : p;
|
|
246
247
|
}
|
|
247
248
|
// metaText is another form of trailing content. The component can only ever display either slotted trailing content or the metaText string
|
|
248
249
|
_renderTrailingContent() {
|
|
249
250
|
const { metaText: i } = this;
|
|
250
|
-
return i ?
|
|
251
|
+
return i ? h`<span class="c-listItem-metaText c-listItem-trailing" aria-hidden=${this._providesAria ? "true" : p}>${i}</span>` : h`<div class="c-listItem-trailing"><slot name="trailing"></slot></div>`;
|
|
251
252
|
}
|
|
252
253
|
/**
|
|
253
254
|
* The interactive target for a `button` row: an empty, native `<button>` stretched invisibly
|
|
@@ -260,7 +261,7 @@ let a = class extends A {
|
|
|
260
261
|
_renderActionButton() {
|
|
261
262
|
var t, e;
|
|
262
263
|
const i = this._providedAria;
|
|
263
|
-
return
|
|
264
|
+
return h`<button
|
|
264
265
|
class="c-listItem-action"
|
|
265
266
|
type="button"
|
|
266
267
|
?disabled=${this._isDisabled}
|
|
@@ -274,14 +275,15 @@ let a = class extends A {
|
|
|
274
275
|
"is-compact": this.isCompact,
|
|
275
276
|
"is-bold": this.isBold,
|
|
276
277
|
"has-media": this.hasMedia,
|
|
278
|
+
"has-divider": this.hasDivider,
|
|
277
279
|
"is-selectable": this._isSelectable,
|
|
278
280
|
"is-link": this._isLinkRow,
|
|
279
281
|
"is-button": this._isButtonRow,
|
|
280
282
|
"is-disabled": this._isDisabled
|
|
281
283
|
};
|
|
282
|
-
return
|
|
284
|
+
return h`
|
|
283
285
|
<div class=${_(t)}>
|
|
284
|
-
${this._isLinkRow ?
|
|
286
|
+
${this._isLinkRow ? h`<slot name="link"></slot>` : p}
|
|
285
287
|
${this._isButtonRow ? this._renderActionButton() : p}
|
|
286
288
|
<div class="c-listItem-leading">
|
|
287
289
|
<slot name="leading"></slot>
|
|
@@ -296,7 +298,7 @@ let a = class extends A {
|
|
|
296
298
|
</div>`;
|
|
297
299
|
}
|
|
298
300
|
};
|
|
299
|
-
a.styles = x(
|
|
301
|
+
a.styles = x(S);
|
|
300
302
|
l([
|
|
301
303
|
c({ type: String })
|
|
302
304
|
], a.prototype, "primaryText", 2);
|
|
@@ -317,11 +319,14 @@ l([
|
|
|
317
319
|
], a.prototype, "hasMedia", 2);
|
|
318
320
|
l([
|
|
319
321
|
c({ type: String }),
|
|
320
|
-
I(
|
|
322
|
+
I(z, P, d.interactionType)
|
|
321
323
|
], a.prototype, "interactionType", 2);
|
|
322
324
|
l([
|
|
323
325
|
c({ type: Boolean })
|
|
324
326
|
], a.prototype, "disabled", 2);
|
|
327
|
+
l([
|
|
328
|
+
c({ type: Boolean })
|
|
329
|
+
], a.prototype, "hasDivider", 2);
|
|
325
330
|
l([
|
|
326
331
|
c({ type: Object })
|
|
327
332
|
], a.prototype, "aria", 2);
|
|
@@ -334,6 +339,6 @@ a = l([
|
|
|
334
339
|
], a);
|
|
335
340
|
export {
|
|
336
341
|
a as P,
|
|
337
|
-
|
|
338
|
-
|
|
342
|
+
d,
|
|
343
|
+
P as i
|
|
339
344
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { html as
|
|
2
|
-
import { P as f } from "./PieElement-
|
|
3
|
-
import { RtlMixin as
|
|
4
|
-
const
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
(o =
|
|
8
|
-
return
|
|
1
|
+
import { html as a, unsafeCSS as c } from "lit";
|
|
2
|
+
import { P as f } from "./PieElement-DgjFUjAZ.js";
|
|
3
|
+
import { RtlMixin as m, safeCustomElement as p } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
const b = "*,*:after,*:before{box-sizing:inherit}:host{display:block}";
|
|
5
|
+
var u = Object.getOwnPropertyDescriptor, h = (r, l, n, i) => {
|
|
6
|
+
for (var e = i > 1 ? void 0 : i ? u(l, n) : l, t = r.length - 1, o; t >= 0; t--)
|
|
7
|
+
(o = r[t]) && (e = o(e) || e);
|
|
8
|
+
return e;
|
|
9
9
|
};
|
|
10
|
-
let
|
|
10
|
+
let s = class extends m(f) {
|
|
11
11
|
connectedCallback() {
|
|
12
12
|
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "list");
|
|
13
13
|
}
|
|
14
14
|
render() {
|
|
15
|
-
return
|
|
15
|
+
return a`<slot></slot>`;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
s.styles = c(b);
|
|
19
|
+
s = h([
|
|
20
20
|
p("pie-list")
|
|
21
|
-
],
|
|
21
|
+
], s);
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
s as PieList
|
|
24
24
|
};
|
|
@@ -64,6 +64,10 @@ export interface ListItemProps {
|
|
|
64
64
|
* (static) item.
|
|
65
65
|
*/
|
|
66
66
|
disabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* When `true`, renders a bottom divider line on the item. Do not set this to true for the last item in a list.
|
|
69
|
+
*/
|
|
70
|
+
hasDivider?: boolean;
|
|
67
71
|
/**
|
|
68
72
|
* Additional ARIA properties that the item cannot derive from its text props. `button.haspopup`
|
|
69
73
|
* applies when `interactionType="button"`: its value is forwarded to the internal `<button>`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,KAAK,SAAS,GAAG;IACb,MAAM,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;KACvE,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,gBAAgB,oEAAqE,CAAC;AAEnG,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC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AAO,CAAA;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,CAAC,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC;AAEzI,eAAO,MAAM,YAAY,EAAE,YAO1B,CAAC"}
|
|
@@ -17,6 +17,7 @@ export declare class PieListItem extends PieElement implements ListItemProps {
|
|
|
17
17
|
hasMedia: boolean;
|
|
18
18
|
interactionType: "button" | "checkbox" | "link" | "none" | "radio" | "switch";
|
|
19
19
|
disabled: boolean;
|
|
20
|
+
hasDivider: boolean;
|
|
20
21
|
aria: ListItemProps['aria'];
|
|
21
22
|
private _parentDisabled;
|
|
22
23
|
private _ariaProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACa,OAAO,EAC1B,MAAM,KAAK,CAAC;AAYb,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AACrF,OAAO,EAAE,KAAK,aAAa,EAAkC,MAAM,QAAQ,CAAC;AAG5E,QAAA,MAAM,iBAAiB,kBAAkB,CAAC;AAE1C;;;;;GAKG;AACH,qBACa,WAAY,SAAQ,UAAW,YAAW,aAAa;IAE5D,WAAW,EAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAG3C,aA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BAAmB;IAYnB,MAAM;IAiCN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAAC;KACpC;CACJ"}
|
|
@@ -2,9 +2,9 @@ import "lit";
|
|
|
2
2
|
import "lit/decorators.js";
|
|
3
3
|
import "lit/directives/class-map.js";
|
|
4
4
|
import "lit/directives/if-defined.js";
|
|
5
|
-
import { P } from "../index-
|
|
5
|
+
import { P } from "../index-K8-W-Okw.js";
|
|
6
6
|
import "@justeattakeaway/pie-webc-core";
|
|
7
|
-
import "../PieElement-
|
|
7
|
+
import "../PieElement-DgjFUjAZ.js";
|
|
8
8
|
export {
|
|
9
9
|
P as PieListItem
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as t } from "@lit/react";
|
|
3
|
-
import { P as i } from "../index-
|
|
4
|
-
import { d as n, i as c } from "../index-
|
|
3
|
+
import { P as i } from "../index-K8-W-Okw.js";
|
|
4
|
+
import { d as n, i as c } from "../index-K8-W-Okw.js";
|
|
5
5
|
const s = t({
|
|
6
6
|
displayName: "PieListItem",
|
|
7
7
|
elementClass: i,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-list",
|
|
3
3
|
"description": "PIE Design System List built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@justeattakeaway/pie-components-config": "0.21.3",
|
|
41
|
-
"@justeattakeaway/pie-css": "1.
|
|
41
|
+
"@justeattakeaway/pie-css": "1.4.0",
|
|
42
42
|
"@justeattakeaway/pie-monorepo-utils": "0.9.8"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@justeattakeaway/pie-webc-core": "
|
|
45
|
+
"@justeattakeaway/pie-webc-core": "17.0.0",
|
|
46
46
|
"@lit/context": "1.1.6"
|
|
47
47
|
},
|
|
48
48
|
"customElements": "custom-elements.json",
|
package/src/list.scss
CHANGED
|
@@ -74,6 +74,11 @@ export interface ListItemProps {
|
|
|
74
74
|
*/
|
|
75
75
|
disabled?: boolean
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* When `true`, renders a bottom divider line on the item. Do not set this to true for the last item in a list.
|
|
79
|
+
*/
|
|
80
|
+
hasDivider?: boolean
|
|
81
|
+
|
|
77
82
|
/**
|
|
78
83
|
* Additional ARIA properties that the item cannot derive from its text props. `button.haspopup`
|
|
79
84
|
* applies when `interactionType="button"`: its value is forwarded to the internal `<button>`.
|
|
@@ -90,4 +95,5 @@ export const defaultProps: DefaultProps = {
|
|
|
90
95
|
hasMedia: false,
|
|
91
96
|
interactionType: 'none',
|
|
92
97
|
disabled: false,
|
|
98
|
+
hasDivider: false,
|
|
93
99
|
};
|
|
@@ -51,6 +51,9 @@ export class PieListItem extends PieElement implements ListItemProps {
|
|
|
51
51
|
@property({ type: Boolean })
|
|
52
52
|
disabled = defaultProps.disabled;
|
|
53
53
|
|
|
54
|
+
@property({ type: Boolean })
|
|
55
|
+
hasDivider = defaultProps.hasDivider;
|
|
56
|
+
|
|
54
57
|
@property({ type: Object })
|
|
55
58
|
aria: ListItemProps['aria'];
|
|
56
59
|
|
|
@@ -302,6 +305,7 @@ export class PieListItem extends PieElement implements ListItemProps {
|
|
|
302
305
|
'is-compact': this.isCompact,
|
|
303
306
|
'is-bold': this.isBold,
|
|
304
307
|
'has-media': this.hasMedia,
|
|
308
|
+
'has-divider': this.hasDivider,
|
|
305
309
|
'is-selectable': this._isSelectable,
|
|
306
310
|
'is-link': this._isLinkRow,
|
|
307
311
|
'is-button': this._isButtonRow,
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
// host declaration wins over a value inherited from an ancestor.
|
|
7
7
|
--list-item-inline-padding: var(--dt-spacing-d);
|
|
8
8
|
--list-item-alignment: flex-start;
|
|
9
|
-
--list-item-border: none;
|
|
10
9
|
|
|
11
10
|
// Using contents to remove the host from the box model so that the internal container element fully acts as the component shell
|
|
12
11
|
display: block;
|
|
@@ -16,21 +15,24 @@
|
|
|
16
15
|
.c-listItem-container {
|
|
17
16
|
--list-item-block-padding: var(--dt-spacing-d);
|
|
18
17
|
|
|
19
|
-
// The list component will add a border to each list-item that follows another. This ensures the height accounts for the added border.
|
|
20
|
-
--list-item-block-end-padding: calc(var(--list-item-block-padding) - var(--list-item-size-modifier));
|
|
21
|
-
|
|
22
18
|
padding-inline-start: var(--list-item-inline-padding);
|
|
23
19
|
padding-inline-end: var(--list-item-inline-padding);
|
|
24
20
|
|
|
25
21
|
padding-block-start: var(--list-item-block-padding);
|
|
26
|
-
padding-block-end: var(--list-item-block-
|
|
22
|
+
padding-block-end: var(--list-item-block-padding);
|
|
27
23
|
|
|
28
24
|
// Layout
|
|
29
25
|
display: flex;
|
|
30
26
|
align-items: var(--list-item-alignment);
|
|
31
27
|
gap: var(--dt-spacing-c);
|
|
32
28
|
min-height: 56px;
|
|
33
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// When hasDivider is true, show a bottom border and subtract 1px from padding-block-end so the
|
|
32
|
+
// total item height is unchanged whether the divider is present or not.
|
|
33
|
+
.c-listItem-container.has-divider {
|
|
34
|
+
padding-block-end: calc(var(--list-item-block-padding) - 1px);
|
|
35
|
+
border-bottom: 1px solid var(--dt-color-divider-default);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
// Two lines of text (primary + secondary) need top-alignment so leading/trailing
|