Skip to content

Commit dc9b993

Browse files
committed
doc(elements): Explain how pos-list works and that it needs a template
1 parent d4057f2 commit dc9b993

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

docs/elements/components/pos-list/readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
<!-- Auto Generated Below -->
44

55

6+
## Overview
7+
8+
Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
9+
or by a class for which instances will be listed.
10+
11+
`pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
12+
in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
13+
will then render the label of each list item.
14+
615
## Properties
716

817
| Property | Attribute | Description | Type | Default |

elements/src/components.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ export namespace Components {
138138
*/
139139
interface PosLabel {
140140
}
141+
/**
142+
* Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
143+
* or by a class for which instances will be listed.
144+
* `pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
145+
* in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
146+
* will then render the label of each list item.
147+
*/
141148
interface PosList {
142149
/**
143150
* Whether listed resources should be fetched before being displayed
@@ -825,6 +832,13 @@ declare global {
825832
"pod-os:resource": any;
826833
"pod-os:init": any;
827834
}
835+
/**
836+
* Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
837+
* or by a class for which instances will be listed.
838+
* `pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
839+
* in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
840+
* will then render the label of each list item.
841+
*/
828842
interface HTMLPosListElement extends Components.PosList, HTMLStencilElement {
829843
addEventListener<K extends keyof HTMLPosListElementEventMap>(type: K, listener: (this: HTMLPosListElement, ev: PosListCustomEvent<HTMLPosListElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
830844
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -1518,6 +1532,13 @@ declare namespace LocalJSX {
15181532
interface PosLabel {
15191533
"onPod-os:resource"?: (event: PosLabelCustomEvent<any>) => void;
15201534
}
1535+
/**
1536+
* Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
1537+
* or by a class for which instances will be listed.
1538+
* `pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
1539+
* in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
1540+
* will then render the label of each list item.
1541+
*/
15211542
interface PosList {
15221543
/**
15231544
* Whether listed resources should be fetched before being displayed
@@ -1963,6 +1984,13 @@ declare module "@stencil/core" {
19631984
* Displays a human-readable label of the resource, provided by [Thing.label()](https://pod-os.org/reference/core/classes/thing/#label)
19641985
*/
19651986
"pos-label": LocalJSX.IntrinsicElements["pos-label"] & JSXBase.HTMLAttributes<HTMLPosLabelElement>;
1987+
/**
1988+
* Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
1989+
* or by a class for which instances will be listed.
1990+
* `pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
1991+
* in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
1992+
* will then render the label of each list item.
1993+
*/
19661994
"pos-list": LocalJSX.IntrinsicElements["pos-list"] & JSXBase.HTMLAttributes<HTMLPosListElement>;
19671995
"pos-literals": LocalJSX.IntrinsicElements["pos-literals"] & JSXBase.HTMLAttributes<HTMLPosLiteralsElement>;
19681996
"pos-login": LocalJSX.IntrinsicElements["pos-login"] & JSXBase.HTMLAttributes<HTMLPosLoginElement>;

elements/src/components/pos-list/pos-list.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import { ResourceAware, ResourceEventEmitter, subscribeResource } from '../event
44
import { PodOsAware, PodOsEventEmitter, subscribePodOs } from '../events/PodOsAware';
55
import { Subject, takeUntil } from 'rxjs';
66

7+
/**
8+
* Renders a template for each resource in a list. The list is either defined by a relation from the parent resource
9+
* or by a class for which instances will be listed.
10+
*
11+
* `pos-list` must contain a `<template>` as a single child component. This template will be used to render each resource
12+
* in the list. All PodOS elements within this template will receive the listed resource as their context, e.g. a `pos-label`
13+
* will then render the label of each list item.
14+
*/
715
@Component({
816
tag: 'pos-list',
917
shadow: false,

0 commit comments

Comments
 (0)