@threadlabs/looma 0.49.1 → 0.49.3

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
@@ -1,13 +1,17 @@
1
1
  # @threadlabs/looma
2
2
 
3
3
  Looma's components are authored as HTML Next definitions. The HTML Next Vite adapter
4
- converts those definitions in Vue, React and Svelte applications.
4
+ converts those definitions in Vue, React and Svelte applications. In an existing
5
+ Vue/Vite project:
5
6
 
6
7
  ```sh
7
- pnpm add '@threadlabs/looma@>=0.49.0' vue
8
- pnpm add -D '@nextwebwg/html-next-unplugin@>=1.0.0-alpha.76' @vitejs/plugin-vue vite
8
+ pnpm add @threadlabs/looma
9
+ pnpm add -D @nextwebwg/html-next-unplugin
9
10
  ```
10
11
 
12
+ Looma installs its HTML Next runtime automatically. For a new Vue project, also
13
+ install `vue`, `@vitejs/plugin-vue`, `vite`, `vue-tsc` and `typescript`.
14
+
11
15
  ```ts
12
16
  // vite.config.ts
13
17
  import { defineConfig } from "vite";
@@ -34,7 +38,8 @@ The framework-neutral `trackInputModality` helper is available from
34
38
  For React, use `target: "react"` before `react()` from `@vitejs/plugin-react`.
35
39
  For Svelte 5, use `target: "svelte"` before `svelte()` from
36
40
  `@sveltejs/vite-plugin-svelte`. Both import the same prefixed names from
37
- `@threadlabs/looma`. Use HTML Next runtime alpha.74 or later and Vite adapter alpha.76 or later; see the [loading guide](https://threadlabs.studio/looma/getting-started/).
41
+ `@threadlabs/looma`. See the [loading guide](https://threadlabs.studio/looma/getting-started/)
42
+ for framework setup and compatibility requirements.
38
43
 
39
44
  The document editor, compact field, and compact renderer use the same source imports:
40
45
 
@@ -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