@threadlabs/looma 0.15.1 → 0.15.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.
@@ -5,7 +5,8 @@
5
5
  Neutral looks the same in solid and subtle.</prop>
6
6
  <prop name="tone" type="neutral | accent | info | success | warning | danger" default="neutral"
7
7
  >Which colour the badge speaks in. neutral is a quiet grey for plain labels; accent draws the eye in the accent colour; info, success, warning, and danger
8
- mark a status, so match the tone to what the badge says.</prop>
8
+ mark a status, so match the tone to what the badge says. For a category rather than a status, set the --ui-badge-color hook on the badge instead: any CSS
9
+ colour, which overrides the tone.</prop>
9
10
  <prop name="shape" type="pill | tag" default="pill"
10
11
  >Silhouette. pill is rounded at both ends; tag is a label: flat at the start and coming to a point at the end, for a tag or a chosen chip.</prop>
11
12
  </defs>
@@ -16,6 +17,10 @@
16
17
  syntax: "*";
17
18
  inherits: false;
18
19
  }
20
+ @property --ui-badge-color {
21
+ syntax: "*";
22
+ inherits: false;
23
+ }
19
24
  @property --ui-badge-font-size {
20
25
  syntax: "*";
21
26
  inherits: false;
@@ -58,17 +63,26 @@
58
63
  --_badge-text: var(--ui-text-secondary);
59
64
  /* Every tone's edge is its fill, so it is unseen until forced colors draw it. */
60
65
  --_badge-border: var(--ui-surface-subtle);
61
- --_badge-outline-surface: var(--ui-badge-surface, var(--_badge-surface));
66
+ /* --ui-badge-color derives a wash and an ink from one colour, between the tone and the explicit
67
+ surface, text, and border hooks. Each value is invalid, so the tone shows, while it is unset. The
68
+ mixes keep 4.5:1 text contrast for any colour, in a light theme or a dark one. */
69
+ --_ui-badge-color: var(--ui-badge-color);
70
+ --_badge-color-wash: color-mix(in oklab, var(--_ui-badge-color) 15%, var(--ui-surface-default));
71
+ --_badge-color-ink: color-mix(in oklab, var(--_ui-badge-color) 35%, var(--ui-text-primary));
72
+ --_badge-color-surface: var(--_badge-color-wash);
73
+ --_badge-color-border: var(--_badge-color-wash);
74
+ --_badge-color-text: var(--_badge-color-ink);
75
+ --_badge-outline-surface: var(--ui-badge-surface, var(--_badge-color-surface, var(--_badge-surface)));
62
76
 
63
77
  display: inline-flex;
64
78
  align-items: center;
65
79
  justify-content: center;
66
80
  max-width: 100%;
67
81
  padding: var(--ui-badge-padding-block, var(--ui-space-0-5)) var(--ui-badge-padding-inline, var(--ui-space-2));
68
- border: 1px solid var(--ui-badge-border, var(--_badge-border));
82
+ border: 1px solid var(--ui-badge-border, var(--_badge-color-border, var(--_badge-border)));
69
83
  border-radius: var(--ui-radius-round);
70
84
  background: var(--_badge-outline-surface);
71
- color: var(--ui-badge-text, var(--_badge-text));
85
+ color: var(--ui-badge-text, var(--_badge-color-text, var(--_badge-text)));
72
86
  font-family: var(--ui-font-family-sans);
73
87
  font-size: var(--ui-badge-font-size, var(--ui-font-size-sm));
74
88
  font-weight: var(--ui-badge-font-weight, var(--ui-font-medium));
@@ -150,10 +164,21 @@
150
164
  --_badge-text: var(--ui-info-subtle-text, var(--ui-info-solid));
151
165
  }
152
166
 
