@grucloud/bau-ui 0.301.0 → 0.303.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.
Files changed (61) hide show
  1. package/accordion/accordion.js +36 -63
  2. package/alert/alert.js +14 -24
  3. package/alertStack/README.md +89 -0
  4. package/alertStack/alertStack.js +98 -28
  5. package/animate/animate.js +2 -0
  6. package/autocomplete/autocomplete.js +130 -164
  7. package/avatar/avatar.js +20 -25
  8. package/breadcrumbs/breadcrumbs.js +34 -30
  9. package/button/button.js +27 -41
  10. package/buttonGroup/buttonGroup.js +20 -27
  11. package/calendar/calendar.js +6 -12
  12. package/carousel/carousel.js +64 -47
  13. package/checkbox/checkbox.js +10 -13
  14. package/chip/chip.js +9 -0
  15. package/collapsible/collapsible.js +73 -47
  16. package/collapsible/index.d.ts +12 -1
  17. package/constants.d.ts +1 -0
  18. package/constants.js +4 -0
  19. package/divider/divider.js +1 -0
  20. package/drawer/drawer.js +48 -1
  21. package/drillDownMenu/drillDownMenu.js +90 -67
  22. package/dropdownMenu/dropdownMenu.js +29 -122
  23. package/fileInput/fileInput.js +4 -0
  24. package/globalStyle/globalStyle.js +75 -30
  25. package/input/input.js +35 -44
  26. package/inputSearch/inputSearch.js +26 -31
  27. package/lazy/lazy.js +8 -5
  28. package/linearProgress/linearProgress.js +12 -24
  29. package/list/list.js +2 -1
  30. package/loadingButton/loadingButton.js +29 -22
  31. package/modal/modal.js +38 -41
  32. package/multiSelect/multiSelect.js +84 -171
  33. package/package.json +13 -5
  34. package/paginationNavigation/paginationNavigation.js +8 -13
  35. package/popover/popover.js +5 -2
  36. package/radioButton/radioButton.js +10 -23
  37. package/radioButtonGroup/radioButtonGroup.js +15 -24
  38. package/resizable/resizable.js +74 -70
  39. package/select/select.js +84 -160
  40. package/selectNative/selectNative.js +2 -0
  41. package/slider/slider.js +6 -12
  42. package/spinner/spinner.js +37 -53
  43. package/stepper/stepper.js +23 -35
  44. package/switch/switch.js +28 -45
  45. package/tableOfContent/tableOfContent.js +55 -84
  46. package/tablePagination/tablePagination.js +39 -69
  47. package/tabs/tabs.js +95 -59
  48. package/textareaAutosize/textareaAutosize.js +13 -16
  49. package/themeSwitch/themeSwitch.js +27 -41
  50. package/toggle/index.d.ts +8 -1
  51. package/toggle/toggle.js +17 -9
  52. package/toggleGroup/toggleGroup.js +23 -28
  53. package/tooltip/tooltip.js +79 -94
  54. package/treeView/treeView.js +57 -25
  55. package/utils/control.js +20 -0
  56. package/utils/popupList.js +137 -0
  57. package/utils/urlChange.js +32 -0
  58. package/virtualList/index.d.ts +27 -0
  59. package/virtualList/index.js +1 -0
  60. package/virtualList/virtualList.js +111 -0
  61. package/vite.config.js +48 -0
@@ -1,4 +1,7 @@
1
1
  import { toPropsAndChildren } from "@grucloud/bau/bau.js";
2
+ import { focusable } from "../utils/control.js";
3
+
4
+ let tooltipCount = 0;
2
5
 
