@threadlabs/looma 0.10.10 → 0.10.11
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/components/ui-tree-item/ui-tree-item.html +39 -29
- package/components/ui-tree-item/ui-tree-item.js +17 -11
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/styles/ui-tree-item.css +44 -32
- package/vanilla/UiTreeItem.js +1 -1
- package/vue/UiTreeItem.vue +49 -29
- package/vue/chunks/UiTreeItem.js +15 -5
- package/vue/components.css +103 -87
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
<button class="disclosure" $ref="disclosure" type="button" :disabled="disabled" :hidden="not isContainer">
|
|
86
86
|
<span class="disclosure-icon" aria-hidden="true"></span>
|
|
87
87
|
</button>
|
|
88
|
-
<span class="leading"><slot name="leading"></slot></span>
|
|
89
|
-
<span class="label"><span class="label-text" $ref="labelText"><slot name="label"><template $value="label"></template></slot></span></span>
|
|
88
|
+
<span class="leading" $ref="leading"><slot name="leading"></slot></span>
|
|
89
|
+
<span class="label" $ref="label"><span class="label-text" $ref="labelText"><slot name="label"><template $value="label"></template></slot></span></span>
|
|
90
90
|
<span class="actions" $ref="actions"><slot name="actions"></slot></span>
|
|
91
91
|
<span class="drop-indicator row-drop-indicator" aria-hidden="true"></span>
|
|
92
92
|
</div>
|
|
@@ -221,6 +221,9 @@
|
|
|
221
221
|
block-size: 1em;
|
|
222
222
|
margin-inline-start: var(--ui-space-1);
|
|
223
223
|
color: var(--ui-text-muted);
|
|
224
|
+
/* Above the label, so a sliding name passes under the icon. */
|
|
225
|
+
position: relative;
|
|
226
|
+
z-index: 1;
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
.leading:empty {
|
|
@@ -248,6 +251,9 @@
|
|
|
248
251
|
/* The cell clips: a name longer than the row slides inside it rather than over its icons. */
|
|
249
252
|
overflow: hidden;
|
|
250
253
|
padding: var(--ui-tree-item-label-padding-block, var(--ui-space-1)) var(--ui-tree-item-label-padding-inline, var(--ui-space-2));
|
|
254
|
+
/* The length of the fade before the controls. The label's one flex child lays out no gap; this
|
|
255
|
+
is where the controller reads the length in pixels to stop a sliding name before the fade. */
|
|
256
|
+
column-gap: var(--ui-space-3);
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
/* Slotted label content fills the cell, so a link is the row's hit area rather than sizing to
|
|
@@ -268,6 +274,27 @@
|
|
|
268
274
|
min-inline-size: 0;
|
|
269
275
|
}
|
|
270
276
|
|
|
277
|
+
/* The controls sit over the label's end, so the text fades out where they begin. The fade is
|
|
278
|
+
the truncation mark while it shows: an ellipsis under it would read as a second one. */
|
|
279
|
+
.row:hover > .label,
|
|
280
|
+
.row:focus-within > .label {
|
|
281
|
+
text-overflow: clip;
|
|
282
|
+
mask-image: linear-gradient(
|
|
283
|
+
to right,
|
|
284
|
+
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
285
|
+
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.row:hover > .label:dir(rtl),
|
|
290
|
+
.row:focus-within > .label:dir(rtl) {
|
|
291
|
+
mask-image: linear-gradient(
|
|
292
|
+
to left,
|
|
293
|
+
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
294
|
+
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
271
298
|
/* A hovered row reads its whole name: the label slides far enough to show the end, waits
|
|
272
299
|
there, and comes back. Only when it actually overflows — the controller measures by how
|
|
273
300
|
much — after the controls have taken their place over its end — and hands over the distance
|
|
@@ -279,13 +306,17 @@
|
|
|
279
306
|
will-change: transform;
|
|
280
307
|
}
|
|
281
308
|
|
|
282
|
-
/*
|
|
283
|
-
|
|
309
|
+
/* This comes after the hover fade, which it replaces at the same specificity. While the name
|
|
310
|
+
slides, the label reaches back under the icon (the controller measures how far) with its text
|
|
311
|
+
where it was, and fades out across that stretch, gone by the icon's middle: the name slips
|
|
312
|
+
under the icon rather than stopping at a hard edge beside it. */
|
|
284
313
|
.row[data-ui-marquee] > .label {
|
|
314
|
+
margin-inline-start: calc(-1 * var(--_marquee-lead, 0px));
|
|
315
|
+
padding-inline-start: calc(var(--_marquee-lead, 0px) + var(--ui-tree-item-label-padding-inline, var(--ui-space-2)));
|
|
285
316
|
mask-image: linear-gradient(
|
|
286
317
|
to right,
|
|
287
|
-
transparent
|
|
288
|
-
#000 var(--ui-space-2),
|
|
318
|
+
transparent calc(var(--_marquee-lead, 0px) / 2),
|
|
319
|
+
#000 calc(var(--_marquee-lead, 0px) + var(--ui-tree-item-label-padding-inline, var(--ui-space-2))),
|
|
289
320
|
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
290
321
|
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
291
322
|
);
|
|
@@ -294,8 +325,8 @@
|
|
|
294
325
|
.row[data-ui-marquee] > .label:dir(rtl) {
|
|
295
326
|
mask-image: linear-gradient(
|
|
296
327
|
to left,
|
|
297
|
-
transparent
|
|
298
|
-
#000 var(--ui-space-2),
|
|
328
|
+
transparent calc(var(--_marquee-lead, 0px) / 2),
|
|
329
|
+
#000 calc(var(--_marquee-lead, 0px) + var(--ui-tree-item-label-padding-inline, var(--ui-space-2))),
|
|
299
330
|
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
300
331
|
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
301
332
|
);
|
|
@@ -318,27 +349,6 @@
|
|
|
318
349
|
}
|
|
319
350
|
}
|
|
320
351
|
|
|
321
|
-
/* The controls sit over the label's end, so the text fades out where they begin. The fade is
|
|
322
|
-
the truncation mark while it shows: an ellipsis under it would read as a second one. */
|
|
323
|
-
.row:hover > .label,
|
|
324
|
-
.row:focus-within > .label {
|
|
325
|
-
text-overflow: clip;
|
|
326
|
-
mask-image: linear-gradient(
|
|
327
|
-
to right,
|
|
328
|
-
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
329
|
-
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.row:hover > .label:dir(rtl),
|
|
334
|
-
.row:focus-within > .label:dir(rtl) {
|
|
335
|
-
mask-image: linear-gradient(
|
|
336
|
-
to left,
|
|
337
|
-
#000 calc(100% - var(--_tree-actions-width, 1.75rem) - var(--ui-space-3)),
|
|
338
|
-
transparent calc(100% - var(--_tree-actions-width, 1.75rem))
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
352
|
.row:hover > .label > :slotted(*),
|
|
343
353
|
.row:focus-within > .label > :slotted(*) {
|
|
344
354
|
text-overflow: clip;
|
|
@@ -19,7 +19,7 @@ const CONTROLS = [
|
|
|
19
19
|
|
|
20
20
|
export default function controller(host) {
|
|
21
21
|
const element = host.element;
|
|
22
|
-
const { row, disclosure, children, actions, labelText } = host.refs;
|
|
22
|
+
const { row, disclosure, children, leading, label, actions, labelText } = host.refs;
|
|
23
23
|
// Touch use enlarges rows and hides drag handles (see the template's styles).
|
|
24
24
|
trackInputModality(element.ownerDocument);
|
|
25
25
|
const childItems = () => Array.from(children?.children ?? [])
|
|
@@ -98,23 +98,28 @@ export default function controller(host) {
|
|
|
98
98
|
const stop = host.effect(apply);
|
|
99
99
|
apply();
|
|
100
100
|
/**
|
|
101
|
-
* A hovered row reads its whole name. The
|
|
102
|
-
* width
|
|
103
|
-
*
|
|
101
|
+
* A hovered row reads its whole name. The label box always fills the row, so the name is measured
|
|
102
|
+
* at its own width; it has to end where the fade before the controls begins, since the controls
|
|
103
|
+
* overlay the label's end rather than taking width from it.
|
|
104
104
|
*/
|
|
105
105
|
const MARQUEE_SPEED = 36; // CSS pixels per second.
|
|
106
|
-
const MARQUEE_SLACK = 4; // So the tail clears the edge rather than stopping on it.
|
|
107
106
|
// The tree sets this for its items; an item's own prop overrides it either way.
|
|
108
107
|
const marqueeWanted = () => host.state.marquee
|
|
109
108
|
|| getComputedStyle(element).getPropertyValue("--ui-tree-item-marquee").trim() === "1";
|
|
110
109
|
const startMarquee = () => {
|
|
111
|
-
if (!labelText || !marqueeWanted()) return;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
110
|
+
if (!labelText || !label || !marqueeWanted()) return;
|
|
111
|
+
labelText.style.flex = "none";
|
|
112
|
+
labelText.style.inlineSize = "max-content";
|
|
113
|
+
const text = labelText.getBoundingClientRect();
|
|
114
|
+
labelText.style.flex = labelText.style.inlineSize = "";
|
|
115
|
+
const cell = label.getBoundingClientRect();
|
|
116
|
+
const icon = leading?.getBoundingClientRect();
|
|
117
|
+
const stop = (actions?.offsetWidth ?? 0) + parseFloat(getComputedStyle(label).columnGap);
|
|
117
118
|
const rightToLeft = getComputedStyle(element).direction === "rtl";
|
|
119
|
+
const distance = Math.ceil(rightToLeft ? cell.left + stop - text.left : text.right - (cell.right - stop));
|
|
120
|
+
if (distance <= 0) return;
|
|
121
|
+
const lead = icon?.width ? (rightToLeft ? icon.right - cell.right : cell.left - icon.left) : 0;
|
|
122
|
+
row.style.setProperty("--_marquee-lead", `${Math.max(0, lead)}px`);
|
|
118
123
|
row.style.setProperty("--_marquee-distance", `${rightToLeft ? distance : -distance}px`);
|
|
119
124
|
row.style.setProperty(
|
|
120
125
|
"--_marquee-duration",
|
|
@@ -124,6 +129,7 @@ export default function controller(host) {
|
|
|
124
129
|
};
|
|
125
130
|
const stopMarquee = () => {
|
|
126
131
|
delete row.dataset.uiMarquee;
|
|
132
|
+
row.style.removeProperty("--_marquee-lead");
|
|
127
133
|
row.style.removeProperty("--_marquee-distance");
|
|
128
134
|
row.style.removeProperty("--_marquee-duration");
|
|
129
135
|
};
|