@threadlabs/looma 0.52.3 → 0.52.5

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.
@@ -273,6 +273,7 @@
273
273
 
274
274
  /* Projected marks may be images or composed elements, including block-level image resets. */
275
275
  .label:has(> *) {
276
+ max-inline-size: 100%;
276
277
  display: inline-flex !important;
277
278
  align-items: center !important;
278
279
  gap: var(--ui-space-2) !important;
@@ -832,7 +833,8 @@
832
833
  /* Link: an inline text action. No box, padding, or minimum height (inline targets are exempt under
833
834
  WCAG 2.5.8); the inherited font; an underline that strengthens on hover; a visible focus ring. */
834
835
  :host[data-appearance="link"] {
835
- display: inline !important;
836
+ display: inline-block !important;
837
+ vertical-align: baseline;
836
838
  min-block-size: 0;
837
839
  padding: 0 !important;
838
840
  border: 0;
@@ -10,11 +10,12 @@
10
10
  <defs>
11
11
  <prop name="href" type="string" default="">The link's destination, shown when there is no label.</prop>
12
12
  <prop name="openHref" type="string" default=""
13
- >The address Open link opens in a new tab; without it the card offers no Open link. The editor passes the destination only when it is an http, https,
14
- mailto, tel, or relative address.</prop>
13
+ >The navigable destination for the label and Open link. Same-origin addresses open in the current tab; other destinations open in a new tab. Without it the
14
+ destination is plain text. The editor passes the destination only when it is an http, https, mailto, tel, or relative address.</prop>
15
15
  <prop name="label" type="string" default="">The resolved destination's name, such as a page title, shown in place of the address.</prop>
16
16
  <prop name="detail" type="string" default="">A second line under the label, such as where the destination lives.</prop>
17
17
  <prop name="targetLabel" type="string" default="Item">What a resolved destination is called, as in "Page: Guide" for a screen reader.</prop>
18
+ <state name="openTarget" type="string" value="_blank"></state>
18
19
  <state name="base" type="string" value="ui-editor-link-card"></state>
19
20
  <computed name="resolved" from="$label != ''"></computed>
20
21
  <computed name="shown" from="{ true: $label, false: $href }[concat($resolved)]"></computed>
@@ -24,10 +25,34 @@
24
25
  <div>
25
26
  <ui-card variant="elevated" padding="xs" size="sm">
26
27
  <ui-cluster gap="xs" wrap="nowrap" role="group" aria-label="Link actions">
27
- <ui-icon from:name="{ true: 'file-text', false: 'link' }[concat($resolved)]"></ui-icon>
28
- <ui-stack gap="none" fill from:title="$href" from:aria-label="concat({ true: $targetLabel, false: 'URL' }[concat($resolved)], ': ', $shown)">
29
- <ui-text as="strong" size="sm" weight="medium" font="sans" truncate>{$shown}</ui-text>
30
- <ui-text $if="$detail != ''" as="small" size="xs" tone="secondary" font="sans" truncate>{$detail}</ui-text>
28
+ <ui-stack fill gap="none">
29
+ <ui-button
30
+ $if="$openHref != ''"
31
+ variant="link"
32
+ tone="neutral"
33
+ stretch
34
+ align="start"
35
+ from:href="$openHref"
36
+ from:target="$openTarget"
37
+ rel="noopener noreferrer"
38
+ from:title="$href"
39
+ from:aria-label="concat({ true: $targetLabel, false: 'URL' }[concat($resolved)], ': ', $shown)"
40
+ >
41
+ <ui-cluster gap="xs" wrap="nowrap">
42
+ <ui-icon from:name="{ true: 'file-text', false: 'link' }[concat($resolved)]"></ui-icon>
43
+ <ui-stack gap="none" fill>
44
+ <ui-text as="strong" size="sm" weight="medium" font="sans" truncate>{$shown}</ui-text>
45
+ <ui-text $if="$detail != ''" as="small" size="xs" tone="secondary" font="sans" truncate>{$detail}</ui-text>
46
+ </ui-stack>
47
+ </ui-cluster>
48
+ </ui-button>
49
+ <ui-cluster $if="$openHref = ''" gap="xs" wrap="nowrap">
50
+ <ui-icon from:name="{ true: 'file-text', false: 'link' }[concat($resolved)]"></ui-icon>
51
+ <ui-stack gap="none" fill from:title="$href" from:aria-label="concat({ true: $targetLabel, false: 'URL' }[concat($resolved)], ': ', $shown)">
52
+ <ui-text as="strong" size="sm" weight="medium" font="sans" truncate>{$shown}</ui-text>
53
+ <ui-text $if="$detail != ''" as="small" size="xs" tone="secondary" font="sans" truncate>{$detail}</ui-text>
54
+ </ui-stack>
55
+ </ui-cluster>
31
56
  </ui-stack>
32
57
  <template $if="$openHref != ''">
33
58
  <ui-button
@@ -36,7 +61,7 @@
36
61
  tone="neutral"
37
62
  size="sm"
38
63
  from:href="$openHref"
39
- target="_blank"
64
+ from:target="$openTarget"
40
65
  rel="noopener noreferrer"
41
66
  aria-label="Open link"
42
67
  ><ui-icon name="external-link"></ui-icon></ui-button>
@@ -3,6 +3,15 @@
3
3
  export function connect(host) {
4
4
  const element = host.element;
5
5
  if (host.state.base === "ui-editor-link-card") host.state.base = `ui-editor-link-card-${Math.random().toString(36).slice(2, 11)}`;
6
+ const stop = host.effect(() => {
7
+ const href = host.props.openHref.value;
8
+ const base = element.ownerDocument.baseURI;
9
+ try {
10
+ host.state.openTarget = new URL(href, base).origin === element.ownerDocument.location.origin ? "_self" : "_blank";
11
+ } catch {
12
+ host.state.openTarget = "_blank";
13
+ }
14
+ });
6
15
  const action = (event) => {
7
16
  const control = event.target.closest?.("[data-link-action]");
8
17
  return control && element.contains(control) ? control.dataset.linkAction : null;
@@ -16,6 +25,7 @@ export function connect(host) {
16
25
  element.addEventListener("pointerdown", onPointerDown);
17
26
  element.addEventListener("click", onClick);
18
27
  return () => {
28
+ stop();
19
29
  element.removeEventListener("pointerdown", onPointerDown);
20
30
  element.removeEventListener("click", onClick);
21
31
  };