@justeattakeaway/pie-list 0.2.0 → 0.3.0

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
@@ -248,16 +248,18 @@ import '@justeattakeaway/pie-webc/components/thumbnail.js';
248
248
 
249
249
  ### Selectable lists
250
250
 
251
- `pie-list` itself is a static container with no selection or keyboard behaviour. To build a **selectable** list, do **not** put the controls in `pie-list`. Instead, place `pie-list-item`s inside a [`pie-radio-group`](https://webc.pie.design/?path=/docs/components-radio-group--overview) (single-select) with `selection-type="radio"`, and slot the control into each item's `leading` (or `trailing`) slot. The group lays the rows out as a divided list automatically.
251
+ `pie-list` itself is a static container with no selection or keyboard behaviour. To build a **selectable** list, do **not** put the controls in `pie-list`. Instead, place `pie-list-item`s inside a [`pie-radio-group`](https://webc.pie.design/?path=/docs/components-radio-group--overview) (single-select) or a [`pie-checkbox-group`](https://webc.pie.design/?path=/docs/components-checkbox-group--overview) (multi-select), set each item's `selectionType`, and slot the control into the item's `leading` (or `trailing`) slot.
252
252
 
253
- `selection-type` on each **item** makes that row selectable:
253
+ #### The `selectionType` prop
254
254
 
255
- - takes the correct **role** — `presentation` for `radio`/`checkbox` (so the group owns the controls directly), `listitem` for `switch` and `none`;
256
- - provides its `primaryText`, `secondaryText` and `metaText` as the slotted control's **accessible name and description** (and `aria-hidden`s the now-duplicated visible text);
257
- - **forwards a click** anywhere on the row to the control, so the whole row is a hit target;
258
- - shows **hover and active** states on the row (suppressed when the item's `disabled` is set, or the group is disabled).
255
+ `selectionType` is what makes a row selectable. Set it to `radio` or `checkbox` and it drives the item to:
259
256
 
260
- Provide the label through the item's `primaryText` — not as the control's own content. The group still owns the group-level semantics (its own role, shared `name`, selection coordination and group-disable).
257
+ - take the correct **role** — `presentation` for `radio`/`checkbox` (so the group owns the controls directly), `listitem` for `switch` and `none`;
258
+ - provide its `primaryText`, `secondaryText` and `metaText` as the slotted control's **accessible name and description** (and `aria-hidden` the now-duplicated visible text);
259
+ - **forward a click** anywhere on the row to the control, so the whole row is a hit target;
260
+ - show **hover and active** states on the row (suppressed when the control, or the group, is disabled).
261
+
262
+ Provide the label through the item's `primaryText` — not as the control's own content. The group still owns the group-level semantics (its own role, shared `name`, selection coordination and group-disable); `selectionType` only governs the item. See the [`pie-radio-group`](https://webc.pie.design/?path=/docs/components-radio-group--overview) and [`pie-checkbox-group`](https://webc.pie.design/?path=/docs/components-checkbox-group--overview) docs for the group behaviour.
261
263
 
262
264
  Single-select (radios):
263
265
 
@@ -268,18 +270,37 @@ import '@justeattakeaway/pie-webc/components/list-item.js';
268
270
  ```
269
271
 
270
272
  ```html
271
- <!-- `selection-type="radio"` makes each row selectable and the group lays them out as a divided
273
+ <!-- `selectionType="radio"` makes each row selectable and the group lays them out as a divided
272
274
  list. `value` on the group selects the matching radio (here, Express). -->
273
275
  <pie-radio-group name="delivery" value="express">
274
- <pie-list-item selection-type="radio" primaryText="Standard delivery" secondaryText="3 to 5 working days" metaText="Free">
276
+ <pie-list-item selectionType="radio" primaryText="Standard delivery" secondaryText="3 to 5 working days" metaText="Free">
275
277
  <pie-radio slot="leading" value="standard"></pie-radio>
276
278
  </pie-list-item>
277
- <pie-list-item selection-type="radio" primaryText="Express delivery" secondaryText="Next working day" metaText="£4.99">
279
+ <pie-list-item selectionType="radio" primaryText="Express delivery" secondaryText="Next working day" metaText="£4.99">
278
280
  <pie-radio slot="leading" value="express"></pie-radio>
279
281
  </pie-list-item>
280
282
  </pie-radio-group>
281
283
  ```
282
284
 
285
+ Multi-select (checkboxes):
286
+
287
+ ```js
288
+ import '@justeattakeaway/pie-webc/components/checkbox-group.js';
289
+ import '@justeattakeaway/pie-webc/components/checkbox.js';
290
+ import '@justeattakeaway/pie-webc/components/list-item.js';
291
+ ```
292
+
293
+ ```html
294
+ <pie-checkbox-group>
295
+ <pie-list-item selectionType="checkbox" primaryText="Cheese" secondaryText="Extra mature" metaText="Free">
296
+ <pie-checkbox slot="leading" name="cheese"></pie-checkbox>
297
+ </pie-list-item>
298
+ <pie-list-item selectionType="checkbox" primaryText="Pepperoni" secondaryText="Spicy">
299
+ <pie-checkbox slot="leading" name="pepperoni"></pie-checkbox>
300
+ </pie-list-item>
301
+ </pie-checkbox-group>
302
+ ```
303
+
283
304
  **For Native JS Applications, Vue, Angular, Svelte etc.:**
284
305
 
285
306
  ```js
@@ -163,7 +163,7 @@
163
163
  {
164
164
  "kind": "field",
165
165
  "name": "selectionType",
166
- "attribute": "selection-type"
166
+ "attribute": "selectionType"
167
167
  },
168
168
  {
169
169
  "kind": "field",
@@ -308,7 +308,7 @@
308
308
  "fieldName": "hasMedia"
309
309
  },
310
310
  {
311
- "name": "selection-type",
311
+ "name": "selectionType",
312
312
  "fieldName": "selectionType"
313
313
  },
314
314
  {
@@ -4,7 +4,7 @@ const t = class t extends i {
4
4
  this.getAttribute("v") || this.setAttribute("v", t.v);
5
5
  }
6
6
  };
7
- t.v = "0.2.0";
7
+ t.v = "0.3.0";
8
8
  let s = t;
9
9
  export {
10
10
  s as P
@@ -2,7 +2,7 @@ import { unsafeCSS as x, isServer as f, html as p, nothing as m } from "lit";
2
2
  import { property as c, state as y } from "lit/decorators.js";
3
3
  import { classMap as k } from "lit/directives/class-map.js";
4
4
  import { validPropertyValues as _, safeCustomElement as T, ariaContext as I, parentDisabledContext as C } from "@justeattakeaway/pie-webc-core";
5
- import { P as w } from "./PieElement-B3g_8vKy.js";
5
+ import { P as w } from "./PieElement-ab_PEQpW.js";
6
6
  /**
7
7
  * @license
8
8
  * Copyright 2021 Google LLC
@@ -245,7 +245,7 @@ l([
245
245
  c({ type: Boolean })
246
246
  ], n.prototype, "hasMedia", 2);
247
247
  l([
248
- c({ type: String, attribute: "selection-type" }),
248
+ c({ type: String }),
249
249
  _($, z, d.selectionType)
250
250
  ], n.prototype, "selectionType", 2);
251
251
  l([
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { html as n, unsafeCSS as m } from "lit";
2
- import { P as f } from "./PieElement-B3g_8vKy.js";
2
+ import { P as f } from "./PieElement-ab_PEQpW.js";
3
3
  import { RtlMixin as d, safeCustomElement as p } from "@justeattakeaway/pie-webc-core";
4
4
  const c = "*,*:after,*:before{box-sizing:inherit}:host{display:block}:host ::slotted(pie-list-item:not(:last-of-type)){--list-item-size-modifier: 1px;--list-item-border: var(--list-item-size-modifier) solid var(--dt-color-divider-default)}";
5
5
  var b = Object.getOwnPropertyDescriptor, u = (s, r, a, l) => {
@@ -1,9 +1,9 @@
1
1
  import "lit";
2
2
  import "lit/decorators.js";
3
3
  import "lit/directives/class-map.js";
4
- import { P as s } from "../index-KnN5fPmj.js";
4
+ import { P as s } from "../index-mqipXuiX.js";
5
5
  import "@justeattakeaway/pie-webc-core";
6
- import "../PieElement-B3g_8vKy.js";
6
+ import "../PieElement-ab_PEQpW.js";
7
7
  export {
8
8
  s as PieListItem
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
- import { P as s } from "../index-KnN5fPmj.js";
4
- import { d as c, s as n } from "../index-KnN5fPmj.js";
3
+ import { P as s } from "../index-mqipXuiX.js";
4
+ import { d as c, s as n } from "../index-mqipXuiX.js";
5
5
  const i = t({
6
6
  displayName: "PieListItem",
7
7
  elementClass: s,
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.2.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "devDependencies": {
40
40
  "@justeattakeaway/pie-components-config": "0.21.3",
41
41
  "@justeattakeaway/pie-css": "1.3.1",
42
- "@justeattakeaway/pie-monorepo-utils": "0.9.7"
42
+ "@justeattakeaway/pie-monorepo-utils": "0.9.8"
43
43
  },
44
44
  "dependencies": {
45
45
  "@justeattakeaway/pie-webc-core": "16.1.0",
@@ -42,7 +42,7 @@ export class PieListItem extends PieElement implements ListItemProps {
42
42
  @property({ type: Boolean })
43
43
  hasMedia = defaultProps.hasMedia;
44
44
 
45
- @property({ type: String, attribute: 'selection-type' })
45
+ @property({ type: String })
46
46
  @validPropertyValues(componentSelector, selectionTypes, defaultProps.selectionType)
47
47
  selectionType = defaultProps.selectionType;
48
48