3
6
  export default function (context, options = {}) {
4
7
  const { bau, css, window } = context;
@@ -40,49 +43,34 @@ export default function (context, options = {}) {
40
43
  right: 100%;
41
44
  padding-right: 0.3rem;
42
45
  }
43
- & .top.start.container {
44
- left: 0%;
45
- }
46
- & .top.centered.container {
47
- left: 50%;
48
- transform: translateX(-50%);
49
- }
50
- & .top.end.container {
51
- left: 100%;
52
- transform: translateX(-100%);
53
- }
54
- & .bottom.start.container {
55
- left: 0%;
56
- }
57
- & .bottom.centered.container {
58
- left: 50%;
59
- transform: translateX(-50%);
60
- }
61
- & .bottom.end.container {
62
- left: 100%;
63
- transform: translateX(-100%);
64
- }
65
- & .right.start.container {
66
- top: 0%;
67
- }
68
- & .right.centered.container {
69
- top: 50%;
70
- transform: translateY(-50%);
71
- }
72
- & .right.end.container {
73
- top: 100%;
74
- transform: translateY(-100%);
75
- }
76
- & .left.start.container {
77
- top: 0%;
78
- }
79
- & .left.centered.container {
80
- top: 50%;
81
- transform: translateY(-50%);
46
+ /* Along the side: at its start, centered or at its end */
47
+ & .top.container,
48
+ & .bottom.container {
49
+ &.start {
50
+ left: 0%;
51
+ }
52
+ &.centered {
53
+ left: 50%;
54
+ transform: translateX(-50%);
55
+ }
56
+ &.end {
57
+ left: 100%;
58
+ transform: translateX(-100%);
59
+ }
82
60
  }
83
- & .left.end.container {
84
- top: 100%;
85
- transform: translateY(-100%);
61
+ & .left.container,
62
+ & .right.container {
63
+ &.start {
64
+ top: 0%;
65
+ }
66
+ &.centered {
67
+ top: 50%;
68
+ transform: translateY(-50%);
69
+ }
70
+ &.end {
71
+ top: 100%;
72
+ transform: translateY(-100%);
73
+ }
86
74
  }
87
75
  `;
88
76
 
@@ -99,80 +87,77 @@ export default function (context, options = {}) {
99
87
  children,
100
88
  ] = toPropsAndChildren(args);
101
89
 
90
+ const tooltipId = `tooltip-${++tooltipCount}`;
102
91
  const tooltipContentEl = div(
103
92
  {
104
93
  class: ["container", ...side.split("-")],
105
94
  },
106
95
  div(
107
- { class: ["content", color, variant, size], role: "tooltip" },
96
+ {
97
+ id: tooltipId,
98
+ class: ["content", color, variant, size],
99
+ role: "tooltip",
100
+ },
108
101
  titleEl
109
102
  )
110
103
  );
111
104
 
112
- const toMovedClass = (add) => `move-to-${add}`;
113
-
114
- const addClassMoved = (cond, add, remove) => {
115
- if (cond()) {
116
- const movedClass = toMovedClass(add);
117
- tooltipContentEl.classList.add(movedClass);
118
- tooltipContentEl.classList.add(add);
119
- tooltipContentEl.classList.remove(remove);
120
- }
105
+ // Shown in the window: past one of its edges, on the other side
106
+ const sideClasses = ["container", ...side.split("-")];
107
+ const show = () => {
108
+ const rect = tooltipContentEl.getBoundingClientRect();
109
+ const moves = [
110
+ rect.x < 0 && ["right", "left"],
111
+ rect.right > window.innerWidth && ["left", "right"],
112
+ rect.y < 0 && ["bottom", "top"],
113
+ rect.bottom > window.innerHeight && ["top", "bottom"],
114
+ ].filter(Boolean);
115
+ tooltipContentEl.className = [
116
+ ...sideClasses.filter(
117
+ (name) => !moves.some(([, from]) => from == name)
118
+ ),
119
+ ...moves.map(([to]) => to),
120
+ "visible",
121
+ ].join(" ");
121
122
  };
122
-
123
- const removeClassMoved = (add, remove) => {
124
- const movedClass = toMovedClass(add);
125
- if (tooltipContentEl.classList.contains(movedClass)) {
126
- tooltipContentEl.classList.remove(movedClass);
127
- tooltipContentEl.classList.add(remove);
128
- tooltipContentEl.classList.remove(add);
129
- }
130
- };
131
-
132
- const mouseover = (event) => {
133
- const tooltipRect = tooltipContentEl.getBoundingClientRect();
134
- // TODO event.target["aria-describedby"]
135
- addClassMoved(() => tooltipRect.x < 0, "right", "left");
136
- addClassMoved(
137
- () => tooltipRect.x + tooltipRect.width > window.innerWidth,
138
- "left",
139
- "right"
140
- );
141
- addClassMoved(() => tooltipRect.y < 0, "bottom", "top"),
142
- addClassMoved(
143
- () => tooltipRect.bottom > window.innerHeight,
144
- "top",
145
- "bottom"
146
- );
147
- tooltipContentEl.classList.add("visible");
148
- };
149
-
150
- const mouseout = (event) => {
151
- tooltipContentEl.classList.remove("visible");
152
- removeClassMoved("right", "left");
153
- removeClassMoved("left", "right");
154
- removeClassMoved("bottom", "top");
155
- removeClassMoved("top", "bottom");
123
+ const hide = () => {
124
+ tooltipContentEl.className = sideClasses.join(" ");
156
125
  };
157
126
 
158
127
  const rootEl = div(
159
128
  {
160
129
  ...props,
161
- class: ["tooltip", className, options?.class, props?.class],
162
- bauMounted: ({ element }) => {
163
- element.addEventListener("mouseover", mouseover);
164
- element.addEventListener("mouseout", mouseout);
130
+ class: ["tooltip", className, options.class, props.class],
131
+ onmouseover: show,
132
+ onmouseout: hide,
133
+ // The keyboard shows it too, at once, not when mounted: it can get
134
+ // the focus before the next frame
135
+ // addEventListener: the DOM has no onfocusin property
136
+ // No removeEventListener: collected with the element
137
+ bauCreated: ({ element }) => {
138
+ element.addEventListener("focusin", show);
139
+ element.addEventListener("focusout", hide);
165
140
  },
166
- bauUnmounted: ({ element }) => {
167
- element.removeEventListener("mouseover", mouseover);
168
- element.removeEventListener("mouseout", mouseout);
141
+ // Dismissed without moving the pointer or the focus
142
+ // A block: a handler returning false would cancel every other key
143
+ onkeydown: (event) => {
144
+ event.key == "Escape" && hide();
169
145
  },
170
146
  },
171
-
172
147
  children,
173
148
  tooltipContentEl
174
149
  );
175
150
 
151
+ // The tooltip describes its trigger, the first control in it, or the
152
+ // tooltip itself, made focusable
153
+ const triggerEl = rootEl.querySelector(focusable);
154
+ if (triggerEl && !tooltipContentEl.contains(triggerEl)) {
155
+ triggerEl.setAttribute("aria-describedby", tooltipId);
156
+ } else {
157
+ rootEl.setAttribute("tabindex", "0");
158
+ rootEl.setAttribute("aria-describedby", tooltipId);
159
+ }
160
+
176
161
  return rootEl;
177
162
  };
178
163
  }
@@ -43,6 +43,33 @@ const createStyles = ({ css, createGlobalStyles }) => {
43
43
  background: inherit;
44
44
  & .header {
45
45
  width: 100%;
46
+ /* The chevron is the button */
47
+ &::before {
48
+ display: none;
49
+ }
50
+ & .toggle {
51
+ border: none;
52
+ background: none;
53
+ color: inherit;
54
+ font: inherit;
55
+ line-height: 1rem;
56
+ padding: 0.5rem;
57
+ /* WCAG 2.5.8, the size of a target */
58
+ min-width: 24px;
59
+ cursor: pointer;
60
+ &::before {
61
+ content: "\u203A";
62
+ display: inline-block;
63
+ transition: transform var(--transition-fast) linear;
64
+ }
65
+ &[aria-expanded="true"]::before {
66
+ transform: rotate(90deg);
67
+ }
68
+ &:focus-visible {
69
+ outline: 2px solid var(--color-primary);
70
+ outline-offset: -2px;
71
+ }
72
+ }
46
73
  display: flex;
47
74
  justify-content: space-between;
48
75
  align-items: center;
@@ -50,6 +77,9 @@ const createStyles = ({ css, createGlobalStyles }) => {
50
77
  &:hover {
51
78
  filter: brightness(var(--brightness-hover));
52
79
  }
80
+ }
81
+ /* The item, with its children or not: in the color of the tree */
82
+ & .item {
53
83
  & a,
54
84
  & span {
55
85
  display: flex;
@@ -71,10 +101,10 @@ const createStyles = ({ css, createGlobalStyles }) => {
71
101
  };
72
102
  };
73
103
 
74
- export default function (context, options = {}) {
104
+ export default function (context, options) {
75
105
  const { bau, css, createGlobalStyles } = context;
76
106
  const { renderMenuItem } = options;
77
- const { ul, li, nav, div } = bau.tags;
107
+ const { ul, li, nav, div, button } = bau.tags;
78
108
 
79
109
  const styles = createStyles({ css, createGlobalStyles });
80
110
 
@@ -84,26 +114,34 @@ export default function (context, options = {}) {
84
114
  ({ depth = 1, maxDepth, parent, color, variant, size }) =>
85
115
  (item) => {
86
116
  const { children, expanded } = item;
87
- const closeState = bau.state(!expanded);
117
+ const expandable = children.length > 0 && depth < maxDepth;
88
118
 
89
- const Header = () =>
90
- div(
119
+ // The item, and the button that expands its children: the item can be
120
+ // a link, or hold a checkbox
121
+ const Header = () => {
122
+ const itemEl = renderMenuItem({ item, parent, depth });
123
+ return div(
91
124
  {
92
- class: css`
93
- cursor: ${children ? "pointer" : "auto"};
94
- display: inline-flex;
95
- justify-content: flex-start;
96
- align-items: center;
97
- width: 100%;
98
- `,
99
- onclick: (event) => {
100
- if (children) {
101
- closeState.val = !closeState.val;
102
- }
103
- },
125
+ class: [
126
+ "item",
127
+ css`
128
+ cursor: ${expandable ? "pointer" : "auto"};
129
+ display: inline-flex;
130
+ justify-content: flex-start;
131
+ align-items: center;
132
+ width: 100%;
133
+ `,
134
+ ],
104
135
  },
105
- renderMenuItem({ item, parent, depth })
136
+ expandable &&
137
+ button({
138
+ type: "button",
139
+ class: "toggle",
140
+ "aria-label": itemEl.textContent.trim() || "Toggle",
141
+ }),
142
+ itemEl
106
143
  );
144
+ };
107
145
 
108
146
  const Content = () =>
109
147
  ul(
@@ -113,13 +151,7 @@ export default function (context, options = {}) {
113
151
  children.map(Tree({ depth: depth + 1, maxDepth, parent: item }))
114
152
  );
115
153
  return li(
116
- children.length
117
- ? Collapsible({
118
- expanded,
119
- Header,
120
- Content: children && depth < maxDepth && Content,
121
- })
122
- : Header()
154
+ expandable ? Collapsible({ expanded, Header, Content }) : Header()
123
155
  );
124
156
  };
125
157
 
@@ -0,0 +1,20 @@
1
+ // The elements the keyboard reaches
2
+ export const focusable =
3
+ "button, a[href], input, select, textarea, [tabindex]:not([tabindex='-1'])";
4
+
5
+ // The control an element is or holds, like the button of a header: it gets
6
+ // the aria attributes that tell what it does
7
+ export const controlIn = (element, selector = focusable) =>
8
+ element instanceof Element
9
+ ? element.matches(selector)
10
+ ? element
11
+ : element.querySelector(selector)
12
+ : null;
13
+
14
+ // Enter and Space press an element that is a button by its role
15
+ export const onkeydownButton = (onpress) => (event) => {
16
+ if (event.key == "Enter" || event.key == " ") {
17
+ event.preventDefault();
18
+ onpress(event);
19
+ }
20
+ };
@@ -0,0 +1,137 @@
1
+ import popover from "../popover/popover.js";
2
+ import button from "../button/button.js";
3
+ import list from "../list/list.js";
4
+
5
+ // The ids of the lists and their items
6
+ let count = 0;
7
+
8
+ // A button that opens a list in a popover: a listbox of options, or a menu.
9
+ // The focus goes to the list, which tells the active item with
10
+ // aria-activedescendant: the arrow keys, Home and End move it, Enter and
11
+ // Space click it, Escape closes. Closing gives the focus back to the button.
12
+ export default function popupList(context) {
13
+ const { bau } = context;
14
+ const { li } = bau.tags;
15
+ const Button = button(context);
16
+ const Popover = popover(context);
17
+ const List = list(context);
18
+
19
+ return function PopupList({
20
+ role,
21
+ label,
22
+ items,
23
+ Item,
24
+ itemProps,
25
+ onClickItem,
26
+ // The item active when it opens; without, the one before
27
+ activeOnOpen,
28
+ listProps,
29
+ buttonProps,
30
+ buttonChildren,
31
+ color,
32
+ variant,
33
+ size,
34
+ }) {
35
+ const activeState = bau.state(0);
36
+ const openState = bau.state(false);
37
+
38
+ const id = `${role}-${++count}`;
39
+ const itemId = (index) => `${id}-item-${index}`;
40
+
41
+ const open = () => {
42
+ if (activeOnOpen) activeState.val = activeOnOpen();
43
+ popoverEl.openDialog();
44
+ listEl.focus();
45
+ openState.val = true;
46
+ };
47
+ // Closed by Escape or a click outside too: onClose
48
+ const close = () => popoverEl.closeDialog();
49
+
50
+ const last = () => items.length - 1;
51
+ const onkeydown = (event) => {
52
+ if (!popoverEl.open) {
53
+ // The arrow keys open it too; Enter and Space click the button
54
+ if (event.key == "ArrowDown" || event.key == "ArrowUp") {
55
+ event.preventDefault();
56
+ open();
57
+ }
58
+ return;
59
+ }
60
+ const active = activeState.val;
61
+ const moves = {
62
+ ArrowDown: () => (active < last() ? active + 1 : 0),
63
+ ArrowUp: () => (active <= 0 ? last() : active - 1),
64
+ Home: () => 0,
65
+ End: last,
66
+ };
67
+ if (moves[event.key]) {
68
+ activeState.val = moves[event.key]();
69
+ listEl.children[activeState.val].scrollIntoView({ block: "nearest" });
70
+ } else if (event.key == "Enter" || event.key == " ") {
71
+ // As a click does: on the element of the item, a link for instance
72
+ const itemEl = listEl.children[active];
73
+ (itemEl.firstElementChild ?? itemEl).click();
74
+ } else if (event.key == "Escape") {
75
+ close();
76
+ } else {
77
+ // Tab and the other keys keep their default
78
+ return;
79
+ }
80
+ event.preventDefault();
81
+ };
82
+
83
+ const listEl = List(
84
+ {
85
+ id: `${id}-list`,
86
+ role,
87
+ tabindex: "-1",
88
+ "aria-label": label,
89
+ "aria-activedescendant": () => itemId(activeState.val),
90
+ class: [color, variant],
91
+ ...listProps,
92
+ },
93
+ items.map((item, index) =>
94
+ li(
95
+ {
96
+ id: itemId(index),
97
+ class: () => [activeState.val == index && "active"],
98
+ onclick: (event) => {
99
+ activeState.val = index;
100
+ onClickItem(index);
101
+ event.preventDefault();
102
+ },
103
+ ...itemProps(index),
104
+ },
105
+ Item(item)
106
+ )
107
+ )
108
+ );
109
+
110
+ const buttonEl = Button(
111
+ {
112
+ type: "button",
113
+ "aria-haspopup": role,
114
+ "aria-controls": `${id}-list`,
115
+ "aria-expanded": () => String(openState.val),
116
+ onclick: (event) => {
117
+ popoverEl.open ? close() : open();
118
+ event.preventDefault();
119
+ },
120
+ color,
121
+ variant,
122
+ size,
123
+ ...buttonProps,
124
+ },
125
+ buttonChildren
126
+ );
127
+
128
+ const popoverEl = Popover({
129
+ "aria-label": label,
130
+ triggerEl: buttonEl,
131
+ contentEl: listEl,
132
+ onClose: () => (openState.val = false),
133
+ });
134
+
135
+ return { buttonEl, popoverEl, onkeydown, close };
136
+ };
137
+ }
@@ -0,0 +1,32 @@
1
+ // The components on the page following the query of the url, like the tabs
2
+ // and the stepper, told when it changes with pushState: by a click on one of
3
+ // them, or on a link of the app with the router. pushState is watched once,
4
+ // whatever the number of components.
5
+ const listeners = new Set();
6
+ let watching = false;
7
+
8
+ const watch = (window) => {
9
+ if (watching) return;
10
+ watching = true;
11
+ window.history.pushState = new Proxy(window.history.pushState, {
12
+ apply: (target, thisArg, argArray) => {
13
+ target.apply(thisArg, argArray);
14
+ const url = argArray[2] ?? "";
15
+ if (["?", "#"].includes(url[0])) {
16
+ listeners.forEach((listener) => listener());
17
+ }
18
+ },
19
+ });
20
+ };
21
+
22
+ // Calls the listener on a change of the query or of the hash, until the
23
+ // function returned is called
24
+ export const onUrlChange = (window, listener) => {
25
+ watch(window);
26
+ listeners.add(listener);
27
+ window.addEventListener("popstate", listener);
28
+ return () => {
29
+ listeners.delete(listener);
30
+ window.removeEventListener("popstate", listener);
31
+ };
32
+ };
@@ -0,0 +1,27 @@
1
+ declare module "@grucloud/bau-ui/virtualList" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+ type ReadonlyState<T> = import("@grucloud/bau").ReadonlyState<T>;
5
+
6
+ export type VirtualListProps<T = any> = {
7
+ // The items, a state of an array
8
+ items: ReadonlyState<T[]>;
9
+ // The element of an item
10
+ Item: (item: T, index: number) => HTMLElement;
11
+ // The height of a row in px, the same for all; 40 by default
12
+ itemHeight?: number;
13
+ // The rows rendered before and after those in view; 5 by default
14
+ overscan?: number;
15
+ } & DefaultDesignProps &
16
+ import("@grucloud/bau").PropsAll<HTMLDivElement>;
17
+
18
+ type Option = {
19
+ itemHeight?: number;
20
+ overscan?: number;
21
+ } & ComponentOption;
22
+
23
+ export default function (
24
+ context: any,
25
+ option?: Option
26
+ ): <T>(props: VirtualListProps<T>) => HTMLDivElement;
27
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./virtualList";
@@ -0,0 +1,111 @@
1
+ export default function (context, options = {}) {
2
+ const { bau, css, window } = context;
3
+ const { div, ul, li } = bau.tags;
4
+
5
+ const className = css`
6
+ display: block;
7
+ height: 20rem;
8
+ overflow-y: auto;
9
+ position: relative;
10
+ box-sizing: border-box;
11
+ border-radius: var(--global-radius);
12
+ &.outline {
13
+ border: 1px solid var(--color-border-subtle);
14
+ }
15
+ &.solid {
16
+ background-color: var(--accent-lightest);
17
+ }
18
+ & > ul {
19
+ position: relative;
20
+ list-style: none;
21
+ margin: 0;
22
+ padding: 0;
23
+ }
24
+ & > ul > li {
25
+ position: absolute;
26
+ left: 0;
27
+ right: 0;
28
+ box-sizing: border-box;
29
+ display: flex;
30
+ align-items: center;
31
+ overflow: hidden;
32
+ }
33
+ `;
34
+
35
+ return function VirtualList({
36
+ size = options.size ?? "md",
37
+ variant = options.variant ?? "outline",
38
+ color = options.color ?? "neutral",
39
+ // The items, a state of an array
40
+ items,
41
+ // The element of an item: Item(item, index)
42
+ Item,
43
+ // The height of a row in px, the same for all
44
+ itemHeight = options.itemHeight ?? 40,
45
+ // The rows rendered before and after those in view
46
+ overscan = options.overscan ?? 5,
47
+ ...props
48
+ }) {
49
+ // The rows rendered, from start to end, excluded. A scroll renders them
50
+ // again only when the rows in view are not all rendered.
51
+ const start = bau.state(0);
52
+ const end = bau.state(0);
53
+ let observer;
54
+
55
+ const update = (element) => {
56
+ const first = Math.floor(element.scrollTop / itemHeight);
57
+ const last = Math.ceil(
58
+ (element.scrollTop + element.clientHeight) / itemHeight
59
+ );
60
+ if (first < start.val || last > end.val) {
61
+ start.val = Math.max(0, first - overscan);
62
+ end.val = last + overscan;
63
+ }
64
+ };
65
+
66
+ return div(
67
+ {
68
+ // Scrolled by the keyboard: arrows, page up and down, home, end
69
+ tabindex: 0,
70
+ ...props,
71
+ class: [
72
+ "virtualList",
73
+ className,
74
+ color,
75
+ variant,
76
+ size,
77
+ options.class,
78
+ props.class,
79
+ ],
80
+ onscroll: (event) => update(event.currentTarget),
81
+ bauMounted: ({ element }) => {
82
+ // The height of the list, known once in the document, and when it
83
+ // changes
84
+ observer = new window.ResizeObserver(() => update(element));
85
+ observer.observe(element);
86
+ },
87
+ bauUnmounted: () => observer.disconnect(),
88
+ },
89
+ () => {
90
+ const all = items.val;
91
+ const last = Math.min(end.val, all.length);
92
+ const rows = [];
93
+ for (let index = start.val; index < last; index++) {
94
+ rows.push(
95
+ li(
96
+ {
97
+ style: `top: ${index * itemHeight}px; height: ${itemHeight}px`,
98
+ // The position of the row in the whole list, for the screen
99
+ // readers
100
+ "aria-setsize": all.length,
101
+ "aria-posinset": index + 1,
102
+ },
103
+ Item(all[index], index)
104
+ )
105
+ );
106
+ }
107
+ return ul({ style: `height: ${all.length * itemHeight}px` }, rows);
108
+ }
109
+ );
110
+ };
111
+ }