@cas-smartdesign/list 6.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/LICENSE +8 -0
- package/dist/docs/declarative-list-item.js +1 -0
- package/dist/docs/doc.css +1 -0
- package/dist/docs/doc.mjs +447 -0
- package/dist/docs/icon.svg +1 -0
- package/dist/docs/index.html +28 -0
- package/dist/docs/lock.svg +1 -0
- package/dist/docs/multi-select.js +1 -0
- package/dist/docs/right-arrow.svg +6 -0
- package/dist/docs/sample-data.mjs +1 -0
- package/dist/docs/single-select.js +1 -0
- package/dist/docs/trigger-only.js +1 -0
- package/dist/list-with-externals.js +133 -0
- package/dist/list-with-externals.js.map +7 -0
- package/dist/list.d.ts +68 -0
- package/dist/list.mjs +264 -0
- package/dist/list.mjs.map +1 -0
- package/npm-third-party-licenses.json +192 -0
- package/package.json +35 -0
- package/readme.md +71 -0
package/readme.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @cas-smartdesign/list
|
|
2
|
+
|
|
3
|
+
An element that renders a given array of items in a list.
|
|
4
|
+
|
|
5
|
+
## Attributes
|
|
6
|
+
|
|
7
|
+
- `selection-type`: string
|
|
8
|
+
- Defines the type of selection that the list uses. Allowed values are:
|
|
9
|
+
- `single`: the list items can be selected one at a time, the `selected` attribute is set on the selected item
|
|
10
|
+
- `extended`: multiple list items can be selected, the `selected` attribute is set on the selected items
|
|
11
|
+
- `trigger-only`: the `selected` attribute is not set on the selected item(s)
|
|
12
|
+
- `role`: string
|
|
13
|
+
- Aria attribute, default value is "list"
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
- `items`: array
|
|
18
|
+
- The data to be used by the list.
|
|
19
|
+
- `itemGenerator`: ItemGenerator
|
|
20
|
+
- A function that creates a HTMLElement from an element of the `items` array to be rendered by the list.
|
|
21
|
+
- If it is not set then the default implementation is used.
|
|
22
|
+
- `selectedIndexes`: array
|
|
23
|
+
- The indexes of the currently selected items.
|
|
24
|
+
|
|
25
|
+
## CSS Custom Properties
|
|
26
|
+
|
|
27
|
+
- `--sd-list-base-background-color`
|
|
28
|
+
- Defines the background color of the list
|
|
29
|
+
- This is only present due to backward compatibility reasons, as it might be easier to change the background of an item with regular css rules
|
|
30
|
+
|
|
31
|
+
## Custom Events
|
|
32
|
+
|
|
33
|
+
- `selection`
|
|
34
|
+
- Dispatched when one of the items is selected/deselected
|
|
35
|
+
- Contains the index of the item and a `selected` flag which is when false indicates that the item is deselected
|
|
36
|
+
- The `hasModifier` property is true if mouse wheel or ctrl/meta key is down while selection. Note that the auto scroll feature is disabled while middle mouse click.
|
|
37
|
+
|
|
38
|
+
## Public methods
|
|
39
|
+
|
|
40
|
+
- `getListItem`
|
|
41
|
+
- Returns the DOM node that represents the item with the given index
|
|
42
|
+
- `increaseWidthIfNeeded`
|
|
43
|
+
- The width of the list is increased to an extent, that all texts in the list-items are visible without ellipsis.
|
|
44
|
+
- If the list has already reached it's maximum width, then line clamp may be enabled on the items to wrap the content if possible.
|
|
45
|
+
- Note that this functionality works only if `sd-list-items` are rendered in the list
|
|
46
|
+
|
|
47
|
+
## Selection state
|
|
48
|
+
|
|
49
|
+
The list marks the items with `selected` attribute in case if they are selected, but does not define any style for this state.
|
|
50
|
+
The items generated by the `itemGenerator` can use this attribute if custom logic is required.
|
|
51
|
+
|
|
52
|
+
## A11Y
|
|
53
|
+
|
|
54
|
+
The default _role_ is `listbox`, with the corresponding `option` role on the items, since most of the time this element is used with a selection state.
|
|
55
|
+
It ensures the items have an associated id which is used to update `aria-activedescendant`.
|
|
56
|
+
The selection is also marked with `aria-selected`.
|
|
57
|
+
|
|
58
|
+
Please note that the selection type `trigger-only` does not provide any accessibility event in case of a selection,
|
|
59
|
+
but it can be added externally for example with an `aria-live` area where the content can notify about the selection.
|
|
60
|
+
Although normally the page would change by such a selection, so it may not be necessary to do this notification.
|
|
61
|
+
|
|
62
|
+
## Attributes managed on items
|
|
63
|
+
|
|
64
|
+
In addition to above mentioned aria attributes, the items are marked with certain custom attributes:
|
|
65
|
+
|
|
66
|
+
- `focused`
|
|
67
|
+
- Set if the item is currently focused.
|
|
68
|
+
- `selected`
|
|
69
|
+
- Set if the item is selected.
|
|
70
|
+
|
|
71
|
+
## Examples
|