167
+ /* A solid colour fills with the ink. Its text is the page surface, mixed at 0% only so that it too is
168
+ invalid while the hook is unset. */
169
+ :host-state([variant="solid"]) {
170
+ --_badge-color-surface: var(--_badge-color-ink);
171
+ --_badge-color-border: var(--_badge-color-ink);
172
+ --_badge-color-text: color-mix(in oklab, var(--_ui-badge-color) 0%, var(--ui-surface-default));
173
+ }
174
+
153
175
  :host-state([variant="outline"]) {
154
176
  --_badge-surface: var(--ui-surface-default);
155
177
  --_badge-border: var(--ui-border-strong);
156
178
  --_badge-text: var(--ui-text-secondary);
179
+ /* An outline colour keeps the surface and draws its edge and text in the ink. */
180
+ --_badge-color-surface: initial;
181
+ --_badge-color-border: var(--_badge-color-ink);
157
182
  }
158
183
 
159
184
  :host-state([variant="outline"][tone="accent"]) {
@@ -204,7 +229,7 @@
204
229
  :host-state([variant="outline"][shape="tag"]) {
205
230
  position: relative;
206
231
  isolation: isolate;
207
- background: var(--ui-badge-border, var(--_badge-border));
232
+ background: var(--ui-badge-border, var(--_badge-color-border, var(--_badge-border)));
208
233
  }
209
234
 
210
235
  :host-state([variant="outline"][shape="tag"])::before {
@@ -16,7 +16,7 @@
16
16
  this value.</prop>
17
17
  <prop
18
18
  name="items"
19
- type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }))"
19
+ type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }))"
20
20
  >The selected items in multiple mode, as JSON; a named combobox submits each one's value. A form reset returns to these items, or to none when unset.</prop>
21
21
  <prop name="selectedValues" type="list(string)"
22
22
  >The selected option values in multiple mode, when the consumer controls the selection. Once set, the consumer owns it: each value shows as a badge with its
@@ -73,7 +73,7 @@
73
73
  it.</prop>
74
74
  <state
75
75
  name="internalItems"
76
- type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }))"
76
+ type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }))"
77
77
  :value="[]"
78
78
  ></state>
79
79
  <state name="raw" :value="''"></state>
@@ -82,7 +82,7 @@
82
82
  <state name="expanded" :value="false"></state>
83
83
  <state
84
84
  name="rows"
85
- type="list(object({ id: string, value: string, label: string, group?: string, disabled: boolean, selected: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }))"
85
+ type="list(object({ id: string, value: string, label: string, group?: string, disabled: boolean, selected: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }))"
86
86
  :value="[]"
87
87
  ></state>
88
88
  <state name="active" :value="-1"></state>
@@ -97,7 +97,7 @@
97
97
  <state name="submitted" :value="''"></state>
98
98
  <state
99
99
  name="groups"
100
- type="list(object({ name: string, role: group | presentation, label: string | null, rows: list(object({ id: string, value: string, label: string, group?: string, disabled: boolean, selected: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }), index: integer, labelledBy: string | null, detail: string | null })) }))"
100
+ type="list(object({ name: string, role: group | presentation, label: string | null, rows: list(object({ id: string, value: string, label: string, group?: string, disabled: boolean, selected: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }), index: integer, labelledBy: string | null, detail: string | null })) }))"
101
101
  :value="[]"
102
102
  ></state>
103
103
  <state name="creatable" :value="false"></state>
@@ -108,15 +108,15 @@
108
108
  <event name="query-change" type="object({ query: string, display: string, trigger: keyboard | pointer | programmatic })"></event>
109
109
  <event
110
110
  name="value-change"
111
- type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic }) | list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }))"
111
+ type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic }) | list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }))"
112
112
  ></event>
113
113
  <event
114
114
  name="free-entry"
115
- type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic })"
115
+ type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic })"
116
116
  ></event>
117
117
  <event
118
118
  name="create-entry"
119
- type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic })"
119
+ type="object({ value: string | null, query: string, option: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }) | null, kind: selection | clear | free-entry | create, trigger: keyboard | pointer | programmatic })"
120
120
  ></event>
121
121
  <event
122
122
  name="validation-change"
@@ -124,15 +124,15 @@
124
124
  ></event>
125
125
  <event
126
126
  name="options-change"
127
- type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }))"
127
+ type="list(object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }))"
128
128
  ></event>
129
129
  <event
130
130
  name="add-item"
131
- type="object({ item: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }), index: integer, trigger: keyboard | pointer | programmatic })"
131
+ type="object({ item: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }), index: integer, trigger: keyboard | pointer | programmatic })"
132
132
  ></event>
