@threadlabs/looma 0.49.1 → 0.49.2

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.
@@ -6,6 +6,8 @@
6
6
  >Ordered states with a value, readable label and Looma icon name. Activation advances to the next state and wraps.</prop>
7
7
  <prop name="index" type="number" default="0">Initial or externally selected zero-based state. The first state is the default.</prop>
8
8
  <prop name="label" type="string" default="State">What the button changes, such as Appearance. The selected state is included in its accessible name.</prop>
9
+ <prop name="description" type="string" default="Activate to choose the next state.">Accessible instruction for cycling; accepts localized reader text.</prop>
10
+ <prop name="emptyLabel" type="string" default="No choices">Selected-state label while no choices are available.</prop>
9
11
  <prop name="size" type="keyword" values="sm, md, lg" default="md">Uses IconButton's compact visible sizes and adjustable invisible touch area.</prop>
10
12
  <prop name="variant" type="keyword" values="ghost, outline, solid" default="outline">Uses IconButton's standard emphasis.</prop>
11
13
  <prop name="disabled" type="boolean" default="false">Prevents cycling while keeping the selected state visible.</prop>
@@ -14,13 +16,13 @@
14
16
  <event name="change" type="object"><prop name="value" type="string" required></prop><prop name="index" type="number" required></prop></event>
15
17
  </defs>
16
18
  <span><ui-icon-button
17
- from:label="concat($label, ': ', default($selected.label, 'No choices'))"
18
- from:title="concat($label, ': ', default($selected.label, 'No choices'))"
19
+ from:label="concat($label, ': ', default($selected.label, $emptyLabel))"
20
+ from:title="concat($label, ': ', default($selected.label, $emptyLabel))"
19
21
  from:size="$size"
20
22
  from:variant="$variant"
21
23
  from:disabled="$disabled or $items.length &lt; 2"
22
24
  tone="neutral"
23
- aria-description="Activate to choose the next state."
25
+ from:aria-description="$description"
24
26
  >
25
27
  <ui-icon from:name="default($selected.icon, '')"></ui-icon>
26
28
  </ui-icon-button></span>
@@ -5,11 +5,12 @@ export function connect(host) {
5
5
  const signature = JSON.stringify([host.props.items.value, host.props.index.value]);
6
6
  if (signature === external) return;
7
7
  external = signature;
8
+ const items = host.props.items.value ?? [];
8
9
  const index = Math.trunc(Number(host.props.index.value));
9
- host.state.current = Number.isFinite(index) && index >= 0 && index < host.props.items.value.length ? index : 0;
10
+ host.state.current = Number.isFinite(index) && index >= 0 && index < items.length ? index : 0;
10
11
  });
11
12
  const cycle = () => {
12
- const items = host.props.items.value;
13
+ const items = host.props.items.value ?? [];
13
14
  if (host.props.disabled.value || items.length < 2) return;
14
15
  host.state.current = (host.state.current + 1) % items.length;
15
16
  host.dispatch('change', { value: items[host.state.current].value, index: host.state.current });
@@ -33,7 +33,7 @@
33
33
  border-radius: var(--ui-selection-radius);
34
34
  color: inherit;
35
35
  cursor: pointer;
36
- text-align: left;
36
+ text-align: start;
37
37
  transition: background-color var(--ui-motion-fast) var(--ui-motion-ease);
38
38
  }
39
39