133
133
  <event
134
134
  name="remove-item"
135
- type="object({ item: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger }) }), index: integer, trigger: keyboard | pointer | programmatic })"
135
+ type="object({ item: object({ id: string, value: string, label: string, group?: string, disabled?: boolean, description?: string, tag?: object({ label: string, tone?: neutral | accent | info | success | warning | danger, color?: string }) }), index: integer, trigger: keyboard | pointer | programmatic })"
136
136
  ></event>
137
137
  <event name="create-item" type="object({ query: string, trigger: keyboard | pointer | programmatic })"></event>
138
138
  <event name="selected-values-change" type="object({ selectedValues: list(string), trigger: keyboard | pointer | programmatic })"></event>
@@ -246,7 +246,10 @@
246
246
  <span $if="row.detail" class="detail">
247
247
  <span class="line">
248
248
  <span class="primary" :id="format('%s-option-%s-label', uid, row.index)" $value="row.label"></span>
249
- <ui-badge $if="row.tag" :tone="row.tag.tone"><span :id="format('%s-option-%s-tag', uid, row.index)" $value="row.tag.label"></span></ui-badge>
249
+ <ui-badge $if="row.tag" :tone="row.tag.tone" style:--ui-badge-color="row.tag.color"><span
250
+ :id="format('%s-option-%s-tag', uid, row.index)"
251
+ $value="row.tag.label"
252
+ ></span></ui-badge>
250
253
  </span>
251
254
  <span $if="row.description" class="description" :id="format('%s-option-%s-description', uid, row.index)" $value="row.description"></span>
252
255
  </span>
@@ -9,7 +9,7 @@ let comboboxes = 0;
9
9
  // it would run into its label before JavaScript. A row without them keeps the declared shape exactly.
10
10
  function authoredOptions(container) {
11
11
  return Array.from(container.querySelectorAll("option")).map((option, index) => {
12
- const { description, tag, tagTone } = option.dataset;
12
+ const { description, tag, tagTone, tagColor } = option.dataset;
13
13
  return {
14
14
  id: option.id || option.value || `option-${index}`,
15
15
  value: option.value,
@@ -17,7 +17,7 @@ function authoredOptions(container) {
17
17
  group: option.closest("optgroup")?.label || undefined,
18
18
  disabled: option.disabled,
19
19
  ...(description ? { description } : {}),
20
- ...(tag ? { tag: tagTone ? { label: tag, tone: tagTone } : { label: tag } } : {}),
20
+ ...(tag ? { tag: { label: tag, ...(tagTone ? { tone: tagTone } : {}), ...(tagColor ? { color: tagColor } : {}) } } : {}),
21
21
  };
22
22
  });
23
23
  }
@@ -11,7 +11,10 @@
11
11
  adds no visual marker; show one in the label if the form needs it.</prop>
12
12
  </defs>
13
13
  <div>
14
- <div class="label"><slot name="label"></slot></div>
14
+ <div class="label">
15
+ <slot name="label"></slot>
16
+ <span class="label-action"><slot name="label-action"></slot></span>
17
+ </div>
15
18
  <slot></slot>
16
19
  <div class="help"><slot name="help"></slot></div>
17
20
  <div class="error"><slot name="error"></slot></div>
@@ -52,6 +55,25 @@
52
55
  font-size: var(--ui-font-size-sm);
53
56
  }
54
57
 
58
+ /* A label action, such as a small help button, sits after the label text in a box one line
59
+ tall, centred on the first line and overflowing it. A button taller than a line of label
60
+ text then never makes this field's label row taller than its neighbours' in a grid row. */
61
+ .label:has(> .label-action > *) {
62
+ display: flex;
63
+ align-items: start;
64
+ gap: var(--ui-space-1);
65
+ }
66
+
67
+ .label-action {
68
+ display: flex;
69
+ align-items: unsafe center;
70
+ block-size: 1lh;
71
+ }
72
+
73
+ .label-action:not(:has(> *)) {
74
+ display: none;
75
+ }
76
+
55
77
  .help {
56
78
  color: var(--ui-text-muted);
57
79
  font-size: var(--ui-font-size-sm);